diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..0daa1447 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,40 @@ +# These settings are for any web project + +# Handle line endings automatically for files detected as text +# and leave all files detected as binary untouched. +* text=auto + +# Force the following filetypes to have unix eols, so Windows does not break them +*.* text eol=lf + +# Windows forced line-endings +/.idea/* text eol=crlf +*.bat text eol=crlf + +# +## These files are binary and should be left untouched +# + +# (binary is a macro for -text -diff) +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.mov binary +*.mp4 binary +*.mp3 binary +*.flv binary +*.fla binary +*.swf binary +*.gz binary +*.zip binary +*.7z binary +*.ttf binary +*.eot binary +*.woff binary +*.pyc binary +*.pdf binary +*.ez binary +*.bz2 binary +*.swp binary \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..44003a74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +# ignore all rom files +baseroms/* +*.z64 +*.n64 +*.v64 + +#compiled or ripped asm +asm/* +asm +build/* +build/ + +#binaries ripped from the ROMs +assets/ +assets/* +bin/ +bin/* + + +# This folder will hold modified asset binaries +# these assets will override the original game +# assets in the bin/ at compile time. +mod/ +mod/* + + +#compiled object files +*.slo +*.lo +*.o +*.obj + +#Precompiled Headers +*.gch +*.pch + +#compiled dynamic libraries +*.so +*.dylib +*.dll + +#static libraries +*.lai +*.la +*.a +*.lib + +#misc +__pycache__/ +*__pycache__/ +expected/ +.*/ +*.ld +*/*.ld +*.map +*/*.map +*auto.txt +*_auto.*.txt +*.*auto.txt +*/.splat_cache +.splat_cache +.splat_cache* +diff_settings.py +symbol_addrs.us.txt +ctx.c +!tools/build \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..d1145cb6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tools/n64splat"] + path = tools/n64splat + url = https://github.com/ethteck/splat.git +[submodule "tools/asm-processor"] + path = tools/asm-processor + url = https://github.com/simonlindholm/asm-processor.git diff --git a/Build Docker Image.bat b/Build Docker Image.bat new file mode 100644 index 00000000..699075cd --- /dev/null +++ b/Build Docker Image.bat @@ -0,0 +1,3 @@ +@echo off +docker build . -t donkeykong64 +pause \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..52896518 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:21.04 as build + +RUN apt-get update + +RUN apt-get install -y \ + binutils-mips-linux-gnu \ + build-essential \ + gcc-mips-linux-gnu \ + less \ + libglib2.0 \ + python3 \ + python3-pip \ + unzip \ + wget \ + libssl-dev + +RUN python3 -m pip install \ + capstone pylibyaml pyyaml pycparser \ + colorama ansiwrap watchdog python-Levenshtein cxxfilt \ + python-ranges \ + pypng anybadge + +RUN mkdir /donkeykong64 +WORKDIR /donkeykong64 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..0e259d42 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..822fd418 --- /dev/null +++ b/Makefile @@ -0,0 +1,471 @@ +### Configuration ### +BASENAME = donkeykong64 +VERSION ?= us + +### Tools ### + +# System tools +MKDIR := mkdir +CP := cp +CD := cd +RM := rm +CAT := cat +DIFF := diff +GUNZIP := gunzip + +# Build tools +CROSS = mips-linux-gnu- +CC = ido/ido5.3_recomp/cc #!!! CORRECT COMPILER TO BE DETERMINED +CPP = cpp +GCC = $(CROSS)gcc +AS = $(CROSS)as +LD = $(CROSS)ld +OBJDUMP = $(CROSS)objdump +OBJCOPY = $(CROSS)objcopy +PYTHON = python3 +GREP := grep -rl +SPLAT = $(PYTHON) tools/n64splat/split.py +PRINT := printf +ASM_PROCESSOR_DIR := tools/asm-processor +GZIP_DIR := tools/gzip-1.2.4 + +GZIP := $(GZIP_DIR)/gzip +ASM_PROCESSOR := $(PYTHON) $(ASM_PROCESSOR_DIR)/asm_processor.py +SPLAT_INPUTS := $(PYTHON) tools/splat_inputs.py +PROGRESS := $(PYTHON) tools/progress.py +PROGRESS_READ := $(PYTHON) tools/progress_read.py +PNG_TO_INCC := $(PYTHON) tools/build/img/build.py + +### Files and Directories ### + +# Inputs +OVERLAYS := global_asm menu multiplayer minecart race bonus water arcade jetpac boss + +# Creates a list of all the source files for the given overlay (e.g. BGS_C_SRCS) +# Appends that list to OVERLAY_C_FILES +define get_overlay_sources + $(1)_C_SRCS := $(filter $(SRC_ROOT)/$(1)/%,$(ALL_C_SRCS)) + $(1)_ASM_SRCS := $(filter $(ASM_ROOT)/$(1)/%,$(ALL_ASM_SRCS)) + $(1)_BINS := $(filter $(BIN_ROOT)/$(1)/%,$(ALL_BINS)) + $(1)_IMGS := $(filter $(BIN_ROOT)/$(1)/%,$(ALL_IMGS)) + OVERLAY_C_SRCS += $$($(1)_C_SRCS) + OVERLAY_ASM_SRCS += $$($(1)_ASM_SRCS) + OVERLAY_BINS += $$($(1)_BINS) + OVERLAY_IMGS += $$($(1)_IMGS) + # Overlay inputs + $(1)_NEW_FILES := $$(filter $(BIN_ROOT)/$(1)/%, $(NEW_BINS)) $$(filter $(BIN_ROOT)/$(1)/%, $(NEW_IMGS)) $$(filter $(SRC_ROOT)/$(1)/%, $(NEW_C_SRCS)) $$(filter $(ASM_ROOT)/$(1)/%, $(NEW_ASM_SRCS)) + OVERLAY_NEW_FILES += $$($(1)_NEW_FILES) +endef + +# Source files +SRC_ROOT := src +ASM_ROOT := asm +BIN_ROOT := bin +SUBYAML := subyaml +NONMATCHINGS := nonmatchings +NONMATCHING_DIR := $(ASM_ROOT)/$(NONMATCHINGS) +BUILD_ROOT := build +BUILD_DIR := $(BUILD_ROOT)/$(VERSION) +ALL_C_SRCS := $(shell find $(SRC_ROOT) -type f -iname '*.c' 2> /dev/null) +ALL_ASM_SRCS := $(filter-out $(ASM_ROOT)/$(NONMATCHINGS), $(shell find $(ASM_ROOT) -name $(NONMATCHINGS) -prune -o -iname '*.s' 2> /dev/null)) +ALL_BINS := $(shell find $(BIN_ROOT) -type f -iname '*.bin' 2> /dev/null) +ALL_IMGS := $(shell find $(BIN_ROOT) -type f -iname '*.png' 2> /dev/null) +# Files referenced in the splat files +YAML_CALL := $(SPLAT_INPUTS) $(BASENAME).$(VERSION).yaml $(addprefix $(SUBYAML)/, $(addsuffix .$(VERSION).yaml, $(OVERLAYS))) +YAML_SRCS := $(shell $(SPLAT_INPUTS) $(BASENAME).$(VERSION).yaml $(addprefix $(SUBYAML)/, $(addsuffix .$(VERSION).yaml, $(OVERLAYS)))) +YAML_C_SRCS := $(filter %.c, $(YAML_SRCS)) +YAML_ASM_SRCS := $(filter %.s, $(YAML_SRCS)) +YAML_BINS := $(filter %.bin, $(YAML_SRCS)) +YAML_IMGS := $(filter %.png, $(YAML_SRCS)) +# Files that need to be extracted +NEW_C_SRCS := $(filter-out $(ALL_C_SRCS), $(YAML_C_SRCS)) +NEW_ASM_SRCS := $(filter-out $(ALL_ASM_SRCS), $(YAML_ASM_SRCS)) +NEW_BINS := $(filter-out $(ALL_BINS), $(YAML_BINS)) +NEW_IMGS := $(filter-out $(ALL_IMGS), $(YAML_IMGS)) +NEW_FILES := $(NEW_C_SRCS) $(NEW_ASM_SRCS) $(NEW_BINS) $(NEW_IMGS) +$(foreach overlay,$(OVERLAYS),$(eval $(call get_overlay_sources,$(overlay)))) +# Files for the rom itself +MAIN_C_SRCS := $(filter-out $(OVERLAY_C_SRCS),$(ALL_C_SRCS)) +MAIN_ASM_SRCS := $(filter-out $(OVERLAY_ASM_SRCS),$(ALL_ASM_SRCS)) +MAIN_BINS := $(filter-out $(OVERLAY_BINS),$(ALL_BINS)) +MAIN_IMGS := $(filter-out $(OVERLAY_IMGS),$(ALL_IMGS)) +# Files that need to be extracted for the rom itself +MAIN_NEW_FILES := $(filter-out $(OVERLAY_NEW_FILES), $(NEW_FILES)) +# Any source files that have GLOBAL_ASM in them or do not exist before splitting +GLOBAL_ASM_C_SRCS := $(shell $(GREP) GLOBAL_ASM $(SRC_ROOT) arg2) +define print2 + @$(PRINT) "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)\n" +endef + +define print3 + @$(PRINT) "$(RED)$(1) $(BLUE)$(2)$(NO_COL)\n" +endef + +### Flags ### + +# Build tool flags +CFLAGS := -c -Wab,-r4300_mul -non_shared -G 0 -Xfullwarn -Xcpluscomm -signed $(OPT_FLAGS) $(MIPSBIT) -D_FINALROM -DF3DEX2_GBI +CFLAGS += -woff 649,838,807 +CPPFLAGS := -D_FINALROM -DN_MICRO -DF3DEX_GBI_2x +INCLUDE_CFLAGS := -I . -I include -I include/2.0L -I include/2.0L/PR +OPT_FLAGS := -O2 +MIPSBIT := -mips2 +ASFLAGS := -EB -mtune=vr4300 -march=vr4300 -mabi=32 -I include +GCC_ASFLAGS := -c -x assembler-with-cpp -mabi=32 -ffreestanding -mtune=vr4300 -march=vr4300 -mfix4300 -G 0 -O -mno-shared -fno-PIC -mno-abicalls +LDFLAGS_COMMON := --no-check-sections --accept-unknown-input-arch -T symbol_addrs.dk64_boot.$(VERSION).txt +LDFLAGS := -T $(LD_SCRIPT) -T symbol_addrs.rom.$(VERSION).txt -Map $(ELF:.elf=.map) --no-check-sections --accept-unknown-input-arch +BINOFLAGS := -I binary -O elf32-big + +### Rules ### + +# Default target, all +all: verify + +# Shows progress for all overlays, boot, and total +progress: $(OVERLAY_PROG_CSVS) $(MAIN_PROG_CSV) $(TOTAL_PROG_CSV) + @$(foreach overlay,$(OVERLAYS),$(PROGRESS_READ) progress/progress.$(overlay).csv $(VERSION) $(overlay) &&) \ + $(PROGRESS_READ) $(MAIN_PROG_CSV) $(VERSION) dk64_boot + @$(PROGRESS_READ) $(TOTAL_PROG_CSV) $(VERSION) total + +# Shows progress for a single overlay (e.g. progress-SM) +$(addprefix progress-,$(OVERLAYS)) : progress-% : progress/progress.%.csv + @$(PROGRESS_READ) $< $(VERSION) $* + +# Verify that the roms match, also sets up diff_settings +verify: $(Z64) | $(ALL_DIRS) + @$(DIFF) $(BASEROM) $(Z64) > /dev/null && \ + $(PRINT) "$(YELLOW) _\n//\\ \nV \\ \n \\ \\_\n \\,'.'-.\n |\\ '. '.\n ( \\ '. '-. _,.-:\\ \n \\ \\ '. '-._ __..--' ,-';/\n \\ '. '-. '-..___..---' _.--' ,'/\n '. '. '-._ __..--' ,' /\n '. '-_ ''--..'' _.-' ,'\n '-_ '-.___ __,--' ,'\n '-.__ '----\"\"\" __.-'\n '--..____..--'\n$(BLUE)$(BASENAME).$(VERSION).z64$(NO_COL): $(GREEN)OK$(NO_COL)\n" || \ + $(PRINT) "$(BLUE)$(BASEROM) $(RED)differs$(NO_COL)\n" + @$(PRINT) "def apply(config, args):\n" > diff_settings.py + @$(PRINT) "\tconfig[\"baseimg\"] = \"$(BASEROM)\"\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"myimg\"] = \"$(Z64)\"\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"mapfile\"] = \"$(Z64:.z64=.map)\"\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"source_directories\"] = ['$(SRC_ROOT)', 'include']\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"makeflags\"] = ['-s']\n" >> diff_settings.py + +# Musical note print for individual overlays +# Need to figure out how to print this only when building a single overlay +# $(YELLOW) ╒════╕\n │ │\n _│ _│\n └─┘ └─┘\n + +# Verify that any given overlay matches, also sets up diff_settings + +verify-%: $(BUILD_DIR)/%.rzip.bin $(BIN_ROOT)/%.$(VERSION).rzip.bin $(BUILD_DIR)/%.full progress/progress_%.svg + @$(DIFF) $< $(BIN_ROOT)/$*.$(VERSION).rzip.bin > /dev/null && \ + $(PRINT) "$(BLUE)%-10s$(NO_COL): $(GREEN)OK$(NO_COL)\n" "$*" || \ + $(PRINT) "$(BLUE)$* $(RED)differs$(NO_COL)\n" + @$(PRINT) "def apply(config, args):\n" > diff_settings.py + @$(PRINT) "\tconfig[\"baseimg\"] = \"$(BUILD_DIR)/$*.$(VERSION).bin\"\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"myimg\"] = \"$(BUILD_DIR)/$*.full\"\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"mapfile\"] = \"$(BUILD_DIR)/$*.map\"\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"source_directories\"] = ['$(SRC_ROOT)/$*', 'include']\n" >> diff_settings.py + @$(PRINT) "\tconfig[\"makeflags\"] = ['TARGET=$*','-s']\n" >> diff_settings.py + +$(OVERLAY_PROG_SVGS) : progress/progress_%.svg: progress/progress.%.csv + $(call print1,Creating progress svg for:,$*) + @$(PROGRESS_READ) $< $(VERSION) $* + +$(OVERLAY_PROG_CSVS) : progress/progress.%.csv: $(BUILD_DIR)/%.elf + $(call print1,Calculating progress for:,$*) + @$(PROGRESS) . $(BUILD_DIR)/$*.elf .code --version $(VERSION) --subcode $* > $@ + +$(MAIN_PROG_SVG): $(MAIN_PROG_CSV) + $(call print1,Creating progress svg for:,boot) + @$(PROGRESS_READ) $< $(VERSION) dk64_boot + +$(MAIN_PROG_CSV): $(ELF) + $(call print1,Calculating progress for:,boot) + @$(PROGRESS) . $< .dk64_boot --version $(VERSION) --subcode dk64_boot > $@ + +$(TOTAL_PROG_SVG): $(TOTAL_PROG_CSV) + $(call print0,Creating total progress svg) + @$(PROGRESS_READ) $< $(VERSION) total + +$(TOTAL_PROG_CSV): $(OVERLAY_PROG_CSVS) $(MAIN_PROG_CSV) + $(call print0,Calculating total progress) + @cat $^ > $@ + +# Verify that each overlay matches +verify-each: $(addprefix verify-,$(OVERLAYS)) + +# per-overlay rules + # .o -> .elf (overlay) +define global_asm_elf_rule + # .o -> .elf (overlay) + $(BUILD_DIR)/$(1).elf : $$($(1)_ALL_OBJS) $(1).ld + $(call print1,Linking elf:,$$@) + $(LD) -T $(1).ld -Map $(BUILD_DIR)/$(1).map $$(LDFLAGS_COMMON) -T symbol_addrs.$(1).$(VERSION).txt -T undefined_syms_auto.$(1).$(VERSION).txt -T undefined_funcs_auto.$(1).$(VERSION).txt -o $$@ +endef + +define overlay_elf_rule + # .o -> .elf (overlay) + $(BUILD_DIR)/$(1).elf : $$($(1)_ALL_OBJS) $(1).ld + $(call print1,Linking elf:,$$@) + $(LD) -T $(1).ld -Map $(BUILD_DIR)/$(1).map $$(LDFLAGS_COMMON) -T symbol_addrs.$(1).$(VERSION).txt -T symbol_addrs.global_asm.$(VERSION).txt -T undefined_syms_auto.$(1).$(VERSION).txt -T undefined_funcs_auto.$(1).$(VERSION).txt -o $$@ +endef + +define overlay_rules + # split overlay + $(BUILD_DIR)/$(1)_SPLAT_TIMESTAMP : $(SUBYAML)/$(1).$(VERSION).yaml $(BUILD_DIR)/$(1).$(VERSION).bin $(SYMBOL_ADDRS) + $(call print1,Splitting bin:,$$<) + @$(SPLAT) --target $(BUILD_DIR)/$(1).$(VERSION).bin $(SUBYAML)/$(1).$(VERSION).yaml --basedir . > /dev/null + @touch $$@ + @touch $(1).ld + # Dummy target to make sure extraction happens before compilation, mainly for extracted asm + $$($(1)_C_SRCS) $$($(1)_ASM_SRCS) $$($(1)_BINS) : | $(BUILD_DIR)/$(1)_SPLAT_TIMESTAMP + @: + # Dummy target to make sure extraction happens before processing extracted files and linking + $$($(1)_NEW_FILES) $(1).ld: $(BUILD_DIR)/$(1)_SPLAT_TIMESTAMP + @: +endef +$(foreach overlay,$(OVERLAYS),$(eval $(call overlay_rules,$(overlay)))) +$(foreach overlay,$(filter-out global_asm, $(OVERLAYS)),$(eval $(call overlay_elf_rule,$(overlay)))) +$(eval $(call global_asm_elf_rule,global_asm)) + + +# mkdir +$(ALL_DIRS) : + $(call print1,Making folder:,$@) + @$(MKDIR) -p $@ + +# .s -> .o (assemble with gcc for preprocessor support) +$(BUILD_DIR)/%.s.o: %.s | $(ASM_BUILD_DIRS) + $(call print2,Assembling:,$<,$@) + @$(GCC) $(GCC_ASFLAGS) $(INCLUDE_CFLAGS) -o $@ $< + +# .png -> .png.bin +$(IMG_BINS) : $(BUILD_DIR)/%.png.bin : %.png | $(IMG_BUILD_DIRS) + $(call print2,Converting image:,$<,$@) + @tools/build/img/build.py auto $< $@ + +# .png.bin -> .png.o +$(IMG_OBJS) : $(BUILD_DIR)/%.png.o : $(BUILD_DIR)/%.png.bin + $(call print2,Objcopying:,$<,$@) + @$(OBJCOPY) $(BINOFLAGS) $< $@ + +# .bin -> .o +$(BIN_OBJS) : $(BUILD_DIR)/%.bin.o : %.bin | $(BIN_BUILD_DIRS) + $(call print2,Objcopying:,$<,$@) + @$(OBJCOPY) $(BINOFLAGS) $< $@ + +# .bin -> .o (overlay) +$(OVERLAY_RZIP_OBJS) : $(BUILD_DIR)/$(BIN_ROOT)/%.$(VERSION).rzip.bin.o : $(BUILD_DIR)/%.rzip.bin + $(call print2,Objcopying:,$<,$@) + @$(OBJCOPY) $(BINOFLAGS) $< $@ + +# .c -> .o +$(BUILD_DIR)/%.c.o : %.c | $(C_BUILD_DIRS) + $(call print2,Compiling:,$<,$@) + $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_CFLAGS) $(OPT_FLAGS) $(MIPSBIT) -o $@ $< + +# .c -> .o (mips3) +$(MIPS3_OBJS) : $(BUILD_DIR)/%.c.o : %.c | $(C_BUILD_DIRS) + $(call print2,Compiling:,$<,$@) + @$(CC) -c -32 $(CFLAGS) $(CPPFLAGS) $(INCLUDE_CFLAGS) $(OPT_FLAGS) $(LOOP_UNROLL) $(MIPSBIT) -o $@ $< + @tools/set_o32abi_bit.py $@ + +# .c -> .o with asm processor +$(GLOBAL_ASM_C_OBJS) : $(BUILD_DIR)/%.c.o : %.c | $(C_BUILD_DIRS) + $(call print2,Compiling (with ASM Processor):,$<,$@) + @$(ASM_PROCESSOR) $(OPT_FLAGS) $< > $(BUILD_DIR)/$< + @$(CC) -32 $(CFLAGS) $(CPPFLAGS) $(INCLUDE_CFLAGS) $(OPT_FLAGS) $(MIPSBIT) -o $@ $(BUILD_DIR)/$< + @$(ASM_PROCESSOR) $(OPT_FLAGS) $< --post-process $@ \ + --assembler "$(AS) $(ASFLAGS)" --asm-prelude $(ASM_PROCESSOR_DIR)/prelude.s + +# Split baserom +$(BUILD_DIR)/SPLAT_TIMESTAMP: $(BASENAME).$(VERSION).yaml $(SYMBOL_ADDRS) | $(BUILD_DIR) + $(call print1,Splitting rom:,$<) + @touch $@ + @$(SPLAT) $(BASENAME).$(VERSION).yaml + @touch $(LD_SCRIPT) +# Dummy target to make the LD script and overlay rzips depend on splat being run +# without causing it to be rerun once for every overlay +# Bin files are also dependent on the splat timestamp since they get overwritten on resplit +$(MAIN_NEW_FILES) $(LD_SCRIPT) $(MAIN_BINS) : $(BUILD_DIR)/SPLAT_TIMESTAMP + @: +# Dummy target to make sure extraction happens before compilation, mainly for extracted asm +$(MAIN_C_SRCS) $(MAIN_ASM_SRCS) : | $(BUILD_DIR)/SPLAT_TIMESTAMP + @: + +# .rzip.bin -> .bin +$(OVERLAY_BINS) : $(BUILD_DIR)/%.$(VERSION).bin : $(BIN_ROOT)/%.$(VERSION).rzip.bin | $(BUILD_DIR) + $(call print1,Decompressing rzip:,$<) + $(GUNZIP) -cf -S .rzip.bin $< > $@ + + +# .elf -> .code +$(OVERLAY_CODE_BINS) : $(BUILD_DIR)/%.code : $(BUILD_DIR)/%.elf + $(call print2,Converting overlay code:,$<,$@) + @$(OBJCOPY) -O binary --only-section .code --only-section .mips3 $< $@ + +# .elf -> .data +$(OVERLAY_DATA_BINS) : $(BUILD_DIR)/%.data : $(BUILD_DIR)/%.elf + $(call print2,Converting overlay data:,$<,$@) + @$(OBJCOPY) -O binary --only-section .data --only-section .*_data_* $< $@ + +# .elf -> .full +$(BUILD_DIR)/%.full : $(BUILD_DIR)/%.elf + @$(OBJCOPY) -O binary $< $@ + +# .data + .code -> .rzip.bin +$(BUILD_DIR)/%.rzip.bin : $(BUILD_DIR)/%.code $(BUILD_DIR)/%.data $(GZIP) + $(call print1,Compressing overlay:,$@) + $(GZIP) -cnf -9 $(BUILD_DIR)/$*.code > $@ + $(GZIP) -cnf -9 $(BUILD_DIR)/$*.data >> $@ + truncate -s%16 $@ + +# .o -> .elf (game) +$(ELF): $(MAIN_ALL_OBJS) $(LD_SCRIPT) $(OVERLAY_RZIP_OBJS) $(addprefix $(BUILD_DIR)/, $(addsuffix .full, $(OVERLAYS))) + $(call print1,Linking elf:,$@) + @$(LD) $(LDFLAGS) -T undefined_syms_auto.$(VERSION).txt -o $@ + +# .elf -> .z64 +$(Z64) : $(ELF) $(OVERLAY_PROG_SVGS) $(MAIN_PROG_SVG) $(TOTAL_PROG_SVG) + $(call print1,Creating z64:,$@) + @$(OBJCOPY) $< $@ -O binary $(OCOPYFLAGS) + +$(GZIP_DIR)/%: $(GZIP_DIR)/Makefile + $(call print1,Compiling compression tools:,$@) + @$(CD) $(GZIP_DIR) && $(MAKE) gzip + +$(GZIP_DIR)/Makefile: + @$(CD) $(GZIP_DIR) && ./configure + +# Combined symbol addresses file +$(SYMBOL_ADDRS): $(SYMBOL_ADDR_FILES) + $(call print0,Combining symbol address files) + @$(CAT) symbol_addrs.*.$(VERSION).txt > $@ + +# Shorthand rules for each overlay (e.g. SM) +$(OVERLAYS): %: verify-% + +clean: + $(call print0,Cleaning build artifacts) + @$(RM) -rf $(BUILD_ROOT) + @$(RM) -rf $(BIN_ROOT) + @$(RM) -rf $(NONMATCHING_DIR) + @$(RM) -rf $(ASM_ROOT)/*.s + @$(RM) -rf $(addprefix $(ASM_ROOT)/,$(filter-out global_asm,$(OVERLAYS))) + @$(RM) -rf $(ASM_ROOT)/global_asm/*.s + @$(RM) -rf $(ASM_ROOT)/global_asm/os + @$(RM) -f undefined_syms_auto* undefined_funcs_auto* + @$(RM) -f *.ld + @$(RM) -f $(SYMBOL_ADDRS) + +# Per-file flag definitions +build/us/src/dk64_boot/dk64_boot_3C00.c.o: OPT_FLAGS = -O1 +build/us/src/dk64_boot/dk64_boot_61D0.c.o: OPT_FLAGS = -O1 +build/us/src/dk64_boot/gu/%.c.o: OPT_FLAGS = -O3 +build/us/src/dk64_boot/gu/nonmatching/%.c.o: OPT_FLAGS = -O2 +build/us/src/dk64_boot/io/%.c.o: OPT_FLAGS = -O1 +build/us/src/dk64_boot/io/conteepwrite.c.o: OPT_FLAGS = -O2 +build/us/src/dk64_boot/io/contpfs.c.o: OPT_FLAGS = -O2 +build/us/src/dk64_boot/io/contpfs.c.o: MIPSISET := -mips3 -o32 +build/us/src/dk64_boot/io/motor.c.o: OPT_FLAGS = -O2 +build/us/src/dk64_boot/io/crc.c.o: OPT_FLAGS = -O2 +build/us/src/dk64_boot/libc/%.c.o: OPT_FLAGS = -O3 +build/us/src/dk64_boot/libc/ll%.o: MIPSISET := -mips3 -o32 +build/us/src/dk64_boot/libc/ll%.o: OPT_FLAGS := -O1 +build/us/src/dk64_boot/os/%.c.o: OPT_FLAGS = -O1 + +build/us/src/global_asm/audio/%.c.o: OPT_FLAGS = -g + +#build/us/src/dk64_boot/gu/%.c.o: INCLUDE_CFLAGS = -I . -I include -I include/2.0L -I include/2.0L/PR + +# Disable implicit rules +MAKEFLAGS += -r + +# Phony targets +.PHONY: all clean verify $(OVERLAYS) progress $(addprefix progress-,$(OVERLAYS)) + +# Set up pipefail +SHELL = /bin/bash -e -o pipefail + +# Debug variable print target +print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true diff --git a/README.md b/README.md index bddd0a9f..44dec8e0 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,81 @@ -# dk64 +# donkey + +- +- +- +- +- +- +- +- +- +- +- -## Getting started +Grab tools -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.com/dk64_decomp/dk64.git -git branch -M main -git push -uf origin main +```sh +git submodule update --init --recursive ``` -## Integrate with your tools +Drop in `US` as `baserom.us.z64` (sha1sum: `cf806ff2603640a748fca5026ded28802f1f4a50`) -- [ ] [Set up project integrations](https://gitlab.com/dk64_decomp/dk64/-/settings/integrations) +To extract and build everything -## Collaborate with your team +```sh +make +``` -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) +Build a level or core code section separately (from base of repo): -## Test and Deploy -Use the built-in continuous integration in GitLab. +```sh +make +``` -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +where the following are supported values of `` +- `global_asm` +- `menu` +- `multiplayer` +- `minecart` +- `bonus` +- `race` +- `water` +- `boss` +- `arcade` +- `jetpac` -*** +## Prerequisites -# Editing this README +Ubuntu 18.04 or higher. -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +```sh +apt-get update && \ + apt-get install -y \ + binutils-mips-linux-gnu \ + build-essential \ + gcc-mips-linux-gnu \ + less \ + libglib2.0 \ + python3 \ + python3-pip \ + unzip \ + wget \ + libssl-dev -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. +python3 -m pip install \ + capstone pyyaml pylibyaml pycparser \ + colorama ansiwrap watchdog python-Levenshtein cxxfilt \ + python-ranges \ + pypng anybadge +``` -## Name -Choose a self-explaining name for your project. +## Other versions -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. +Drop in `kiosk`, `jp`, or `pal` as `baserom..z64` e.g. `baserom.kiosk.z64` -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +```sh +make VERSION=kiosk +``` diff --git a/Start Docker Image.bat b/Start Docker Image.bat new file mode 100644 index 00000000..682304a3 --- /dev/null +++ b/Start Docker Image.bat @@ -0,0 +1,3 @@ +@echo off +docker run --rm -ti -v %cd%:/donkeykong64 donkeykong64 +pause \ No newline at end of file diff --git a/diff.sh b/diff.sh new file mode 100755 index 00000000..6bdf5bad --- /dev/null +++ b/diff.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 ./tools/asm-differ/diff.py -wm3 $1 diff --git a/donkeykong64.us.yaml b/donkeykong64.us.yaml new file mode 100644 index 00000000..1a8ae9dc --- /dev/null +++ b/donkeykong64.us.yaml @@ -0,0 +1,249 @@ +options: + basename: donkeykong64 + find_file_boundaries: True + compiler: "IDO" + platform: n64 + asm_endlabels: yes + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.us.txt + undefined_syms_auto_path: undefined_syms_auto.us.txt + symbol_addrs_path: symbol_addrs.dk64_boot.us.txt + base_path: . + target_path: baserom.us.z64 + asset_path: bin + build_path: build/us +segments: + - name: header + type: header + start: 0x0 + - name: boot + type: bin + start: 0x40 + vram: 0xA4000040 + subsegments: + - [0x0040, asm, boot] + - [0x0B70, bin, boot2] + - name: dk64_boot + type: code + start: 0x1000 + vram: 0x80000400 + dir: dk64_boot + subsegments: + - [0x1000, hasm, entry] #DONE + - [0x1050, c, dk64_boot_1050] + - [0x1630, c, dk64_boot_1630] + - [0x1CC0, c, dk64_boot_1CC0] + - [0x30E0, c, dk64_boot_30E0] + - [0x3390, c, dk64_boot_3390] + - [0x3C00, c, dk64_boot_3C00] + - [0x3D20, c, dk64_boot_3D20] + - [0x5120, hasm, os/invaldcache] #DONE + - [0x51D0, c, io/pirawdma] #DONE + - [0x52B0, c, io/pigetstat] #DONE + - [0x52C0, c, os/recvmesg] #DONE + - [0x5400, c, io/viblack] #DONE + - [0x5470, c, os/setthreadpri] #DONE + - [0x5550, c, os/createmesgqueue] #DONE + - [0x5580, c, os/seteventmesg] #DONE + - [0x55F0, c, os/createthread] + - [0x5740, c, os/startthread] #DONE + - [0x5890, c, io/vimgr] + - [0x5BA0, c, io/visetmode] #DONE + - [0x5C10, bin, dk64_boot_5C10] #??? nops ??? + - [0x5C70, c, dk64_boot_5C70] + - [0x5DC0, hasm, libc/bzero] #DONE + - [0x5E60, hasm, os/invalicache] #DONE + - [0x5EE0, hasm, os/writebackdcacheall] #DONE + - [0x5F10, c, os/initialize] + - [0x61D0, c, dk64_boot_61D0] #DONE + - [0x6270, hasm, os/writebackdcache] #DONE + - [0x62F0, c, dk64_boot_62F0] + - [0x6360, c, io/viswapbuf] #DONE + - [0x63B0, c, dk64_boot_63B0] + - [0x6680, hasm, os/getfpccsr] #DONE + - [0x6690, c, gu/nonmatching/usprite] + - [0x66E0, c, os/stopthread] #DONE + - [0x67A0, c, io/dpsetstat] #DONE + - [0x67B0, c, io/spsetstat] #DONE + - [0x67C0, c, io/visetspecial] #DONE + - [0x6980, c, gu/translate] #DONE + - [0x6A20, c, gu/perspective] #DONE + - [0x6CB0, c, os/gettime] #DONE + - [0x6D40, c, os/settime] #DONE + - [0x6D70, c, gu/nonmatching/lookathil] + - [0x7560, c, gu/lookat] #DONE + - [0x7890, c, gu/ortho] #DONE + - [0x7A50, c, io/aisetnextbuf] #DONE + - [0x7B00, c, io/aigetlen] #DONE + - [0x7B10, c, os/pidma] #DONE + - [0x7C20, c, io/controller] + - [0x7F60, c, dk64_boot_7F60] + - [0x7FD0, c, dk64_boot_7FD0] + - [0x81B0, c, libc/llcvt] + - [0x83C0, c, os/settimer] #DONE + - [0x84A0, c, os/getthreadid] #DONE + - [0x84C0, c, io/conteeplongread] #DONE + - [0x8550, c, io/conteepwrite] + - [0x8920, c, io/conteepprobe] + - [0x8990, c, io/motor] + - [0x8D60, c, io/dpgetstat] #DONE + - [0x8D70, c, io/vigetcurrframebuf] #DONE + - [0x8DB0, c, io/vigetnextframebuf] #DONE + - [0x8DF0, c, io/sptaskyielded] #DONE + - [0x8E70, c, io/sptask] #DONE + - [0x9160, c, io/sptaskyield] #DONE + - [0x9180, c, gu/scale] #DONE + - [0x9220, c, gu/nonmatching/rotate] + - [0x9410, c, gu/mtxcatf] #DONE + - [0x9620, c, gu/mtxcatl] #DONE + - [0x96E0, c, gu/nonmatching/align] + - [0x98F0, c, io/piread] #DONE + - [0x9930, c, io/vigetmode] #DONE + - [0x9980, c, gu/nonmatching/position] + - [0x9BA0, c, os/virtualtophysical] #DONE + - [0x9C20, hasm, interrupt] #DONE + - [0x9C60, c, os/thread] + - [0x9CA0, hasm, os/exceptasm] + - [0xA5A0, c, io/vi] #DONE + - [0xA6E0, c, os/timerintr] + - [0xAAE0, c, os/getthreadpri] #DONE + - [0xAB00, c, io/vigetcurrcontext] #DONE + - [0xAB10, c, io/viswapcontext] + - [0xAE10, c, os/sendmesg] #DONE + - [0xAF60, hasm, os/getcount] #DONE + - [0xAF70, hasm, os/setsr] #DONE + - [0xAF80, hasm, os/getsr] #DONE + - [0xAF90, hasm, os/setfpccsr] #DONE + - [0xAFA0, c, io/sirawread] #DONE + - [0xAFF0, c, io/sirawwrite] #DONE + - [0xB040, hasm, os/unmaptlball] #DONE + - [0xB090, hasm, os/maptlbrdb] #DONE + - [0xB0F0, c, io/pirawread] #DONE + - [0xB150, c, io/pimgr] + - [0xB2C0, c, gu/nonmatching/mtxutil] + - [0xB530, c, cosf] + - [0xB6A0, c, sinf] + - [0xB860, hasm, gu/sqrt] #DONE + - [0xB870, c, io/ai] #DONE + - [0xB8A0, c, os/jammesg] #DONE + - [0xB9F0, c, io/pigetcmdq] #DONE + - [0xBA20, c, io/sirawdma] + - [0xBAD0, c, io/siacs] + - [0xBB90, c, io/conteepread] + - [0xBDE0, c, io/crc] + - [0xBF50, c, io/contramwritesafe] + - [0xBFD0, c, io/contramread] + - [0xC200, c, io/spgetstat] + - [0xC210, hasm, bcopy] #DONE + - [0xC520, c, io/spsetpc] #DONE + - [0xC560, c, io/sprawdma] #DONE + - [0xC5F0, c, io/sp] #DONE + - [0xC620, c, gu/normalize] #DONE + - [0xC6B0, c, io/piacs] + - [0xC770, hasm, probetlb] #DONE + - [0xC830, c, os/setIntMask] + - [0xC8D0, c, os/destroythread] #DONE + - [0xC9E0, hasm, os/setcompare] + - [0xC9F0, c, io/si] + - [0xCA20, c, dk64_boot_CA20] + - [0xCC00, c, io/devmgr] + - [0xD090, c, io/contramwrite] + - [0xD2E0, c, io/pfsisplug] + - [0xD620, c, io/pfsgetstatus] + - [0xD850, c, os/resetglobalintmask] + - [0xD8B0, c, io/epirawwrite] + - [0xDA10, c, io/epirawread] + - [0xDB70, c, os/setglobalintmask] #DONE + - [0xDBC0, c, os/yieldthread] #DONE + - [0xDC10, c, io/contpfs] + - [0xE790, c, dk64_boot_E790] + - name: dk64_boot_data + dir: dk64_boot + type: code + start: 0xE8B0 + vram: 0x8000DCB0 + subsegments: + - [0xE8B0, bin, dk64_boot_data_E8B0] + - [0xFB00, .data, io/vimgr] + - [0xFB20, bin, dk64_boot_data_FB20] + - [0x10CC0, .data, io/aisetnextbuf] + - [0x10CD0, bin, dk64_boot_data_10CD0] + - [0x10D30, .data, io/vi] + - [0x10DA0, bin, dk64_boot_data_10DA0] + - [0x11120, .rodata, gu/perspective] + - [0x11130, bin, dk64_boot_data_11130] #- [0x11130, .rodata, gu/lookathil] + - [0x11140, bin, dk64_boot_data_11140] + #- [0x11150, .rodata, gu/rotate] + - [0x11160, bin, dk64_boot_data_11160] + #- [0x11170, .rodata, gu/position] + - [0x11180, bin, dk64_boot_data_11180] + - name: global_asm.us.rzip #805fb300 + type: bin + start: 0x113F0 + subsegments: + - [0x113F0, bin] + - name: menu.us.rzip + type: bin + start: 0xCBE70 + subsegments: + - [0xCBE70, bin] + - name: multiplayer.us.rzip + type: bin + start: 0xD4B00 + subsegments: + - [0xD4B00, bin] + - name: minecart.us.rzip + type: bin + start: 0xD6B00 + subsegments: + - [0xD6B00, bin] + - name: bonus.us.rzip + type: bin + start: 0xD9A40 + subsegments: + - [0xD9A40, bin] + - name: race.us.rzip + type: bin + start: 0xDF600 + subsegments: + - [0xDF600, bin] + - name: water.us.rzip + type: bin + start: 0xE6780 + subsegments: + - [0xE6780, bin] + - name: boss.us.rzip + type: bin + start: 0xEA0B0 + subsegments: + - [0xEA0B0, bin] + - name: arcade.us.rzip + type: bin + start: 0xF41A0 + subsegments: + - [0xF41A0, bin] + - name: jetpac.us.rzip + type: bin + start: 0xFD2F0 + subsegments: + - [0xFD2F0, bin] + - name: unkown_101A40 + type: bin + start: 0x101A40 + subsegments: + - [0x101A40, bin, unkown_101A40] + - name: assets + type: bin + start: 0x101C50 + subsegments: + - [0x101C50, bin, assets] + - [0x2000000] diff --git a/find_first_diff.sh b/find_first_diff.sh new file mode 100755 index 00000000..94d9ea59 --- /dev/null +++ b/find_first_diff.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cmp -l build/us/$1.us.bin build/us/$1.full | gawk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}' +#diff -y <(xxd build/us/$1.us.bin) <(xxd build/us/$1.full) \ No newline at end of file diff --git a/ido/ido5.3_recomp/as1 b/ido/ido5.3_recomp/as1 new file mode 100755 index 00000000..17ff2aa7 Binary files /dev/null and b/ido/ido5.3_recomp/as1 differ diff --git a/ido/ido5.3_recomp/cc b/ido/ido5.3_recomp/cc new file mode 100755 index 00000000..6dbb85eb Binary files /dev/null and b/ido/ido5.3_recomp/cc differ diff --git a/ido/ido5.3_recomp/cfe b/ido/ido5.3_recomp/cfe new file mode 100755 index 00000000..d742f7b2 Binary files /dev/null and b/ido/ido5.3_recomp/cfe differ diff --git a/ido/ido5.3_recomp/err.english.cc b/ido/ido5.3_recomp/err.english.cc new file mode 100644 index 00000000..6976e38a --- /dev/null +++ b/ido/ido5.3_recomp/err.english.cc @@ -0,0 +1,1260 @@ +@ + 358 358 358 + 6464 6482 6553 + 6553 6593 6728 + 6728 6746 6803 + 6803 6808 6808 + 6808 6818 6818 + 6818 6826 6826 + 6826 6847 6847 + 6847 6875 6922 + 6922 6930 6930 + 6930 6939 6939 + 6939 6948 6948 + 6948 6974 7120 + 7120 7149 7204 + 7210 7248 7311 + 7317 7350 7442 + 7450 7497 7627 + 7635 7709 7930 + 7938 7975 8063 + 8071 8113 8253 + 8261 8289 8289 + 8298 8338 8445 + 8460 8502 8635 + 8650 8690 8819 + 8834 8857 8965 + 8965 9008 9113 + 9119 9142 9227 + 9235 9282 9451 + 9451 9462 9462 + 9462 9477 9477 + 9477 9497 9497 + 9497 9545 9545 + 9545 9584 9584 + 9584 9604 9662 + 9662 9682 9720 + 9720 9749 9749 + 9749 9788 9788 + 9788 9802 9802 + 9802 9829 9829 + 9829 9861 9861 + 9861 9904 9904 + 9904 9920 9920 + 9920 9962 9962 + 9962 9988 9988 + 9988 10014 10014 +10014 10035 10035 +10035 10054 10097 +10097 10115 10115 +10115 10147 10147 +10147 10183 10183 +10183 10208 10208 +10208 10236 10236 +10236 10269 10269 +10269 10304 10304 +10304 10328 10328 +10328 10351 10351 +10351 10371 10371 +10371 10402 10402 +10402 10447 10447 +10447 10497 10497 +10497 10533 10533 +10533 10598 10598 +10606 10630 10630 +10640 10671 10671 +10690 10719 10719 +10728 10752 10795 +10795 10837 10837 +10837 10876 10876 +10876 10900 10900 +10900 10948 10948 +10960 11021 11103 +11103 11128 11128 +11128 11153 11153 +11153 11216 11216 +11216 11239 11239 +11239 11303 11303 +11303 11347 11347 +11357 11393 11393 +11393 11432 11432 +11442 11494 11494 +11494 11536 11536 +11536 11595 11595 +11595 11622 11622 +11622 11684 11684 +11684 11726 11726 +11738 11778 11778 +11782 11813 11813 +11813 11850 11850 +11850 11900 12087 +12111 12120 12120 +12120 12129 12129 +12129 12158 12158 +12158 12192 12192 +12192 12237 12237 +12237 12273 12273 +12273 12326 12326 +12330 12366 12366 +12366 12423 12423 +12427 12482 12482 +12486 12560 12560 +12568 12631 12631 +12637 12691 12691 +12691 12743 12743 +12743 12785 12785 +12785 12826 12826 +12826 12865 12865 +12865 12883 12883 +12883 12946 12946 +12956 12995 12995 +13005 13066 13066 +13077 13163 13163 +13163 13211 13211 +13211 13270 13270 +13270 13318 13318 +13318 13350 13350 +13350 13387 13387 +13387 13428 13428 +13428 13464 13533 +13533 13580 13737 +13737 13776 13854 +13854 13913 13913 +13913 13950 13950 +13950 14118 14118 +14118 14150 14150 +14150 14163 14194 +14194 14224 14255 +14255 14275 14319 +14319 14353 14458 +14466 14484 14530 +14534 14567 14567 +14567 14635 14682 +14690 14742 14742 +14742 14789 14789 +14801 14875 14875 +14886 14947 14947 +14947 14992 14992 +14992 15035 15085 +15085 15134 15205 +15214 15267 15448 +15454 15496 16810 +16822 16875 16960 +16972 17053 17179 +17191 17236 17332 +17344 17491 17841 +17853 17939 18304 +18316 18471 18774 +18786 18952 19323 +19335 19364 19496 +19500 19527 19598 +19598 19613 19776 +19797 19808 19837 +19837 19862 19862 +19868 19927 20026 +20034 20075 20179 +20187 20223 20223 +20223 20290 20382 +20392 20441 20589 +20601 20656 20656 +20656 20699 20818 +20826 20860 21038 +21046 21094 21191 +21203 21236 21314 +21326 21395 21457 +21469 21502 21502 +21502 21587 21731 +21756 21789 21864 +21875 21901 21976 +22013 22059 22220 +22257 22397 22561 +22561 22595 22595 +22603 22623 22623 +22631 22667 22828 +22865 22919 22994 +23031 23059 23120 +23132 23201 23201 +23212 23274 23274 +23285 23345 23345 +23356 23393 23393 +23399 23431 23532 +23542 23587 23646 +23656 23697 23745 +23755 23796 23844 +23854 23876 23928 +23942 23971 24153 +24160 24243 24243 +24247 24273 24743 +24755 24784 24984 +24996 25034 25034 +25034 25075 25273 +25281 25332 25410 +25420 25467 25544 +25554 25583 25744 +25754 25783 26061 +26071 26111 26185 +26194 26239 26525 +26535 26568 26914 +26924 26951 26998 +27008 27035 27082 +27093 27120 27167 +27178 27206 27251 +27261 27289 27334 +27345 27391 27931 +27938 27959 28007 +28019 28037 28037 +28043 28069 28069 +28077 28147 28199 +28207 28266 28266 +28274 28306 28306 +28314 28339 28339 +28347 28404 28510 +28518 28567 28682 +28690 28728 28728 +28736 28782 29023 +29033 29085 29234 +29246 29303 29383 +29395 29432 29570 +29592 29631 29644 +29644 29693 29758 +29767 29810 29875 +29875 29911 29976 +29984 30014 30014 +30027 30086 30151 +30157 30223 30293 +30301 30369 30445 +30457 30511 30568 +30580 30630 30743 +30755 30812 30874 +30886 30959 31035 +31043 31076 31175 +31183 31243 31243 +31251 31323 31323 +31331 31433 31433 +31445 31544 31686 +31698 31740 31740 +31740 31783 31783 +31783 31824 31824 +31824 31873 31996 +32008 32056 32164 +32176 32210 32210 +32229 32271 32271 +32279 32323 32569 +32581 32642 32718 +32739 32779 32916 +32926 32953 33047 +33057 33116 33315 +33325 33373 33373 +33373 33407 33469 +33494 33527 33527 +33536 33573 33573 +33584 33650 33697 +33705 33763 33763 +33763 33797 33797 +33797 33829 33906 +33915 33976 33976 +33985 34016 34098 +34098 34133 34198 +34198 34261 34261 +34269 34312 34312 +34324 34363 34438 +34444 34530 34530 +34538 34596 34626 +34636 34675 34754 +34764 34821 34821 +34821 34867 34950 +34959 35016 35135 +35145 35198 35198 +35208 35266 35344 +35355 35382 35537 +35547 35576 35629 +35637 35705 35705 +35713 35764 35764 +35764 35784 35876 +35888 35932 35950 +35950 36013 36138 +36150 36191 36280 +36286 36314 36419 +36431 36516 36516 +36516 36554 36642 +36642 36689 36808 +36818 36881 37105 +37113 37183 37204 +37204 37225 37225 +37225 37255 37348 +37348 37388 37388 +37388 37454 37454 +37454 37518 37518 +37518 37584 37584 +37584 37717 37717 +37717 37752 37752 +37752 37783 37889 +37901 37928 38034 +38046 38115 38115 +38115 38140 38187 +38195 38219 38339 +38351 38422 38422 +38422 38486 38486 +38486 38555 38555 +38555 38619 38619 +38619 38641 38641 +38641 38758 38758 +38758 38929 38929 +38929 38975 39043 +39055 39084 39133 +39133 39175 39265 +39275 39310 39494 +39504 39547 39576 +39587 39614 39668 +39674 39697 39797 +39797 39845 40094 +40094 40158 40264 +40264 40369 40523 +40523 40593 40593 +40593 40629 40876 +40876 40911 40971 +40977 41026 41026 +41038 41077 41077 +41077 41116 41116 +41116 41156 41156 +41156 41195 41195 +41195 41237 41237 +41237 41285 41285 +41285 41304 41304 +41304 41371 41371 +41371 41429 41429 +41429 41491 41491 +41491 41519 41519 +41519 41572 41572 +41572 41642 41642 +41642 41676 41676 +41676 41713 41713 +41713 41751 41751 +41751 41792 41792 +41792 41856 41856 +41856 41881 41881 +41881 41936 41936 +41936 41977 41977 +41977 42018 42018 +42018 42090 42090 +42090 42162 42162 +42162 42205 42205 +42205 42267 42267 +42267 42294 42294 +42294 42309 42309 +42309 42338 42386 +42393 42425 42522 +42530 42577 42577 +42577 42623 42623 +42623 42643 42725 +42725 42748 42748 +42748 42829 42897 +42901 42952 42952 +42952 42978 43025 +43025 43116 43116 +43116 43171 43171 +43171 43204 43376 +43386 43453 43471 +43471 43547 43780 +43798 43921 44116 +44120 44120 44120 +Out of memory: %s +There is no more memory left in the system for compiling this program. +Internal Error Unknown Error Message %s +1) An internal error, while attempting to print an unavailable message +2) The error message file is inaccessible or has other problems +Unknown Signal %s +1) An unknown signal has been caught +2) 2 Nested signals +line +Warning: +Fatal: +Source not available +Too many errors... goodbye. +There is a limit of 30 errors before aborting. +Error: +reserved +reserved +Unknown Control Statement +1) The line begins with a '#' and is not of the form: + # "" +2) Please compile this program with the preprocessor enabled. +Unknown character %s ignored +The character is not part of the source character set. +2.2.1 +Unknown control character \%s ignored +The control character is not part of the source character set. +2.2.1 +Illegal character %s in exponent +1) Digits or sign expected after 'e' or 'E'. +2) Digits are expected after sign in exponent. +3.1.3.1 +Constant is out of range and may be truncated. +The constant is too large to be accurately represented and may be +truncated. The limits are in the system include file limits.h. +2.2.4.2 +Constant is out of range for a 32-bit data type, but accepted as written. +The constant is too large to fit in a 32-bit data type, but will be +accurately represented in a wider data type. The value may be truncated, +depending on its context. The limits are in the system include file +limits.h. +2.2.4.2 +Character constant size out of range +1) No characters in a character constant. +2) More than 4 bytes in a character constant. +3.1.3.4 +Wide character constant size out of range +1) No characters in the multibyte sequence (0 assumed). +2) More than 1 byte in the multi-byte sequence (only the first byte was converted). +3.1.3.4 +Invalid multibyte character +4.10.7.2 +Newline in string or character constant +1) Terminate your string or character constant with closing quotes. +2) Put a backslash before the newline. +3.1.3.4, 3.1.4 +Octal character escape too large: %s > %s +1) Terminate end of octal sequence with a non-octal character. +2) Select a character value within the limits. +Value may be truncated +3.1.3.4, 3.1.4 +Hex character escape too large: %s > %s +1) Terminate end of hex sequence with a non-hex character. +2) Select a character value within the limits. +Value may be truncated +3.1.3.4, 3.1.4 +Unexpected End-of-file +1) Unterminated string or character constant +2) Missing closing comment marker (*/) +3) File system problems +Unrecognized escape sequence in string \%s +Recognized escape sequences are \a, \b, \f, \n, \r, \t, and \v. +Character will be treated as un-escaped. +3.9.2 +Illegal octal digit %s +Octal constants, beginning with 0, must only have digits between 0 and 7, +inclusive. +3.1.3.2 +Unable to open temporary file for compiling %s +1) TMPDIR environment variable is set to a directory that you have no + permissions for. +2) The file system is full. +3) System errors beyond the scope of the compiler. +%s: Hangup +%s: Interrupt +%s: Quit (ASCII FS) +%s: Illegal instruction (not reset when caught) +%s: Trace trap (not reset when caught) +%s: IOT instruction +Also SIGABRT, used by abort, replace SIGIOT in the future +%s: EMT instruction +Also SIGXCPU, Exceeded CPU time limit +%s: Floating point exception +%s: Kill (cannot be caught or ignored) +%s: Bus error +%s: Segmentation violation +%s: Bad argument to system call +%s: Write on a pipe with no one to read it +%s: Alarm clock +%s: Software termination signal from kill +%s: User defined signal 1 +%s: User defined signal 2 +%s: Death of a child +Power-fail restart +%s: Also SIGXFSZ, exceeded file size limit +%s: Window change +%s: Handset, line status change +%s: Sendablestop signalnot from tty +%s: Stop signal from tty +%s: Pollable event occurred +%s: Input/Output possible signal +%s: Urgent condition on IO channel +%s: Window size changes +%s: Virtual time alarm +%s: Profiling alarm +%s: Continue a stopped process +%s: To readers pgrp upon background tty read +%s: Like TTIN for output if (tp->t_local<OSTOP) +%s: Resource lost (eg, record-lock) +'auto' and 'register' are not allowed in an external declaration +3.7(10) +must have function type +3.7.1(30) +Functions cannot return arrays +3.7.1(33), 3.3.2.2 +Declaration list not allowed +3.7.1(5) +Too many input files %s +The command line may contain only one file +cpp internal error: input stack underflow +cpp internal error: if stack underflow +Cannot open the file %s +No new-line character at the end of the file %s +2.1.1.2(30) +Fatal: Exceeded the limit of nesting level for #include file +Fatal: Exceeded the limit of nesting level for #include file. This limit +is 200. +Fail to read the file %s +Cannot write the file %s +%s: %s: An if directive is not terminated properly in the file +%s: %s: nested comment +%s:%s: Illegal macro name %s; macro name shall be an identifier +%s:%s: Illegal preprocessing token sequence +3.8.3(35) +%s:%s: Illegal macro parameter name +%s:%s: Non-unique macro parameter name +3.8.3(18) +%s:%s: Missing ')' in parameter list for #define %s +%s:%s: Missing ')' in macro instantiation +%s:%s: Bad punctuator in the parameter list for #define %s +%s:%s: Macro %s redefined. +%s:%s: # operator should be followed by a macro argument name +%s:%s: Badly formed constant expression%s +3.4(9), 3.8 +%s:%s: Division by zero in #if or #elif +3.8 +unknown command line option %s +extraneous input/output file name %s +%s: %s: Unterminated string or character constant +A preprocessing string or character constant token was not +terminated. Note that preprocessing directives are processed +after the source file has been divided into preprocessing tokens. +2.1.1.2(30) 3.1(18) 3.8 +%s: %s: +%s: %s: +%s: %s: Unterminated comment +%s: %s: Unknown directive type %s +%s: %s: #elif or #else after #else directive +%s: %s: Bad identifier after the %s +%s: %s: #%s accepts only one identifier as parameter +3.8 +%s: %s: Bad identifier after the %s +%s: %s: text following #%s violates the ANSI C standard. +3.8 +%s: %s: Bad character %s occurs after the # directive. +3.8 +%s: %s: the ## operator shall not be the %s token in the replacement list +3.8.3.3 +%s: %s: the defined operator takes identifier as operand only. +3.8.1 +%s: %s: Not in a conditional directive while using %s +%s: %s: Illegal filename specification for #include +%s: %s: Invalid file name %s for #include +%s: %s: Cannot open file %s for #include +%s: %s: Bad argument for #line command +%s: %s: #error %s +%s: %s: Tried to redefine predefined macro %s, attempt ignored +3.8.7(22) +%s: %s: Undefining predefined macro %s +3.8.7(22) +%s: %s: Undefined the ANSI standard library defined macro %s +4.1.2.1(9) +%s: %s: The number of arguments in the macro invocation does not match the definition +%s: %s: Illegal character %s in preprocessor if +%s: %s: Illegal character %s for number in preprocessor if +%s: %s: No string is allowed in preprocessor if +%s: %s: Not supported pragma %s +%s: %s: Not supported #pragma format +%s: %s: ANSI C does not allow #ident; %s +%s: %s: Not supported #ident format +This cpp extension accepts the following format: +#ident "any string" +%s: %s: Not supported #assert/#unassert format +This cpp extension accepts the following format: +#assert identifier +#assert identifier ( pp-tokens ) +#unassert identifier +#unassert identifier ( pp-tokens ) +%s: %s: Bad assertion predicate format +The correct syntax for this cpp extension is: +#assert identifier ( pp-token ) +%s: %s: directive is an upward-compatible ANSI C extension +%s: This option requires an argument +%s: %s: A macro has expanded recursively more than %s times. Further expansion will be disabled! Use command-line option: -Wp,-max_rec_depth=depth to recurse deeper. +A status return from cpp to cfe +Syntax Error +The token read was unexpected. +Syntax Error -- cannot backup +The token read was unexpected. +Yacc stack overflow +The expression is too complicated to parse. +Trailing comma in enumerator list +The use of a trailing comma in an enumerator list is not standard C. There +may be portability problems. +3.5.2.2 +Empty declaration +Empty declarations are invalid in standard C. +3.5 +%s declared, but not referenced. +redeclaration of '%s'; previous declaration at line %s in file '%s' +Identifier redeclared in the same scope/block. +3.1.2.3 +'%s' undefined; reoccurrences will not be reported. +Non-function name referenced in function call. +3.3.2.2(18) +The number of arguments doesn't agree with the number in the declaration. +3.3.2.2(5) +'%s' section name longer than 8 characters. Name truncated. +'%s' is already placed by pragma alloc_text. +Cannot write ucode file while compiling %s +1) The file system is full +2) Permissions problem +Must have corresponding formal argument for '%s' +Parameter found in the declaration part, but not in the argument list. +3.7.1(7) +Non-prototype declaration is an obsolescent feature. +The use of function definitions with separate parameter identifier +and declaration lists (not prototype-format parameter type and +identifier declarators) is an obsolescent feature. +3.9.5 +Incompatible function declarations for %s +For two function types to be compatible, both shall specify compatible +return types. Moreover, the parameter type lists, if both are present, +shall agree in the number of parameters and in use of the ellipsis +terminator; corresponding parameters shall have compatible types. If +one type has a parameter type list and the other type is specified by +a function declarator that is not part of a function definition and +contains an empty identifier list, the parameter list shall not have +an ellipsis terminator and the type of each parameter shall be +compatible with they type that results from application of the default +argument promotions. If one type has a parameter type list and the +other is specified by a function definition that contains a (possibly +empty) identifier list, both shall agree in the number of parameters, +and the type of each prototype parameter shall be compatible with the +type that results from application of the default argument promotions +to the type of the corresponding identifier. (For each parameter +declared with function or array type, its type for these comparisons +is the one that results from conversion to a pointer type. For each +parameter declared with qualified type, its type for these comparisons +is the unqualified version of its declared type.) There you have it! +3.5.4.3(15) +Incompatible function return type for this function. +For two function types to be compatible, both shall specify compatible +return types. +3.5.4.3(15) +The number of parameters for function is different from the previous declaration +The parameter type lists, if both are present, shall agree in the +number of parameters and in use of the ellipsis terminator. +3.5.4.3(15) +Incompatible type for the function parameter +If both parameter type lists are present, corresponding +parameters shall have compatible types. +3.5.4.3(15) +Function %s is redeclared with an incompatible argument type (after default argument promotion), which could lead to undefined run-time behaviour. +The redeclaration could cause arguments at a call site to be passed +inconsistently with what the function implementation expects, and +parameters would therefore be accessed erroneously when executing the +function body. Note that a float argument is promoted to a double +when passed (potentially through fp registers) to an unprototyped +function. +3.5.4.3(15) +prototype and non-prototype declaration found for %s, ellipsis terminator not allowed +If one type has a parameter type list and the other type is specified +by a function declarator that is not part of a function definition and +contains an empty identifier list, the parameter list shall not have +an ellipsis terminator and the type of each parameter shall be +compatible with they type that results from application of the default +argument promotions. +3.5.4.3(15) +prototype and non-prototype declaration found for %s, the type of this parameter is not compatible with the type after applying default argument promotion +If one type has a parameter type list and the other type is specified +by a function declarator that is not part of a function definition and +contains an empty identifier list, the type of each parameter shall be +compatible with the type that results from application of the default +argument promotions. +3.5.4.3(15) +prototype declaration and non-prototype definition found for %s, the type of this parameter is not compatible with the type after applying default argument promotion +If one type has a parameter type list and the other is specified by a +function definition that contains a (possibly empty) identifier list, +both shall agree in the number of parameters, and the type of each +prototype parameter shall be compatible with the type that results +from application of the default argument promotions to the type of the +corresponding identifier. +3.5.4.3(15) +Empty declaration specifiers +Standard C requires at least a storage class specifier, type specifier, +or a type qualifier in declarations. 'extern int' assumed. +3.5 +Can't write to the file %s +1) The output file cannot be opened for writing. +2) Out of file space. +Duplicate '%s' +typedef, extern, static, auto, register, const, volatile may not +appear more than once in the same specifier list or qualifier list. +Duplicate occurrence ignored. +3.5.1(10) , 3.5.3(5) +Null input +There is nothing to compile. +Illegal type combination +3.5.2 +Missing ';' at end of structure / union member declaration +In standard C, each member declaration must be terminated by a ';'. A +terminating ';' is assumed. +3.5.2.1 +Missing member name in structure / union +In standard C, each member declaration have a member name. The missing +member is assumed to not exist. +3.5.2.1 +This variable is initialized twice. +Neither 'const' or 'volatile' have any effect on function results. +Qualifiers only apply to expressions designating an object that +can be altered or examined. +3.5.3(10) +An integer constant expression is required here. +The expression that defines the value of an enumeration constant +shall be an integral constant expression that has a value +representable as an int. +3.5.2.2(28) +(previous declaration of '%s' at line %s in file '%s') +Must be an integer type greater than zero. +The array size must be either a char, signed or unsigned integer or +an enumerated type with a value greater than zero. +3.5.4.2 +Array size cannot be a long long. +Arrays with more than 2^32 elements are not yet supported. +The array size must be either a char, signed or unsigned integer or +an enumerated type with a value greater than zero. +3.5.4.2 +bit-field '%s' width is not an integer constant +The expression that specifies the width of a bit-field shall be an +integral constant expression. +3.5.2.1(15) +bit-field '%s' width is negative +The expression that specifies the width of a bit-field shall be +non-negative. +3.5.2.1(15) +bit-field '%s' type required to be int, unsigned int, or signed int. +A bit-field shall have type int, unsigned int, or signed int. +3.5.2.1(30) +bit-field %s's type not integer. +Non-scalar type or pointer type to a non-object for increment or decrement operator. +The operand of the prefix/postfix increment or decrement operator shall have scalar type; if it is of pointer type, it must point to an object. +3.3.2.4(37), 3.3.3.1(25) +Assign value to a function type. +An assignment operator shall have a modifiable lvalue as its left operand. +3.2.2.1(5) +Assign value to an array. +An assignment operator shall have a modifiable lvalue as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +Change value for variable of incomplete type. +The operand of increment and decrement operator shall be a modifiable +scalar lvalue. An assignment operator shall have a modifiable lvalue +as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +The left-hand side of the '.' operator must be an addressable lvalue, when a bit-field is not contained within a unit of 32 bits alignment. +This is a restriction in our implementation, which can be worked +around by always accessing long long bit-fields indirectly (i.e. +by means of the '->' operator). +This expression is not an lvalue. +3.2.2.1 +Modified an rvalue. +3.2.2.1 +Change value for constant variable. +The operand of increment and decrement operators shall be modifiable +scalar lvalues. An assignment operator shall have a modifiable lvalue +as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +Change value for constant field of a struct or union. +An assignment operator shall have a modifiable lvalue as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +Dereferenced a non-pointer. +The operand of the unary * operator shall have pointer type. +3.3.3.2(39) +The operand of the unary + or - operator shall have arithmetic type. +3.3.3.3(6) +The operand of the unary ~ operator shall have integral type. +3.3.3.3(6) +The operand of the unary ! operator shall have scalar type. +3.3.3.3(6) +Constants must have arithmetic type. +3.1.3 +Bad type name for cast operator +The type name for the cast operator should either be void or a +qualified or unqualified scalar type. +3.3.4(22) +Improper cast of non-scalar type expression. +The operand for the cast operator shall be of scalar type. +3.3.4(23) +Cast a pointer into a non-integral type. +A pointer may be converted to an integral type. +3.3.4(31) +Cast a non-integral type into a pointer. +An integral type may be converted to a pointer. +3.3.4(31) +Duplicate member '%s' +Two members of a struct may not have the same name. +3.1.2.2(7,25) +Invalid constant expression. +Constant expressions shall not contain assignment, increment, decrement, +function-call, or comma operators, except when they are contained within +the operand of the sizeof operator. +3.4(9) +Constant expressions must be derived from a constant value or a constant +variable. +3.4 +Dangerous operand of '&'. +The operand of the unary & operator shall be either a function +designator or an lvalue that designates an object that is not a +bit-field and is not declared with the register storage-class +specifier. This operand is NOT an lvalue, but we let it pass. +Note that a segmentation error with possible core dump will result +when the resulting address does not denote a valid (declared) +storage location. This feature will be discontinued in future +releases of the compiler! +3.3.3.2(36) +Unacceptable operand of '&'. +The operand of the unary & operator shall be either a function +designator or an lvalue that designates an object that is not a +bit-field and is not declared with the register storage-class +specifier. +3.3.3.2(36) +'&' before array or function; ignored +Unacceptable operand of sizeof operator. +The sizeof operator shall not be applied to an expression that has +function type or an incomplete type, to the parenthesized name of such +a type, or to an lvalue that designates a bit-field object. +3.3.3.4 +Unacceptable operand of a multiplicative operator. +Each of the operands of a multiplicative operator shall have arithmetic type. +3.3.5(18) +Unacceptable operand of the remainder operator +Each of the operands of the remainder (%) operator shall have integral type. +3.3.5(18) +Unacceptable operand of '+'. +For the + operator, either both operands shall have arithmetic type, or +one operand shall be a pointer to an object type and the other shall +have integral type. +3.3.6(39) +Unacceptable operand of '-'. +For the subtraction operator, one of the following shall hold: both operands +have arithmetic type; operands are pointers to qualified or unqualified +versions of compatible object types; or the left operand is a pointer +to an object type and the right operand has integral type. +3.3.6(39) +Unacceptable operand of shift operator. +Each of the operands of bitwise shift operators shall have integral type. +3.3.7(9) +Unacceptable operand of relational operator. +For relational operators, one of the following shall hold: both +operands have arithmetic type; both operands are pointers to qualified +or unqualified versions of compatible object types; or both operands +are pointers to qualified or unqualified versions of compatible +incomplete types. +3.3.8(32) +Unacceptable operand of == or != +For the == or != operator, one of the following shall hold: both operands +are pointers to qualified or unqualified versions of compatible types; one +operand is a pointer to an object or incomplete type and the other is a +pointer to a qualified or unqualified version of void; or one operand is +a pointer and the other is a null pointer constant. +3.3.9(21) +Unacceptable operand of &. +Each of the operands shall have integral type. +3.3.10(7) +Unacceptable operand of ^. +Each of the operands shall have integral type. +3.3.11(18) +Unacceptable operand of |. +Each of the operands shall have integral type. +3.3.12(30) +Unacceptable operand of &&. +Each of the operands shall have scalar type. +3.3.13(7) +Unacceptable operand of ||. +Each of the operands shall have scalar type. +3.3.14(20) +Unacceptable operand of conditional operator. +The first operand of conditional operator shall have scalar type. One +of the following shall hold for the second and third operands: +both operands have arithmetic type; both operands have compatible +structure or union types; both operands have void type; both operands +are pointers to qualified or unqualified versions of compatible types; +one operand is a pointer and the other is a null pointer constant; or +one operand is pointer to an object or incomplete type and the other +is a pointer to a qualified or unqualified version of void. +3.3.15 +Duplicate label '%s' +A label name can only occur once in a function. +3.1.2.1(25) +Division by zero. +3.3.5 +Subscripting a non-array. +3.3.2.1 +Subscripting an array of incomplete type which is not an object type. +The element of the array shall have an object type. +3.3.2.1 +Should only subscript an array with an integral expression +3.3.2.1 +Subscripting an unbounded array +3.3.2.1 +Array index out of range +3.3.2.1 +Selector requires struct/union pointer as left hand side +In K&R mode the expression is implicitly converted to the '.' selector +for a struct/union left-hand side. +3.3.2.3 +Selector requires struct/union as left hand side +In K&R mode the expression is implicitly converted to the '->' selector +for a struct/union pointer left-hand side. +3.3.2.3 +member of structure or union required +3.3.2.3 +types have different qualifier specifications +For two qualified types to be compatible, both shall have the +identically qualified version of a compatible type; qualified +and unqualified versions of a type are distinct types. For two +types to be compatible their types must be the same. +3.5.3(26) +Incompatible array type due to different array size +For two array types to be compatible, both shall have compatible element +types; if both size specifiers are present, they shall have the +same value. +3.5.4.2(11) +Incompatible array type due to incompatible element type +For two array types to be compatible, both shall have compatible element +types. +3.5.4.2(11) +Incompatible pointer type assignment +The type pointed to by the left-hand side of simple assignment +statement is incompatible with the type pointed to by the right-hand side. +3.3.16.1, 3.5.4.1(21) +Incompatible base type of pointer type +K&R feature. +Type %s of %s is incompatible with type %s of %s +Incompatible types can be resolved by casting or by other means. +3.3.16.1 +illegal combination of pointer and integer +Assigning an integral expression to a pointer is a bad practice. +Type for %s is incompatible with %s +Incompatible types can be resolved by casting or by other means. +3.1.2.6 +Bad operand type for += or -= +3.3.16.2(26) +A case or default label appears outside a switch statement +A case or default label shall appear only in a switch statement. +3.6.1 +The controlling expression of the if statement is not scalar type +The controlling expression of an if statement shall have scalar type. +3.6.4.1 +The controlling expression of switch statement is not integral type +The controlling expression of an switch statement shall have integral type. +3.6.4.2(20) +The case label is not an integral constant expression +The case label shall be an integral constant expression. +3.6.4.2(22) +Duplicate case label in the same switch statement +No two of the case constant expressions in the same switch statement +shall have the same value after conversion. +3.6.4.2(22) +More than one default label in the same switch statement +There may be at most one default label in a switch statement. +3.6.4.2(23) +The controlling expression of the iteration statement is not scalar +type +The controlling expression of a iteration statement shall have scalar +type. +3.6.5.1 +label '%s' used, but not defined +The identifier in a goto statement shall name a label located +somewhere in the enclosing function. +3.6.6.1 +A continue statement shall appear only in or as a loop body +3.6.6.2 +A break statement shall appear only in or as a switch body or loop body +3.6.6.3 +A return statement with an expression should not appear +in a function '%s', whose return type is void +3.6.6.4(24) +A return statement without an expression appears in a +function '%s', whose return type is not void +If a return statement without an expression is executed, and the value +of the function call is used by the caller, the behavior is undefined. +3.6.6.4(33) +Internal Error: statement stack underflow +Long double not supported; double assumed. +Long float not standard; double assumed. +Only 'register' allowed in parameter declaration +The only storage-class specifier that shall occur in a parameter +declaration is 'register'; illegal storage class ignored. +3.5.4.3(25) +Name(s) without types in a function declaration +An old-style function declaration is not allowed to have names +in the parameter list; useless names ignored +3.5.4.3(26) +Functions cannot return functions +3.7.1(33), 3.3.2.2 +Functions cannot return a non-object type +3.3.2.2 +enum declaration must contain enum literals +Although structs or unions may delay the declaration of their members, +a similar construction with enum does not exist and is not necessary, +as there can be no mutual dependencies between the declaration of an +enumerated type and any other type. +3.5.2.3(27) +Register qualification has no effect for this type of object +Register declarations for array, struct, and function types have +no effect. +3.5.1(16), 3.5.1(19) +Functions cannot be declared 'register' +The declaration of an identifier for a function that has block +scope shall have no explicit storage-class specifier other than +'extern'. +3.5.1(19) +'%s' cannot be initialized +The type of the entity to be initialized shall be an object type +or an array of unknown size. +3.5.7(32) +Cannot initialize 'extern' variable '%s' within a function +If the declaration of an identifier has block scope, and the +identifier has 'extern' or 'static' linkage, the declaration +shall have no initializer for the identifier; initialization +allowed anyway. +3.5.7(35) +initializing an 'extern' is an ANSI C extension +conflicting declarations for '%s' +'static' and 'extern' declarations conflict. Which is meant? +3.1.2.2(15), 3.1.2.2(27) +Too many initial values for '%s' +3.5.7(1) +incompatible types in initialization +3.3.16(35) +redefinition of '%s'; previous definition at line %s in file '%s' +Identifier redeclared in the same scope/block. +3.1.2.3 +bit-fields as members of a union are an ANSI C invention. +storage size for '%s' isn't known +type mismatch in initialization +Missing braces in a union initialization or illegally formed +initialization. +3.5.7(5) +union '%s' only allowed one initializer for the first member +3.5.7(5) +width of '%s' exceeds its type +the specified bitfield width is too large to be contained within a +bitfield type. +structure has no member named '%s' +This is allowed for compatibility with AT&T pcc-based compilers. +Reference of an expression of void type or an incomplete type. +3.2.2.1 +element size of an array shall not be zero +3.2.2.5(25) +invalid combination of type specifiers +Although order is unimportant, not all type specifiers can occur together. +3.5.2 +declaration must at least declare an identifier, tag, or the member of an enumeration +3.5(16) +at most one storage class may be given in the declaration +Duplicate occurrence ignored. +3.5.1(10) +size of function's return type is zero +The return type of a function must be void or an object type other than array. +3.7.1(33) +Expecting an integral return type from the main function +identifier missing from parameter declaration +Prototypes for function definitions require identifiers in parameter +declarations. +3.7.1(4) +only 'register' allowed for storage class for parameters +The declarations in the declaration list shall contain no storage class +other than 'register', and no initializations. +3.7.1(10) +parameters declarations can not have initializations +3.7.1(10) +only one instance of 'void' allowed in the parameter list +'void' must occur by itself (specifying that the function has no parameters). +3.5.4.3(1) +%s must have function type +1) An argument list must be explicitly present in the declarator; it cannot + be inherited from a typedef (3.5.4.3). +2) The declarator is not a function. +3.7.1(30) +Illegal hexadecimal constant +You have no digits after the 0x or 0X. 0x0 assumed. +3.1.3.2 +value overflows its type in this context. Value is set to be '%s'! +3.2.1.4 +value is outside range representable for type '%s' +missing member name +K&R mode permits a missing member name; otherwise, only bitfields can omit +the member name. +3.5.2.1(10) +useless keyword or type name in declaration +Type was ignored. +'%s' declared within and is limited to this function prototype +Possible program error, since parameter type checking will always fail +unless the type declaration is visible to the caller. +3.1.2.1(35) +Extra spaces within operator, %s assumed +In ANSI C, the compound assignment operator cannot have embedded +white space characters. +3.1.5 +missing size for array '%s' +Incomplete types permitted for identifiers with internal or +external linkage, but not automatic linkage. +3.1.2.5(10) +can't jump into (from outside of) the body of a 'try' or into either type of handler +'%s' missing, please #include excpt.h +excpt.h required to declare exception statements, intrinsics or compiler +runtime names. +local function declarations cannot be 'static' +A function declaration can only contain the storage-class 'static' +if it is at file scope. Declaration made 'extern'. +3.5.1(19) +static function '%s' declared and referenced, but not defined. +If an identifier declared with internal linkage is used in an +expression (other than as a part of the operand of a sizeof +operator), there shall be exactly one external definition for +the identifier in the translation unit. +3.7(12) +pragma argument '%s' must be declared prior to being used in a pragma +Pragma name ignored. +Pragma not supported +'%s' not enabled as intrinsic +It may have already appeared in a function pragma, or never occurred in +an intrinsic pragma. +'%s' is already enabled as an intrinsic +weak definition for '%s' is later redefined; pragma weak ignored. +definition of primary name '%s' not found; pragma weak ignored. +definition of secondary name '%s' not found; pragma weak ignored. +primary name '%s' is declared as a common or external, and is not defined +with initial value within this file; pragma weak ignored. +useless '%s' storage class ignored +array of functions not allowed +The element type must be an object type representing a region +of data storage which can represent values. +3.1.2.5(23) +array of voids not allowed +The element type must be an object type representing a region +of data storage which can represent values. +3.1.2.5(23) +argument for pragma pack must be an integer constant; pragma ignored +'%s' has wrong tag type. +Identifier redeclared in the same scope/block. +3.1.2.3 +missing dimension bound +For multidimensional arrays, the constant bounds of the array may be +omitted only for the first member of the sequence. +3.1.2.5(23) +Internal error in parameters to function substr; loc: '%s'; len: '%s'. +Internal error in parameters to function insertstr; indx: '%s'. +Internal error in function get_tag_name; input is a non-tagged type. +Internal error in function gen_type_str -- not a type tree '%s' +Cannot open file '%s' +Prototype should be moved after tag or a typedef declaration. +Please look for comments in the extracted header file. +The extracted header file includes prototypes for static functions, +which should be removed, if you wish to include the header in a source file +other than the originator. +ANSI C requires formal parameter before "..." +This extension is meant to be used for compatibility with varargs.h +3.5.4.3(35) +syntax error: "&..." invalid +extension used to access "..." formal arguments. +function '%s' initialized like a variable +The type of entity to be initialized shall be an object type or an +array of unknown size. +3.5.7(31) +initializer not an array aggregate +The initializer for an object that has aggregate type shall be a +brace-enclosed list of initializers for the members of the aggregate, +written in increasing subscript or member order. +3.5.7(20) +'%s' type is incomplete; cannot initialize +Was the struct ever defined? +3.5.7.(31) +'%s' is not standard ANSI. +This keyword/type is not defined in strict ANSI mode. +3.1.1 +not a legal asm string +The first operand of an asm string should be, after argument substitution, +a legal assembly string. +The -float option will be ignored in ANSI mode. +The -float option is ignored, since otherwise program semantics would +violate the ANSI standard. In particular, fp constants are always +'double' with ANSI-C, while with -float the type of fp constants will +depend on the context and may be 'float'. +ANSI C support unavailable with C compiler bundled with RISC/os +The C compiler bundled with RISC/os does not support ANSI C. ANSI +C support requires a separate license. +Ignored invalid warning number(s) in -woff option, %s%s ! +Warning numbers must be in the range %s to %s. +The set of warning numbers in cfe is disjoint from the set of warning numbers +in accom, since accom warnings cannot be mapped one-to-one to cfe warnings. +'%s' not handled as an intrinsic due to incompatible argument types . +'__unalign' only qualifies pointers +'__unalign' indicates the object pointed at by pointer is unaligned (e.g., +int * __unalign p). This is an extension to ANSI C and like 'volatile' +and 'const' can follow the '*' in pointer declarations, but unlike both +cannot qualify a base type. +index expression is an anachronism +ANSI C++ doesn't support array index expressions in delete. +5.3.4 +member cannot be of function or incomplete type. +3.5.2.1(12) +Illegal lint option, '%s', is ignored. +cannot open header message buffer file +cannot write header message buffer file +cannot read header message buffer file +cannot seek in header message buffer file +struct/union/enum '%s' is used, but not defined +static '%s' unused +nonportable character comparison (chars may be signed or unsigned) +redundant comparison of unsigned with constant expression +redundant statement, control flow cannot reach this statement +'%s' may be used before set +function parameter '%s' is not used in function '%s' +'%s' can be const qualified, since it is not set within its lifetime. +'%s' is not used in function '%s' +'%s' set but unused in function '%s' +control may fall through %s statement +function '%s' has return(e); and return; +function '%s' may return random value to place of invocation %s +label without goto: '%s' +width of %s constant is smaller than size of type (%s) +explicit conversion from '%s' to '%s' %s +implicit conversion from '%s' to '%s' %s +'%s' may be indistinguishable from '%s' due to internal name truncation +Promoted formal parameter and promoted argument have incompatible types +No prototype for the definition of '%s' %s +References to '%s' are substituted by its literal initializer + (as included in %s) +============== +unsupported language linkage +string-literal specifies an unsupported linkage +7.4(1) +No prototype for the call to %s +To achieve better type-checking, there should be a full prototype for +the function being called. +3.5.4.3 +'inline' only applies to function declarations +leave statment can occur only within try body +Microsoft extension +Use of a Microsoft extension detected without usage of the +compiler option -msft. +No parameter mentioned +A file with no declarations or definitions is accepted as an extension to ANSI C +The translation unit must contain at least one external definition. +3.7 +Incompatible signed and unsigned version of a type +Yacc initialization error +Internal error: yacc cannot initialize itself. +The cfe option %s may not be in future releases. We suggest that you not use this option! +Incompatible char and unsigned char versions of a type +Lshift with undefined behaviour. +Lshift with a negative right operand, or a right operand that is greater +than or equal to the width in bits of the promoted left operand, results +in undefined behaviour. +3.3.7(11) +useless type name in declaration, possibly a semicolon is missing. +Type was ignored. +constant initializer expression is invalid (refers to automatic variables). +All the expressions in an initializer for an object that has static storage +duration or in the initializer list for an object that has aggregate or +union type shall be constant expressions. Otherwise, unexpected results +may occur. +3.5.7(32) and 3.4 +invalid explicit or implicit conversion of an address constant to an integral value in a constant initializing expression. +An address constant in a constant initializing expression can neither +initialize a bit-field nor be directly or indirectly converted to an +integral type of size different from an address type. +6.4 diff --git a/ido/ido5.3_recomp/ugen b/ido/ido5.3_recomp/ugen new file mode 100755 index 00000000..692086f0 Binary files /dev/null and b/ido/ido5.3_recomp/ugen differ diff --git a/ido/ido5.3_recomp/ujoin b/ido/ido5.3_recomp/ujoin new file mode 100755 index 00000000..98ba6065 Binary files /dev/null and b/ido/ido5.3_recomp/ujoin differ diff --git a/ido/ido5.3_recomp/uld b/ido/ido5.3_recomp/uld new file mode 100755 index 00000000..38833f5b Binary files /dev/null and b/ido/ido5.3_recomp/uld differ diff --git a/ido/ido5.3_recomp/umerge b/ido/ido5.3_recomp/umerge new file mode 100755 index 00000000..5b78e92e Binary files /dev/null and b/ido/ido5.3_recomp/umerge differ diff --git a/ido/ido5.3_recomp/uopt b/ido/ido5.3_recomp/uopt new file mode 100755 index 00000000..49558be9 Binary files /dev/null and b/ido/ido5.3_recomp/uopt differ diff --git a/ido/ido5.3_recomp/usplit b/ido/ido5.3_recomp/usplit new file mode 100755 index 00000000..e6a69ef8 Binary files /dev/null and b/ido/ido5.3_recomp/usplit differ diff --git a/ido/ido7.1_recomp/as1 b/ido/ido7.1_recomp/as1 new file mode 100755 index 00000000..a7bb3adc Binary files /dev/null and b/ido/ido7.1_recomp/as1 differ diff --git a/ido/ido7.1_recomp/cc b/ido/ido7.1_recomp/cc new file mode 100755 index 00000000..e926b545 Binary files /dev/null and b/ido/ido7.1_recomp/cc differ diff --git a/ido/ido7.1_recomp/cfe b/ido/ido7.1_recomp/cfe new file mode 100755 index 00000000..3a3e9831 Binary files /dev/null and b/ido/ido7.1_recomp/cfe differ diff --git a/ido/ido7.1_recomp/err.english.cc b/ido/ido7.1_recomp/err.english.cc new file mode 100644 index 00000000..b5d5be36 --- /dev/null +++ b/ido/ido7.1_recomp/err.english.cc @@ -0,0 +1,1260 @@ +@ + 358 358 358 + 6464 6482 6553 + 6553 6593 6728 + 6728 6746 6803 + 6803 6808 6808 + 6808 6818 6818 + 6818 6826 6826 + 6826 6847 6847 + 6847 6875 6922 + 6922 6930 6930 + 6930 6939 6939 + 6939 6948 6948 + 6948 6974 7120 + 7120 7149 7204 + 7210 7248 7311 + 7317 7350 7442 + 7450 7497 7627 + 7635 7709 7930 + 7938 7975 8063 + 8071 8113 8253 + 8261 8289 8289 + 8298 8338 8445 + 8460 8502 8635 + 8650 8690 8819 + 8834 8857 8965 + 8965 9008 9113 + 9119 9142 9227 + 9235 9282 9451 + 9451 9462 9462 + 9462 9477 9477 + 9477 9497 9497 + 9497 9545 9545 + 9545 9584 9584 + 9584 9604 9662 + 9662 9682 9720 + 9720 9749 9749 + 9749 9788 9788 + 9788 9802 9802 + 9802 9829 9829 + 9829 9861 9861 + 9861 9904 9904 + 9904 9920 9920 + 9920 9962 9962 + 9962 9988 9988 + 9988 10014 10014 +10014 10035 10035 +10035 10054 10097 +10097 10115 10115 +10115 10147 10147 +10147 10183 10183 +10183 10208 10208 +10208 10236 10236 +10236 10269 10269 +10269 10304 10304 +10304 10328 10328 +10328 10351 10351 +10351 10371 10371 +10371 10402 10402 +10402 10447 10447 +10447 10497 10497 +10497 10533 10533 +10533 10598 10598 +10606 10630 10630 +10640 10671 10671 +10690 10719 10719 +10728 10752 10795 +10795 10837 10837 +10837 10876 10876 +10876 10900 10900 +10900 10948 10948 +10960 11021 11103 +11103 11128 11128 +11128 11153 11153 +11153 11216 11216 +11216 11239 11239 +11239 11303 11303 +11303 11347 11347 +11357 11393 11393 +11393 11432 11432 +11442 11494 11494 +11494 11536 11536 +11536 11595 11595 +11595 11622 11622 +11622 11684 11684 +11684 11726 11726 +11738 11778 11778 +11782 11813 11813 +11813 11850 11850 +11850 11900 12087 +12111 12120 12120 +12120 12129 12129 +12129 12158 12158 +12158 12192 12192 +12192 12237 12237 +12237 12273 12273 +12273 12326 12326 +12330 12366 12366 +12366 12423 12423 +12427 12482 12482 +12486 12560 12560 +12568 12631 12631 +12637 12691 12691 +12691 12743 12743 +12743 12785 12785 +12785 12826 12826 +12826 12865 12865 +12865 12883 12883 +12883 12946 12946 +12956 12995 12995 +13005 13066 13066 +13077 13163 13163 +13163 13211 13211 +13211 13270 13270 +13270 13318 13318 +13318 13350 13350 +13350 13387 13387 +13387 13428 13428 +13428 13464 13533 +13533 13580 13737 +13737 13776 13854 +13854 13913 13913 +13913 13950 13950 +13950 14118 14118 +14118 14150 14150 +14150 14163 14194 +14194 14224 14255 +14255 14275 14319 +14319 14353 14458 +14466 14484 14530 +14534 14567 14567 +14567 14635 14682 +14690 14742 14742 +14742 14789 14789 +14801 14875 14875 +14886 14947 14947 +14947 14992 14992 +14992 15035 15085 +15085 15134 15205 +15214 15267 15448 +15454 15496 16810 +16822 16875 16960 +16972 17053 17179 +17191 17236 17332 +17344 17491 17841 +17853 17939 18304 +18316 18471 18774 +18786 18952 19323 +19335 19364 19496 +19500 19527 19598 +19598 19613 19776 +19797 19808 19837 +19837 19862 19862 +19868 19927 20026 +20034 20075 20179 +20187 20223 20223 +20223 20290 20382 +20392 20441 20589 +20601 20656 20656 +20656 20699 20818 +20826 20860 21038 +21046 21094 21191 +21203 21236 21314 +21326 21395 21457 +21469 21502 21502 +21502 21587 21731 +21756 21789 21864 +21875 21901 21976 +22013 22059 22220 +22257 22397 22561 +22561 22595 22595 +22603 22623 22623 +22631 22667 22828 +22865 22919 22994 +23031 23059 23120 +23132 23201 23201 +23212 23274 23274 +23285 23345 23345 +23356 23393 23393 +23399 23431 23532 +23542 23587 23646 +23656 23697 23745 +23755 23796 23844 +23854 23876 23928 +23942 23971 24153 +24160 24243 24243 +24247 24273 24743 +24755 24784 24984 +24996 25034 25034 +25034 25075 25273 +25281 25332 25410 +25420 25467 25544 +25554 25583 25744 +25754 25783 26061 +26071 26111 26185 +26194 26239 26525 +26535 26568 26914 +26924 26951 26998 +27008 27035 27082 +27093 27120 27167 +27178 27206 27251 +27261 27289 27334 +27345 27391 27931 +27938 27959 28007 +28019 28037 28037 +28043 28069 28069 +28077 28147 28199 +28207 28266 28266 +28274 28306 28306 +28314 28339 28339 +28347 28404 28510 +28518 28567 28682 +28690 28728 28728 +28736 28782 29023 +29033 29085 29234 +29246 29303 29383 +29395 29432 29570 +29592 29631 29644 +29644 29693 29758 +29767 29810 29875 +29875 29911 29976 +29984 30014 30014 +30027 30086 30151 +30157 30223 30293 +30301 30369 30445 +30457 30511 30568 +30580 30630 30743 +30755 30812 30874 +30886 30959 31035 +31043 31076 31175 +31183 31243 31243 +31251 31323 31323 +31331 31433 31433 +31445 31544 31686 +31698 31740 31740 +31740 31783 31783 +31783 31824 31824 +31824 31873 31996 +32008 32056 32164 +32176 32210 32210 +32229 32271 32271 +32279 32323 32569 +32581 32642 32718 +32739 32779 32916 +32926 32953 33047 +33057 33116 33315 +33325 33373 33373 +33373 33407 33469 +33494 33527 33527 +33536 33573 33573 +33584 33650 33697 +33705 33763 33763 +33763 33797 33797 +33797 33829 33906 +33915 33976 33976 +33985 34016 34098 +34098 34133 34198 +34198 34261 34261 +34269 34312 34312 +34324 34363 34438 +34444 34530 34530 +34538 34596 34626 +34636 34675 34754 +34764 34821 34821 +34821 34867 34950 +34959 35016 35135 +35145 35198 35198 +35208 35266 35344 +35355 35382 35537 +35547 35576 35629 +35637 35705 35705 +35713 35764 35764 +35764 35784 35876 +35888 35932 35950 +35950 36013 36138 +36150 36191 36280 +36286 36314 36419 +36431 36516 36516 +36516 36554 36642 +36642 36689 36808 +36818 36881 37105 +37113 37183 37204 +37204 37225 37225 +37225 37255 37348 +37348 37388 37388 +37388 37454 37454 +37454 37518 37518 +37518 37584 37584 +37584 37717 37717 +37717 37752 37752 +37752 37783 37889 +37901 37928 38034 +38046 38115 38115 +38115 38140 38187 +38195 38219 38339 +38351 38422 38422 +38422 38486 38486 +38486 38555 38555 +38555 38619 38619 +38619 38641 38641 +38641 38758 38758 +38758 38929 38929 +38929 38975 39043 +39055 39084 39133 +39133 39175 39265 +39275 39310 39494 +39504 39547 39576 +39587 39614 39668 +39674 39697 39797 +39797 39845 40094 +40094 40158 40264 +40264 40369 40523 +40523 40593 40593 +40593 40629 40876 +40876 40911 40971 +40977 41026 41026 +41038 41077 41077 +41077 41116 41116 +41116 41156 41156 +41156 41195 41195 +41195 41237 41237 +41237 41285 41285 +41285 41304 41304 +41304 41371 41371 +41371 41429 41429 +41429 41491 41491 +41491 41519 41519 +41519 41572 41572 +41572 41642 41642 +41642 41676 41676 +41676 41713 41713 +41713 41751 41751 +41751 41792 41792 +41792 41856 41856 +41856 41881 41881 +41881 41944 41944 +41944 41985 41985 +41985 42026 42026 +42026 42098 42098 +42098 42170 42170 +42170 42213 42213 +42213 42275 42275 +42275 42302 42302 +42302 42317 42317 +42317 42346 42394 +42401 42433 42530 +42538 42585 42585 +42585 42631 42631 +42631 42651 42733 +42733 42756 42756 +42756 42837 42905 +42909 42960 42960 +42960 42986 43033 +43033 43124 43124 +43124 43179 43179 +43179 43212 43384 +43394 43461 43479 +43479 43555 43788 +43806 43929 44124 +44128 44128 44128 +Out of memory: %s +There is no more memory left in the system for compiling this program. +Internal Error Unknown Error Message %s +1) An internal error, while attempting to print an unavailable message +2) The error message file is inaccessible or has other problems +Unknown Signal %s +1) An unknown signal has been caught +2) 2 Nested signals +line +Warning: +Fatal: +Source not available +Too many errors... goodbye. +There is a limit of 30 errors before aborting. +Error: +reserved +reserved +Unknown Control Statement +1) The line begins with a '#' and is not of the form: + # "" +2) Please compile this program with the preprocessor enabled. +Unknown character %s ignored +The character is not part of the source character set. +2.2.1 +Unknown control character \%s ignored +The control character is not part of the source character set. +2.2.1 +Illegal character %s in exponent +1) Digits or sign expected after 'e' or 'E'. +2) Digits are expected after sign in exponent. +3.1.3.1 +Constant is out of range and may be truncated. +The constant is too large to be accurately represented and may be +truncated. The limits are in the system include file limits.h. +2.2.4.2 +Constant is out of range for a 32-bit data type, but accepted as written. +The constant is too large to fit in a 32-bit data type, but will be +accurately represented in a wider data type. The value may be truncated, +depending on its context. The limits are in the system include file +limits.h. +2.2.4.2 +Character constant size out of range +1) No characters in a character constant. +2) More than 4 bytes in a character constant. +3.1.3.4 +Wide character constant size out of range +1) No characters in the multibyte sequence (0 assumed). +2) More than 1 byte in the multi-byte sequence (only the first byte was converted). +3.1.3.4 +Invalid multibyte character +4.10.7.2 +Newline in string or character constant +1) Terminate your string or character constant with closing quotes. +2) Put a backslash before the newline. +3.1.3.4, 3.1.4 +Octal character escape too large: %s > %s +1) Terminate end of octal sequence with a non-octal character. +2) Select a character value within the limits. +Value may be truncated +3.1.3.4, 3.1.4 +Hex character escape too large: %s > %s +1) Terminate end of hex sequence with a non-hex character. +2) Select a character value within the limits. +Value may be truncated +3.1.3.4, 3.1.4 +Unexpected End-of-file +1) Unterminated string or character constant +2) Missing closing comment marker (*/) +3) File system problems +Unrecognized escape sequence in string \%s +Recognized escape sequences are \a, \b, \f, \n, \r, \t, and \v. +Character will be treated as un-escaped. +3.9.2 +Illegal octal digit %s +Octal constants, beginning with 0, must only have digits between 0 and 7, +inclusive. +3.1.3.2 +Unable to open temporary file for compiling %s +1) TMPDIR environment variable is set to a directory that you have no + permissions for. +2) The file system is full. +3) System errors beyond the scope of the compiler. +%s: Hangup +%s: Interrupt +%s: Quit (ASCII FS) +%s: Illegal instruction (not reset when caught) +%s: Trace trap (not reset when caught) +%s: IOT instruction +Also SIGABRT, used by abort, replace SIGIOT in the future +%s: EMT instruction +Also SIGXCPU, Exceeded CPU time limit +%s: Floating point exception +%s: Kill (cannot be caught or ignored) +%s: Bus error +%s: Segmentation violation +%s: Bad argument to system call +%s: Write on a pipe with no one to read it +%s: Alarm clock +%s: Software termination signal from kill +%s: User defined signal 1 +%s: User defined signal 2 +%s: Death of a child +Power-fail restart +%s: Also SIGXFSZ, exceeded file size limit +%s: Window change +%s: Handset, line status change +%s: Sendablestop signalnot from tty +%s: Stop signal from tty +%s: Pollable event occurred +%s: Input/Output possible signal +%s: Urgent condition on IO channel +%s: Window size changes +%s: Virtual time alarm +%s: Profiling alarm +%s: Continue a stopped process +%s: To readers pgrp upon background tty read +%s: Like TTIN for output if (tp->t_local<OSTOP) +%s: Resource lost (eg, record-lock) +'auto' and 'register' are not allowed in an external declaration +3.7(10) +must have function type +3.7.1(30) +Functions cannot return arrays +3.7.1(33), 3.3.2.2 +Declaration list not allowed +3.7.1(5) +Too many input files %s +The command line may contain only one file +cpp internal error: input stack underflow +cpp internal error: if stack underflow +Cannot open the file %s +No new-line character at the end of the file %s +2.1.1.2(30) +Fatal: Exceeded the limit of nesting level for #include file +Fatal: Exceeded the limit of nesting level for #include file. This limit +is 200. +Fail to read the file %s +Cannot write the file %s +%s: %s: An if directive is not terminated properly in the file +%s: %s: nested comment +%s:%s: Illegal macro name %s; macro name shall be an identifier +%s:%s: Illegal preprocessing token sequence +3.8.3(35) +%s:%s: Illegal macro parameter name +%s:%s: Non-unique macro parameter name +3.8.3(18) +%s:%s: Missing ')' in parameter list for #define %s +%s:%s: Missing ')' in macro instantiation +%s:%s: Bad punctuator in the parameter list for #define %s +%s:%s: Macro %s redefined. +%s:%s: # operator should be followed by a macro argument name +%s:%s: Badly formed constant expression%s +3.4(9), 3.8 +%s:%s: Division by zero in #if or #elif +3.8 +unknown command line option %s +extraneous input/output file name %s +%s: %s: Unterminated string or character constant +A preprocessing string or character constant token was not +terminated. Note that preprocessing directives are processed +after the source file has been divided into preprocessing tokens. +2.1.1.2(30) 3.1(18) 3.8 +%s: %s: +%s: %s: +%s: %s: Unterminated comment +%s: %s: Unknown directive type %s +%s: %s: #elif or #else after #else directive +%s: %s: Bad identifier after the %s +%s: %s: #%s accepts only one identifier as parameter +3.8 +%s: %s: Bad identifier after the %s +%s: %s: text following #%s violates the ANSI C standard. +3.8 +%s: %s: Bad character %s occurs after the # directive. +3.8 +%s: %s: the ## operator shall not be the %s token in the replacement list +3.8.3.3 +%s: %s: the defined operator takes identifier as operand only. +3.8.1 +%s: %s: Not in a conditional directive while using %s +%s: %s: Illegal filename specification for #include +%s: %s: Invalid file name %s for #include +%s: %s: Cannot open file %s for #include +%s: %s: Bad argument for #line command +%s: %s: #error %s +%s: %s: Tried to redefine predefined macro %s, attempt ignored +3.8.7(22) +%s: %s: Undefining predefined macro %s +3.8.7(22) +%s: %s: Undefined the ANSI standard library defined macro %s +4.1.2.1(9) +%s: %s: The number of arguments in the macro invocation does not match the definition +%s: %s: Illegal character %s in preprocessor if +%s: %s: Illegal character %s for number in preprocessor if +%s: %s: No string is allowed in preprocessor if +%s: %s: Not supported pragma %s +%s: %s: Not supported #pragma format +%s: %s: ANSI C does not allow #ident; %s +%s: %s: Not supported #ident format +This cpp extension accepts the following format: +#ident "any string" +%s: %s: Not supported #assert/#unassert format +This cpp extension accepts the following format: +#assert identifier +#assert identifier ( pp-tokens ) +#unassert identifier +#unassert identifier ( pp-tokens ) +%s: %s: Bad assertion predicate format +The correct syntax for this cpp extension is: +#assert identifier ( pp-token ) +%s: %s: directive is an upward-compatible ANSI C extension +%s: This option requires an argument +%s: %s: A macro has expanded recursively more than %s times. Further expansion will be disabled! Use command-line option: -Wp,-max_rec_depth=depth to recurse deeper. +A status return from cpp to cfe +Syntax Error +The token read was unexpected. +Syntax Error -- cannot backup +The token read was unexpected. +Yacc stack overflow +The expression is too complicated to parse. +Trailing comma in enumerator list +The use of a trailing comma in an enumerator list is not standard C. There +may be portability problems. +3.5.2.2 +Empty declaration +Empty declarations are invalid in standard C. +3.5 +%s declared, but not referenced. +redeclaration of '%s'; previous declaration at line %s in file '%s' +Identifier redeclared in the same scope/block. +3.1.2.3 +'%s' undefined; reoccurrences will not be reported. +Non-function name referenced in function call. +3.3.2.2(18) +The number of arguments doesn't agree with the number in the declaration. +3.3.2.2(5) +'%s' section name longer than 8 characters. Name truncated. +'%s' is already placed by pragma alloc_text. +Cannot write ucode file while compiling %s +1) The file system is full +2) Permissions problem +Must have corresponding formal argument for '%s' +Parameter found in the declaration part, but not in the argument list. +3.7.1(7) +Non-prototype declaration is an obsolescent feature. +The use of function definitions with separate parameter identifier +and declaration lists (not prototype-format parameter type and +identifier declarators) is an obsolescent feature. +3.9.5 +Incompatible function declarations for %s +For two function types to be compatible, both shall specify compatible +return types. Moreover, the parameter type lists, if both are present, +shall agree in the number of parameters and in use of the ellipsis +terminator; corresponding parameters shall have compatible types. If +one type has a parameter type list and the other type is specified by +a function declarator that is not part of a function definition and +contains an empty identifier list, the parameter list shall not have +an ellipsis terminator and the type of each parameter shall be +compatible with they type that results from application of the default +argument promotions. If one type has a parameter type list and the +other is specified by a function definition that contains a (possibly +empty) identifier list, both shall agree in the number of parameters, +and the type of each prototype parameter shall be compatible with the +type that results from application of the default argument promotions +to the type of the corresponding identifier. (For each parameter +declared with function or array type, its type for these comparisons +is the one that results from conversion to a pointer type. For each +parameter declared with qualified type, its type for these comparisons +is the unqualified version of its declared type.) There you have it! +3.5.4.3(15) +Incompatible function return type for this function. +For two function types to be compatible, both shall specify compatible +return types. +3.5.4.3(15) +The number of parameters for function is different from the previous declaration +The parameter type lists, if both are present, shall agree in the +number of parameters and in use of the ellipsis terminator. +3.5.4.3(15) +Incompatible type for the function parameter +If both parameter type lists are present, corresponding +parameters shall have compatible types. +3.5.4.3(15) +Function %s is redeclared with an incompatible argument type (after default argument promotion), which could lead to undefined run-time behaviour. +The redeclaration could cause arguments at a call site to be passed +inconsistently with what the function implementation expects, and +parameters would therefore be accessed erroneously when executing the +function body. Note that a float argument is promoted to a double +when passed (potentially through fp registers) to an unprototyped +function. +3.5.4.3(15) +prototype and non-prototype declaration found for %s, ellipsis terminator not allowed +If one type has a parameter type list and the other type is specified +by a function declarator that is not part of a function definition and +contains an empty identifier list, the parameter list shall not have +an ellipsis terminator and the type of each parameter shall be +compatible with they type that results from application of the default +argument promotions. +3.5.4.3(15) +prototype and non-prototype declaration found for %s, the type of this parameter is not compatible with the type after applying default argument promotion +If one type has a parameter type list and the other type is specified +by a function declarator that is not part of a function definition and +contains an empty identifier list, the type of each parameter shall be +compatible with the type that results from application of the default +argument promotions. +3.5.4.3(15) +prototype declaration and non-prototype definition found for %s, the type of this parameter is not compatible with the type after applying default argument promotion +If one type has a parameter type list and the other is specified by a +function definition that contains a (possibly empty) identifier list, +both shall agree in the number of parameters, and the type of each +prototype parameter shall be compatible with the type that results +from application of the default argument promotions to the type of the +corresponding identifier. +3.5.4.3(15) +Empty declaration specifiers +Standard C requires at least a storage class specifier, type specifier, +or a type qualifier in declarations. 'extern int' assumed. +3.5 +Can't write to the file %s +1) The output file cannot be opened for writing. +2) Out of file space. +Duplicate '%s' +typedef, extern, static, auto, register, const, volatile may not +appear more than once in the same specifier list or qualifier list. +Duplicate occurrence ignored. +3.5.1(10) , 3.5.3(5) +Null input +There is nothing to compile. +Illegal type combination +3.5.2 +Missing ';' at end of structure / union member declaration +In standard C, each member declaration must be terminated by a ';'. A +terminating ';' is assumed. +3.5.2.1 +Missing member name in structure / union +In standard C, each member declaration have a member name. The missing +member is assumed to not exist. +3.5.2.1 +This variable is initialized twice. +Neither 'const' or 'volatile' have any effect on function results. +Qualifiers only apply to expressions designating an object that +can be altered or examined. +3.5.3(10) +An integer constant expression is required here. +The expression that defines the value of an enumeration constant +shall be an integral constant expression that has a value +representable as an int. +3.5.2.2(28) +(previous declaration of '%s' at line %s in file '%s') +Must be an integer type greater than zero. +The array size must be either a char, signed or unsigned integer or +an enumerated type with a value greater than zero. +3.5.4.2 +Array size cannot be a long long. +Arrays with more than 2^32 elements are not yet supported. +The array size must be either a char, signed or unsigned integer or +an enumerated type with a value greater than zero. +3.5.4.2 +bit-field '%s' width is not an integer constant +The expression that specifies the width of a bit-field shall be an +integral constant expression. +3.5.2.1(15) +bit-field '%s' width is negative +The expression that specifies the width of a bit-field shall be +non-negative. +3.5.2.1(15) +bit-field '%s' type required to be int, unsigned int, or signed int. +A bit-field shall have type int, unsigned int, or signed int. +3.5.2.1(30) +bit-field %s's type not integer. +Non-scalar type or pointer type to a non-object for increment or decrement operator. +The operand of the prefix/postfix increment or decrement operator shall have scalar type; if it is of pointer type, it must point to an object. +3.3.2.4(37), 3.3.3.1(25) +Assign value to a function type. +An assignment operator shall have a modifiable lvalue as its left operand. +3.2.2.1(5) +Assign value to an array. +An assignment operator shall have a modifiable lvalue as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +Change value for variable of incomplete type. +The operand of increment and decrement operator shall be a modifiable +scalar lvalue. An assignment operator shall have a modifiable lvalue +as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +The left-hand side of the '.' operator must be an addressable lvalue, when a bit-field is not contained within a unit of 32 bits alignment. +This is a restriction in our implementation, which can be worked +around by always accessing long long bit-fields indirectly (i.e. +by means of the '->' operator). +This expression is not an lvalue. +3.2.2.1 +Modified an rvalue. +3.2.2.1 +Change value for constant variable. +The operand of increment and decrement operators shall be modifiable +scalar lvalues. An assignment operator shall have a modifiable lvalue +as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +Change value for constant field of a struct or union. +An assignment operator shall have a modifiable lvalue as its left operand. +3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) +Dereferenced a non-pointer. +The operand of the unary * operator shall have pointer type. +3.3.3.2(39) +The operand of the unary + or - operator shall have arithmetic type. +3.3.3.3(6) +The operand of the unary ~ operator shall have integral type. +3.3.3.3(6) +The operand of the unary ! operator shall have scalar type. +3.3.3.3(6) +Constants must have arithmetic type. +3.1.3 +Bad type name for cast operator +The type name for the cast operator should either be void or a +qualified or unqualified scalar type. +3.3.4(22) +Improper cast of non-scalar type expression. +The operand for the cast operator shall be of scalar type. +3.3.4(23) +Cast a pointer into a non-integral type. +A pointer may be converted to an integral type. +3.3.4(31) +Cast a non-integral type into a pointer. +An integral type may be converted to a pointer. +3.3.4(31) +Duplicate member '%s' +Two members of a struct may not have the same name. +3.1.2.2(7,25) +Invalid constant expression. +Constant expressions shall not contain assignment, increment, decrement, +function-call, or comma operators, except when they are contained within +the operand of the sizeof operator. +3.4(9) +Constant expressions must be derived from a constant value or a constant +variable. +3.4 +Dangerous operand of '&'. +The operand of the unary & operator shall be either a function +designator or an lvalue that designates an object that is not a +bit-field and is not declared with the register storage-class +specifier. This operand is NOT an lvalue, but we let it pass. +Note that a segmentation error with possible core dump will result +when the resulting address does not denote a valid (declared) +storage location. This feature will be discontinued in future +releases of the compiler! +3.3.3.2(36) +Unacceptable operand of '&'. +The operand of the unary & operator shall be either a function +designator or an lvalue that designates an object that is not a +bit-field and is not declared with the register storage-class +specifier. +3.3.3.2(36) +'&' before array or function; ignored +Unacceptable operand of sizeof operator. +The sizeof operator shall not be applied to an expression that has +function type or an incomplete type, to the parenthesized name of such +a type, or to an lvalue that designates a bit-field object. +3.3.3.4 +Unacceptable operand of a multiplicative operator. +Each of the operands of a multiplicative operator shall have arithmetic type. +3.3.5(18) +Unacceptable operand of the remainder operator +Each of the operands of the remainder (%) operator shall have integral type. +3.3.5(18) +Unacceptable operand of '+'. +For the + operator, either both operands shall have arithmetic type, or +one operand shall be a pointer to an object type and the other shall +have integral type. +3.3.6(39) +Unacceptable operand of '-'. +For the subtraction operator, one of the following shall hold: both operands +have arithmetic type; operands are pointers to qualified or unqualified +versions of compatible object types; or the left operand is a pointer +to an object type and the right operand has integral type. +3.3.6(39) +Unacceptable operand of shift operator. +Each of the operands of bitwise shift operators shall have integral type. +3.3.7(9) +Unacceptable operand of relational operator. +For relational operators, one of the following shall hold: both +operands have arithmetic type; both operands are pointers to qualified +or unqualified versions of compatible object types; or both operands +are pointers to qualified or unqualified versions of compatible +incomplete types. +3.3.8(32) +Unacceptable operand of == or != +For the == or != operator, one of the following shall hold: both operands +are pointers to qualified or unqualified versions of compatible types; one +operand is a pointer to an object or incomplete type and the other is a +pointer to a qualified or unqualified version of void; or one operand is +a pointer and the other is a null pointer constant. +3.3.9(21) +Unacceptable operand of &. +Each of the operands shall have integral type. +3.3.10(7) +Unacceptable operand of ^. +Each of the operands shall have integral type. +3.3.11(18) +Unacceptable operand of |. +Each of the operands shall have integral type. +3.3.12(30) +Unacceptable operand of &&. +Each of the operands shall have scalar type. +3.3.13(7) +Unacceptable operand of ||. +Each of the operands shall have scalar type. +3.3.14(20) +Unacceptable operand of conditional operator. +The first operand of conditional operator shall have scalar type. One +of the following shall hold for the second and third operands: +both operands have arithmetic type; both operands have compatible +structure or union types; both operands have void type; both operands +are pointers to qualified or unqualified versions of compatible types; +one operand is a pointer and the other is a null pointer constant; or +one operand is pointer to an object or incomplete type and the other +is a pointer to a qualified or unqualified version of void. +3.3.15 +Duplicate label '%s' +A label name can only occur once in a function. +3.1.2.1(25) +Division by zero. +3.3.5 +Subscripting a non-array. +3.3.2.1 +Subscripting an array of incomplete type which is not an object type. +The element of the array shall have an object type. +3.3.2.1 +Should only subscript an array with an integral expression +3.3.2.1 +Subscripting an unbounded array +3.3.2.1 +Array index out of range +3.3.2.1 +Selector requires struct/union pointer as left hand side +In K&R mode the expression is implicitly converted to the '.' selector +for a struct/union left-hand side. +3.3.2.3 +Selector requires struct/union as left hand side +In K&R mode the expression is implicitly converted to the '->' selector +for a struct/union pointer left-hand side. +3.3.2.3 +member of structure or union required +3.3.2.3 +types have different qualifier specifications +For two qualified types to be compatible, both shall have the +identically qualified version of a compatible type; qualified +and unqualified versions of a type are distinct types. For two +types to be compatible their types must be the same. +3.5.3(26) +Incompatible array type due to different array size +For two array types to be compatible, both shall have compatible element +types; if both size specifiers are present, they shall have the +same value. +3.5.4.2(11) +Incompatible array type due to incompatible element type +For two array types to be compatible, both shall have compatible element +types. +3.5.4.2(11) +Incompatible pointer type assignment +The type pointed to by the left-hand side of simple assignment +statement is incompatible with the type pointed to by the right-hand side. +3.3.16.1, 3.5.4.1(21) +Incompatible base type of pointer type +K&R feature. +Type %s of %s is incompatible with type %s of %s +Incompatible types can be resolved by casting or by other means. +3.3.16.1 +illegal combination of pointer and integer +Assigning an integral expression to a pointer is a bad practice. +Type for %s is incompatible with %s +Incompatible types can be resolved by casting or by other means. +3.1.2.6 +Bad operand type for += or -= +3.3.16.2(26) +A case or default label appears outside a switch statement +A case or default label shall appear only in a switch statement. +3.6.1 +The controlling expression of the if statement is not scalar type +The controlling expression of an if statement shall have scalar type. +3.6.4.1 +The controlling expression of switch statement is not integral type +The controlling expression of an switch statement shall have integral type. +3.6.4.2(20) +The case label is not an integral constant expression +The case label shall be an integral constant expression. +3.6.4.2(22) +Duplicate case label in the same switch statement +No two of the case constant expressions in the same switch statement +shall have the same value after conversion. +3.6.4.2(22) +More than one default label in the same switch statement +There may be at most one default label in a switch statement. +3.6.4.2(23) +The controlling expression of the iteration statement is not scalar +type +The controlling expression of a iteration statement shall have scalar +type. +3.6.5.1 +label '%s' used, but not defined +The identifier in a goto statement shall name a label located +somewhere in the enclosing function. +3.6.6.1 +A continue statement shall appear only in or as a loop body +3.6.6.2 +A break statement shall appear only in or as a switch body or loop body +3.6.6.3 +A return statement with an expression should not appear +in a function '%s', whose return type is void +3.6.6.4(24) +A return statement without an expression appears in a +function '%s', whose return type is not void +If a return statement without an expression is executed, and the value +of the function call is used by the caller, the behavior is undefined. +3.6.6.4(33) +Internal Error: statement stack underflow +Long double not supported; double assumed. +Long float not standard; double assumed. +Only 'register' allowed in parameter declaration +The only storage-class specifier that shall occur in a parameter +declaration is 'register'; illegal storage class ignored. +3.5.4.3(25) +Name(s) without types in a function declaration +An old-style function declaration is not allowed to have names +in the parameter list; useless names ignored +3.5.4.3(26) +Functions cannot return functions +3.7.1(33), 3.3.2.2 +Functions cannot return a non-object type +3.3.2.2 +enum declaration must contain enum literals +Although structs or unions may delay the declaration of their members, +a similar construction with enum does not exist and is not necessary, +as there can be no mutual dependencies between the declaration of an +enumerated type and any other type. +3.5.2.3(27) +Register qualification has no effect for this type of object +Register declarations for array, struct, and function types have +no effect. +3.5.1(16), 3.5.1(19) +Functions cannot be declared 'register' +The declaration of an identifier for a function that has block +scope shall have no explicit storage-class specifier other than +'extern'. +3.5.1(19) +'%s' cannot be initialized +The type of the entity to be initialized shall be an object type +or an array of unknown size. +3.5.7(32) +Cannot initialize 'extern' variable '%s' within a function +If the declaration of an identifier has block scope, and the +identifier has 'extern' or 'static' linkage, the declaration +shall have no initializer for the identifier; initialization +allowed anyway. +3.5.7(35) +initializing an 'extern' is an ANSI C extension +conflicting declarations for '%s' +'static' and 'extern' declarations conflict. Which is meant? +3.1.2.2(15), 3.1.2.2(27) +Too many initial values for '%s' +3.5.7(1) +incompatible types in initialization +3.3.16(35) +redefinition of '%s'; previous definition at line %s in file '%s' +Identifier redeclared in the same scope/block. +3.1.2.3 +bit-fields as members of a union are an ANSI C invention. +storage size for '%s' isn't known +type mismatch in initialization +Missing braces in a union initialization or illegally formed +initialization. +3.5.7(5) +union '%s' only allowed one initializer for the first member +3.5.7(5) +width of '%s' exceeds its type +the specified bitfield width is too large to be contained within a +bitfield type. +structure has no member named '%s' +This is allowed for compatibility with AT&T pcc-based compilers. +Reference of an expression of void type or an incomplete type. +3.2.2.1 +element size of an array shall not be zero +3.2.2.5(25) +invalid combination of type specifiers +Although order is unimportant, not all type specifiers can occur together. +3.5.2 +declaration must at least declare an identifier, tag, or the member of an enumeration +3.5(16) +at most one storage class may be given in the declaration +Duplicate occurrence ignored. +3.5.1(10) +size of function's return type is zero +The return type of a function must be void or an object type other than array. +3.7.1(33) +Expecting an integral return type from the main function +identifier missing from parameter declaration +Prototypes for function definitions require identifiers in parameter +declarations. +3.7.1(4) +only 'register' allowed for storage class for parameters +The declarations in the declaration list shall contain no storage class +other than 'register', and no initializations. +3.7.1(10) +parameters declarations can not have initializations +3.7.1(10) +only one instance of 'void' allowed in the parameter list +'void' must occur by itself (specifying that the function has no parameters). +3.5.4.3(1) +%s must have function type +1) An argument list must be explicitly present in the declarator; it cannot + be inherited from a typedef (3.5.4.3). +2) The declarator is not a function. +3.7.1(30) +Illegal hexadecimal constant +You have no digits after the 0x or 0X. 0x0 assumed. +3.1.3.2 +value overflows its type in this context. Value is set to be '%s'! +3.2.1.4 +value is outside range representable for type '%s' +missing member name +K&R mode permits a missing member name; otherwise, only bitfields can omit +the member name. +3.5.2.1(10) +useless keyword or type name in declaration +Type was ignored. +'%s' declared within and is limited to this function prototype +Possible program error, since parameter type checking will always fail +unless the type declaration is visible to the caller. +3.1.2.1(35) +Extra spaces within operator, %s assumed +In ANSI C, the compound assignment operator cannot have embedded +white space characters. +3.1.5 +missing size for array '%s' +Incomplete types permitted for identifiers with internal or +external linkage, but not automatic linkage. +3.1.2.5(10) +can't jump into (from outside of) the body of a 'try' or into either type of handler +'%s' missing, please #include excpt.h +excpt.h required to declare exception statements, intrinsics or compiler +runtime names. +local function declarations cannot be 'static' +A function declaration can only contain the storage-class 'static' +if it is at file scope. Declaration made 'extern'. +3.5.1(19) +static function '%s' declared and referenced, but not defined. +If an identifier declared with internal linkage is used in an +expression (other than as a part of the operand of a sizeof +operator), there shall be exactly one external definition for +the identifier in the translation unit. +3.7(12) +pragma argument '%s' must be declared prior to being used in a pragma +Pragma name ignored. +Pragma not supported +'%s' not enabled as intrinsic +It may have already appeared in a function pragma, or never occurred in +an intrinsic pragma. +'%s' is already enabled as an intrinsic +weak definition for '%s' is later redefined; pragma weak ignored. +definition of primary name '%s' not found; pragma weak ignored. +definition of secondary name '%s' not found; pragma weak ignored. +primary name '%s' is declared as a common or external, and is not defined +with initial value within this file; pragma weak ignored. +useless '%s' storage class ignored +array of functions not allowed +The element type must be an object type representing a region +of data storage which can represent values. +3.1.2.5(23) +array of voids not allowed +The element type must be an object type representing a region +of data storage which can represent values. +3.1.2.5(23) +argument for pragma pack must be an integer constant; pragma ignored +'%s' has wrong tag type. +Identifier redeclared in the same scope/block. +3.1.2.3 +missing dimension bound +For multidimensional arrays, the constant bounds of the array may be +omitted only for the first member of the sequence. +3.1.2.5(23) +Internal error in parameters to function substr; loc: '%s'; len: '%s'. +Internal error in parameters to function insertstr; indx: '%s'. +Internal error in function get_tag_name; input is a non-tagged type. +Internal error in function gen_type_str -- not a type tree '%s' +Cannot open file '%s' +Prototype should be moved after tag or a typedef declaration. +Please look for comments in the extracted header file. +The extracted header file includes prototypes for static functions, +which should be removed, if you wish to include the header in a source file +other than the originator. +ANSI C requires formal parameter before "..." +This extension is meant to be used for compatibility with varargs.h +3.5.4.3(35) +syntax error: "&..." invalid +extension used to access "..." formal arguments. +function '%s' initialized like a variable +The type of entity to be initialized shall be an object type or an +array of unknown size. +3.5.7(31) +initializer not an array aggregate +The initializer for an object that has aggregate type shall be a +brace-enclosed list of initializers for the members of the aggregate, +written in increasing subscript or member order. +3.5.7(20) +'%s' type is incomplete; cannot initialize +Was the struct ever defined? +3.5.7.(31) +'%s' is not standard ANSI. +This keyword/type is not defined in strict ANSI mode. +3.1.1 +not a legal asm string +The first operand of an asm string should be, after argument substitution, +a legal assembly string. +The -float option will be ignored in ANSI mode. +The -float option is ignored, since otherwise program semantics would +violate the ANSI standard. In particular, fp constants are always +'double' with ANSI-C, while with -float the type of fp constants will +depend on the context and may be 'float'. +ANSI C support unavailable with C compiler bundled with RISC/os +The C compiler bundled with RISC/os does not support ANSI C. ANSI +C support requires a separate license. +Ignored invalid warning number(s) in -woff option, %s%s ! +Warning numbers must be in the range %s to %s. +The set of warning numbers in cfe is disjoint from the set of warning numbers +in accom, since accom warnings cannot be mapped one-to-one to cfe warnings. +'%s' not handled as an intrinsic due to incompatible argument types . +'__unalign' only qualifies pointers +'__unalign' indicates the object pointed at by pointer is unaligned (e.g., +int * __unalign p). This is an extension to ANSI C and like 'volatile' +and 'const' can follow the '*' in pointer declarations, but unlike both +cannot qualify a base type. +index expression is an anachronism +ANSI C++ doesn't support array index expressions in delete. +5.3.4 +member cannot be of function or incomplete type. +3.5.2.1(12) +Illegal lint option, '%s', is ignored. +cannot open header message buffer file +cannot write header message buffer file +cannot read header message buffer file +cannot seek in header message buffer file +struct/union/enum '%s' is used, but not defined +static '%s' unused +nonportable character comparison (chars may be signed or unsigned) +redundant comparison of unsigned with constant expression +redundant statement, control flow cannot reach this statement +'%s' may be used before set +function parameter '%s' is not used in function '%s' +'%s' can be const qualified, since it is not set within its lifetime. +'%s' is not used in function '%s' +'%s' set but unused in function '%s' +control may fall through %s statement +function '%s' has return(e); and return; +function '%s' may return random value to place of invocation %s +label without goto: '%s' +only %s bits of '%s' constant (type '%s') are explicitly given +explicit conversion from '%s' to '%s' %s +implicit conversion from '%s' to '%s' %s +'%s' may be indistinguishable from '%s' due to internal name truncation +Promoted formal parameter and promoted argument have incompatible types +No prototype for the definition of '%s' %s +References to '%s' are substituted by its literal initializer + (as included in %s) +============== +unsupported language linkage +string-literal specifies an unsupported linkage +7.4(1) +No prototype for the call to %s +To achieve better type-checking, there should be a full prototype for +the function being called. +3.5.4.3 +'inline' only applies to function declarations +leave statment can occur only within try body +Microsoft extension +Use of a Microsoft extension detected without usage of the +compiler option -msft. +No parameter mentioned +A file with no declarations or definitions is accepted as an extension to ANSI C +The translation unit must contain at least one external definition. +3.7 +Incompatible signed and unsigned version of a type +Yacc initialization error +Internal error: yacc cannot initialize itself. +The cfe option %s may not be in future releases. We suggest that you not use this option! +Incompatible char and unsigned char versions of a type +Lshift with undefined behaviour. +Lshift with a negative right operand, or a right operand that is greater +than or equal to the width in bits of the promoted left operand, results +in undefined behaviour. +3.3.7(11) +useless type name in declaration, possibly a semicolon is missing. +Type was ignored. +constant initializer expression is invalid (refers to automatic variables). +All the expressions in an initializer for an object that has static storage +duration or in the initializer list for an object that has aggregate or +union type shall be constant expressions. Otherwise, unexpected results +may occur. +3.5.7(32) and 3.4 +invalid explicit or implicit conversion of an address constant to an integral value in a constant initializing expression. +An address constant in a constant initializing expression can neither +initialize a bit-field nor be directly or indirectly converted to an +integral type of size different from an address type. +6.4 diff --git a/ido/ido7.1_recomp/ugen b/ido/ido7.1_recomp/ugen new file mode 100755 index 00000000..e8e87563 Binary files /dev/null and b/ido/ido7.1_recomp/ugen differ diff --git a/ido/ido7.1_recomp/ujoin b/ido/ido7.1_recomp/ujoin new file mode 100755 index 00000000..98ba6065 Binary files /dev/null and b/ido/ido7.1_recomp/ujoin differ diff --git a/ido/ido7.1_recomp/uld b/ido/ido7.1_recomp/uld new file mode 100755 index 00000000..38833f5b Binary files /dev/null and b/ido/ido7.1_recomp/uld differ diff --git a/ido/ido7.1_recomp/umerge b/ido/ido7.1_recomp/umerge new file mode 100755 index 00000000..5b78e92e Binary files /dev/null and b/ido/ido7.1_recomp/umerge differ diff --git a/ido/ido7.1_recomp/uopt b/ido/ido7.1_recomp/uopt new file mode 100755 index 00000000..fd93d2dc Binary files /dev/null and b/ido/ido7.1_recomp/uopt differ diff --git a/ido/ido7.1_recomp/usplit b/ido/ido7.1_recomp/usplit new file mode 100755 index 00000000..e6a69ef8 Binary files /dev/null and b/ido/ido7.1_recomp/usplit differ diff --git a/include/2.0L/PR/PRimage.h b/include/2.0L/PR/PRimage.h new file mode 100755 index 00000000..7bab1ad9 --- /dev/null +++ b/include/2.0L/PR/PRimage.h @@ -0,0 +1,125 @@ +/************************************************************************** + * + * $Revision: 1.4 $ + * $Date: 1997/11/26 00:30:50 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/PRimage.h,v $ + * + **************************************************************************/ + +#ifndef __GL_IMAGE_H__ +#define __GL_IMAGE_H__ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Defines for image files . . . . + * + * Paul Haeberli - 1984 + * Look in /usr/people/4Dgifts/iristools/imgtools for example code! + * + */ + + +#define IMAGIC 0732 + +/* colormap of images */ +#define CM_NORMAL 0 /* file contains rows of values which + * are either RGB values (zsize == 3) + * or greyramp values (zsize == 1) */ +#define CM_DITHERED 1 +#define CM_SCREEN 2 /* file contains data which is a screen + * image; getrow returns buffer which + * can be displayed directly with + * writepixels */ +#define CM_COLORMAP 3 /* a colormap file */ + +#define TYPEMASK 0xff00 +#define BPPMASK 0x00ff +#define ITYPE_VERBATIM 0x0000 +#define ITYPE_RLE 0x0100 +#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE) +#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) +#define BPP(type) ((type) & BPPMASK) +#define RLE(bpp) (ITYPE_RLE | (bpp)) +#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) +#define IBUFSIZE(pixels) (((pixels)+((pixels)>>6))<<2) +#define RLE_NOP 0x00 + +#define ierror(p) (((p)->flags&_IOERR)!=0) +#define ifileno(p) ((p)->file) +#define getpix(p) (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p)) +#define putpix(p,x) (--(p)->cnt>=0 \ + ? ((int)(*(p)->ptr++=(unsigned)(x))) \ + : iflsbuf(p,(unsigned)(x))) + +typedef struct { + unsigned short imagic; /* stuff saved on disk . . */ + unsigned short type; + unsigned short dim; + unsigned short xsize; + unsigned short ysize; + unsigned short zsize; + unsigned long min; + unsigned long max; + unsigned long wastebytes; + char name[80]; + unsigned long colormap; + + long file; /* stuff used in core only */ + unsigned short flags; + short dorev; + short x; + short y; + short z; + short cnt; + unsigned short *ptr; + unsigned short *base; + unsigned short *tmpbuf; + unsigned long offset; + unsigned long rleend; /* for rle images */ + unsigned long *rowstart; /* for rle images */ + long *rowsize; /* for rle images */ +} IMAGE; + +IMAGE *icreate(); +/* + * IMAGE *iopen(char *file, char *mode, unsigned int type, unsigned int dim, + * unsigned int xsize, unsigned int ysize, unsigned int zsize); + * IMAGE *fiopen(int f, char *mode, unsigned int type, unsigned int dim, + * unsigned int xsize, unsigned int ysize, unsigned int zsize); + * + * ...while iopen and fiopen can take an extended set of parameters, the + * last five are optional, so a more correct prototype would be: + * + */ +IMAGE *iopen(char *file, char *mode, ...); +IMAGE *fiopen(int f, char *mode, ...); + +/* + * + * unsigned short *ibufalloc(IMAGE *image); + * int ifilbuf(IMAGE *image); + * int iflush(IMAGE *image); + * unsigned int iflsbuf(IMAGE *image, unsigned int c); + * void isetname(IMAGE *image, char *name); + * void isetcolormap(IMAGE *image, int colormap); + */ + +int iclose(IMAGE *image); +int putrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); +int getrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); + +/* +IMAGE *iopen(); +IMAGE *icreate(); +*/ + +unsigned short *ibufalloc(); + +#define IMAGEDEF /* for backwards compatibility */ +#ifdef __cplusplus +} +#endif +#endif /* !__GL_IMAGE_H__ */ diff --git a/include/2.0L/PR/R4300.h b/include/2.0L/PR/R4300.h new file mode 100755 index 00000000..932694d3 --- /dev/null +++ b/include/2.0L/PR/R4300.h @@ -0,0 +1,453 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.13 $ + * $Date: 1997/02/11 08:15:34 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/R4300.h,v $ + * + **************************************************************************/ + +#ifndef __R4300_H__ +#define __R4300_H__ + +#include + +/* + * Segment base addresses and sizes + */ +#define KUBASE 0 +#define KUSIZE 0x80000000 +#define K0BASE 0x80000000 +#define K0SIZE 0x20000000 +#define K1BASE 0xA0000000 +#define K1SIZE 0x20000000 +#define K2BASE 0xC0000000 +#define K2SIZE 0x20000000 + +/* + * Exception vectors + */ +#define SIZE_EXCVEC 0x80 /* Size of an exc. vec */ +#define UT_VEC K0BASE /* utlbmiss vector */ +#define R_VEC (K1BASE+0x1fc00000) /* reset vector */ +#define XUT_VEC (K0BASE+0x80) /* extended address tlbmiss */ +#define ECC_VEC (K0BASE+0x100) /* Ecc exception vector */ +#define E_VEC (K0BASE+0x180) /* Gen. exception vector */ + +/* + * Address conversion macros + */ +#ifdef _LANGUAGE_ASSEMBLY + +#define K0_TO_K1(x) ((x)|0xA0000000) /* kseg0 to kseg1 */ +#define K1_TO_K0(x) ((x)&0x9FFFFFFF) /* kseg1 to kseg0 */ +#define K0_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg0 to physical */ +#define K1_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg1 to physical */ +#define KDM_TO_PHYS(x) ((x)&0x1FFFFFFF) /* direct mapped to physical */ +#define PHYS_TO_K0(x) ((x)|0x80000000) /* physical to kseg0 */ +#define PHYS_TO_K1(x) ((x)|0xA0000000) /* physical to kseg1 */ + +#else /* _LANGUAGE_C */ + +#define K0_TO_K1(x) ((u32)(x)|0xA0000000) /* kseg0 to kseg1 */ +#define K1_TO_K0(x) ((u32)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */ +#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg0 to physical */ +#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg1 to physical */ +#define KDM_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* direct mapped to physical */ +#define PHYS_TO_K0(x) ((u32)(x)|0x80000000) /* physical to kseg0 */ +#define PHYS_TO_K1(x) ((u32)(x)|0xA0000000) /* physical to kseg1 */ + +#endif /* _LANGUAGE_ASSEMBLY */ + +/* + * Address predicates + */ +#define IS_KSEG0(x) ((u32)(x) >= K0BASE && (u32)(x) < K1BASE) +#define IS_KSEG1(x) ((u32)(x) >= K1BASE && (u32)(x) < K2BASE) +#define IS_KSEGDM(x) ((u32)(x) >= K0BASE && (u32)(x) < K2BASE) +#define IS_KSEG2(x) ((u32)(x) >= K2BASE && (u32)(x) < KPTE_SHDUBASE) +#define IS_KPTESEG(x) ((u32)(x) >= KPTE_SHDUBASE) +#define IS_KUSEG(x) ((u32)(x) < K0BASE) + +/* + * TLB size constants + */ + +#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ + +#define TLBHI_VPN2MASK 0xffffe000 +#define TLBHI_VPN2SHIFT 13 +#define TLBHI_PIDMASK 0xff +#define TLBHI_PIDSHIFT 0 +#define TLBHI_NPID 255 /* 255 to fit in 8 bits */ + +#define TLBLO_PFNMASK 0x3fffffc0 +#define TLBLO_PFNSHIFT 6 +#define TLBLO_CACHMASK 0x38 /* cache coherency algorithm */ +#define TLBLO_CACHSHIFT 3 +#define TLBLO_UNCACHED 0x10 /* not cached */ +#define TLBLO_NONCOHRNT 0x18 /* Cacheable non-coherent */ +#define TLBLO_EXLWR 0x28 /* Exclusive write */ +#define TLBLO_D 0x4 /* writeable */ +#define TLBLO_V 0x2 /* valid bit */ +#define TLBLO_G 0x1 /* global access bit */ + +#define TLBINX_PROBE 0x80000000 +#define TLBINX_INXMASK 0x3f +#define TLBINX_INXSHIFT 0 + +#define TLBRAND_RANDMASK 0x3f +#define TLBRAND_RANDSHIFT 0 + +#define TLBWIRED_WIREDMASK 0x3f + +#define TLBCTXT_BASEMASK 0xff800000 +#define TLBCTXT_BASESHIFT 23 +#define TLBCTXT_BASEBITS 9 + +#define TLBCTXT_VPNMASK 0x7ffff0 +#define TLBCTXT_VPNSHIFT 4 + +#define TLBPGMASK_4K 0x0 +#define TLBPGMASK_16K 0x6000 +#define TLBPGMASK_64K 0x1e000 + +/* + * Status register + */ +#define SR_CUMASK 0xf0000000 /* coproc usable bits */ + +#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ +#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ +#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ +#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ +#define SR_RP 0x08000000 /* Reduced power (quarter speed) */ +#define SR_FR 0x04000000 /* MIPS III FP register mode */ +#define SR_RE 0x02000000 /* Reverse endian */ +#define SR_ITS 0x01000000 /* Instruction trace support */ +#define SR_BEV 0x00400000 /* Use boot exception vectors */ +#define SR_TS 0x00200000 /* TLB shutdown */ +#define SR_SR 0x00100000 /* Soft reset occured */ +#define SR_CH 0x00040000 /* Cache hit for last 'cache' op */ +#define SR_CE 0x00020000 /* Create ECC */ +#define SR_DE 0x00010000 /* ECC of parity does not cause error */ + +/* + * Interrupt enable bits + * (NOTE: bits set to 1 enable the corresponding level interrupt) + */ +#define SR_IMASK 0x0000ff00 /* Interrupt mask */ +#define SR_IMASK8 0x00000000 /* mask level 8 */ +#define SR_IMASK7 0x00008000 /* mask level 7 */ +#define SR_IMASK6 0x0000c000 /* mask level 6 */ +#define SR_IMASK5 0x0000e000 /* mask level 5 */ +#define SR_IMASK4 0x0000f000 /* mask level 4 */ +#define SR_IMASK3 0x0000f800 /* mask level 3 */ +#define SR_IMASK2 0x0000fc00 /* mask level 2 */ +#define SR_IMASK1 0x0000fe00 /* mask level 1 */ +#define SR_IMASK0 0x0000ff00 /* mask level 0 */ + +#define SR_IBIT8 0x00008000 /* bit level 8 */ +#define SR_IBIT7 0x00004000 /* bit level 7 */ +#define SR_IBIT6 0x00002000 /* bit level 6 */ +#define SR_IBIT5 0x00001000 /* bit level 5 */ +#define SR_IBIT4 0x00000800 /* bit level 4 */ +#define SR_IBIT3 0x00000400 /* bit level 3 */ +#define SR_IBIT2 0x00000200 /* bit level 2 */ +#define SR_IBIT1 0x00000100 /* bit level 1 */ + +#define SR_IMASKSHIFT 8 + +#define SR_KX 0x00000080 /* extended-addr TLB vec in kernel */ +#define SR_SX 0x00000040 /* xtended-addr TLB vec supervisor */ +#define SR_UX 0x00000020 /* xtended-addr TLB vec in user mode */ +#define SR_KSU_MASK 0x00000018 /* mode mask */ +#define SR_KSU_USR 0x00000010 /* user mode */ +#define SR_KSU_SUP 0x00000008 /* supervisor mode */ +#define SR_KSU_KER 0x00000000 /* kernel mode */ +#define SR_ERL 0x00000004 /* Error level, 1=>cache error */ +#define SR_EXL 0x00000002 /* Exception level, 1=>exception */ +#define SR_IE 0x00000001 /* interrupt enable, 1=>enable */ + +/* + * Cause Register + */ +#define CAUSE_BD 0x80000000 /* Branch delay slot */ +#define CAUSE_CEMASK 0x30000000 /* coprocessor error */ +#define CAUSE_CESHIFT 28 + +/* Interrupt pending bits */ +#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */ +#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 */ +#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 */ +#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 */ +#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 */ +#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 */ +#define CAUSE_SW2 0x00000200 /* Software level 2 pending */ +#define CAUSE_SW1 0x00000100 /* Software level 1 pending */ + +#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */ +#define CAUSE_IPSHIFT 8 + +#define CAUSE_EXCMASK 0x0000007C /* Cause code bits */ + +#define CAUSE_EXCSHIFT 2 + +/* Cause register exception codes */ + +#define EXC_CODE(x) ((x)<<2) + +/* Hardware exception codes */ +#define EXC_INT EXC_CODE(0) /* interrupt */ +#define EXC_MOD EXC_CODE(1) /* TLB mod */ +#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */ +#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */ +#define EXC_RADE EXC_CODE(4) /* Read Address Error */ +#define EXC_WADE EXC_CODE(5) /* Write Address Error */ +#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */ +#define EXC_DBE EXC_CODE(7) /* Data Bus Error */ +#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */ +#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */ +#define EXC_II EXC_CODE(10) /* Illegal Instruction */ +#define EXC_CPU EXC_CODE(11) /* CoProcessor Unusable */ +#define EXC_OV EXC_CODE(12) /* OVerflow */ +#define EXC_TRAP EXC_CODE(13) /* Trap exception */ +#define EXC_VCEI EXC_CODE(14) /* Virt. Coherency on Inst. fetch */ +#define EXC_FPE EXC_CODE(15) /* Floating Point Exception */ +#define EXC_WATCH EXC_CODE(23) /* Watchpoint reference */ +#define EXC_VCED EXC_CODE(31) /* Virt. Coherency on data read */ + +/* C0_PRID Defines */ +#define C0_IMPMASK 0xff00 +#define C0_IMPSHIFT 8 +#define C0_REVMASK 0xff +#define C0_MAJREVMASK 0xf0 +#define C0_MAJREVSHIFT 4 +#define C0_MINREVMASK 0xf + +/* + * Coprocessor 0 operations + */ +#define C0_READI 0x1 /* read ITLB entry addressed by C0_INDEX */ +#define C0_WRITEI 0x2 /* write ITLB entry addressed by C0_INDEX */ +#define C0_WRITER 0x6 /* write ITLB entry addressed by C0_RAND */ +#define C0_PROBE 0x8 /* probe for ITLB entry addressed by TLBHI */ +#define C0_RFE 0x10 /* restore for exception */ + +/* + * 'cache' instruction definitions + */ + +/* Target cache */ +#define CACH_PI 0x0 /* specifies primary inst. cache */ +#define CACH_PD 0x1 /* primary data cache */ +#define CACH_SI 0x2 /* secondary instruction cache */ +#define CACH_SD 0x3 /* secondary data cache */ + +/* Cache operations */ +#define C_IINV 0x0 /* index invalidate (inst, 2nd inst) */ +#define C_IWBINV 0x0 /* index writeback inval (d, sd) */ +#define C_ILT 0x4 /* index load tag (all) */ +#define C_IST 0x8 /* index store tag (all) */ +#define C_CDX 0xc /* create dirty exclusive (d, sd) */ +#define C_HINV 0x10 /* hit invalidate (all) */ +#define C_HWBINV 0x14 /* hit writeback inv. (d, sd) */ +#define C_FILL 0x14 /* fill (i) */ +#define C_HWB 0x18 /* hit writeback (i, d, sd) */ +#define C_HSV 0x1c /* hit set virt. (si, sd) */ + +/* + * Cache size definitions + */ +#define ICACHE_SIZE 0x4000 /* 16K */ +#define ICACHE_LINESIZE 32 /* 8 words */ +#define ICACHE_LINEMASK (ICACHE_LINESIZE-1) + +#define DCACHE_SIZE 0x2000 /* 8K */ +#define DCACHE_LINESIZE 16 /* 4 words */ +#define DCACHE_LINEMASK (DCACHE_LINESIZE-1) + +/* + * C0_CONFIG register definitions + */ +#define CONFIG_CM 0x80000000 /* 1 == Master-Checker enabled */ +#define CONFIG_EC 0x70000000 /* System Clock ratio */ +#define CONFIG_EC_1_1 0x6 /* System Clock ratio 1 :1 */ +#define CONFIG_EC_3_2 0x7 /* System Clock ratio 1.5 :1 */ +#define CONFIG_EC_2_1 0x0 /* System Clock ratio 2 :1 */ +#define CONFIG_EC_3_1 0x1 /* System Clock ratio 3 :1 */ +#define CONFIG_EP 0x0f000000 /* Transmit Data Pattern */ +#define CONFIG_SB 0x00c00000 /* Secondary cache block size */ + +#define CONFIG_SS 0x00200000 /* Split scache: 0 == I&D combined */ +#define CONFIG_SW 0x00100000 /* scache port: 0==128, 1==64 */ +#define CONFIG_EW 0x000c0000 /* System Port width: 0==64, 1==32 */ +#define CONFIG_SC 0x00020000 /* 0 -> 2nd cache present */ +#define CONFIG_SM 0x00010000 /* 0 -> Dirty Shared Coherency enabled*/ +#define CONFIG_BE 0x00008000 /* Endian-ness: 1 --> BE */ +#define CONFIG_EM 0x00004000 /* 1 -> ECC mode, 0 -> parity */ +#define CONFIG_EB 0x00002000 /* Block order:1->sequent,0->subblock */ + +#define CONFIG_IC 0x00000e00 /* Primary Icache size */ +#define CONFIG_DC 0x000001c0 /* Primary Dcache size */ +#define CONFIG_IB 0x00000020 /* Icache block size */ +#define CONFIG_DB 0x00000010 /* Dcache block size */ +#define CONFIG_CU 0x00000008 /* Update on Store-conditional */ +#define CONFIG_K0 0x00000007 /* K0SEG Coherency algorithm */ + +#define CONFIG_UNCACHED 0x00000002 /* K0 is uncached */ +#define CONFIG_NONCOHRNT 0x00000003 +#define CONFIG_COHRNT_EXLWR 0x00000005 +#define CONFIG_SB_SHFT 22 /* shift SB to bit position 0 */ +#define CONFIG_IC_SHFT 9 /* shift IC to bit position 0 */ +#define CONFIG_DC_SHFT 6 /* shift DC to bit position 0 */ +#define CONFIG_BE_SHFT 15 /* shift BE to bit position 0 */ + +/* + * C0_TAGLO definitions for setting/getting cache states and physaddr bits + */ +#define SADDRMASK 0xFFFFE000 /* 31..13 -> scache paddr bits 35..17 */ +#define SVINDEXMASK 0x00000380 /* 9..7: prim virt index bits 14..12 */ +#define SSTATEMASK 0x00001c00 /* bits 12..10 hold scache line state */ +#define SINVALID 0x00000000 /* invalid --> 000 == state 0 */ +#define SCLEANEXCL 0x00001000 /* clean exclusive --> 100 == state 4 */ +#define SDIRTYEXCL 0x00001400 /* dirty exclusive --> 101 == state 5 */ +#define SECC_MASK 0x0000007f /* low 7 bits are ecc for the tag */ +#define SADDR_SHIFT 4 /* shift STagLo (31..13) to 35..17 */ + +#define PADDRMASK 0xFFFFFF00 /* PTagLo31..8->prim paddr bits35..12 */ +#define PADDR_SHIFT 4 /* roll bits 35..12 down to 31..8 */ +#define PSTATEMASK 0x00C0 /* bits 7..6 hold primary line state */ +#define PINVALID 0x0000 /* invalid --> 000 == state 0 */ +#define PCLEANEXCL 0x0080 /* clean exclusive --> 10 == state 2 */ +#define PDIRTYEXCL 0x00C0 /* dirty exclusive --> 11 == state 3 */ +#define PPARITY_MASK 0x0001 /* low bit is parity bit (even). */ + +/* + * C0_CACHE_ERR definitions. + */ +#define CACHERR_ER 0x80000000 /* 0: inst ref, 1: data ref */ +#define CACHERR_EC 0x40000000 /* 0: primary, 1: secondary */ +#define CACHERR_ED 0x20000000 /* 1: data error */ +#define CACHERR_ET 0x10000000 /* 1: tag error */ +#define CACHERR_ES 0x08000000 /* 1: external ref, e.g. snoop*/ +#define CACHERR_EE 0x04000000 /* error on SysAD bus */ +#define CACHERR_EB 0x02000000 /* complicated, see spec. */ +#define CACHERR_EI 0x01000000 /* complicated, see spec. */ +#define CACHERR_SIDX_MASK 0x003ffff8 /* secondary cache index */ +#define CACHERR_PIDX_MASK 0x00000007 /* primary cache index */ +#define CACHERR_PIDX_SHIFT 12 /* bits 2..0 are paddr14..12 */ + +/* R4000 family supports hardware watchpoints: + * C0_WATCHLO: + * bits 31..3 are bits 31..3 of physaddr to watch + * bit 2: reserved; must be written as 0. + * bit 1: when set causes a watchpoint trap on load accesses to paddr. + * bit 0: when set traps on stores to paddr; + * C0_WATCHHI + * bits 31..4 are reserved and must be written as zeros. + * bits 3..0 are bits 35..32 of the physaddr to watch + */ +#define WATCHLO_WTRAP 0x00000001 +#define WATCHLO_RTRAP 0x00000002 +#define WATCHLO_ADDRMASK 0xfffffff8 +#define WATCHLO_VALIDMASK 0xfffffffb +#define WATCHHI_VALIDMASK 0x0000000f + +/* + * Coprocessor 0 registers + */ +#ifdef _LANGUAGE_ASSEMBLY +#define C0_INX $0 +#define C0_RAND $1 +#define C0_ENTRYLO0 $2 +#define C0_ENTRYLO1 $3 +#define C0_CONTEXT $4 +#define C0_PAGEMASK $5 /* page mask */ +#define C0_WIRED $6 /* # wired entries in tlb */ +#define C0_BADVADDR $8 +#define C0_COUNT $9 /* free-running counter */ +#define C0_ENTRYHI $10 +#define C0_SR $12 +#define C0_CAUSE $13 +#define C0_EPC $14 +#define C0_PRID $15 /* revision identifier */ +#define C0_COMPARE $11 /* counter comparison reg. */ +#define C0_CONFIG $16 /* hardware configuration */ +#define C0_LLADDR $17 /* load linked address */ +#define C0_WATCHLO $18 /* watchpoint */ +#define C0_WATCHHI $19 /* watchpoint */ +#define C0_ECC $26 /* S-cache ECC and primary parity */ +#define C0_CACHE_ERR $27 /* cache error status */ +#define C0_TAGLO $28 /* cache operations */ +#define C0_TAGHI $29 /* cache operations */ +#define C0_ERROR_EPC $30 /* ECC error prg. counter */ + +# else /* ! _LANGUAGE_ASSEMBLY */ + +#define C0_INX 0 +#define C0_RAND 1 +#define C0_ENTRYLO0 2 +#define C0_ENTRYLO1 3 +#define C0_CONTEXT 4 +#define C0_PAGEMASK 5 /* page mask */ +#define C0_WIRED 6 /* # wired entries in tlb */ +#define C0_BADVADDR 8 +#define C0_COUNT 9 /* free-running counter */ +#define C0_ENTRYHI 10 +#define C0_SR 12 +#define C0_CAUSE 13 +#define C0_EPC 14 +#define C0_PRID 15 /* revision identifier */ +#define C0_COMPARE 11 /* counter comparison reg. */ +#define C0_CONFIG 16 /* hardware configuration */ +#define C0_LLADDR 17 /* load linked address */ +#define C0_WATCHLO 18 /* watchpoint */ +#define C0_WATCHHI 19 /* watchpoint */ +#define C0_ECC 26 /* S-cache ECC and primary parity */ +#define C0_CACHE_ERR 27 /* cache error status */ +#define C0_TAGLO 28 /* cache operations */ +#define C0_TAGHI 29 /* cache operations */ +#define C0_ERROR_EPC 30 /* ECC error prg. counter */ + +#endif /* _LANGUAGE_ASSEMBLY */ + +/* + * floating-point status register + */ +#define FPCSR_FS 0x01000000 /* flush denorm to zero */ +#define FPCSR_C 0x00800000 /* condition bit */ +#define FPCSR_CE 0x00020000 /* cause: unimplemented operation */ +#define FPCSR_CV 0x00010000 /* cause: invalid operation */ +#define FPCSR_CZ 0x00008000 /* cause: division by zero */ +#define FPCSR_CO 0x00004000 /* cause: overflow */ +#define FPCSR_CU 0x00002000 /* cause: underflow */ +#define FPCSR_CI 0x00001000 /* cause: inexact operation */ +#define FPCSR_EV 0x00000800 /* enable: invalid operation */ +#define FPCSR_EZ 0x00000400 /* enable: division by zero */ +#define FPCSR_EO 0x00000200 /* enable: overflow */ +#define FPCSR_EU 0x00000100 /* enable: underflow */ +#define FPCSR_EI 0x00000080 /* enable: inexact operation */ +#define FPCSR_FV 0x00000040 /* flag: invalid operation */ +#define FPCSR_FZ 0x00000020 /* flag: division by zero */ +#define FPCSR_FO 0x00000010 /* flag: overflow */ +#define FPCSR_FU 0x00000008 /* flag: underflow */ +#define FPCSR_FI 0x00000004 /* flag: inexact operation */ +#define FPCSR_RM_MASK 0x00000003 /* rounding mode mask */ +#define FPCSR_RM_RN 0x00000000 /* round to nearest */ +#define FPCSR_RM_RZ 0x00000001 /* round to zero */ +#define FPCSR_RM_RP 0x00000002 /* round to positive infinity */ +#define FPCSR_RM_RM 0x00000003 /* round to negative infinity */ + +#endif /* __R4300_H */ diff --git a/include/2.0L/PR/abi.h b/include/2.0L/PR/abi.h new file mode 100755 index 00000000..2102bc87 --- /dev/null +++ b/include/2.0L/PR/abi.h @@ -0,0 +1,410 @@ +#ifndef _ABI_H_ +#define _ABI_H_ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.32 $ + * $Date: 1997/02/11 08:16:37 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/abi.h,v $ + * + **************************************************************************/ + +/* + * Header file for the Audio Binary Interface. + * This is included in the Media Binary Interface file + * mbi.h. + * + * This file follows the framework used for graphics. + * + */ + +/* Audio commands: */ +#define A_SPNOOP 0 +#define A_ADPCM 1 +#define A_CLEARBUFF 2 +#define A_ENVMIXER 3 +#define A_LOADBUFF 4 +#define A_RESAMPLE 5 +#define A_SAVEBUFF 6 +#define A_SEGMENT 7 +#define A_SETBUFF 8 +#define A_SETVOL 9 +#define A_DMEMMOVE 10 +#define A_LOADADPCM 11 +#define A_MIXER 12 +#define A_INTERLEAVE 13 +#define A_POLEF 14 +#define A_SETLOOP 15 + +#define ACMD_SIZE 32 +/* + * Audio flags + */ + +#define A_INIT 0x01 +#define A_CONTINUE 0x00 +#define A_LOOP 0x02 +#define A_OUT 0x02 +#define A_LEFT 0x02 +#define A_RIGHT 0x00 +#define A_VOL 0x04 +#define A_RATE 0x00 +#define A_AUX 0x08 +#define A_NOAUX 0x00 +#define A_MAIN 0x00 +#define A_MIX 0x10 + +/* + * BEGIN C-specific section: (typedef's) + */ +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* + * Data Structures. + */ + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int gain:16; + unsigned int addr; +} Aadpcm; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int gain:16; + unsigned int addr; +} Apolef; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pad1:16; + unsigned int addr; +} Aenvelope; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int dmem:16; + unsigned int pad2:16; + unsigned int count:16; +} Aclearbuff; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int pad2:16; + unsigned int inL:16; + unsigned int inR:16; +} Ainterleave; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:24; + unsigned int addr; +} Aloadbuff; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pad1:16; + unsigned int addr; +} Aenvmixer; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int gain:16; + unsigned int dmemi:16; + unsigned int dmemo:16; +} Amixer; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int dmem2:16; + unsigned int addr; +} Apan; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pitch:16; + unsigned int addr; +} Aresample; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pad1:16; + unsigned int addr; +} Areverb; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:24; + unsigned int addr; +} Asavebuff; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:24; + unsigned int pad2:2; + unsigned int number:4; + unsigned int base:24; +} Asegment; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int dmemin:16; + unsigned int dmemout:16; + unsigned int count:16; +} Asetbuff; + +typedef struct { + unsigned int cmd:8; + unsigned int flags:8; + unsigned int vol:16; + unsigned int voltgt:16; + unsigned int volrate:16; +} Asetvol; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int dmemin:16; + unsigned int dmemout:16; + unsigned int count:16; +} Admemmove; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int count:16; + unsigned int addr; +} Aloadadpcm; + +typedef struct { + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int pad2:16; + unsigned int addr; +} Asetloop; + +/* + * Generic Acmd Packet + */ + +typedef struct { + unsigned int w0; + unsigned int w1; +} Awords; + +typedef union { + Awords words; + Aadpcm adpcm; + Apolef polef; + Aclearbuff clearbuff; + Aenvelope envelope; + Ainterleave interleave; + Aloadbuff loadbuff; + Aenvmixer envmixer; + Aresample resample; + Areverb reverb; + Asavebuff savebuff; + Asegment segment; + Asetbuff setbuff; + Asetvol setvol; + Admemmove dmemmove; + Aloadadpcm loadadpcm; + Amixer mixer; + Asetloop setloop; + long long int force_union_align; /* dummy, force alignment */ +} Acmd; + +/* + * ADPCM State + */ +#define ADPCMVSIZE 8 +#define ADPCMFSIZE 16 +typedef short ADPCM_STATE[ADPCMFSIZE]; + +/* + * Pole filter state + */ +typedef short POLEF_STATE[4]; + +/* + * Resampler state + */ +typedef short RESAMPLE_STATE[16]; + +/* + * Resampler constants + */ +#define UNITY_PITCH 0x8000 +#define MAX_RATIO 1.99996 /* within .03 cents of +1 octave */ + +/* + * Enveloper/Mixer state + */ +typedef short ENVMIX_STATE[40]; + +/* + * Macros to assemble the audio command list + */ + +#define aADPCMdec(pkt, f, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aPoleFilter(pkt, f, g, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aClearBuffer(pkt, d, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ + _a->words.w1 = (unsigned int)(c); \ +} + +#define aEnvMixer(pkt, f, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aInterleave(pkt, l, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ + _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ +} + +#define aLoadBuffer(pkt, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aMix(pkt, f, g, i, o) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = _SHIFTL(i,16, 16) | _SHIFTL(o, 0, 16); \ +} + +#define aPan(pkt, f, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(d, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aResample(pkt, f, p, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) |\ + _SHIFTL(p, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aSaveBuffer(pkt, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aSegment(pkt, s, b) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ + _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ +} + +#define aSetBuffer(pkt, f, i, o, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(i, 0, 16)); \ + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +} + +#define aSetVolume(pkt, f, v, t, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \ +} + +#define aSetLoop(pkt, a) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ + _a->words.w1 = (unsigned int)(a); \ +} + +#define aDMEMMove(pkt, i, o, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +} + +#define aLoadADPCM(pkt, c, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ + _a->words.w1 = (unsigned int) d; \ +} + +#endif /* _LANGUAGE_C */ + +#endif /* !_ABI_H_ */ + + + diff --git a/include/2.0L/PR/gbi.h b/include/2.0L/PR/gbi.h new file mode 100755 index 00000000..7c7ffd29 --- /dev/null +++ b/include/2.0L/PR/gbi.h @@ -0,0 +1,4378 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ +/************************************************************************** + * + * $Revision: 1.128 $ + * $Date: 1997/11/26 00:30:51 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/gbi.h,v $ + * + **************************************************************************/ + +#ifndef _GBI_H_ +#define _GBI_H_ + +/* + * To use the F3DEX ucodes, define F3DEX_GBI before include this file. + * + * #define F3DEX_GBI + * #include + * + * or + * + * cc -c -DF3DEX_GBI -I.... foo.c + * + */ + +/************************************************************************** + * + * Graphics Binary Interface + * + **************************************************************************/ + +/* + * Graphics Commands, 'xxx' parts may be generated from ucode + * + * The command format is + * + * |00xxxxxx| = DMA 0,..,127 + * |10xxxxxx| = Immediate Mode -65,..,-128 + * |11xxxxxx| = RDP cmds -1,..,-64 + * + * Note: in order for the RSP microcode to process RDP commands opaquely, + * we need to further identify those RDP commands that need DRAM address + * "fixup". To do this, we have the dummy command G_RDP_ADDR_FIXUP, and + * all |RDP commands| less than this are commands with embedded DRAM + * addresses. Further, the format of these commands should be similar so + * only one fixup routine is needed. + * + * Further explanation: + * The names of the commands are somewhat misleading. Here is clarification: + * + * - a 'DMA' type command has a pointer to additional data and + * causes a DMA transfer to bring that into DMEM. + * + * - an 'Immediate' type command isn't really 'immediate', in the + * traditional sense. This just means that the entire command fits + * in the 64-bit word, and the ucode can execute it 'immediately' + * without additional memory transfers. + * + * - an 'RDP' command is identified as such because the RDP + * commands can be passed-thru the RSP and sent to the RDP + * directly. One further confusing thing, is that some 'DP' + * macros below actually generate immediate commands, not + * not direct DP commands. + * + * IMPLEMENTATION NOTE: + * There is another group of RDP commands that includes the triangle commands + * generated by the RSP code. These are the raw commands the rasterizer + * hardware chews on, with slope info, etc. They will follow the RDP + * ordering... + * + * IMPLEMENTATION NOTE: + * The RDP hardware has some of these bit patterns wired up. If the hardware + * changes, we must adjust this table, likewise we can't change/add things + * once the hardware is frozen. (actually, the RDP hardware only looks at + * the lower 6 bits of the command byte) + * + */ + +#ifdef F3DEX_GBI_2x +#define G_NOOP 0x00 +#define G_RDPHALF_2 0xf1 +#define G_SETOTHERMODE_H 0xe3 +#define G_SETOTHERMODE_L 0xe2 +#define G_RDPHALF_1 0xe1 +#define G_SPNOOP 0xe0 +#define G_ENDDL 0xdf +#define G_DL 0xde +#define G_LOAD_UCODE 0xdd +#define G_MOVEMEM 0xdc +#define G_MOVEWORD 0xdb +#define G_MTX 0xda +#define G_GEOMETRYMODE 0xd9 +#define G_POPMTX 0xd8 +#define G_TEXTURE 0xd7 +#define G_SUBMODULE 0xd6 + +#define G_VTX 0x01 +#define G_MODIFYVTX 0x02 +#define G_CULLDL 0x03 +#define G_BRANCH_Z 0x04 +#define G_TRI1 0x05 +#define G_TRI2 0x06 +#define G_LINE3D 0x07 +#else /* F3DEX_GBI_2 */ + +/* DMA commands: */ +#define G_SPNOOP 0 /* handle 0 gracefully */ +#define G_MTX 1 +#define G_RESERVED0 2 /* not implemeted */ +#define G_MOVEMEM 3 /* move a block of memory (up to 4 words) to dmem */ +#define G_VTX 4 +#define G_RESERVED1 5 /* not implemeted */ +#define G_DL 6 +#define G_RESERVED2 7 /* not implemeted */ +#define G_RESERVED3 8 /* not implemeted */ +#define G_SPRITE2D_BASE 9 /* sprite command */ + +/* IMMEDIATE commands: */ +#define G_IMMFIRST -65 +#define G_TRI1 (G_IMMFIRST-0) +#define G_CULLDL (G_IMMFIRST-1) +#define G_POPMTX (G_IMMFIRST-2) +#define G_MOVEWORD (G_IMMFIRST-3) +#define G_TEXTURE (G_IMMFIRST-4) +#define G_SETOTHERMODE_H (G_IMMFIRST-5) +#define G_SETOTHERMODE_L (G_IMMFIRST-6) +#define G_ENDDL (G_IMMFIRST-7) +#define G_SETGEOMETRYMODE (G_IMMFIRST-8) +#define G_CLEARGEOMETRYMODE (G_IMMFIRST-9) +#define G_LINE3D (G_IMMFIRST-10) +#define G_RDPHALF_1 (G_IMMFIRST-11) +#define G_RDPHALF_2 (G_IMMFIRST-12) +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +# define G_MODIFYVTX (G_IMMFIRST-13) +# define G_TRI2 (G_IMMFIRST-14) +# define G_BRANCH_Z (G_IMMFIRST-15) +# define G_LOAD_UCODE (G_IMMFIRST-16) +#else +# define G_RDPHALF_CONT (G_IMMFIRST-13) +#endif + +/* We are overloading 2 of the immediate commands + to keep the byte alignment of dmem the same */ + +#define G_SPRITE2D_SCALEFLIP (G_IMMFIRST-1) +#define G_SPRITE2D_DRAW (G_IMMFIRST-2) + +/* RDP commands: */ +#define G_NOOP 0xc0 /* 0 */ + +#endif /* F3DEX_GBI_2 */ + +/* RDP commands: */ +#define G_SETCIMG 0xff /* -1 */ +#define G_SETZIMG 0xfe /* -2 */ +#define G_SETTIMG 0xfd /* -3 */ +#define G_SETCOMBINE 0xfc /* -4 */ +#define G_SETENVCOLOR 0xfb /* -5 */ +#define G_SETPRIMCOLOR 0xfa /* -6 */ +#define G_SETBLENDCOLOR 0xf9 /* -7 */ +#define G_SETFOGCOLOR 0xf8 /* -8 */ +#define G_SETFILLCOLOR 0xf7 /* -9 */ +#define G_FILLRECT 0xf6 /* -10 */ +#define G_SETTILE 0xf5 /* -11 */ +#define G_LOADTILE 0xf4 /* -12 */ +#define G_LOADBLOCK 0xf3 /* -13 */ +#define G_SETTILESIZE 0xf2 /* -14 */ +#define G_LOADTLUT 0xf0 /* -16 */ +#define G_RDPSETOTHERMODE 0xef /* -17 */ +#define G_SETPRIMDEPTH 0xee /* -18 */ +#define G_SETSCISSOR 0xed /* -19 */ +#define G_SETCONVERT 0xec /* -20 */ +#define G_SETKEYR 0xeb /* -21 */ +#define G_SETKEYGB 0xea /* -22 */ +#define G_RDPFULLSYNC 0xe9 /* -23 */ +#define G_RDPTILESYNC 0xe8 /* -24 */ +#define G_RDPPIPESYNC 0xe7 /* -25 */ +#define G_RDPLOADSYNC 0xe6 /* -26 */ +#define G_TEXRECTFLIP 0xe5 /* -27 */ +#define G_TEXRECT 0xe4 /* -28 */ + + +/* + * The following commands are the "generated" RDP commands; the user + * never sees them, the RSP microcode generates them. + * + * The layout of the bits is magical, to save work in the ucode. + * These id's are -56, -52, -54, -50, -55, -51, -53, -49, ... + * edge, shade, texture, zbuff bits: estz + */ +#define G_TRI_FILL 0xc8 /* fill triangle: 11001000 */ +#define G_TRI_SHADE 0xcc /* shade triangle: 11001100 */ +#define G_TRI_TXTR 0xca /* texture triangle: 11001010 */ +#define G_TRI_SHADE_TXTR 0xce /* shade, texture triangle: 11001110 */ +#define G_TRI_FILL_ZBUFF 0xc9 /* fill, zbuff triangle: 11001001 */ +#define G_TRI_SHADE_ZBUFF 0xcd /* shade, zbuff triangle: 11001101 */ +#define G_TRI_TXTR_ZBUFF 0xcb /* texture, zbuff triangle: 11001011 */ +#define G_TRI_SHADE_TXTR_ZBUFF 0xcf /* shade, txtr, zbuff trngl: 11001111 */ + +/* + * A TRI_FILL triangle is just the edges. You need to set the DP + * to use primcolor, in order to see anything. (it is NOT a triangle + * that gets rendered in 'fill mode'. Triangles can't be rendered + * in 'fill mode') + * + * A TRI_SHADE is a gouraud triangle that has colors interpolated. + * Flat-shaded triangles (from the software) are still gouraud shaded, + * it's just the colors are all the same and the deltas are 0. + * + * Other triangle types, and combinations are more obvious. + */ + +/* masks to build RDP triangle commands: */ +#define G_RDP_TRI_FILL_MASK 0x08 +#define G_RDP_TRI_SHADE_MASK 0x04 +#define G_RDP_TRI_TXTR_MASK 0x02 +#define G_RDP_TRI_ZBUFF_MASK 0x01 + +/* + * HACK: + * This is a dreadful hack. For version 1.0 hardware, there are still + * some 'bowtie' hangs. This parameter can be increased to avoid + * the hangs. Every increase of 4 chops one scanline off of every + * triangle. Values of 4,8,12 should be sufficient to avoid any + * bowtie hang. + * + * Change this value, then recompile ALL of your program (including static + * display lists!) + * + * THIS WILL BE REMOVED FOR HARDWARE VERSION 2.0! + */ +#define BOWTIE_VAL 0 + + +/* gets added to RDP command, in order to test for addres fixup: */ +#define G_RDP_ADDR_FIXUP 3 /* |RDP cmds| <= this, do addr fixup */ +#ifdef _LANGUAGE_ASSEMBLY +#define G_RDP_TEXRECT_CHECK ((-1*G_TEXRECTFLIP)& 0xff) +#endif + +/* macros for command parsing: */ +#define GDMACMD(x) (x) +#define GIMMCMD(x) (G_IMMFIRST-(x)) +#define GRDPCMD(x) (0xff-(x)) + +#define G_DMACMDSIZ 128 +#define G_IMMCMDSIZ 64 +#define G_RDPCMDSIZ 64 + +/* + * Coordinate shift values, number of bits of fraction + */ +#define G_TEXTURE_IMAGE_FRAC 2 +#define G_TEXTURE_SCALE_FRAC 16 +#define G_SCALE_FRAC 8 +#define G_ROTATE_FRAC 16 + +/* + * Parameters to graphics commands + */ + +/* + * Data packing macros + */ + +/* + * Maximum z-buffer value, used to initialize the z-buffer. + * Note : this number is NOT the viewport z-scale constant. + * See the comment next to G_MAXZ for more info. + */ +#define G_MAXFBZ 0x3fff /* 3b exp, 11b mantissa */ + +#define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ + (((g)<<3) & 0x7c0) | \ + (((b)>>2) & 0x3e) | ((a) & 0x1)) +#define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) + +/* + * G_MTX: parameter flags + */ +#ifdef F3DEX_GBI_2x +# define G_MTX_MODELVIEW 0x00 /* matrix types */ +# define G_MTX_PROJECTION 0x04 +# define G_MTX_MUL 0x00 /* concat or load */ +# define G_MTX_LOAD 0x02 +# define G_MTX_NOPUSH 0x00 /* push or not */ +# define G_MTX_PUSH 0x01 +#else /* F3DEX_GBI_2 */ +# define G_MTX_MODELVIEW 0x00 /* matrix types */ +# define G_MTX_PROJECTION 0x01 +# define G_MTX_MUL 0x00 /* concat or load */ +# define G_MTX_LOAD 0x02 +# define G_MTX_NOPUSH 0x00 /* push or not */ +# define G_MTX_PUSH 0x04 +#endif /* F3DEX_GBI_2 */ + +/* + * flags for G_SETGEOMETRYMODE + * (this rendering state is maintained in RSP) + * + * DO NOT USE THE LOW 8 BITS OF GEOMETRYMODE: + * The weird bit-ordering is for the micro-code: the lower byte + * can be OR'd in with G_TRI_SHADE (11001100) to construct + * the triangle command directly. Don't break it... + * + * DO NOT USE THE HIGH 8 BITS OF GEOMETRYMODE: + * The high byte is OR'd with 0x703 to form the clip code mask. + * If it is set to 0x04, this will cause near clipping to occur. + * If it is zero, near clipping will not occur. + * + * Further explanation: + * G_SHADE is necessary in order to see the color that you passed + * down with the vertex. If G_SHADE isn't set, you need to set the DP + * appropriately and use primcolor to see anything. + * + * G_SHADING_SMOOTH enabled means use all 3 colors of the triangle. + * If it is not set, then do 'flat shading', where only one vertex color + * is used (and all 3 vertices are set to that same color by the ucode) + * See the man page for gSP1Triangle(). + * + */ +#define G_ZBUFFER 0x00000001 +#define G_TEXTURE_ENABLE 0x00000002 /* Microcode use only */ +#define G_SHADE 0x00000004 /* enable Gouraud interp */ +/* rest of low byte reserved for setup ucode */ +#define G_SHADING_SMOOTH 0x00000200 /* flat or smooth shaded */ +#define G_CULL_FRONT 0x00001000 +#define G_CULL_BACK 0x00002000 +#define G_CULL_BOTH 0x00003000 /* To make code cleaner */ +#define G_FOG 0x00010000 +#define G_LIGHTING 0x00020000 +#define G_TEXTURE_GEN 0x00040000 +#define G_TEXTURE_GEN_LINEAR 0x00080000 +#define G_LOD 0x00100000 /* NOT IMPLEMENTED */ +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +# define G_CLIPPING 0x00800000 +#else +# define G_CLIPPING 0x00000000 +#endif + +#ifdef _LANGUAGE_ASSEMBLY +#define G_FOG_H (G_FOG/0x10000) +#define G_LIGHTING_H (G_LIGHTING/0x10000) +#define G_TEXTURE_GEN_H (G_TEXTURE_GEN/0x10000) +#define G_TEXTURE_GEN_LINEAR_H (G_TEXTURE_GEN_LINEAR/0x10000) +#define G_LOD_H (G_LOD/0x10000) /* NOT IMPLEMENTED */ +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +# define G_CLIPPING_H (G_CLIPPING/0x10000) +#endif +#endif + +/* Need these defined for Sprite Microcode */ +#ifdef _LANGUAGE_ASSEMBLY +#define G_TX_LOADTILE 7 +#define G_TX_RENDERTILE 0 + +#define G_TX_NOMIRROR 0 +#define G_TX_WRAP 0 +#define G_TX_MIRROR 0x1 +#define G_TX_CLAMP 0x2 +#define G_TX_NOMASK 0 +#define G_TX_NOLOD 0 +#endif + +/* + * G_SETIMG fmt: set image formats + */ +#define G_IM_FMT_RGBA 0 +#define G_IM_FMT_YUV 1 +#define G_IM_FMT_CI 2 +#define G_IM_FMT_IA 3 +#define G_IM_FMT_I 4 + +/* + * G_SETIMG siz: set image pixel size + */ +#define G_IM_SIZ_4b 0 +#define G_IM_SIZ_8b 1 +#define G_IM_SIZ_16b 2 +#define G_IM_SIZ_32b 3 + +#define G_IM_SIZ_4b_BYTES 0 +#define G_IM_SIZ_4b_TILE_BYTES G_IM_SIZ_4b_BYTES +#define G_IM_SIZ_4b_LINE_BYTES G_IM_SIZ_4b_BYTES + +#define G_IM_SIZ_8b_BYTES 1 +#define G_IM_SIZ_8b_TILE_BYTES G_IM_SIZ_8b_BYTES +#define G_IM_SIZ_8b_LINE_BYTES G_IM_SIZ_8b_BYTES + +#define G_IM_SIZ_16b_BYTES 2 +#define G_IM_SIZ_16b_TILE_BYTES G_IM_SIZ_16b_BYTES +#define G_IM_SIZ_16b_LINE_BYTES G_IM_SIZ_16b_BYTES + +#define G_IM_SIZ_32b_BYTES 4 +#define G_IM_SIZ_32b_TILE_BYTES 2 +#define G_IM_SIZ_32b_LINE_BYTES 2 + +#define G_IM_SIZ_4b_LOAD_BLOCK G_IM_SIZ_16b +#define G_IM_SIZ_8b_LOAD_BLOCK G_IM_SIZ_16b +#define G_IM_SIZ_16b_LOAD_BLOCK G_IM_SIZ_16b +#define G_IM_SIZ_32b_LOAD_BLOCK G_IM_SIZ_32b + +#define G_IM_SIZ_4b_SHIFT 2 +#define G_IM_SIZ_8b_SHIFT 1 +#define G_IM_SIZ_16b_SHIFT 0 +#define G_IM_SIZ_32b_SHIFT 0 + +#define G_IM_SIZ_4b_INCR 3 +#define G_IM_SIZ_8b_INCR 1 +#define G_IM_SIZ_16b_INCR 0 +#define G_IM_SIZ_32b_INCR 0 + +/* + * G_SETCOMBINE: color combine modes + */ +/* Color combiner constants: */ +#define G_CCMUX_COMBINED 0 +#define G_CCMUX_TEXEL0 1 +#define G_CCMUX_TEXEL1 2 +#define G_CCMUX_PRIMITIVE 3 +#define G_CCMUX_SHADE 4 +#define G_CCMUX_ENVIRONMENT 5 +#define G_CCMUX_CENTER 6 +#define G_CCMUX_SCALE 6 +#define G_CCMUX_COMBINED_ALPHA 7 +#define G_CCMUX_TEXEL0_ALPHA 8 +#define G_CCMUX_TEXEL1_ALPHA 9 +#define G_CCMUX_PRIMITIVE_ALPHA 10 +#define G_CCMUX_SHADE_ALPHA 11 +#define G_CCMUX_ENV_ALPHA 12 +#define G_CCMUX_LOD_FRACTION 13 +#define G_CCMUX_PRIM_LOD_FRAC 14 +#define G_CCMUX_NOISE 7 +#define G_CCMUX_K4 7 +#define G_CCMUX_K5 15 +#define G_CCMUX_1 6 +#define G_CCMUX_0 31 + +/* Alpha combiner constants: */ +#define G_ACMUX_COMBINED 0 +#define G_ACMUX_TEXEL0 1 +#define G_ACMUX_TEXEL1 2 +#define G_ACMUX_PRIMITIVE 3 +#define G_ACMUX_SHADE 4 +#define G_ACMUX_ENVIRONMENT 5 +#define G_ACMUX_LOD_FRACTION 0 +#define G_ACMUX_PRIM_LOD_FRAC 6 +#define G_ACMUX_1 6 +#define G_ACMUX_0 7 + +/* typical CC cycle 1 modes */ +#define G_CC_PRIMITIVE 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE +#define G_CC_SHADE 0, 0, 0, SHADE, 0, 0, 0, SHADE +#define G_CC_MODULATEI TEXEL0, 0, SHADE, 0, 0, 0, 0, SHADE +#define G_CC_MODULATEIA TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0 +#define G_CC_MODULATEIDECALA TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0 +#define G_CC_MODULATERGB G_CC_MODULATEI +#define G_CC_MODULATERGBA G_CC_MODULATEIA +#define G_CC_MODULATERGBDECALA G_CC_MODULATEIDECALA +#define G_CC_MODULATEI_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE +#define G_CC_MODULATEIA_PRIM TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0 +#define G_CC_MODULATEIDECALA_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0 +#define G_CC_MODULATERGB_PRIM G_CC_MODULATEI_PRIM +#define G_CC_MODULATERGBA_PRIM G_CC_MODULATEIA_PRIM +#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIDECALA_PRIM +#define G_CC_DECALRGB 0, 0, 0, TEXEL0, 0, 0, 0, SHADE +#define G_CC_DECALRGBA 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 +#define G_CC_BLENDI ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_BLENDIA ENVIRONMENT, SHADE, TEXEL0, SHADE, TEXEL0, 0, SHADE, 0 +#define G_CC_BLENDIDECALA ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_BLENDRGBA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, SHADE +#define G_CC_BLENDRGBDECALA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_ADDRGB 1, 0, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_ADDRGBDECALA 1, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_REFLECTRGB ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_REFLECTRGBDECALA ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_HILITERGB PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_HILITERGBA PRIMITIVE, SHADE, TEXEL0, SHADE, PRIMITIVE, SHADE, TEXEL0, SHADE +#define G_CC_HILITERGBDECALA PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_SHADEDECALA 0, 0, 0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_BLENDPE PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0 +#define G_CC_BLENDPEDECALA PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL0 + +/* oddball modes */ +#define _G_CC_BLENDPE ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, SHADE, 0 +#define _G_CC_BLENDPEDECALA ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, 0, 0, 0, TEXEL0 +#define _G_CC_TWOCOLORTEX PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE +/* used for 1-cycle sparse mip-maps, primitive color has color of lowest LOD */ +#define _G_CC_SPARSEST PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0, PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0 +#define G_CC_TEMPLERP TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0 + +/* typical CC cycle 1 modes, usually followed by other cycle 2 modes */ +#define G_CC_TRILERP TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0, TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0 +#define G_CC_INTERFERENCE TEXEL0, 0, TEXEL1, 0, TEXEL0, 0, TEXEL1, 0 + +/* + * One-cycle color convert operation + */ +#define G_CC_1CYUV2RGB TEXEL0, K4, K5, TEXEL0, 0, 0, 0, SHADE + +/* + * NOTE: YUV2RGB expects TF step1 color conversion to occur in 2nd clock. + * Therefore, CC looks for step1 results in TEXEL1 + */ +#define G_CC_YUV2RGB TEXEL1, K4, K5, TEXEL1, 0, 0, 0, 0 + +/* typical CC cycle 2 modes */ +#define G_CC_PASS2 0, 0, 0, COMBINED, 0, 0, 0, COMBINED +#define G_CC_MODULATEI2 COMBINED, 0, SHADE, 0, 0, 0, 0, SHADE +#define G_CC_MODULATEIA2 COMBINED, 0, SHADE, 0, COMBINED, 0, SHADE, 0 +#define G_CC_MODULATERGB2 G_CC_MODULATEI2 +#define G_CC_MODULATERGBA2 G_CC_MODULATEIA2 +#define G_CC_MODULATEI_PRIM2 COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE +#define G_CC_MODULATEIA_PRIM2 COMBINED, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0 +#define G_CC_MODULATERGB_PRIM2 G_CC_MODULATEI_PRIM2 +#define G_CC_MODULATERGBA_PRIM2 G_CC_MODULATEIA_PRIM2 +#define G_CC_DECALRGB2 0, 0, 0, COMBINED, 0, 0, 0, SHADE +/* + * ? +#define G_CC_DECALRGBA2 COMBINED, SHADE, COMBINED_ALPHA, SHADE, 0, 0, 0, SHADE +*/ +#define G_CC_BLENDI2 ENVIRONMENT, SHADE, COMBINED, SHADE, 0, 0, 0, SHADE +#define G_CC_BLENDIA2 ENVIRONMENT, SHADE, COMBINED, SHADE, COMBINED, 0, SHADE, 0 +#define G_CC_CHROMA_KEY2 TEXEL0, CENTER, SCALE, 0, 0, 0, 0, 0 +#define G_CC_HILITERGB2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, SHADE +#define G_CC_HILITERGBA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, ENVIRONMENT, COMBINED, TEXEL0, COMBINED +#define G_CC_HILITERGBDECALA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, TEXEL0 +#define G_CC_HILITERGBPASSA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, COMBINED + +/* + * G_SETOTHERMODE_L sft: shift count + */ +#define G_MDSFT_ALPHACOMPARE 0 +#define G_MDSFT_ZSRCSEL 2 +#define G_MDSFT_RENDERMODE 3 +#define G_MDSFT_BLENDER 16 + +/* + * G_SETOTHERMODE_H sft: shift count + */ +#define G_MDSFT_BLENDMASK 0 /* unsupported */ +#define G_MDSFT_ALPHADITHER 4 +#define G_MDSFT_RGBDITHER 6 + +#define G_MDSFT_COMBKEY 8 +#define G_MDSFT_TEXTCONV 9 +#define G_MDSFT_TEXTFILT 12 +#define G_MDSFT_TEXTLUT 14 +#define G_MDSFT_TEXTLOD 16 +#define G_MDSFT_TEXTDETAIL 17 +#define G_MDSFT_TEXTPERSP 19 +#define G_MDSFT_CYCLETYPE 20 +#define G_MDSFT_COLORDITHER 22 /* unsupported in HW 2.0 */ +#define G_MDSFT_PIPELINE 23 + +/* G_SETOTHERMODE_H gPipelineMode */ +#define G_PM_1PRIMITIVE (1 << G_MDSFT_PIPELINE) +#define G_PM_NPRIMITIVE (0 << G_MDSFT_PIPELINE) + +/* G_SETOTHERMODE_H gSetCycleType */ +#define G_CYC_1CYCLE (0 << G_MDSFT_CYCLETYPE) +#define G_CYC_2CYCLE (1 << G_MDSFT_CYCLETYPE) +#define G_CYC_COPY (2 << G_MDSFT_CYCLETYPE) +#define G_CYC_FILL (3 << G_MDSFT_CYCLETYPE) + +/* G_SETOTHERMODE_H gSetTexturePersp */ +#define G_TP_NONE (0 << G_MDSFT_TEXTPERSP) +#define G_TP_PERSP (1 << G_MDSFT_TEXTPERSP) + +/* G_SETOTHERMODE_H gSetTextureDetail */ +#define G_TD_CLAMP (0 << G_MDSFT_TEXTDETAIL) +#define G_TD_SHARPEN (1 << G_MDSFT_TEXTDETAIL) +#define G_TD_DETAIL (2 << G_MDSFT_TEXTDETAIL) + +/* G_SETOTHERMODE_H gSetTextureLOD */ +#define G_TL_TILE (0 << G_MDSFT_TEXTLOD) +#define G_TL_LOD (1 << G_MDSFT_TEXTLOD) + +/* G_SETOTHERMODE_H gSetTextureLUT */ +#define G_TT_NONE (0 << G_MDSFT_TEXTLUT) +#define G_TT_RGBA16 (2 << G_MDSFT_TEXTLUT) +#define G_TT_IA16 (3 << G_MDSFT_TEXTLUT) + +/* G_SETOTHERMODE_H gSetTextureFilter */ +#define G_TF_POINT (0 << G_MDSFT_TEXTFILT) +#define G_TF_AVERAGE (3 << G_MDSFT_TEXTFILT) +#define G_TF_BILERP (2 << G_MDSFT_TEXTFILT) + +/* G_SETOTHERMODE_H gSetTextureConvert */ +#define G_TC_CONV (0 << G_MDSFT_TEXTCONV) +#define G_TC_FILTCONV (5 << G_MDSFT_TEXTCONV) +#define G_TC_FILT (6 << G_MDSFT_TEXTCONV) + +/* G_SETOTHERMODE_H gSetCombineKey */ +#define G_CK_NONE (0 << G_MDSFT_COMBKEY) +#define G_CK_KEY (1 << G_MDSFT_COMBKEY) + +/* G_SETOTHERMODE_H gSetColorDither */ +#define G_CD_MAGICSQ (0 << G_MDSFT_RGBDITHER) +#define G_CD_BAYER (1 << G_MDSFT_RGBDITHER) +#define G_CD_NOISE (2 << G_MDSFT_RGBDITHER) + +#ifndef _HW_VERSION_1 +#define G_CD_DISABLE (3 << G_MDSFT_RGBDITHER) +#define G_CD_ENABLE G_CD_NOISE /* HW 1.0 compatibility mode */ +#else +#define G_CD_ENABLE (1 << G_MDSFT_COLORDITHER) +#define G_CD_DISABLE (0 << G_MDSFT_COLORDITHER) +#endif + +/* G_SETOTHERMODE_H gSetAlphaDither */ +#define G_AD_PATTERN (0 << G_MDSFT_ALPHADITHER) +#define G_AD_NOTPATTERN (1 << G_MDSFT_ALPHADITHER) +#define G_AD_NOISE (2 << G_MDSFT_ALPHADITHER) +#define G_AD_DISABLE (3 << G_MDSFT_ALPHADITHER) + +/* G_SETOTHERMODE_L gSetAlphaCompare */ +#define G_AC_NONE (0 << G_MDSFT_ALPHACOMPARE) +#define G_AC_THRESHOLD (1 << G_MDSFT_ALPHACOMPARE) +#define G_AC_DITHER (3 << G_MDSFT_ALPHACOMPARE) + +/* G_SETOTHERMODE_L gSetDepthSource */ +#define G_ZS_PIXEL (0 << G_MDSFT_ZSRCSEL) +#define G_ZS_PRIM (1 << G_MDSFT_ZSRCSEL) + +/* G_SETOTHERMODE_L gSetRenderMode */ +#define AA_EN 0x8 +#define Z_CMP 0x10 +#define Z_UPD 0x20 +#define IM_RD 0x40 +#define CLR_ON_CVG 0x80 +#define CVG_DST_CLAMP 0 +#define CVG_DST_WRAP 0x100 +#define CVG_DST_FULL 0x200 +#define CVG_DST_SAVE 0x300 +#define ZMODE_OPA 0 +#define ZMODE_INTER 0x400 +#define ZMODE_XLU 0x800 +#define ZMODE_DEC 0xc00 +#define CVG_X_ALPHA 0x1000 +#define ALPHA_CVG_SEL 0x2000 +#define FORCE_BL 0x4000 +#define TEX_EDGE 0x0000 /* used to be 0x8000 */ + +#define G_BL_CLR_IN 0 +#define G_BL_CLR_MEM 1 +#define G_BL_CLR_BL 2 +#define G_BL_CLR_FOG 3 +#define G_BL_1MA 0 +#define G_BL_A_MEM 1 +#define G_BL_A_IN 0 +#define G_BL_A_FOG 1 +#define G_BL_A_SHADE 2 +#define G_BL_1 2 +#define G_BL_0 3 + +#define GBL_c1(m1a, m1b, m2a, m2b) \ + (m1a) << 30 | (m1b) << 26 | (m2a) << 22 | (m2b) << 18 +#define GBL_c2(m1a, m1b, m2a, m2b) \ + (m1a) << 28 | (m1b) << 24 | (m2a) << 20 | (m2b) << 16 + +#define RM_AA_ZB_OPA_SURF(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_RA_ZB_OPA_SURF(clk) \ + AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_ZB_XLU_SURF(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ + FORCE_BL | ZMODE_XLU | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_OPA_DECAL(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ALPHA_CVG_SEL | \ + ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_RA_ZB_OPA_DECAL(clk) \ + AA_EN | Z_CMP | CVG_DST_WRAP | ALPHA_CVG_SEL | \ + ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_ZB_XLU_DECAL(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ + FORCE_BL | ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_OPA_INTER(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + ALPHA_CVG_SEL | ZMODE_INTER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_RA_ZB_OPA_INTER(clk) \ + AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ + ALPHA_CVG_SEL | ZMODE_INTER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_ZB_XLU_INTER(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ + FORCE_BL | ZMODE_INTER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_XLU_LINE(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ + ALPHA_CVG_SEL | FORCE_BL | ZMODE_XLU | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_DEC_LINE(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | CVG_X_ALPHA | \ + ALPHA_CVG_SEL | FORCE_BL | ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_TEX_EDGE(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_ZB_TEX_INTER(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_INTER | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_ZB_SUB_SURF(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_ZB_PCL_SURF(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + ZMODE_OPA | G_AC_DITHER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_OPA_TERR(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_TEX_TERR(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_ZB_SUB_TERR(clk) \ + AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + + +#define RM_AA_OPA_SURF(clk) \ + AA_EN | IM_RD | CVG_DST_CLAMP | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_RA_OPA_SURF(clk) \ + AA_EN | CVG_DST_CLAMP | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_XLU_SURF(clk) \ + AA_EN | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | \ + ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_XLU_LINE(clk) \ + AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ + ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_DEC_LINE(clk) \ + AA_EN | IM_RD | CVG_DST_FULL | CVG_X_ALPHA | \ + ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_TEX_EDGE(clk) \ + AA_EN | IM_RD | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_SUB_SURF(clk) \ + AA_EN | IM_RD | CVG_DST_FULL | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_AA_PCL_SURF(clk) \ + AA_EN | IM_RD | CVG_DST_CLAMP | \ + ZMODE_OPA | G_AC_DITHER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_OPA_TERR(clk) \ + AA_EN | IM_RD | CVG_DST_CLAMP | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_TEX_TERR(clk) \ + AA_EN | IM_RD | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_AA_SUB_TERR(clk) \ + AA_EN | IM_RD | CVG_DST_FULL | \ + ZMODE_OPA | ALPHA_CVG_SEL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + + +#define RM_ZB_OPA_SURF(clk) \ + Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | \ + ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_ZB_XLU_SURF(clk) \ + Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_ZB_OPA_DECAL(clk) \ + Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) + +#define RM_ZB_XLU_DECAL(clk) \ + Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_ZB_CLD_SURF(clk) \ + Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_ZB_OVL_SURF(clk) \ + Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_ZB_PCL_SURF(clk) \ + Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ + G_AC_DITHER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) + + +#define RM_OPA_SURF(clk) \ + CVG_DST_CLAMP | FORCE_BL | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) + +#define RM_XLU_SURF(clk) \ + IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_TEX_EDGE(clk) \ + CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL |\ + ZMODE_OPA | TEX_EDGE | AA_EN | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) + +#define RM_CLD_SURF(clk) \ + IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define RM_PCL_SURF(clk) \ + CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ + G_AC_DITHER | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) + +#define RM_ADD(clk) \ + IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1) + +#define RM_NOOP(clk) \ + GBL_c##clk(0, 0, 0, 0) + +#define RM_VISCVG(clk) \ + IM_RD | FORCE_BL | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM) + +/* for rendering to an 8-bit framebuffer */ +#define RM_OPA_CI(clk) \ + CVG_DST_CLAMP | ZMODE_OPA | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) + + + +#define G_RM_AA_ZB_OPA_SURF RM_AA_ZB_OPA_SURF(1) +#define G_RM_AA_ZB_OPA_SURF2 RM_AA_ZB_OPA_SURF(2) +#define G_RM_AA_ZB_XLU_SURF RM_AA_ZB_XLU_SURF(1) +#define G_RM_AA_ZB_XLU_SURF2 RM_AA_ZB_XLU_SURF(2) +#define G_RM_AA_ZB_OPA_DECAL RM_AA_ZB_OPA_DECAL(1) +#define G_RM_AA_ZB_OPA_DECAL2 RM_AA_ZB_OPA_DECAL(2) +#define G_RM_AA_ZB_XLU_DECAL RM_AA_ZB_XLU_DECAL(1) +#define G_RM_AA_ZB_XLU_DECAL2 RM_AA_ZB_XLU_DECAL(2) +#define G_RM_AA_ZB_OPA_INTER RM_AA_ZB_OPA_INTER(1) +#define G_RM_AA_ZB_OPA_INTER2 RM_AA_ZB_OPA_INTER(2) +#define G_RM_AA_ZB_XLU_INTER RM_AA_ZB_XLU_INTER(1) +#define G_RM_AA_ZB_XLU_INTER2 RM_AA_ZB_XLU_INTER(2) +#define G_RM_AA_ZB_XLU_LINE RM_AA_ZB_XLU_LINE(1) +#define G_RM_AA_ZB_XLU_LINE2 RM_AA_ZB_XLU_LINE(2) +#define G_RM_AA_ZB_DEC_LINE RM_AA_ZB_DEC_LINE(1) +#define G_RM_AA_ZB_DEC_LINE2 RM_AA_ZB_DEC_LINE(2) +#define G_RM_AA_ZB_TEX_EDGE RM_AA_ZB_TEX_EDGE(1) +#define G_RM_AA_ZB_TEX_EDGE2 RM_AA_ZB_TEX_EDGE(2) +#define G_RM_AA_ZB_TEX_INTER RM_AA_ZB_TEX_INTER(1) +#define G_RM_AA_ZB_TEX_INTER2 RM_AA_ZB_TEX_INTER(2) +#define G_RM_AA_ZB_SUB_SURF RM_AA_ZB_SUB_SURF(1) +#define G_RM_AA_ZB_SUB_SURF2 RM_AA_ZB_SUB_SURF(2) +#define G_RM_AA_ZB_PCL_SURF RM_AA_ZB_PCL_SURF(1) +#define G_RM_AA_ZB_PCL_SURF2 RM_AA_ZB_PCL_SURF(2) +#define G_RM_AA_ZB_OPA_TERR RM_AA_ZB_OPA_TERR(1) +#define G_RM_AA_ZB_OPA_TERR2 RM_AA_ZB_OPA_TERR(2) +#define G_RM_AA_ZB_TEX_TERR RM_AA_ZB_TEX_TERR(1) +#define G_RM_AA_ZB_TEX_TERR2 RM_AA_ZB_TEX_TERR(2) +#define G_RM_AA_ZB_SUB_TERR RM_AA_ZB_SUB_TERR(1) +#define G_RM_AA_ZB_SUB_TERR2 RM_AA_ZB_SUB_TERR(2) + +#define G_RM_RA_ZB_OPA_SURF RM_RA_ZB_OPA_SURF(1) +#define G_RM_RA_ZB_OPA_SURF2 RM_RA_ZB_OPA_SURF(2) +#define G_RM_RA_ZB_OPA_DECAL RM_RA_ZB_OPA_DECAL(1) +#define G_RM_RA_ZB_OPA_DECAL2 RM_RA_ZB_OPA_DECAL(2) +#define G_RM_RA_ZB_OPA_INTER RM_RA_ZB_OPA_INTER(1) +#define G_RM_RA_ZB_OPA_INTER2 RM_RA_ZB_OPA_INTER(2) + +#define G_RM_AA_OPA_SURF RM_AA_OPA_SURF(1) +#define G_RM_AA_OPA_SURF2 RM_AA_OPA_SURF(2) +#define G_RM_AA_XLU_SURF RM_AA_XLU_SURF(1) +#define G_RM_AA_XLU_SURF2 RM_AA_XLU_SURF(2) +#define G_RM_AA_XLU_LINE RM_AA_XLU_LINE(1) +#define G_RM_AA_XLU_LINE2 RM_AA_XLU_LINE(2) +#define G_RM_AA_DEC_LINE RM_AA_DEC_LINE(1) +#define G_RM_AA_DEC_LINE2 RM_AA_DEC_LINE(2) +#define G_RM_AA_TEX_EDGE RM_AA_TEX_EDGE(1) +#define G_RM_AA_TEX_EDGE2 RM_AA_TEX_EDGE(2) +#define G_RM_AA_SUB_SURF RM_AA_SUB_SURF(1) +#define G_RM_AA_SUB_SURF2 RM_AA_SUB_SURF(2) +#define G_RM_AA_PCL_SURF RM_AA_PCL_SURF(1) +#define G_RM_AA_PCL_SURF2 RM_AA_PCL_SURF(2) +#define G_RM_AA_OPA_TERR RM_AA_OPA_TERR(1) +#define G_RM_AA_OPA_TERR2 RM_AA_OPA_TERR(2) +#define G_RM_AA_TEX_TERR RM_AA_TEX_TERR(1) +#define G_RM_AA_TEX_TERR2 RM_AA_TEX_TERR(2) +#define G_RM_AA_SUB_TERR RM_AA_SUB_TERR(1) +#define G_RM_AA_SUB_TERR2 RM_AA_SUB_TERR(2) + +#define G_RM_RA_OPA_SURF RM_RA_OPA_SURF(1) +#define G_RM_RA_OPA_SURF2 RM_RA_OPA_SURF(2) + +#define G_RM_ZB_OPA_SURF RM_ZB_OPA_SURF(1) +#define G_RM_ZB_OPA_SURF2 RM_ZB_OPA_SURF(2) +#define G_RM_ZB_XLU_SURF RM_ZB_XLU_SURF(1) +#define G_RM_ZB_XLU_SURF2 RM_ZB_XLU_SURF(2) +#define G_RM_ZB_OPA_DECAL RM_ZB_OPA_DECAL(1) +#define G_RM_ZB_OPA_DECAL2 RM_ZB_OPA_DECAL(2) +#define G_RM_ZB_XLU_DECAL RM_ZB_XLU_DECAL(1) +#define G_RM_ZB_XLU_DECAL2 RM_ZB_XLU_DECAL(2) +#define G_RM_ZB_CLD_SURF RM_ZB_CLD_SURF(1) +#define G_RM_ZB_CLD_SURF2 RM_ZB_CLD_SURF(2) +#define G_RM_ZB_OVL_SURF RM_ZB_OVL_SURF(1) +#define G_RM_ZB_OVL_SURF2 RM_ZB_OVL_SURF(2) +#define G_RM_ZB_PCL_SURF RM_ZB_PCL_SURF(1) +#define G_RM_ZB_PCL_SURF2 RM_ZB_PCL_SURF(2) + +#define G_RM_OPA_SURF RM_OPA_SURF(1) +#define G_RM_OPA_SURF2 RM_OPA_SURF(2) +#define G_RM_XLU_SURF RM_XLU_SURF(1) +#define G_RM_XLU_SURF2 RM_XLU_SURF(2) +#define G_RM_CLD_SURF RM_CLD_SURF(1) +#define G_RM_CLD_SURF2 RM_CLD_SURF(2) +#define G_RM_TEX_EDGE RM_TEX_EDGE(1) +#define G_RM_TEX_EDGE2 RM_TEX_EDGE(2) +#define G_RM_PCL_SURF RM_PCL_SURF(1) +#define G_RM_PCL_SURF2 RM_PCL_SURF(2) +#define G_RM_ADD RM_ADD(1) +#define G_RM_ADD2 RM_ADD(2) +#define G_RM_NOOP RM_NOOP(1) +#define G_RM_NOOP2 RM_NOOP(2) +#define G_RM_VISCVG RM_VISCVG(1) +#define G_RM_VISCVG2 RM_VISCVG(2) +#define G_RM_OPA_CI RM_OPA_CI(1) +#define G_RM_OPA_CI2 RM_OPA_CI(2) + + +#define G_RM_FOG_SHADE_A GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA) +#define G_RM_FOG_PRIM_A GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA) +#define G_RM_PASS GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) + +/* + * G_SETCONVERT: K0-5 + */ +#define G_CV_K0 175 +#define G_CV_K1 -43 +#define G_CV_K2 -89 +#define G_CV_K3 222 +#define G_CV_K4 114 +#define G_CV_K5 42 + +/* + * G_SETSCISSOR: interlace mode + */ +#define G_SC_NON_INTERLACE 0 +#define G_SC_ODD_INTERLACE 3 +#define G_SC_EVEN_INTERLACE 2 + +/* flags to inhibit pushing of the display list (on branch) */ +#define G_DL_PUSH 0x00 +#define G_DL_NOPUSH 0x01 + +/* + * BEGIN C-specific section: (typedef's) + */ +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* + * Data Structures + * + * NOTE: + * The DMA transfer hardware requires 64-bit aligned, 64-bit multiple- + * sized transfers. This important hardware optimization is unfortunately + * reflected in the programming interface, with some structures + * padded and alignment enforced. + * + * Since structures are aligned to the boundary of the "worst-case" + * element, we can't depend on the C compiler to align things + * properly. + * + * 64-bit structure alignment is enforced by wrapping structures with + * unions that contain a dummy "long long int". Why this works is + * explained in the ANSI C Spec, or on page 186 of the second edition + * of K&R, "The C Programming Language". + * + * The price we pay for this is a little awkwardness referencing the + * structures through the union. There is no memory penalty, since + * all the structures are at least 64-bits the dummy alignment field + * does not increase the size of the union. + * + * Static initialization of these union structures works because + * the ANSI C spec states that static initialization for unions + * works by using the first union element. We put the dummy alignment + * field last for this reason. + * + * (it's possible a newer 64-bit compiler from MIPS might make this + * easier with a flag, but we can't wait for it...) + * + */ + +/* + * Vertex (set up for use with colors) + */ +typedef struct { + short ob[3]; /* x, y, z */ + unsigned short flag; + short tc[2]; /* texture coord */ + unsigned char cn[4]; /* color & alpha */ +} Vtx_t; + +/* + * Vertex (set up for use with normals) + */ +typedef struct { + short ob[3]; /* x, y, z */ + unsigned short flag; + short tc[2]; /* texture coord */ + signed char n[3]; /* normal */ + unsigned char a; /* alpha */ +} Vtx_tn; + +typedef union { + Vtx_t v; /* Use this one for colors */ + Vtx_tn n; /* Use this one for normals */ + long long int force_structure_alignment; +} Vtx; + +/* + * Sprite structure + */ + +typedef struct { + void *SourceImagePointer; + void *TlutPointer; + short Stride; + short SubImageWidth; + short SubImageHeight; + char SourceImageType; + char SourceImageBitSize; + short SourceImageOffsetS; + short SourceImageOffsetT; + /* 20 bytes for above */ + + /* padding to bring structure size to 64 bit allignment */ + char dummy[4]; + +} uSprite_t; + +typedef union { + uSprite_t s; + + /* Need to make sure this is 64 bit aligned */ + long long int force_structure_allignment[3]; +} uSprite; + +/* + * Triangle face + */ +typedef struct { + unsigned char flag; + unsigned char v[3]; +} Tri; + +/* + * 4x4 matrix, fixed point s15.16 format. + * First 8 words are integer portion of the 4x4 matrix + * Last 8 words are the fraction portion of the 4x4 matrix + */ +typedef long Mtx_t[4][4]; + +typedef union { + Mtx_t m; + long long int force_structure_alignment; +} Mtx; + +/* + * Viewport + */ + +/* + * + * This magic value is the maximum INTEGER z-range of the hardware + * (there are also 16-bits of fraction, which are introduced during + * any transformations). This is not just a good idea, it's the law. + * Feeding the hardware eventual z-coordinates (after any transforms + * or scaling) bigger than this, will not work. + * + * This number is DIFFERENT than G_MAXFBZ, which is the maximum value + * you want to use to initialize the z-buffer. + * + * The reason these are different is mildly interesting, but too long + * to explain here. It is basically the result of optimizations in the + * hardware. A more generic API might hide this detail from the users, + * but we don't have the ucode to do that... + * + */ +#define G_MAXZ 0x03ff /* 10 bits of integer screen-Z precision */ + +/* + * The viewport structure elements have 2 bits of fraction, necessary + * to accomodate the sub-pixel positioning scaling for the hardware. + * This can also be exploited to handle odd-sized viewports. + * + * Accounting for these fractional bits, using the default projection + * and viewing matrices, the viewport structure is initialized thusly: + * + * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, G_MAXZ, 0, + * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, 0, 0, + */ +typedef struct { + short vscale[4]; /* scale, 2 bits fraction */ + short vtrans[4]; /* translate, 2 bits fraction */ + /* both the above arrays are padded to 64-bit boundary */ +} Vp_t; + +typedef union { + Vp_t vp; + long long int force_structure_alignment; +} Vp; + +/* + * MOVEMEM indices + * + * Each of these indexes an entry in a dmem table + * which points to a 1-4 word block of dmem in + * which to store a 1-4 word DMA. + * + */ +#ifdef F3DEX_GBI_2x +/* 0,2,4,6 are reserved by G_MTX */ +# define G_MV_VIEWPORT 8 +# define G_MV_LIGHT 10 +# define G_MV_POINT 12 +# define G_MV_MATRIX 14 /* NOTE: this is in moveword table */ +# define G_MVO_LOOKATX (0*24) +# define G_MVO_LOOKATY (1*24) +# define G_MVO_L0 (2*24) +# define G_MVO_L1 (3*24) +# define G_MVO_L2 (4*24) +# define G_MVO_L3 (5*24) +# define G_MVO_L4 (6*24) +# define G_MVO_L5 (7*24) +# define G_MVO_L6 (8*24) +# define G_MVO_L7 (9*24) +#else /* F3DEX_GBI_2 */ +# define G_MV_VIEWPORT 0x80 +# define G_MV_LOOKATY 0x82 +# define G_MV_LOOKATX 0x84 +# define G_MV_L0 0x86 +# define G_MV_L1 0x88 +# define G_MV_L2 0x8a +# define G_MV_L3 0x8c +# define G_MV_L4 0x8e +# define G_MV_L5 0x90 +# define G_MV_L6 0x92 +# define G_MV_L7 0x94 +# define G_MV_TXTATT 0x96 +# define G_MV_MATRIX_1 0x9e /* NOTE: this is in moveword table */ +# define G_MV_MATRIX_2 0x98 +# define G_MV_MATRIX_3 0x9a +# define G_MV_MATRIX_4 0x9c +#endif /* F3DEX_GBI_2 */ + +/* + * MOVEWORD indices + * + * Each of these indexes an entry in a dmem table + * which points to a word in dmem in dmem where + * an immediate word will be stored. + * + */ +#define G_MW_MATRIX 0x00 /* NOTE: also used by movemem */ +#define G_MW_NUMLIGHT 0x02 +#define G_MW_CLIP 0x04 +#define G_MW_SEGMENT 0x06 +#define G_MW_FOG 0x08 +#define G_MW_LIGHTCOL 0x0a +#ifdef F3DEX_GBI_2x +# define G_MW_FORCEMTX 0x0c +#else /* F3DEX_GBI_2 */ +# define G_MW_POINTS 0x0c +#endif /* F3DEX_GBI_2 */ +#define G_MW_PERSPNORM 0x0e + +/* + * These are offsets from the address in the dmem table + */ +#define G_MWO_NUMLIGHT 0x00 +#define G_MWO_CLIP_RNX 0x04 +#define G_MWO_CLIP_RNY 0x0c +#define G_MWO_CLIP_RPX 0x14 +#define G_MWO_CLIP_RPY 0x1c +#define G_MWO_SEGMENT_0 0x00 +#define G_MWO_SEGMENT_1 0x01 +#define G_MWO_SEGMENT_2 0x02 +#define G_MWO_SEGMENT_3 0x03 +#define G_MWO_SEGMENT_4 0x04 +#define G_MWO_SEGMENT_5 0x05 +#define G_MWO_SEGMENT_6 0x06 +#define G_MWO_SEGMENT_7 0x07 +#define G_MWO_SEGMENT_8 0x08 +#define G_MWO_SEGMENT_9 0x09 +#define G_MWO_SEGMENT_A 0x0a +#define G_MWO_SEGMENT_B 0x0b +#define G_MWO_SEGMENT_C 0x0c +#define G_MWO_SEGMENT_D 0x0d +#define G_MWO_SEGMENT_E 0x0e +#define G_MWO_SEGMENT_F 0x0f +#define G_MWO_FOG 0x00 +#define G_MWO_aLIGHT_1 0x00 +#define G_MWO_bLIGHT_1 0x04 +#define G_MWO_aLIGHT_2 0x20 +#define G_MWO_bLIGHT_2 0x24 +#define G_MWO_aLIGHT_3 0x40 +#define G_MWO_bLIGHT_3 0x44 +#define G_MWO_aLIGHT_4 0x60 +#define G_MWO_bLIGHT_4 0x64 +#define G_MWO_aLIGHT_5 0x80 +#define G_MWO_bLIGHT_5 0x84 +#define G_MWO_aLIGHT_6 0xa0 +#define G_MWO_bLIGHT_6 0xa4 +#define G_MWO_aLIGHT_7 0xc0 +#define G_MWO_bLIGHT_7 0xc4 +#define G_MWO_aLIGHT_8 0xe0 +#define G_MWO_bLIGHT_8 0xe4 +#define G_MWO_MATRIX_XX_XY_I 0x00 +#define G_MWO_MATRIX_XZ_XW_I 0x04 +#define G_MWO_MATRIX_YX_YY_I 0x08 +#define G_MWO_MATRIX_YZ_YW_I 0x0c +#define G_MWO_MATRIX_ZX_ZY_I 0x10 +#define G_MWO_MATRIX_ZZ_ZW_I 0x14 +#define G_MWO_MATRIX_WX_WY_I 0x18 +#define G_MWO_MATRIX_WZ_WW_I 0x1c +#define G_MWO_MATRIX_XX_XY_F 0x20 +#define G_MWO_MATRIX_XZ_XW_F 0x24 +#define G_MWO_MATRIX_YX_YY_F 0x28 +#define G_MWO_MATRIX_YZ_YW_F 0x2c +#define G_MWO_MATRIX_ZX_ZY_F 0x30 +#define G_MWO_MATRIX_ZZ_ZW_F 0x34 +#define G_MWO_MATRIX_WX_WY_F 0x38 +#define G_MWO_MATRIX_WZ_WW_F 0x3c +#define G_MWO_POINT_RGBA 0x10 +#define G_MWO_POINT_ST 0x14 +#define G_MWO_POINT_XYSCREEN 0x18 +#define G_MWO_POINT_ZSCREEN 0x1c + +/* + * Light structure. + * + * Note: only directional (infinite) lights are currently supported. + * + * Note: the weird order is for the DMEM alignment benefit of + * the microcode. + * + */ + +typedef struct { + unsigned char col[3]; /* diffuse light value (rgba) */ + char pad1; + unsigned char colc[3]; /* copy of diffuse light value (rgba) */ + char pad2; + signed char dir[3]; /* direction of light (normalized) */ + char pad3; +} Light_t; + +typedef struct { + unsigned char col[3]; /* ambient light value (rgba) */ + char pad1; + unsigned char colc[3]; /* copy of ambient light value (rgba) */ + char pad2; +} Ambient_t; + +typedef struct { + int x1,y1,x2,y2; /* texture offsets for highlight 1/2 */ +} Hilite_t; + +typedef union { + Light_t l; + long long int force_structure_alignment[2]; +} Light; + +typedef union { + Ambient_t l; + long long int force_structure_alignment[1]; +} Ambient; + +typedef struct { + Ambient a; + Light l[7]; +} Lightsn; + +typedef struct { + Ambient a; + Light l[1]; +} Lights0; + +typedef struct { + Ambient a; + Light l[1]; +} Lights1; + +typedef struct { + Ambient a; + Light l[2]; +} Lights2; + +typedef struct { + Ambient a; + Light l[3]; +} Lights3; + +typedef struct { + Ambient a; + Light l[4]; +} Lights4; + +typedef struct { + Ambient a; + Light l[5]; +} Lights5; + +typedef struct { + Ambient a; + Light l[6]; +} Lights6; + +typedef struct { + Ambient a; + Light l[7]; +} Lights7; + +typedef struct { + Light l[2]; +} LookAt; + +typedef union { + Hilite_t h; + long int force_structure_alignment[4]; +} Hilite; + +#define gdSPDefLights0(ar,ag,ab) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} } +#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } +#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ + {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} } +#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ + {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ + {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} } +#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ + {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ + {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ + {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} } +#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ + {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ + {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ + {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ + {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} } + + +#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ + {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ + {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ + {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ + {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ + {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} } + + +#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \ + { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ + {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ + {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ + {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ + {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ + {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ + {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \ + {{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} } + + +#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ + { {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \ + { {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} } + +/* + * Graphics DMA Packet + */ +typedef struct { + int cmd:8; + unsigned int par:8; + unsigned int len:16; + unsigned int addr; +} Gdma; + +/* + * Graphics Immediate Mode Packet types + */ +typedef struct { + int cmd:8; + int pad:24; + Tri tri; +} Gtri; + +typedef struct { + int cmd:8; + int pad1:24; + int pad2:24; + unsigned char param:8; +} Gpopmtx; + +/* + * typedef struct { + * int cmd:8; + * int pad0:24; + * int pad1:4; + * int number:4; + * int base:24; + * } Gsegment; + */ +typedef struct { + int cmd:8; + int pad0:8; + int mw_index:8; + int number:8; + int pad1:8; + int base:24; +} Gsegment; + +typedef struct { + int cmd:8; + int pad0:8; + int sft:8; + int len:8; + unsigned int data:32; +} GsetothermodeL; + +typedef struct { + int cmd:8; + int pad0:8; + int sft:8; + int len:8; + unsigned int data:32; +} GsetothermodeH; + +typedef struct { + unsigned char cmd; + unsigned char lodscale; + unsigned char tile; + unsigned char on; + unsigned short s; + unsigned short t; +} Gtexture; + +typedef struct { + int cmd:8; + int pad:24; + Tri line; +} Gline3D; + +typedef struct { + int cmd:8; + int pad1:24; + short int pad2; + short int scale; +} Gperspnorm; + + +/* + * RDP Packet types + */ +typedef struct { + int cmd:8; + unsigned int fmt:3; + unsigned int siz:2; + unsigned int pad:7; + unsigned int wd:12; /* really only 10 bits, extra */ + unsigned int dram; /* to account for 1024 */ +} Gsetimg; + +typedef struct { + int cmd:8; + unsigned int muxs0:24; + unsigned int muxs1:32; +} Gsetcombine; + +typedef struct { + int cmd:8; + unsigned char pad; + unsigned char prim_min_level; + unsigned char prim_level; + unsigned long color; +} Gsetcolor; + +typedef struct { + int cmd:8; + int x0:10; + int x0frac:2; + int y0:10; + int y0frac:2; + unsigned int pad:8; + int x1:10; + int x1frac:2; + int y1:10; + int y1frac:2; +} Gfillrect; + +typedef struct { + int cmd:8; + unsigned int fmt:3; + unsigned int siz:2; + unsigned int pad0:1; + unsigned int line:9; + unsigned int tmem:9; + unsigned int pad1:5; + unsigned int tile:3; + unsigned int palette:4; + unsigned int ct:1; + unsigned int mt:1; + unsigned int maskt:4; + unsigned int shiftt:4; + unsigned int cs:1; + unsigned int ms:1; + unsigned int masks:4; + unsigned int shifts:4; +} Gsettile; + +typedef struct { + int cmd:8; + unsigned int sl:12; + unsigned int tl:12; + int pad:5; + unsigned int tile:3; + unsigned int sh:12; + unsigned int th:12; +} Gloadtile; + +typedef Gloadtile Gloadblock; + +typedef Gloadtile Gsettilesize; + +typedef Gloadtile Gloadtlut; + +typedef struct { + unsigned int cmd:8; /* command */ + unsigned int xl:12; /* X coordinate of upper left */ + unsigned int yl:12; /* Y coordinate of upper left */ + unsigned int pad1:5; /* Padding */ + unsigned int tile:3; /* Tile descriptor index */ + unsigned int xh:12; /* X coordinate of lower right */ + unsigned int yh:12; /* Y coordinate of lower right */ + unsigned int s:16; /* S texture coord at top left */ + unsigned int t:16; /* T texture coord at top left */ + unsigned int dsdx:16;/* Change in S per change in X */ + unsigned int dtdy:16;/* Change in T per change in Y */ +} Gtexrect; + +#define MakeTexRect(xh,yh,flip,tile,xl,yl,s,t,dsdx,dtdy) \ + G_TEXRECT, xh, yh, 0, flip, 0, tile, xl, yl, s, t, dsdx, dtdy + +/* + * Textured rectangles are 128 bits not 64 bits + */ +typedef struct { + unsigned long w0; + unsigned long w1; + unsigned long w2; + unsigned long w3; +} TexRect; + +/* + * Generic Gfx Packet + */ +typedef struct { + unsigned int w0; + unsigned int w1; +} Gwords; + +/* + * This union is the fundamental type of the display list. + * It is, by law, exactly 64 bits in size. + */ +typedef union { + Gwords words; + Gdma dma; + Gtri tri; + Gline3D line; + Gpopmtx popmtx; + Gsegment segment; + GsetothermodeH setothermodeH; + GsetothermodeL setothermodeL; + Gtexture texture; + Gperspnorm perspnorm; + Gsetimg setimg; + Gsetcombine setcombine; + Gsetcolor setcolor; + Gfillrect fillrect; /* use for setscissor also */ + Gsettile settile; + Gloadtile loadtile; /* use for loadblock also, th is dxt */ + Gsettilesize settilesize; + Gloadtlut loadtlut; + long long int force_structure_alignment; +} Gfx; + +/* + * Macros to assemble the graphics display list + */ + +/* + * DMA macros + */ +#define gDma0p(pkt, c, s, l) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24); \ + _g->words.w1 = (unsigned int)(s); \ +} + +#define gsDma0p(c, s, l) \ +{ \ + _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24), (unsigned int)(s) \ +} + +#define gDma1p(pkt, c, s, l, p) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ + _SHIFTL((l), 0, 16)); \ + _g->words.w1 = (unsigned int)(s); \ +} + +#define gsDma1p(c, s, l, p) \ +{ \ + (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ + _SHIFTL((l), 0, 16)), \ + (unsigned int)(s) \ +} + +#define gDma2p(pkt, c, adrs, len, idx, ofs) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL((c),24,8)|_SHIFTL((ofs)/8,16,8)| \ + _SHIFTL(((len)-1)/8,8,8)|_SHIFTL((idx),0,8)); \ + _g->words.w1 = (unsigned int)(adrs); \ +} +#define gsDma2p(c, adrs, len, idx, ofs) \ +{ \ + (_SHIFTL((c),24,8)|_SHIFTL((ofs)/8,16,8)| \ + _SHIFTL(((len)-1)/8,8,8)|_SHIFTL((idx),0,8)), \ + (unsigned int)(adrs) \ +} + +#define gSPNoOp(pkt) gDma0p(pkt, G_SPNOOP, 0, 0) +#define gsSPNoOp() gsDma0p(G_SPNOOP, 0, 0) + +#ifdef F3DEX_GBI_2x +# define gSPMatrix(pkt, m, p) \ + gDma2p((pkt),G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) +# define gsSPMatrix(m, p) \ + gsDma2p( G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) +#else /* F3DEX_GBI_2 */ +# define gSPMatrix(pkt, m, p) gDma1p(pkt, G_MTX, m, sizeof(Mtx), p) +# define gsSPMatrix(m, p) gsDma1p(G_MTX, m, sizeof(Mtx), p) +#endif /* F3DEX_GBI_2 */ + +/* + * F3DEX_GBI: G_VTX GBI format was changed to support 64 vertice. + * + * +--------+--------+------+---------------+ + * G_VTX | cmd:8 | v0:8 | n:6 | length:10 | + * +-+---+--+--------+------+---------------+ + * | |seg| address | + * +-+---+----------------------------------+ + */ +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +# define gSPVertex(pkt, v, n, v0) \ + gDma1p(pkt, G_VTX, v, ((n)<<10)|(sizeof(Vtx)*(n)-1), (v0)*2) +# define gsSPVertex(v, n, v0) \ + gsDma1p(G_VTX, v, ((n)<<10)|(sizeof(Vtx)*(n)-1), (v0)*2) +#else +# define gSPVertex(pkt, v, n, v0) \ + gDma1p(pkt, G_VTX, v, sizeof(Vtx)*(n),((n)-1)<<4|(v0)) +# define gsSPVertex(v, n, v0) \ + gsDma1p(G_VTX, v, sizeof(Vtx)*(n), ((n)-1)<<4|(v0)) +#endif + + +#ifdef F3DEX_GBI_2x +# define gSPViewport(pkt, v) gDma2p(pkt,G_MOVEMEM,v,sizeof(Vp),G_MV_VIEWPORT,0) +# define gsSPViewport(v) gsDma2p( G_MOVEMEM,v,sizeof(Vp),G_MV_VIEWPORT,0) +#else /* F3DEX_GBI_2 */ +# define gSPViewport(pkt,v) gDma1p(pkt,G_MOVEMEM,(v),sizeof(Vp),G_MV_VIEWPORT) +# define gsSPViewport(v) gsDma1p( G_MOVEMEM,(v),sizeof(Vp),G_MV_VIEWPORT) +#endif /* F3DEX_GBI_2 */ + +#define gSPDisplayList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_PUSH) +#define gsSPDisplayList( dl) gsDma1p( G_DL,dl,0,G_DL_PUSH) + +#define gSPBranchList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_NOPUSH) +#define gsSPBranchList( dl) gsDma1p( G_DL,dl,0,G_DL_NOPUSH) + +#define gSPSprite2DBase(pkt, s) gDma1p(pkt, G_SPRITE2D_BASE, s, sizeof(uSprite), 0) +#define gsSPSprite2DBase(s) gsDma1p(G_SPRITE2D_BASE, s, sizeof(uSprite), 0) + +/* + * RSP short command (no DMA required) macros + */ +#define gImmp0(pkt, c) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL((c), 24, 8); \ +} + +#define gsImmp0(c) \ +{ \ + _SHIFTL((c), 24, 8) \ +} + +#define gImmp1(pkt, c, p0) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL((c), 24, 8); \ + _g->words.w1 = (unsigned int)(p0); \ +} + +#define gsImmp1(c, p0) \ +{ \ + _SHIFTL((c), 24, 8), (unsigned int)(p0) \ +} + +#define gImmp2(pkt, c, p0, p1) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL((c), 24, 8); \ + _g->words.w1 = _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8); \ +} + +#define gsImmp2(c, p0, p1) \ +{ \ + _SHIFTL((c), 24, 8), _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8)\ +} + +#define gImmp3(pkt, c, p0, p1, p2) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL((c), 24, 8); \ + _g->words.w1 = (_SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8) | \ + _SHIFTL((p2), 0, 8)); \ +} + +#define gsImmp3(c, p0, p1, p2) \ +{ \ + _SHIFTL((c), 24, 8), (_SHIFTL((p0), 16, 16) | \ + _SHIFTL((p1), 8, 8) | _SHIFTL((p2), 0, 8))\ +} + +#define gImmp21(pkt, c, p0, p1, dat) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | \ + _SHIFTL((p1), 0, 8)); \ + _g->words.w1 = (unsigned int) (dat); \ +} + +#define gsImmp21(c, p0, p1, dat) \ +{ \ + _SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | _SHIFTL((p1), 0, 8),\ + (unsigned int) (dat) \ +} + +#ifdef F3DEX_GBI_2x +#define gMoveWd(pkt, index, offset, data) \ + gDma1p((pkt), G_MOVEWORD, data, offset, index) +#define gsMoveWd( index, offset, data) \ + gsDma1p( G_MOVEWORD, data, offset, index) +#else /* F3DEX_GBI_2 */ +#define gMoveWd(pkt, index, offset, data) \ + gImmp21((pkt), G_MOVEWORD, offset, index, data) +#define gsMoveWd( index, offset, data) \ + gsImmp21( G_MOVEWORD, offset, index, data) +#endif /* F3DEX_GBI_2 */ + +/* Sprite immediate macros, there is also a sprite dma macro above */ + +#define gSPSprite2DScaleFlip(pkt, sx, sy, fx, fy) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ + _SHIFTL((fx), 8, 8) | \ + _SHIFTL((fy), 0, 8)); \ + _g->words.w1 = (_SHIFTL((sx), 16, 16) | \ + _SHIFTL((sy), 0, 16)); \ +} + +#define gsSPSprite2DScaleFlip(sx, sy, fx, fy) \ +{ \ + (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ + _SHIFTL((fx), 8, 8) | \ + _SHIFTL((fy), 0, 8)), \ + (_SHIFTL((sx), 16, 16) | \ + _SHIFTL((sy), 0, 16)) \ +} + +#define gSPSprite2DDraw(pkt, px, py) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)); \ + _g->words.w1 = (_SHIFTL((px), 16, 16) | \ + _SHIFTL((py), 0, 16)); \ +} + +#define gsSPSprite2DDraw(px, py) \ +{ \ + (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)), \ + (_SHIFTL((px), 16, 16) | \ + _SHIFTL((py), 0, 16)) \ +} + + +/* + * Note: the SP1Triangle() and line macros multiply the vertex indices + * by 10, this is an optimization for the microcode. + */ +#if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) +# define __gsSP1Triangle_w1(v0, v1, v2) \ + (_SHIFTL((v0)*2,16,8)|_SHIFTL((v1)*2,8,8)|_SHIFTL((v2)*2,0,8)) +# define __gsSP1Triangle_w1f(v0, v1, v2, flag) \ + (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ + ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v0): \ + __gsSP1Triangle_w1(v2, v0, v1)) +# define __gsSPLine3D_w1(v0, v1, wd) \ + (_SHIFTL((v0)*2,16,8)|_SHIFT((v1)*2,8,8)|_SHIFT((wd),0,8)) +# define __gsSPLine3D_w1f(v0, v1, wd, flag) \ + (((flag) == 0) ? __gsSPLine3D_w1(v0, v1, wd): \ + __gsSPLine3D_w1(v1, v0, wd)) +#else +# define __gsSP1Triangle_w1f(v0, v1, v2, flag) \ + (_SHIFTL((flag), 24,8)|_SHIFTL((v0)*10,16,8)| \ + _SHIFTL((v1)*10, 8,8)|_SHIFTL((v2)*10, 0,8)) +# define __gsSPLine3D_w1f(v0, v1, wd, flag) \ + (_SHIFTL((flag), 24,8)|_SHIFTL((v0)*10,16,8)| \ + _SHIFTL((v1)*10, 8,8)|_SHIFTL((wd), 0,8)) +#endif + +/*** + *** 1 Triangle + ***/ +#define gSP1Triangle(pkt, v0, v1, v2, flag) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ + _g->words.w1 = __gsSP1Triangle_w1f(v0, v1, v2, flag); \ +} + +#define gsSP1Triangle(v0, v1, v2, flag) \ +{ \ + _SHIFTL(G_TRI1, 24, 8), \ + __gsSP1Triangle_w1f(v0, v1, v2, flag) \ +} + +/*** + *** Line + ***/ +#define gSPLine3D(pkt, v0, v1, flag) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \ + _g->words.w1 = __gsSPLine3D_w1f(v0, v1, 0, flag); \ +} + +#define gsSPLine3D(v0, v1, flag) \ +{ \ + _SHIFTL(G_LINE3D, 24, 8), \ + __gsSPLine3D_w1f(v0, v1, 0, flag) \ +} + +/*** + *** LineW + ***/ +/* these macros are the same as SPLine3D, except they have an + * additional parameter for width. The width is added to the "minimum" + * thickness, which is 1.5 pixels. The units for width are in + * half-pixel units, so a width of 1 translates to (.5 + 1.5) or + * a 2.0 pixels wide line. + */ +#define gSPLineW3D(pkt, v0, v1, wd, flag) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \ + _g->words.w1 = __gsSPLine3D_w1f(v0, v1, wd, flag); \ +} + +#define gsSPLineW3D(v0, v1, wd, flag) \ +{ \ + _SHIFTL(G_LINE3D, 24, 8), \ + __gsSPLine3D_w1f(v0, v1, wd, flag) \ +} + +#if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) +/*** + *** 2 Triangles + ***/ +#define gSP2Triangles(pkt, v00, v01, v02, flag0, v10, v11, v12, flag1) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ + __gsSP1Triangle_w1f(v00, v01, v02, flag0)); \ + _g->words.w1 = __gsSP1Triangle_w1f(v10, v11, v12, flag1); \ +} + +#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ +{ \ + (_SHIFTL(G_TRI2, 24, 8)| \ + __gsSP1Triangle_w1f(v00, v01, v02, flag0)), \ + __gsSP1Triangle_w1f(v10, v11, v12, flag1) \ +} + +/*** + *** 1 Quadrangle + ***/ +#define __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag) \ + (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ + ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v3): \ + ((flag) == 2) ? __gsSP1Triangle_w1(v2, v3, v0): \ + __gsSP1Triangle_w1(v3, v0, v1)) + +#define __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ + (((flag) == 0) ? __gsSP1Triangle_w1(v0, v2, v3): \ + ((flag) == 1) ? __gsSP1Triangle_w1(v1, v3, v0): \ + ((flag) == 2) ? __gsSP1Triangle_w1(v2, v0, v1): \ + __gsSP1Triangle_w1(v3, v1, v2)) + +#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ + __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \ + _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \ +} + +#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ +{ \ + (_SHIFTL(G_TRI2, 24, 8)| \ + __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ + __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ +} +#endif /* F3DEX_GBI/F3DLP_GBI */ + +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +#define gSPCullDisplayList(pkt,vstart,vend) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ + _SHIFTL((vstart)*2, 0, 16); \ + _g->words.w1 = _SHIFTL((vend)*2, 0, 16); \ +} + +#define gsSPCullDisplayList(vstart,vend) \ +{ \ + _SHIFTL(G_CULLDL, 24, 8) | _SHIFTL((vstart)*2, 0, 16), \ + _SHIFTL((vend)*2, 0, 16) \ +} + +#else +#define gSPCullDisplayList(pkt,vstart,vend) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ + ((0x0f & (vstart))*40); \ + _g->words.w1 = (unsigned int)((0x0f & ((vend)+1))*40); \ +} + +#define gsSPCullDisplayList(vstart,vend) \ +{ \ + _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart))*40), \ + ((0x0f & ((vend)+1))*40) \ +} +#endif + +#define gSPSegment(pkt, segment, base) \ + gMoveWd(pkt, G_MW_SEGMENT, (segment)*4, base) +#define gsSPSegment(segment, base) \ + gsMoveWd( G_MW_SEGMENT, (segment)*4, base) + +/* + * Clipping Macros + */ +#define FR_NEG_FRUSTRATIO_1 0x00000001 +#define FR_POS_FRUSTRATIO_1 0x0000ffff +#define FR_NEG_FRUSTRATIO_2 0x00000002 +#define FR_POS_FRUSTRATIO_2 0x0000fffe +#define FR_NEG_FRUSTRATIO_3 0x00000003 +#define FR_POS_FRUSTRATIO_3 0x0000fffd +#define FR_NEG_FRUSTRATIO_4 0x00000004 +#define FR_POS_FRUSTRATIO_4 0x0000fffc +#define FR_NEG_FRUSTRATIO_5 0x00000005 +#define FR_POS_FRUSTRATIO_5 0x0000fffb +#define FR_NEG_FRUSTRATIO_6 0x00000006 +#define FR_POS_FRUSTRATIO_6 0x0000fffa +/* + * r should be one of: FRUSTRATIO_1, FRUSTRATIO_2, FRUSTRATIO_3, ... FRUSTRATIO_6 + */ +#define gSPClipRatio(pkt, r) \ +{ \ + gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r); \ + gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r); \ + gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r); \ + gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r); \ +} + +#define gsSPClipRatio(r) \ + gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r), \ + gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r), \ + gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r), \ + gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r) + +/* + * Insert values into Matrix + * + * where = element of matrix (byte offset) + * num = new element (32 bit value replacing 2 int or 2 frac matrix + * componants + */ +#ifdef F3DEX_GBI_2x +//ERROR!! gSPInsertMatrix is no longer supported. +#else +#define gSPInsertMatrix(pkt, where, num) \ + gMoveWd(pkt, G_MW_MATRIX, where, num) +#define gsSPInsertMatrix(where, num) \ + gsMoveWd(G_MW_MATRIX, where, num) +#endif + +/* + * Load new matrix directly + * + * mptr = pointer to matrix + */ +#ifdef F3DEX_GBI_2x +#define gSPForceMatrix(pkt, mptr) \ +{ gDma2p((pkt),G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0); \ + gMoveWd((pkt), G_MW_FORCEMTX,0,0x00010000); \ +} +#define gsSPForceMatrix(mptr) \ + gsDma2p(G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0), \ + gsMoveWd(G_MW_FORCEMTX,0,0x00010000) + +#else /* F3DEX_GBI_2 */ +#define gSPForceMatrix(pkt, mptr) \ +{ \ + gDma1p(pkt, G_MOVEMEM, mptr, 16, G_MV_MATRIX_1); \ + gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2); \ + gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3); \ + gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4); \ +} +#define gsSPForceMatrix(mptr) \ + gsDma1p( G_MOVEMEM, mptr, 16, G_MV_MATRIX_1), \ + gsDma1p( G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2), \ + gsDma1p( G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3), \ + gsDma1p( G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4) +#endif /* F3DEX_GBI_2 */ + +/* + * Insert values into Points + * + * point = point number 0-15 + * where = which element of point to modify (byte offset into point) + * num = new value (32 bit) + */ +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +# define gSPModifyVertex(pkt, vtx, where, val) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(G_MODIFYVTX,24,8)| \ + _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16)); \ + _g->words.w1 = (unsigned int)(val); \ +} +# define gsSPModifyVertex(vtx, where, val) \ +{ \ + _SHIFTL(G_MODIFYVTX,24,8)| \ + _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16), \ + (unsigned int)(val) \ +} +#else +# define gSPModifyVertex(pkt, vtx, where, val) \ + gMoveWd(pkt, G_MW_POINTS, (vtx)*40+(where), val) +# define gsSPModifyVertex(vtx, where, val) \ + gsMoveWd(G_MW_POINTS, (vtx)*40+(where), val) +#endif + +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) +/* + * gSPBranchLessZ Branch DL if (vtx.z) less than or equal (zval). + * + * dl = DL branch to + * vtx = Vertex + * zval = Screen depth + * near = Near plane + * far = Far plane + * flag = G_BZ_PERSP or G_BZ_ORTHO + */ + +#define G_BZ_PERSP 0 +#define G_BZ_ORTHO 1 + +#define G_DEPTOZSrg(zval, near, far, flag, zmin, zmax) \ +(((unsigned int)FTOFIX32(((flag) == G_BZ_PERSP ? \ + (1.0f-(float)(near)/(float)(zval)) / \ + (1.0f-(float)(near)/(float)(far )) : \ + ((float)(zval) - (float)(near)) / \ + ((float)(far ) - (float)(near))))) * \ + (((int)((zmax) - (zmin)))&~1) + (int)FTOFIX32(zmin)) + +#define G_DEPTOZS(zval, near, far, flag) \ + G_DEPTOZSrg(zval, near, far, flag, 0, G_MAXZ) + +#define gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, zmin, zmax) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ + _g->words.w1 = (unsigned int)(dl); \ + _g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(G_BRANCH_Z,24,8)| \ + _SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12)); \ + _g->words.w1 = G_DEPTOZSrg(zval, near, far, flag, zmin, zmax); \ +} + +#define gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, zmin, zmax) \ +{ _SHIFTL(G_RDPHALF_1,24,8), \ + (unsigned int)(dl), }, \ +{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ + G_DEPTOZSrg(zval, near, far, flag, zmin, zmax), } + +#define gSPBranchLessZ(pkt, dl, vtx, zval, near, far, flag) \ + gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, 0, G_MAXZ) +#define gsSPBranchLessZ(dl, vtx, zval, near, far, flag) \ + gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, 0, G_MAXZ) + +/* + * gSPBranchLessZraw Branch DL if (vtx.z) less than or equal (raw zval). + * + * dl = DL branch to + * vtx = Vertex + * zval = Raw value of screen depth + */ +#define gSPBranchLessZraw(pkt, dl, vtx, zval) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ + _g->words.w1 = (unsigned int)(dl); \ + _g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(G_BRANCH_Z,24,8)| \ + _SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12)); \ + _g->words.w1 = (unsigned int)(zval); \ +} + +#define gsSPBranchLessZraw(dl, vtx, zval) \ +{ _SHIFTL(G_RDPHALF_1,24,8), \ + (unsigned int)(dl), }, \ +{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ + (unsigned int)(zval), } + +/* + * gSPLoadUcode RSP loads specified ucode. + * + * uc_start = ucode text section start + * uc_dstart = ucode data section start + */ +#define gSPLoadUcodeEx(pkt, uc_start, uc_dstart, uc_dsize) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ + _g->words.w1 = (unsigned int)(uc_dstart); \ + _g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(G_LOAD_UCODE,24,8)| \ + _SHIFTL((int)(uc_dsize)-1,0,16)); \ + _g->words.w1 = (unsigned int)(uc_start); \ +} + +#define gsSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize) \ +{ _SHIFTL(G_RDPHALF_1,24,8), \ + (unsigned int)(uc_dstart), }, \ +{ _SHIFTL(G_LOAD_UCODE,24,8)| \ + _SHIFTL((int)(uc_dsize)-1,0,16), \ + (unsigned int)(uc_start), } + +#define gSPLoadUcode(pkt, uc_start, uc_dstart) \ + gSPLoadUcodeEx((pkt), (uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) +#define gsSPLoadUcode(uc_start, uc_dstart) \ + gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) + +#define gSPLoadUcodeL(pkt, ucode) \ + gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&##ucode##DataStart)) +#define gsSPLoadUcodeL(ucode) \ + gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&##ucode##DataStart)) +#endif + +/* + * Lighting Macros + */ +#ifdef F3DEX_GBI_2x +# define NUML(n) ((n)*24) +#else +# define NUML(n) (((n)+1)*32 + 0x80000000) +#endif +#define NUMLIGHTS_0 1 +#define NUMLIGHTS_1 1 +#define NUMLIGHTS_2 2 +#define NUMLIGHTS_3 3 +#define NUMLIGHTS_4 4 +#define NUMLIGHTS_5 5 +#define NUMLIGHTS_6 6 +#define NUMLIGHTS_7 7 +/* + * n should be one of: NUMLIGHTS_0, NUMLIGHTS_1, ..., NUMLIGHTS_7 + * NOTE: in addition to the number of directional lights specified, + * there is always 1 ambient light + */ +#define gSPNumLights(pkt, n) \ + gMoveWd(pkt, G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) +#define gsSPNumLights(n) \ + gsMoveWd( G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) + +#define LIGHT_1 1 +#define LIGHT_2 2 +#define LIGHT_3 3 +#define LIGHT_4 4 +#define LIGHT_5 5 +#define LIGHT_6 6 +#define LIGHT_7 7 +#define LIGHT_8 8 +/* + * l should point to a Light struct + * n should be one of: LIGHT_1, LIGHT_2, ..., LIGHT_8 + * NOTE: the highest numbered light is always the ambient light (eg if there are + * 3 directional lights defined: gsSPNumLights(NUMLIGHTS_3), then lights + * LIGHT_1 through LIGHT_3 will be the directional lights and light + * LIGHT_4 will be the ambient light. + */ +#ifdef F3DEX_GBI_2x +# define gSPLight(pkt, l, n) \ + gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*3+3) +# define gsSPLight(l, n) \ + gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*3+3) +#else /* F3DEX_GBI_2 */ +# define gSPLight(pkt, l, n) \ + gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) +# define gsSPLight(l, n) \ + gsDma1p( G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) +#endif /* F3DEX_GBI_2 */ + +/* + * gSPLightColor changes color of light without recalculating light direction + * col is a 32 bit word with r,g,b,a (alpha is ignored) + * n should be one of LIGHT_1, LIGHT_2, ..., LIGHT_8 + */ +#define gSPLightColor(pkt, n, col) \ +{ \ + gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_a##n, col); \ + gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_b##n, col); \ +} +#define gsSPLightColor(n, col) \ + gsMoveWd(G_MW_LIGHTCOL, G_MWO_a##n, col), \ + gsMoveWd(G_MW_LIGHTCOL, G_MWO_b##n, col) + +/* These macros use a structure "name" which is init'd with the gdSPDefLights macros*/ + +#define gSPSetLights0(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_0); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.a,2); \ +} +#define gsSPSetLights0(name) \ + gsSPNumLights(NUMLIGHTS_0), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.a,2) + +#define gSPSetLights1(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_1); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.a,2); \ +} +#define gsSPSetLights1(name) \ + gsSPNumLights(NUMLIGHTS_1), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.a,2) + +#define gSPSetLights2(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_2); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.l[1],2); \ + gSPLight(pkt,&name.a,3); \ +} +#define gsSPSetLights2(name) \ + gsSPNumLights(NUMLIGHTS_2), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.l[1],2), \ + gsSPLight(&name.a,3) + +#define gSPSetLights3(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_3); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.l[1],2); \ + gSPLight(pkt,&name.l[2],3); \ + gSPLight(pkt,&name.a,4); \ +} +#define gsSPSetLights3(name) \ + gsSPNumLights(NUMLIGHTS_3), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.l[1],2), \ + gsSPLight(&name.l[2],3), \ + gsSPLight(&name.a,4) + +#define gSPSetLights4(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_4); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.l[1],2); \ + gSPLight(pkt,&name.l[2],3); \ + gSPLight(pkt,&name.l[3],4); \ + gSPLight(pkt,&name.a,5); \ +} +#define gsSPSetLights4(name) \ + gsSPNumLights(NUMLIGHTS_4), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.l[1],2), \ + gsSPLight(&name.l[2],3), \ + gsSPLight(&name.l[3],4), \ + gsSPLight(&name.a,5) + +#define gSPSetLights5(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_5); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.l[1],2); \ + gSPLight(pkt,&name.l[2],3); \ + gSPLight(pkt,&name.l[3],4); \ + gSPLight(pkt,&name.l[4],5); \ + gSPLight(pkt,&name.a,6); \ +} + +#define gsSPSetLights5(name) \ + gsSPNumLights(NUMLIGHTS_5), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.l[1],2), \ + gsSPLight(&name.l[2],3), \ + gsSPLight(&name.l[3],4), \ + gsSPLight(&name.l[4],5), \ + gsSPLight(&name.a,6) + +#define gSPSetLights6(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_6); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.l[1],2); \ + gSPLight(pkt,&name.l[2],3); \ + gSPLight(pkt,&name.l[3],4); \ + gSPLight(pkt,&name.l[4],5); \ + gSPLight(pkt,&name.l[5],6); \ + gSPLight(pkt,&name.a,7); \ +} + +#define gsSPSetLights6(name) \ + gsSPNumLights(NUMLIGHTS_6), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.l[1],2), \ + gsSPLight(&name.l[2],3), \ + gsSPLight(&name.l[3],4), \ + gsSPLight(&name.l[4],5), \ + gsSPLight(&name.l[5],6), \ + gsSPLight(&name.a,7) + +#define gSPSetLights7(pkt,name) \ +{ \ + gSPNumLights(pkt,NUMLIGHTS_7); \ + gSPLight(pkt,&name.l[0],1); \ + gSPLight(pkt,&name.l[1],2); \ + gSPLight(pkt,&name.l[2],3); \ + gSPLight(pkt,&name.l[3],4); \ + gSPLight(pkt,&name.l[4],5); \ + gSPLight(pkt,&name.l[5],6); \ + gSPLight(pkt,&name.l[6],7); \ + gSPLight(pkt,&name.a,8); \ +} + +#define gsSPSetLights7(name) \ + gsSPNumLights(NUMLIGHTS_7), \ + gsSPLight(&name.l[0],1), \ + gsSPLight(&name.l[1],2), \ + gsSPLight(&name.l[2],3), \ + gsSPLight(&name.l[3],4), \ + gsSPLight(&name.l[4],5), \ + gsSPLight(&name.l[5],6), \ + gsSPLight(&name.l[6],7), \ + gsSPLight(&name.a,8) + +/* + * Reflection/Hiliting Macros + */ +#ifdef F3DEX_GBI_2 +# define gSPLookAtX(pkt, l) \ + gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATX,0) +# define gsSPLookAtX(l) \ + gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATX,0) +# define gSPLookAtY(pkt, l) \ + gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATY,0) +# define gsSPLookAtY(l) \ + gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATY,0) +#else /* F3DEX_GBI_2 */ +# define gSPLookAtX(pkt, l) \ + gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) +# define gsSPLookAtX(l) \ + gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) +# define gSPLookAtY(pkt, l) \ + gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) +# define gsSPLookAtY(l) \ + gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) +#endif /* F3DEX_GBI_2 */ + +#define gSPLookAt(pkt, la) \ +{ \ + gSPLookAtX(pkt,la) \ + gSPLookAtY(pkt,(char *)(la)+16) \ +} +#define gsSPLookAt(la) \ + gsSPLookAtX(la), \ + gsSPLookAtY((char *)(la)+16) + +#define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \ + gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ + ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) +#define gsDPSetHilite1Tile(tile, hilite, width, height) \ + gsDPSetTileSize(tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ + ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) + +#define gDPSetHilite2Tile(pkt, tile, hilite, width, height) \ + gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ + ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) +#define gsDPSetHilite2Tile(tile, hilite, width, height) \ + gsDPSetTileSize(tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ + ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) + +/* + * FOG macros + * fm = z multiplier + * fo = z offset + * FOG FORMULA: alpha(fog) = (eyespace z) * fm + fo CLAMPED 0 to 255 + * note: (eyespace z) ranges -1 to 1 + * + * Alternate method of setting fog: + * min, max: range 0 to 1000: 0=nearplane, 1000=farplane + * min is where fog begins (usually less than max and often 0) + * max is where fog is thickest (usually 1000) + * + */ +#define gSPFogFactor(pkt, fm, fo) \ + gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ + (_SHIFTL(fm,16,16) | _SHIFTL(fo,0,16))) + +#define gsSPFogFactor(fm, fo) \ + gsMoveWd(G_MW_FOG, G_MWO_FOG, \ + (_SHIFTL(fm,16,16) | _SHIFTL(fo,0,16))) + +#define gSPFogPosition(pkt, min, max) \ + gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ + (_SHIFTL((128000/((max)-(min))),16,16) | \ + _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) + +#define gsSPFogPosition(min, max) \ + gsMoveWd(G_MW_FOG, G_MWO_FOG, \ + (_SHIFTL((128000/((max)-(min))),16,16) | \ + _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) + +/* + * Macros to turn texture on/off + */ +#define gSPTexture(pkt, s, t, level, tile, on) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | \ + _SHIFTL(BOWTIE_VAL, 16, 8) | \ + _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | \ + _SHIFTL(on, 0, 8)); \ + _g->words.w1 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ +} + +#define gsSPTexture(s, t, level, tile, on) \ +{ \ + (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(BOWTIE_VAL, 16, 8) | \ + _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | _SHIFTL(on, 0, 8)),\ + (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)) \ +} + +/* + * Different version of SPTexture macro, has an additional parameter + * which is currently reserved in the microcode. + */ +#define gSPTextureL(pkt, s, t, level, xparam, tile, on) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | \ + _SHIFTL(xparam, 16, 8) | \ + _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | \ + _SHIFTL(on, 0, 8)); \ + _g->words.w1 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ +} + +#define gsSPTextureL(s, t, level, xparam, tile, on) \ +{ \ + (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(xparam, 16, 8) | \ + _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | _SHIFTL(on, 0, 8)),\ + (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)) \ +} + + +#define gSPPerspNormalize(pkt, s) \ + gMoveWd(pkt, G_MW_PERSPNORM, 0, (s)) +#define gsSPPerspNormalize(s) \ + gsMoveWd( G_MW_PERSPNORM, 0, (s)) + +#ifdef F3DEX_GBI_2x +# define gSPPopMatrixN(pkt, n, num) gDma2p((pkt),G_POPMTX,(num)*64,64,2,0) +# define gsSPPopMatrixN(n, num) gsDma2p( G_POPMTX,(num)*64,64,2,0) +# define gSPPopMatrix(pkt, n) gSPPopMatrixN((pkt), (n), 1) +# define gsSPPopMatrix(n) gsSPPopMatrixN( (n), 1) +#else /* F3DEX_GBI_2 */ +# define gSPPopMatrix(pkt, n) gImmp1(pkt, G_POPMTX, n) +# define gsSPPopMatrix(n) gsImmp1( G_POPMTX, n) +#endif /* F3DEX_GBI_2 */ + +#define gSPEndDisplayList(pkt) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_ENDDL, 24, 8); \ + _g->words.w1 = 0; \ +} + +#define gsSPEndDisplayList() \ +{ \ + _SHIFTL(G_ENDDL, 24, 8), 0 \ +} + +#ifdef F3DEX_GBI_2x +/* + * One gSPGeometryMode(pkt,c,s) GBI is equal to these two GBIs. + * + * gSPClearGeometryMode(pkt,c) + * gSPSetGeometryMode(pkt,s) + * + * gSPLoadGeometryMode(pkt, word) sets GeometryMode directly. + */ +#define gSPGeometryMode(pkt, c, s) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24);\ + _g->words.w1 = (u32)(s); \ +} + +#define gsSPGeometryMode(c, s) \ +{ \ + (_SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24)),(u32)(s) \ +} +#define gSPSetGeometryMode(pkt, word) gSPGeometryMode((pkt),0,(word)) +#define gsSPSetGeometryMode(word) gsSPGeometryMode(0,(word)) +#define gSPClearGeometryMode(pkt, word) gSPGeometryMode((pkt),(word),0) +#define gsSPClearGeometryMode(word) gsSPGeometryMode((word),0) +#define gSPLoadGeometryMode(pkt, word) gSPGeometryMode((pkt),-1,(word)) +#define gsSPLoadGeometryMode(pkt, word) gsSPGeometryMode(-1,(word)) + +#else /* F3DEX_GBI_2 */ +#define gSPSetGeometryMode(pkt, word) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_SETGEOMETRYMODE, 24, 8); \ + _g->words.w1 = (unsigned int)(word); \ +} + +#define gsSPSetGeometryMode(word) \ +{ \ + _SHIFTL(G_SETGEOMETRYMODE, 24, 8), (unsigned int)(word) \ +} + +#define gSPClearGeometryMode(pkt, word) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8); \ + _g->words.w1 = (unsigned int)(word); \ +} + +#define gsSPClearGeometryMode(word) \ +{ \ + _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8), (unsigned int)(word) \ +} +#endif /* F3DEX_GBI_2 */ + +#ifdef F3DEX_GBI_2x +#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)| \ + _SHIFTL((len)-1,0,8)); \ + _g->words.w1 = (unsigned int)(data); \ +} + +#define gsSPSetOtherMode(cmd, sft, len, data) \ +{ \ + _SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)|_SHIFTL((len)-1,0,8), \ + (unsigned int)(data) \ +} +#else +#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | \ + _SHIFTL(len, 0, 8)); \ + _g->words.w1 = (unsigned int)(data); \ +} + +#define gsSPSetOtherMode(cmd, sft, len, data) \ +{ \ + _SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8), \ + (unsigned int)(data) \ +} +#endif + +/* + * RDP setothermode register commands - register shadowed in RSP + */ +#define gDPPipelineMode(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode) +#define gsDPPipelineMode(mode) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode) + +#define gDPSetCycleType(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type) +#define gsDPSetCycleType(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type) + +#define gDPSetTexturePersp(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type) +#define gsDPSetTexturePersp(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type) + +#define gDPSetTextureDetail(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type) +#define gsDPSetTextureDetail(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type) + +#define gDPSetTextureLOD(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type) +#define gsDPSetTextureLOD(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type) + +#define gDPSetTextureLUT(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type) +#define gsDPSetTextureLUT(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type) + +#define gDPSetTextureFilter(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type) +#define gsDPSetTextureFilter(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type) + +#define gDPSetTextureConvert(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type) +#define gsDPSetTextureConvert(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type) + +#define gDPSetCombineKey(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type) +#define gsDPSetCombineKey(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type) + +#ifndef _HW_VERSION_1 +#define gDPSetColorDither(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode) +#define gsDPSetColorDither(mode) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode) +#else +#define gDPSetColorDither(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode) +#define gsDPSetColorDither(mode) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode) +#endif + +#ifndef _HW_VERSION_1 +#define gDPSetAlphaDither(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) +#define gsDPSetAlphaDither(mode) \ + gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) +#endif + +/* 'blendmask' is not supported anymore. + * The bits are reserved for future use. + * Fri May 26 13:45:55 PDT 1995 + */ +#define gDPSetBlendMask(pkt, mask) gDPNoOp(pkt) +#define gsDPSetBlendMask(mask) gsDPNoOp() + +#define gDPSetAlphaCompare(pkt, type) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type) +#define gsDPSetAlphaCompare(type) \ + gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type) + +#define gDPSetDepthSource(pkt, src) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src) +#define gsDPSetDepthSource(src) \ + gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src) + +#define gDPSetRenderMode(pkt, c0, c1) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \ + (c0) | (c1)) +#define gsDPSetRenderMode(c0, c1) \ + gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \ + (c0) | (c1)) + +#define gSetImage(pkt, cmd, fmt, siz, width, i) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ + _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12); \ + _g->words.w1 = (unsigned int)(i); \ +} + +#define gsSetImage(cmd, fmt, siz, width, i) \ +{ \ + _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ + _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12), \ + (unsigned int)(i) \ +} + +#define gDPSetColorImage(pkt, f, s, w, i) gSetImage(pkt, G_SETCIMG, f, s, w, i) +#define gsDPSetColorImage(f, s, w, i) gsSetImage(G_SETCIMG, f, s, w, i) + + +/* use these for new code */ +#define gDPSetDepthImage(pkt, i) gSetImage(pkt, G_SETZIMG, 0, 0, 1, i) +#define gsDPSetDepthImage(i) gsSetImage(G_SETZIMG, 0, 0, 1, i) +/* kept for compatibility */ +#define gDPSetMaskImage(pkt, i) gDPSetDepthImage(pkt, i) +#define gsDPSetMaskImage(i) gsDPSetDepthImage(i) + +#define gDPSetTextureImage(pkt, f, s, w, i) gSetImage(pkt, G_SETTIMG, f, s, w, i) +#define gsDPSetTextureImage(f, s, w, i) gsSetImage(G_SETTIMG, f, s, w, i) + +/* + * RDP macros + */ + +#define gDPSetCombine(pkt, muxs0, muxs1) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24);\ + _g->words.w1 = (unsigned int)(muxs1); \ +} + +#define gsDPSetCombine(muxs0, muxs1) \ +{ \ + _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24), \ + (unsigned int)(muxs1) \ +} + +#define GCCc0w0(saRGB0, mRGB0, saA0, mA0) \ + (_SHIFTL((saRGB0), 20, 4) | _SHIFTL((mRGB0), 15, 5) | \ + _SHIFTL((saA0), 12, 3) | _SHIFTL((mA0), 9, 3)) + +#define GCCc1w0(saRGB1, mRGB1) \ + (_SHIFTL((saRGB1), 5, 4) | _SHIFTL((mRGB1), 0, 5)) + +#define GCCc0w1(sbRGB0, aRGB0, sbA0, aA0) \ + (_SHIFTL((sbRGB0), 28, 4) | _SHIFTL((aRGB0), 15, 3) | \ + _SHIFTL((sbA0), 12, 3) | _SHIFTL((aA0), 9, 3)) + +#define GCCc1w1(sbRGB1, saA1, mA1, aRGB1, sbA1, aA1) \ + (_SHIFTL((sbRGB1), 24, 4) | _SHIFTL((saA1), 21, 3) | \ + _SHIFTL((mA1), 18, 3) | _SHIFTL((aRGB1), 6, 3) | \ + _SHIFTL((sbA1), 3, 3) | _SHIFTL((aA1), 0, 3)) + +#define gDPSetCombineLERP(pkt, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ + a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | \ + _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ + G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ + GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), \ + 0, 24); \ + _g->words.w1 = (unsigned int)(GCCc0w1(G_CCMUX_##b0, \ + G_CCMUX_##d0, \ + G_ACMUX_##Ab0, \ + G_ACMUX_##Ad0) | \ + GCCc1w1(G_CCMUX_##b1, \ + G_ACMUX_##Aa1, \ + G_ACMUX_##Ac1, \ + G_CCMUX_##d1, \ + G_ACMUX_##Ab1, \ + G_ACMUX_##Ad1)); \ +} + +#define gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ + a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ +{ \ + _SHIFTL(G_SETCOMBINE, 24, 8) | \ + _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ + G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ + GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), 0, 24), \ + (unsigned int)(GCCc0w1(G_CCMUX_##b0, G_CCMUX_##d0, \ + G_ACMUX_##Ab0, G_ACMUX_##Ad0) | \ + GCCc1w1(G_CCMUX_##b1, G_ACMUX_##Aa1, \ + G_ACMUX_##Ac1, G_CCMUX_##d1, \ + G_ACMUX_##Ab1, G_ACMUX_##Ad1)) \ +} + +/* + * SetCombineMode macros are NOT redunant. It allow the C preprocessor + * to substitute single parameter which includes commas in the token and + * rescan for higher parameter count macro substitution. + * + * eg. gsDPSetCombineMode(G_CC_MODULATE, G_CC_MODULATE) turns into + * gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0, + * TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0) + */ + +#define gDPSetCombineMode(pkt, a, b) gDPSetCombineLERP(pkt, a, b) +#define gsDPSetCombineMode(a, b) gsDPSetCombineLERP(a, b) + +#define gDPSetColor(pkt, c, d) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(c, 24, 8); \ + _g->words.w1 = (unsigned int)(d); \ +} + +#define gsDPSetColor(c, d) \ +{ \ + _SHIFTL(c, 24, 8), (unsigned int)(d) \ +} + +#define DPRGBColor(pkt, cmd, r, g, b, a) \ + gDPSetColor(pkt, cmd, \ + (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ + _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) +#define sDPRGBColor(cmd, r, g, b, a) \ + gsDPSetColor(cmd, \ + (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ + _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) + +#define gDPSetEnvColor(pkt, r, g, b, a) \ + DPRGBColor(pkt, G_SETENVCOLOR, r,g,b,a) +#define gsDPSetEnvColor(r, g, b, a) \ + sDPRGBColor(G_SETENVCOLOR, r,g,b,a) +#define gDPSetBlendColor(pkt, r, g, b, a) \ + DPRGBColor(pkt, G_SETBLENDCOLOR, r,g,b,a) +#define gsDPSetBlendColor(r, g, b, a) \ + sDPRGBColor(G_SETBLENDCOLOR, r,g,b,a) +#define gDPSetFogColor(pkt, r, g, b, a) \ + DPRGBColor(pkt, G_SETFOGCOLOR, r,g,b,a) +#define gsDPSetFogColor(r, g, b, a) \ + sDPRGBColor(G_SETFOGCOLOR, r,g,b,a) +#define gDPSetFillColor(pkt, d) \ + gDPSetColor(pkt, G_SETFILLCOLOR, (d)) +#define gsDPSetFillColor(d) \ + gsDPSetColor(G_SETFILLCOLOR, (d)) + +#define gDPSetPrimDepth(pkt, z, dz) \ + gDPSetColor(pkt, G_SETPRIMDEPTH, \ + _SHIFTL(z, 16, 16) | _SHIFTL(dz, 0, 16)) +#define gsDPSetPrimDepth(z, dz) \ + gsDPSetColor(G_SETPRIMDEPTH, _SHIFTL(z, 16, 16) | \ + _SHIFTL(dz, 0, 16)) + +#define gDPSetPrimColor(pkt, m, l, r, g, b, a) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | \ + _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \ + _g->words.w1 = (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ + _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)); \ +} + +#define gsDPSetPrimColor(m, l, r, g, b, a) \ +{ \ + (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | \ + _SHIFTL(l, 0, 8)), \ + (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | \ + _SHIFTL(a, 0, 8)) \ +} + +/* + * gDPSetOtherMode (This is for expert user.) + * + * This command makes all othermode parameters set. + * Do not use this command in the same DL with another g*SPSetOtherMode DLs. + * + * [Usage] + * gDPSetOtherMode(pkt, modeA, modeB) + * + * 'modeA' is described all parameters of GroupA GBI command. + * 'modeB' is also described all parameters of GroupB GBI command. + * + * GroupA: + * gDPPipelineMode, gDPSetCycleType, gSPSetTexturePersp, + * gDPSetTextureDetail, gDPSetTextureLOD, gDPSetTextureLUT, + * gDPSetTextureFilter, gDPSetTextureConvert, gDPSetCombineKey, + * gDPSetColorDither, gDPSetAlphaDither + * + * GroupB: + * gDPSetAlphaCompare, gDPSetDepthSource, gDPSetRenderMode + * + * Use 'OR' operation to get modeA and modeB. + * + * modeA = G_PM_* | G_CYC_* | G_TP_* | G_TD_* | G_TL_* | G_TT_* | G_TF_* + * G_TC_* | G_CK_* | G_CD_* | G_AD_*; + * + * modeB = G_AC_* | G_ZS_* | G_RM_* | G_RM_*2; + */ +#define gDPSetOtherMode(pkt, mode0, mode1) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24);\ + _g->words.w1 = (unsigned int)(mode1); \ +} + +#define gsDPSetOtherMode(mode0, mode1) \ +{ \ + _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24), \ + (unsigned int)(mode1) \ +} + +/* + * Texturing macros + */ + +/* These are also defined defined above for Sprite Microcode */ + +#define G_TX_LOADTILE 7 +#define G_TX_RENDERTILE 0 + +#define G_TX_NOMIRROR 0 +#define G_TX_WRAP 0 +#define G_TX_MIRROR 0x1 +#define G_TX_CLAMP 0x2 +#define G_TX_NOMASK 0 +#define G_TX_NOLOD 0 + + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +/* + * Dxt is the inverse of the number of 64-bit words in a line of + * the texture being loaded using the load_block command. If + * there are any 1's to the right of the 11th fractional bit, + * dxt should be rounded up. The following macros accomplish + * this. The 4b macros are a special case since 4-bit textures + * are loaded as 8-bit textures. Dxt is fixed point 1.11. RJM + */ +#define G_TX_DXT_FRAC 11 + +/* + * For RCP 2.0, the maximum number of texels that can be loaded + * using a load_block command is 2048. In order to load the total + * 4kB of Tmem, change the texel size when loading to be G_IM_SIZ_16b, + * then change the tile to the proper texel size after the load. + * The g*DPLoadTextureBlock macros already do this, so this change + * will be transparent if you use these macros. If you use + * the g*DPLoadBlock macros directly, you will need to handle this + * tile manipulation yourself. RJM. + */ +#ifdef _HW_VERSION_1 +#define G_TX_LDBLK_MAX_TXL 4095 +#else +#define G_TX_LDBLK_MAX_TXL 2047 +#endif /* _HW_VERSION_1 */ + +#define TXL2WORDS(txls, b_txl) MAX(1, ((txls)*(b_txl)/8)) +#define CALC_DXT(width, b_txl) \ + (((1 << G_TX_DXT_FRAC) + TXL2WORDS(width, b_txl) - 1) / \ + TXL2WORDS(width, b_txl)) + +#define TXL2WORDS_4b(txls) MAX(1, ((txls)/16)) +#define CALC_DXT_4b(width) \ + (((1 << G_TX_DXT_FRAC) + TXL2WORDS_4b(width) - 1) / \ + TXL2WORDS_4b(width)) + +#define gDPLoadTileGeneric(pkt, c, tile, uls, ult, lrs, lrt) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | \ + _SHIFTL(ult, 0, 12); \ + _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | \ + _SHIFTL(lrt, 0, 12); \ +} + +#define gsDPLoadTileGeneric(c, tile, uls, ult, lrs, lrt) \ +{ \ + _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12), \ + _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | _SHIFTL(lrt, 0, 12)\ +} + +#define gDPSetTileSize(pkt, t, uls, ult, lrs, lrt) \ + gDPLoadTileGeneric(pkt, G_SETTILESIZE, t, uls, ult, lrs, lrt) +#define gsDPSetTileSize(t, uls, ult, lrs, lrt) \ + gsDPLoadTileGeneric(G_SETTILESIZE, t, uls, ult, lrs, lrt) +#define gDPLoadTile(pkt, t, uls, ult, lrs, lrt) \ + gDPLoadTileGeneric(pkt, G_LOADTILE, t, uls, ult, lrs, lrt) +#define gsDPLoadTile(t, uls, ult, lrs, lrt) \ + gsDPLoadTileGeneric(G_LOADTILE, t, uls, ult, lrs, lrt) + +#define gDPSetTile(pkt, fmt, siz, line, tmem, tile, palette, cmt, \ + maskt, shiftt, cms, masks, shifts) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) |\ + _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | \ + _SHIFTL(tmem, 0, 9); \ + _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ + _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ + _SHIFTL(shiftt, 10, 4) |_SHIFTL(cms, 8, 2) | \ + _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4); \ +} + +#define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, \ + maskt, shiftt, cms, masks, shifts) \ +{ \ + (_SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) | \ + _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | _SHIFTL(tmem, 0, 9)),\ + (_SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ + _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ + _SHIFTL(shiftt, 10, 4) | _SHIFTL(cms, 8, 2) | \ + _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4)) \ +} + +/* + * For RCP 2.0, the maximum number of texels that can be loaded + * using a load_block command is 2048. In order to load the total + * 4kB of Tmem, change the texel size when loading to be G_IM_SIZ_16b, + * then change the tile to the proper texel size after the load. + * The g*DPLoadTextureBlock macros already do this, so this change + * will be transparent if you use these macros. If you use + * the g*DPLoadBlock macros directly, you will need to handle this + * tile manipulation yourself. RJM. + */ +#define gDPLoadBlock(pkt, tile, uls, ult, lrs, dxt) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_LOADBLOCK, 24, 8) | \ + _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | \ + _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) |\ + _SHIFTL(dxt, 0, 12)); \ +} + +#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \ +{ \ + (_SHIFTL(G_LOADBLOCK, 24, 8) | _SHIFTL(uls, 12, 12) | \ + _SHIFTL(ult, 0, 12)), \ + (_SHIFTL(tile, 24, 3) | \ + _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) | \ + _SHIFTL(dxt, 0, 12)) \ +} + +#define gDPLoadTLUTCmd(pkt, tile, count) \ +{ \ + Gfx *_g = (Gfx *)pkt; \ + \ + _g->words.w0 = _SHIFTL(G_LOADTLUT, 24, 8); \ + _g->words.w1 = _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10);\ +} + +#define gsDPLoadTLUTCmd(tile, count) \ +{ \ + _SHIFTL(G_LOADTLUT, 24, 8), \ + _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10) \ +} + +#define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, \ + CALC_DXT(width, siz##_BYTES)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((width) * siz##_LINE_BYTES)+7)>>3, 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +#define gDPLoadTextureBlockYuv(pkt, timg, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, \ + CALC_DXT(width, siz##_BYTES)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((width) * 1)+7)>>3, 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* Load fix rww 27jun95 */ +/* The S at the end means odd lines are already word Swapped */ + +#define gDPLoadTextureBlockS(pkt, timg, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((width) * siz##_LINE_BYTES)+7)>>3, 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* + * Allow tmem address and render tile to be specified. + * The S at the end means odd lines are already word Swapped + */ +#define gDPLoadMultiBlockS(pkt, timg, tmem, rtile, fmt, siz, width, \ + height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((width) * siz##_LINE_BYTES)+7)>>3, tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + + +#define gDPLoadTextureBlockYuvS(pkt, timg, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, \ + (((width) * 1)+7)>>3, 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* + * allows tmem address to be specified + */ +#define _gDPLoadTextureBlock(pkt, timg, tmem, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ + 0, cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ + tmem, G_TX_RENDERTILE, pal, cmt, \ + maskt, shiftt, cms, masks, shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* + * allows tmem address and render tile to be specified + */ +#define _gDPLoadTextureBlockTile(pkt, timg, tmem, rtile, fmt, siz, width, \ + height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ + tmem, rtile, pal, cmt, \ + maskt, shiftt, cms, masks, shifts); \ + gDPSetTileSize(pkt, rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* + * allows tmem address and render tile to be specified + */ +#define gDPLoadMultiBlock(pkt, timg, tmem, rtile, fmt, siz, width, \ + height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ + gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ + tmem, rtile, pal, cmt, \ + maskt, shiftt, cms, masks, shifts); \ + gDPSetTileSize(pkt, rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +#define gsDPLoadTextureBlock(timg, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ + gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ + masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + +/* Here is the static form of the pre-swapped texture block loading */ +/* See gDPLoadTextureBlockS() for reference. Basically, just don't + calculate DxT, use 0 */ + +#define gsDPLoadTextureBlockS(timg, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ + gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0 , \ + cmt, maskt,shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, 0 ),\ + gsDPPipeSync(), \ + gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + +/* + * Allow tmem address to be specified + */ +#define _gsDPLoadTextureBlock(timg, tmem, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ + gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, siz, \ + ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + + +/* + * Allow tmem address and render_tile to be specified + */ +#define _gsDPLoadTextureBlockTile(timg, tmem, rtile, fmt, siz, width, \ + height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ + gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, siz, \ + ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + + +/* + * Allow tmem address and render_tile to be specified, useful when loading + * mutilple tiles at a time. + */ +#define gsDPLoadMultiBlock(timg, tmem, rtile, fmt, siz, width, \ + height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ + gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ + 0 , cmt, maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ + CALC_DXT(width, siz##_BYTES)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, siz, \ + ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + +/* + * Allows tmem and render tile to be specified. Useful when loading + * several tiles at a time. + * + * Here is the static form of the pre-swapped texture block loading + * See gDPLoadTextureBlockS() for reference. Basically, just don't + * calculate DxT, use 0 + */ + +#define gsDPLoadMultiBlockS(timg, tmem, rtile, fmt, siz, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ + gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0 , \ + cmt, maskt,shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ + (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, 0 ),\ + gsDPPipeSync(), \ + gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), tmem,\ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + + +#define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height)+3)>>2)-1, \ + CALC_DXT_4b(width)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* Load fix rww 27jun95 */ +/* The S at the end means odd lines are already word Swapped */ + +#define gDPLoadTextureBlock_4bS(pkt, timg, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height)+3)>>2)-1, 0 ); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* + * 4-bit load block. Useful when loading multiple tiles + */ +#define gDPLoadMultiBlock_4b(pkt, timg, tmem, rtile, fmt, width, height,\ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height)+3)>>2)-1, \ + CALC_DXT_4b(width)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +/* + * 4-bit load block. Allows tmem and render tile to be specified. Useful when + * loading multiple tiles. The S means odd lines are already word swapped. + */ +#define gDPLoadMultiBlock_4bS(pkt, timg, tmem, rtile, fmt, width, height,\ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height)+3)>>2)-1, 0 ); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + + +#define _gDPLoadTextureBlock_4b(pkt, timg, tmem, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ + cmt, maskt, shiftt, cms, masks, shifts); \ + gDPLoadSync(pkt); \ + gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ + (((width)*(height)+3)>>2)-1, \ + CALC_DXT_4b(width)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ +} + +#define gsDPLoadTextureBlock_4b(timg, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ + gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0 , cmt, \ + maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ + CALC_DXT_4b(width)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + +#define gsDPLoadTextureBlock_4bS(timg, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ + gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0 , cmt, \ + maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1,0),\ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + +/* + * 4-bit load block. Allows tmem address and render tile to be specified. + * Useful when loading multiple tiles. + */ +#define gsDPLoadMultiBlock_4b(timg, tmem, rtile, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ + gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ + maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ + CALC_DXT_4b(width)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + + +/* + * 4-bit load block. Allows tmem address and render tile to be specified. + * Useful when loading multiple tiles. S means odd lines are already swapped. + */ +#define gsDPLoadMultiBlock_4bS(timg, tmem, rtile, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ + gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ + maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1,0),\ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + + +/* + * Allows tmem address to be specified + */ +#define _gsDPLoadTextureBlock_4b(timg, tmem, fmt, width, height, \ + pal, cms, cmt, masks, maskt, shifts, shiftt) \ + \ + gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ + gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ + maskt, shiftt, cms, masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ + CALC_DXT_4b(width)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ + ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC) + +#ifndef _HW_VERSION_1 + +#define gDPLoadTextureTile(pkt, timg, fmt, siz, width, height, \ + uls, ult, lrs, lrt, pal, \ + cms, cmt, masks, maskt, shifts, shiftt) \ +{ \ + gDPSetTextureImage(pkt, fmt, siz, width, timg); \ + gDPSetTile(pkt, fmt, siz, \ + (((((lrs)-(uls)+1) * siz##_TILE_BYTES)+7)>>3), 0, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPLoadSync(pkt); \ + gDPLoadTile( pkt, G_TX_LOADTILE, \ + (uls)<>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, \ + (uls)<>3), tmem, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPLoadSync(pkt); \ + gDPLoadTile( pkt, G_TX_LOADTILE, \ + (uls)<>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, rtile, \ + (uls)<>3), 0, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPLoadSync(), \ + gsDPLoadTile( G_TX_LOADTILE, \ + (uls)<>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks,\ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, \ + (uls)<>3), \ + tmem, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ + masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadTile( G_TX_LOADTILE, \ + (uls)<>3), \ + tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, \ + (uls)<>1), timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ + (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPLoadSync(pkt); \ + gDPLoadTile( pkt, G_TX_LOADTILE, \ + (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (ult)<<(G_TEXTURE_IMAGE_FRAC), \ + (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (lrt)<<(G_TEXTURE_IMAGE_FRAC)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \ + (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, \ + masks, shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, \ + (uls)<>1), timg); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ + (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPLoadSync(pkt); \ + gDPLoadTile( pkt, G_TX_LOADTILE, \ + (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (ult)<<(G_TEXTURE_IMAGE_FRAC), \ + (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (lrt)<<(G_TEXTURE_IMAGE_FRAC)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \ + (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ + rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, rtile, \ + (uls)<>1), timg), \ + gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ + G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPLoadSync(), \ + gsDPLoadTile( G_TX_LOADTILE, \ + (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (ult)<<(G_TEXTURE_IMAGE_FRAC), \ + (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (lrt)<<(G_TEXTURE_IMAGE_FRAC)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(G_TX_RENDERTILE, \ + (uls)<>1), timg), \ + gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs)-(uls)+1)>>1)+7)>>3), \ + tmem, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ + masks, shifts), \ + gsDPLoadSync(), \ + gsDPLoadTile( G_TX_LOADTILE, \ + (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (ult)<<(G_TEXTURE_IMAGE_FRAC), \ + (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ + (lrt)<<(G_TEXTURE_IMAGE_FRAC)), \ + gsDPPipeSync(), \ + gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs)-(uls)+1)>>1)+7)>>3), \ + tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \ + shifts), \ + gsDPSetTileSize(rtile, \ + (uls)<words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | \ + _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ + _SHIFTL((int)((float)(uly)*4.0F), 0, 12); \ + _g->words.w1 = _SHIFTL(mode, 24, 2) | \ + _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ + _SHIFTL((int)((float)(lry)*4.0F), 0, 12); \ +} + + +#define gDPSetScissorFrac(pkt, mode, ulx, uly, lrx, lry) \ +{ \ + Gfx *_g = (Gfx *)pkt; \ + \ + _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | \ + _SHIFTL((int)((ulx)), 12, 12) | \ + _SHIFTL((int)((uly)), 0, 12); \ + _g->words.w1 = _SHIFTL(mode, 24, 2) | \ + _SHIFTL((int)((lrx)), 12, 12) | \ + _SHIFTL((int)((lry)), 0, 12); \ +} + +#define gsDPSetScissor(mode, ulx, uly, lrx, lry) \ +{ \ + _SHIFTL(G_SETSCISSOR, 24, 8) | \ + _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ + _SHIFTL((int)((float)(uly)*4.0F), 0, 12), \ + _SHIFTL(mode, 24, 2) | \ + _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ + _SHIFTL((int)((float)(lry)*4.0F), 0, 12) \ +} + +#define gsDPSetScissorFrac(mode, ulx, uly, lrx, lry) \ +{ \ + _SHIFTL(G_SETSCISSOR, 24, 8) | \ + _SHIFTL((int)((ulx)), 12, 12) | \ + _SHIFTL((int)((uly)), 0, 12), \ + _SHIFTL(mode, 24, 2) | \ + _SHIFTL((int)(lrx), 12, 12) | \ + _SHIFTL((int)(lry), 0, 12) \ +} + +/* Fraction never used in fill */ +#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | \ + _SHIFTL((lrx), 14, 10) | _SHIFTL((lry), 2, 10));\ + _g->words.w1 = (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10));\ +} + +#define gsDPFillRectangle(ulx, uly, lrx, lry) \ +{ \ + (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | \ + _SHIFTL((lry), 2, 10)), \ + (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)) \ +} + +/* like gDPFillRectangle but accepts negative arguments */ +#define gDPScisFillRectangle(pkt, ulx, uly, lrx, lry) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | \ + _SHIFTL(MAX((lrx),0), 14, 10) | \ + _SHIFTL(MAX((lry),0), 2, 10)); \ + _g->words.w1 = (_SHIFTL(MAX((ulx),0), 14, 10) | \ + _SHIFTL(MAX((uly),0), 2, 10)); \ +} + +#define gDPSetConvert(pkt, k0, k1, k2, k3, k4, k5) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_SETCONVERT, 24, 8) | \ + _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | \ + _SHIFTR(k2, 5, 4)); \ + _g->words.w1 = (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | \ + _SHIFTL(k4, 9, 9) | _SHIFTL(k5, 0, 9)); \ +} + +#define gsDPSetConvert(k0, k1, k2, k3, k4, k5) \ +{ \ + (_SHIFTL(G_SETCONVERT, 24, 8) | \ + _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTL(k2, 5, 4)), \ + (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | _SHIFTL(k4, 9, 9) | \ + _SHIFTL(k5, 0, 9)) \ +} + +#define gDPSetKeyR(pkt, cR, sR, wR) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_SETKEYR, 24, 8); \ + _g->words.w1 = (_SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | \ + _SHIFTL(sR, 0, 8)); \ +} + +#define gsDPSetKeyR(cR, sR, wR) \ +{ \ + _SHIFTL(G_SETKEYR, 24, 8), \ + _SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | _SHIFTL(sR, 0, 8) \ +} + +#define gDPSetKeyGB(pkt, cG, sG, wG, cB, sB, wB) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_SETKEYGB, 24, 8) | \ + _SHIFTL(wG, 12, 12) | _SHIFTL(wB, 0, 12)); \ + _g->words.w1 = (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | \ + _SHIFTL(cB, 8, 8) | _SHIFTL(sB, 0, 8)); \ +} + +#define gsDPSetKeyGB(cG, sG, wG, cB, sB, wB) \ +{ \ + (_SHIFTL(G_SETKEYGB, 24, 8) | _SHIFTL(wG, 12, 12) | \ + _SHIFTL(wB, 0, 12)), \ + (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | _SHIFTL(cB, 8, 8) | \ + _SHIFTL(sB, 0, 8)) \ +} + +#define gDPNoParam(pkt, cmd) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(cmd, 24, 8); \ + _g->words.w1 = 0; \ +} + +#define gsDPNoParam(cmd) \ +{ \ + _SHIFTL(cmd, 24, 8), 0 \ +} + +#define gDPParam(pkt, cmd, param) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(cmd, 24, 8); \ + _g->words.w1 = (param); \ +} + +#define gsDPParam(cmd, param) \ +{ \ + _SHIFTL(cmd, 24, 8), (param) \ +} + +/* Notice that textured rectangles are 128-bit commands, therefore + * gsDPTextureRectangle() should not be used in display lists + * under normal circumstances (use gsSPTextureRectangle()). + * That is also why there is no gDPTextureRectangle() macros. + */ +#define gsDPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ +{ \ + (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)), \ + (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ +}, \ +{ \ + _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ + _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ +} + +#define gDPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + if (pkt); \ + _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ + _SHIFTL(yl, 0, 12)); \ + _g ++; \ + _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ + _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ +} + +#define gsDPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ +{ \ + (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)), \ + (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ +}, \ +{ \ + _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ + _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ +} + +#define gDPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + if (pkt); \ + _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ + _SHIFTL(yl, 0, 12)); \ + _g ++; \ + _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ + _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ +} + +#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ + (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ + (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ + gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ + gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) + +#define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ + _SHIFTL(yl, 0, 12)); \ + gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ + gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)));\ +} + +/* like gSPTextureRectangle but accepts negative position arguments */ +#define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | \ + _SHIFTL(MAX((s16)(xh),0), 12, 12) | \ + _SHIFTL(MAX((s16)(yh),0), 0, 12)); \ + _g->words.w1 = (_SHIFTL((tile), 24, 3) | \ + _SHIFTL(MAX((s16)(xl),0), 12, 12) | \ + _SHIFTL(MAX((s16)(yl),0), 0, 12)); \ + gImmp1(pkt, G_RDPHALF_1, \ + (_SHIFTL(((s) - \ + (((s16)(xl) < 0) ? \ + (((s16)(dsdx) < 0) ? \ + (MAX((((s16)(xl)*(s16)(dsdx))>>7),0)) : \ + (MIN((((s16)(xl)*(s16)(dsdx))>>7),0))) : 0)), \ + 16, 16) | \ + _SHIFTL(((t) - \ + (((yl) < 0) ? \ + (((s16)(dtdy) < 0) ? \ + (MAX((((s16)(yl)*(s16)(dtdy))>>7),0)) : \ + (MIN((((s16)(yl)*(s16)(dtdy))>>7),0))) : 0)), \ + 0, 16))); \ + gImmp1(pkt, G_RDPHALF_2, (_SHIFTL((dsdx), 16, 16) | \ + _SHIFTL((dtdy), 0, 16))); \ +} + +#define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ + (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)), \ + (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ + gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ + gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) + +#define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) |\ + _SHIFTL(yh, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ + _SHIFTL(yl, 0, 12)); \ + gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ + gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \ +} + +#define gsDPWord(wordhi, wordlo) \ + gsImmp1(G_RDPHALF_1, (unsigned int)(wordhi)), \ + gsImmp1(G_RDPHALF_2, (unsigned int)(wordlo)) + +#define gDPWord(pkt, wordhi, wordlo) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + gImmp1(pkt, G_RDPHALF_1, (unsigned int)(wordhi)); \ + gImmp1(pkt, G_RDPHALF_2, (unsigned int)(wordlo)); \ +} + +#define gDPFullSync(pkt) gDPNoParam(pkt, G_RDPFULLSYNC) +#define gsDPFullSync() gsDPNoParam(G_RDPFULLSYNC) +#define gDPTileSync(pkt) gDPNoParam(pkt, G_RDPTILESYNC) +#define gsDPTileSync() gsDPNoParam(G_RDPTILESYNC) +#define gDPPipeSync(pkt) gDPNoParam(pkt, G_RDPPIPESYNC) +#define gsDPPipeSync() gsDPNoParam(G_RDPPIPESYNC) +#define gDPLoadSync(pkt) gDPNoParam(pkt, G_RDPLOADSYNC) +#define gsDPLoadSync() gsDPNoParam(G_RDPLOADSYNC) +#define gDPNoOp(pkt) gDPNoParam(pkt, G_NOOP) +#define gsDPNoOp() gsDPNoParam(G_NOOP) +#define gDPNoOpTag(pkt, tag) gDPParam(pkt, G_NOOP, tag) +#define gsDPNoOpTag(tag) gsDPParam(G_NOOP, tag) + +#endif /* _LANGUAGE_C */ + + +#endif /* _GBI_H_ */ diff --git a/include/2.0L/PR/gs2dex.h b/include/2.0L/PR/gs2dex.h new file mode 100755 index 00000000..7e2b2c6a --- /dev/null +++ b/include/2.0L/PR/gs2dex.h @@ -0,0 +1,364 @@ +/*--------------------------------------------------------------------- + Copyright (C) 1997, Nintendo. + + File gs2dex.h + Coded by Yoshitaka Yasumoto. Jul 31, 1997. + Modified by + Comments Header file for S2DEX ucode. + + $Id: gs2dex.h,v 1.15 1997/10/17 08:19:07 yasu Exp $ + ---------------------------------------------------------------------*/ + +#ifndef _GS2DEX_H_ +#define _GS2DEX_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +/*===========================================================================* + * Macro + *===========================================================================*/ +#define GS_CALC_DXT(line) (((1<< G_TX_DXT_FRAC)-1)/(line)+1) +#define GS_PIX2TMEM(pix, siz) ((pix)>>(4-(siz))) +#define GS_PIX2DXT(pix, siz) GS_CALC_DXT(GS_PIX2TMEM((pix), (siz))) + +/*===========================================================================* + * Data structures for S2DEX microcode + *===========================================================================*/ + +/*---------------------------------------------------------------------------* + * Background + *---------------------------------------------------------------------------*/ +#define G_BGLT_LOADBLOCK 0x0033 +#define G_BGLT_LOADTILE 0xfff4 + +#define G_BG_FLAG_FLIPS 0x01 +#define G_BG_FLAG_FLIPT 0x10 + +/* Non scalable background plane */ +typedef struct { + u16 imageX; /* The x-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageW; /* The width of the texture. (u10.2)*/ + s16 frameX; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameW; /* The width of the transferred frame. (u10.2)*/ + + u16 imageY; /* The y-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageH; /* The height of the texture. (u10.2)*/ + s16 frameY; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameH; /* The height of the transferred frame. (u10.2)*/ + + u64 *imagePtr; /* The texture source address on DRAM. */ + u16 imageLoad; /* Which to use, LoadBlock or LoadTile? */ + u8 imageFmt; /* The format of the texel. G_IM_FMT_* */ + u8 imageSiz; /* The size of the texel G_IM_SIZ_* */ + u16 imagePal; /* The pallet number. */ + u16 imageFlip; /* The right & left inversion of the image. Inverted by G_BG_FLAG_FLIPS*/ + + /* Because the following are set in the initialization routine guS2DInitBg(), the user doesn't + have to set it.*/ + u16 tmemW; /* The TMEM width and Work size of the frame 1 line. + At LoadBlock, GS_PIX2TMEM(imageW/4,imageSiz) + At LoadTile GS_PIX2TMEM(frameW/4,imageSiz)+1 */ + u16 tmemH; /* The height of TMEM loadable at a time. (s13.2) The 4 times value. + When the normal texture, 512/tmemW*4 + When the CI texture, 256/tmemW*4 */ + u16 tmemLoadSH; /* The SH value + At LoadBlock, tmemSize/2-1 + At LoadTile, tmemW*16-1 */ + u16 tmemLoadTH; /* The TH value or the Stride value + At LoadBlock, GS_CALC_DXT(tmemW) + At LoadTile, tmemH-1 */ + u16 tmemSizeW; /* The skip value of imagePtr for image 1-line. + At LoadBlock, tmemW*2 + At LoadTile, GS_PIX2TMEM(imageW/4,imageSiz)*2 */ + u16 tmemSize; /* The skip value of imagePtr for 1-loading. + = tmemSizeW*tmemH */ +} uObjBg_t; /* 40 bytes */ + +/* Scalable background plane */ +typedef struct { + u16 imageX; /* The x-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageW; /* The width of the texture. (u10.2)*/ + s16 frameX; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameW; /* The width of the transferred frame. (u10.2)*/ + + u16 imageY; /* The y-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageH; /* The height of the texture. (u10.2)*/ + s16 frameY; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameH; /* The height of the transferred frame. (u10.2)*/ + + u64 *imagePtr; /* The texture source address on DRAM. */ + u16 imageLoad; /* Which to use, LoadBlock or LoadTile? */ + u8 imageFmt; /* The format of the texel. G_IM_FMT_* */ + u8 imageSiz; /* The size of the texel G_IM_SIZ_* */ + u16 imagePal; /* The pallet number. */ + u16 imageFlip; /* The right & left inversion of the image. Inverted by G_BG_FLAG_FLIPS*/ + + u16 scaleW; /* The scale value of the X-direction. (u5.10)*/ + u16 scaleH; /* The scale value of the Y-direction. (u5.10)*/ + s32 imageYorig; /* The start point of drawing on the image. (s20.5)*/ + + u8 padding[4]; + +} uObjScaleBg_t; /* 40 bytes */ + +typedef union { + uObjBg_t b; + uObjScaleBg_t s; + long long int force_structure_alignment; +} uObjBg; + +/*---------------------------------------------------------------------------* + * 2D Objects + *---------------------------------------------------------------------------*/ +#define G_OBJ_FLAG_FLIPS 1<<0 /* The inversion to the S-direction. */ +#define G_OBJ_FLAG_FLIPT 1<<4 /* The inversion to the T-direction. */ + +typedef struct { + s16 objX; /* The x-coordinate of the upper-left end. s10.2 OBJ */ + u16 scaleW; /* Scaling of the u5.10 width direction. */ + u16 imageW; /* The width of the u10.5 texture. (The length of the S-direction.) */ + u16 paddingX; /* Unused. Always 0. */ + s16 objY; /* The y-coordinate of the s10.2 OBJ upper-left end. */ + u16 scaleH; /* Scaling of the u5.10 height direction. */ + u16 imageH; /* The height of the u10.5 texture. (The length of the T-direction.)*/ + u16 paddingY; /* Unused. Always 0. */ + u16 imageStride; /* The folding width of the texel. (In units of 64bit word.) */ + u16 imageAdrs; /* The texture header position in TMEM. (In units of 64bit word.) */ + u8 imageFmt; /* The format of the texel. G_IM_FMT_* */ + u8 imageSiz; /* The size of the texel. G_IM_SIZ_* */ + u8 imagePal; /*The pallet number. 0-7 */ + u8 imageFlags; /* The display flag. G_OBJ_FLAG_FLIP* */ +} uObjSprite_t; /* 24 bytes */ + +typedef union { + uObjSprite_t s; + long long int force_structure_alignment; +} uObjSprite; + +/*---------------------------------------------------------------------------* + * 2D Matrix + *---------------------------------------------------------------------------*/ +typedef struct { + s32 A, B, C, D; /* s15.16 */ + s16 X, Y; /* s10.2 */ + u16 BaseScaleX; /* u5.10 */ + u16 BaseScaleY; /* u5.10 */ +} uObjMtx_t; /* 24 bytes */ + +typedef union { + uObjMtx_t m; + long long int force_structure_alignment; +} uObjMtx; + +typedef struct { + s16 X, Y; /* s10.2 */ + u16 BaseScaleX; /* u5.10 */ + u16 BaseScaleY; /* u5.10 */ +} uObjSubMtx_t; /* 8 bytes */ + +typedef union { + uObjSubMtx_t m; + long long int force_structure_alignment; +} uObjSubMtx; + +/*---------------------------------------------------------------------------* + * Loading into TMEM + *---------------------------------------------------------------------------*/ +#define G_OBJLT_TXTRBLOCK 0x00001033 +#define G_OBJLT_TXTRTILE 0x00fc1034 +#define G_OBJLT_TLUT 0x00000030 + +#define GS_TB_TSIZE(pix,siz) (GS_PIX2TMEM((pix),(siz))-1) +#define GS_TB_TLINE(pix,siz) (GS_CALC_DXT(GS_PIX2TMEM((pix),(siz)))) + +typedef struct { + u32 type; /* G_OBJLT_TXTRBLOCK divided into types. */ + u64 *image; /* The texture source address on DRAM. */ + u16 tmem; /* The transferred TMEM word address. (8byteWORD) */ + u16 tsize; /* The Texture size. Specified by the macro GS_TB_TSIZE(). */ + u16 tline; /* The width of the Texture 1-line. Specified by the macro GS_TB_TLINE()*/ + u16 sid; /* STATE ID Multipled by 4. Either one of 0,4,8 and 12. */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrBlock_t; /* 24 bytes */ + +#define GS_TT_TWIDTH(pix,siz) ((GS_PIX2TMEM((pix), (siz))<<2)-1) +#define GS_TT_THEIGHT(pix,siz) (((pix)<<2)-1) + +typedef struct { + u32 type; /* G_OBJLT_TXTRTILE divided into types. */ + u64 *image; /* The texture source address on DRAM. */ + u16 tmem; /* The loaded texture source address on DRAM. (8byteWORD) */ + u16 twidth; /* The width of the Texture. Specified by the macro GS_TT_TWIDTH() */ + u16 theight; /* The height of the Texture. Specified by the macro GS_TT_THEIGHT()*/ + u16 sid; /* STATE ID Multiplied by 4. Either one of 0,4,8 and 12. */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrTile_t; /* 24 bytes */ + +#define GS_PAL_HEAD(head) ((head)+256) +#define GS_PAL_NUM(num) ((num)-1) + +typedef struct { + u32 type; /* G_OBJLT_TLUT divided into types. */ + u64 *image; /* the texture source address on DRAM. */ + u16 phead; /* The pallet number of the load header. Between 256 and 511. */ + u16 pnum; /* The loading pallet number -1. */ + u16 zero; /* Assign 0 all the time. */ + u16 sid; /* STATE ID Multiplied by 4. Either one of 0,4,8 and 12. */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrTLUT_t; /* 24 bytes */ + +typedef union { + uObjTxtrBlock_t block; + uObjTxtrTile_t tile; + uObjTxtrTLUT_t tlut; + long long int force_structure_alignment; +} uObjTxtr; + +/*---------------------------------------------------------------------------* + * Loading into TMEM & 2D Objects + *---------------------------------------------------------------------------*/ +typedef struct { + uObjTxtr txtr; + uObjSprite sprite; +} uObjTxSprite; /* 48 bytes */ + +/*===========================================================================* + * GBI Commands for S2DEX microcode + *===========================================================================*/ +/* GBI Header */ +#define G_BG_1CYC 0x01 +#define G_BG_COPY 0x02 +#define G_OBJ_RECTANGLE 0x03 +#define G_OBJ_SPRITE 0x04 +#define G_OBJ_MOVEMEM 0x05 +#define G_SELECT_DL 0xb0 +#define G_OBJ_RENDERMODE 0xb1 +#define G_OBJ_RECTANGLE_R 0xb2 +#define G_OBJ_LOADTXTR 0xc1 +#define G_OBJ_LDTX_SPRITE 0xc2 +#define G_OBJ_LDTX_RECT 0xc3 +#define G_OBJ_LDTX_RECT_R 0xc4 +#define G_RDPHALF_0 0xe4 + + +/*---------------------------------------------------------------------------* + * Background wrapped screen + *---------------------------------------------------------------------------*/ +#define gSPBgRectangle(pkt, m, mptr) gDma0p((pkt),(m),(mptr),0) +#define gsSPBgRectangle(m, mptr) gsDma0p( (m),(mptr),0) +#define gSPBgRectCopy(pkt, mptr) gSPBgRectangle((pkt), G_BG_COPY, (mptr)) +#define gsSPBgRectCopy(mptr) gsSPBgRectangle( G_BG_COPY, (mptr)) +#define gSPBgRect1Cyc(pkt, mptr) gSPBgRectangle((pkt), G_BG_1CYC, (mptr)) +#define gsSPBgRect1Cyc(mptr) gsSPBgRectangle( G_BG_1CYC, (mptr)) + +/*---------------------------------------------------------------------------* + * 2D Objects + *---------------------------------------------------------------------------*/ +#define gSPObjSprite(pkt, mptr) gDma0p((pkt),G_OBJ_SPRITE, (mptr),0) +#define gsSPObjSprite(mptr) gsDma0p( G_OBJ_SPRITE, (mptr),0) +#define gSPObjRectangle(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE, (mptr),0) +#define gsSPObjRectangle(mptr) gsDma0p( G_OBJ_RECTANGLE, (mptr),0) +#define gSPObjRectangleR(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE_R,(mptr),0) +#define gsSPObjRectangleR(mptr) gsDma0p( G_OBJ_RECTANGLE_R,(mptr),0) + +/*---------------------------------------------------------------------------* + * 2D Matrix + *---------------------------------------------------------------------------*/ +#define gSPObjMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),0,23) +#define gsSPObjMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),0,23) +#define gSPObjSubMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),2, 7) +#define gsSPObjSubMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),2, 7) + +/*---------------------------------------------------------------------------* + * Loading into TMEM + *---------------------------------------------------------------------------*/ +#define gSPObjLoadTxtr(pkt, tptr) gDma0p((pkt),G_OBJ_LOADTXTR, (tptr),23) +#define gsSPObjLoadTxtr(tptr) gsDma0p( G_OBJ_LOADTXTR, (tptr),23) +#define gSPObjLoadTxSprite(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_SPRITE,(tptr),47) +#define gsSPObjLoadTxSprite(tptr) gsDma0p( G_OBJ_LDTX_SPRITE,(tptr),47) +#define gSPObjLoadTxRect(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT, (tptr),47) +#define gsSPObjLoadTxRect(tptr) gsDma0p( G_OBJ_LDTX_RECT, (tptr),47) +#define gSPObjLoadTxRectR(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT_R,(tptr),47) +#define gsSPObjLoadTxRectR(tptr) gsDma0p( G_OBJ_LDTX_RECT_R,(tptr),47) + +/*---------------------------------------------------------------------------* + * Select Display List + *---------------------------------------------------------------------------*/ +#define gSPSelectDL(pkt, mptr, sid, flag, mask) \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } +#define gsSPSelectDL(mptr, sid, flag, mask) \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } +#define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } +#define gsSPSelectBranchDL(mptr, sid, flag, mask) \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } + +/*---------------------------------------------------------------------------* + * Set general status + *---------------------------------------------------------------------------*/ +#define G_MW_GENSTAT 0x08 /* Note that it is the same value of G_MW_FOG. */ + +#define gSPSetStatus(pkt, sid, val) \ + gMoveWd((pkt), G_MW_GENSTAT, (sid), (val)) +#define gsSPSetStatus(sid, val) \ + gsMoveWd( G_MW_GENSTAT, (sid), (val)) + +/*---------------------------------------------------------------------------* + * Set Object Render Mode + *---------------------------------------------------------------------------*/ +#define G_OBJRM_NOTXCLAMP 0x01 +#define G_OBJRM_XLU 0x02 /* Ignored */ +#define G_OBJRM_ANTIALIAS 0x04 /* Ignored */ +#define G_OBJRM_BILERP 0x08 +#define G_OBJRM_SHRINKSIZE_1 0x10 +#define G_OBJRM_SHRINKSIZE_2 0x20 +#define G_OBJRM_WIDEN 0x40 + +#define gSPObjRenderMode(pkt, mode) gImmp1((pkt),G_OBJ_RENDERMODE,(mode)) +#define gsSPObjRenderMode(mode) gsImmp1( G_OBJ_RENDERMODE,(mode)) + +/*===========================================================================* + * Render Mode Macro + *===========================================================================*/ +#define RM_RA_SPRITE(clk) \ + AA_EN | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define G_RM_SPRITE G_RM_OPA_SURF +#define G_RM_SPRITE2 G_RM_OPA_SURF2 +#define G_RM_RA_SPRITE RM_RA_SPRITE(1) +#define G_RM_RA_SPRITE2 RM_RA_SPRITE(2) +#define G_RM_AA_SPRITE G_RM_AA_TEX_TERR +#define G_RM_AA_SPRITE2 G_RM_AA_TEX_TERR2 +#define G_RM_XLU_SPRITE G_RM_XLU_SURF +#define G_RM_XLU_SPRITE2 G_RM_XLU_SURF2 +#define G_RM_AA_XLU_SPRITE G_RM_AA_XLU_SURF +#define G_RM_AA_XLU_SPRITE2 G_RM_AA_XLU_SURF2 + +/*===========================================================================* + * External functions + *===========================================================================*/ +extern u64 gspS2DEX_fifoTextStart[], gspS2DEX_fifoTextEnd[]; +extern u64 gspS2DEX_fifoDataStart[], gspS2DEX_fifoDataEnd[]; +extern u64 gspS2DEX_fifo_dTextStart[], gspS2DEX_fifo_dTextEnd[]; +extern u64 gspS2DEX_fifo_dDataStart[], gspS2DEX_fifo_dDataEnd[]; +extern void guS2DInitBg(uObjBg *); +extern void guS2DEmuSetScissor(u32, u32, u32, u32, u8); +extern void guS2DEmuBgRect1Cyc(Gfx **, uObjBg *); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _GS2DEX_H_ */ + +/*======== End of gs2dex.h ========*/ diff --git a/include/2.0L/PR/gt.h b/include/2.0L/PR/gt.h new file mode 100755 index 00000000..07fa2bcf --- /dev/null +++ b/include/2.0L/PR/gt.h @@ -0,0 +1,363 @@ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * + * UNPUBLISHED -- Rights reserved under the copyright laws of the United + * States. Use of a copyright notice is precautionary only and does not + * imply publication or disclosure. + * + * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or + * in similar or successor clauses in the FAR, or the DOD or NASA FAR + * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., + * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. + * + * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY + * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, + * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY + * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON + * GRAPHICS, INC. + * + */ + +/* + * File: gt.h + * Creator: hsa@sgi.com + * Create Date: Thu Oct 12 15:48:14 PDT 1995 + * + * This file defines the GBI for the TURBO 3D graphics microcode. + * The turbo microcode is a special FEATURE-LIMITED microcode designed + * for specific applications. It is not for general use. + * + * (see XXX for more information) + * + */ + +/************************************************************************** + * + * $Revision: 1.14 $ + * $Date: 1997/02/11 08:22:47 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/gt.h,v $ + * + **************************************************************************/ + +#ifndef _GT_H_ +#define _GT_H_ + +/* this file should be #included AFTER gbi.h */ + +#include "sptask.h" + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif /* _LANGUAGE_C_PLUS_PLUS */ + +/* the following #defines seem out of order, but we need them + * for the microcode. + */ + +/* + * object state field: rendState + * + * This flag word is built up out of the bits from a + * subset of the G_SETGEOMETRYMODE flags from gbi.h. + * + * When each of these bits is '1', the comments below explain + * the effect on the triangles. + */ +#define GT_ZBUFFER G_ZBUFFER +#define GT_TEXTURE G_TEXTURE_ENABLE /* texture ON */ +#define GT_CULL_BACK G_CULL_BACK /* reject backfaces */ +#define GT_SHADING_SMOOTH G_SHADING_SMOOTH /* smooth shade ON */ + +/* + * object state field: textureState + * + * The lower 3 bits of this flag word contain the texture tile number + * to be used. All triangles of an object are rendered with the same + * texture tile. + */ + +/* + * object state field: flag + * + * This is a group of what would be pad bits. We use them for some + * flag bits. + */ +#define GT_FLAG_NOMTX 0x01 /* don't load the matrix */ +#define GT_FLAG_NO_XFM 0x02 /* load vtx, use verbatim */ +#define GT_FLAG_XFM_ONLY 0x04 /* xform vtx, write to *TriN */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* turbo 3D ucode: */ +extern long long int gspTurbo3DTextStart[], gspTurbo3DTextEnd[]; +extern long long int gspTurbo3DDataStart[], gspTurbo3DDataEnd[]; +extern long long int gspTurbo3D_dramTextStart[], gspTurbo3D_dramTextEnd[]; +extern long long int gspTurbo3D_dramDataStart[], gspTurbo3D_dramDataEnd[]; +extern long long int gspTurbo3D_fifoTextStart[], gspTurbo3D_fifoTextEnd[]; +extern long long int gspTurbo3D_fifoDataStart[], gspTurbo3D_fifoDataEnd[]; + +/* + * This is the global state structure. It's definition carefully + * matches the ucode, so if this structure changes, you must also change + * the ucode. + */ +typedef struct { + u16 perspNorm; /* persp normalization */ + u16 pad0; + u32 flag; + Gfx rdpOthermode; + u32 segBases[16]; /* table of segment base addrs (SEE NOTE!) */ + Vp viewport; /* the viewport to use */ + Gfx *rdpCmds; /* block of RDP data, process if !NULL + * block terminated by gDPEndDisplayList() + * (This is a segment address) + */ +} gtGlobState_t; + +/* NOTE: + * Although there are 16 segment table entries, the first one (segment 0) + * is reserved for physical memory mapping. You should not segment 0 + * to anything other than 0x0. + */ + +typedef union { + gtGlobState_t sp; + long long int force_structure_alignment; +} gtGlobState; + + +/* + * This is the 'state' structure associated with each object + * to be rendered. It's definition carefully matches the + * ucode, so if this structure changes, you must also change + * the gtoff.c tool and the ucode. + */ +typedef struct { + u32 renderState; /* render state */ + u32 textureState; /* texture state */ + u8 vtxCount; /* how many verts? */ + u8 vtxV0; /* where to load verts? */ + u8 triCount; /* how many tris? */ + u8 flag; + Gfx *rdpCmds; /* ptr (segment address) to RDP DL */ + Gfx rdpOthermode; + Mtx transform; /* the transform matrix to use */ +} gtState_t; + +typedef union { + gtState_t sp; + long long int force_structure_alignment; +} gtState; + +/* gtStateLite : same as gtState, but no matrix (see flags below) */ +/* this structure must be identical to gtState! (bad) */ +typedef struct { + u32 renderState; /* render state */ + u32 textureState; /* texture state */ + u8 vtxCount; /* how many verts? */ + u8 vtxV0; /* where to load verts? */ + u8 triCount; /* how many tris? */ + u8 flag; + Gfx *rdpCmds; /* ptr (segment address) to RDP DL */ + Gfx rdpOthermode; +} gtStateL_t; + +typedef union { + gtStateL_t sp; + long long int force_structure_alignment; +} gtStateL; + +/* + * The vertex list for the turbo display list uses the + * Vtx struct in gbi.h + * + */ + + +/* + * This structure represents a single triangle, part of the + * triangle list of the object to be rendered. + * + * NOTE: The triangle list MUST be aligned to an 8-byte boundary. + * Since this structure is only 4 bytes, we are REQUIRING that + * this structure only be used as an array of triangles, and we + * depend on the MIPS C compiler (which always aligns arrays to + * 8-byte boundaries). THIS IS DANGEROUS!!!! + * + */ +typedef struct { + u8 v0, v1, v2, flag; /* flag is which one for flat shade */ +} gtTriN; + + +/* + * This structure represents the transformed points. It is the format + * of the points written out when GT_FLAG_XFM_ONLY is set, as well as + * the format expected when GT_FLAG_NO_XFM is used. + * + * NOTE: The size and layout of these points is very similar to Vtx, + * except the screen coordinates overwrite the x,y,z,pad fields. + * (we could consider adding to the Vtx union, but we want to keep + * turbo stuff out of gbi.h) + * + * NOTE: The z is a special format. It can be used to compare vertices + * for sorting, but it should not be used for other purposes. If modified, + * the z-buffer hardware might not understand the data. + * + */ +typedef struct { + short int xscrn; /* x,y screen coordinates are SSSS10.2 */ + short int yscrn; + int zscrn; /* z screen is S15.16 */ + + short int s; /* transformed texture coord, S10.5 */ + short int t; + + u8 r; /* color (or normal) */ + u8 g; + u8 b; + u8 a; +} gtVtxOut_t; + +/* see "Data Structure" comment in gbi.h for information about why + * we use this union. + */ +typedef union { + gtVtxOut_t v; + long long int force_structure_alignment; +} gtVtxOut; + + + +/* + * state field: rdpOthermode + * + * This is one of the trickier state fields. The turbo interface + * requires the RDP othermode command to be cached by the host, + * therefore we provide a different interface in libultra to help cache + * this in the gt state (this word is just bits, you could pack them + * on your own). + * + * gtStateSetOthermode() accomplishs this, taking as arguments + * the state, one of the following mode enums, and a piece of data + * (othermode parameters from gbi.h). + * + * By definition, the othermode word from the gt state structure is sent + * to the RDP *before* any RDP commands from the rdpCmds[] field. The + * othermode is *always* sent. + * + * Stated another way, NONE of the gbi RDP othermode commands equivalent + * to those listed here are allowed in the rdpCmd[] field of the + * gt state structure. + * + * Notice also that many of these commands do not make sense for + * the turbo ucode (they control features not supported, like mip-mapping). + * They are only included here for completeness. + * + */ +typedef enum { + GT_CLEAR, /* special gt mode, clears othermode state */ + GT_ALPHACOMPARE, + GT_ZSRCSEL, + GT_RENDERMODE, + GT_ALPHADITHER, + GT_RGBDITHER, + GT_COMBKEY, + GT_TEXTCONV, + GT_TEXTFILT, + GT_TEXTLUT, + GT_TEXTLOD, + GT_TEXTDETAIL, + GT_TEXTPERSP, + GT_CYCLETYPE, + GT_PIPELINE +} gtStateOthermode_t; + +/* + * This call builds up an othermode command word. The 'mode' is one of + * the above modes, the 'data' field comes from gbi.h, it is the data + * field for the equivalent gbi setothermode macro. + */ +extern void gtStateSetOthermode(Gfx *om, gtStateOthermode_t mode, int data); + +/* + * This call dumps a turbo display list for use with gbi2mem and RSPSIM + */ +#define GT_DUMPTURBO_HANGAFTER 64 +#define GT_DUMPTURBO_NOTEXTURES 128 +extern void gtDumpTurbo(OSTask *tp,u8 flags); + +/* + * Special macros to init othermode words to all 0's, a good default + * value. + */ +#define gDPClearOtherMode(pkt) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE, 24, 8); \ + _g->words.w1 = 0x0; \ +} + +#define gsDPClearOtherMode() \ +{ \ + _SHIFTL(G_RDPSETOTHERMODE, 24, 8), 0x0 \ +} + +/* + * Special macros to end DP blocks (see above). These commands + * generate all 0's, which the turbo ucode looks for. They *aren't* + * real DP commands! + */ +#define gDPEndDisplayList(pkt) gSPNoOp(pkt) +#define gsDPEndDisplayList() gsSPNoOp() + +/* + * This structure is a turbo 'object', the turbo display list is + * simply a list of these. + * + * NOTE: All pointers are segment addresses + * + * NOTE: If (statep->flag & GT_FLAG_XFM_ONLY), the trip field is + * interpreted as a pointer to gtVtxOut[] that can be used to store + * the transformed points. (statep->triCount should be 0, else bad + * things could happen...) + * + * NOTE: If (statep->flag & GT_FLAG_NO_XFM), the vtxp field is + * interpreted as a pointer to gtVtxOut[] that can be used to load + * pre-transformed points. + * + */ +typedef struct { + gtGlobState *gstatep; /* global state, usually NULL */ + gtState *statep; /* if this is NULL, end object processing */ + Vtx *vtxp; /* if this is NULL, use points in buffer */ + gtTriN *trip; /* if this is NULL, use tris in buffer */ +} gtGfx_t; + +typedef union { + gtGfx_t obj; + long long int force_structure_alignment; +} gtGfx; + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_ASSEMBLY +#include +#endif /* _LANGUAGE_ASSEMBLY */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif /* _LANGUAGE_C_PLUS_PLUS */ + +#ifdef _LANGUAGE_MAKEROM +#endif /* _LANGUAGE_MAKEROM */ + +#endif /* _GT_H_ */ diff --git a/include/2.0L/PR/gu.h b/include/2.0L/PR/gu.h new file mode 100755 index 00000000..3063e7b0 --- /dev/null +++ b/include/2.0L/PR/gu.h @@ -0,0 +1,266 @@ +#ifndef _GU_H_ +#define _GU_H_ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.46 $ + * $Date: 1997/11/26 00:30:53 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/gu.h,v $ + * + **************************************************************************/ + +#include +#include +#include + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#define M_PI 3.14159265358979323846 +#define M_DTOR (3.14159265358979323846/180.0) + +#define FTOFIX32(x) (long)((x) * (float)0x00010000) +#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000)) +#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff) + +#define FILTER_WRAP 0 +#define FILTER_CLAMP 1 + +#define RAND(x) (guRandom()%x) /* random number between 0 to x */ + +/* + * Data Structures + */ +typedef struct { + unsigned char *base; + int fmt, siz; + int xsize, ysize; + int lsize; + /* current tile info */ + int addr; + int w, h; + int s, t; +} Image; + +typedef struct { + float col[3]; + float pos[3]; + float a1, a2; /* actual color = col/(a1*dist + a2) */ +} PositionalLight; + + +/* + * 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, + unsigned char cft); + +extern int guGetDPLoadTextureTileSz (int ult, int lrt); +extern void guDPLoadTextureTile (Gfx *glistp, void *timg, + int texl_fmt, int texl_size, + int img_width, int img_height, + int uls, int ult, int lrs, int lrt, + int palette, + int cms, int cmt, + int masks, int maskt, + int shifts, int shiftt); + + +/* + * matrix operations: + * + * The 'F' version is floating point, in case the application wants + * to do matrix manipulations and convert to fixed-point at the last + * minute. + */ +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, + float n, float f, float scale); +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, + float n, float f, float scale); +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, + float aspect, float near, float far, float scale); +extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, + float aspect, float near, float far, float scale); +extern void guLookAt(Mtx *m, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +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, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtHilite(Mtx *m, 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 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, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float eyedist); +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 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); +extern void guRotateRPY(Mtx *m, float r, float p, float y); +extern void guRotateRPYF(float mf[4][4], float r, float p, float h); +extern void guAlign(Mtx *m, float a, float x, float y, float z); +extern void guAlignF(float mf[4][4], float a, float x, float y, float z); +extern void guScale(Mtx *m, float x, float y, float z); +extern void guScaleF(float mf[4][4], float x, float y, float z); +extern void guTranslate(Mtx *m, float x, float y, float z); +extern void guTranslateF(float mf[4][4], float x, float y, float z); +extern void guPosition(Mtx *m, float r, float p, float h, float s, + float x, float y, float z); +extern void guPositionF(float mf[4][4], float r, float p, float h, float s, + float x, float y, float z); +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, + float *ox, float *oy, float *oz); +extern void guMtxXFML(Mtx *m, float x, float y, float z, + float *ox, float *oy, float *oz); + +/* vector utility: */ +extern void guNormalize(float *x, float *y, float *z); + +/* light utilities: */ +void guPosLight(PositionalLight *pl, Light *l, + float xOb, float yOb, float zOb); +void guPosLightHilite(PositionalLight *pl1, PositionalLight *pl2, + Light *l1, Light *l2, + LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xOb, float yOb, float zOb, + float xUp, float yUp, float zUp, + int twidth, int theight); +extern int guRandom(void); + +/* + * Math functions + */ +extern float sinf(float angle); +extern float cosf(float angle); +extern signed short sins (unsigned short angle); +extern signed short coss (unsigned short angle); +extern float sqrtf(float value); + +/* + * Dump routines for low-level display lists + */ +/* flag values for guParseRdpDL() */ +#define GU_PARSERDP_VERBOSE 1 +#define GU_PARSERDP_PRAREA 2 +#define GU_PARSERDP_PRHISTO 4 +#define GU_PARSERDP_DUMPONLY 32 /* doesn't need to be same as */ + /* GU_PARSEGBI_DUMPOLNY, but this */ + /* allows app to use interchangeably */ + +extern void guParseRdpDL(u64 *rdp_dl, u64 nbytes, u8 flags); +extern void guParseString(char *StringPointer, u64 nbytes); + +/* + * NO LONGER SUPPORTED, + * use guParseRdpDL with GU_PARSERDP_DUMPONLY flags + */ +/* extern void guDumpRawRdpDL(u64 *rdp_dl, u64 nbytes); */ + +/* flag values for guBlinkRdpDL() */ +#define GU_BLINKRDP_HILITE 1 +#define GU_BLINKRDP_EXTRACT 2 + +extern void +guBlinkRdpDL(u64 *rdp_dl_in, u64 nbytes_in, + u64 *rdp_dl_out, u64 *nbytes_out, + 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 +#define GU_PARSEGBI_FLTMTX 4 +#define GU_PARSEGBI_SHOWDMA 8 +#define GU_PARSEGBI_ALLMTX 16 +#define GU_PARSEGBI_DUMPONLY 32 +/* +#define GU_PARSEGBI_HANGAFTER 64 +#define GU_PARSEGBI_NOTEXTURES 128 +*/ +extern void guParseGbiDL(u64 *gbi_dl, u32 nbytes, u8 flags); +extern void guDumpGbiDL(OSTask *tp,u8 flags); + +#define GU_PARSE_GBI_TYPE 1 +#define GU_PARSE_RDP_TYPE 2 +#define GU_PARSE_READY 3 +#define GU_PARSE_MEM_BLOCK 4 +#define GU_PARSE_ABI_TYPE 5 +#define GU_PARSE_STRING_TYPE 6 + +typedef struct { + int dataSize; + int dlType; + int flags; + u32 paddr; +} guDLPrintCB; + +void guSprite2DInit(uSprite *SpritePointer, + void *SourceImagePointer, + void *TlutPointer, + int Stride, + int SubImageWidth, + int SubImageHeight, + int SourceImageType, + int SourceImageBitSize, + int SourceImageOffsetS, + int SourceImageOffsetT); + +#endif /* !_GU_H_ */ diff --git a/include/2.0L/PR/libaudio.h b/include/2.0L/PR/libaudio.h new file mode 100755 index 00000000..55f22c84 --- /dev/null +++ b/include/2.0L/PR/libaudio.h @@ -0,0 +1,947 @@ +/*==================================================================== + * libaudio.h + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.173 $ + * $Date: 1997/12/01 12:42:21 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/libaudio.h,v $ + * + **************************************************************************/ + +#ifndef __LIB_AUDIO__ +#define __LIB_AUDIO__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +/*********************************************************************** + * misc defines + ***********************************************************************/ +#ifndef _EMULATOR +# ifdef AUD_PROFILE + +#define PROFILE_AUD(num, cnt, max, min) \ +{ \ + u32 currCnt = osGetCount(); \ + currCnt -= lastCnt[cnt_index]; \ + cnt_index--; \ + cnt += currCnt; \ + num++; \ + \ + if ( currCnt > max ) max = currCnt; \ + if ( currCnt < min ) min = currCnt; \ +} + +# endif /* AUD_PROFILE */ +#endif /* EMULATOR */ + +#ifndef NULL +#define NULL 0 +#endif + +#define AL_FX_BUFFER_SIZE 8192 +#define AL_FRAME_INIT -1 +#define AL_USEC_PER_FRAME 16000 +#define AL_MAX_PRIORITY 127 +#define AL_GAIN_CHANGE_TIME 1000 + +typedef s32 ALMicroTime; +typedef u8 ALPan; + +#define AL_PAN_CENTER 64 +#define AL_PAN_LEFT 0 +#define AL_PAN_RIGHT 127 +#define AL_VOL_FULL 127 +#define AL_KEY_MIN 0 +#define AL_KEY_MAX 127 +#define AL_DEFAULT_FXMIX 0 +#define AL_SUSTAIN 63 + +/*********************************************************************** + * Error handling + ***********************************************************************/ + +#ifdef _DEBUG +#define ALFailIf(condition, error) \ + if (condition) { \ + __osError(error, 0); \ + return; } + +#else +#define ALFailIf(condition, error) \ + if (condition) { \ + return; } +#endif + +#ifdef _DEBUG +#define ALFlagFailIf(condition, flag, error) \ + if (condition) { \ + if(flag) __osError(error, 0); \ + return; } + +#else +#define ALFlagFailIf(condition, flag, error) \ + if (condition) { \ + return; } +#endif + +/*********************************************************************** + * Audio Library global routines + ***********************************************************************/ +typedef struct ALLink_s { + struct ALLink_s *next; + struct ALLink_s *prev; +} ALLink; + +void alUnlink(ALLink *element); +void alLink(ALLink *element, ALLink *after); + +typedef s32 (*ALDMAproc)(s32 addr, s32 len, void *state); +typedef ALDMAproc (*ALDMANew)(void *state); + +void alCopy(void *src, void *dest, s32 len); + +typedef struct { + u8 *base; + u8 *cur; + s32 len; + s32 count; +} ALHeap; + +#define AL_HEAP_DEBUG 1 +#define AL_HEAP_MAGIC 0x20736a73 +#define AL_HEAP_INIT 0 + +void alHeapInit(ALHeap *hp, u8 *base, s32 len); +void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); +s32 alHeapCheck(ALHeap *hp); + +#ifdef _DEBUG +#define alHeapAlloc(hp, elem ,size) alHeapDBAlloc((u8 *) __FILE__,__LINE__,(hp),(elem),(size)) +#else +#define alHeapAlloc(hp, elem ,size) alHeapDBAlloc(0, 0,(hp),(elem),(size)) +#endif + +/*********************************************************************** + * FX Stuff + ***********************************************************************/ +#define AL_FX_NONE 0 +#define AL_FX_SMALLROOM 1 +#define AL_FX_BIGROOM 2 +#define AL_FX_CHORUS 3 +#define AL_FX_FLANGE 4 +#define AL_FX_ECHO 5 +#define AL_FX_CUSTOM 6 + +typedef u8 ALFxId; +typedef void *ALFxRef; + +/*********************************************************************** + * data structures for sound banks + ***********************************************************************/ + +#define AL_BANK_VERSION 0x4231 /* 'B1' */ + +/* Possible wavetable types */ +enum {AL_ADPCM_WAVE = 0, + AL_RAW16_WAVE}; + +typedef struct { + s32 order; + s32 npredictors; + s16 book[1]; /* Actually variable size. Must be 8-byte aligned */ +} ALADPCMBook; + +typedef struct { + u32 start; + u32 end; + u32 count; + ADPCM_STATE state; +} ALADPCMloop; + +typedef struct { + u32 start; + u32 end; + u32 count; +} ALRawLoop; + +typedef struct { + ALMicroTime attackTime; + ALMicroTime decayTime; + ALMicroTime releaseTime; + u8 attackVolume; + u8 decayVolume; +} ALEnvelope; + +typedef struct { + u8 velocityMin; + u8 velocityMax; + u8 keyMin; + u8 keyMax; + u8 keyBase; + s8 detune; +} ALKeyMap; + +typedef struct { + ALADPCMloop *loop; + ALADPCMBook *book; +} ALADPCMWaveInfo; + +typedef struct { + ALRawLoop *loop; +} ALRAWWaveInfo; + +typedef struct ALWaveTable_s { + u8 *base; /* ptr to start of wave data */ + s32 len; /* length of data in bytes */ + u8 type; /* compression type */ + u8 flags; /* offset/address flags */ + union { + ALADPCMWaveInfo adpcmWave; + ALRAWWaveInfo rawWave; + } waveInfo; +} ALWaveTable; + +typedef struct ALSound_s { + ALEnvelope *envelope; + ALKeyMap *keyMap; + ALWaveTable *wavetable; /* offset to wavetable struct */ + ALPan samplePan; + u8 sampleVolume; + u8 flags; +} ALSound; + +typedef struct { + u8 volume; /* overall volume for this instrument */ + ALPan pan; /* 0 = hard left, 127 = hard right */ + u8 priority; /* voice priority for this instrument */ + u8 flags; + u8 tremType; /* the type of tremelo osc. to use */ + u8 tremRate; /* the rate of the tremelo osc. */ + u8 tremDepth; /* the depth of the tremelo osc */ + u8 tremDelay; /* the delay for the tremelo osc */ + u8 vibType; /* the type of tremelo osc. to use */ + u8 vibRate; /* the rate of the tremelo osc. */ + u8 vibDepth; /* the depth of the tremelo osc */ + u8 vibDelay; /* the delay for the tremelo osc */ + s16 bendRange; /* pitch bend range in cents */ + s16 soundCount; /* number of sounds in this array */ + ALSound *soundArray[1]; +} ALInstrument; + +typedef struct ALBank_s { + s16 instCount; /* number of programs in this bank */ + u8 flags; + u8 pad; + s32 sampleRate; /* e.g. 44100, 22050, etc... */ + ALInstrument *percussion; /* default percussion for GM */ + ALInstrument *instArray[1]; /* ARRAY of instruments */ +} ALBank; + +typedef struct { /* Note: sizeof won't be correct */ + s16 revision; /* format revision of this file */ + s16 bankCount; /* number of banks */ + ALBank *bankArray[1]; /* ARRAY of bank offsets */ +} ALBankFile; + +void alBnkfNew(ALBankFile *f, u8 *table); + +/*********************************************************************** + * Sequence Files + ***********************************************************************/ +#define AL_SEQBANK_VERSION 'S1' + +typedef struct { + u8 *offset; + s32 len; +} ALSeqData; + +typedef struct { /* Note: sizeof won't be correct */ + s16 revision; /* format revision of this file */ + s16 seqCount; /* number of sequences */ + ALSeqData seqArray[1]; /* ARRAY of sequence info */ +} ALSeqFile; + +void alSeqFileNew(ALSeqFile *f, u8 *base); + +/*********************************************************************** + * Synthesis driver stuff + ***********************************************************************/ +typedef ALMicroTime (*ALVoiceHandler)(void *); + +typedef struct { + s32 maxVVoices; /* obsolete */ + s32 maxPVoices; + s32 maxUpdates; + s32 maxFXbusses; + void *dmaproc; + ALHeap *heap; + s32 outputRate; /* output sample rate */ + ALFxId fxType; + s32 *params; +} ALSynConfig; + +typedef struct ALPlayer_s { + struct ALPlayer_s *next; + void *clientData; /* storage for client callback */ + ALVoiceHandler handler; /* voice handler for player */ + ALMicroTime callTime; /* usec requested callback */ + s32 samplesLeft; /* usec remaining to callback */ +} ALPlayer; + +typedef struct ALVoice_s { + ALLink node; + struct PVoice_s *pvoice; + ALWaveTable *table; + void *clientPrivate; + s16 state; + s16 priority; + s16 fxBus; + s16 unityPitch; +} ALVoice; + +typedef struct ALVoiceConfig_s { + s16 priority; /* voice priority */ + s16 fxBus; /* bus assignment */ + u8 unityPitch; /* unity pitch flag */ +} ALVoiceConfig; + +typedef struct { + ALPlayer *head; /* client list head */ + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + + struct ALParam_s *paramList; + + struct ALMainBus_s *mainBus; + struct ALAuxBus_s *auxBus; /* ptr to array of aux bus structs */ + struct ALFilter_s *outputFilter; /* last filter in the filter chain */ + + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; /* output sample rate */ + s32 maxOutSamples; /* Maximum samples rsp can generate + at one time at output rate */ +} ALSynth; + +void alSynNew(ALSynth *s, ALSynConfig *config); +void alSynDelete(ALSynth *s); + +void alSynAddPlayer(ALSynth *s, ALPlayer *client); +void alSynRemovePlayer(ALSynth *s, ALPlayer *client); + +s32 alSynAllocVoice(ALSynth *s, ALVoice *v, ALVoiceConfig *vc); +void alSynFreeVoice(ALSynth *s, ALVoice *voice); + +void alSynStartVoice(ALSynth *s, ALVoice *voice, ALWaveTable *w); +void alSynStartVoiceParams(ALSynth *s, ALVoice *voice, ALWaveTable *w, + f32 pitch, s16 vol, ALPan pan, u8 fxmix, + ALMicroTime t); +void alSynStopVoice(ALSynth *s, ALVoice *voice); + +void alSynSetVol(ALSynth *s, ALVoice *v, s16 vol, ALMicroTime delta); +void alSynSetPitch(ALSynth *s, ALVoice *voice, f32 ratio); +void alSynSetPan(ALSynth *s, ALVoice *voice, ALPan pan); +void alSynSetFXMix(ALSynth *s, ALVoice *voice, u8 fxmix); +void alSynSetPriority(ALSynth *s, ALVoice *voice, s16 priority); +s16 alSynGetPriority(ALSynth *s, ALVoice *voice); + +ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp); +ALFxRef alSynGetFXRef(ALSynth *s, s16 bus, s16 index); +void alSynFreeFX(ALSynth *s, ALFxRef *fx); +void alSynSetFXParam(ALSynth *s, ALFxRef fx, s16 paramID, void *param); + +/*********************************************************************** + * Audio Library (AL) stuff + ***********************************************************************/ +typedef struct { + ALSynth drvr; +} ALGlobals; + +extern ALGlobals *alGlobals; + +void alInit(ALGlobals *glob, ALSynConfig *c); +void alClose(ALGlobals *glob); + +Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen); + +/*********************************************************************** + * Sequence Player stuff + ***********************************************************************/ + +/* + * Play states + */ +#define AL_STOPPED 0 +#define AL_PLAYING 1 +#define AL_STOPPING 2 + +#define AL_DEFAULT_PRIORITY 5 +#define AL_DEFAULT_VOICE 0 +#define AL_MAX_CHANNELS 16 + +/* + * Audio Library event type definitions + */ +enum ALMsg { + AL_SEQ_REF_EVT, /* Reference to a pending event in the sequence. */ + AL_SEQ_MIDI_EVT, + AL_SEQP_MIDI_EVT, + AL_TEMPO_EVT, + AL_SEQ_END_EVT, + AL_NOTE_END_EVT, + AL_SEQP_ENV_EVT, + AL_SEQP_META_EVT, + AL_SEQP_PROG_EVT, + AL_SEQP_API_EVT, + AL_SEQP_VOL_EVT, + AL_SEQP_LOOP_EVT, + AL_SEQP_PRIORITY_EVT, + AL_SEQP_SEQ_EVT, + AL_SEQP_BANK_EVT, + AL_SEQP_PLAY_EVT, + AL_SEQP_STOP_EVT, + AL_SEQP_STOPPING_EVT, + AL_TRACK_END, + AL_CSP_LOOPSTART, + AL_CSP_LOOPEND, + AL_CSP_NOTEOFF_EVT, + AL_TREM_OSC_EVT, + AL_VIB_OSC_EVT +}; + +/* + * Midi event definitions + */ +#define AL_EVTQ_END 0x7fffffff + +enum AL_MIDIstatus { + /* For distinguishing channel number from status */ + AL_MIDI_ChannelMask = 0x0F, + AL_MIDI_StatusMask = 0xF0, + + /* Channel voice messages */ + AL_MIDI_ChannelVoice = 0x80, + AL_MIDI_NoteOff = 0x80, + AL_MIDI_NoteOn = 0x90, + AL_MIDI_PolyKeyPressure = 0xA0, + AL_MIDI_ControlChange = 0xB0, + AL_MIDI_ChannelModeSelect = 0xB0, + AL_MIDI_ProgramChange = 0xC0, + AL_MIDI_ChannelPressure = 0xD0, + AL_MIDI_PitchBendChange = 0xE0, + + /* System messages */ + AL_MIDI_SysEx = 0xF0, /* System Exclusive */ + + /* System common */ + AL_MIDI_SystemCommon = 0xF1, + AL_MIDI_TimeCodeQuarterFrame = 0xF1, + AL_MIDI_SongPositionPointer = 0xF2, + AL_MIDI_SongSelect = 0xF3, + AL_MIDI_Undefined1 = 0xF4, + AL_MIDI_Undefined2 = 0xF5, + AL_MIDI_TuneRequest = 0xF6, + AL_MIDI_EOX = 0xF7, /* End of System Exclusive */ + + /* System real time */ + AL_MIDI_SystemRealTime = 0xF8, + AL_MIDI_TimingClock = 0xF8, + AL_MIDI_Undefined3 = 0xF9, + AL_MIDI_Start = 0xFA, + AL_MIDI_Continue = 0xFB, + AL_MIDI_Stop = 0xFC, + AL_MIDI_Undefined4 = 0xFD, + AL_MIDI_ActiveSensing = 0xFE, + AL_MIDI_SystemReset = 0xFF, + AL_MIDI_Meta = 0xFF /* MIDI Files only */ +}; + +enum AL_MIDIctrl { + AL_MIDI_VOLUME_CTRL = 0x07, + AL_MIDI_PAN_CTRL = 0x0A, + AL_MIDI_PRIORITY_CTRL = 0x10, /* use general purpose controller for priority */ + AL_MIDI_FX_CTRL_0 = 0x14, + AL_MIDI_FX_CTRL_1 = 0x15, + AL_MIDI_FX_CTRL_2 = 0x16, + AL_MIDI_FX_CTRL_3 = 0x17, + AL_MIDI_FX_CTRL_4 = 0x18, + AL_MIDI_FX_CTRL_5 = 0x19, + AL_MIDI_FX_CTRL_6 = 0x1A, + AL_MIDI_FX_CTRL_7 = 0x1B, + AL_MIDI_FX_CTRL_8 = 0x1C, + AL_MIDI_FX_CTRL_9 = 0x1D, + AL_MIDI_SUSTAIN_CTRL = 0x40, + AL_MIDI_FX1_CTRL = 0x5B, + AL_MIDI_FX3_CTRL = 0x5D +}; + +enum AL_MIDImeta { + AL_MIDI_META_TEMPO = 0x51, + AL_MIDI_META_EOT = 0x2f +}; + + +#define AL_CMIDI_BLOCK_CODE 0xFE +#define AL_CMIDI_LOOPSTART_CODE 0x2E +#define AL_CMIDI_LOOPEND_CODE 0x2D +#define AL_CMIDI_CNTRL_LOOPSTART 102 +#define AL_CMIDI_CNTRL_LOOPEND 103 +#define AL_CMIDI_CNTRL_LOOPCOUNT_SM 104 +#define AL_CMIDI_CNTRL_LOOPCOUNT_BIG 105 + +typedef struct { + u8 *curPtr; /* ptr to the next event */ + s32 lastTicks; /* sequence clock ticks (used by alSeqSetLoc) */ + s32 curTicks; /* sequence clock ticks of next event (used by loop end test) */ + s16 lastStatus; /* the last status msg */ +} ALSeqMarker; + +typedef struct { + s32 ticks; /* MIDI, Tempo and End events must start with ticks */ + u8 status; + u8 byte1; + u8 byte2; + u32 duration; +} ALMIDIEvent; + +typedef struct { + s32 ticks; + u8 status; + u8 type; + u8 len; + u8 byte1; + u8 byte2; + u8 byte3; +} ALTempoEvent; + +typedef struct { + s32 ticks; + u8 status; + u8 type; + u8 len; +} ALEndEvent; + +typedef struct { + struct ALVoice_s *voice; +} ALNoteEvent; + +typedef struct { + struct ALVoice_s *voice; + ALMicroTime delta; + u8 vol; +} ALVolumeEvent; + +typedef struct { + s16 vol; +} ALSeqpVolEvent; + +typedef struct { + ALSeqMarker *start; + ALSeqMarker *end; + s32 count; +} ALSeqpLoopEvent; + +typedef struct { + u8 chan; + u8 priority; +} ALSeqpPriorityEvent; + +typedef struct { + void *seq; /* pointer to a seq (could be an ALSeq or an ALCSeq). */ +} ALSeqpSeqEvent; + +typedef struct { + ALBank *bank; +} ALSeqpBankEvent; + +typedef struct { + struct ALVoiceState_s *vs; + void *oscState; + u8 chan; +} ALOscEvent; + +typedef struct { + s16 type; + union { + ALMIDIEvent midi; + ALTempoEvent tempo; + ALEndEvent end; + ALNoteEvent note; + ALVolumeEvent vol; + ALSeqpLoopEvent loop; + ALSeqpVolEvent spvol; + ALSeqpPriorityEvent sppriority; + ALSeqpSeqEvent spseq; + ALSeqpBankEvent spbank; + ALOscEvent osc; + } msg; +} ALEvent; + +typedef struct { + ALLink node; + ALMicroTime delta; + ALEvent evt; +} ALEventListItem; + +typedef struct { + ALLink freeList; + ALLink allocList; + s32 eventCount; +} ALEventQueue; + +void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, + s32 itemCount); +ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); +void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, + ALMicroTime delta); +void alEvtqFlush(ALEventQueue *evtq); +void alEvtqFlushType(ALEventQueue *evtq, s16 type); + + +#define AL_PHASE_ATTACK 0 +#define AL_PHASE_NOTEON 0 +#define AL_PHASE_DECAY 1 +#define AL_PHASE_SUSTAIN 2 +#define AL_PHASE_RELEASE 3 +#define AL_PHASE_SUSTREL 4 + +typedef struct ALVoiceState_s { + struct ALVoiceState_s *next;/* MUST be first */ + ALVoice voice; + ALSound *sound; + ALMicroTime envEndTime; /* time of envelope segment end */ + f32 pitch; /* currect pitch ratio */ + f32 vibrato; /* current value of the vibrato */ + u8 envGain; /* current envelope gain */ + u8 channel; /* channel assignment */ + u8 key; /* note on key number */ + u8 velocity; /* note on velocity */ + u8 envPhase; /* what envelope phase */ + u8 phase; + u8 tremelo; /* current value of the tremelo */ + u8 flags; /* bit 0 tremelo flag + bit 1 vibrato flag */ +} ALVoiceState; + +typedef struct { + ALInstrument *instrument; /* instrument assigned to this chan */ + s16 bendRange; /* pitch bend range in cents */ + ALFxId fxId; /* type of fx assigned to this chan */ + ALPan pan; /* overall pan for this chan */ + u8 priority; /* priority for this chan */ + u8 vol; /* current volume for this chan */ + u8 fxmix; /* current fx mix for this chan */ + u8 sustain; /* current sustain pedal state */ + f32 pitchBend; /* current pitch bend val in cents */ +} ALChanState; + +typedef struct ALSeq_s { + u8 *base; /* ptr to start of sequence file */ + u8 *trackStart; /* ptr to first MIDI event */ + u8 *curPtr; /* ptr to next event to read */ + s32 lastTicks; /* MIDI ticks for last event */ + s32 len; /* length of sequence in bytes */ + f32 qnpt; /* qrter notes / tick (1/division) */ + s16 division; /* ticks per quarter note */ + s16 lastStatus; /* for running status */ +} ALSeq; + +typedef struct { + u32 trackOffset[16]; + u32 division; +} ALCMidiHdr; + +typedef struct ALCSeq_s { + ALCMidiHdr *base; /* ptr to start of sequence file */ + u32 validTracks; /* set of flags, showing valid tracks */ + f32 qnpt; /* qrter notes / tick (1/division) */ + u32 lastTicks; /* keep track of ticks incase app wants */ + u32 lastDeltaTicks; /* number of delta ticks of last event */ + u32 deltaFlag; /* flag: set if delta's not subtracted */ + u8 *curLoc[16]; /* ptr to current track location, */ + /* may point to next event, or may point */ + /* to a backup code */ + u8 *curBUPtr[16]; /* ptr to next event if in backup mode */ + u8 curBULen[16]; /* if > 0, then in backup mode */ + u8 lastStatus[16]; /* for running status */ + u32 evtDeltaTicks[16]; /* delta time to next event */ +} ALCSeq; + +typedef struct { + u32 validTracks; + s32 lastTicks; + u32 lastDeltaTicks; + u8 *curLoc[16]; + u8 *curBUPtr[16]; + u8 curBULen[16]; + u8 lastStatus[16]; + u32 evtDeltaTicks[16]; +} ALCSeqMarker; + +#define NO_SOUND_ERR_MASK 0x01 +#define NOTE_OFF_ERR_MASK 0x02 +#define NO_VOICE_ERR_MASK 0x04 + +typedef struct { + s32 maxVoices; /* max number of voices to alloc */ + s32 maxEvents; /* max internal events to support */ + u8 maxChannels; /* max MIDI channels to support (16)*/ + u8 debugFlags; /* control which error get reported */ + ALHeap *heap; /* ptr to initialized heap */ + void *initOsc; + void *updateOsc; + void *stopOsc; +} ALSeqpConfig; + +typedef ALMicroTime (*ALOscInit)(void **oscState,f32 *initVal, u8 oscType, + u8 oscRate, u8 oscDepth, u8 oscDelay); +typedef ALMicroTime (*ALOscUpdate)(void *oscState, f32 *updateVal); +typedef void (*ALOscStop)(void *oscState); + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALSynth *drvr; /* reference to the client driver */ + ALSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + ALVoiceState *vAllocHead; /* list head for allocated voices */ + ALVoiceState *vAllocTail; /* list tail for allocated voices */ + ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + ALSeqMarker *loopStart; + ALSeqMarker *loopEnd; + s32 loopCount; /* -1 = loop forever, 0 = no loop */ +} ALSeqPlayer; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALSynth *drvr; /* reference to the client driver */ + ALCSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + ALVoiceState *vAllocHead; /* list head for allocated voices */ + ALVoiceState *vAllocTail; /* list tail for allocated voices */ + ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; +} ALCSPlayer; + +/* + * Sequence data representation routines + */ +void alSeqNew(ALSeq *seq, u8 *ptr, s32 len); +void alSeqNextEvent(ALSeq *seq, ALEvent *event); +s32 alSeqGetTicks(ALSeq *seq); +f32 alSeqTicksToSec(ALSeq *seq, s32 ticks, u32 tempo); +u32 alSeqSecToTicks(ALSeq *seq, f32 sec, u32 tempo); +void alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks); +void alSeqSetLoc(ALSeq *seq, ALSeqMarker *marker); +void alSeqGetLoc(ALSeq *seq, ALSeqMarker *marker); +/* + * Compact Sequence data representation routines + */ +void alCSeqNew(ALCSeq *seq, u8 *ptr); +void alCSeqNextEvent(ALCSeq *seq,ALEvent *evt); +s32 alCSeqGetTicks(ALCSeq *seq); +f32 alCSeqTicksToSec(ALCSeq *seq, s32 ticks, u32 tempo); +u32 alCSeqSecToTicks(ALCSeq *seq, f32 sec, u32 tempo); +void alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); +void alCSeqSetLoc(ALCSeq *seq, ALCSeqMarker *marker); +void alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *marker); + +/* + * Sequence Player routines + */ +f32 alCents2Ratio(s32 cents); + +void alSeqpNew(ALSeqPlayer *seqp, ALSeqpConfig *config); +void alSeqpDelete(ALSeqPlayer *seqp); +void alSeqpSetSeq(ALSeqPlayer *seqp, ALSeq *seq); +ALSeq *alSeqpGetSeq(ALSeqPlayer *seqp); +void alSeqpPlay(ALSeqPlayer *seqp); +void alSeqpStop(ALSeqPlayer *seqp); +s32 alSeqpGetState(ALSeqPlayer *seqp); +void alSeqpSetBank(ALSeqPlayer *seqp, ALBank *b); +void alSeqpSetTempo(ALSeqPlayer *seqp, s32 tempo); +s32 alSeqpGetTempo(ALSeqPlayer *seqp); +s16 alSeqpGetVol(ALSeqPlayer *seqp); /* Master volume control */ +void alSeqpSetVol(ALSeqPlayer *seqp, s16 vol); +void alSeqpLoop(ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count); + +void alSeqpSetChlProgram(ALSeqPlayer *seqp, u8 chan, u8 prog); +s32 alSeqpGetChlProgram(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlFXMix(ALSeqPlayer *seqp, u8 chan, u8 fxmix); +u8 alSeqpGetChlFXMix(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlVol(ALSeqPlayer *seqp, u8 chan, u8 vol); +u8 alSeqpGetChlVol(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlPan(ALSeqPlayer *seqp, u8 chan, ALPan pan); +ALPan alSeqpGetChlPan(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlPriority(ALSeqPlayer *seqp, u8 chan, u8 priority); +u8 alSeqpGetChlPriority(ALSeqPlayer *seqp, u8 chan); +void alSeqpSendMidi(ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); + + +/* Maintain backwards compatibility with old routine names. */ +#define alSeqpSetProgram alSeqpSetChlProgram +#define alSeqpGetProgram alSeqpGetChlProgram +#define alSeqpSetFXMix alSeqpSetChlFXMix +#define alSeqpGetFXMix alSeqpGetChlFXMix +#define alSeqpSetPan alSeqpSetChlPan +#define alSeqpGetPan alSeqpGetChlPan +#define alSeqpSetChannelPriority alSeqpSetChlPriority +#define alSeqpGetChannelPriority alSeqpGetChlPriority + + + +/* + * Compressed Sequence Player routines + */ +void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config); +void alCSPDelete(ALCSPlayer *seqp); +void alCSPSetSeq(ALCSPlayer *seqp, ALCSeq *seq); +ALCSeq *alCSPGetSeq(ALCSPlayer *seqp); +void alCSPPlay(ALCSPlayer *seqp); +void alCSPStop(ALCSPlayer *seqp); +s32 alCSPGetState(ALCSPlayer *seqp); +void alCSPSetBank(ALCSPlayer *seqp, ALBank *b); +void alCSPSetTempo(ALCSPlayer *seqp, s32 tempo); +s32 alCSPGetTempo(ALCSPlayer *seqp); +s16 alCSPGetVol(ALCSPlayer *seqp); +void alCSPSetVol(ALCSPlayer *seqp, s16 vol); + +void alCSPSetChlProgram(ALCSPlayer *seqp, u8 chan, u8 prog); +s32 alCSPGetChlProgram(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlFXMix(ALCSPlayer *seqp, u8 chan, u8 fxmix); +u8 alCSPGetChlFXMix(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlPan(ALCSPlayer *seqp, u8 chan, ALPan pan); +ALPan alCSPGetChlPan(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlVol(ALCSPlayer *seqp, u8 chan, u8 vol); +u8 alCSPGetChlVol(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlPriority(ALCSPlayer *seqp, u8 chan, u8 priority); +u8 alCSPGetChlPriority(ALCSPlayer *seqp, u8 chan); +void alCSPSendMidi(ALCSPlayer *seqp, s32 ticks, u8 status, + u8 byte1, u8 byte2); + + +/* Maintain backwards compatibility with old routine names. */ +#define alCSPSetProgram alCSPSetChlProgram +#define alCSPGetProgram alCSPGetChlProgram +#define alCSPSetFXMix alCSPSetChlFXMix +#define alCSPGetFXMix alCSPGetChlFXMix +#define alCSPSetPan alCSPSetChlPan +#define alCSPGetPan alCSPGetChlPan +#define alCSPSetChannelPriority alCSPSetChlPriority +#define alCSPGetChannelPriority alCSPGetChlPriority + + + +/*********************************************************************** + * Sound Player stuff + ***********************************************************************/ + +typedef struct { + s32 maxSounds; + s32 maxEvents; + ALHeap *heap; +} ALSndpConfig; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALEventQueue evtq; + ALEvent nextEvent; + ALSynth *drvr; /* reference to the client driver */ + s32 target; + void *sndState; + s32 maxSounds; + ALMicroTime frameTime; + ALMicroTime nextDelta; /* microseconds to next callback */ + ALMicroTime curTime; +} ALSndPlayer; + +typedef s16 ALSndId; + +void alSndpNew(ALSndPlayer *sndp, ALSndpConfig *c); +void alSndpDelete(ALSndPlayer *sndp); + +ALSndId alSndpAllocate(ALSndPlayer *sndp, ALSound *sound); +void alSndpDeallocate(ALSndPlayer *sndp, ALSndId id); + +void alSndpSetSound(ALSndPlayer *sndp, ALSndId id); +ALSndId alSndpGetSound(ALSndPlayer *sndp); + +void alSndpPlay(ALSndPlayer *sndp); +void alSndpPlayAt(ALSndPlayer *sndp, ALMicroTime delta); +void alSndpStop(ALSndPlayer *sndp); + +void alSndpSetVol(ALSndPlayer *sndp, s16 vol); +void alSndpSetPitch(ALSndPlayer *sndp, f32 pitch); +void alSndpSetPan(ALSndPlayer *sndp, ALPan pan); +void alSndpSetPriority(ALSndPlayer *sndp, ALSndId id, u8 priority); + +void alSndpSetFXMix(ALSndPlayer *sndp, u8 mix); +s32 alSndpGetState(ALSndPlayer *sndp); + +#ifndef _FINALROM +void alParseAbiCL(Acmd *cmdList, u32 nbytes); +#endif +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !__LIB_AUDIO__ */ + + + diff --git a/include/2.0L/PR/mbi.h b/include/2.0L/PR/mbi.h new file mode 100755 index 00000000..9956ef20 --- /dev/null +++ b/include/2.0L/PR/mbi.h @@ -0,0 +1,98 @@ +#ifndef _MBI_H_ +#define _MBI_H_ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.135 $ + * $Date: 1997/11/26 00:30:54 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/mbi.h,v $ + * + **************************************************************************/ + +/* + * Header file for the Media Binary Interface + * + * NOTE: This file is included by the RSP microcode, so any C-specific + * constructs must be bracketed by #ifdef _LANGUAGE_C + * + */ + + +/* + * the SHIFT macros are used to build display list commands, inserting + * bit-fields into a 32-bit word. They take a value, a shift amount, + * and a width. + * + * For the left shift, the lower bits of the value are masked, + * then shifted left. + * + * For the right shift, the value is shifted right, then the lower bits + * are masked. + * + * (NOTE: _SHIFTL(v, 0, 32) won't work, just use an assignment) + * + */ +#define _SHIFTL(v, s, w) \ + ((unsigned int) (((unsigned int)(v) & ((0x01 << (w)) - 1)) << (s))) +#define _SHIFTR(v, s, w) \ + ((unsigned int)(((unsigned int)(v) >> (s)) & ((0x01 << (w)) - 1))) + +#define _SHIFT _SHIFTL /* old, for compatibility only */ + +#define G_ON (1) +#define G_OFF (0) + +/************************************************************************** + * + * Graphics Binary Interface + * + **************************************************************************/ + +#include + +/************************************************************************** + * + * Audio Binary Interface + * + **************************************************************************/ + +#include + +/************************************************************************** + * + * Task list + * + **************************************************************************/ + +#define M_GFXTASK 1 +#define M_AUDTASK 2 +#define M_VIDTASK 3 + +/************************************************************************** + * + * Segment macros and definitions + * + **************************************************************************/ + +#define NUM_SEGMENTS (16) +#define SEGMENT_OFFSET(a) ((unsigned int)(a) & 0x00ffffff) +#define SEGMENT_NUMBER(a) (((unsigned int)(a) << 4) >> 28) +#define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) + +#ifndef NULL +#define NULL 0 +#endif + +#endif /* !_MBI_H_ */ diff --git a/include/2.0L/PR/n_abi.h b/include/2.0L/PR/n_abi.h new file mode 100644 index 00000000..fc9c135c --- /dev/null +++ b/include/2.0L/PR/n_abi.h @@ -0,0 +1,122 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_ABI__ +#define __N_ABI__ + +/* + * BEGIN C-specific section: (typedef's) + */ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + + +/* + * Macros to assemble the audio command list + */ + +#define n_aADPCMdec(pkt, s, f, c, a, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(s, 0, 24)); \ + _a->words.w1 = (_SHIFTL(f, 28, 4) | _SHIFTL(c, 16, 12) | \ + _SHIFTL(a, 12, 4) | _SHIFTL(d, 0, 12)); \ +} + +#define n_aPoleFilter(pkt, f, g, t, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = (_SHIFTL(t, 24, 8) | \ + _SHIFTL((unsigned int)(s), 0, 24)); \ +} + +#define n_aEnvMixer(pkt, f, t, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8) |\ + _SHIFTL(t, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define n_aInterleave(pkt) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ +} + +#define n_aLoadBuffer(pkt, c, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL(c, 12, 12)|\ + _SHIFTL(d, 0, 12)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define n_aResample(pkt, s, f, p, i, o) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(s, 0, 24));\ + _a->words.w1 = (_SHIFTL(f, 30, 2) | _SHIFTL(p, 14, 16) | \ + _SHIFTL(i, 2, 12) | _SHIFTL(o, 0, 2)); \ +} + +#define n_aSaveBuffer(pkt, c, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL(c, 12, 12)|\ + _SHIFTL(d, 0, 12)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define n_aSetVolume(pkt, f, v, t, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \ +} + +#define n_aLoadADPCM(pkt, c, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ + _a->words.w1 = (unsigned int) d; \ +} + +#endif /* _LANGUAGE_C */ + +#endif /* __N_ABI__ */ + + + + + + + diff --git a/include/2.0L/PR/n_libaudio.h b/include/2.0L/PR/n_libaudio.h new file mode 100644 index 00000000..fb3d33ee --- /dev/null +++ b/include/2.0L/PR/n_libaudio.h @@ -0,0 +1,386 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_LIBAUDIO__ +#define __N_LIBAUDIO__ + +#include + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + + +/* + * Synthesis driver stuff + */ +typedef struct N_ALVoice_s { + ALLink node; + struct N_PVoice_s *pvoice; + ALWaveTable *table; + void *clientPrivate; + s16 state; + s16 priority; + s16 fxBus; + s16 unityPitch; +} N_ALVoice; + +typedef struct N_ALAuxBus_s{ + u8 unk0[0x48]; +}N_ALAuxBus; + +typedef struct N_ALParam_s { + struct N_ALParam_s *next; + s32 delta; + s16 type; + union { + f32 f; + s32 i; + } data; + union { + f32 f; + s32 i; + } moredata; + union { + f32 f; + s32 i; + } stillmoredata; + union { + f32 f; + s32 i; + } yetstillmoredata; + union { + f32 f; + s32 i; + } yetstillevenmoredata; + union { + f32 f; + s32 i; + } willthedataeverend; +} N_ALParam; + +typedef struct { + ALPlayer *head; /* client list head */ + //ALPlayer *n_seqp1; /* for fade in / fade out */ + //ALPlayer *n_seqp2; + //ALPlayer *n_sndp; + + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + struct N_ALParam_s *paramList; + struct N_ALMainBus_s *mainBus; + struct N_ALAuxBus_s *auxBus; + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; + s32 maxOutSamples; + s32 sv_dramout; + s32 sv_first; +} N_ALSynth; + + +void n_alSynAddPlayer(ALPlayer *client); +void n_alSynAddSndPlayer(ALPlayer *client); +void n_alSynAddSeqPlayer(ALPlayer *client); + +ALFxRef n_alSynAllocFX( s16 bus,ALSynConfig *c, ALHeap *hp); +s32 n_alSynAllocVoice( N_ALVoice *voice, ALVoiceConfig *vc); + + +void n_alSynFreeVoice(N_ALVoice *voice); +ALFxRef n_alSynGetFXRef( s16 bus, s16 index); +s16 n_alSynGetPriority( N_ALVoice *voice); +void n_alSynRemovePlayer( ALPlayer *client); +void n_alSynSetFXMix(N_ALVoice *v, u8 fxmix); +void n_alSynSetFXParam(ALFxRef fx, s16 paramID, void *param); +void n_alSynFreeFX(ALFxRef *fx); +void n_alSynSetPan(N_ALVoice *v, u8 pan); +void n_alSynSetPitch( N_ALVoice *v, f32 pitch); +void n_alSynSetPriority( N_ALVoice *voice, s16 priority); +void n_alSynSetVol( N_ALVoice *v, s16 volume, ALMicroTime t); +void n_alSynStartVoice(N_ALVoice *v, ALWaveTable *table); +void n_alSynStartVoiceParams(N_ALVoice *v, ALWaveTable *w,f32 pitch, s16 vol, + ALPan pan, u8 fxmix, ALMicroTime t); +void n_alSynStopVoice( N_ALVoice *v); + +void n_alSynNew(ALSynConfig *c); +void n_alSynDelete(void); + + +/* + * Audio Library (AL) stuff + */ +typedef struct { + N_ALSynth drvr; +} N_ALGlobals; + +extern N_ALGlobals *n_alGlobals; +extern N_ALSynth *n_syn; + +void n_alInit(N_ALGlobals *g, ALSynConfig *c); +void n_alClose(N_ALGlobals *glob); +Acmd *n_alAudioFrame(Acmd *cmdList, s32 *cmdLen, + s16 *outBuf, s32 outLen); + + +/* + * Sequence Player stuff + */ +typedef struct { + struct N_ALVoice_s *voice; +} N_ALNoteEvent; + + +typedef struct { + struct N_ALVoice_s *voice; + ALMicroTime delta; + u8 vol; +} N_ALVolumeEvent; + + +typedef struct { + struct N_ALVoiceState_s *vs; + void *oscState; + u8 chan; +} N_ALOscEvent; + + +typedef struct { + s16 type; + union { + ALMIDIEvent midi; + ALTempoEvent tempo; + ALEndEvent end; + N_ALNoteEvent note; + N_ALVolumeEvent vol; + ALSeqpLoopEvent loop; + ALSeqpVolEvent spvol; + ALSeqpPriorityEvent sppriority; + ALSeqpSeqEvent spseq; + ALSeqpBankEvent spbank; + N_ALOscEvent osc; + } msg; +} N_ALEvent; + + +typedef struct { + ALLink node; + ALMicroTime delta; + N_ALEvent evt; +} N_ALEventListItem; + +void n_alEvtqNew(ALEventQueue *evtq, N_ALEventListItem *items, s32 itemCount); +ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, N_ALEvent *evt); +void n_alEvtqPostEvent(ALEventQueue *evtq, N_ALEvent *evt, ALMicroTime delta, s32 foo); +void n_alEvtqFlushType(ALEventQueue *evtq, s16 type); + + +typedef struct N_ALVoiceState_s { + struct N_ALVoiceState_s *next;/* MUST be first */ + N_ALVoice voice; + ALSound *sound; + ALMicroTime envEndTime; /* time of envelope segment end */ + f32 pitch; /* currect pitch ratio */ + f32 vibrato; /* current value of the vibrato */ + u8 envGain; /* current envelope gain */ + u8 channel; /* channel assignment */ + u8 key; /* note on key number */ + u8 velocity; /* note on velocity */ + u8 envPhase; /* what envelope phase */ + u8 phase; + u8 tremelo; /* current value of the tremelo */ + u8 flags; /* bit 0 tremelo flag + bit 1 vibrato flag */ +} N_ALVoiceState; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + N_ALSynth *drvr; /* reference to the client driver */ + ALSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + N_ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + N_ALVoiceState *vAllocHead; /* list head for allocated voices */ + N_ALVoiceState *vAllocTail; /* list tail for allocated voices */ + N_ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + ALSeqMarker *loopStart; + ALSeqMarker *loopEnd; + s32 loopCount; /* -1 = loop forever, 0 = no loop */ +} N_ALSeqPlayer; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + N_ALSynth *drvr; /* reference to the client driver */ + ALCSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + N_ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + N_ALVoiceState *vAllocHead; /* list head for allocated voices */ + N_ALVoiceState *vAllocTail; /* list tail for allocated voices */ + N_ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; +} N_ALCSPlayer; + + +/* + * Sequence data representation routines + */ +void n_alSeqNextEvent(ALSeq *seq, N_ALEvent *event); +void n_alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks); + +void n_alCSeqNew(ALCSeq *seq, u8 *ptr); +void n_alCSeqNextEvent(ALCSeq *seq, N_ALEvent *evt); +void n_alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); + + +/* + * Sequence Player routines + */ +void n_alSeqpNew(N_ALSeqPlayer *seqp, ALSeqpConfig *config); +void n_alSeqpDelete(N_ALSeqPlayer *seqp); +u8 n_alSeqpGetChlVol(N_ALSeqPlayer *seqp, u8 chan); +u8 n_alSeqpGetChlFXMix(N_ALSeqPlayer *seqp, u8 chan); +ALPan n_alSeqpGetChlPan(N_ALSeqPlayer *seqp, u8 chan); +u8 n_alSeqpGetChlPriority(N_ALSeqPlayer *seqp, u8 chan); +s32 n_alSeqpGetChlProgram(N_ALSeqPlayer *seqp, u8 chan); +ALSeq *n_alSeqpGetSeq(N_ALSeqPlayer *seqp); +s32 n_alSeqpGetState(N_ALSeqPlayer *seqp); +s32 n_alSeqpGetTempo(N_ALSeqPlayer *seqp); +s16 n_alSeqpGetVol(N_ALSeqPlayer *seqp); /* Master volume control */ +void n_alSeqpPlay(N_ALSeqPlayer *seqp); +void n_alSeqpSendMidi(N_ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); +void n_alSeqpSetBank(N_ALSeqPlayer *seqp, ALBank *b); +void n_alSeqpSetChlVol(N_ALSeqPlayer *seqp, u8 chan, u8 vol); +void n_alSeqpSetChlFXMix(N_ALSeqPlayer *seqp, u8 chan, u8 fxmix); +void n_alSeqpSetChlPan(N_ALSeqPlayer *seqp, u8 chan, ALPan pan); +void n_alSeqpSetChlPriority(N_ALSeqPlayer *seqp, u8 chan, u8 priority); +void n_alSeqpSetChlProgram(N_ALSeqPlayer *seqp, u8 chan, u8 prog); +void n_alSeqpSetSeq(N_ALSeqPlayer *seqp, ALSeq *seq); +void n_alSeqpSetTempo(N_ALSeqPlayer *seqp, s32 tempo); +void n_alSeqpSetVol(N_ALSeqPlayer *seqp, s16 vol); +void n_alSeqpStop(N_ALSeqPlayer *seqp); +void n_alSeqpLoop(N_ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count); + + +/* + * Compressed Sequence Player routines + */ +void n_alCSPNew(N_ALCSPlayer *seqp, ALSeqpConfig *config); +void n_alCSPDelete(N_ALCSPlayer *seqp); +u8 n_alCSPGetChlVol(N_ALCSPlayer *seqp, u8 chan); +u8 n_alCSPGetChlFXMix(N_ALCSPlayer *seqp, u8 chan); +ALPan n_alCSPGetChlPan(N_ALCSPlayer *seqp, u8 chan); +u8 n_alCSPGetChlPriority(N_ALCSPlayer *seqp, u8 chan); +s32 n_alCSPGetChlProgram(N_ALCSPlayer *seqp, u8 chan); +ALCSeq *n_alCSPGetSeq(N_ALCSPlayer *seqp); +s32 n_alCSPGetState(N_ALCSPlayer *seqp); +s32 n_alCSPGetTempo(N_ALCSPlayer *seqp); +s16 n_alCSPGetVol(N_ALCSPlayer *seqp); +void n_alCSPPlay(N_ALCSPlayer *seqp); +void n_alCSPSendMidi(N_ALCSPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); +void n_alCSPSetBank(N_ALCSPlayer *seqp, ALBank *b); +void n_alCSPSetChlVol(N_ALCSPlayer *seqp, u8 chan, u8 vol); +void n_alCSPSetChlFXMix(N_ALCSPlayer *seqp, u8 chan, u8 fxmix); +void n_alCSPSetChlPan(N_ALCSPlayer *seqp, u8 chan, ALPan pan); +void n_alCSPSetChlPriority(N_ALCSPlayer *seqp, u8 chan, u8 priority); +void n_alCSPSetChlProgram(N_ALCSPlayer *seqp, u8 chan, u8 prog); +void n_alCSPSetSeq(N_ALCSPlayer *seqp, ALCSeq *seq); +void n_(N_ALCSPlayer *seqp, s32 tempo); +void n_alCSPSetVol(N_ALCSPlayer *seqp, s16 vol); +void n_alCSPStop(N_ALCSPlayer *seqp); + + +/* + * Sound Player stuff + */ +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALEventQueue evtq; + N_ALEvent nextEvent; + N_ALSynth *drvr; /* reference to the client driver */ + s32 target; + void *sndState; + s32 maxSounds; + ALMicroTime frameTime; + ALMicroTime nextDelta; /* microseconds to next callback */ + ALMicroTime curTime; +} N_ALSndPlayer; + +void n_alSndpNew(N_ALSndPlayer *sndp, ALSndpConfig *c); +void n_alSndpDelete(void); +ALSndId n_alSndpAllocate(ALSound *sound); +void n_alSndpDeallocate(ALSndId id); +s32 n_alSndpGetState(void); +void n_alSndpPlay(void); +void n_alSndpPlayAt(ALMicroTime delta); +void n_alSndpSetFXMix(u8 mix); +void n_alSndpSetPan(ALPan pan); +void n_alSndpSetPitch(f32 pitch); +void n_alSndpSetPriority(ALSndId id, u8 priority); +void n_alSndpSetVol(s16 vol); +void n_alSndpStop(void); +ALSndId n_alSndpGetSound(void); +void n_alSndpSetSound(ALSndId id); + + +/* + * for n_audio micro code + */ +extern long long int n_aspMainTextStart[], n_aspMainTextEnd[]; +extern long long int n_aspMainDataStart[], n_aspMainDataEnd[]; + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* __N_LIBAUDIO__ */ diff --git a/include/2.0L/PR/n_libaudio_s_to_n.h b/include/2.0L/PR/n_libaudio_s_to_n.h new file mode 100644 index 00000000..5726c771 --- /dev/null +++ b/include/2.0L/PR/n_libaudio_s_to_n.h @@ -0,0 +1,120 @@ +#define ALVoice N_ALVoice +#define ALSynth N_ALSynth +#define ALGlobals n_alGlobals + +#define n_alSynAddPlayer( a, b) n_alSynAddPlayer( b) +#define alSynAllocFX( a, b, c, d) n_alSynAllocFX( b, c, d) +#define alSynAllocVoice( a, b, c) n_alSynAllocVoice( b, c) +#define alSynDelete( a) n_alSynDelete() +#define alSynFreeVoice( a, b) n_alSynFreeVoice( b) +#define alSynGetFXRef( a, b, c) n_alSynGetFXRef( b, c) +#define alSynGetPriority( a, b) n_alSynGetPriority( b) +#define alSynRemovePlayer( a, b) n_alSynRemovePlayer( b) +#define alSynSetFXMix( a, b, c) n_alSynSetFXMix( b, c) +#define alSynSetFXParam( a, b, c, d) n_alSynSetFXParam( b, c, d) +#define alSynFreeFX( a, b) n_alSynFreeFX( b) +#define alSynSetPan( a, b, c) n_alSynSetPan( b, c) +#define alSynSetPitch( a, b, c) n_alSynSetPitch( b, c) +#define alSynSetPriority( a, b, c) n_alSynSetPriority( b, c) +#define alSynSetVol( a, b, c, d) n_alSynSetVol( b, c, d) +#define alSynStartVoice( a, b, c) n_alSynStartVoice( b, c) +#define n_alSynStartVoiceParams( a, b, c, d, e, f, g, h) \ + n_n_alSynStartVoiceParams( b, c, d, e, f, g, h) +#define alSynStopVoice( a, b) n_alSynStopVoice( b) +#define alSynNew( a, b) n_alSynNew( b) + +#define alInit n_alInit +#define alClose n_alClose +#define alAudioFrame n_alAudioFrame + +#define ALVoiceState N_ALVoiceState +#define ALSeqPlayer N_ALSeqPlayer +#define ALCSPlayer N_ALCSPlayer + +#define alSeqNextEvent n_alSeqNextEvent +#define alSeqNewMarker n_alSeqNewMarker + +#define alCSeqNew n_alCSeqNew +#define alCSeqNextEvent n_alCSeqNextEvent +#define alCSeqNewMarker n_alCSeqNewMarker + +#define alSeqpNew n_alSeqpNew +#define alSeqpDelete n_alSeqpDelete +#define alSeqpGetChlVol n_alSeqpGetChlVol +#define alSeqpGetChlFXMix n_alSeqpGetChlFXMix +#define alSeqpGetChlPan n_alSeqpGetChlPan +#define alSeqpGetChlPriority n_alSeqpGetChlPriority +#define alSeqpGetChlProgram n_alSeqpGetChlProgram +#define alSeqpGetSeq n_alSeqpGetSeq +#define alSeqpGetState n_alSeqpGetState +#define alSeqpGetTempo n_alSeqpGetTempo +#define alSeqpGetVol n_alSeqpGetVol +#define alSeqpPlay n_alSeqpPlay +#define alSeqpSendMidi n_alSeqpSendMidi +#define alSeqpSetBank n_alSeqpSetBank +#define alSeqpSetChlVol n_alSeqpSetChlVol +#define alSeqpSetChlFXMix n_alSeqpSetChlFXMix +#define alSeqpSetChlPan n_alSeqpSetChlPan +#define alSeqpSetChlPriority n_alSeqpSetChlPriority +#define alSeqpSetChlProgram n_alSeqpSetChlProgram +#define alSeqpSetSeq n_alSeqpSetSeq +#define alSeqpSetTempo n_alSeqpSetTempo +#define alSeqpSetVol n_alSeqpSetVol +#define alSeqpStop n_alSeqpStop +#define alSeqpLoop n_alSeqpLoop + +#define alCSPNew n_alCSPNew +#define alCSPDelete n_alCSPDelete +#define alCSPGetChlVol n_alCSPGetChlVol +#define alCSPGetChlFXMix n_alCSPGetChlFXMix +#define alCSPGetChlPan n_alCSPGetChlPan +#define alCSPGetChlPriority n_alCSPGetChlPriority +#define alCSPGetChlProgram n_alCSPGetChlProgram +#define alCSPGetSeq n_alCSPGetSeq +#define alCSPGetState n_alCSPGetState +#define alCSPGetTempo n_alCSPGetTempo +#define alCSPGetVol n_alCSPGetVol +#define alCSPPlay n_alCSPPlay +#define alCSPSendMidi n_alCSPSendMidi +#define alCSPSetBank n_alCSPSetBank +#define alCSPSetChlVol n_alCSPSetChlVol +#define alCSPSetChlFXMix n_alCSPSetChlFXMix +#define alCSPSetChlPan n_alCSPSetChlPan +#define alCSPSetChlPriority n_alCSPSetChlPriority +#define alCSPSetChlProgram n_alCSPSetChlProgram +#define alCSPSetSeq n_alCSPSetSeq +#define n_ +#define alCSPSetVol n_alCSPSetVol +#define alCSPStop n_alCSPStop + +#define ALSoundState N_ALSoundState +#define ALSndpEvent N_ALSndpEvent +#define ALSndPlayer N_ALSndPlayer + +#define alSndpNew( a, b) n_alSndpNew( a, b) +#define alSndpDelete( a) n_alSndpDelete() +#define alSndpAllocate( a, b) n_alSndpAllocate( b) +#define alSndpDeallocate( a, b) n_alSndpDeallocate( b) +#define alSndpGetState( a) n_alSndpGetState() +#define alSndpPlay( a) n_alSndpPlay() +#define alSndpPlayAt( a, b) n_alSndpPlayAt( b) +#define alSndpSetFXMix( a, b) n_alSndpSetFXMix( b) +#define alSndpSetPan( a, b) n_alSndpSetPan( b) +#define alSndpSetPitch( a, b) n_alSndpSetPitch( b) +#define alSndpSetPriority( a, b, c) n_alSndpSetPriority( b, c) +#define alSndpSetVol( a, b) n_alSndpSetVol( b) +#define alSndpStop( a) n_alSndpStop() +#define alSndpGetSound( a) n_alSndpGetSound() +#define alSndpSetSound( a, b) n_alSndpSetSound( b) + +#define alEvtqNew n_alEvtqNew +#define alEvtqNextEvent n_alEvtqNextEvent +#define alEvtqPostEvent n_alEvtqPostEvent +#define alEvtqFlushType n_alEvtqFlushType +#define alEvtqPrintEvtQueue n_alEvtqPrintEvtQueue +#define alEvtqPrintAllocEvts n_alEvtqPrintAllocEvts + + + + + diff --git a/include/2.0L/PR/os.h b/include/2.0L/PR/os.h new file mode 100755 index 00000000..353b5b2e --- /dev/null +++ b/include/2.0L/PR/os.h @@ -0,0 +1,1000 @@ + +/*==================================================================== + * os.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.149 $ + * $Date: 1997/12/15 04:30:52 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/os.h,v $ + * + **************************************************************************/ + + +#ifndef _OS_H_ +#define _OS_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef s32 OSPri; +typedef s32 OSId; +typedef union { struct { f32 f_odd; f32 f_even; } f; f64 d; } __OSfp; + +typedef struct { + u64 at, v0, v1, a0, a1, a2, a3; + u64 t0, t1, t2, t3, t4, t5, t6, t7; + u64 s0, s1, s2, s3, s4, s5, s6, s7; + u64 t8, t9, gp, sp, s8, ra; + u64 lo, hi; + u32 sr, pc, cause, badvaddr, rcp; + u32 fpcsr; + __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; + __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; +} __OSThreadContext; + +typedef struct OSThread_s { + struct OSThread_s *next; /* run/mesg queue link */ + OSPri priority; /* run/mesg queue priority */ + struct OSThread_s **queue; /* queue thread is on */ + struct OSThread_s *tlnext; /* all threads queue link */ + u16 state; /* OS_STATE_* */ + u16 flags; /* flags for rmon */ + OSId id; /* id for debugging */ + int fp; /* thread has used fp unit */ + __OSThreadContext context; /* register/interrupt mask */ +} OSThread; + +typedef u32 OSEvent; +typedef u32 OSIntMask; +typedef u32 OSPageMask; +typedef u32 OSHWIntr; + +/* + * Structure for message + */ +typedef void * OSMesg; + +/* + * Structure for message queue + */ +typedef struct OSMesgQueue_s { + OSThread *mtqueue; /* Queue to store threads blocked + on empty mailboxes (receive) */ + OSThread *fullqueue; /* Queue to store threads blocked + on full mailboxes (send) */ + s32 validCount; /* Contains number of valid message */ + s32 first; /* Points to first valid message */ + s32 msgCount; /* Contains total # of messages */ + OSMesg *msg; /* Points to message buffer array */ +} OSMesgQueue; + +/* + * Structure for Enhanced PI interface + */ + +/* + * OSTranxInfo is set up for Leo Disk DMA. This info will be maintained + * by exception handler. This is how the PIMGR and the ISR communicate. + */ + +typedef struct { + u32 errStatus; /* error status */ + void *dramAddr; /* RDRAM buffer address (DMA) */ + void *C2Addr; /* C2 buffer address */ + u32 sectorSize; /* size of transfering sector */ + u32 C1ErrNum; /* total # of C1 errors */ + u32 C1ErrSector[4]; /* error sectors */ +} __OSBlockInfo; + +typedef struct { + u32 cmdType; /* for disk only */ + u16 transferMode; /* Block, Track, or sector? */ + u16 blockNum; /* which block is transfering */ + s32 sectorNum; /* which sector is transfering */ + u32 devAddr; /* Device buffer address */ + u32 bmCtlShadow; /* asic bm_ctl(510) register shadow ram */ + u32 seqCtlShadow; /* asic seq_ctl(518) register shadow ram */ + __OSBlockInfo block[2]; /* bolck transfer info */ +} __OSTranxInfo; + + +typedef struct OSPiHandle_s { + struct OSPiHandle_s *next; /* point to next handle on the table */ + u8 type; /* DEVICE_TYPE_BULK for disk */ + u8 latency; /* domain latency */ + u8 pageSize; /* domain page size */ + u8 relDuration; /* domain release duration */ + u8 pulse; /* domain pulse width */ + u8 domain; /* which domain */ + u32 baseAddress; /* Domain address */ + u32 speed; /* for roms only */ + /* The following are "private" elements" */ + __OSTranxInfo transferInfo; /* for disk only */ +} OSPiHandle; + +typedef struct { + u8 type; + u32 address; +} OSPiInfo; + +/* + * Structure for I/O message block + */ +typedef struct { + u16 type; /* Message type */ + u8 pri; /* Message priority (High or Normal) */ + u8 status; /* Return status */ + OSMesgQueue *retQueue; /* Return message queue to notify I/O + * completion */ +} OSIoMesgHdr; + +typedef struct { + OSIoMesgHdr hdr; /* Message header */ + void * dramAddr; /* RDRAM buffer address (DMA) */ + u32 devAddr; /* Device buffer address (DMA) */ + u32 size; /* DMA transfer size in bytes */ + OSPiHandle *piHandle; /* PI device handle */ +} OSIoMesg; + +/* + * Structure for device manager block + */ +typedef struct { + s32 active; /* Status flag */ + OSThread *thread; /* Calling thread */ + OSMesgQueue *cmdQueue; /* Command queue */ + OSMesgQueue *evtQueue; /* Event queue */ + OSMesgQueue *acsQueue; /* Access queue */ + /* Raw DMA routine */ + s32 (*dma)(s32, u32, void *, u32); + s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); +} OSDevMgr; + + +/* + * Structure to store VI register values that remain the same between 2 fields + */ +typedef struct { + u32 ctrl; + u32 width; + u32 burst; + u32 vSync; + u32 hSync; + u32 leap; + u32 hStart; + u32 xScale; + u32 vCurrent; +} OSViCommonRegs; + + +/* + * Structure to store VI register values that change between fields + */ +typedef struct { + u32 origin; + u32 yScale; + u32 vStart; + u32 vBurst; + u32 vIntr; +} OSViFieldRegs; + + +/* + * Structure for VI mode + */ +typedef struct { + u8 type; /* Mode type */ + OSViCommonRegs comRegs; /* Common registers for both fields */ + OSViFieldRegs fldRegs[2]; /* Registers for Field 1 & 2 */ +} OSViMode; + +/* + * Structure for time value + */ +typedef u64 OSTime; + +/* + * Structure for interval timer + */ +typedef struct OSTimer_s { + struct OSTimer_s *next; /* point to next timer in list */ + struct OSTimer_s *prev; /* point to previous timer in list */ + OSTime interval; /* duration set by user */ + OSTime value; /* time remaining before */ + /* timer fires */ + OSMesgQueue *mq; /* Message Queue */ + OSMesg msg; /* Message to send */ +} OSTimer; + +/* + * Structure for controllers + */ + +typedef struct { + u16 type; /* Controller Type */ + u8 status; /* Controller status */ + u8 errno; +}OSContStatus; + +typedef struct { + u16 button; + s8 stick_x; /* -80 <= stick_x <= 80 */ + s8 stick_y; /* -80 <= stick_y <= 80 */ + u8 errno; +} OSContPad; + +typedef struct { + void *address; /* Ram pad Address: 11 bits */ + u8 databuffer[32]; /* address of the data buffer */ + u8 addressCrc; /* CRC code for address */ + u8 dataCrc; /* CRC code for data */ + u8 errno; +} OSContRamIo; + +/* + * Structure for file system + */ + + + +typedef struct { + int status; + OSMesgQueue *queue; + int channel; + u8 id[32]; + u8 label[32]; + int version; + int dir_size; + int inode_table; /* block location */ + int minode_table; /* mirrioring inode_table */ + int dir_table; /* block location */ + int inode_start_page; /* page # */ + u8 banks; + u8 activebank; +} OSPfs; + + +typedef struct { + u32 file_size; /* bytes */ + u32 game_code; + u16 company_code; + char ext_name[4]; + char game_name[16]; +} OSPfsState; + +/* + * Structure for Profiler + */ +typedef struct { + u16 *histo_base; /* histogram base */ + u32 histo_size; /* histogram size */ + u32 *text_start; /* start of text segment */ + u32 *text_end; /* end of text segment */ +} OSProf; + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* Thread states */ + +#define OS_STATE_STOPPED 1 +#define OS_STATE_RUNNABLE 2 +#define OS_STATE_RUNNING 4 +#define OS_STATE_WAITING 8 + +/* Events */ +#ifdef _FINALROM +#define OS_NUM_EVENTS 15 +#else +#define OS_NUM_EVENTS 23 +#endif + +#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ +#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ +#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ +#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ +#define OS_EVENT_SP 4 /* SP task done interrupt */ +#define OS_EVENT_SI 5 /* SI (controller) interrupt */ +#define OS_EVENT_AI 6 /* AI interrupt */ +#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ +#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ +#define OS_EVENT_DP 9 /* DP full sync interrupt */ +#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ +#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ +#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ +#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ +#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ +#ifndef _FINALROM +#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ +#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ +#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ +#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ +#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ +#define OS_EVENT_RDB_DBG_DONE 20 +#define OS_EVENT_RDB_FLUSH_PROF 21 +#define OS_EVENT_RDB_ACK_PROF 22 +#endif + +/* Flags for debugging purpose */ + +#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */ +#define OS_FLAG_FAULT 2 /* CPU fault has occurred */ + +/* Interrupt masks */ + +#define OS_IM_NONE 0x00000001 +#define OS_IM_SW1 0x00000501 +#define OS_IM_SW2 0x00000601 +#define OS_IM_CART 0x00000c01 +#define OS_IM_PRENMI 0x00001401 +#define OS_IM_RDBWRITE 0x00002401 +#define OS_IM_RDBREAD 0x00004401 +#define OS_IM_COUNTER 0x00008401 +#define OS_IM_CPU 0x0000ff01 +#define OS_IM_SP 0x00010401 +#define OS_IM_SI 0x00020401 +#define OS_IM_AI 0x00040401 +#define OS_IM_VI 0x00080401 +#define OS_IM_PI 0x00100401 +#define OS_IM_DP 0x00200401 +#define OS_IM_ALL 0x003fff01 +#define RCP_IMASK 0x003f0000 +#define RCP_IMASKSHIFT 16 + +/* Recommended thread priorities for the system threads */ + +#define OS_PRIORITY_MAX 255 +#define OS_PRIORITY_VIMGR 254 +#define OS_PRIORITY_RMON 250 +#define OS_PRIORITY_RMONSPIN 200 +#define OS_PRIORITY_PIMGR 150 +#define OS_PRIORITY_SIMGR 140 +#define OS_PRIORITY_APPMAX 127 +#define OS_PRIORITY_IDLE 0 /* Must be 0 */ + + +/* Flags to turn blocking on/off when sending/receiving message */ + +#define OS_MESG_NOBLOCK 0 +#define OS_MESG_BLOCK 1 + +/* Flags to indicate direction of data transfer */ + +#define OS_READ 0 /* device -> RDRAM */ +#define OS_WRITE 1 /* device <- RDRAM */ +#define OS_OTHERS 2 /* for Leo disk only */ + +/* + * I/O message types + */ +#define OS_MESG_TYPE_BASE (10) +#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE+0) +#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE+1) +#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE+2) +#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE+3) +#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE+4) +#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE+5) +#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE+6) + +/* + * I/O message priority + */ +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +/* + * Page size argument for TLB routines + */ +#define OS_PM_4K 0x0000000 +#define OS_PM_16K 0x0006000 +#define OS_PM_64K 0x001e000 +#define OS_PM_256K 0x007e000 +#define OS_PM_1M 0x01fe000 +#define OS_PM_4M 0x07fe000 +#define OS_PM_16M 0x1ffe000 + +/* + * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager), + * SIM (SI Manager) + * + */ +#define OS_PIM_STACKSIZE 4096 +#define OS_VIM_STACKSIZE 4096 +#define OS_SIM_STACKSIZE 4096 + +#define OS_MIN_STACKSIZE 72 + +/* + * Values for osTvType + */ +#define OS_TV_PAL 0 +#define OS_TV_NTSC 1 +#define OS_TV_MPAL 2 + +/* + * Video Interface (VI) mode type + */ +#define OS_VI_NTSC_LPN1 0 /* NTSC */ +#define OS_VI_NTSC_LPF1 1 +#define OS_VI_NTSC_LAN1 2 +#define OS_VI_NTSC_LAF1 3 +#define OS_VI_NTSC_LPN2 4 +#define OS_VI_NTSC_LPF2 5 +#define OS_VI_NTSC_LAN2 6 +#define OS_VI_NTSC_LAF2 7 +#define OS_VI_NTSC_HPN1 8 +#define OS_VI_NTSC_HPF1 9 +#define OS_VI_NTSC_HAN1 10 +#define OS_VI_NTSC_HAF1 11 +#define OS_VI_NTSC_HPN2 12 +#define OS_VI_NTSC_HPF2 13 + +#define OS_VI_PAL_LPN1 14 /* PAL */ +#define OS_VI_PAL_LPF1 15 +#define OS_VI_PAL_LAN1 16 +#define OS_VI_PAL_LAF1 17 +#define OS_VI_PAL_LPN2 18 +#define OS_VI_PAL_LPF2 19 +#define OS_VI_PAL_LAN2 20 +#define OS_VI_PAL_LAF2 21 +#define OS_VI_PAL_HPN1 22 +#define OS_VI_PAL_HPF1 23 +#define OS_VI_PAL_HAN1 24 +#define OS_VI_PAL_HAF1 25 +#define OS_VI_PAL_HPN2 26 +#define OS_VI_PAL_HPF2 27 + +#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ +#define OS_VI_MPAL_LPF1 29 +#define OS_VI_MPAL_LAN1 30 +#define OS_VI_MPAL_LAF1 31 +#define OS_VI_MPAL_LPN2 32 +#define OS_VI_MPAL_LPF2 33 +#define OS_VI_MPAL_LAN2 34 +#define OS_VI_MPAL_LAF2 35 +#define OS_VI_MPAL_HPN1 36 +#define OS_VI_MPAL_HPF1 37 +#define OS_VI_MPAL_HAN1 38 +#define OS_VI_MPAL_HAF1 39 +#define OS_VI_MPAL_HPN2 40 +#define OS_VI_MPAL_HPF2 41 + +/* + * Video Interface (VI) special features + */ +#define OS_VI_GAMMA_ON 0x0001 +#define OS_VI_GAMMA_OFF 0x0002 +#define OS_VI_GAMMA_DITHER_ON 0x0004 +#define OS_VI_GAMMA_DITHER_OFF 0x0008 +#define OS_VI_DIVOT_ON 0x0010 +#define OS_VI_DIVOT_OFF 0x0020 +#define OS_VI_DITHER_FILTER_ON 0x0040 +#define OS_VI_DITHER_FILTER_OFF 0x0080 + +/* + * Video Interface (VI) mode attribute bit + */ +#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ +#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ +#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ +#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ +#define OS_VI_BIT_ANTIALIAS 0x0010 +#define OS_VI_BIT_POINTSAMPLE 0x0020 +#define OS_VI_BIT_16PIXEL 0x0040 +#define OS_VI_BIT_32PIXEL 0x0080 +#define OS_VI_BIT_LORES 0x0100 +#define OS_VI_BIT_HIRES 0x0200 +#define OS_VI_BIT_NTSC 0x0400 +#define OS_VI_BIT_PAL 0x0800 + +/* + * Leo Disk + */ + +/* transfer mode */ + +#define LEO_BLOCK_MODE 1 +#define LEO_TRACK_MODE 2 +#define LEO_SECTOR_MODE 3 + +/* + * Controllers number + */ + +#ifndef _HW_VERSION_1 +#define MAXCONTROLLERS 4 +#else +#define MAXCONTROLLERS 6 +#endif + +/* controller errors */ +#define CONT_NO_RESPONSE_ERROR 0x8 +#define CONT_OVERRUN_ERROR 0x4 +#ifdef _HW_VERSION_1 +#define CONT_FRAME_ERROR 0x2 +#define CONT_COLLISION_ERROR 0x1 +#endif + +/* Controller type */ + +#define CONT_ABSOLUTE 0x0001 +#define CONT_RELATIVE 0x0002 +#define CONT_JOYPORT 0x0004 +#define CONT_EEPROM 0x8000 +#define CONT_EEP16K 0x4000 +#define CONT_TYPE_MASK 0x1f07 +#define CONT_TYPE_NORMAL 0x0005 +#define CONT_TYPE_MOUSE 0x0002 + +/* Controller status */ + +#define CONT_CARD_ON 0x01 +#define CONT_CARD_PULL 0x02 +#define CONT_ADDR_CRC_ER 0x04 +#define CONT_EEPROM_BUSY 0x80 + +/* EEPROM TYPE */ + +#define EEPROM_TYPE_4K 0x01 +#define EEPROM_TYPE_16K 0x02 + +/* Buttons */ + +#define CONT_A 0x8000 +#define CONT_B 0x4000 +#define CONT_G 0x2000 +#define CONT_START 0x1000 +#define CONT_UP 0x0800 +#define CONT_DOWN 0x0400 +#define CONT_LEFT 0x0200 +#define CONT_RIGHT 0x0100 +#define CONT_L 0x0020 +#define CONT_R 0x0010 +#define CONT_E 0x0008 +#define CONT_D 0x0004 +#define CONT_C 0x0002 +#define CONT_F 0x0001 + +/* Nintendo's official button names */ + +#define A_BUTTON CONT_A +#define B_BUTTON CONT_B +#define L_TRIG CONT_L +#define R_TRIG CONT_R +#define Z_TRIG CONT_G +#define START_BUTTON CONT_START +#define U_JPAD CONT_UP +#define L_JPAD CONT_LEFT +#define R_JPAD CONT_RIGHT +#define D_JPAD CONT_DOWN +#define U_CBUTTONS CONT_E +#define L_CBUTTONS CONT_C +#define R_CBUTTONS CONT_F +#define D_CBUTTONS CONT_D + +/* File System size */ +#define OS_PFS_VERSION 0x0200 +#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) +#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) + +#define PFS_FILE_NAME_LEN 16 +#define PFS_FILE_EXT_LEN 4 +#define BLOCKSIZE 32 /* bytes */ +#define PFS_ONE_PAGE 8 /* blocks */ +#define PFS_MAX_BANKS 62 + +/* File System flag */ + +#define PFS_READ 0 +#define PFS_WRITE 1 +#define PFS_CREATE 2 + +/* File System status */ +#define PFS_INITIALIZED 0x1 +#define PFS_CORRUPTED 0x2 /* File system was corrupted */ + +/* File System error number */ + +#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */ +#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */ + /* different one */ +#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */ +#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR +#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/ +#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/ +#define PFS_DATA_FULL 7 /* no free pages on ram pack */ +#define PFS_DIR_FULL 8 /* no free directories on ram pack*/ +#define PFS_ERR_EXIST 9 /* file exists */ +#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ +#define PFS_ERR_DEVICE 11 /* wrong device type*/ + +/* definition for EEPROM */ + +#define EEPROM_MAXBLOCKS 64 +#define EEP16K_MAXBLOCKS 256 +#define EEPROM_BLOCK_SIZE 8 + +/* + * PI/EPI + */ +#define PI_DOMAIN1 0 +#define PI_DOMAIN2 1 + +/* + * Profiler constants + */ +#define PROF_MIN_INTERVAL 50 /* microseconds */ + +/* + * Boot addresses + */ +#define BOOT_ADDRESS_ULTRA 0x80000400 +#define BOOT_ADDRESS_COSIM 0x80002000 +#define BOOT_ADDRESS_EMU 0x20010000 +#define BOOT_ADDRESS_INDY 0x88100000 + +/* + * Size of buffer the retains contents after NMI + */ +#define OS_APP_NMI_BUFSIZE 64 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* PARTNER-N64 */ +#ifdef PTN64 +#define osReadHost osReadHost_pt +#define osWriteHost osWriteHost_pt +#endif + +/* Get count of valid messages in queue */ +#define MQ_GET_COUNT(mq) ((mq)->validCount) + +/* Figure out if message queue is empty or full */ +#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) +#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) + +/* + * CPU counter increments at 3/4 of bus clock rate: + * + * Bus Clock Proc Clock Counter (1/2 Proc Clock) + * --------- ---------- ------------------------ + * 62.5 Mhz 93.75 Mhz 46.875 Mhz + */ +extern u64 osClockRate; + +#define OS_CLOCK_RATE 62500000LL +#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) +#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) +#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) +#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) +#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) + +/************************************************************************** + * + * Extern variables + * + */ +extern OSViMode osViModeTable[]; /* Global VI mode table */ + +extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */ +extern OSViMode osViModeNtscLpf1; +extern OSViMode osViModeNtscLan1; +extern OSViMode osViModeNtscLaf1; +extern OSViMode osViModeNtscLpn2; +extern OSViMode osViModeNtscLpf2; +extern OSViMode osViModeNtscLan2; +extern OSViMode osViModeNtscLaf2; +extern OSViMode osViModeNtscHpn1; +extern OSViMode osViModeNtscHpf1; +extern OSViMode osViModeNtscHan1; +extern OSViMode osViModeNtscHaf1; +extern OSViMode osViModeNtscHpn2; +extern OSViMode osViModeNtscHpf2; + +extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */ +extern OSViMode osViModePalLpf1; +extern OSViMode osViModePalLan1; +extern OSViMode osViModePalLaf1; +extern OSViMode osViModePalLpn2; +extern OSViMode osViModePalLpf2; +extern OSViMode osViModePalLan2; +extern OSViMode osViModePalLaf2; +extern OSViMode osViModePalHpn1; +extern OSViMode osViModePalHpf1; +extern OSViMode osViModePalHan1; +extern OSViMode osViModePalHaf1; +extern OSViMode osViModePalHpn2; +extern OSViMode osViModePalHpf2; + +extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */ +extern OSViMode osViModeMpalLpf1; +extern OSViMode osViModeMpalLan1; +extern OSViMode osViModeMpalLaf1; +extern OSViMode osViModeMpalLpn2; +extern OSViMode osViModeMpalLpf2; +extern OSViMode osViModeMpalLan2; +extern OSViMode osViModeMpalLaf2; +extern OSViMode osViModeMpalHpn1; +extern OSViMode osViModeMpalHpf1; +extern OSViMode osViModeMpalHan1; +extern OSViMode osViModeMpalHaf1; +extern OSViMode osViModeMpalHpn2; +extern OSViMode osViModeMpalHpf2; + +extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ +extern void *osRomBase; /* Rom base address of the game image */ +extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ +extern s32 osResetType; /* 0 = cold reset, 1 = NMI */ +extern s32 osCicId; +extern s32 osVersion; +extern u32 osMemSize; /* Memory Size */ +extern s32 osAppNMIBuffer[]; + +extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ +extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */ +extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/ + + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Thread operations */ + +extern void osCreateThread(OSThread *, OSId, void (*)(void *), + void *, void *, OSPri); +extern void osDestroyThread(OSThread *); +extern void osYieldThread(void); +extern void osStartThread(OSThread *); +extern void osStopThread(OSThread *); +extern OSId osGetThreadId(OSThread *); +extern void osSetThreadPri(OSThread *, OSPri); +extern OSPri osGetThreadPri(OSThread *); + +/* Message operations */ + +extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); +extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); +extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); +extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); + +/* Event operations */ + +extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); + +/* Interrupt operations */ + +extern OSIntMask osGetIntMask(void); +extern OSIntMask osSetIntMask(OSIntMask); + +/* RDB port operations */ + +extern void osInitRdb(u8 *sendBuf, u32 sendSize); + +/* Cache operations and macros */ + +extern void osInvalDCache(void *, s32); +extern void osInvalICache(void *, s32); +extern void osWritebackDCache(void *, s32); +extern void osWritebackDCacheAll(void); + +#define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10)) +#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10)) + +/* TLB management routines */ + +extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32); +extern void osMapTLBRdb(void); +extern void osUnmapTLB(s32); +extern void osUnmapTLBAll(void); +extern void osSetTLBASID(s32); + +/* Address translation routines and macros */ + +extern u32 osVirtualToPhysical(void *); +extern void * osPhysicalToVirtual(u32); + +#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) +#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) + +#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) +#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) + +/* I/O operations */ + +/* Audio interface (Ai) */ +extern u32 osAiGetStatus(void); +extern u32 osAiGetLength(void); +extern s32 osAiSetFrequency(u32); +extern s32 osAiSetNextBuffer(void *, u32); + +/* Display processor interface (Dp) */ +extern u32 osDpGetStatus(void); +extern void osDpSetStatus(u32); +extern void osDpGetCounters(u32 *); +extern s32 osDpSetNextBuffer(void *, u64); + +/* Peripheral interface (Pi) */ +extern u32 osPiGetStatus(void); +extern s32 osPiGetDeviceType(void); +extern s32 osPiRawWriteIo(u32, u32); +extern s32 osPiRawReadIo(u32, u32 *); +extern s32 osPiRawStartDma(s32, u32, void *, u32); +extern s32 osPiWriteIo(u32, u32); +extern s32 osPiReadIo(u32, u32 *); +extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, + OSMesgQueue *); +extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32); + +/* Video interface (Vi) */ +extern u32 osViGetStatus(void); +extern u32 osViGetCurrentMode(void); +extern u32 osViGetCurrentLine(void); +extern u32 osViGetCurrentField(void); +extern void *osViGetCurrentFramebuffer(void); +extern void *osViGetNextFramebuffer(void); +extern void osViSetXScale(f32); +extern void osViSetYScale(f32); +extern void osViSetSpecialFeatures(u32); +extern void osViSetMode(OSViMode *); +extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); +extern void osViSwapBuffer(void *); +extern void osViBlack(u8); +extern void osViFade(u8, u16); +extern void osViRepeatLine(u8); +extern void osCreateViManager(OSPri); + +/* Timer interface */ + +extern OSTime osGetTime(void); +extern void osSetTime(OSTime); +extern int osSetTimer(OSTimer *, OSTime, OSTime, + OSMesgQueue *, OSMesg); +extern int osStopTimer(OSTimer *); + +/* Controller interface */ + +extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); +extern s32 osContReset(OSMesgQueue *, OSContStatus *); +extern s32 osContStartQuery(OSMesgQueue *); +extern s32 osContStartReadData(OSMesgQueue *); +#ifndef _HW_VERSION_1 +extern s32 osContSetCh(u8); +#endif +extern void osContGetQuery(OSContStatus *); +extern void osContGetReadData(OSContPad *); + +/* file system interface */ + +extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int); +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 *); + +/* EEPROM interface */ + +extern s32 osEepromProbe(OSMesgQueue *); +extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); +extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); +extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int); +extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int); + +/* MOTOR interface */ + +extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); +extern s32 osMotorStop(OSPfs *); +extern s32 osMotorStart(OSPfs *); + +/* Enhanced PI interface */ + +extern OSPiHandle *osCartRomInit(void); +extern OSPiHandle *osLeoDiskInit(void); +extern OSPiHandle *osDriveRomInit(void); + +extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *); +extern s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32); +extern s32 osEPiRawReadIo(OSPiHandle *, u32 , u32 *); +extern s32 osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 ); +extern s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32 ); +extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); +extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); +extern s32 osEPiLinkHandle(OSPiHandle *); + +/* Profiler Interface */ + +extern void osProfileInit(OSProf *, u32 profcnt); +extern void osProfileStart(u32); +extern void osProfileFlush(void); +extern void osProfileStop(void); + +/* Game <> Host data transfer functions */ + +extern s32 osTestHost(void); +extern void osReadHost(void *, u32); +extern void osWriteHost(void *, u32); +extern void osAckRamromRead(void); +extern void osAckRamromWrite(void); + + +/* byte string operations */ + +extern void bcopy(const void *, void *, int); +extern int bcmp(const void *, const void *, int); +extern void bzero(void *, int); + +/* Miscellaneous operations */ + +extern void osInitialize(void); +extern u32 osGetCount(void); +extern void osExit(void); +extern u32 osGetMemSize(void); + +/* Printf */ + +extern int sprintf(char *s, const char *fmt, ...); +extern void osSyncPrintf(const char *fmt, ...); +extern void osAsyncPrintf(const char *fmt, ...); +extern int osSyncGetChars(char *buf); +extern int osAsyncGetChars(char *buf); + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_H */ diff --git a/include/2.0L/PR/os_internal.h b/include/2.0L/PR/os_internal.h new file mode 100755 index 00000000..bef19ce6 --- /dev/null +++ b/include/2.0L/PR/os_internal.h @@ -0,0 +1,118 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.18 $ + * $Date: 1997/02/11 08:26:14 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/os_internal.h,v $ + * + **************************************************************************/ + +#ifndef _OS_INTERNAL_H_ +#define _OS_INTERNAL_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routines to get/fetch coprocessor 0 registers */ + +extern u32 __osGetCause(void); +extern void __osSetCause(u32); +extern u32 __osGetCompare(void); +extern void __osSetCompare(u32); +extern u32 __osGetConfig(void); +extern void __osSetConfig(u32); +extern void __osSetCount(u32); +extern u32 __osGetSR(void); +extern void __osSetSR(u32); +extern u32 __osDisableInt(void); +extern void __osRestoreInt(u32); + +/* Routines to get/set floating-point control and status register */ +extern u32 __osSetFpcCsr(u32); +extern u32 __osGetFpcCsr(void); + +/* Routine for HW interrupt "handler" */ +extern void __osSetHWIntrRoutine(OSHWIntr, s32 (*handler)(void)); + +/* Routine for global interrupt mask */ +extern void __osSetGlobalIntMask(OSHWIntr); +extern void __osResetGlobalIntMask(OSHWIntr); + +/* Routine for global interrupt mask */ +extern s32 __osLeoInterrupt(void); + +/* Routines for fetch TLB info */ + +extern u32 __osGetTLBASID(void); +extern u32 __osGetTLBPageMask(s32); +extern u32 __osGetTLBHi(s32); +extern u32 __osGetTLBLo0(s32); +extern u32 __osGetTLBLo1(s32); + +/* Serial interface (Si) */ + +extern u32 __osSiGetStatus(void); +extern s32 __osSiRawWriteIo(u32, u32); +extern s32 __osSiRawReadIo(u32, u32 *); +extern s32 __osSiRawStartDma(s32, void *); + +/* Signal processor interface (Sp) */ + +extern u32 __osSpGetStatus(void); +extern void __osSpSetStatus(u32); +extern s32 __osSpSetPc(u32); +extern s32 __osSiRawWriteIo(u32, u32); +extern s32 __osSpRawReadIo(u32, u32 *); +extern s32 __osSpRawStartDma(s32, u32, void *, u32); + +/* Error handling */ + +extern void __osError(s16, s16, ...); +extern OSThread * __osGetCurrFaultedThread(void); +extern OSThread * __osGetNextFaultedThread(OSThread *); + +/* Development board functions */ + +extern void __osGIOInit(s32); +extern void __osGIOInterrupt(s32); +extern void __osGIORawInterrupt(s32); + +/* For debugger use */ + +extern OSThread * __osGetActiveQueue(void); + +/* Debug port */ +extern void __osSyncPutChars(int, int, const char *); +extern int __osSyncGetChars(char *); +extern void __osAsyncPutChars(int, int, const char *); +extern int __osAsyncGetChars(char *); +extern int __osAtomicInc(unsigned int *p); +extern int __osAtomicDec(unsigned int *p); + +/* routine for rdb port */ +extern u32 __osRdbSend(u8 *buf, u32 size, u32 type); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_H */ diff --git a/include/2.0L/PR/ramrom.h b/include/2.0L/PR/ramrom.h new file mode 100755 index 00000000..397b6760 --- /dev/null +++ b/include/2.0L/PR/ramrom.h @@ -0,0 +1,113 @@ +#ifndef _RAMROM_H +#define _RAMROM_H + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.20 $ + * $Date: 1997/02/11 08:26:47 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ramrom.h,v $ + * + **************************************************************************/ + +/* + * Defines for the GIO card in the Nintendo Development Station + * + * The RAM on the GIO card acts as ROM for the game + * Interrupts available between the game and the Indy host + * + * The last part of the ramrom is used for communication between + * game and host. There are 6 4K buffers defined: + * log, printf, rmon to indy, rmon from indy, app to indy, app from indy + * The last 8 bytes of the buffer are used in the emulator environment + */ + +#define RAMROM_SIZE (0x1000000) + +#define RAMROM_BUF_SIZE (4096) +#define RAMROM_MSG_SIZE (RAMROM_BUF_SIZE*6) +#define RAMROM_MSG_ADDR (RAMROM_SIZE - RAMROM_MSG_SIZE) +#define RAMROM_MSG_HDR_SIZE (3*sizeof(long)) +#define RAMROM_USER_DATA_SIZE (RAMROM_MSG_SIZE-RAMROM_MSG_HDR_SIZE) + +#define RAMROM_APP_READ_ADDR (RAMROM_MSG_ADDR + (0*RAMROM_BUF_SIZE)) +#define RAMROM_APP_WRITE_ADDR (RAMROM_MSG_ADDR + (1*RAMROM_BUF_SIZE)) +#define RAMROM_RMON_READ_ADDR (RAMROM_MSG_ADDR + (2*RAMROM_BUF_SIZE)) +#define RAMROM_RMON_WRITE_ADDR (RAMROM_MSG_ADDR + (3*RAMROM_BUF_SIZE)) +#define RAMROM_PRINTF_ADDR (RAMROM_MSG_ADDR + (4*RAMROM_BUF_SIZE)) +#define RAMROM_LOG_ADDR (RAMROM_MSG_ADDR + (5*RAMROM_BUF_SIZE)) + +/*#define RAMROM_GIO_INTERRUPT (RAMROM_MSG_ADDR + RAMROM_MSG_SIZE - 4)*/ + +/* + * For the initial round of PIF bringup, we will load in a bootstrap loader + * 0x400 bytes into the ramrom, and the rom will be loaded at 0x2000 + */ +#ifndef _HW_VERSION_1 +#define RAMROM_BOOTSTRAP_OFFSET 0x40 +#define RAMROM_GAME_OFFSET 0x1000 +#define RAMROM_FONTDATA_OFFSET 0xb70 +#define RAMROM_FONTDATA_SIZE 1152 +#else +#define RAMROM_BOOTSTRAP_OFFSET 0x400 +#define RAMROM_GAME_OFFSET 0x2000 +#endif +#define RAMROM_CLOCKRATE_OFFSET 0x4 +#define RAMROM_CLOCKRATE_MASK 0xfffffff0 +#define RAMROM_BOOTADDR_OFFSET 0x8 +#define RAMROM_RELEASE_OFFSET 0xc +/* + * Second version of the PIF jumps to location 0x1000, and we'll put a jump to + * location 0x400 into the ramrom (for backwards compatibility). + */ +#define RAMROM_PIF2BOOTSTRAP_OFFSET 0x1000 + +typedef struct { + long type; + long length; /* in bytes of userdata */ + long magic; + char userdata[RAMROM_USER_DATA_SIZE]; +} RamRomBuffer; + +/* + * Interrupt values (must fit in 6 bits!) + * values are used for both request & response + * Transactions initiated by the host start with HOST + * and those initiated by the target start with GAME. + */ + +#define HOST_PIACCESS_REQ 1 +#define HOST_DBG_CMD_READY 2 +#define GAME_DBG_DATA_SEND 3 +#define HOST_DBG_DATA_ACK 4 +#define GAME_PRINTF_SEND 5 +#define HOST_PRINTF_ACK 6 +#define GAME_LOG_SEND 7 +#define HOST_LOG_ACK 8 +#define HOST_APP_CMD_READY 9 +#define GAME_APP_DATA_READY 10 +#define HOST_PROF_REQ 11 +#define GAME_PROF_SEND 12 +#define HOST_PROF_ACK 13 +#define GAME_FAULT_SEND 14 +#define HOST_FAULT_ACK 15 +#define GAME_EXIT 16 +#define HOST_DATA_ACK 17 + +#ifdef _EMULATOR +void __RamRomInit(int key, void *romaddr); +void __RamRomDestroy(int key); +#endif /* _EMULATOR */ + +#endif /* !_RAMROM_H */ diff --git a/include/2.0L/PR/rcp.h b/include/2.0L/PR/rcp.h new file mode 100755 index 00000000..3795ff72 --- /dev/null +++ b/include/2.0L/PR/rcp.h @@ -0,0 +1,882 @@ +#ifndef _RCP_H_ +#define _RCP_H_ + +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * File: rcp.h + * + * This file contains register and bit definitions for RCP memory map. + * $Revision: 1.20 $ + * $Date: 1997/07/23 08:35:21 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $ + * + **************************************************************************/ + +#include +#include + +/********************************************************************** + * + * Here is a quick overview of the RCP memory map: + * + +0x0000_0000 .. 0x03ef_ffff RDRAM memory +0x03f0_0000 .. 0x03ff_ffff RDRAM registers + + RCP registers (see below) +0x0400_0000 .. 0x040f_ffff SP registers +0x0410_0000 .. 0x041f_ffff DP command registers +0x0420_0000 .. 0x042f_ffff DP span registers +0x0430_0000 .. 0x043f_ffff MI registers +0x0440_0000 .. 0x044f_ffff VI registers +0x0450_0000 .. 0x045f_ffff AI registers +0x0460_0000 .. 0x046f_ffff PI registers +0x0470_0000 .. 0x047f_ffff RI registers +0x0480_0000 .. 0x048f_ffff SI registers +0x0490_0000 .. 0x04ff_ffff unused + +0x0500_0000 .. 0x05ff_ffff cartridge domain 2 +0x0600_0000 .. 0x07ff_ffff cartridge domain 1 +0x0800_0000 .. 0x0fff_ffff cartridge domain 2 +0x1000_0000 .. 0x1fbf_ffff cartridge domain 1 + +0x1fc0_0000 .. 0x1fc0_07bf PIF Boot Rom (1984 bytes) +0x1fc0_07c0 .. 0x1fc0_07ff PIF (JoyChannel) RAM (64 bytes) +0x1fc0_0800 .. 0x1fcf_ffff Reserved +0x1fd0_0000 .. 0x7fff_ffff cartridge domain 1 +0x8000_0000 .. 0xffff_ffff external SysAD device + +The Indy development board use cartridge domain 1: +0x1000_0000 .. 0x10ff_ffff RAMROM +0x1800_0000 .. 0x1800_0003 GIO interrupt (6 bits valid in 4 bytes) +0x1800_0400 .. 0x1800_0403 GIO sync (6 bits valid in 4 bytes) +0x1800_0800 .. 0x1800_0803 CART interrupt (6 bits valid in 4 bytes) + + + +**************************************************************************/ + + +/************************************************************************* + * RDRAM Memory (Assumes that maximum size is 4 MB) + */ +#define RDRAM_0_START 0x00000000 +#define RDRAM_0_END 0x001FFFFF +#define RDRAM_1_START 0x00200000 +#define RDRAM_1_END 0x003FFFFF + +#define RDRAM_START RDRAM_0_START +#define RDRAM_END RDRAM_1_END + + +/************************************************************************* + * Address predicates + */ +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +#define IS_RDRAM(x) ((unsigned)(x) >= RDRAM_START && \ + (unsigned)(x) < RDRAM_END) +#endif + + +/************************************************************************* + * RDRAM Registers (0x03f0_0000 .. 0x03ff_ffff) + */ +#define RDRAM_BASE_REG 0x03F00000 + +#define RDRAM_CONFIG_REG (RDRAM_BASE_REG+0x00) +#define RDRAM_DEVICE_TYPE_REG (RDRAM_BASE_REG+0x00) +#define RDRAM_DEVICE_ID_REG (RDRAM_BASE_REG+0x04) +#define RDRAM_DELAY_REG (RDRAM_BASE_REG+0x08) +#define RDRAM_MODE_REG (RDRAM_BASE_REG+0x0c) +#define RDRAM_REF_INTERVAL_REG (RDRAM_BASE_REG+0x10) +#define RDRAM_REF_ROW_REG (RDRAM_BASE_REG+0x14) +#define RDRAM_RAS_INTERVAL_REG (RDRAM_BASE_REG+0x18) +#define RDRAM_MIN_INTERVAL_REG (RDRAM_BASE_REG+0x1c) +#define RDRAM_ADDR_SELECT_REG (RDRAM_BASE_REG+0x20) +#define RDRAM_DEVICE_MANUF_REG (RDRAM_BASE_REG+0x24) + +#define RDRAM_0_DEVICE_ID 0 +#define RDRAM_1_DEVICE_ID 1 + +#define RDRAM_RESET_MODE 0 +#define RDRAM_ACTIVE_MODE 1 +#define RDRAM_STANDBY_MODE 2 + +#define RDRAM_LENGTH (2*512*2048) +#define RDRAM_0_BASE_ADDRESS (RDRAM_0_DEVICE_ID*RDRAM_LENGTH) +#define RDRAM_1_BASE_ADDRESS (RDRAM_1_DEVICE_ID*RDRAM_LENGTH) + +#define RDRAM_0_CONFIG 0x00000 +#define RDRAM_1_CONFIG 0x00400 +#define RDRAM_GLOBAL_CONFIG 0x80000 + + +/************************************************************************* + * PIF Physical memory map (total size = 2 KB) + * + * Size Description Mode + * 1FC007FF +-------+-----------------+-----+ + * | 64 B | JoyChannel RAM | R/W | + * 1FC007C0 +-------+-----------------+-----+ + * |1984 B | Boot ROM | * | * = Reserved + * 1FC00000 +-------+-----------------+-----+ + * + */ +#define PIF_ROM_START 0x1FC00000 +#define PIF_ROM_END 0x1FC007BF +#define PIF_RAM_START 0x1FC007C0 +#define PIF_RAM_END 0x1FC007FF + + +/************************************************************************* + * Controller channel + * Each game controller channel has 4 error bits that are defined in bit 6-7 of + * the Rx and Tx data size area bytes. Programmers need to clear these bits + * when setting the Tx/Rx size area values for a channel + */ +#define CHNL_ERR_NORESP 0x80 /* Bit 7 (Rx): No response error */ +#define CHNL_ERR_OVERRUN 0x40 /* Bit 6 (Rx): Overrun error */ +#define CHNL_ERR_FRAME 0x80 /* Bit 7 (Tx): Frame error */ +#define CHNL_ERR_COLLISION 0x40 /* Bit 6 (Tx): Collision error */ + +#define CHNL_ERR_MASK 0xC0 /* Bit 6-7: channel errors */ + + +/************************************************************************* + * External device info + */ +#define DEVICE_TYPE_CART 0 /* ROM cartridge */ +#define DEVICE_TYPE_BULK 1 /* ROM bulk */ +#define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */ +#define DEVICE_TYPE_SRAM 3 /* SRAM */ + +/************************************************************************* + * SP Memory + */ +#define SP_DMEM_START 0x04000000 /* read/write */ +#define SP_DMEM_END 0x04000FFF +#define SP_IMEM_START 0x04001000 /* read/write */ +#define SP_IMEM_END 0x04001FFF + +/************************************************************************* + * SP CP0 Registers + */ + +#define SP_BASE_REG 0x04040000 + +/* SP memory address (R/W): [11:0] DMEM/IMEM address; [12] 0=DMEM,1=IMEM */ +#define SP_MEM_ADDR_REG (SP_BASE_REG+0x00) /* Master */ + +/* SP DRAM DMA address (R/W): [23:0] RDRAM address */ +#define SP_DRAM_ADDR_REG (SP_BASE_REG+0x04) /* Slave */ + +/* SP read DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip */ +/* direction: I/DMEM <- RDRAM */ +#define SP_RD_LEN_REG (SP_BASE_REG+0x08) /* R/W: read len */ + +/* SP write DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip */ +/* direction: I/DMEM -> RDRAM */ +#define SP_WR_LEN_REG (SP_BASE_REG+0x0C) /* R/W: write len */ + +/* SP status (R/W): [14:0] valid bits; see below for write/read mode */ +#define SP_STATUS_REG (SP_BASE_REG+0x10) + +/* SP DMA full (R): [0] valid bit; dma full */ +#define SP_DMA_FULL_REG (SP_BASE_REG+0x14) + +/* SP DMA busy (R): [0] valid bit; dma busy */ +#define SP_DMA_BUSY_REG (SP_BASE_REG+0x18) + +/* SP semaphore (R/W): Read: [0] semaphore flag (set on read) */ +/* Write: [] clear semaphore flag */ +#define SP_SEMAPHORE_REG (SP_BASE_REG+0x1C) + +/* SP PC (R/W): [11:0] program counter */ +#define SP_PC_REG 0x04080000 + +/* SP MEM address: bit 12 specifies if address is IMEM or DMEM */ +#define SP_DMA_DMEM 0x0000 /* Bit 12: 0=DMEM, 1=IMEM */ +#define SP_DMA_IMEM 0x1000 /* Bit 12: 0=DMEM, 1=IMEM */ + +/* + * Values to clear/set bit in status reg (SP_STATUS_REG - write) + */ +#define SP_CLR_HALT 0x00001 /* Bit 0: clear halt */ +#define SP_SET_HALT 0x00002 /* Bit 1: set halt */ +#define SP_CLR_BROKE 0x00004 /* Bit 2: clear broke */ +#define SP_CLR_INTR 0x00008 /* Bit 3: clear intr */ +#define SP_SET_INTR 0x00010 /* Bit 4: set intr */ +#define SP_CLR_SSTEP 0x00020 /* Bit 5: clear sstep */ +#define SP_SET_SSTEP 0x00040 /* Bit 6: set sstep */ +#define SP_CLR_INTR_BREAK 0x00080 /* Bit 7: clear intr on break */ +#define SP_SET_INTR_BREAK 0x00100 /* Bit 8: set intr on break */ +#define SP_CLR_SIG0 0x00200 /* Bit 9: clear signal 0 */ +#define SP_SET_SIG0 0x00400 /* Bit 10: set signal 0 */ +#define SP_CLR_SIG1 0x00800 /* Bit 11: clear signal 1 */ +#define SP_SET_SIG1 0x01000 /* Bit 12: set signal 1 */ +#define SP_CLR_SIG2 0x02000 /* Bit 13: clear signal 2 */ +#define SP_SET_SIG2 0x04000 /* Bit 14: set signal 2 */ +#define SP_CLR_SIG3 0x08000 /* Bit 15: clear signal 3 */ +#define SP_SET_SIG3 0x10000 /* Bit 16: set signal 3 */ +#define SP_CLR_SIG4 0x20000 /* Bit 17: clear signal 4 */ +#define SP_SET_SIG4 0x40000 /* Bit 18: set signal 4 */ +#define SP_CLR_SIG5 0x80000 /* Bit 19: clear signal 5 */ +#define SP_SET_SIG5 0x100000 /* Bit 20: set signal 5 */ +#define SP_CLR_SIG6 0x200000 /* Bit 21: clear signal 6 */ +#define SP_SET_SIG6 0x400000 /* Bit 22: set signal 6 */ +#define SP_CLR_SIG7 0x800000 /* Bit 23: clear signal 7 */ +#define SP_SET_SIG7 0x1000000 /* Bit 24: set signal 7 */ + +/* + * Patterns to interpret status reg (SP_STATUS_REG - read) + */ +#define SP_STATUS_HALT 0x001 /* Bit 0: halt */ +#define SP_STATUS_BROKE 0x002 /* Bit 1: broke */ +#define SP_STATUS_DMA_BUSY 0x004 /* Bit 2: dma busy */ +#define SP_STATUS_DMA_FULL 0x008 /* Bit 3: dma full */ +#define SP_STATUS_IO_FULL 0x010 /* Bit 4: io full */ +#define SP_STATUS_SSTEP 0x020 /* Bit 5: single step */ +#define SP_STATUS_INTR_BREAK 0x040 /* Bit 6: interrupt on break */ +#define SP_STATUS_SIG0 0x080 /* Bit 7: signal 0 set */ +#define SP_STATUS_SIG1 0x100 /* Bit 8: signal 1 set */ +#define SP_STATUS_SIG2 0x200 /* Bit 9: signal 2 set */ +#define SP_STATUS_SIG3 0x400 /* Bit 10: signal 3 set */ +#define SP_STATUS_SIG4 0x800 /* Bit 11: signal 4 set */ +#define SP_STATUS_SIG5 0x1000 /* Bit 12: signal 5 set */ +#define SP_STATUS_SIG6 0x2000 /* Bit 13: signal 6 set */ +#define SP_STATUS_SIG7 0x4000 /* Bit 14: signal 7 set */ + +/* + * Use of SIG bits + */ +#define SP_CLR_YIELD SP_CLR_SIG0 +#define SP_SET_YIELD SP_SET_SIG0 +#define SP_STATUS_YIELD SP_STATUS_SIG0 +#define SP_CLR_YIELDED SP_CLR_SIG1 +#define SP_SET_YIELDED SP_SET_SIG1 +#define SP_STATUS_YIELDED SP_STATUS_SIG1 +#define SP_CLR_TASKDONE SP_CLR_SIG2 +#define SP_SET_TASKDONE SP_SET_SIG2 +#define SP_STATUS_TASKDONE SP_STATUS_SIG2 +#define SP_CLR_RSPSIGNAL SP_CLR_SIG3 +#define SP_SET_RSPSIGNAL SP_SET_SIG3 +#define SP_STATUS_RSPSIGNAL SP_STATUS_SIG3 +#define SP_CLR_CPUSIGNAL SP_CLR_SIG4 +#define SP_SET_CPUSIGNAL SP_SET_SIG4 +#define SP_STATUS_CPUSIGNAL SP_STATUS_SIG4 + +/* SP IMEM BIST REG (R/W): [6:0] BIST status bits; see below for detail */ +#define SP_IBIST_REG 0x04080004 + +/* + * Patterns to interpret status reg (SP_BIST_REG - write) + */ +#define SP_IBIST_CHECK 0x01 /* Bit 0: BIST check */ +#define SP_IBIST_GO 0x02 /* Bit 1: BIST go */ +#define SP_IBIST_CLEAR 0x04 /* Bit 2: BIST clear */ + +/* + * Patterns to interpret status reg (SP_BIST_REG - read) + */ +/* First 2 bits are same as in write mode: + * Bit 0: BIST check; Bit 1: BIST go + */ +#define SP_IBIST_DONE 0x04 /* Bit 2: BIST done */ +#define SP_IBIST_FAILED 0x78 /* Bit [6:3]: BIST fail */ + + +/************************************************************************* + * DP Command Registers + */ +#define DPC_BASE_REG 0x04100000 + +/* DP CMD DMA start (R/W): [23:0] DMEM/RDRAM start address */ +#define DPC_START_REG (DPC_BASE_REG+0x00) + +/* DP CMD DMA end (R/W): [23:0] DMEM/RDRAM end address */ +#define DPC_END_REG (DPC_BASE_REG+0x04) + +/* DP CMD DMA end (R): [23:0] DMEM/RDRAM current address */ +#define DPC_CURRENT_REG (DPC_BASE_REG+0x08) + +/* DP CMD status (R/W): [9:0] valid bits - see below for definitions */ +#define DPC_STATUS_REG (DPC_BASE_REG+0x0C) + +/* DP clock counter (R): [23:0] clock counter */ +#define DPC_CLOCK_REG (DPC_BASE_REG+0x10) + +/* DP buffer busy counter (R): [23:0] clock counter */ +#define DPC_BUFBUSY_REG (DPC_BASE_REG+0x14) + +/* DP pipe busy counter (R): [23:0] clock counter */ +#define DPC_PIPEBUSY_REG (DPC_BASE_REG+0x18) + +/* DP TMEM load counter (R): [23:0] clock counter */ +#define DPC_TMEM_REG (DPC_BASE_REG+0x1C) + +/* + * Values to clear/set bit in status reg (DPC_STATUS_REG - write) + */ +#define DPC_CLR_XBUS_DMEM_DMA 0x0001 /* Bit 0: clear xbus_dmem_dma */ +#define DPC_SET_XBUS_DMEM_DMA 0x0002 /* Bit 1: set xbus_dmem_dma */ +#define DPC_CLR_FREEZE 0x0004 /* Bit 2: clear freeze */ +#define DPC_SET_FREEZE 0x0008 /* Bit 3: set freeze */ +#define DPC_CLR_FLUSH 0x0010 /* Bit 4: clear flush */ +#define DPC_SET_FLUSH 0x0020 /* Bit 5: set flush */ +#define DPC_CLR_TMEM_CTR 0x0040 /* Bit 6: clear tmem ctr */ +#define DPC_CLR_PIPE_CTR 0x0080 /* Bit 7: clear pipe ctr */ +#define DPC_CLR_CMD_CTR 0x0100 /* Bit 8: clear cmd ctr */ +#define DPC_CLR_CLOCK_CTR 0x0200 /* Bit 9: clear clock ctr */ + +/* + * Patterns to interpret status reg (DPC_STATUS_REG - read) + */ +#define DPC_STATUS_XBUS_DMEM_DMA 0x001 /* Bit 0: xbus_dmem_dma */ +#define DPC_STATUS_FREEZE 0x002 /* Bit 1: freeze */ +#define DPC_STATUS_FLUSH 0x004 /* Bit 2: flush */ +/*#define DPC_STATUS_FROZEN 0x008*/ /* Bit 3: frozen */ +#define DPC_STATUS_START_GCLK 0x008 /* Bit 3: start gclk */ +#define DPC_STATUS_TMEM_BUSY 0x010 /* Bit 4: tmem busy */ +#define DPC_STATUS_PIPE_BUSY 0x020 /* Bit 5: pipe busy */ +#define DPC_STATUS_CMD_BUSY 0x040 /* Bit 6: cmd busy */ +#define DPC_STATUS_CBUF_READY 0x080 /* Bit 7: cbuf ready */ +#define DPC_STATUS_DMA_BUSY 0x100 /* Bit 8: dma busy */ +#define DPC_STATUS_END_VALID 0x200 /* Bit 9: end valid */ +#define DPC_STATUS_START_VALID 0x400 /* Bit 10: start valid */ + + +/************************************************************************* + * DP Span Registers + */ +#define DPS_BASE_REG 0x04200000 + +/* DP tmem bist (R/W): [10:0] BIST status bits; see below for detail */ +#define DPS_TBIST_REG (DPS_BASE_REG+0x00) + +/* DP span test mode (R/W): [0] Span buffer test access enable */ +#define DPS_TEST_MODE_REG (DPS_BASE_REG+0x04) + +/* DP span buffer test address (R/W): [6:0] bits; see below for detail */ +#define DPS_BUFTEST_ADDR_REG (DPS_BASE_REG+0x08) + +/* DP span buffer test data (R/W): [31:0] span buffer data */ +#define DPS_BUFTEST_DATA_REG (DPS_BASE_REG+0x0C) + +/* + * Patterns to interpret status reg (DPS_TMEM_BIST_REG - write) + */ +#define DPS_TBIST_CHECK 0x01 /* Bit 0: BIST check */ +#define DPS_TBIST_GO 0x02 /* Bit 1: BIST go */ +#define DPS_TBIST_CLEAR 0x04 /* Bit 2: BIST clear */ + +/* + * Patterns to interpret status reg (DPS_TMEM_BIST_REG - read) + */ +/* First 2 bits are same as in write mode: + * Bit 0: BIST check; Bit 1: BIST go + */ +#define DPS_TBIST_DONE 0x004 /* Bit 2: BIST done */ +#define DPS_TBIST_FAILED 0x7F8 /* Bit [10:3]: BIST fail */ + + +/************************************************************************* + * MIPS Interface (MI) Registers + */ +#define MI_BASE_REG 0x04300000 + +/* + * MI init mode (W): [6:0] init length, [7] clear init mode, [8] set init mode + * [9/10] clear/set ebus test mode, [11] clear DP interrupt + * (R): [6:0] init length, [7] init mode, [8] ebus test mode + */ +#define MI_INIT_MODE_REG (MI_BASE_REG+0x00) +#define MI_MODE_REG MI_INIT_MODE_REG + +/* + * Values to clear/set bit in mode reg (MI_MODE_REG - write) + */ +#define MI_CLR_INIT 0x0080 /* Bit 7: clear init mode */ +#define MI_SET_INIT 0x0100 /* Bit 8: set init mode */ +#define MI_CLR_EBUS 0x0200 /* Bit 9: clear ebus test */ +#define MI_SET_EBUS 0x0400 /* Bit 10: set ebus test mode */ +#define MI_CLR_DP_INTR 0x0800 /* Bit 11: clear dp interrupt */ +#define MI_CLR_RDRAM 0x1000 /* Bit 12: clear RDRAM reg */ +#define MI_SET_RDRAM 0x2000 /* Bit 13: set RDRAM reg mode */ + +/* + * Patterns to interpret mode reg (MI_MODE_REG - read) + */ +#define MI_MODE_INIT 0x0080 /* Bit 7: init mode */ +#define MI_MODE_EBUS 0x0100 /* Bit 8: ebus test mode */ +#define MI_MODE_RDRAM 0x0200 /* Bit 9: RDRAM reg mode */ + +/* MI version (R): [7:0] io, [15:8] rac, [23:16] rdp, [31:24] rsp */ +#define MI_VERSION_REG (MI_BASE_REG+0x04) +#define MI_NOOP_REG MI_VERSION_REG + +/* MI interrupt (R): [5:0] valid bits - see below for bit patterns */ +#define MI_INTR_REG (MI_BASE_REG+0x08) + +/* + * MI interrupt mask (W): [11:0] valid bits - see below for bit patterns + * (R): [5:0] valid bits - see below for bit patterns + */ +#define MI_INTR_MASK_REG (MI_BASE_REG+0x0C) + +/* + * The following are values to check for interrupt setting (MI_INTR_REG) + */ +#define MI_INTR_SP 0x01 /* Bit 0: SP intr */ +#define MI_INTR_SI 0x02 /* Bit 1: SI intr */ +#define MI_INTR_AI 0x04 /* Bit 2: AI intr */ +#define MI_INTR_VI 0x08 /* Bit 3: VI intr */ +#define MI_INTR_PI 0x10 /* Bit 4: PI intr */ +#define MI_INTR_DP 0x20 /* Bit 5: DP intr */ + +/* + * The following are values to clear/set various interrupt bit mask + * They can be ORed together to manipulate multiple bits + * (MI_INTR_MASK_REG - write) + */ +#define MI_INTR_MASK_CLR_SP 0x0001 /* Bit 0: clear SP mask */ +#define MI_INTR_MASK_SET_SP 0x0002 /* Bit 1: set SP mask */ +#define MI_INTR_MASK_CLR_SI 0x0004 /* Bit 2: clear SI mask */ +#define MI_INTR_MASK_SET_SI 0x0008 /* Bit 3: set SI mask */ +#define MI_INTR_MASK_CLR_AI 0x0010 /* Bit 4: clear AI mask */ +#define MI_INTR_MASK_SET_AI 0x0020 /* Bit 5: set AI mask */ +#define MI_INTR_MASK_CLR_VI 0x0040 /* Bit 6: clear VI mask */ +#define MI_INTR_MASK_SET_VI 0x0080 /* Bit 7: set VI mask */ +#define MI_INTR_MASK_CLR_PI 0x0100 /* Bit 8: clear PI mask */ +#define MI_INTR_MASK_SET_PI 0x0200 /* Bit 9: set PI mask */ +#define MI_INTR_MASK_CLR_DP 0x0400 /* Bit 10: clear DP mask */ +#define MI_INTR_MASK_SET_DP 0x0800 /* Bit 11: set DP mask */ + +/* + * The following are values to check for interrupt mask setting + * (MI_INTR_MASK_REG - read) + */ +#define MI_INTR_MASK_SP 0x01 /* Bit 0: SP intr mask */ +#define MI_INTR_MASK_SI 0x02 /* Bit 1: SI intr mask */ +#define MI_INTR_MASK_AI 0x04 /* Bit 2: AI intr mask */ +#define MI_INTR_MASK_VI 0x08 /* Bit 3: VI intr mask */ +#define MI_INTR_MASK_PI 0x10 /* Bit 4: PI intr mask */ +#define MI_INTR_MASK_DP 0x20 /* Bit 5: DP intr mask */ + + +/************************************************************************* + * Video Interface (VI) Registers + */ +#define VI_BASE_REG 0x04400000 + +/* VI status/control (R/W): [15-0] valid bits: + * [1:0] = type[1:0] (pixel size) + * 0: blank (no data, no sync) + * 1: reserved + * 2: 5/5/5/3 ("16" bit) + * 3: 8/8/8/8 (32 bit) + * [2] = gamma_dither_enable (normally on, unless "special effect") + * [3] = gamma_enable (normally on, unless MPEG/JPEG) + * [4] = divot_enable (normally on if antialiased, unless decal lines) + * [5] = reserved - always off + * [6] = serrate (always on if interlaced, off if not) + * [7] = reserved - diagnostics only + * [9:8] = anti-alias (aa) mode[1:0] + * 0: aa & resamp (always fetch extra lines) + * 1: aa & resamp (fetch extra lines if needed) + * 2: resamp only (treat as all fully covered) + * 3: neither (replicate pixels, no interpolate) + * [11] = reserved - diagnostics only + * [15:12] = reserved + * + */ +#define VI_STATUS_REG (VI_BASE_REG+0x00) +#define VI_CONTROL_REG VI_STATUS_REG + +/* VI origin (R/W): [23:0] frame buffer origin in bytes */ +#define VI_ORIGIN_REG (VI_BASE_REG+0x04) +#define VI_DRAM_ADDR_REG VI_ORIGIN_REG + +/* VI width (R/W): [11:0] frame buffer line width in pixels */ +#define VI_WIDTH_REG (VI_BASE_REG+0x08) +#define VI_H_WIDTH_REG VI_WIDTH_REG + +/* VI vertical intr (R/W): [9:0] interrupt when current half-line = V_INTR */ +#define VI_INTR_REG (VI_BASE_REG+0x0C) +#define VI_V_INTR_REG VI_INTR_REG + +/* + * VI current vertical line (R/W): [9:0] current half line, sampled once per + * line (the lsb of V_CURRENT is constant within a field, and in + * interlaced modes gives the field number - which is constant for non- + * interlaced modes) + * - Any write to this register will clear interrupt line + */ +#define VI_CURRENT_REG (VI_BASE_REG+0x10) +#define VI_V_CURRENT_LINE_REG VI_CURRENT_REG + +/* + * VI video timing (R/W): [ 7: 0] horizontal sync width in pixels, + * [15: 8] color burst width in pixels, + * [19:16] vertical sync width in half lines, + * [29:20] start of color burst in pixels from h-sync + */ +#define VI_BURST_REG (VI_BASE_REG+0x14) +#define VI_TIMING_REG VI_BURST_REG + +/* VI vertical sync (R/W): [9:0] number of half-lines per field */ +#define VI_V_SYNC_REG (VI_BASE_REG+0x18) + +/* VI horizontal sync (R/W): [11: 0] total duration of a line in 1/4 pixel + * [20:16] a 5-bit leap pattern used for PAL only + * (h_sync_period) + */ +#define VI_H_SYNC_REG (VI_BASE_REG+0x1C) + +/* + * VI horizontal sync leap (R/W): [11: 0] identical to h_sync_period + * [27:16] identical to h_sync_period + */ +#define VI_LEAP_REG (VI_BASE_REG+0x20) +#define VI_H_SYNC_LEAP_REG VI_LEAP_REG + +/* + * VI horizontal video (R/W): [ 9: 0] end of active video in screen pixels + * : [25:16] start of active video in screen pixels + */ +#define VI_H_START_REG (VI_BASE_REG+0x24) +#define VI_H_VIDEO_REG VI_H_START_REG + +/* + * VI vertical video (R/W): [ 9: 0] end of active video in screen half-lines + * : [25:16] start of active video in screen half-lines + */ +#define VI_V_START_REG (VI_BASE_REG+0x28) +#define VI_V_VIDEO_REG VI_V_START_REG + +/* + * VI vertical burst (R/W): [ 9: 0] end of color burst enable in half-lines + * : [25:16] start of color burst enable in half-lines + */ +#define VI_V_BURST_REG (VI_BASE_REG+0x2C) + +/* VI x-scale (R/W): [11: 0] 1/horizontal scale up factor (2.10 format) + * [27:16] horizontal subpixel offset (2.10 format) + */ +#define VI_X_SCALE_REG (VI_BASE_REG+0x30) + +/* VI y-scale (R/W): [11: 0] 1/vertical scale up factor (2.10 format) + * [27:16] vertical subpixel offset (2.10 format) + */ +#define VI_Y_SCALE_REG (VI_BASE_REG+0x34) + +/* + * Patterns to interpret VI_CONTROL_REG + */ +#define VI_CTRL_TYPE_16 0x00002 /* Bit [1:0] pixel size: 16 bit */ +#define VI_CTRL_TYPE_32 0x00003 /* Bit [1:0] pixel size: 32 bit */ +#define VI_CTRL_GAMMA_DITHER_ON 0x00004 /* Bit 2: default = on */ +#define VI_CTRL_GAMMA_ON 0x00008 /* Bit 3: default = on */ +#define VI_CTRL_DIVOT_ON 0x00010 /* Bit 4: default = on */ +#define VI_CTRL_SERRATE_ON 0x00040 /* Bit 6: on if interlaced */ +#define VI_CTRL_ANTIALIAS_MASK 0x00300 /* Bit [9:8] anti-alias mode */ +#define VI_CTRL_DITHER_FILTER_ON 0x10000 /* Bit 16: dither-filter mode */ + +/* + * Possible video clocks (NTSC or PAL) + */ +#define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */ +#define VI_PAL_CLOCK 49656530 /* Hz = 49.656530 MHz */ +#define VI_MPAL_CLOCK 48628316 /* Hz = 48.628316 MHz */ + + +/************************************************************************* + * Audio Interface (AI) Registers + * + * The address and length registers are double buffered; that is, they + * can be written twice before becoming full. + * The address must be written before the length. + */ +#define AI_BASE_REG 0x04500000 + +/* AI DRAM address (W): [23:0] starting RDRAM address (8B-aligned) */ +#define AI_DRAM_ADDR_REG (AI_BASE_REG+0x00) /* R0: DRAM address */ + +/* AI length (R/W): [14:0] transfer length (v1.0) - Bottom 3 bits are ignored */ +/* [17:0] transfer length (v2.0) - Bottom 3 bits are ignored */ +#define AI_LEN_REG (AI_BASE_REG+0x04) /* R1: Length */ + +/* AI control (W): [0] DMA enable - if LSB == 1, DMA is enabled */ +#define AI_CONTROL_REG (AI_BASE_REG+0x08) /* R2: DMA Control */ + +/* + * AI status (R): [31]/[0] ai_full (addr & len buffer full), [30] ai_busy + * Note that a 1->0 transition in ai_full will set interrupt + * (W): clear audio interrupt + */ +#define AI_STATUS_REG (AI_BASE_REG+0x0C) /* R3: Status */ + +/* + * AI DAC sample period register (W): [13:0] dac rate + * - vid_clock/(dperiod + 1) is the DAC sample rate + * - (dperiod + 1) >= 66 * (aclockhp + 1) must be true + */ +#define AI_DACRATE_REG (AI_BASE_REG+0x10) /* R4: DAC rate 14-lsb*/ + +/* + * AI bit rate (W): [3:0] bit rate (abus clock half period register - aclockhp) + * - vid_clock/(2 * (aclockhp + 1)) is the DAC clock rate + * - The abus clock stops if aclockhp is zero + */ +#define AI_BITRATE_REG (AI_BASE_REG+0x14) /* R5: Bit rate 4-lsb */ + +/* Value for control register */ +#define AI_CONTROL_DMA_ON 0x01 /* LSB = 1: DMA enable*/ +#define AI_CONTROL_DMA_OFF 0x00 /* LSB = 1: DMA enable*/ + +/* Value for status register */ +#define AI_STATUS_FIFO_FULL 0x80000000 /* Bit 31: full */ +#define AI_STATUS_DMA_BUSY 0x40000000 /* Bit 30: busy */ + +/* DAC rate = video clock / audio frequency + * - DAC rate >= (66 * Bit rate) must be true + */ +#define AI_MAX_DAC_RATE 16384 /* 14-bit+1 */ +#define AI_MIN_DAC_RATE 132 + +/* Bit rate <= (DAC rate / 66) */ +#define AI_MAX_BIT_RATE 16 /* 4-bit+1 */ +#define AI_MIN_BIT_RATE 2 + +/* + * Maximum and minimum values for audio frequency based on video clocks + * max frequency = (video clock / min dac rate) + * min frequency = (video clock / max dac rate) + */ +#define AI_NTSC_MAX_FREQ 368000 /* 368 KHz */ +#define AI_NTSC_MIN_FREQ 3000 /* 3 KHz ~ 2971 Hz */ + +#define AI_PAL_MAX_FREQ 376000 /* 376 KHz */ +#define AI_PAL_MIN_FREQ 3050 /* 3 KHz ~ 3031 Hz */ + +#define AI_MPAL_MAX_FREQ 368000 /* 368 KHz */ +#define AI_MPAL_MIN_FREQ 3000 /* 3 KHz ~ 2968 Hz */ + + +/************************************************************************* + * Peripheral Interface (PI) Registers + */ +#define PI_BASE_REG 0x04600000 + +/* PI DRAM address (R/W): [23:0] starting RDRAM address */ +#define PI_DRAM_ADDR_REG (PI_BASE_REG+0x00) /* DRAM address */ + +/* PI pbus (cartridge) address (R/W): [31:0] starting AD16 address */ +#define PI_CART_ADDR_REG (PI_BASE_REG+0x04) + +/* PI read length (R/W): [23:0] read data length */ +#define PI_RD_LEN_REG (PI_BASE_REG+0x08) + +/* PI write length (R/W): [23:0] write data length */ +#define PI_WR_LEN_REG (PI_BASE_REG+0x0C) + +/* + * PI status (R): [0] DMA busy, [1] IO busy, [2], error + * (W): [0] reset controller (and abort current op), [1] clear intr + */ +#define PI_STATUS_REG (PI_BASE_REG+0x10) + +/* PI dom1 latency (R/W): [7:0] domain 1 device latency */ +#define PI_BSD_DOM1_LAT_REG (PI_BASE_REG+0x14) + +/* PI dom1 pulse width (R/W): [7:0] domain 1 device R/W strobe pulse width */ +#define PI_BSD_DOM1_PWD_REG (PI_BASE_REG+0x18) + +/* PI dom1 page size (R/W): [3:0] domain 1 device page size */ +#define PI_BSD_DOM1_PGS_REG (PI_BASE_REG+0x1C) /* page size */ + +/* PI dom1 release (R/W): [1:0] domain 1 device R/W release duration */ +#define PI_BSD_DOM1_RLS_REG (PI_BASE_REG+0x20) + +/* PI dom2 latency (R/W): [7:0] domain 2 device latency */ +#define PI_BSD_DOM2_LAT_REG (PI_BASE_REG+0x24) /* Domain 2 latency */ + +/* PI dom2 pulse width (R/W): [7:0] domain 2 device R/W strobe pulse width */ +#define PI_BSD_DOM2_PWD_REG (PI_BASE_REG+0x28) /* pulse width */ + +/* PI dom2 page size (R/W): [3:0] domain 2 device page size */ +#define PI_BSD_DOM2_PGS_REG (PI_BASE_REG+0x2C) /* page size */ + +/* PI dom2 release (R/W): [1:0] domain 2 device R/W release duration */ +#define PI_BSD_DOM2_RLS_REG (PI_BASE_REG+0x30) /* release duration */ + +#define PI_DOMAIN1_REG PI_BSD_DOM1_LAT_REG +#define PI_DOMAIN2_REG PI_BSD_DOM2_LAT_REG + +#define PI_DOM_LAT_OFS 0x00 +#define PI_DOM_PWD_OFS 0x04 +#define PI_DOM_PGS_OFS 0x08 +#define PI_DOM_RLS_OFS 0x0C + +/* + * PI status register has 3 bits active when read from (PI_STATUS_REG - read) + * Bit 0: DMA busy - set when DMA is in progress + * Bit 1: IO busy - set when IO is in progress + * Bit 2: Error - set when CPU issues IO request while DMA is busy + */ +#define PI_STATUS_ERROR 0x04 +#define PI_STATUS_IO_BUSY 0x02 +#define PI_STATUS_DMA_BUSY 0x01 + +/* PI status register has 2 bits active when written to: + * Bit 0: When set, reset PIC + * Bit 1: When set, clear interrupt flag + * The values of the two bits can be ORed together to both reset PIC and + * clear interrupt at the same time. + * + * Note: + * - The PIC does generate an interrupt at the end of each DMA. CPU + * needs to clear the interrupt flag explicitly (from an interrupt + * handler) by writing into the STATUS register with bit 1 set. + * + * - When a DMA completes, the interrupt flag is set. CPU can issue + * another request even while the interrupt flag is set (as long as + * PIC is idle). However, it is the CPU's responsibility for + * maintaining accurate correspondence between DMA completions and + * interrupts. + * + * - When PIC is reset, if PIC happens to be busy, an interrupt will + * be generated as PIC returns to idle. Otherwise, no interrupt will + * be generated and PIC remains idle. + */ +/* + * Values to clear interrupt/reset PIC (PI_STATUS_REG - write) + */ +#define PI_STATUS_RESET 0x01 +#define PI_SET_RESET PI_STATUS_RESET + +#define PI_STATUS_CLR_INTR 0x02 +#define PI_CLR_INTR PI_STATUS_CLR_INTR + +#define PI_DMA_BUFFER_SIZE 128 + +#define PI_DOM1_ADDR1 0x06000000 /* to 0x07FFFFFF */ +#define PI_DOM1_ADDR2 0x10000000 /* to 0x1FBFFFFF */ +#define PI_DOM1_ADDR3 0x1FD00000 /* to 0x7FFFFFFF */ +#define PI_DOM2_ADDR1 0x05000000 /* to 0x05FFFFFF */ +#define PI_DOM2_ADDR2 0x08000000 /* to 0x0FFFFFFF */ + + +/************************************************************************* + * RDRAM Interface (RI) Registers + */ +#define RI_BASE_REG 0x04700000 + +/* RI mode (R/W): [1:0] operating mode, [2] stop T active, [3] stop R active */ +#define RI_MODE_REG (RI_BASE_REG+0x00) + +/* RI config (R/W): [5:0] current control input, [6] current control enable */ +#define RI_CONFIG_REG (RI_BASE_REG+0x04) + +/* RI current load (W): [] any write updates current control register */ +#define RI_CURRENT_LOAD_REG (RI_BASE_REG+0x08) + +/* RI select (R/W): [2:0] receive select, [2:0] transmit select */ +#define RI_SELECT_REG (RI_BASE_REG+0x0C) + +/* RI refresh (R/W): [7:0] clean refresh delay, [15:8] dirty refresh delay, + * [16] refresh bank, [17] refresh enable + * [18] refresh optimize + */ +#define RI_REFRESH_REG (RI_BASE_REG+0x10) +#define RI_COUNT_REG RI_REFRESH_REG + +/* RI latency (R/W): [3:0] DMA latency/overlap */ +#define RI_LATENCY_REG (RI_BASE_REG+0x14) + +/* RI error (R): [0] nack error, [1] ack error */ +#define RI_RERROR_REG (RI_BASE_REG+0x18) + +/* RI error (W): [] any write clears all error bits */ +#define RI_WERROR_REG (RI_BASE_REG+0x1C) + + +/************************************************************************* + * Serial Interface (SI) Registers + */ +#define SI_BASE_REG 0x04800000 + +/* SI DRAM address (R/W): [23:0] starting RDRAM address */ +#define SI_DRAM_ADDR_REG (SI_BASE_REG+0x00) /* R0: DRAM address */ + +/* SI address read 64B (W): [] any write causes a 64B DMA write */ +#define SI_PIF_ADDR_RD64B_REG (SI_BASE_REG+0x04) /* R1: 64B PIF->DRAM */ + +/* Address SI_BASE_REG + (0x08, 0x0c, 0x14) are reserved */ + +/* SI address write 64B (W): [] any write causes a 64B DMA read */ +#define SI_PIF_ADDR_WR64B_REG (SI_BASE_REG+0x10) /* R4: 64B DRAM->PIF */ + +/* + * SI status (W): [] any write clears interrupt + * (R): [0] DMA busy, [1] IO read busy, [2] reserved + * [3] DMA error, [12] interrupt + */ +#define SI_STATUS_REG (SI_BASE_REG+0x18) /* R6: Status */ + +/* SI status register has the following bits active: + * 0: DMA busy - set when DMA is in progress + * 1: IO busy - set when IO access is in progress + * 3: DMA error - set when there are overlapping DMA requests + * 12: Interrupt - Interrupt set + */ +#define SI_STATUS_DMA_BUSY 0x0001 +#define SI_STATUS_RD_BUSY 0x0002 +#define SI_STATUS_DMA_ERROR 0x0008 +#define SI_STATUS_INTERRUPT 0x1000 + +/************************************************************************* + * Development Board GIO Control Registers + */ + +#define GIO_BASE_REG 0x18000000 + +/* Game to Host Interrupt */ +#define GIO_GIO_INTR_REG (GIO_BASE_REG+0x000) + +/* Game to Host SYNC */ +#define GIO_GIO_SYNC_REG (GIO_BASE_REG+0x400) + +/* Host to Game Interrupt */ +#define GIO_CART_INTR_REG (GIO_BASE_REG+0x800) + + +/************************************************************************* + * Common macros + */ +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +#define IO_READ(addr) (*(vu32 *)PHYS_TO_K1(addr)) +#define IO_WRITE(addr,data) (*(vu32 *)PHYS_TO_K1(addr)=(u32)(data)) +#define RCP_STAT_PRINT \ + rmonPrintf("current=%x start=%x end=%x dpstat=%x spstat=%x\n", \ + IO_READ(DPC_CURRENT_REG), \ + IO_READ(DPC_START_REG), \ + IO_READ(DPC_END_REG), \ + IO_READ(DPC_STATUS_REG), \ + IO_READ(SP_STATUS_REG)) + +#endif + +#endif /* _RCP_H_ */ + diff --git a/include/2.0L/PR/rdb.h b/include/2.0L/PR/rdb.h new file mode 100755 index 00000000..c5c3159b --- /dev/null +++ b/include/2.0L/PR/rdb.h @@ -0,0 +1,93 @@ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:29:31 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/rdb.h,v $ + * + **************************************************************************/ + +#ifndef _RDB_H +#define _RDB_H + +/* U64 side address */ +#define RDB_BASE_REG 0xc0000000 +#define RDB_WRITE_INTR_REG (RDB_BASE_REG + 0x8) +#define RDB_READ_INTR_REG (RDB_BASE_REG + 0xc) +#define RDB_BASE_VIRTUAL_ADDR 0x80000000 + +/* packet type Have six bits, so can have up to 63 types */ +#define RDB_TYPE_INVALID 0 +#define RDB_TYPE_GtoH_PRINT 1 +#define RDB_TYPE_GtoH_FAULT 2 +#define RDB_TYPE_GtoH_LOG_CT 3 +#define RDB_TYPE_GtoH_LOG 4 +#define RDB_TYPE_GtoH_READY_FOR_DATA 5 +#define RDB_TYPE_GtoH_DATA_CT 6 +#define RDB_TYPE_GtoH_DATA 7 +#define RDB_TYPE_GtoH_DEBUG 8 +#define RDB_TYPE_GtoH_RAMROM 9 +#define RDB_TYPE_GtoH_DEBUG_DONE 10 +#define RDB_TYPE_GtoH_DEBUG_READY 11 +#define RDB_TYPE_GtoH_KDEBUG 12 +#define RDB_TYPE_GtoH_PROF_DATA 22 + + +#define RDB_TYPE_HtoG_LOG_DONE 13 +#define RDB_TYPE_HtoG_DEBUG 14 +#define RDB_TYPE_HtoG_DEBUG_CT 15 +#define RDB_TYPE_HtoG_DATA 16 +#define RDB_TYPE_HtoG_DATA_DONE 17 +#define RDB_TYPE_HtoG_REQ_RAMROM 18 +#define RDB_TYPE_HtoG_FREE_RAMROM 19 +#define RDB_TYPE_HtoG_KDEBUG 20 +#define RDB_TYPE_HtoG_PROF_SIGNAL 21 + + +#define RDB_PROF_ACK_SIG 1 +#define RDB_PROF_FLUSH_SIG 2 +#define PROF_BLOCK_SIZE 2048 + +#define RDB_LOG_MAX_BLOCK_SIZE 0x8000 +#define RDB_DATA_MAX_BLOCK_SIZE 0x8000 + + +/* GIO side address */ +#define GIO_RDB_BASE_REG 0xbf480000 +#define GIO_RDB_WRITE_INTR_REG (GIO_RDB_BASE_REG + 0x8) +#define GIO_RDB_READ_INTR_REG (GIO_RDB_BASE_REG + 0xc) + +/* minor device number */ +#define GIO_RDB_PRINT_MINOR 1 +#define GIO_RDB_DEBUG_MINOR 2 + +/* interrupt bit */ +#define GIO_RDB_WRITE_INTR_BIT 0x80000000 +#define GIO_RDB_READ_INTR_BIT 0x40000000 + +/* debug command */ +#define DEBUG_COMMAND_NULL 0 +#define DEBUG_COMMAND_MEMORY 1 +#define DEBUG_COMMAND_REGISTER 2 +#define DEBUG_COMMAND_INVALID 255 + +/* debug state */ +#define DEBUG_STATE_NULL 0 +#define DEBUG_STATE_RECEIVE 1 +#define DEBUG_STATE_INVALID 255 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Structure for debug port */ +typedef struct { + unsigned type : 6; /* 0: invalid, 1: print, 2: debug */ + unsigned length : 2; /* 1, 2, or 3 */ + char buf[3]; /* character buffer */ +} rdbPacket; + +extern unsigned int __osRdbWriteOK; +extern unsigned int __osRdbSendMessage; + +#endif /* _LANGUAGE_C */ + +#endif /* !_RDB_H */ diff --git a/include/2.0L/PR/region.h b/include/2.0L/PR/region.h new file mode 100755 index 00000000..9f8bb7f1 --- /dev/null +++ b/include/2.0L/PR/region.h @@ -0,0 +1,123 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * Module: region.h + * + * $Revision: 1.8 $ + * $Date: 1997/11/26 00:30:56 $ + * $Author: mitu $ + * $Source: /disk6/Master/cvsmdev2/PR/include/region.h,v $ + * + * Description: + * This file contains macros and structure definitions for the region + * library. + * + **************************************************************************/ + + +#ifndef _REGION_H_ +#define _REGION_H_ + + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + + +/*************************************** + * + * Global defines + * + */ + /* Alignment sizes */ +#define ALIGNSZ (sizeof(long long)) /* 8 bytes */ +#define ALIGNOFFST (ALIGNSZ-1) + + /* size for storing index to free buffer */ +#define BUF_CTRL_SIZE ALIGNSZ + + /* Max bufcount = 32K */ +#define MAX_BUFCOUNT 0x8000 + /* code for last free buffer */ +#define BUF_FREE_WO_NEXT 0x8000 + +/* + * Global defines for alignment size (default is 8-byte alignment) + */ +#define OS_RG_ALIGN_2B 2 /* 2 bytes = 16-bit alignment */ +#define OS_RG_ALIGN_4B 4 /* 4 bytes = 32-bit alignment */ +#define OS_RG_ALIGN_8B 8 /* 8 bytes = 64-bit alignment */ +#define OS_RG_ALIGN_16B 16 /* 16 bytes = 128-bit alignment */ + +#define OS_RG_ALIGN_DEFAULT OS_RG_ALIGN_8B + + +/*************************************** + * + * Macro definitions + * + */ + +/* Perform alignment on input 's' */ +#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1)) + + +/*************************************** + * + * Typedefs & structure definitions + * + */ +/* + * Structure for region header/control area + */ +typedef struct _Region_s { + u8 *r_startBufferAddress; /* start address to data buffer */ + u8 *r_endAddress; /* end address of region */ + s32 r_bufferSize; /* size of buffers for this region */ + s32 r_bufferCount; /* up to 32K entries; MSB is used for + setting end-of-list/used */ + u16 r_freeList; /* point to array index of first + available memory buffer */ + u16 r_alignSize; /* alignment size (# of bytes) */ +} OSRegion; + +/* + * Macro to simplify accessing region header structure + */ +#define RP(x) rp->r_##x + + +/*************************************** + * + * Function prototypes + * + */ +extern void *osCreateRegion(void *, u32, u32, u32); +extern void *osMalloc(void *); +extern void osFree(void *, void *); +extern s32 osGetRegionBufCount(void *); +extern s32 osGetRegionBufSize(void *); + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + + +#endif /* _REGION_H_ */ + + diff --git a/include/2.0L/PR/rmon.h b/include/2.0L/PR/rmon.h new file mode 100755 index 00000000..ea826d17 --- /dev/null +++ b/include/2.0L/PR/rmon.h @@ -0,0 +1,39 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:30:08 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/rmon.h,v $ + * + **************************************************************************/ + +#ifndef _RMON_H_ +#define _RMON_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#define RMON_DBG_BUF_SIZE 2048 +#define RMON_STACKSIZE 0x1000 + +extern void rmonMain( void * ); +extern void rmonPrintf( const char *, ... ); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_H */ diff --git a/include/2.0L/PR/sched.h b/include/2.0L/PR/sched.h new file mode 100755 index 00000000..9addae7d --- /dev/null +++ b/include/2.0L/PR/sched.h @@ -0,0 +1,115 @@ +/*==================================================================== + * sched.h + * + * Synopsis: + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.7 $ + * $Date: 1997/02/11 08:32:02 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/sched.h,v $ + * + **************************************************************************/ + +#ifndef __sched__ +#define __sched__ + +#include + +#define OS_SC_STACKSIZE 0x2000 + +#define OS_SC_RETRACE_MSG 1 +#define OS_SC_DONE_MSG 2 +#define OS_SC_RDP_DONE_MSG 3 +#define OS_SC_PRE_NMI_MSG 4 +#define OS_SC_LAST_MSG 4 /* this should have highest number */ +#define OS_SC_MAX_MESGS 8 + +typedef struct { + short type; + char misc[30]; +} OSScMsg; + +typedef struct OSScTask_s { + struct OSScTask_s *next; /* note: this must be first */ + u32 state; + u32 flags; + void *framebuffer; /* used by graphics tasks */ + + OSTask list; + OSMesgQueue *msgQ; + OSMesg msg; +#ifndef _FINALROM /* all #ifdef items should */ + OSTime startTime; /* remain at the end!!, or */ + OSTime totalTime; /* possible conflict if */ +#endif /* FINALROM library used with */ +} OSScTask; /* non FINALROM code */ + +/* + * OSScTask flags: + */ +#define OS_SC_NEEDS_RDP 0x0001 /* uses the RDP */ +#define OS_SC_NEEDS_RSP 0x0002 /* uses the RSP */ +#define OS_SC_DRAM_DLIST 0x0004 /* SP & DP communicate through DRAM */ +#define OS_SC_PARALLEL_TASK 0x0010 /* must be first gfx task on list */ +#define OS_SC_LAST_TASK 0x0020 /* last task in queue for frame */ +#define OS_SC_SWAPBUFFER 0x0040 /* swapbuffers when gfx task done */ + +#define OS_SC_RCP_MASK 0x0003 /* mask for needs bits */ +#define OS_SC_TYPE_MASK 0x0007 /* complete type mask */ +/* + * OSScClient: + * + * Data structure used by threads that wish to communicate to the + * scheduling thread + * + */ +typedef struct SCClient_s { + struct SCClient_s *next; /* next client in the list */ + OSMesgQueue *msgQ; /* where to send the frame msg */ +} OSScClient; + +typedef struct { + OSScMsg retraceMsg; + OSScMsg prenmiMsg; + OSMesgQueue interruptQ; + OSMesg intBuf[OS_SC_MAX_MESGS]; + OSMesgQueue cmdQ; + OSMesg cmdMsgBuf[OS_SC_MAX_MESGS]; + OSThread thread; + OSScClient *clientList; + OSScTask *audioListHead; + OSScTask *gfxListHead; + OSScTask *audioListTail; + OSScTask *gfxListTail; + OSScTask *curRSPTask; + OSScTask *curRDPTask; + u32 frameCount; + s32 doAudio; +} OSSched; + +void osCreateScheduler(OSSched *s, void *stack, OSPri priority, + u8 mode, u8 numFields); +void osScAddClient(OSSched *s, OSScClient *c, OSMesgQueue *msgQ); +void osScRemoveClient(OSSched *s, OSScClient *c); +OSMesgQueue *osScGetCmdQ(OSSched *s); + +#endif + diff --git a/include/2.0L/PR/sp.h b/include/2.0L/PR/sp.h new file mode 100755 index 00000000..24f11a1d --- /dev/null +++ b/include/2.0L/PR/sp.h @@ -0,0 +1,177 @@ +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * Sprite library include file + * + * $Revision: 1.15 $ + * $Date: 1997/02/11 08:33:02 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/sp.h,v $ + * + **************************************************************************/ + +#ifndef _SP_H_ +#define _SP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +struct bitmap { + s16 width; /* Size across to draw in texels */ + /* Done if width = 0 */ + + s16 width_img; /* Size across of bitmap in texels */ + /* Done if width = 0 */ + + s16 s; /* Horizontal offset into bitmap */ + /* if (s > width), then load only! */ + + s16 t; /* Vertical offset into base */ + + void *buf; /* Pointer to bitmap data */ + /* Don't re-load if new buf */ + /* is the same as the old one */ + /* Skip if NULL */ + + s16 actualHeight; /* True Height of this bitmap piece */ + + s16 LUToffset; /* LUT base index */ +}; + +typedef struct bitmap Bitmap; + +struct sprite { + s16 x,y; /* Target position */ + + s16 width, height; /* Target size */ + + f32 scalex, scaley; /* Texel to Pixel scale factor */ + + s16 expx, expy; /* Explosion spacing */ + + u16 attr; /* Attribute Flags */ + s16 zdepth; /* Z Depth */ + + u8 red; /* Red component */ + u8 green; /* Green component */ + u8 blue; /* Blue component */ + u8 alpha; /* Alpha component */ + + s16 startTLUT; /* Lookup Table Entry Starting index */ + s16 nTLUT; /* Total number of Lookup Table Entries */ + + int *LUT; /* Pointer to Lookup Table */ + + s16 istart; /* Starting bitmap index */ + s16 istep; /* Bitmaps index step (see SP_INCY) */ + /* if 0, then variable width bitmaps */ + + s16 nbitmaps; /* Total number of bitmaps */ + s16 ndisplist; /* Total number of display-list words */ + + s16 bmheight; /* Bitmap Texel height (Used) */ + s16 bmHreal; /* Bitmap Texel height (Real) */ + u8 bmfmt; /* Bitmap Format */ + u8 bmsiz; /* Bitmap Texel Size */ + + Bitmap *bitmap; /* Pointer to first bitmap */ + + Gfx *rsp_dl; /* Pointer to RSP display list */ + + Gfx *rsp_dl_next; /* Pointer to next RSP display entry */ + + s16 frac_s, /* Fractional Texture offsets */ + frac_t; /* These have 5 fraction bits */ +}; + +typedef struct sprite Sprite; + +/* + * DANGER! + * This is bad programming. Where the *heck* do these numbers come + * from? + * + * They are obviously 'maximums' from the sprite library, but since + * the sprite library is built on top of gbi.h, which includes macros + * that decode into multiple macros, etc., it is nearly impossible to + * know what these maximums should be. + * + * Worse, there are some gbi macros (texture alignment mostly) that + * decode into *many* macros, so if we choose that as a maximum, we + * are wasting TONS of space... + * + * These numbers work for "reasonable" sprite library usage, and + * there is an assert() in the library to detect when they aren't + * enough. (use the debug version) + */ +#define DL_BM_OVERHEAD (12) +#define DL_SPRITE_OVERHEAD (24) + +#define NUM_DL(nb) ((nb)*DL_BM_OVERHEAD +DL_SPRITE_OVERHEAD) + +/* + * Misc constants + */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +/* + * For sprite->attr + */ + +#define SP_TRANSPARENT 0x00000001 +#define SP_CUTOUT 0x00000002 +#define SP_HIDDEN 0x00000004 +#define SP_Z 0x00000008 +#define SP_SCALE 0x00000010 +#define SP_FASTCOPY 0x00000020 +#define SP_OVERLAP 0x00000040 +#define SP_TEXSHIFT 0x00000080 +#define SP_FRACPOS 0x00000100 +#define SP_TEXSHUF 0x00000200 +#define SP_EXTERN 0x00000400 + +/* + * Function prototypes + */ + +void spSetAttribute (Sprite *sp, s32 attr); +void spClearAttribute (Sprite *sp, s32 attr); +void spMove (Sprite *sp, s32 x, s32 y); +void spScale (Sprite *sp, f32 sx, f32 sy); +void spSetZ (Sprite *sp, s32 z ); +void spColor (Sprite *sp, u8 red, u8 green, u8 blue, u8 alpha); +Gfx *spDraw (Sprite *sp); +void spInit( Gfx **glistp ); +void spScissor( s32 xmin, s32 xmax, s32 ymin, s32 ymax ); +void spFinish( Gfx **glistp ); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* _SP_H_ */ diff --git a/include/2.0L/PR/sptask.h b/include/2.0L/PR/sptask.h new file mode 100755 index 00000000..603d92e0 --- /dev/null +++ b/include/2.0L/PR/sptask.h @@ -0,0 +1,201 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.8 $ + * $Date: 1997/11/10 10:48:35 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/sptask.h,v $ + * + **************************************************************************/ + +#ifndef _SPTASK_H_ +#define _SPTASK_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Task List Structure. + * + * Things an app might pass to the SP via the task list. + * Not every task ucode would need/use every field, but + * + * - type (audio, gfx, video, ...) + * - flags + * - wait for DP to drain before running new task + * - SEE BIT DEFINITIONS UNDER "Task Flags field" + * - pointer to boot ucode + * - size of boot ucode + * - pointer to ucode + * - size of ucode + * - pointer to initial DMEM data + * - size of initial DMEM data + * - pointer to DRAM stack + * - size of DRAM stack (max) + * - pointer to output buffer + * - pointer to store output buffer length + * - generic data pointer (for display list, etc.) + * - generic data length (for display list, etc.) + * - pointer to buffer where to store saved DMEM (in yield case) + * - size of buffer to store saved DMEM. + * + * IMPORTANT!!! Watch alignment issues. + * + * IMPORTANT!!! Watch data cache issues. The RCP may write data into the + * dram_stack, output_buff, output_buff_size, and the yield_data_ptr areas. + * These buffers should be cache aligned and use the entire line (16 bytes) to + * avoid corruption by writebacks by the CPU (cache tearing). + * + * IMPORTANT!!! all addresses are virtual addresses. Library does + * any necessary translation. + * + */ +typedef struct { + u32 type; + u32 flags; + + u64 *ucode_boot; + u32 ucode_boot_size; + + u64 *ucode; + u32 ucode_size; + + u64 *ucode_data; + u32 ucode_data_size; + + u64 *dram_stack; + u32 dram_stack_size; + + u64 *output_buff; + u64 *output_buff_size; + + u64 *data_ptr; + u32 data_size; + + u64 *yield_data_ptr; + u32 yield_data_size; + +} OSTask_t; + +typedef union { + OSTask_t t; + long long int force_structure_alignment; +} OSTask; + +typedef u32 OSYieldResult; + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_ASSEMBLY + +/* + * For the RSP ucode: + * offsets into the task structure + */ + +#include + +#endif + +/* + * Task Flags field + */ +#define OS_TASK_YIELDED 0x0001 +#define OS_TASK_DP_WAIT 0x0002 +#define OS_TASK_LOADABLE 0x0004 +#define OS_TASK_SP_ONLY 0x0008 +#define OS_TASK_USR0 0x0010 +#define OS_TASK_USR1 0x0020 +#define OS_TASK_USR2 0x0040 +#define OS_TASK_USR3 0x0080 + +/* + * Size of Yield buffer. The taskHdrPtr->t.yield_data_ptr must point to a + * buffer of this size. (The size is in bytes). ONLY If the task will NEVER + * yield it may be a null pointer. The buffer must be aligned to a 64 bit + * boundary. The taskHdrPtr->t.yield_data_ptr must be set to point to the + * buffer BEFORE the task is started. + */ +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)|| defined(F3DEX2_GBI)) +#define OS_YIELD_DATA_SIZE 0xc00 +#else +#define OS_YIELD_DATA_SIZE 0x900 +#endif +#define OS_YIELD_AUDIO_SIZE 0x400 + +/************************************************************************** + * + * Global definitions + * + */ + + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* + * this macro simulates atomic action. + */ +#define osSpTaskStart(tp) \ + { \ + osSpTaskLoad((tp)); \ + osSpTaskStartGo((tp)); \ + } + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* + * break this up into two steps for debugging. + */ +extern void osSpTaskLoad(OSTask *tp); +extern void osSpTaskStartGo(OSTask *tp); + +extern void osSpTaskYield(void); +extern OSYieldResult osSpTaskYielded(OSTask *tp); + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_SPTASK_H */ diff --git a/include/2.0L/PR/ucode.h b/include/2.0L/PR/ucode.h new file mode 100755 index 00000000..1025d2f9 --- /dev/null +++ b/include/2.0L/PR/ucode.h @@ -0,0 +1,186 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.13 $ + * $Date: 1997/11/07 04:55:12 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ucode.h,v $ + * + **************************************************************************/ + +#ifndef _UCODE_H_ +#define _UCODE_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* + * This is the recommended size of the SP DRAM stack area, used + * by the graphics ucode. This stack is used primarily for the + * matrix stack, so it needs to be AT LEAST (10 * 64bytes) in size. + */ +#define SP_DRAM_STACK_SIZE8 (1024) +#define SP_DRAM_STACK_SIZE64 (SP_DRAM_STACK_SIZE8 >> 3) + +/* + * This is the size of the IMEM, which is also the size of the + * graphics microcode. (other ucode might be less) + * This value is used in apps to tell the OS how much ucode to + * load. + */ +#define SP_UCODE_SIZE 4096 + +/* + * This is 1/2 the size of DMEM, which is the maximum amount of + * initialized DMEM data any of the ucode tasks need to start up. + * This value is dependent on all of the task ucodes, and is therefore + * fixed per release. + */ +#define SP_UCODE_DATA_SIZE 2048 + + +/************************************************************************** + * + * Extern variables + * + */ + +/* + * Symbols generated by "rsp2elf", included by "makerom" that indicate + * the location and size of the SP microcode objects. The ucode objects + * are loaded as part of the codesegment (arbitrary, could do other + * ways) + * + */ + +/* standard boot ucode: */ +extern long long int rspbootTextStart[], rspbootTextEnd[]; + +/* standard 3D ucode: */ +extern long long int gspFast3DTextStart[], gspFast3DTextEnd[]; +extern long long int gspFast3DDataStart[], gspFast3DDataEnd[]; + +/* 3D ucode with output to DRAM: */ +extern long long int gspFast3D_dramTextStart[], gspFast3D_dramTextEnd[]; +extern long long int gspFast3D_dramDataStart[], gspFast3D_dramDataEnd[]; + +/* 3D ucode with output through DRAM FIFO to RDP: */ +extern long long int gspFast3D_fifoTextStart[], gspFast3D_fifoTextEnd[]; +extern long long int gspFast3D_fifoDataStart[], gspFast3D_fifoDataEnd[]; + +/* 3D ucode without nearclip: */ +extern long long int gspF3DNoNTextStart[], gspF3DNoNTextEnd[]; +extern long long int gspF3DNoNDataStart[], gspF3DNoNDataEnd[]; + +/* 3D ucode without nearclip with output to DRAM: */ +extern long long int gspF3DNoN_dramTextStart[]; +extern long long int gspF3DNoN_dramTextEnd[]; +extern long long int gspF3DNoN_dramDataStart[]; +extern long long int gspF3DNoN_dramDataEnd[]; + +/* 3D ucode without nearclip with output through DRAM FIFO to RDP: */ +extern long long int gspF3DNoN_fifoTextStart[]; +extern long long int gspF3DNoN_fifoTextEnd[]; +extern long long int gspF3DNoN_fifoDataStart[]; +extern long long int gspF3DNoN_fifoDataEnd[]; + +/* 3D line ucode: */ +extern long long int gspLine3DTextStart[], gspLine3DTextEnd[]; +extern long long int gspLine3DDataStart[], gspLine3DDataEnd[]; + +/* 3D line ucode with output to DRAM: */ +extern long long int gspLine3D_dramTextStart[], gspLine3D_dramTextEnd[]; +extern long long int gspLine3D_dramDataStart[], gspLine3D_dramDataEnd[]; + +/* 3D line ucode with output through DRAM FIFO to RDP: */ +extern long long int gspLine3D_fifoTextStart[], gspLine3D_fifoTextEnd[]; +extern long long int gspLine3D_fifoDataStart[], gspLine3D_fifoDataEnd[]; + +/* 2D sprite ucode: */ +extern long long int gspSprite2DTextStart[], gspSprite2DTextEnd[]; +extern long long int gspSprite2DDataStart[], gspSprite2DDataEnd[]; + +/* 2D sprite ucode with output to DRAM: */ +extern long long int gspSprite2D_dramTextStart[], gspSprite2D_dramTextEnd[]; +extern long long int gspSprite2D_dramDataStart[], gspSprite2D_dramDataEnd[]; + +/* 2D sprite ucode with output through DRAM FIFO to RDP: */ +extern long long int gspSprite2D_fifoTextStart[], gspSprite2D_fifoTextEnd[]; +extern long long int gspSprite2D_fifoDataStart[], gspSprite2D_fifoDataEnd[]; + +/* basic audio ucode: */ +extern long long int aspMainTextStart[], aspMainTextEnd[]; +extern long long int aspMainDataStart[], aspMainDataEnd[]; + +/*========== F3DEX/F3DLX/F3DLP/L3DEX ==========*/ +/* FIFO version only */ +extern long long int gspF3DEX_fifoTextStart[], gspF3DEX_fifoTextEnd[]; +extern long long int gspF3DEX_fifoDataStart[], gspF3DEX_fifoDataEnd[]; +extern long long int gspF3DEX_NoN_fifoTextStart[], gspF3DEX_NoN_fifoTextEnd[]; +extern long long int gspF3DEX_NoN_fifoDataStart[], gspF3DEX_NoN_fifoDataEnd[]; + +extern long long int gspF3DLX_fifoTextStart[], gspF3DLX_fifoTextEnd[]; +extern long long int gspF3DLX_fifoDataStart[], gspF3DLX_fifoDataEnd[]; +extern long long int gspF3DLX_NoN_fifoTextStart[], gspF3DLX_NoN_fifoTextEnd[]; +extern long long int gspF3DLX_NoN_fifoDataStart[], gspF3DLX_NoN_fifoDataEnd[]; +extern long long int gspF3DLX_Rej_fifoTextStart[], gspF3DLX_Rej_fifoTextEnd[]; +extern long long int gspF3DLX_Rej_fifoDataStart[], gspF3DLX_Rej_fifoDataEnd[]; + +extern long long int gspF3DLP_Rej_fifoTextStart[], gspF3DLP_Rej_fifoTextEnd[]; +extern long long int gspF3DLP_Rej_fifoDataStart[], gspF3DLP_Rej_fifoDataEnd[]; +extern long long int gspL3DEX_fifoTextStart[], gspL3DEX_fifoTextEnd[]; +extern long long int gspL3DEX_fifoDataStart[], gspL3DEX_fifoDataEnd[]; + +/*========== F3DEX2/F3DLX2/F3DLP2/L3DEX2 ==========*/ +/* FIFO version only */ +extern long long int gspF3DEX2_fifoTextStart[], gspF3DEX2_fifoTextEnd[]; +extern long long int gspF3DEX2_fifoDataStart[], gspF3DEX2_fifoDataEnd[]; +extern long long int gspF3DEX2_NoN_fifoTextStart[],gspF3DEX2_NoN_fifoTextEnd[]; +extern long long int gspF3DEX2_NoN_fifoDataStart[],gspF3DEX2_NoN_fifoDataEnd[]; + +extern long long int gspF3DLX2_fifoTextStart[], gspF3DLX2_fifoTextEnd[]; +extern long long int gspF3DLX2_fifoDataStart[], gspF3DLX2_fifoDataEnd[]; +extern long long int gspF3DLX2_NoN_fifoTextStart[],gspF3DLX2_NoN_fifoTextEnd[]; +extern long long int gspF3DLX2_NoN_fifoDataStart[],gspF3DLX2_NoN_fifoDataEnd[]; +extern long long int gspF3DLX2_Rej_fifoTextStart[],gspF3DLX2_Rej_fifoTextEnd[]; +extern long long int gspF3DLX2_Rej_fifoDataStart[],gspF3DLX2_Rej_fifoDataEnd[]; + +extern long long int gspF3DLP2_Rej_fifoTextStart[],gspF3DLP2_Rej_fifoTextEnd[]; +extern long long int gspF3DLP2_Rej_fifoDataStart[],gspF3DLP2_Rej_fifoDataEnd[]; +extern long long int gspL3DEX2_fifoTextStart[], gspL3DEX2_fifoTextEnd[]; +extern long long int gspL3DEX2_fifoDataStart[], gspL3DEX2_fifoDataEnd[]; + +/************************************************************************** + * + * Function prototypes + * + */ + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_UCODE_H */ diff --git a/include/2.0L/PR/ultraerror.h b/include/2.0L/PR/ultraerror.h new file mode 100755 index 00000000..ef470ba7 --- /dev/null +++ b/include/2.0L/PR/ultraerror.h @@ -0,0 +1,165 @@ +/*==================================================================== + * ultraerror.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.23 $ + * $Date: 1997/02/11 08:38:08 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ultraerror.h,v $ + * + **************************************************************************/ + +#ifndef __ULTRAERROR_H__ +#define __ULTRAERROR_H__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#define OS_ERROR_FMT "/usr/lib/PR/error.fmt" +#define OS_ERROR_MAGIC 0x6b617479 + +/* OS error codes */ + +#define ERR_OSCREATETHREAD_SP 1 +#define ERR_OSCREATETHREAD_PRI 2 +#define ERR_OSSTARTTHREAD 3 +#define ERR_OSSETTHREADPRI 4 +#define ERR_OSCREATEMESGQUEUE 5 +#define ERR_OSSENDMESG 6 +#define ERR_OSJAMMESG 7 +#define ERR_OSRECVMESG 8 +#define ERR_OSSETEVENTMESG 9 +#define ERR_OSMAPTLB_INDEX 10 +#define ERR_OSMAPTLB_ASID 11 +#define ERR_OSUNMAPTLB 12 +#define ERR_OSSETTLBASID 13 +#define ERR_OSAISETFREQUENCY 14 +#define ERR_OSAISETNEXTBUFFER_ADDR 15 +#define ERR_OSAISETNEXTBUFFER_SIZE 16 +#define ERR_OSDPSETNEXTBUFFER_ADDR 17 +#define ERR_OSDPSETNEXTBUFFER_SIZE 18 +#define ERR_OSPIRAWREADIO 19 +#define ERR_OSPIRAWWRITEIO 20 +#define ERR_OSPIRAWSTARTDMA_DIR 21 +#define ERR_OSPIRAWSTARTDMA_DEVADDR 22 +#define ERR_OSPIRAWSTARTDMA_ADDR 23 +#define ERR_OSPIRAWSTARTDMA_SIZE 24 +#define ERR_OSPIRAWSTARTDMA_RANGE 25 +#define ERR_OSPIREADIO 26 +#define ERR_OSPIWRITEIO 27 +#define ERR_OSPISTARTDMA_PIMGR 28 +#define ERR_OSPISTARTDMA_PRI 29 +#define ERR_OSPISTARTDMA_DIR 30 +#define ERR_OSPISTARTDMA_DEVADDR 31 +#define ERR_OSPISTARTDMA_ADDR 32 +#define ERR_OSPISTARTDMA_SIZE 33 +#define ERR_OSPISTARTDMA_RANGE 34 +#define ERR_OSCREATEPIMANAGER 35 +#define ERR_OSVIGETCURRENTMODE 36 +#define ERR_OSVIGETCURRENTFRAMEBUFFER 37 +#define ERR_OSVIGETNEXTFRAMEBUFFER 38 +#define ERR_OSVISETXSCALE_VALUE 39 +#define ERR_OSVISETXSCALE_VIMGR 40 +#define ERR_OSVISETYSCALE_VALUE 41 +#define ERR_OSVISETYSCALE_VIMGR 42 +#define ERR_OSVISETSPECIAL_VALUE 43 +#define ERR_OSVISETSPECIAL_VIMGR 44 +#define ERR_OSVISETMODE 45 +#define ERR_OSVISETEVENT 46 +#define ERR_OSVISWAPBUFFER_ADDR 47 +#define ERR_OSVISWAPBUFFER_VIMGR 48 +#define ERR_OSCREATEVIMANAGER 49 +#define ERR_OSCREATEREGION_ALIGN 50 +#define ERR_OSCREATEREGION_SIZE 51 +#define ERR_OSMALLOC 52 +#define ERR_OSFREE_REGION 53 +#define ERR_OSFREE_ADDR 54 +#define ERR_OSGETREGIONBUFCOUNT 55 +#define ERR_OSGETREGIONBUFSIZE 56 +#define ERR_OSSPTASKLOAD_DRAM 57 +#define ERR_OSSPTASKLOAD_OUT 58 +#define ERR_OSSPTASKLOAD_OUTSIZE 59 +#define ERR_OSSPTASKLOAD_YIELD 60 +#define ERR_OSPROFILEINIT_STR 61 +#define ERR_OSPROFILEINIT_CNT 62 +#define ERR_OSPROFILEINIT_ALN 63 +#define ERR_OSPROFILEINIT_ORD 64 +#define ERR_OSPROFILEINIT_SIZ 65 +#define ERR_OSPROFILESTART_TIME 66 +#define ERR_OSPROFILESTART_FLAG 67 +#define ERR_OSPROFILESTOP_FLAG 68 +#define ERR_OSPROFILESTOP_TIMER 69 +#define ERR_OSREADHOST_ADDR 70 +#define ERR_OSREADHOST_SIZE 71 +#define ERR_OSWRITEHOST_ADDR 72 +#define ERR_OSWRITEHOST_SIZE 73 +#define ERR_OSGETTIME 74 +#define ERR_OSSETTIME 75 +#define ERR_OSSETTIMER 76 +#define ERR_OSSTOPTIMER 77 +#define ERR_ALSEQP_NO_SOUND 100 +#define ERR_ALSEQP_NO_VOICE 101 +#define ERR_ALSEQP_MAP_VOICE 102 +#define ERR_ALSEQP_OFF_VOICE 103 +#define ERR_ALSEQP_POLY_VOICE 104 +#define ERR_ALSNDP_NO_VOICE 105 +#define ERR_ALSYN_NO_UPDATE 106 +#define ERR_ALSNDPDEALLOCATE 107 +#define ERR_ALSNDPDELETE 108 +#define ERR_ALSNDPPLAY 109 +#define ERR_ALSNDPSETSOUND 110 +#define ERR_ALSNDPSETPRIORITY 111 +#define ERR_ALSNDPSETPAR 112 +#define ERR_ALBNKFNEW 113 +#define ERR_ALSEQNOTMIDI 114 +#define ERR_ALSEQNOTMIDI0 115 +#define ERR_ALSEQNUMTRACKS 116 +#define ERR_ALSEQTIME 117 +#define ERR_ALSEQTRACKHDR 118 +#define ERR_ALSEQSYSEX 119 +#define ERR_ALSEQMETA 120 +#define ERR_ALSEQPINVALIDPROG 121 +#define ERR_ALSEQPUNKNOWNMIDI 122 +#define ERR_ALSEQPUNMAP 123 +#define ERR_ALEVENTNOFREE 124 +#define ERR_ALHEAPNOFREE 125 +#define ERR_ALHEAPCORRUPT 126 +#define ERR_ALHEAPFIRSTBLOCK 127 +#define ERR_ALCSEQZEROSTATUS 128 +#define ERR_ALCSEQZEROVEL 129 +#define ERR_ALCSPVNOTFREE 130 +#define ERR_ALSEQOVERRUN 131 +#define ERR_OSAISETNEXTBUFFER_ENDADDR 132 +#define ERR_ALMODDELAYOVERFLOW 133 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +typedef void (*OSErrorHandler)(s16, s16, ...); + +OSErrorHandler osSetErrorHandler(OSErrorHandler); +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* __ULTRAERROR_H__ */ diff --git a/include/2.0L/PR/ultralog.h b/include/2.0L/PR/ultralog.h new file mode 100755 index 00000000..9f37359c --- /dev/null +++ b/include/2.0L/PR/ultralog.h @@ -0,0 +1,74 @@ +/*==================================================================== + * ultralog.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:39:05 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ultralog.h,v $ + * + **************************************************************************/ + +#ifndef __log__ +#define __log__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#define OS_LOG_MAX_ARGS 16 +#define OS_LOG_MAGIC 0x20736a73 +#define OS_LOG_FLOAT(x) (*(int *) &(x)) +#define OS_LOG_VERSION 1 + +typedef struct { + u32 magic; /* log identifier */ + u32 len; /* length of log data + log structure */ + u32 *base; /* starting addr array */ + s32 startCount; /* read offset from dataBase */ + s32 writeOffset; /* write offset from dataBase */ +} OSLog; + +typedef struct { + u32 magic; + u32 timeStamp; + u16 argCount; + u16 eventID; +} OSLogItem; + +typedef struct { + u32 magic; /* log identifier */ + u32 version; /* 1 */ +} OSLogFileHdr; + +void osCreateLog(OSLog *log, u32 *base, s32 len); +void osLogEvent(OSLog *log, s16 code, s16 numArgs, ...); +void osFlushLog(OSLog *log); +u32 osLogFloat(f32); + +extern void osDelay(int count); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif diff --git a/include/2.0L/PR/ultratypes.h b/include/2.0L/PR/ultratypes.h new file mode 100755 index 00000000..58fef8bd --- /dev/null +++ b/include/2.0L/PR/ultratypes.h @@ -0,0 +1,90 @@ +#ifndef _ULTRATYPES_H_ +#define _ULTRATYPES_H_ + + +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + + +/************************************************************************* + * + * File: ultratypes.h + * + * This file contains various types used in Ultra64 interfaces. + * + * $Revision: 1.6 $ + * $Date: 1997/12/17 04:02:06 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ultratypes.h,v $ + * + **************************************************************************/ + + + +/********************************************************************** + * General data types for R4300 + */ +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +typedef unsigned char u8; /* unsigned 8-bit */ +typedef unsigned short u16; /* unsigned 16-bit */ +typedef unsigned long u32; /* unsigned 32-bit */ +typedef unsigned long long u64; /* unsigned 64-bit */ + +typedef signed char s8; /* signed 8-bit */ +typedef short s16; /* signed 16-bit */ +typedef long s32; /* signed 32-bit */ +typedef long long s64; /* signed 64-bit */ + +typedef volatile unsigned char vu8; /* unsigned 8-bit */ +typedef volatile unsigned short vu16; /* unsigned 16-bit */ +typedef volatile unsigned long vu32; /* unsigned 32-bit */ +typedef volatile unsigned long long vu64; /* unsigned 64-bit */ + +typedef volatile signed char vs8; /* signed 8-bit */ +typedef volatile short vs16; /* signed 16-bit */ +typedef volatile long vs32; /* signed 32-bit */ +typedef volatile long long vs64; /* signed 64-bit */ + +typedef float f32; /* single prec floating point */ +typedef double f64; /* double prec floating point */ + +#if !defined(_SIZE_T) && !defined(_SIZE_T_) && !defined(_SIZE_T_DEF) +#define _SIZE_T +#define _SIZE_T_DEF /* exeGCC size_t define label */ +#if (_MIPS_SZLONG == 32) +typedef unsigned int size_t; +#endif +#if (_MIPS_SZLONG == 64) +typedef unsigned long size_t; +#endif +#endif + +#endif /* _LANGUAGE_C */ + + +/************************************************************************* + * Common definitions + */ +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#endif /* _ULTRATYPES_H_ */ + diff --git a/include/2.0L/PR/uportals.h b/include/2.0L/PR/uportals.h new file mode 100755 index 00000000..28a1466f --- /dev/null +++ b/include/2.0L/PR/uportals.h @@ -0,0 +1,134 @@ +/*==================================================================== + * uportals.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * uportals.h - header file for the ultraportals library + * + * $Revision: 1.12 $ + * $Date: 1997/02/11 08:40:49 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/uportals.h,v $ + * + **************************************************************************/ + + + +#ifndef __ULTRAPORTALS_H__ +#define __ULTRAPORTALS_H__ + +#include +#include "matrix.h" +#include "vector.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ENABLEPORTALS +#define ENABLEPORTALS +#endif + +#define UP_MAXPVERTS 16 /* max number of portal verts */ +#define UP_MAXCELLS 50 /* max number of cells */ +#define UP_CELLNL 32 /* max length of cell names */ +#define UP_OBNL 32 /* max length of obejct names */ + +typedef struct +{ + vec3 min, max; /* min and max pts of the box */ +} upBox; + +typedef struct _upPortalData * _portalptr; +typedef struct _upCellData * _cellptr; +typedef struct _upObjectData * _objectptr; + +typedef struct _upPortalData +{ + int numverts; /* number of verts in the portal*/ + _cellptr attached_cell; /* cell on the 'other side' */ + vec3 verts[UP_MAXPVERTS]; /* the actual vertices */ +#ifdef MVTVIEW + int mvt_id; /* if has mvt, this is the id */ +#endif +} upPortalData; + +typedef struct _upCellData +{ + int numportals; /* number of portals */ + int numobjects; /* number of objects */ + int rendered; /* last frame number rendered */ + _portalptr *portals; /* array for the actual portals */ + _objectptr *objects; /* array for 'detail' objects */ + upBox bbox; /* bounding box of the cell */ + Gfx *dlist; /* associated display list */ + char name[UP_CELLNL]; /* name of the cell */ + float eyeheight; /* height to constrain eyept to */ + int zone; /* current zone number */ +} upCellData; + +typedef struct _upObjectData +{ + int rendered; /* last frame number rendered */ + upBox bbox; /* bounding box for the object */ + Gfx *dlist; /* associated display list */ + char name[UP_OBNL]; /* name of the object */ +} upObjectData; + +typedef struct +{ + int numcells; /* how many cells are there? */ + upCellData cells[UP_MAXCELLS]; /* the actual cells */ + Gfx *rootdlist; /* display list for all cells */ + vec2 portalmin, portalmax; /* XY bbox used by upCheckCells */ + float near, far; /* near, far clipping planes */ + FMatrix viewmat; /* viewing matrix (world->eye) */ + FMatrix projmat; /* proj matrix (eye->screen) */ + FMatrix compmat; /* view * proj (world->screen) */ + int portaldepth; /* depth of the portal stack */ + int framecount; /* current frame number */ +} upLocateData; + +/* + * Functions: + */ +extern void upInit(); /* generated automatically by flt2walk */ +extern Gfx *upAddVisibleCells(Gfx * glistp, vec3 eyept); +extern void upTogglePortalBounds(); +extern void upToggleScissorBox(); + +/* + * Globals: + */ +extern upLocateData upLocator; /* also extern by test_portals.h */ + +/* + * Macros: + */ +#define UP_HUGEVAL 3.40282347e+37 +#define PT_IN_BOX(p,box) ((p)[0] > (box).min[0] && (p)[0] < (box).max[0] &&\ + (p)[1] > (box).min[1] && (p)[1] < (box).max[1] &&\ + (p)[2] > (box).min[2] && (p)[2] < (box).max[2]) + + +#ifdef __Cplusplus +} +#endif + +#endif diff --git a/include/2.0L/assert.h b/include/2.0L/assert.h new file mode 100755 index 00000000..a3736e37 --- /dev/null +++ b/include/2.0L/assert.h @@ -0,0 +1,54 @@ +#ifndef __ASSERT_H__ +#define __ASSERT_H__ +#ifdef __cplusplus +extern "C" { +#endif +/************************************************************************** + * * + * Copyright (C) 1984, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ +/* Copyright (c) 1984 AT&T */ +/* All Rights Reserved */ + +/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ +/* The copyright notice above does not evidence any */ +/* actual or intended publication of such source code. */ + +#ident "$Revision: 1.17 $" + +/* ANSI C Notes: + * + * - THE IDENTIFIERS APPEARING OUTSIDE OF #ifdef __EXTENSIONS__ IN THIS + * standard header ARE SPECIFIED BY ANSI! CONFORMANCE WILL BE ALTERED + * IF ANY NEW IDENTIFIERS ARE ADDED TO THIS AREA UNLESS THEY ARE IN ANSI's + * RESERVED NAMESPACE. (i.e., unless they are prefixed by __[a-z] or + * _[A-Z]. For external objects, identifiers with the prefix _[a-z] + * are also reserved.) + */ + +#ifdef NDEBUG +#undef assert +#define assert(EX) ((void)0) + +#else + +extern void __assert(const char *, const char *, int); +#ifdef __ANSI_CPP__ +#define assert(EX) ((EX)?((void)0):__assert( # EX , __FILE__, __LINE__)) +#else +#define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__)) +#endif +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__ASSERT_H__ */ diff --git a/include/2.0L/bstring.h b/include/2.0L/bstring.h new file mode 100755 index 00000000..4ed25959 --- /dev/null +++ b/include/2.0L/bstring.h @@ -0,0 +1,36 @@ +#ifndef __BSTRING_H__ +#define __BSTRING_H__ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * bstring(3C) -- byte string operations + * + * Copyright 1990, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied or + * duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - + * rights reserved under the Copyright Laws of the United States. + */ + +#ident "$Revision: 1.4 $" + +extern void bcopy(const void *, void *, int); +extern int bcmp(const void *, const void *, int); +extern void bzero(void *, int); +extern void blkclr(void *, int); + +#ifdef __cplusplus +} +#endif +#endif /* !__BSTRING_H__ */ diff --git a/include/2.0L/make/PRdefs b/include/2.0L/make/PRdefs new file mode 100755 index 00000000..f5456a7a --- /dev/null +++ b/include/2.0L/make/PRdefs @@ -0,0 +1,85 @@ +# +# Commondefs for Project Reality source tree +# +# Makefiles which include this should first define PRDEPTH to be the relative +# path from their parent directory. + +include $(ROOT)/usr/include/make/commondefs + +# +# Use $(MAKE) $(MAKEARGS) instead of $(MAKEF) so that make -n works +# This gets around the fact that $(MAKE) works and $(MAKEF) does not. +# MAKEARGS is based directly on $(MAKEF) in commondefs. +# +MAKEARGS = VCFLAGS="$(VCFLAGS)" VFFLAGS="$(VFFLAGS)" \ + VPFLAGS="$(VPFLAGS)" VMKDEPFLAGS="$(VMKDEPFLAGS)" + +# make sure 'default' does not hit these rules +defaultrule: default + +# +# Compile tree for RCP 1.0 or RCP 2.0 +# +#GCDEFS = $(HW_FLAGS) +#GCDEFS = $(HW_FLAGS) -B -Wab,-r4300_mul +#ifdef __GCC__ +GCDEFS = +#else +GCDEFS = $(HW_FLAGS) -Wab,-r4300_mul +#endif + +# +# VCS compiler options +# +VCSOPTS = $(GVCSOPTS) $(LVCSOPTS) $(VVCSOPTS) +GVCSOPTS = +acc -V -M -Mupdate -Mmakep=pmake \ + -CC "-mips2 -Wab,-big_got -Wab,-dwalign" -lgl -limage \ + -P $(PRDEPTH)/rdpsim/pli/pli.tab $(ROOT)/usr/lib/PR/libpli.a + +SHELL = /bin/sh + +FLT2C = $(ROOT)/usr/sbin/flt2c +IC = $(ROOT)/usr/sbin/ic +#ifdef __GCC__ +MAKEROM = $(GCCDIR)/mipse/bin/mild +#else +MAKEROM = $(ROOT)/usr/sbin/makerom +#endif +MIDIPARSE = $(ROOT)/usr/sbin/midiparse +MIDICVT = $(ROOT)/usr/sbin/midicvt +MIDICOMP = $(ROOT)/usr/sbin/midicomp +SBC = $(ROOT)/usr/sbin/sbc +NLD = $(ROOT)/usr/sbin/nld +RGB2C = $(ROOT)/usr/sbin/rgb2c +MKSPRITE = $(ROOT)/usr/sbin/mksprite +MKISPRITE = $(ROOT)/usr/sbin/mkisprite +TABLEDESIGN = $(ROOT)/usr/sbin/tabledesign +VADPCM_ENC = $(ROOT)/usr/sbin/vadpcm_enc +RSPASM = $(ROOT)/usr/sbin/rspasm +BUILDTASK = $(ROOT)/usr/sbin/buildtask +RSP2ELF = $(ROOT)/usr/sbin/rsp2elf + +DATA2RDRAM = $(PRDEPTH)/tools/data/data2rdram +RDRAM2DATA = $(PRDEPTH)/tools/data/rdram2data +TMEMFMT = $(PRDEPTH)/tools/tmemfmt/tmemfmt + +ECS2VL = $(PRDEPTH)/rdpsim/tools/ecs2vl +ECSGEN = $(PRDEPTH)/rdpsim/tools/ecs_gen +MERRG = $(PRDEPTH)/rdpsim/tools/merrg +RMVCOM = $(PRDEPTH)/rdpsim/tools/remove_comments +TAB2VMEM= $(PRDEPTH)/rdpsim/tools/tab2vmem +TAB2WVS = $(PRDEPTH)/rdpsim/tools/tab2wvs +VSIG = $(PRDEPTH)/rdpsim/tools/vsig +XNET = $(PRDEPTH)/rdpsim/tools/xnet + +ASYIN = /ecad/ecs/ecs_2.4/bin/asyin +MAKEINI = /ecad/ecs/ecs_2.4/bin/makeini + +VCSDIR = /ecad/vcs/vcs_2.2/sgi +VCS = $(VCSDIR)/bin/vcs + +LOG_RESULT = \ + @echo -n "!!! $(*:T) of" `basename \`pwd\``": "; \ + grep "number of errors" $*.out + +LOG_ERROR = $(LOG_RESULT) diff --git a/include/2.0L/regdef.h b/include/2.0L/regdef.h new file mode 100755 index 00000000..34c27193 --- /dev/null +++ b/include/2.0L/regdef.h @@ -0,0 +1,45 @@ +#ifndef __REGDEF_H__ +#define __REGDEF_H__ +#ifdef __cplusplus +extern "C" { +#endif +/* +* +* Copyright 1992, Silicon Graphics, Inc. +* All Rights Reserved. +* +* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; +* the contents of this file may not be disclosed to third parties, copied or +* duplicated in any form, in whole or in part, without the prior written +* permission of Silicon Graphics, Inc. +* +* RESTRICTED RIGHTS LEGEND: +* Use, duplication or disclosure by the Government is subject to restrictions +* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data +* and Computer Software clause at DFARS 252.227-7013, and/or in similar or +* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - +* rights reserved under the Copyright Laws of the United States. +*/ +/* ------------------------------------------------------------------ */ +/* | Copyright Unpublished, MIPS Computer Systems, Inc. All Rights | */ +/* | Reserved. This software contains proprietary and confidential | */ +/* | information of MIPS and its suppliers. Use, disclosure or | */ +/* | reproduction is prohibited without the prior express written | */ +/* | consent of MIPS. | */ +/* ------------------------------------------------------------------ */ +#ident "$Revision: 1.9 $" +/* regdef.h 1.2 */ + +/* + * Mips register definitions. + */ + +#ifdef mips +#include +/*#include */ +#endif /* mips */ + +#ifdef __cplusplus +} +#endif +#endif /* !__REGDEF_H__ */ diff --git a/include/2.0L/sgidefs.h b/include/2.0L/sgidefs.h new file mode 100755 index 00000000..bee627b8 --- /dev/null +++ b/include/2.0L/sgidefs.h @@ -0,0 +1,189 @@ +/************************************************************************** + * * + * Copyright (C) 1991-1992 Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ +#ifndef __SGIDEFS_H__ +#define __SGIDEFS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ident "$Revision: 1.5 $" + +/* + * sgidefs.h - SGI/MIPS basic software generation system constants & types + * + * This file MUST be includable in any language + * and in the 'C' case must be ANSI compliant + * In particular this means NO long long ... + * + * Constants and types defined here are to support + * multi-isa (instruction set architecture) coding + * + * Each catagory has a define that the compilation system will set + * based on the environment the compile is initiated in. Programs + * can test the define using the manifest constants defined here. + * (e.g. #if (_MIPS_FPSET == 16) ) + */ + +/* + * Floating Point register set + * Define: + * _MIPS_FPSET + * Can take on the values 16 or 32 + */ + +/* + * Instruction Set Architecture + * Define: + * _MIPS_ISA + */ +#define _MIPS_ISA_MIPS1 1 /* R2/3K */ +#define _MIPS_ISA_MIPS2 2 /* R4K/6K */ +#define _MIPS_ISA_MIPS3 3 /* R4K */ +#define _MIPS_ISA_MIPS4 4 /* TFP */ + +/* + * Subprogram Interface Model + * Define: + * _MIPS_SIM + */ +#define _MIPS_SIM_ABI32 1 /* MIPS MSIG calling convention */ +#define _MIPS_SIM_NABI32 2 /* MIPS new 32-bit abi */ + /* NABI32 is 64bit calling convention but 32bit type sizes) */ +#define _MIPS_SIM_ABI64 3 /* MIPS 64 calling convention */ + +/* + * Data Types Sizes (C and C++) + * Defines: + * _MIPS_SZINT + * _MIPS_SZLONG + * _MIPS_SZPTR + * + * These can take on the values: 32, 64, 128 + */ + +/* + * Compilation Environments + * various compilers may offer a set of different compilation environments + * each one will pre-define the above defines appropriately. + * The MIPS ABI environment will pre-define the following: + * (cc -systype=XXX) + * + * -D_MIPS_FPSET=16 -D_MIPS_ISA=_MIPS_ISA_MIPS1 + * -D_MIPS_SIM=_MIPS_SIM_ABI32 -D_MIPS_SZINT=32 + * -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 + * + * The new MIPS 32-bit ABI environment will pre-define the following + * (cc -systype=XXX) + * -D_MIPS_FPSET=32 -D_MIPS_ISA=_MIPS_ISA_MIPS3 + * -D_MIPS_SIM=_MIPS_SIM_NABI32 -D_MIPS_SZINT=32 + * -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 + * + * The MIPS 64 bit environment will pre-define the following + * (cc -systype=XXX) + * -D_MIPS_FPSET=32 -D_MIPS_ISA=_MIPS_ISA_MIPS3 + * -D_MIPS_SIM=_MIPS_SIM_ABI64 -D_MIPS_SZINT=32 + * -D_MIPS_SZLONG=64 -D_MIPS_SZPTR=64 + * + */ + +/* + * Language Specific + * Type __psint_t - a pointer sized int - this can be used: + * a) when casting a pointer so can perform e.g. a bit operation + * b) as a return code for functions incorrectly typed as int but + * return a pointer. + * User level code can also use the ANSI std ptrdiff_t, defined in stddef.h + * in place of __psint_t + * Type __scint_t - a 'scaling' int - used when in fact one wants an 'int' + * that scales when moving to say 64 bit. (e.g. byte counts, bit lens) + */ + +#if (defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)) + +/* + * assumes int is 32 - + * otherwise there must be some other compiler basic type + */ +#if (_MIPS_SZINT != 32) +#ifdef _MIPS_SZINT +ERROR -- the macro "_MIPS_SZINT" is set to _MIPS_SZINT -- should be 32 +#else +ERROR -- the macro "_MIPS_SZINT" is unset (currently, must be set to 32) +#endif +#endif + +typedef int __int32_t; +typedef unsigned __uint32_t; + +#if (_MIPS_SZLONG == 64) + +typedef long __int64_t; +typedef unsigned long __uint64_t; + +#else + +#if defined(_LONGLONG) + +typedef long long __int64_t; +typedef unsigned long long __uint64_t; + +#else + +typedef struct { + int hi32; + int lo32; +} __int64_t; +typedef struct { + unsigned int hi32; + unsigned int lo32; +} __uint64_t; + +#endif /* _LONGLONG */ + +#endif /* _MIPS_SZLONG */ + +#if (_MIPS_SZPTR == 32) +typedef __int32_t __psint_t; +typedef __uint32_t __psunsigned_t; +#endif + +#if (_MIPS_SZPTR == 64) +typedef __int64_t __psint_t; +typedef __uint64_t __psunsigned_t; +#endif + +/* + * If any fundamental type is 64 bit, then set the scaling type + * to 64 bit + */ +#if (_MIPS_SZPTR == 64) || (_MIPS_SZLONG == 64) || (_MIPS_SZINT == 64) + +/* there exists some large fundamental type */ +typedef __int64_t __scint_t; +typedef __uint64_t __scunsigned_t; + +#else + +/* a 32 bit world */ +typedef __int32_t __scint_t; +typedef __uint32_t __scunsigned_t; + +#endif + +#endif /* C || C++ */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__SGIDEFS_H__ */ diff --git a/include/2.0L/stdarg.h b/include/2.0L/stdarg.h new file mode 100755 index 00000000..a5d0b13f --- /dev/null +++ b/include/2.0L/stdarg.h @@ -0,0 +1,42 @@ +#ifndef STDARG_H +#define STDARG_H + +// When not building with IDO, use the builtin vaarg macros for portability. +#ifndef __sgi +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#else + +typedef char *va_list; +#define _FP 1 +#define _INT 0 +#define _STRUCT 2 + +#define _VA_FP_SAVE_AREA 0x10 +#define _VA_ALIGN(p, a) (((unsigned int)(((char *)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4)) +#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) + +#define __va_stack_arg(list, mode) \ + ( \ + ((list) = (char *)_VA_ALIGN(list, __builtin_alignof(mode)) + \ + _VA_ALIGN(sizeof(mode), 4)), \ + (((char *)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode)))) + +#define __va_double_arg(list, mode) \ + ( \ + (((long)list & 0x1) /* 1 byte aligned? */ \ + ? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \ + : (((long)list & 0x2) /* 2 byte aligned? */ \ + ? (list = (char *)((long)list + 10), (char *)((long)list - 24 - _VA_FP_SAVE_AREA)) \ + : __va_stack_arg(list, mode)))) + +#define va_arg(list, mode) ((mode *)(((__builtin_classof(mode) == _FP && \ + __builtin_alignof(mode) == sizeof(double)) \ + ? __va_double_arg(list, mode) \ + : __va_stack_arg(list, mode))))[-1] +#define va_end(__list) + +#endif +#endif diff --git a/include/2.0L/stdlib.h b/include/2.0L/stdlib.h new file mode 100755 index 00000000..ee1f1407 --- /dev/null +++ b/include/2.0L/stdlib.h @@ -0,0 +1,21 @@ +#ifndef __STDLIB_H__ +#define __STDLIB_H__ + +#ifndef NULL +#define NULL 0 +#endif +typedef struct lldiv_t +{ + long long quot; + long long rem; +} lldiv_t; + +typedef struct ldiv_t +{ + long quot; + long rem; +} ldiv_t; + +lldiv_t lldiv(long long num, long long denom); +ldiv_t ldiv(long num, long denom); +#endif /* !__STDLIB_H__ */ diff --git a/include/2.0L/string.h b/include/2.0L/string.h new file mode 100755 index 00000000..9c809db0 --- /dev/null +++ b/include/2.0L/string.h @@ -0,0 +1,55 @@ +#ifndef __STRING_H__ +#define __STRING_H__ +#ifdef __cplusplus +extern "C" { +#endif +#ident "$Revision: 1.23 $" +/* +* +* Copyright 1992, Silicon Graphics, Inc. +* All Rights Reserved. +* +* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; +* the contents of this file may not be disclosed to third parties, copied or +* duplicated in any form, in whole or in part, without the prior written +* permission of Silicon Graphics, Inc. +* +* RESTRICTED RIGHTS LEGEND: +* Use, duplication or disclosure by the Government is subject to restrictions +* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data +* and Computer Software clause at DFARS 252.227-7013, and/or in similar or +* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - +* rights reserved under the Copyright Laws of the United States. +*/ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */ +/* UNIX System Laboratories, Inc. */ +/* The copyright notice above does not evidence any */ +/* actual or intended publication of such source code. */ + + +#if !defined(_SIZE_T) && !defined(_SIZE_T_) +#define _SIZE_T +#if (_MIPS_SZLONG == 32) +typedef unsigned int size_t; +#endif +#if (_MIPS_SZLONG == 64) +typedef unsigned long size_t; +#endif +#endif + +#ifndef NULL +#define NULL 0 +#endif + +extern void *memcpy(void *, const void *, size_t); +extern char *strchr(const char *, int); +extern size_t strlen(const char *); + +#ifdef __cplusplus +} +#endif +#endif /* !__STRING_H__ */ diff --git a/include/2.0L/sys/asm.h b/include/2.0L/sys/asm.h new file mode 100755 index 00000000..74e85571 --- /dev/null +++ b/include/2.0L/sys/asm.h @@ -0,0 +1,704 @@ +/************************************************************************** + * * + * Copyright (C) 1990, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ +/* + * Copyright 1985 by MIPS Computer Systems, Inc. + */ +#ifndef __SYS_ASM_H__ +#define __SYS_ASM_H__ + +#ident "$Revision: 3.33 $" + +#include "sgidefs.h" + +/* + * asm.h -- cpp definitions for assembler files + */ + +/* + * Notes on putting entry pt and frame info into symbol table for debuggers + * + * .ent name,lex-level # name is entry pt, lex-level is 0 for c + * name: # actual entry point + * .frame fp,framesize,saved_pc_reg + * # fp -- register which is pointer to base + * # of previous frame, debuggers are special + * # cased if "sp" to add "framesize" + * # (sp is usually used) + * # framesize -- size of frame + * # the expression: + * # new_sp + framesize == old_sp + * # should be true + * # saved_pc_reg -- either a register which + * # contains callers pc or $0, if $0 + * # saved pc is assumed to be in + * # (fp)+framesize-4 + * + * Notes regarding multiple entry points: + * LEAF is used when including the profiling header is appropriate + * XLEAF is used when the profiling header is in appropriate (e.g. + * when a entry point is known by multiple names, the profiling call + * should appear only once.) The correct ordering of ENTRY/XENTRY in this + * case is: + * LEAF(copyseg) # declare globl and emit profiling code + * XLEAF(copypage) # declare globl and alternate entry + */ +/* + * LEAF -- declare leaf routine + */ +#define LEAF(x) \ + .globl x; \ + .ent x,0; \ +x:; \ + .frame sp,0,ra + +/* + * XLEAF -- declare alternate entry to leaf routine + */ +#define XLEAF(x) \ + .globl x; \ + .aent x,0; \ +x: + +/* + * VECTOR -- declare exception routine entry + */ +#if _K32U32 +#define VECTOR(x, regmask) \ + .globl x; \ + .ent x,0; \ +x:; \ + .frame sp,EF_SIZE,$0; \ + .mask +(regmask)|M_EXCFRM,-(EF_SIZE-(EF_RA)) +#else +#define VECTOR(x, regmask) \ + .globl x; \ + .ent x,0; \ +x:; \ + .frame sp,EF_SIZE,$0; \ + .mask +(regmask)|M_EXCFRM,-(EF_SIZE-(EF_RA+4)) +#endif + +/* + * NESTED -- declare nested routine entry point + */ +#define NESTED(x, fsize, rpc) \ + .globl x; \ + .ent x,0; \ +x:; \ + .frame sp,fsize, rpc + +/* + * XNESTED -- declare alternate entry point to nested routine + */ +#define XNESTED(x) \ + .globl x; \ + .aent x,0; \ +x: + +/* + * END -- mark end of procedure + */ +#define END(proc) \ + .end proc + +/* + * IMPORT -- import external symbol + */ +#define IMPORT(sym, size) \ + .extern sym,size + +/* + * ABS -- declare absolute symbol + */ +#define ABS(x, y) \ + .globl x; \ +x = y + +/* + * EXPORT -- export definition of symbol + */ +#define EXPORT(x) \ + .globl x; \ +x: + +/* + * BSS -- allocate space in bss + */ +#define BSS(x,y) \ + .comm x,y + +/* + * LBSS -- allocate static space in bss + */ +#define LBSS(x,y) \ + .lcomm x,y + +/* + * Macros for writing PIC asm code + */ +#ifdef PIC +#define PICOPT .option pic2 + +/* + * Set gp when at 1st instruction + */ +#define SETUP_GP \ + .set noreorder; \ + .cpload t9; \ + .set reorder + +/* + * Set gp when not at 1st instruction + */ +#define SETUP_GPX(r) \ + .set noreorder; \ + move r, ra; /* save old ra */ \ + bal 10f; /* find addr of cpload */\ + nop; \ +10: \ + .cpload ra; \ + move ra, r; \ + .set reorder; + +#define SAVE_GP(x) \ + .cprestore x; /* save gp trigger t9/jalr conversion */ + +#else /* PIC */ + +#define PICOPT +#define SETUP_GP +#define SETUP_GPX(r) +#define SAVE_GP(x) + +#endif /* PIC */ + +/* + * Stack Frame Definitions + */ +#if (_MIPS_SIM == _MIPS_SIM_ABI32) +#define NARGSAVE 4 /* space for 4 arg regs must be allocated */ +#define ALSZ 7 /* align on 8 byte boundary */ +#define ALMASK ~7 +#endif +#if (_MIPS_SIM == _MIPS_SIM_ABI64) +#define NARGSAVE 0 /* no caller responsibilities */ +#define ALSZ 15 /* align on 16 byte boundary */ +#define ALMASK ~0xf +#endif + +#if _KERNEL +/* Round the size of a stack frame to fit compiler conventions. */ +#define FRAMESZ(size) (((size)+ALSZ) & ALMASK) +#endif + +#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2) +#define SZREG 4 +#endif + +#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4) +#define SZREG 8 +#endif + +/* + * The following macros reserve the usage of the local label '9' + * By convention the caller should put the return addr in a2 + * so that the stack backtrace can trace from a leaf + */ +#if defined(STANDALONE) || defined(LOCORE) +#define PANIC(msg) \ + sw zero,waittime; \ + la a0,9f; \ + jal panic; \ + MSG(msg) + +#define PRINTF(msg) \ + la a0,9f; \ + jal printf; \ + MSG(msg) + +#else /* the kernel */ +#define PANIC(msg) \ + li a0,CE_PANIC; \ + la a1,9f; \ + jal cmn_err; \ + MSG(msg) + +#define SPPANIC(msg) \ + /* make sure a good frame */\ + lw sp,VPDA_LBOOTSTACK(zero); \ + li a0,CE_PANIC; \ + la a1,9f; \ + jal cmn_err; \ + MSG(msg) + +#define ASMASSFAIL(msg) \ + la a0,9f; \ + la a1,lmsg; \ + move a2,zero; \ + j assfail; \ + MSG(msg) + +#define PRINTF(msg) \ + la a0,9f; \ + jal dprintf; \ + MSG(msg) + +#endif /* defined(STANDALONE) || defined(LOCORE) */ + +#define MSG(msg) \ + .data; \ +9: .asciiz msg; \ + .text + +#define SYSMAP(mname, vname, page, len) \ + .globl mname; \ +mname: \ + .space len*4; \ + .globl vname; \ +vname = ((page)*NBPG) + +#if !defined(_MIPSEB) && !defined(_MIPSEL) + .error Must define either _MIPSEB or _MIPSEL +#endif +#if defined(_MIPSEB) && defined(_MIPSEL) + .error Only one of _MIPSEB and _MIPSEL may be defined +#endif + +/* + * The following macros deal with the coprocessor 0 scheduling + * hazards, which are different for the R3000 and R4000. + * The first digit in the name refers to the number + * of NOPs in the R2000/R3000 case, while the second digit + * refers to the number of NOPs in the R4000 case. + * NOTE: For now use R4000 values for TFP too. This at least + * lets us make the kernel. + */ +#if R4000 +#define NOP_0_1 nop +#define NOP_0_2 nop; nop +#define NOP_0_3 nop; nop; nop +#define NOP_0_4 nop; nop; nop; nop +#define NOP_1_0 +#define NOP_1_1 nop +#define NOP_1_2 nop; nop +#define NOP_1_3 nop; nop; nop +#define NOP_1_4 nop; nop; nop; nop +#endif + +#if TFP +#define NOP_0_1 +#define NOP_0_2 +#define NOP_0_3 +#define NOP_0_4 +#define NOP_1_0 +#define NOP_1_1 NOP_SSNOP +#define NOP_1_2 NOP_SSNOP +#define NOP_1_3 NOP_SSNOP +#define NOP_1_4 NOP_SSNOP +/* TFP has the following kinds of nops: + * + * NOP_NOP regular old nop -- takes a dispatch slot, but another + * integer instruction could be issued with it. But since + * TFP has only one shifter, two consecutive NOP_NOPs would + * go in separate cycles + * NOP_SSNOP nop which breaks superscalar dispatch. Will be the last + * instruction issued in a cycle. Instruction following + * will be first instruction issued in next cycle. + * NOP_NADA more than one of these can be scheduled per cycle + * since it does not use the shifter + */ +#define NOP_NOP sll zero,zero,0 +#define NOP_SSNOP sll zero,zero,1 +#define NOP_NADA addu zero,zero,zero +/* + * The following hazards are intended to be the maximum needed so that we + * do not have to worry about the instructions which follow. You may make + * use of the actual restrictions in order to optimize the code. + * + * Theoretically, NOP_MFC1_HAZ and NOP_MTC1_HAZ should not be needed but they + * are here just in case. + * + * NOP_MFC0_HAZ hazard after loading from C0 + * NOP_MTC0_HAZ hazard after storing to C0 + * NOP_ERET_HAZ hazard before eret after storing C0 registers + * NOP_COM_HAZ hazard following a COM operation -- TLBW, TLBR, etc. + * NOP_MFC1_HAZ hazard after loading from C1 + * NOP_MTC1_HAZ hazard after storing to C1 + * + * Actual restrictions: + * MFC0 + * - two dmfc0 should not be executed in same cycle + * - a dmfc0 should not be issued in cycle following a dmtc0 + * MTC0 + * - in cycle after dmtc0 VAddr a COM will not correctly execute + * - in cycle after dmtc0 status a COM will not correctly execute + * - in same cycle as dmtc0 TLBSet a COM will not correctly execute + * - integer store should not be execute in same cycle as dmtc0 VAddr + * - two dmtc0 should not be executed in the same cycle + * - a dmfc0 should not be issued in cycle following a dmtc0 + * + * - there should be three SSNOPs following a MTC0 which + * is enabling/disabling interrupts in the SR before new mask is + * effective + * - there should be three SSNOPs between a MTC0 which enables a CU + * field (like the FP) before issuing an instruction which uses the + * the FP. + * COM + * - 2 cycles after a COM a memory instruction will not execute properly + * - a TLBR/DCTR followed by a dmfc0 of EntryHi/EntryLo/DCache should + * leave two cycles between TLBR and dmfc0 + * + * Additional restriction found executing kernel on RTL simulator: + *-------------------------------------------------------------------------- + * jr r31 + * dmtc0 r2,sr + * The jr happens to jump to 0x801b9204. However, the jal didn't store the + * proper value (pc + 8) into r31. + * The reason for this behavior is that mtc0's require an internal bus + * (MiscBus to be specific), in the W cycle. However, the jal also requires + * the MiscBus in its E cycle. Thus, the mux select lines for selecting + * the data to go into the GPR was incorrect. + * To make sure something like this won't occur again, it's probably a good + * idea not to have mtc0's in the delay slot, unless you are sure that the + * target quadword of instructions won't cause this internal bus collision. + *-------------------------------------------------------------------------- + */ +#define NOP_MFC0_HAZ NOP_SSNOP +#define NOP_MTC0_HAZ NOP_SSNOP; NOP_SSNOP; NOP_SSNOP; NOP_SSNOP +#define NOP_ERET_HAZ +#define NOP_COM_HAZ NOP_SSNOP; NOP_SSNOP; NOP_SSNOP; NOP_SSNOP +/* + * The NOP_MFC1_HAZ and NOP_MTC1_HAZ are here only due to paranoia. + * I am also defining DMFC1 and DMTC1 which use these macros (in ip21prom.h). + * All this will exist until there is established confidence in FPU. + */ +#define NOP_MFC1_HAZ NOP_SSNOP; NOP_SSNOP; NOP_SSNOP; NOP_SSNOP +#define NOP_MTC1_HAZ NOP_SSNOP; NOP_SSNOP; NOP_SSNOP; NOP_SSNOP +#endif + +#if R3000 +#define NOP_0_1 +#define NOP_0_2 +#define NOP_0_3 +#define NOP_0_4 +#define NOP_1_0 nop +#define NOP_1_1 nop +#define NOP_1_2 nop +#define NOP_1_3 nop +#define NOP_1_4 nop +#endif + +/* + * register mask bit definitions + */ +#define M_EXCFRM 0x00000001 +#define M_AT 0x00000002 +#define M_V0 0x00000004 +#define M_V1 0x00000008 +#define M_A0 0x00000010 +#define M_A1 0x00000020 +#define M_A2 0x00000040 +#define M_A3 0x00000080 +#define M_T0 0x00000100 +#define M_T1 0x00000200 +#define M_T2 0x00000400 +#define M_T3 0x00000800 +#define M_T4 0x00001000 +#define M_T5 0x00002000 +#define M_T6 0x00004000 +#define M_T7 0x00008000 +#define M_S0 0x00010000 +#define M_S1 0x00020000 +#define M_S2 0x00040000 +#define M_S3 0x00080000 +#define M_S4 0x00100000 +#define M_S5 0x00200000 +#define M_S6 0x00400000 +#define M_S7 0x00800000 +#define M_T8 0x01000000 +#define M_T9 0x02000000 +#define M_K0 0x04000000 +#define M_K1 0x08000000 +#define M_GP 0x10000000 +#define M_SP 0x20000000 +#define M_FP 0x40000000 +#define M_RA 0x80000000 + + +/* + * Macros for dealing with 64/32 bit asm files + */ + +/* + * Basic register save and restore + */ +#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2) +#define REG_L lw +#define REG_S sw +#endif + +#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4) +#define REG_L ld +#define REG_S sd +#endif + +#if (_MIPS_SZINT == 32) +#define INT_L lw +#define INT_S sw +#define INT_LLEFT lwl /* load left */ +#define INT_SLEFT swl /* store left */ +#define INT_LRIGHT lwr /* load right */ +#define INT_SRIGHT swr /* store right */ +#define INT_ADD add +#define INT_ADDI addi +#define INT_ADDIU addiu +#define INT_ADDU addu +#define INT_SUB sub +#define INT_SUBI subi +#define INT_SUBIU subiu +#define INT_SUBU subu +#define INT_SLL sll +#define INT_SRL srl +#define INT_SRA sra +#define INT_SLLV sllv +#define INT_SRLV srlv +#define INT_SRAV srav +#define INT_LL ll +#define INT_SC sc +#endif /* _MIPS_SZINT == 32 */ + +#if (_MIPS_SZINT == 64) +#define INT_L ld +#define INT_S sd +#define INT_LLEFT ldl /* load left */ +#define INT_SLEFT sdl /* store left */ +#define INT_LRIGHT ldr /* load right */ +#define INT_SRIGHT sdr /* store right */ +#define INT_ADD dadd +#define INT_ADDI daddi +#define INT_ADDIU daddiu +#define INT_ADDU daddu +#define INT_SUB dsub +#define INT_SUBI dsubi +#define INT_SUBIU dsubiu +#define INT_SUBU dsubu +#define INT_SLL dsll +#define INT_SRL dsrl +#define INT_SRA dsra +#define INT_SLLV dsllv +#define INT_SRLV dsrlv +#define INT_SRAV dsrav +#define INT_LL lld +#define INT_SC scd +#endif /* _MIPS_SZINT == 64 */ + +#if (_MIPS_SZLONG == 32) +#define LONG_L lw +#define LONG_S sw +#define LONG_LLEFT lwl /* load left */ +#define LONG_SLEFT swl /* store left */ +#define LONG_LRIGHT lwr /* load right */ +#define LONG_SRIGHT swr /* store right */ +#define LONG_ADD add +#define LONG_ADDI addi +#define LONG_ADDIU addiu +#define LONG_ADDU addu +#define LONG_SUB sub +#define LONG_SUBI subi +#define LONG_SUBIU subiu +#define LONG_SUBU subu +#define LONG_SLL sll +#define LONG_SRL srl +#define LONG_SRA sra +#define LONG_SLLV sllv +#define LONG_SRLV srlv +#define LONG_SRAV srav +#define LONG_LL ll +#define LONG_SC sc +#endif /* _MIPS_SZLONG == 32 */ + +#if (_MIPS_SZLONG == 64) +#define LONG_L ld +#define LONG_S sd +#define LONG_LLEFT ldl /* load left */ +#define LONG_SLEFT sdl /* store left */ +#define LONG_LRIGHT ldr /* load right */ +#define LONG_SRIGHT sdr /* store right */ +#define LONG_ADD dadd +#define LONG_ADDI daddi +#define LONG_ADDIU daddiu +#define LONG_ADDU daddu +#define LONG_SUB dsub +#define LONG_SUBI dsubi +#define LONG_SUBIU dsubiu +#define LONG_SUBU dsubu +#define LONG_SLL dsll +#define LONG_SRL dsrl +#define LONG_SRA dsra +#define LONG_SLLV dsllv +#define LONG_SRLV dsrlv +#define LONG_SRAV dsrav +#define LONG_LL lld +#define LONG_SC scd +#endif /* _MIPS_SZLONG == 64 */ + +#if (_MIPS_SZPTR == 32) +#define PTR_L lw +#define PTR_S sw +#define PTR_LLEFT lwl /* load left */ +#define PTR_SLEFT swl /* store left */ +#define PTR_LRIGHT lwr /* load right */ +#define PTR_SRIGHT swr /* store right */ +#define PTR_ADD add +#define PTR_ADDI addi +#define PTR_ADDIU addiu +#define PTR_ADDU addu +#define PTR_SUB sub +#define PTR_SUBI subi +#define PTR_SUBIU subiu +#define PTR_SUBU subu +#define PTR_SLL sll +#define PTR_SRL srl +#define PTR_SRA sra +#define PTR_SLLV sllv +#define PTR_SRLV srlv +#define PTR_SRAV srav +#define PTR_LL ll +#define PTR_SC sc + +#define PTR_WORD .word /* psuedo-op to reserve space for a ptr */ +#define PTR_SCALESHIFT 2 + +#define LI li +#define LA la +#endif /* _MIPS_SZPTR == 32 */ + +#if (_MIPS_SZPTR == 64) +#define PTR_L ld +#define PTR_S sd +#define PTR_LLEFT ldl /* load left */ +#define PTR_SLEFT sdl /* store left */ +#define PTR_LRIGHT ldr /* load right */ +#define PTR_SRIGHT sdr /* store right */ +#define PTR_ADD dadd +#define PTR_ADDI daddi +#define PTR_ADDIU daddiu +#define PTR_ADDU daddu +#define PTR_SUB dsub +#define PTR_SUBI dsubi +#define PTR_SUBIU dsubiu +#define PTR_SUBU dsubu +#define PTR_SLL dsll +#define PTR_SRL dsrl +#define PTR_SRA dsra +#define PTR_SLLV dsllv +#define PTR_SRLV dsrlv +#define PTR_SRAV dsrav +#define PTR_LL lld +#define PTR_SC scd + +#define PTR_WORD .dword /* psuedo-op to reserve space for a ptr */ +#define PTR_SCALESHIFT 3 + +#define LI dli +#define LA dla +#endif /* _MIPS_SZPTR == 64 */ + +#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2) +#define MFC0 mfc0 +#define MTC0 mtc0 +#endif + +#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4) +#define MFC0 dmfc0 +#define MTC0 dmtc0 +#endif +#if TFP +#define DMTC0(r,c) dmtc0 r,c; \ + NOP_MTC0_HAZ +#define DMFC0(c,r) dmfc0 c,r; \ + NOP_MFC0_HAZ +#if _K32U32 || _K32U64 + # This code only works for SABLE + # We need to avoid a tlbmiss on the PC address (our pseudo-K0 space) + # because such a fault destroys values loaded into BADVADDR, + # TLBHI, etc. +#define SABLE_GOTO_KP64(reg1,reg2) \ + lui reg2,0xa000; \ + dsll reg2,32; \ + la reg1,1f; \ + dsll reg1,35; \ + dsrl reg1,35; \ + dadd reg1,reg2; \ + NOP_SSNOP; \ + j reg1; \ + NOP_SSNOP; \ + NOP_SSNOP; \ +1: NOP_SSNOP \ + # Now we're executing in Kernel Physical (KP) space +#else +#define SABLE_GOTO_KP64(reg1,reg2) +#endif /* !_K32U32 && ! _K32U64 */ + +#endif /* TFP */ +#if R3000 || R4000 +/* These macros let us replace existing mtc0/mfc0 instructions with macros + * that have no additional overhead for non-TFP machines but have the required + * number of scheduling NOPS for TFP. + */ +#define DMTC0(r,c) mtc0 r,c +#define DMFC0(c,r) mfc0 c,r +#define SABLE_GOTO_KP64(reg1,reg2) +#endif /* R3000 || R4000 */ + +#if TFP_TLBCACHE_WAR +/* + * This problem occurs when there is an I-Cache miss within two cycles of + * a valid tlb or dct (data cache tag) instruction. If the previous contents + * of the I-Cache contained a store instruction, the data cache can be + * corrupted. + * + * This problem can be worked around by putting all tlb/dct instructions on a + * 16-byte boundary. And, the three instructions that follow the tlb/dct + * must be ssnops (super-scalar no-ops). This guarantees that for the two + * cycles following the tlb/dct instruction, there can only be noops in the + * pipeline. + */ +#define TLB_READ .align 4; \ + c0 C0_READ; \ + NOP_SSNOP; \ + NOP_SSNOP; \ + NOP_SSNOP +#define TLB_WRITER .align 4; \ + c0 C0_WRITER; \ + NOP_SSNOP; \ + NOP_SSNOP; \ + NOP_SSNOP +#define TLB_PROBE .align 4; \ + c0 C0_PROBE; \ + NOP_SSNOP; \ + NOP_SSNOP; \ + NOP_SSNOP +#else /* !TFP_TLBCACHE_WAR */ +#if TFP +#define TLB_READ c0 C0_READ; \ + NOP_COM_HAZ +#define TLB_WRITER c0 C0_WRITER; \ + NOP_COM_HAZ +#define TLB_PROBE c0 C0_PROBE; \ + NOP_COM_HAZ +#else +#define TLB_READ c0 C0_READ +#define TLB_WRITER c0 C0_WRITER +#endif +#endif /* !TFP_TLBCACHE_WAR */ +#endif /* __SYS_ASM_H__ */ diff --git a/include/2.0L/sys/regdef.h b/include/2.0L/sys/regdef.h new file mode 100755 index 00000000..8d319a2b --- /dev/null +++ b/include/2.0L/sys/regdef.h @@ -0,0 +1,104 @@ +/************************************************************************** + * * + * Copyright (C) 1990-1992, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ +/* + * Copyright 1985 by MIPS Computer Systems, Inc. + */ +#ifndef __SYS_REGDEF_H__ +#define __SYS_REGDEF_H__ + +#ident "$Revision: 3.7 $" + +#include "sgidefs.h" + +#if (_MIPS_SIM == _MIPS_SIM_ABI32) +#define zero $0 /* wired zero */ +#define AT $at /* assembler temp */ +#define v0 $2 /* return value */ +#define v1 $3 +#define a0 $4 /* argument registers */ +#define a1 $5 +#define a2 $6 +#define a3 $7 +#define t0 $8 /* caller saved */ +#define t1 $9 +#define t2 $10 +#define t3 $11 +#define t4 $12 /* caller saved - 32 bit env arg reg 64 bit */ +#define ta0 $12 /* caller saved in 32 bit - arg regs in 64 bit */ +#define t5 $13 +#define ta1 $13 +#define t6 $14 +#define ta2 $14 +#define t7 $15 +#define ta3 $15 +#define s0 $16 /* callee saved */ +#define s1 $17 +#define s2 $18 +#define s3 $19 +#define s4 $20 +#define s5 $21 +#define s6 $22 +#define s7 $23 +#define t8 $24 /* code generator */ +#define t9 $25 +#define jp $25 /* PIC jump register */ +#define k0 $26 /* kernel temporary */ +#define k1 $27 +#define gp $28 /* global pointer */ +#define sp $29 /* stack pointer */ +#define fp $30 /* frame pointer */ +#define s8 $30 /* calle saved */ +#define ra $31 /* return address */ +#endif + +#if (_MIPS_SIM == _MIPS_SIM_ABI64) +#define zero $0 /* wired zero */ +#define AT $at /* assembler temp */ +#define v0 $2 /* return value - caller saved */ +#define v1 $3 +#define a0 $4 /* argument registers */ +#define a1 $5 +#define a2 $6 +#define a3 $7 +#define a4 $8 /* arg reg 64 bit; caller saved in 32 bit */ +#define ta0 $8 +#define a5 $9 +#define ta1 $9 +#define a6 $10 +#define ta2 $10 +#define a7 $11 +#define ta3 $11 +#define t0 $12 /* caller saved */ +#define t1 $13 +#define t2 $14 +#define t3 $15 +#define s0 $16 /* callee saved */ +#define s1 $17 +#define s2 $18 +#define s3 $19 +#define s4 $20 +#define s5 $21 +#define s6 $22 +#define s7 $23 +#define t8 $24 /* caller saved */ +#define t9 $25 /* callee address for PIC/temp */ +#define jp $25 /* PIC jump register */ +#define k0 $26 /* kernel temporary */ +#define k1 $27 +#define gp $28 /* global pointer - caller saved for PIC */ +#define sp $29 /* stack pointer */ +#define fp $30 /* frame pointer */ +#define s8 $30 /* callee saved */ +#define ra $31 /* return address */ +#endif + +#endif /* __SYS_REGDEF_H__ */ diff --git a/include/2.0L/sys/u64driver.h b/include/2.0L/sys/u64driver.h new file mode 100755 index 00000000..db4fe336 --- /dev/null +++ b/include/2.0L/sys/u64driver.h @@ -0,0 +1,131 @@ +#ifndef __SYS_U64DRIVER_H__ +#define __SYS_U64DRIVER_H__ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied or + * duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - + * rights reserved under the Copyright Laws of the United States. + * + */ + +#include +#include +#include "u64gio.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + + +#define U64_MINOR_PRINT 1 +#define U64_MINOR_DEBUG 2 +#define U64_MINOR_LOGGING 3 +#define U64_MINOR_DATA 4 +#define U64_MINOR_FAULT 5 +#define U64_MINOR_KDEBUG 6 +#define U64_MINOR_PROFILE 7 +#define NUMBER_MINORS 8 /* don't use minor zero , but must count 0-7 */ + +#define U64_MINOR_PRINT_BUF_SIZE 0x80000 /* buffer used by incoming printf data */ +#define U64_MINOR_DEBUG_BUF_SIZE 0x4000 +#define U64_MINOR_LOGGING_BUF_SIZE RDB_LOG_MAX_BLOCK_SIZE /* buffer used by incoming logging data */ +#define U64_MINOR_DATA_BUF_SIZE RDB_DATA_MAX_BLOCK_SIZE /* buffer used by incoming data */ +#define U64_MINOR_FAULT_BUF_SIZE 1024 /* buffer used for incoming fault data */ +#define U64_MINOR_KDEBUG_BUF_SIZE 1024 /* buffer used for incoming kdebug data */ +#define U64_MINOR_PROFILE_BUF_SIZE 2048 /* buffer used for incoming profile data */ +#define U64_MINOR_PROFILE_SEND_BUF_SIZE 16 /* only send one byte messages */ +#define U64_INTERNAL_WRITE_BUF_SIZE 0x8000 /* buffer used to store packets waiting to go out */ + + + +#define u64_increment_Qptr(x) { ((x) = ((x) + 1) & 0xff) ; } + + +typedef struct { + sema_t minor_sema; /* used to allow only one app to open the minor */ + sema_t read_sema; /* used to block while waiting for data */ + sema_t write_sema; /* only allow one entry to write at a time */ + int read_count; /* the number of bytes waiting to be read */ + int write_count; /* the number of bytes waiting to be written */ + int read_cur_write; + int write_cur_write; + int read_cur_read; + int write_cur_read; + unsigned char *read_buf; + unsigned char *write_buf; + int read_buf_size; /* measured in unsigned char's */ + int write_buf_size; /* measured in unsigned char's */ + int incoming_ct; /* used by minors that receive data from game */ + /* indicates how many bytes left in block */ + /* before signaling game that transfer is done */ + /* used by logging and game to host data stuff */ + int message; /* when not zero, send this message to game to */ + /* indicate that data or log data has been read */ + struct pollhead *phead; +} u64_minor; + +/* + * Our private one-per-board data structure + * The user can't get at any of this + */ +struct u64_data { + + volatile struct u64_board *board; + unsigned char *memaddr; /* 16/32 bit access R/W */ + + /* + * Only one client may be in the kernel at a time; this semaphore is used + * to prevent multiple clients from overrunning each other's interactions + * with the hardware. + */ + sema_t ioctl_sema; + + /* + * The ramrom_sema is used by the driver so that it can arbitrate for the + * control of ramrom with the game, and sleep while waiting for the game + * to respond. + */ + sema_t ramrom_sema; + + /* + * Allocate a megabyte buffer which we can use when reading/writing data + * to or from the board (we can't copyin/copyout directly from the user's + * buffer, because those routines use 64 bit transfers). + */ + unsigned int *oneMeg; + + union { + u64_write_arg_t u64_write; /* WRITE, SAFE_WRITE */ + u64_read_arg_t u64_read; /* READ, SAFE_READ */ + } args; + + /* rdb port */ + unsigned int *write_buf; + unsigned int write_buf_cur_write; + unsigned int write_buf_cur_read; + unsigned int write_buf_ct; /* number of packets waiting for transmission */ + unsigned int write_buf_size; /* measured in rdbPackets */ + sema_t write_buf_sema; + u64_minor minors[NUMBER_MINORS]; + +}; + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#endif /* __SYS_U64DRIVER_H__ */ + + + + + + diff --git a/include/2.0L/sys/u64gio.h b/include/2.0L/sys/u64gio.h new file mode 100755 index 00000000..106a9ccd --- /dev/null +++ b/include/2.0L/sys/u64gio.h @@ -0,0 +1,110 @@ +#ifndef __SYS_U64GIO_H__ +#define __SYS_U64GIO_H__ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied or + * duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - + * rights reserved under the Copyright Laws of the United States. + * + */ + +#define DEV_U64 "/dev/u64" +#define DEV_U64_PRINT "/dev/u64_print" +#define DEV_U64_DEBUG "/dev/u64_debug" +#define DEV_U64_LOG "/dev/u64_logging" +#define DEV_U64_DATA "/dev/u64_data" +#define DEV_U64_FAULT "/dev/u64_fault" +#define DEV_U64_KDEBUG "/dev/u64_kdebug" +#define DEV_U64_PROFILE "/dev/u64_profile" +/* + * ioctls + */ +#define U64IOC ('u'<<24|'6'<<16) +#define U64IOCTL(x) (U64IOC|x) + +#define U64_RESET U64IOCTL(1) /* arg: 0 - deassert, 1 - assert */ +#define U64_WRITE U64IOCTL(2) +#define U64_READ U64IOCTL(3) +#define U64_SAFE_WRITE U64IOCTL(4) +#define U64_SAFE_READ U64IOCTL(5) +#define U64_LISTEN U64IOCTL(6) /* arg is register value for listen */ +#define U64_SIGNAL U64IOCTL(7) /* arg is register value for signal */ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* structure for WRITE & SAFE_WRITE*/ +typedef struct u64_write_arg { + void *buffer; + long ramrom_addr; + int nbytes; +} u64_write_arg_t; + +/* structure for READ & SAFE_READ */ +typedef struct u64_read_arg { + void *buffer; + long ramrom_addr; + int nbytes; +} u64_read_arg_t; + +/* NOTE: if game is in reset, don't interrupt the game */ + +struct u64_board { + volatile unsigned int product_id_reg; /* bf400000, read only */ + unsigned char fill_0[0x3fc]; + volatile unsigned int reset_control; /* bf400400, write only */ + unsigned char fill_1[0x3fc]; + volatile unsigned int cart_interrupt; /* bf400800, read/write */ + unsigned char fill_3[0x1fc]; + volatile unsigned int dram_page_cntrl;/* bf400a00, read/write */ + unsigned char fill_2[0x1fc]; + volatile unsigned int gio_interrupt; /* bf400c00, read only */ + unsigned char fill_4[0x1fc]; + volatile unsigned int gio_sync; /* bf400e00, read only */ +}; + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/* + * _U64_PRODUCT_ID_REG - GIO bus Product ID register + */ +#define _U64_PRODUCT_ID_MASK 0x0000007f +#define _U64_PRODUCT_ID_VALUE 0x00000015 + +/* + * reset control register has two bits defined + */ +#define _U64_RESET_CONTROL_NMI 0x4 +#define _U64_RESET_CONTROL_RESET 0x2 + +/* + * Only look at the least significant 5 bits of the sync and interrupt + * registers. Future revs of the firmware may provide more. + */ + +#define _U64_REGMASK 0x1f + +/* + * 16MB available, one meg at a time, selected by the 4 bit + * dram_page_cntrl register setting. + */ +#define U64_MEM_SIZE 0x100000 + +/* + * Declare size of gio-addressable memory to mmap, and provide the base + * physical address so that clients who want to mmap() may do so. + */ +#define U64_GIOBUS_SIZE 0x200000 /* 2 MB */ +#define U64_GIOBUS_BASE 0x1f400000 + +#endif /* __SYS_U64GIO_H__ */ diff --git a/include/2.0L/tinymon.h b/include/2.0L/tinymon.h new file mode 100755 index 00000000..5856d4f6 --- /dev/null +++ b/include/2.0L/tinymon.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1995, Silicon Graphics, Inc. All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished + * rights reserved under the Copyright Laws of the United States. + * + * Module: tinymon.h: constants for use with the tinymon family of debug servers + */ + +#define GIO_BASE_REG_UPPER 0x1800 +#define GIO_BASE_REG_UPPER_K1 0xb800 +#define GIO_INTR_REG_OFFSET 0x0 +#define GIO_SYNC_REG_OFFSET 0x400 +#define CART_INTR_REG_OFFSET 0x800 + +#define RAMROM_BASE_UPPER 0x1000 +#define RAMROM_BASE_UPPER_K1 0xb000 + +/* + * jal will or in the upper four bits of 0xb0000000 whenever we invoke these + * routines. + */ +#define PIFMON_WRITE_ADDR 0xfc00030 + +#define PI_BASE_REG_UPPER 0x0460 +#define PI_BASE_REG_UPPER_K1 0xa460 +#define PI_STATUS_REG_OFFSET 0x10 + +/* + * PI status register has 3 bits active when read from (PI_STATUS_REG - read) + * Bit 0: DMA busy - set when DMA is in progress + * Bit 1: IO busy - set when IO is in progress + * Bit 2: Error - set when R4300 issues IO request while DMA is busy + */ +#define PI_STATUS_ERROR 0x04 +#define PI_STATUS_IO_BUSY 0x02 +#define PI_STATUS_DMA_BUSY 0x01 + +/* + * Host to R4300 protocol definitions. + * + * Host writes DG_RAMROM_REQUEST, DG_RAMROM_CMD_READY to the cartridge + * interrupt register (which the R4300 can poll), + * + * R4300 writes DG_RAMROM_GRANT, DG_RAMROM_CMD_DONE to the gio sync register + * (which the host can poll). + */ + +#define DG_CARTREG_MASK 0x3f + +#define DG_RAMROM_REQUEST 1 +#define DG_RAMROM_GRANT 2 +#define DG_RAMROM_CMD_READY 3 +#define DG_RAMROM_CMD_DONE 4 + +#define DG_TINYMON_READ_OP 1 +#define DG_TINYMON_WRITE_OP 2 +#define DG_TINYMON_DMA_READ_OP 3 +#define DG_TINYMON_DMA_WRITE_OP 4 diff --git a/include/2.0L/ultra64.h b/include/2.0L/ultra64.h new file mode 100755 index 00000000..93c34164 --- /dev/null +++ b/include/2.0L/ultra64.h @@ -0,0 +1,41 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + *************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.10 $ + * $Date: 1997/02/11 08:37:33 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ultra64.h,v $ + * + **************************************************************************/ + +#ifndef _ULTRA64_H_ +#define _ULTRA64_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/2.0L/ultrahost.h b/include/2.0L/ultrahost.h new file mode 100755 index 00000000..25c772ae --- /dev/null +++ b/include/2.0L/ultrahost.h @@ -0,0 +1,58 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + *************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.8 $ + * $Date: 1997/07/02 02:35:06 $ + * $Source: /disk6/Master/cvsmdev2/PR/include/ultrahost.h,v $ + * + **************************************************************************/ + +#ifndef _ULTRAHOST_H_ +#define _ULTRAHOST_H_ + +#ifdef PTN64 /* { */ + +#define execl execl_pt + +#define uhOpenGame uhOpenGame_pt +#define uhCloseGame uhCloseGame_pt + +#define uhReadGame uhReadGame_pt +#define uhWriteGame uhWriteGame_pt +#define uhReadRamrom uhReadRamrom_pt +#define uhWriteRamrom uhWriteRamrom_pt +#define uhPartnerCmd uhPartnerCmd_pt +#define uhGload uhGload_pt + +int uhPartnerCmd(int,char *); +int uhGload(int,char *); + +#endif /* } */ + +#ifdef __cplusplus +extern "C" { +#endif +int uhOpenGame(const char *); +int uhCloseGame(int); + +int uhReadGame(int, void *, int); +int uhWriteGame(int, void *, int); +int uhWriteRamrom(int, void *, void*, int); +int uhReadRamrom(int, void *, void*, int); + +#ifdef __cplusplus +} +#endif + +#endif /* ULTRAHOST */ diff --git a/include/arcade_int.h b/include/arcade_int.h new file mode 100644 index 00000000..a95ee707 --- /dev/null +++ b/include/arcade_int.h @@ -0,0 +1,362 @@ +#ifndef ARCADE_INTERNAL_H +#define ARCADE_INTERNAL_H + +#include +#include "functions.h" +#include "variables.h" + +enum ARCADE_OBJ_E { + ARCADE_OBJ_01_BARREL = 1, + ARCADE_OBJ_02_FLAME_ENEMY, + ARCADE_OBJ_03_SPRING, + ARCADE_OBJ_04_PIE, + ARCADE_OBJ_05_BONUS_ITEM, + ARCADE_OBJ_06_HAMMER, + ARCADE_OBJ_07_HAMMER_PARTICLES, + ARCADE_OBJ_08_DK_HOW_HIGH, + ARCADE_OBJ_09_NAME_SELECT_CURSOR, + ARCADE_OBJ_0A_BARREL_STACK, + ARCADE_OBJ_0B_RIVET, + ARCADE_OBJ_0C_MOVING_LADDER, + ARCADE_OBJ_0D_JUMPMAN, + ARCADE_OBJ_0E_BONUS_OSD, + ARCADE_OBJ_0F_100M_COMPLETE_PARTICLE, + ARCADE_OBJ_10_OIL_DRUM, + ARCADE_OBJ_11_ELEVATOR_CRANK, + ARCADE_OBJ_12_PULLEY, + ARCADE_OBJ_13_OIL_DRUM_FLAMES, + ARCADE_OBJ_14_POINTS_TEXT, + ARCADE_OBJ_15_DK_TITLE, + ARCADE_OBJ_16_DK_25M, + ARCADE_OBJ_17_DK_100M, + ARCADE_OBJ_18_DK_75M, + ARCADE_OBJ_19_DK_50M, + ARCADE_OBJ_1A_PAULINE_BOTTOM, + ARCADE_OBJ_1B_PAULINE_TOP, + //ARCADE_OBJ_1C + ARCADE_OBJ_1D_HELP_TEXT = 0x1D, + ARCADE_OBJ_1E_NINTENDO_COIN +}; + +typedef struct { + uSprite sprite[2]; //array size unknown + u8 pad30[0x750]; +} ArcadeStruct3; //size(0x780) + +typedef struct arcade_struct_1 { + f32 x_position; // x position at 0x0 + f32 y_position; // y position at 0x4 + f32 x_velocity; // x velocity at 0x8 + f32 y_velocity; // y velocity at 0xC + f32 unk10; // lifetime? + s32 *unk14; // imageDataPointer + u8 unk18; // object_type + u8 unk19; // state? + u8 unk1A; + u8 unk1B; + u8 unk1C; + u8 unk1D; + u8 unk1E; // height + u8 unk1F; // width +} ArcadeStruct1; + +typedef struct { + u16 r:5; + u16 g:5; + u16 b:5; + u16 a:1; +} rgba5551; + +typedef struct { + u8 pad0[0xC]; +} ArcadeStruct4; + +void func_8002549C(void); +void func_80024D90(void); +void func_800259D0(Gfx **arg0); +void func_80026680(Gfx **arg0); +void func_800268AC(Gfx **arg0); +void func_80029968(void); +s32 func_80029ACC(s32 arg0, s32 arg1); +void func_80029CD0(s32 arg0, s32 arg1); +void func_80029EFC(s32 arg0, s32 arg1); +s32 func_8002A264(s32 arg0, s32 arg1); +s32 func_8002A408(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5); +void func_8002B2C0(Gfx **arg0); + +void func_800303B8(u8); +void func_80030734(u8); +void arcade_rivet_update(u8); +void func_80030A04(u8); +void func_80030CEC(u8); +void arcade_pie_update(u8); + +void func_80030FEC(void); +void func_800313B8(void); + +void func_8060C648(u8 arg0, u32 arg1, u8 arg2, u32 fileIndex, s32 arg4); +u32 func_8060C6B8(u8 arg0, u32 arg1, u8 arg2, u32 arg3); +void func_8060DEA8(void); +void func_80737638(void * arg0, enum sfx_e arg1, u32 arg2 , u32 arg3, f32 arg4, u32 arg5, u32 arg6); + +/* rom */ +extern Gfx **D_1000040; +extern Gfx **D_1000090; + +/*.data */ //0x8032220 = 0xE220 + +extern u8 D_80032228; // imageData +// these are likely the same struct +extern u8 D_80032B48; +extern u8 D_80032B90; +extern u8 D_80032BD8; +extern u8 D_80032C20; +extern u8 D_80032DF8; +extern u8 D_80032E80; // imageData +extern u8 D_80032F68; // imageData +extern u8 D_800335D8; +extern u8 D_80033C48; +extern u8 D_80034360; // imageData +extern u8 D_80034568; +extern u8 D_80034610; // imageData //barrel +extern u8 D_80034818[]; +extern u8 D_80034A20[]; +extern u8 D_80034C28[]; +extern u8 D_80034E30[]; +extern u8 D_80035038[]; +extern u8 D_80035240[]; +extern u8 D_80035448[]; +extern u8 D_80035650[]; +extern u8 D_80035898[]; +extern u8 D_80035AE0[]; +extern u8 D_80035CE8[]; +extern u8 D_80037130; // imageData +extern u8 D_80037338; // imageData +extern u8 D_80037580; // imageData +extern s32 D_80037B98; // sprite? +extern s32 D_80037DA0; // sprite? +extern s32 D_80037FA8; // sprite? +extern u8 D_800381B0; // imageData +extern s32 D_800383B8; // sprite? +extern s32 D_800385C0; // sprite? +extern s32 D_800387C8; // sprite? +extern u8 D_80038BD8[]; +extern u8 D_80038DE0; // imageData +extern u8 D_80038FE8; +extern u8 D_800391F0; +extern u8 D_800393F8; // imageData +extern u8 D_80039640; +extern u8 D_80039888; +extern u8 D_800389D0; +extern u8 D_80039AD0; +extern s32 D_80039D18; // sprite +extern s32 D_80039F60; // sprite +extern s32 D_8003A1A8; // sprite +extern s32 D_8003A3F0; // sprite +extern u8 D_8003A638; // imageData +extern u8 D_8003A840; // imageData +extern u8 D_8003AA48; // imageData +extern u8 D_8003AC50; // imageData +extern u8 D_8003AE58; // nintendo coin sprite +extern u8 D_8003B180[]; +extern rgba5551 D_8003DA90[8][8]; // image data +extern u8 D_8003DB18; +extern u8 D_8003DD60; +extern u8 D_8003E438; +extern u8 D_8003E680[]; +extern u8 D_8003E868[]; +extern u8 D_8003E9F0; +extern u8 D_8003F9B8; // imageData +extern s32 D_80040540; // sprite? // donkey kong sprite +extern s32 D_80041508; +extern s32 D_800424D0; // imageData +extern u8 D_80044460; +extern u8 D_80045428; + +extern s32 D_80047C24; // reload_arcade_level +extern s32 D_8004A308[]; +extern u8 D_8004A338[]; +extern u8 D_8004A358[]; +extern u8 D_8004A378[]; + +extern s32 D_8004A318[8]; +extern ArcadeStruct1 arcade_jumpman_obj_template = { 96.0f, 247.0f, 0.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_0D_JUMPMAN, 0, 3, 0, 0, 0, 0x10, 0x12}; +extern ArcadeStruct1 arcade_barrel_obj_template = { 64.0f, 79.0f, 1.0f, 0.0f, 0.0f, &D_80034610, ARCADE_OBJ_01_BARREL, 0, 0, 0, 0, 0, 0x10, 0x0F}; +extern ArcadeStruct1 arcade_flame_enemy_obj_template = { 76.0f, 230.0f, 1.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_02_FLAME_ENEMY, 2, 0, 0, 0, 0, 0x10, 0x11}; +extern ArcadeStruct1 arcade_oil_drum_flame_obj_template = { 64.0f, 216.0f, 1.0f, 0.0f, 0.0f, &D_80032228, ARCADE_OBJ_13_OIL_DRUM_FLAMES, 2, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_spring_obj_template = { -24.0f, 81.0f, 2.0f, -3.5f, 0.0f, NULL, ARCADE_OBJ_03_SPRING, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_bonus_osd_obj_template = { 219.0f, 38.0f, 2.0f, -3.5f, 0.0f, &D_80032F68, ARCADE_OBJ_0E_BONUS_OSD, 0, 0, 0, 0, 0, 0x2B, 0x13}; +extern ArcadeStruct1 arcade_oil_drum_obj_template = { 64.0f, 231.0f, 0.0f, 0.0f, 0.0f, &D_80037338, ARCADE_OBJ_10_OIL_DRUM, 0, 0, 0, 0, 0, 0x10, 0x11}; +extern ArcadeStruct1 arcade_elevator_obj_template = { 80.0f, 88.0f, 0.0f, 0.0f, 0.0f, &D_80037580, ARCADE_OBJ_11_ELEVATOR_CRANK, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_pulley_obj_template = { 48.0f, 84.0f, 0.0f, 0.0f, 0.0f, &D_80037B98, ARCADE_OBJ_12_PULLEY, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_pauline_top_obj_template = { 136.0f, 26.0f, 0.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_1B_PAULINE_TOP, 0, 0, 0, 0, 0, 0x10, 0x11}; +extern ArcadeStruct1 arcade_pauline_bottom_obj_template = { 136.0f, 42.0f, 0.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_1A_PAULINE_BOTTOM, 0, 0, 0, 0, 0, 0x10, 0x11}; +extern ArcadeStruct1 arcade_nintendo_coin_obj_template = { 136.0f, 42.0f, 0.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_1E_NINTENDO_COIN, 0, 0, 0, 0, 0, 0x14, 0x14}; +extern ArcadeStruct1 arcade_help_text_obj_template = { 152.0f, 33.0f, 0.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_1D_HELP_TEXT, 0, 0, 0, 0, 0, 0x18, 0x0A}; +extern ArcadeStruct1 arcade_dk_title_obj_template = { 148.0f, 200.0f, 0.0f, 0.0f, 0.0f, NULL, ARCADE_OBJ_15_DK_TITLE, 0, 0, 0, 0, 0, 0x30, 0x29}; +extern ArcadeStruct1 arcade_dk_25m_obj_template = { 68.0f, 38.0f, 0.0f, 0.0f, 0.0f, &D_80040540, ARCADE_OBJ_16_DK_25M, 0xC, 0, 0, 1, 0, 0x30, 0x29}; +extern ArcadeStruct1 arcade_dk_100m_obj_template = { 136.0f, 53.0f, 0.0f, 0.0f, 0.0f, &D_80040540, ARCADE_OBJ_17_DK_100M, 2, 0, 0, 0, 0, 0x30, 0x29}; +extern ArcadeStruct1 arcade_dk_75m_obj_template = { 68.0f, 42.0f, 0.0f, 0.0f, 0.0f, &D_80040540, ARCADE_OBJ_18_DK_75M, 2, 0, 0, 0, 0, 0x30, 0x29}; +extern ArcadeStruct1 arcade_dk_50m_obj_template = { 68.0f, 42.0f, 1.0f, 0.0f, 0.0f, &D_80040540, ARCADE_OBJ_19_DK_50M, 2, 0, 0, 0, 0, 0x30, 0x29}; +extern ArcadeStruct1 arcade_dk_how_high_obj_template = { 138.0f, 198.0f, 0.0f, 0.0f, 0.0f, &D_8003F9B8, ARCADE_OBJ_08_DK_HOW_HIGH, 0, 0, 0, 0, 0, 0x2E, 0x20}; +extern ArcadeStruct1 arcade_points_text_obj_template = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, &D_800381B0, ARCADE_OBJ_14_POINTS_TEXT, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_bonus_item_obj_template = { 180.0f, 247.0f, 0.0f, 0.0f, 0.0f, &D_80038DE0, ARCADE_OBJ_05_BONUS_ITEM, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_hammer_obj_template = { 220.0f, 200.0f, 0.0f, 0.0f, 0.0f, &D_800393F8, ARCADE_OBJ_06_HAMMER, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_rivet_obj_template = { 108.0f, 208.0f, 0.0f, 0.0f, 0.0f, &D_80032E80, ARCADE_OBJ_0B_RIVET, 0, 0, 0, 1, 0, 0x08, 0x09}; +extern ArcadeStruct1 arcade_moving_ladder_obj_template = { 60.0f, 97.0f, 0.0f, 0.0f, 0.0f, &D_8003A638, ARCADE_OBJ_0C_MOVING_LADDER, 0, 0, 0, 0xF4, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_name_select_cursor_obj_template = { 60.0f, 97.0f, 0.0f, 0.0f, 0.0f, &D_8003A840, ARCADE_OBJ_09_NAME_SELECT_CURSOR, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 D_8004A6B8 = { 60.0f, 97.0f, 0.0f, 0.0f, 0.0f, &D_80034360, 0x1C, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_pie_obj_template = { 60.0f, 207.0f, 0.0f, 0.0f, 0.0f, &D_8003AA48, ARCADE_OBJ_04_PIE, 0, 0, 0, 3, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_100m_complete_particle_obj_template = { 160.0f, 214.0f, 0.0f, 0.0f, 0.0f, &D_8003AC50, ARCADE_OBJ_0F_100M_COMPLETE_PARTICLE, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern ArcadeStruct1 arcade_barrel_stack_obj_template = { 58.0f, 83.0f, 0.0f, 0.0f, 0.0f, &D_80037130, ARCADE_OBJ_0A_BARREL_STACK, 0, 0, 0, 0, 0, 0x10, 0x10}; +extern u32 D_8004A738 = 1; // rng +extern u8 D_8004A73C = 0; +extern u8 D_8004A740 = 0; // arcade_is_in_nintendo_coin_mode +extern u8 D_8004A744; +extern s32 arcade_current_score = 3700; //0x8004A748 +extern s32 arcade_saved_high_scores[5] = { + 7650, 6100, 5950, 5050, 4300 +}; //0x8004A74C + +extern s32 D_8004A760 = 7650; +extern u8 D_8004A764 = 0; +extern s8 D_8004A768 = 0; +extern u8 D_8004A76C = 0; +extern u8 D_8004A770 = 0; +extern u8 D_8004A774[3] = {' ',' ',' '}; +extern u8 arcade_saved_high_score_initials[5][3] = { + {' ',' ',' '}, + {' ',' ',' '}, + {' ',' ',' '}, + {' ',' ',' '}, + {' ',' ',' '} +}; //0x8004A778 +extern u8 D_8004A788[4]; +extern s32 D_8004A78C = 1; +extern s32 D_8004A790 = 0; +extern u8 D_8004A794 = 0x20; +extern s32 D_8004A798[0xC]; + +extern u8 D_8004A81C[8][2]; // 50m rivet positions +extern u8 D_8004A82C[5][3] = { + {'1','S','T'}, + {'2','N','D'}, + {'3','R','D'}, + {'4','T','H'}, + {'5','T','H'}, +}; +extern s32 D_8004A83C = 0; + +/*.rodata 0x8004A840*/ +extern char D_8004A840[] = "NAME %.3s"; +extern char D_8004A84C[] = "---"; +extern char D_8004A850[] = "REGI TIME <%02d>"; +extern char D_8004A864[] = "YOUR NAME WAS"; +extern char D_8004A874[] = "REGISTERED"; +extern char D_8004A880[] = "NAME REGISTRATION"; +extern char D_8004A894[] = "A B C D E F G H I J"; +extern char D_8004A8A8[] = "K L M N O P Q R S T"; +extern char D_8004A8BC[] = "U V W X Y Z . -"; +extern char D_8004A8CC[] = "ba"; +extern char D_8004A8D0[] = "%.3s"; +extern char D_8004A8D8[] = "%.3s %06d %.3s"; +extern char D_8004A8EC[] = "CREDIT 00"; +extern char D_8004A8F8[] = "1UP"; +extern char D_8004A8FC[] = "HIGH SCORE"; +extern char D_8004A908[] = "L=%02d"; +extern char D_8004A910[] = "%06d %06d"; +extern char D_8004A920[] = "GAME OVER"; +extern char D_8004A92C[] = "RETURN"; +extern u8 D_8004A934; +extern u8 D_8004A944; +extern u8 D_8004A954; +extern u8 D_8004A95C; +extern u8 D_8004A974; +extern u8 D_8004A97C; +extern u8 D_8004A984; +extern u8 D_8004A98C; +extern u8 D_8004A994; +extern u8 D_8004A9A0; +extern u8 D_8004A9B0; +extern u8 D_8004A9BC; +extern u8 D_8004A9D0; +extern u8 D_8004A9DC; +/*jmp_tbl D_8004A9EC[6]*/ + +extern f32 D_8004AA18; +extern f64 D_8004AA98; +extern f64 D_8004AAA0; +extern f64 D_8004AAA8; +extern f64 D_8004AAB0; +extern f64 D_8004AB28; +extern f64 D_8004AB30; +extern f32 D_8004AB38; + +extern f32 D_8004AB78; +extern f32 D_8004AB7C; + +/* .bss 0x804AC00 */ +extern ArcadeStruct3 D_8004AC00[]; +extern uSprite D_8004BB00[2]; +extern uSprite D_8004BB30[2]; +extern uSprite D_8004BB60[2]; +extern uSprite D_8004BB90[2]; +extern uSprite D_8004BBC0[2]; +extern uSprite D_8004BBF0[]; +extern f32 D_8004BC88[6][3]; +extern ArcadeStruct1 D_8004BCD0[0x50]; +extern void *D_8004C6D0; +extern s32 D_8004C6D4; +extern s16 D_8004C6D6; +extern s32 D_8004C6D8; +extern s32 D_8004C6DC; // arcade_internal_timer +extern s32 D_8004C6E0; +extern D_8004C6E4; +extern D_8004C6EC; +extern s32 D_8004C6E8; +extern s32 D_8004C6F0; +extern s32 D_8004C6F4; +extern s32 D_8004C6F8; +extern s32 D_8004C6FC; +extern s32 D_8004C704; +extern u32 D_8004C708; +extern s32 D_8004C70C; +extern s32 D_8004C710; +extern s32 arcade_next_sfx; //0x8004C714 +extern u8 D_8004C718; +extern u8 D_8004C719; +extern u8 D_8004C71A; +extern u8 arcade_lives_internal; //0x8004C71B +extern u8 arcade_lives_visual; //0x8004C71C +extern u8 arcade_game_state; //0x8004C71D +extern s8 D_8004C71E; +extern u8 D_8004C71F; // Index into D_8004BCD0[], arcade_jumpman_slot? +extern u8 D_8004C720; +extern u8 D_8004C721; +extern u8 arcade_background_visual; //0x8004C722 +extern u8 D_8004C723; +extern u8 D_8004C724; +extern u8 D_8004C725; +extern u8 D_8004C726; +extern u8 D_8004C727; +extern u8 D_8004C728; +extern D_8004C72C; +extern s16 D_8004C72E; +extern D_8004C730; +extern s16 D_8004C732; + +/* global_asm */ +extern u8 D_807444FC; +extern Gfx *D_8076A050[]; +extern s32 D_8076A048; +extern void *D_8076A080; +extern s32 D_8076A088; +extern s32 D_8076A08C; +extern u8 D_8076A0B1; +extern u8 D_80767CE8; +extern f32 D_807FD888; +extern u32 D_8076D1F8; // ?? +extern s32 D_80770DF8; +extern GlobalASMStruct17 *D_807ECDE8; +extern u8 *D_80746800; +#endif /* ARCADE_INTERNAL_H */ diff --git a/include/controller.h b/include/controller.h new file mode 100755 index 00000000..720928cd --- /dev/null +++ b/include/controller.h @@ -0,0 +1,210 @@ +#ifndef _CONTROLLER_H +#define _CONTROLLER_H +#include +#include + +//should go somewhere else but +#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0]))) +#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4) + + +typedef struct +{ + /* 0x0 */ u32 ramarray[15]; + /* 0x3C */ u32 pifstatus; +} OSPifRam; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u16 button; + /* 0x6 */ s8 stick_x; + /* 0x7 */ s8 stick_y; +} __OSContReadFormat; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 typeh; + /* 0x5 */ u8 typel; + /* 0x6 */ u8 status; + /* 0x7 */ u8 dummy1; +} __OSContRequesFormat; + +typedef struct +{ + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 typeh; + /* 0x4 */ u8 typel; + /* 0x5 */ u8 status; +} __OSContRequesFormatShort; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 unk4; + /* 0x5 */ u8 unk5; + //u16 address; + /* 0x6 */ u8 data[BLOCKSIZE]; + /* 0x26 */ u8 datacrc; +} __OSContRamReadFormat; + +typedef union { + /* 0x0 */ struct + { + /* 0x0 */ u8 bank; + /* 0x1 */ u8 page; + } inode_t; + /* 0x0 */ u16 ipage; +} __OSInodeUnit; + +typedef struct +{ + /* 0x0 */ u32 game_code; + /* 0x4 */ u16 company_code; + /* 0x6 */ __OSInodeUnit start_page; + /* 0x8 */ u8 status; + /* 0x9 */ s8 reserved; + /* 0xA */ u16 data_sum; + /* 0xC */ u8 ext_name[PFS_FILE_EXT_LEN]; + /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN]; +} __OSDir; + +typedef struct +{ + /* 0x0 */ __OSInodeUnit inode_page[128]; +} __OSInode; + +typedef struct +{ + /* 0x0 */ u32 repaired; + /* 0x4 */ u32 random; + /* 0x8 */ u64 serial_mid; + /* 0x10 */ u64 serial_low; + /* 0x18 */ u16 deviceid; + /* 0x1A */ u8 banks; + /* 0x1B */ u8 version; + /* 0x1C */ u16 checksum; + /* 0x1E */ u16 inverted_checksum; +} __OSPackId; + +typedef struct +{ + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 address; + /* 0x4 */ u8 data[EEPROM_BLOCK_SIZE]; +} __OSContEepromFormat; + +//from: http://en64.shoutwiki.com/wiki/SI_Registers_Detailed#CONT_CMD_Usage +#define CONT_CMD_REQUEST_STATUS 0 +#define CONT_CMD_READ_BUTTON 1 +#define CONT_CMD_READ_MEMPACK 2 +#define CONT_CMD_WRITE_MEMPACK 3 +#define CONT_CMD_READ_EEPROM 4 +#define CONT_CMD_WRITE_EEPROM 5 +#define CONT_CMD_RESET 0xff + +#define CONT_CMD_REQUEST_STATUS_TX 1 +#define CONT_CMD_READ_BUTTON_TX 1 +#define CONT_CMD_READ_MEMPACK_TX 3 +#define CONT_CMD_WRITE_MEMPACK_TX 35 +#define CONT_CMD_READ_EEPROM_TX 2 +#define CONT_CMD_WRITE_EEPROM_TX 10 +#define CONT_CMD_RESET_TX 1 + +#define CONT_CMD_REQUEST_STATUS_RX 3 +#define CONT_CMD_READ_BUTTON_RX 4 +#define CONT_CMD_READ_MEMPACK_RX 33 +#define CONT_CMD_WRITE_MEMPACK_RX 1 +#define CONT_CMD_READ_EEPROM_RX 8 +#define CONT_CMD_WRITE_EEPROM_RX 1 +#define CONT_CMD_RESET_RX 3 + +#define CONT_CMD_NOP 0xff +#define CONT_CMD_END 0xfe //indicates end of a command +#define CONT_CMD_EXE 1 //set pif ram status byte to this to do a command + +#define DIR_STATUS_EMPTY 0 +#define DIR_STATUS_UNKNOWN 1 +#define DIR_STATUS_OCCUPIED 2 + + +typedef struct +{ + /* 0x0 */ __OSInode inode; + /* 0x100 */ u8 bank; + /* 0x101 */ u8 map[256]; +} __OSInodeCache; + +extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *); +u16 __osSumcalc(u8 *ptr, int length); +s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); +s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid); +s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp); +s32 __osGetId(OSPfs *pfs); +s32 __osCheckId(OSPfs *pfs); +s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank); +s32 __osPfsSelectBank(OSPfs *pfs); +s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page); +s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag); +s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank); +s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer); +s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force); +void __osContGetInitData(u8 *pattern, OSContStatus *data); +void __osPackRequestData(u8 cmd); +void __osPfsRequestData(u8 cmd); +void __osPfsGetInitData(u8* pattern, OSContStatus* data); +u8 __osContAddressCrc(u16 addr); +u8 __osContDataCrc(u8 *data); +s32 __osPfsGetStatus(OSMesgQueue *queue, int channel); + +extern u8 __osContLastCmd; +extern OSTimer __osEepromTimer; +extern OSMesg __osEepromTimerMsg; +extern OSMesgQueue __osEepromTimerQ; +extern OSPifRam __osEepPifRam; +extern OSPifRam __osContPifRam; +extern OSPifRam __osPfsPifRam; +extern u8 __osMaxControllers; + +//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0 +#define ERRCK(fn) \ + ret = fn; \ + if (ret != 0) \ + return ret; + +#define SET_ACTIVEBANK_TO_ZERO \ + if (pfs->activebank != 0) \ + { \ + pfs->activebank = 0; \ + ERRCK(__osPfsSelectBank(pfs)) \ + } + +#define PFS_CHECK_ID \ + if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ + return PFS_ERR_NEW_PACK; +#endif + +#define PFS_CHECK_STATUS \ + if ((pfs->status & PFS_INITIALIZED) == 0) \ + return PFS_ERR_INVALID; + +#define PFS_GET_STATUS \ + __osSiGetAccess(); \ + ret = __osPfsGetStatus(queue, channel); \ + __osSiRelAccess(); \ + if (ret != 0) \ + return ret; diff --git a/include/enums.h b/include/enums.h new file mode 100644 index 00000000..fab1f127 --- /dev/null +++ b/include/enums.h @@ -0,0 +1,620 @@ +#ifndef __ENUMS_H__ +#define __ENUMS_H__ + +typedef enum game_mode_e { + GAME_MODE_NINTENDO_LOGO, + GAME_MODE_OPENING_CUTSCENE, + GAME_MODE_DK_RAP, + GAME_MODE_DK_TV, + GAME_MODE_UNKNOWN_4, + GAME_MODE_MAIN_MENU, + GAME_MODE_ADVENTURE, + GAME_MODE_QUIT_GAME, + GAME_MODE_UNKNOWN_8, + GAME_MODE_GAME_OVER, + GAME_MODE_END_SEQUENCE, + GAME_MODE_DK_THEATRE, + GAME_MODE_MYSTERY_MENU_MINIGAME, + GAME_MODE_SNIDES_BONUS_GAME, + GAME_MODE_END_SEQUENCE_DK_THEATRE +} GameModes; + +typedef enum map_e { + MAP_TEST_MAP, + MAP_FUNKYS_STORE, + MAP_DK_ARCADE, + MAP_KROOL_BARREL_LANKY_MAZE, + MAP_JAPES_MOUNTAIN, + MAP_CRANKYS_LAB, + MAP_JAPES_MINECART, + MAP_JAPES, + MAP_JAPES_ARMY_DILLO, + MAP_JETPAC, + MAP_KREMLING_KOSH_VERY_EASY, + MAP_STEALTHY_SNOOP_NORMAL_NO_LOGO, + MAP_JAPES_SHELL, + MAP_JAPES_LANKY_CAVE, + MAP_AZTEC_BEETLE_RACE, + MAP_SNIDES_HQ, + MAP_AZTEC_TINY_TEMPLE, + MAP_HELM, + MAP_TEETERING_TURTLE_TROUBLE_VERY_EASY, + MAP_AZTEC_FIVE_DOOR_TEMPLE_DK, + MAP_AZTEC_LLAMA_TEMPLE, + MAP_AZTEC_FIVE_DOOR_TEMPLE_DIDDY, + MAP_AZTEC_FIVE_DOOR_TEMPLE_TINY, + MAP_AZTEC_FIVE_DOOR_TEMPLE_LANKY, + MAP_AZTEC_FIVE_DOOR_TEMPLE_CHUNKY, + MAP_CANDYS_MUSIC_SHOP, + MAP_FACTORY, + MAP_FACTORY_CAR_RACE, + MAP_HELM_LEVEL_INTROS_GAME_OVER, + MAP_FACTORY_POWER_SHED, + MAP_GALLEON, + MAP_GALLEON_KROOLS_SHIP, + MAP_BATTY_BARREL_BANDIT_EASY, + MAP_JAPES_CHUNKY_CAVE, + MAP_DK_ISLES_OVERWORLD, + MAP_KROOL_BARREL_DK_TARGET_GAME, + MAP_FACTORY_CRUSHER_ROOM, + MAP_JAPES_BARREL_BLAST, + MAP_AZTEC, + MAP_GALLEON_SEAL_RACE, + MAP_NINTENDO_LOGO, + MAP_AZTEC_BARREL_BLAST, + MAP_TROFF_N_SCOFF, + MAP_GALLEON_SHIPWRECK_DIDDY_LANKY_CHUNKY, + MAP_GALLEON_TREASURE_CHEST, + MAP_GALLEON_MERMAID, + MAP_GALLEON_SHIPWRECK_DK_TINY, + MAP_GALLEON_SHIPWRECK_LANKY_TINY, + MAP_FUNGI, + MAP_GALLEON_LIGHTHOUSE, + MAP_KROOL_BARREL_TINY_MUSHROOM_GAME, + MAP_GALLEON_MECHANICAL_FISH, + MAP_FUNGI_ANT_HILL, + MAP_BATTLE_ARENA_BEAVER_BRAWL, + MAP_GALLEON_BARREL_BLAST, + MAP_FUNGI_MINECART, + MAP_FUNGI_DIDDY_BARN, + MAP_FUNGI_DIDDY_ATTIC, + MAP_FUNGI_LANKY_ATTIC, + MAP_FUNGI_DK_BARN, + MAP_FUNGI_SPIDER, + MAP_FUNGI_FRONT_PART_OF_MILL, + MAP_FUNGI_REAR_PART_OF_MILL, + MAP_FUNGI_MUSHROOM_PUZZLE, + MAP_FUNGI_GIANT_MUSHROOM, + MAP_STEALTHY_SNOOP_NORMAL, + MAP_MAD_MAZE_MAUL_HARD, + MAP_STASH_SNATCH_NORMAL, + MAP_MAD_MAZE_MAUL_EASY, + MAP_MAD_MAZE_MAUL_NORMAL, + MAP_FUNGI_MUSHROOM_LEAP, + MAP_FUNGI_SHOOTING_GAME, + MAP_CAVES, + MAP_BATTLE_ARENA_KRITTER_KARNAGE, + MAP_STASH_SNATCH_EASY, + MAP_STASH_SNATCH_HARD, + MAP_DK_RAP, + MAP_MINECART_MAYHEM_EASY, + MAP_BUSY_BARREL_BARRAGE_EASY, + MAP_BUSY_BARREL_BARRAGE_NORMAL, + MAP_MAIN_MENU, + MAP_TITLE_SCREEN_NOT_FOR_RESALE_VERSION, + MAP_CAVES_BEETLE_RACE, + MAP_FUNGI_DOGADON, + MAP_CAVES_IGLOO_TINY, + MAP_CAVES_IGLOO_LANKY, + MAP_CAVES_IGLOO_DK, + MAP_CASTLE, + MAP_CASTLE_BALLROOM, + MAP_CAVES_ROTATING_ROOM, + MAP_CAVES_SHACK_CHUNKY, + MAP_CAVES_SHACK_DK, + MAP_CAVES_SHACK_DIDDY_MIDDLE_PART, + MAP_CAVES_SHACK_TINY, + MAP_CAVES_LANKY_HUT, + MAP_CAVES_IGLOO_CHUNKY, + MAP_SPLISH_SPLASH_SALVAGE_NORMAL, + MAP_KLUMSY, + MAP_CAVES_ICE_CASTLE, + MAP_SPEEDY_SWING_SORTIE_EASY, + MAP_CAVES_IGLOO_DIDDY, + MAP_KRAZY_KONG_KLAMOUR_EASY, + MAP_BIG_BUG_BASH_VERY_EASY, + MAP_SEARCHLIGHT_SEEK_VERY_EASY, + MAP_BEAVER_BOTHER_EASY, + MAP_CASTLE_TOWER, + MAP_CASTLE_MINECART, + MAP_KONG_BATTLE_BATTLE_ARENA, + MAP_CASTLE_CRYPT_LANKY_TINY, + MAP_KONG_BATTLE_ARENA_1, + MAP_FACTORY_BARREL_BLAST, + MAP_GALLEON_PUFFTOSS, + MAP_CASTLE_CRYPT_DK_DIDDY_CHUNKY, + MAP_CASTLE_MUSEUM, + MAP_CASTLE_LIBRARY, + MAP_KREMLING_KOSH_EASY, + MAP_KREMLING_KOSH_NORMAL, + MAP_KREMLING_KOSH_HARD, + MAP_TEETERING_TURTLE_TROUBLE_EASY, + MAP_TEETERING_TURTLE_TROUBLE_NORMAL, + MAP_TEETERING_TURTLE_TROUBLE_HARD, + MAP_BATTY_BARREL_BANDIT_EASY_2, + MAP_BATTY_BARREL_BANDIT_NORMAL, + MAP_BATTY_BARREL_BANDIT_HARD, + MAP_MAD_MAZE_MAUL_INSANE, + MAP_STASH_SNATCH_INSANE, + MAP_STEALTHY_SNOOP_VERY_EASY, + MAP_STEALTHY_SNOOP_EASY, + MAP_STEALTHY_SNOOP_HARD, + MAP_MINECART_MAYHEM_NORMAL, + MAP_MINECART_MAYHEM_HARD, + MAP_BUSY_BARREL_BARRAGE_HARD, + MAP_SPLISH_SPLASH_SALVAGE_HARD, + MAP_SPLISH_SPLASH_SALVAGE_EASY, + MAP_SPEEDY_SWING_SORTIE_NORMAL, + MAP_SPEEDY_SWING_SORTIE_HARD, + MAP_BEAVER_BOTHER_NORMAL, + MAP_BEAVER_BOTHER_HARD, + MAP_SEARCHLIGHT_SEEK_EASY, + MAP_SEARCHLIGHT_SEEK_NORMAL, + MAP_SEARCHLIGHT_SEEK_HARD, + MAP_KRAZY_KONG_KLAMOUR_NORMAL, + MAP_KRAZY_KONG_KLAMOUR_HARD, + MAP_KRAZY_KONG_KLAMOUR_INSANE, + MAP_PERIL_PATH_PANIC_VERY_EASY, + MAP_PERIL_PATH_PANIC_EASY, + MAP_PERIL_PATH_PANIC_NORMAL, + MAP_PERIL_PATH_PANIC_HARD, + MAP_BIG_BUG_BASH_EASY, + MAP_BIG_BUG_BASH_NORMAL, + MAP_BIG_BUG_BASH_HARD, + MAP_CASTLE_DUNGEON, + MAP_HELM_INTRO_STORY, + MAP_DK_ISLES_DK_THEATRE, + MAP_FACTORY_MAD_JACK, + MAP_BATTLE_ARENA_ARENA_AMBUSH, + MAP_BATTLE_ARENA_MORE_KRITTER_KARNAGE, + MAP_BATTLE_ARENA_FOREST_FRACAS, + MAP_BATTLE_ARENA_BISH_BASH_BRAWL, + MAP_BATTLE_ARENA_KAMIKAZE_KREMLINGS, + MAP_BATTLE_ARENA_PLINTH_PANIC, + MAP_BATTLE_ARENA_PINNACLE_PALAVER, + MAP_BATTLE_ARENA_SHOCKWAVE_SHOWDOWN, + MAP_CASTLE_BASEMENT, + MAP_CASTLE_TREE, + MAP_KROOL_BARREL_DIDDY_KREMLING_GAME, + MAP_CASTLE_CHUNKY_TOOLSHED, + MAP_CASTLE_TRASH_CAN, + MAP_CASTLE_GREENHOUSE, + MAP_JAPES_LOBBY, + MAP_HELM_LOBBY, + MAP_DK_HOUSE, + MAP_ROCK_INTRO_STORY, + MAP_AZTEC_LOBBY, + MAP_GALLEON_LOBBY, + MAP_FACTORY_LOBBY, + MAP_TRAINING_GROUNDS, + MAP_DIVE_BARREL, + MAP_FUNGI_LOBBY, + MAP_GALLEON_SUBMARINE, + MAP_ORANGE_BARREL, + MAP_BARREL_BARREL, + MAP_VINE_BARREL, + MAP_CASTLE_CRYPT, + MAP_ENGUARDE_ARENA, + MAP_CASTLE_CAR_RACE, + MAP_CAVES_BARREL_BLAST, + MAP_CASTLE_BARREL_BLAST, + MAP_FUNGI_BARREL_BLAST, + MAP_FAIRY_ISLAND, + MAP_KONG_BATTLE_ARENA_2, + MAP_RAMBI_ARENA, + MAP_KONG_BATTLE_ARENA_3, + MAP_CASTLE_LOBBY, + MAP_CAVES_LOBBY, + MAP_DK_ISLES_SNIDES_ROOM, + MAP_CAVES_ARMY_DILLO, + MAP_AZTEC_DOGADON, + MAP_TRAINING_GROUNDS_END_SEQUENCE, + MAP_CASTLE_KING_KUT_OUT, + MAP_CAVES_SHACK_DIDDY_UPPER_PART, + MAP_KROOL_BARREL_DIDDY_ROCKETBARREL_GAME, + MAP_KROOL_BARREL_LANKY_SHOOTING_GAME, + MAP_KROOL_FIGHT_DK_PHASE, + MAP_KROOL_FIGHT_DIDDY_PHASE, + MAP_KROOL_FIGHT_LANKY_PHASE, + MAP_KROOL_FIGHT_TINY_PHASE, + MAP_KROOL_FIGHT_CHUNKY_PHASE, + MAP_BLOOPERS_ENDING, + MAP_KROOL_BARREL_CHUNKY_HIDDEN_KREMLING_GAME, + MAP_KROOL_BARREL_TINY_PONY_TAIL_TWIRL_GAME, + MAP_KROOL_BARREL_CHUNKY_SHOOTING_GAME, + MAP_KROOL_BARREL_DK_RAMBI_GAME, + MAP_KLUMSY_ENDING, + MAP_KROOLS_SHOE, + MAP_KROOLS_ARENA +} Maps; + +typedef enum actors_e { + ACTOR_UNKNOWN_0, + ACTOR_UNKNOWN_1, + ACTOR_DK, + ACTOR_DIDDY, + ACTOR_LANKY, + ACTOR_TINY, + ACTOR_CHUNKY, + ACTOR_KRUSHA, + ACTOR_RAMBI, + ACTOR_ENGUARDE, + ACTOR_UNKNOWN_10, // Always loaded, not sure what it is + ACTOR_UNKNOWN_11, // Always loaded, not sure what it is + ACTOR_LOADING_ZONE_CONTROLLER, // Always loaded + ACTOR_OBJECT_MODEL_2_CONTROLLER, // Always loaded + ACTOR_UNKNOWN_14, // Always loaded, not sure what it is + ACTOR_UNKNOWN_15, // Always loaded, not sure what it is + ACTOR_UNKNOWN_16, + ACTOR_CANNON_BARREL, + ACTOR_RAMBI_CRATE, + ACTOR_BARREL_DIDDY_5DI, + ACTOR_CAMERA_FOCUS_POINT, // Exists during some cutscenes + ACTOR_PUSHABLE_BOX, // Unused + ACTOR_BARREL_SPAWNER_UNUSED, // Unused + ACTOR_CANNON, + ACTOR_VULTURE_RACE_HOOP, + ACTOR_HUNKY_CHUNKY_BARREL, + ACTOR_TNT_BARREL, + ACTOR_TNT_BARREL_SPAWNER, // Army Dillo + ACTOR_BONUS_BARREL, + ACTOR_MINECART, + ACTOR_BOSS_PROJECTILE_FIREBALL, + ACTOR_CASTLE_BRIDGE, + ACTOR_SWINGING_LIGHT, + ACTOR_VINE_BROWN, + ACTOR_KREMLING_KOSH_CONTROLLER, + ACTOR_PROJECTILE_MELON, + ACTOR_PROJECTILE_PEANUT, + ACTOR_ROCKETBARREL_ON_KONG, + ACTOR_PROJECTILE_PINEAPPLE, + ACTOR_LARGE_BRIDGE, // Unused + ACTOR_MINI_MONKEY_BARREL, + ACTOR_PROJECTILE_ORANGE, + ACTOR_PROJECTILE_GRAPE, + ACTOR_PROJECTILE_FEATHER, + ACTOR_BOSS_PROJECTILE_LASER, + ACTOR_GOLDEN_BANANA, // Vulture, bonus barrels, probably some other places + ACTOR_TTT_GUN, + ACTOR_WATERMELON_SLICE, + ACTOR_PROJECTILE_COCONUTS, + ACTOR_ROCKETBARREL, + ACTOR_PROJECTILE_LIME, + ACTOR_AMMO_CRATE, // Dropped by Red Klaptrap + ACTOR_ORANGE_PICKUP, // Dropped by Klump & Purple Klaptrap + ACTOR_BANANA_COIN, // Dropped by "Diddy", otherwise unused? + ACTOR_DK_COIN, // Minecart + ACTOR_SMALL_EXPLOSION, // Seasick Chunky + ACTOR_ORANGSTAND_SPRINT_BARREL, + ACTOR_STRONG_KONG_BARREL, + ACTOR_SWINGING_LIGHT_2, + ACTOR_BOSS_PROJECTILE_FIREBALL_2, + ACTOR_BANAPORTER, + ACTOR_BOULDER, + ACTOR_MINECART_DK, + ACTOR_VASE_OVAL, + ACTOR_VASE_DOTS, + ACTOR_VASE_TRIANGLE, + ACTOR_VASE_PLUS, + ACTOR_CANNON_BALL, + ACTOR_UNKNOWN_68, + ACTOR_VINE, // Green + ACTOR_COUNTER, // Unused? + ACTOR_KREMLING_RED, // Lanky's Keyboard Game in R&D + ACTOR_BOSS_KEY, + ACTOR_GALLEON_CANNON, // Galleon Minigame + ACTOR_GALLEON_CANNON_BALL, // Galleon Minigame Projectile + ACTOR_BLUEPRINT_DIDDY, + ACTOR_BLUEPRINT_CHUNKY, + ACTOR_BLUEPRINT_LANKY, + ACTOR_BLUEPRINT_DK, + ACTOR_BLUEPRINT_TINY, + ACTOR_MINECART_CHUNKY, + ACTOR_BOSS_FIRE_SPAWNER, // TODO: Verify + ACTOR_BOULDER_DEBRIS, // Minecart + ACTOR_SPIDER_WEB, // Fungi miniBoss + ACTOR_STEEL_KEG_SPAWNER, + ACTOR_STEEL_KEG, + ACTOR_CROWN, + ACTOR_MINECART_BONUS, + ACTOR_UNKNOWN_88, + ACTOR_FIRE_UNUSED, + ACTOR_ICE_WALL, + ACTOR_BALLOON_DIDDY, + ACTOR_STALACTITE, + ACTOR_ROCK_DEBRIS, // Rotating, Unused? + ACTOR_CAR, // Unused? + ACTOR_PAUSE_MENU, + ACTOR_HUNKY_CHUNKY_BARREL_DOGADON, + ACTOR_TNT_BARREL_SPAWNER_DOGADON, + ACTOR_TAG_BARREL, + ACTOR_FIREBALL_GET_OUT, // Get Out + ACTOR_DIDDY_5DI_PAD_1, + ACTOR_DIDDY_5DI_PAD_2, + ACTOR_DIDDY_5DI_PAD_3, + ACTOR_DIDDY_5DI_PAD_4, + ACTOR_DIDDY_5DI_PAD_5, + ACTOR_DIDDY_5DI_PAD_6, + ACTOR_KONG_REFLECTION, + ACTOR_BONUS_BARREL_HELM, + ACTOR_UNKNOWN_108 + /* + [109] = "Race Checkpoint", + [110] = "CB Bunch", // Unused? Doesn't seem to work, these are normally model 2 + ACTOR_BALLOON_CHUNKY, + ACTOR_BALLOON_TINY, + ACTOR_BALLOON_LANKY, + ACTOR_BALLOON_DK, + [115] = "K. Lumsy's Cage", // TODO: Also rabbit race finish line? + [116] = "Chain", + [117] = "Beanstalk", + [118] = "Yellow ?", // Unused? + [119] = "CB Single (Blue)", // Unused? Doesn't seem to work, these are normally model 2 + [120] = "CB Single (Yellow)", // Unused? Doesn't seem to work, these are normally model 2 + [121] = "Crystal Coconut", // Unused? Doesn't seem to work, these are normally model 2 + [122] = "DK Coin", // Multiplayer + [123] = "Kong Mirror", // Creepy Castle Museum + [124] = "Barrel Gun", // Peril Path Panic + [125] = "Barrel Gun", // Krazy Kong Klamour + [126] = "Fly Swatter", + [127] = "Searchlight", // Searchlight Seek + ACTOR_HEADPHONES, + [129] = "Enguarde Crate", + [130] = "Apple", // Fungi + [131] = "Worm", // Fungi + [132] = "Enguarde Crate (Unused?)", + [133] = "Barrel", + [134] = "Training Barrel", + [135] = "Boombox", // Treehouse + [136] = "Tag Barrel", + [137] = "Tag Barrel", // Troff'n'Scoff + ACTOR_B_LOCKER, + ACTOR_RAINBOW_COIN_PATCH, + ACTOR_RAINBOW_COIN, + ACTOR_UNKNOWN_141, + ACTOR_UNKNOWN_142, + ACTOR_UNKNOWN_143, + ACTOR_UNKNOWN_144, + [145] = "Cannon (Seasick Chunky)", // Internal name "Puffer cannon" + ACTOR_UNKNOWN_146, + [147] = "Balloon (Unused - K. Rool)", // Internal Name: K. Rool Banana Balloon, unsure of purpose. Can only be popped by Lanky + [148] = "Rope", // K. Rool's Arena + [149] = "Banana Barrel", // Lanky Phase + [150] = "Banana Barrel Spawner", // Lanky Phase, internal name "Skin barrel generator" + ACTOR_UNKNOWN_151, + ACTOR_UNKNOWN_152, + ACTOR_UNKNOWN_153, + ACTOR_UNKNOWN_154, + ACTOR_UNKNOWN_155, + ACTOR_WRINKLY, + ACTOR_UNKNOWN_157, + ACTOR_UNKNOWN_158, + ACTOR_UNKNOWN_159, + ACTOR_UNKNOWN_160, + ACTOR_UNKNOWN_161, + ACTOR_UNKNOWN_162, + [163] = "Banana Fairy (BFI)", + [164] = "Ice Tomato", + [165] = "Tag Barrel (King Kut Out)", + [166] = "King Kut Out Part", + [167] = "Cannon", + ACTOR_UNKNOWN_168, + [169] = "Pufftup", // Pufftoss Fight + [170] = "Damage Source", // K. Rool's Glove + [171] = "Orange", // Krusha's Gun + [173] = "Cutscene Controller", + ACTOR_UNKNOWN_174, + [175] = "Kaboom", + [176] = "Timer", + [177] = "Timer Controller", // Pufftoss Fight & Fac Beaver Bother Spawn Timer + [178] = "Beaver", // Blue + [179] = "Shockwave (Mad Jack)", + [180] = "Krash", // Minecart Club Guy + [181] = "Book", // Castle Library + [182] = "Klobber", + [183] = "Zinger", + [184] = "Snide", + [185] = "Army Dillo", + [186] = "Kremling", // Kremling Kosh + [187] = "Klump", + [188] = "Camera", + [189] = "Cranky", + [190] = "Funky", + [191] = "Candy", + [192] = "Beetle", // Race + [193] = "Mermaid", + [194] = "Vulture", + [195] = "Squawks", + [196] = "Cutscene DK", + [197] = "Cutscene Diddy", + [198] = "Cutscene Lanky", + [199] = "Cutscene Tiny", + [200] = "Cutscene Chunky", + [201] = "Llama", + [202] = "Fairy Picture", + [203] = "Padlock (T&S)", + [204] = "Mad Jack", + [205] = "Klaptrap", // Green + [206] = "Zinger", + [207] = "Vulture (Race)", + [208] = "Klaptrap (Purple)", + [209] = "Klaptrap (Red)", + [210] = "GETOUT Controller", + [211] = "Klaptrap (Skeleton)", + [212] = "Beaver (Gold)", + [213] = "Fire Column Spawner", // Japes Minecart + [214] = "Minecart (TNT)", // Minecart Mayhem + [215] = "Minecart (TNT)", + [216] = "Pufftoss", + ACTOR_UNKNOWN_217, + [218] = "Handle", + [219] = "Slot", + [220] = "Cannon (Seasick Chunky)", + [221] = "Light Piece", // Lanky Phase + [222] = "Banana Peel", // Lanky Phase + [223] = "Fireball Spawner", // Factory Crusher Room + [224] = "Mushroom Man", + ACTOR_UNKNOWN_225, + [226] = "Troff", + [227] = "K. Rool's Foot", // Including leftmost toe + [228] = "Bad Hit Detection Man", + [229] = "K. Rool's Toe", // Rightmost 3 toes + [230] = "Ruler", + [231] = "Toy Box", + [232] = "Text Overlay", + [233] = "Squawks", + [234] = "Scoff", + [235] = "Robo-Kremling", + [236] = "Dogadon", + ACTOR_UNKNOWN_237, + [238] = "Kremling", + [239] = "Bongos", + [240] = "Spotlight Fish", + [241] = "Kasplat (DK)", + [242] = "Kasplat (Diddy)", + [243] = "Kasplat (Lanky)", + [244] = "Kasplat (Tiny)", + [245] = "Kasplat (Chunky)", + [246] = "Mechanical Fish", + [247] = "Seal", + [248] = "Banana Fairy", + [249] = "Squawks with spotlight", + [250] = "Owl", + [251] = "Spider miniBoss", + [252] = "Rabbit", // Fungi + [253] = "Nintendo Logo", + [254] = "Cutscene Object", // For objects animated by Cutscenes + [255] = "Shockwave", + [256] = "Minigame Controller", + [257] = "Fire Breath Spawner", // Aztec Beetle Race + [258] = "Shockwave", // Boss + [259] = "Guard", // Stealthy Snoop + [260] = "Text Overlay", // K. Rool boss + [261] = "Robo-Zinger", + [262] = "Krossbones", + [263] = "Fire Shockwave (Dogadon)", + [264] = "Squawks", + [265] = "Light beam", // Boss bosss etc + [266] = "DK Rap Controller", // Handles the lyrics etc + [267] = "Shuri", + [268] = "Gimpfish", + [269] = "Mr. Dice", + [270] = "Sir Domino", + [271] = "Mr. Dice", + [272] = "Rabbit", + [273] = "Fireball (With Glasses)", // From Chunky 5DI + ACTOR_UNKNOWN_274, + [275] = "K. Lumsy", + [276] = "Spiderling", + [277] = "Squawks", + [278] = "Projectile", // Spider miniBoss + [279] = "Trap Bubble", // Spider miniBoss + [280] = "Spider Silk String", // Spider miniBoss + [281] = "K. Rool (DK Phase)", + [282] = "Retexturing Controller", // Beaver Bother + [283] = "Skeleton Head", + ACTOR_UNKNOWN_284, + [285] = "Bat", + [286] = "Giant Clam", + ACTOR_UNKNOWN_287, + [288] = "Tomato", // Fungi + [289] = "Kritter-in-a-Sheet", + [290] = "Pufftup", + [291] = "Kosha", + [292] = "K. Rool (Diddy Phase)", + [293] = "K. Rool (Lanky Phase)", + [294] = "K. Rool (Tiny Phase)", + [295] = "K. Rool (Chunky Phase)", + ACTOR_UNKNOWN_296, + [297] = "Battle Crown Controller", + ACTOR_UNKNOWN_298, + [299] = "Textbox", + [300] = "Snake", // Teetering Turtle Trouble + [301] = "Turtle", // Teetering Turtle Trouble + [302] = "Toy Car", // Player in the Factory Toy Car Race + [303] = "Toy Car", + [304] = "Camera", // Factory Toy Car Race + [305] = "Missile", // Car Race + ACTOR_UNKNOWN_306, + ACTOR_UNKNOWN_307, + [308] = "Seal", + [309] = "Kong Logo (Instrument)", // DK for DK, Star for Diddy, DK for Lanky, Flower for Tiny, DK for Chunky + [310] = "Spotlight", // Tag barrel, instrument etc. + [311] = "Race Checkpoint", // Seal race & Castle car race + [312] = "Minecart (TNT)", + [313] = "Idle Particle", + [314] = "Rareware Logo", + ACTOR_UNKNOWN_315, + [316] = "Kong (Tag Barrel)", + [317] = "Locked Kong (Tag Barrel)", + ACTOR_UNKNOWN_318, + [319] = "Propeller (Boat)", + [320] = "Potion", // Cranky Purchase + [321] = "Fairy (Refill)", // Refill Fairy + [322] = "Car", // Car Race + [323] = "Enemy Car", // Car Race, aka George + [324] = "Text Overlay Controller", // Candy's + [325] = "Shockwave", // Simian Slam + [326] = "Main Menu Controller", + [327] = "Kong", // Krazy Kong Klamour + [328] = "Klaptrap", // Peril Path Panic + [329] = "Fairy", // Peril Path Panic + [330] = "Bug", // Big Bug Bash + [331] = "Klaptrap", // Searchlight Seek + [332] = "Big Bug Bash Controller?", // TODO: Fly swatter? + [333] = "Barrel (Main Menu)", + [334] = "Padlock (K. Lumsy)", + [335] = "Snide's Menu", + [336] = "Training Barrel Controller", + [337] = "Multiplayer Model (Main Menu)", + [338] = "End Sequence Controller", + [339] = "Arena Controller", // Rambi/Enguarde + [340] = "Bug", // Trash Can + ACTOR_UNKNOWN_341, + [342] = "Try Again Dialog", + [343] = "Pause Menu", // Mystery menu bosses + */ +} Actors; + +typedef enum sfx_e{ + SFX_0_SILENCE, + + SFX_40_ARCADE_JUMPMAN_MOVING = 0x40, + SFX_41_ARCADE_JUMPMAN_JUMPING, + SFX_42_ARCADE_JUMPMAN_HIT, + SFX_43_ARCADE_SPRING_SPRINGING, + SFX_44_ARCADE_SPRING_FALL, + SFX_45_ARCADE_POINTS, + SFX_46_ARCADE_INTRO, + + SFX_48_ARCADE_RUNNING_OUT_OF_TIME = 0x48, + SFX_49_ARCADE_HAMMER_MUSIC, + + SFX_4B_ARCADE_HAMMER_ATTACK = 0x4b, + SFX_4C_ARCADE_PAULINE_SAVED_STAGE, + SFX_4D_ARCADE_25M, + SFX_4E_ARCADE_100M, + SFX_4F_ARCADE_50M, + + SFX_53_ARCADE_DK_GRUNT = 0x53, + SFX_54_ARCADE_JUMPMAN_DEATH +} SFX_E; + +// TODO: Maybe we should just define these with preprocessor macros, unless there's a way to make this enum explicitly u8 +typedef enum flagtype_e { + FLAG_TYPE_PERMANENT, + FLAG_TYPE_GLOBAL, + FLAG_TYPE_TEMPORARY +} FlagTypes; + +#endif diff --git a/include/functions.h b/include/functions.h new file mode 100644 index 00000000..cf389995 --- /dev/null +++ b/include/functions.h @@ -0,0 +1,82 @@ +#ifndef __FUNCTIONS_H__ +#define __FUNCTIONS_H__ + +#include "enums.h" +#include "structs.h" + +/* your function prototype definitions go here */ +void *malloc(s32 size); +s32 rand(void); +void *memcpy(void *dest, void *src, u32 n); + +void *getPointerTableFile(s32 pointerTableIndex, s32 fileIndex, s32 arg2, s32 arg3); +void loadExits(s32 map); +void setFlag(s16 flagIndex, u8 newValue, u8 flagType); // TODO: Can we use the FlagTypes enum? +u8 isFlagSet(s16 flagIndex, u8 flagType); // TODO: Can we use the FlagTypes enum? +ExitData *getExitData(s32 exitIndex); + +// TODO: What do the params mean? +void playCutscene(Actor*, s16, s32); +void playSong(s32, f32); +void playSound(s16, s16, f32, f32, s32, s32); + +// TODO: arg0 might be actionIndex +u8 func_806EB0C0(s16 arg0, Actor *actor, u8 playerIndex); +void func_8067B238(Actor *destination, Actor *source, f32 scale); + +void func_80684900(u8); +void func_80614E78(Actor*, s32); +void func_80629174(void); + +// TODO: Signatures are suspect +s32 func_80659470(s32); // Returns index into object model2 array +s32 func_80659544(s32); + +s32 func_805FF800(Maps *arg0, s32 *arg1); + +u16 func_806F8AD4(u8 arg0, u8 playerIndex); + +void func_80614EBC(Actor*, s32); + +u8 playerCanDive(void); +u8 playerCanThrowOrange(void); + +u8 func_805FCA64(void); // getCutsceneBarState() +u8 getLevelIndex(u8 map, u8 arg1); +void func_805FF378(Maps nextMap, s32 nextExit); +void func_805FF4D8(Maps map, s32 exit); +void func_805FF5A0(Maps map); +void func_805FFEF8(Maps map); + +void func_806F5378(void); +s32 func_80600080(Maps map); +f32 func_80612790(s16); +void func_806782C0(Actor *arg0); + +u8 func_806E770C(void); + +void setIntroStoryPlaying(u8 arg0); +u8 isIntroStoryPlaying(void); + +s32 func_80712798(void); +int gameIsInDKTVMode(void); +int gameIsInMysteryMenuMinigameMode(void); +int gameIsInMainMenuMode(void); +int gameIsInAdventureMode(void); +int gameIsInDKTheatreMode(void); +int gameIsInQuitGameMode(void); +s32 func_80714CC0(void*, f32, f32, f32, f32); + +// countSetFlags(startIndex, length, flagType); +s32 func_80731AA8(s32 startIndex, s32 length, u8 flagType); + +// TODO: Not 100% on return type +u8 func_80671C0C(Actor*, s32, f32*, f32*, f32*); + +// TODO: Why can't this signature live here, causes some problems for arcade when uncommented +// void func_8060C648(u8 arg0, u32 arg1, u8 arg2, u32 arg3, s32 arg4); + +// TODO: Where is the best place to put this so it's available everywhere and doesn't conflict with internal libultra/gu stuff? +#define ABS(d) ((d) > 0) ? (d) : -(d) + +#endif diff --git a/include/guint.h b/include/guint.h new file mode 100755 index 00000000..fa97f865 --- /dev/null +++ b/include/guint.h @@ -0,0 +1,42 @@ +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +#include +#include + +typedef union +{ + struct + { + unsigned int hi; + unsigned int lo; + } word; + + double d; +} du; + +typedef union +{ + unsigned int i; + float f; +} fu; + +#ifndef __GL_GL_H__ + +typedef float Matrix[4][4]; + +#endif + +#define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5)) +#define ABS(d) ((d) > 0) ? (d) : -(d) + +extern float __libm_qnan_f; diff --git a/include/macro.inc b/include/macro.inc new file mode 100644 index 00000000..e54ad9a8 --- /dev/null +++ b/include/macro.inc @@ -0,0 +1,20 @@ +# Assembly Macros + +.set K0BASE, 0x80000000 +.set K1BASE, 0xA0000000 +.set K2BASE, 0xC0000000 + +.macro glabel label + .global \label + .ent \label + .balign 4 + \label: +.endm + +.macro endlabel label + .end \label +.endm + +.macro .word32 x + .word \x +.endm diff --git a/include/osint.h b/include/osint.h new file mode 100644 index 00000000..82d78080 --- /dev/null +++ b/include/osint.h @@ -0,0 +1,48 @@ +#ifndef _OSINT_H +#define _OSINT_H +#include +typedef struct __OSEventState +{ + OSMesgQueue *messageQueue; + OSMesg message; +} __OSEventState; +extern struct __osThreadTail +{ + OSThread *next; + OSPri priority; +} __osThreadTail; + +//maybe should be in exceptasm.h? +extern void __osEnqueueAndYield(OSThread **); +extern void __osDequeueThread(OSThread **, OSThread *); +extern void __osEnqueueThread(OSThread **, OSThread *); +extern OSThread *__osPopThread(OSThread **); +extern void __osDispatchThread(void); + +extern void __osSetTimerIntr(OSTime); +extern OSTime __osInsertTimer(OSTimer *); +extern void __osTimerInterrupt(void); +extern u32 __osProbeTLB(void *); +extern int __osSpDeviceBusy(void); + +extern OSThread *__osRunningThread; +extern OSThread *__osActiveQueue; +extern OSThread *__osFaultedThread; +extern OSThread *__osRunQueue; + +extern OSTimer *__osTimerList; +extern OSTimer __osBaseTimer; +extern OSTime __osCurrentTime; +extern u32 __osBaseCounter; +extern u32 __osViIntrCount; +extern u32 __osTimerCounter; + +extern __OSEventState __osEventStateTab[OS_NUM_EVENTS]; + + +//not sure if this should be here +extern s32 osViClock; +extern void __osTimerServicesInit(void); +extern s32 __osAiDeviceBusy(void); +extern int __osDpDeviceBusy(void); +#endif diff --git a/include/piint.h b/include/piint.h new file mode 100644 index 00000000..b618cd3a --- /dev/null +++ b/include/piint.h @@ -0,0 +1,145 @@ +#ifndef _PIINT_H +#define _PIINT_H +#include +#include + +//https://github.com/LuigiBlood/64dd/wiki/Memory-Map + +#define LEO_BASE_REG 0x05000000 + +#define LEO_CMD (LEO_BASE_REG + 0x508) +#define LEO_STATUS (LEO_BASE_REG + 0x508) + +#define LEO_BM_CTL (LEO_BASE_REG + 0x510) +#define LEO_BM_STATUS (LEO_BASE_REG + 0x510) + +#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518) +#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518) + +#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) //C2 Sector Buffer +#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) //Data Sector Buffer +#define LEO_DATA (LEO_BASE_REG + 0x500) //Data +#define LEO_MISC_REG (LEO_BASE_REG + 0x504) //Misc Register +#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) //Current Track +#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) //Sector Error Status +#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) //Current Sector +#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) //Hard Reset +#define LEO_C1_S0 (LEO_BASE_REG + 0x524) //C1 +#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) //Sector Size (in bytes) +#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) //C1 +#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) //Sectors per Block, Full Size +#define LEO_C1_S4 (LEO_BASE_REG + 0x534) //C1 +#define LEO_C1_S6 (LEO_BASE_REG + 0x538) //C1 +#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) //Current Address? +#define LEO_ID_REG (LEO_BASE_REG + 0x540) //ID +#define LEO_TEST_REG (LEO_BASE_REG + 0x544) //Test Read +#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) //Test Write +#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) //Microsequencer RAM + +#define LEO_STATUS_PRESENCE_MASK 0xFFFF + +#define LEO_STATUS_DATA_REQUEST 0x40000000 +#define LEO_STATUS_C2_TRANSFER 0x10000000 +#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000 +#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000 +#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000 +#define LEO_STATUS_DISK_PRESENT 0x01000000 +#define LEO_STATUS_BUSY_STATE 0x00800000 +#define LEO_STATUS_RESET_STATE 0x00400000 +#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000 +#define LEO_STATUS_HEAD_RETRACTED 0x00080000 +#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000 +#define LEO_STATUS_MECHANIC_ERROR 0x00020000 +#define LEO_STATUS_DISK_CHANGE 0x00010000 + +#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_ACTIVE 0 + +#define LEO_CUR_TK_INDEX_LOCK 0x60000000 + +#define LEO_BM_STATUS_RUNNING 0x80000000 //Running +#define LEO_BM_STATUS_ERROR 0x04000000 //Error +#define LEO_BM_STATUS_MICRO 0x02000000 //Micro Status? +#define LEO_BM_STATUS_BLOCK 0x01000000 //Block Transfer +#define LEO_BM_STATUS_C1CORRECTION 0x00800000 //C1 Correction +#define LEO_BM_STATUS_C1DOUBLE 0x00400000 //C1 Double +#define LEO_BM_STATUS_C1SINGLE 0x00200000 //C1 Single +#define LEO_BM_STATUS_C1ERROR 0x00010000 //C1 Error + +#define LEO_BM_CTL_START 0x80000000 //Start Buffer Manager +#define LEO_BM_CTL_MODE 0x40000000 //Buffer Manager Mode +#define LEO_BM_CTL_IMASK 0x20000000 //BM Interrupt Mask +#define LEO_BM_CTL_RESET 0x10000000 //Buffer Manager Reset +#define LEO_BM_CTL_DISABLE_OR 0x08000000 //Disable OR Check? +#define LEO_BM_CTL_DISABLE_C1 0x04000000 //Disable C1 Correction +#define LEO_BM_CTL_BLOCK 0x02000000 //Block Transfer +#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 //Mechanic Interrupt Reset + +#define LEO_BM_CTL_CONTROL_MASK 0xFF000000 +#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000 +#define LEO_BM_CTL_SECTOR_SHIFT 16 + +#define LEO_CMD_TYPE_0 0 //TODO: name +#define LEO_CMD_TYPE_1 1 //TODO: name +#define LEO_CMD_TYPE_2 2 //TODO: name + +#define LEO_ERROR_GOOD 0 +#define LEO_ERROR_4 4 //maybe busy? +#define LEO_ERROR_22 22 // +#define LEO_ERROR_23 23 //unrecovered read error? +#define LEO_ERROR_24 24 //no reference position found? +#define LEO_ERROR_29 29 // + +extern OSDevMgr __osPiDevMgr; +extern OSPiHandle *__osCurrentHandle[2]; +extern OSPiHandle CartRomHandle; +extern OSPiHandle LeoDiskHandle; +extern OSMesgQueue __osPiAccessQueue; +extern u32 __osPiAccessQueueEnabled; + +int __osPiDeviceBusy(void); +void __osDevMgrMain(void *); +void __osPiCreateAccessQueue(void); +void __osPiRelAccess(void); +void __osPiGetAccess(void); +OSMesgQueue *osPiGetCmdQueue(void); + +#define OS_RAMROM_STACKSIZE 1024 + +#define WAIT_ON_IOBUSY(stat) \ + stat = IO_READ(PI_STATUS_REG); \ + while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ + stat = IO_READ(PI_STATUS_REG); + +#define UPDATE_REG(reg, var) \ + if (cHandle->var != pihandle->var) \ + IO_WRITE(reg, pihandle->var); + +#define EPI_SYNC(pihandle, stat, domain) \ + \ + WAIT_ON_IOBUSY(stat) \ + \ + domain = pihandle->domain; \ + if (__osCurrentHandle[domain] != pihandle) \ + { \ + OSPiHandle *cHandle = __osCurrentHandle[domain]; \ + if (domain == PI_DOMAIN1) \ + { \ + UPDATE_REG(PI_BSD_DOM1_LAT_REG, latency); \ + UPDATE_REG(PI_BSD_DOM1_PGS_REG, pageSize); \ + UPDATE_REG(PI_BSD_DOM1_RLS_REG, relDuration); \ + UPDATE_REG(PI_BSD_DOM1_PWD_REG, pulse); \ + } \ + else \ + { \ + UPDATE_REG(PI_BSD_DOM2_LAT_REG, latency); \ + UPDATE_REG(PI_BSD_DOM2_PGS_REG, pageSize); \ + UPDATE_REG(PI_BSD_DOM2_RLS_REG, relDuration); \ + UPDATE_REG(PI_BSD_DOM2_PWD_REG, pulse); \ + } \ + __osCurrentHandle[domain] = pihandle; \ + } + +#endif diff --git a/include/siint.h b/include/siint.h new file mode 100755 index 00000000..45bf56bf --- /dev/null +++ b/include/siint.h @@ -0,0 +1,10 @@ +#ifndef _SIINT_H +#define _SIINT_H +#include +#include + +void __osSiGetAccess(void); +void __osSiRelAccess(void); +int __osSiDeviceBusy(void); +void __osSiCreateAccessQueue(void); +#endif diff --git a/include/structs.h b/include/structs.h new file mode 100644 index 00000000..a6275ea6 --- /dev/null +++ b/include/structs.h @@ -0,0 +1,1400 @@ +#ifndef __STRUCTS_H__ +#define __STRUCTS_H__ + +/* your struct definitions go here */ + +typedef struct character_progress { + u8 moves; // at 0x00 + u8 simian_slam; // at 0x01 + u8 weapon; // at 0x02, bitfield, xxxxxshw + u8 ammo_belt; // at 0x03, see ScriptHawk's Game.getMaxStandardAmmo() for formula + u8 instrument; // at 0x04, bitfield, xxxx321i + u8 unk5; + u16 coins; // at 0x06 + u16 instrument_ammo; // at 0x08, also used as lives in multiplayer + u16 coloured_bananas[14]; // TODO: Better datatype? + u16 coloured_bananas_fed_to_tns[14]; // TODO: Better datatype? + u16 golden_bananas[14]; // TODO: Better datatype? +} CharacterProgress; + +typedef struct PlayerProgress { + union { + CharacterProgress character_progress[6]; // 0x5E * 6 (5 Kongs + Krusha) + u8 character_progress_as_bytes[6][0x5E]; // Note: Can't use sizeof(CharacterProgress) because mips_to_c can't do struct maths yet + u16 character_progress_as_shorts[6][0x2F]; // Note: Can't use sizeof(CharacterProgress) because mips_to_c can't do struct maths yet + }; + u8 unk234[0x2F0 - 0x234]; + u16 standardAmmo; // 0x2F0 + u16 homingAmmo; // 0x2F2 + u16 oranges; // 0x2F4 + u16 crystals; // 0x2F6 // Note: Multiplied by 150 compared to on screen counter + u16 film; // 0x2F8 + u8 unk2FA; + s8 health; // 0x2FB + u8 melons; // 0x2FC + s8 unk2FD; // Something to do with health... hmm + s8 unk2FE[0x306 - 0x2FE]; +} PlayerProgress; + +typedef struct enemy_info { + u8 enemy_type; // at 0x00 + u8 unk1; + u16 y_rotation; // at 0x02 + s16 x_position; // at 0x04 + s16 y_position; // at 0x06 + s16 z_position; // at 0x08 + u8 cutscene_model_index; // at 0x0A + u8 unkB; + u32 unkC; + u32 unk10; + u32 unk14; + u32 unk18; + u32 unk1C; + u32 unk20; + u16 unk24; + u16 unk26; + u16 unk28; // Used + s16 unk2A; // Used + u32 unk2C; + u32 unk30; + u32 unk34; + f32 unk38; // Used + f32 unk3C; // at 0x3C + s16 unk40; // Used + s16 unk42; + u8 unk44; // Used + u8 unk45; + u16 unk46; // Used +} EnemyInfo; + +typedef struct ledge_info_8c LedgeInfo8C; + +struct ledge_info_8c { + s32 unk0; + s32 unk4; + s32 unk8; + f32 unkC; // Used + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + LedgeInfo8C *next; +}; + +typedef struct ledge_info_90 LedgeInfo90; + +struct ledge_info_90 { + f32 unk0; + f32 unk4; + f32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + LedgeInfo90 *next; +}; + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s32 unk48; + s32 unk4C; + s32 unk50; + s16 unk54; + s8 unk56; + s8 unk57; +} LedgeInfo98; + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s16 unk28; + s8 unk2A; // Used + s8 unk2B; +} LedgeInfoA0; + +typedef struct ledge_info { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + f32 unk14; + f32 unk18; + f32 unk1C; + f32 unk20; + u8 unk24; + u8 unk25; + u8 unk26; + u8 unk27; + u32 unk28; + u32 unk2C; + u32 unk30; + u32 unk34; + u32 unk38; + u32 unk3C; + u32 unk40; + u32 unk44; + u16 unk48; + u16 unk4A; + u32 unk4C; + u32 unk50; + u32 unk54; + u32 unk58; + u32 unk5C; + u32 unk60; + u32 unk64; + u32 unk68; + u8 unk6C; + u8 unk6D; + u8 unk6E; + u8 unk6F; + u32 unk70; + u32 unk74; + u32 unk78; + s32 unk7C; + s32 unk80; // object_timer gets written here + s32 unk84; + s32 unk88; // object_timer gets written here + LedgeInfo8C *unk8C; // Linked List + LedgeInfo90 *unk90; + s32 unk94; + LedgeInfo98 *unk98; // Array + s32 unk9C; + LedgeInfoA0 *unkA0; // Array + s32 unkA4; + s32 unkA8; + u8 unkAC; +} LedgeInfo; + +// TODO: What is this actually? +typedef struct animation_state_unk0 { + s32 unk0; + f32 unk4; // Used + s32 unk8; + s32 unkC; + s16 unk10; // Used + s16 unk12; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + f32 unk24; // Used +} AnimationStateUnk0; + +// See boss func_8002FB7C +typedef struct animation_state_unk20 { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + f32 unk4; + f32 unk8; + f32 unkC; +} AnimationStateUnk20; + +typedef struct actor_animation_state { + AnimationStateUnk0 *unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s16 unk10; + s16 unk12; + void *bone_array_1; // at 0x14, camera, update bone positions // TODO: Proper type + void *bone_array_2; // at 0x18, camera, update bone positions // TODO: Proper type + void *unk1C; // TODO: Used in func_80724CA4 and func_8068FF40, pretty easy match, array of 0x8 structs? // malloc(0x100) in func_80683158 + AnimationStateUnk20 *unk20; // See boss func_8002FB7C + void *unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + f32 scale_x; // at 0x34 + f32 scale_y; // at 0x38 + f32 scale_z; // at 0x3C + s32 unk40; + s32 unk44; + f32 unk48; + s32 unk4C; + s32 unk50; + s32 unk54; + s32 unk58; + s32 unk5C; + s32 unk60; + u16 unk64; // Used + u16 unk66; + s32 unk68; + s32 unk6C; + s32 unk70; + s32 unk74; + s32 unk78; + s32 unk7C; + s32 unk80; + s32 unk84; + s32 unk88; + s32 unk8C; + s32 unk90; + f32 animation_timer_1; // at 0x94 + f32 animation_timer_2; // at 0x98 + s32 unk9C; + s32 unk100; + f32 animation_timer_3; // at 0x104 + f32 animation_timer_4; // at 0x108 +} ActorAnimationState; + +typedef struct actor_178 { + s16 unk0; // Used + s16 unk2; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; + u8 unk8; + u8 unk9; + u8 unkA; + u8 unkB; + u8 unkC; + u8 unkD; + u8 unkE; + u8 unkF[0x5]; + u8 unk14; +} Actor178; + +typedef struct boss_actor_178 { + s32 unk0; // Used +} BossActor178; + +typedef struct race_actor_178 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + f32 unk14; +} RaceActor178; + +typedef struct actor_17C { + s32 unk0; + u8 unk4; + u8 unk5; + s16 unk6; + s16 unk8; +} Actor17C; + +typedef struct actor_collision ActorCollision; +typedef struct actor Actor; + +// TODO: What type is this actually? +// D_807FBB70 +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + f32 unk4; + f32 unk8; + f32 unkC; + u8 pad10[0x14 - 0x10]; + u8 unk14; + u8 unk15; + u8 unk16; + u8 unk17; + u8 unk18; + u8 unk19; + u8 unk1A; + u8 unk1B; + u8 unk1C; + u8 pad1D[0x24 - 0x1D]; + u8 unk24; + u8 unk25; + u8 pad26[0x2C - 0x26]; + u8 unk2C; + u8 pad2D[0x38 - 0x2D]; + u8 unk38; + u8 unk39; + u8 pad3A[0x90 - 0x3A]; // TODO: Actor* at 0x7C? see func_8069A750 + u8 unk90; + u8 unk91; + u8 pad92[0xD8 - 0x92]; + f32 unkD8; + f32 unkDC; // TODO: Confirm datatype + f32 unkE0; + u8 unkE4; + u8 unkE5; + u8 unkE6; + u8 unkE7; + f32 unkE8; + s32 unkEC; + f32 unkF0; + f32 unkF4; + u8 padF8[0x1F8 - 0xF8]; + s32 unk1F8; + Actor *unk1FC; + u8 unk200; + u8 unk201; + s16 unk202; + Actor *unk204; + u8 pad208[0x244 - 0x208]; + s8 unk244; + s8 unk245; + s8 unk246; + s8 unk247; + u8 pad248[0x254 - 0x248]; + u8 unk254; // Used + u8 unk255; + u8 unk256; + u8 unk257; + s32 unk258; // Used + s32 unk25C; + s32 unk260; + s32 unk264; + s32 unk268; + s32 unk26C; + s32 unk270; + s32 unk274; + s32 unk278; +} GlobalASMStruct35; + +struct actor_collision { + u32 unk0; // Collision type? + u32 unk4; + Actor *collisionSource; + u32 unkC; + u32 unk10; + ActorCollision* next; + ActorCollision* prev; +}; + +typedef struct other_additional_actor_data { + s32 unk0; + s32 unk4; + s16 unk8; + s16 unkA; + f32 unkC; + f32 unk10; + f32 unk14; + s16 unk18; + s16 unk1A; + s32 unk1C; +} OtherAdditionalActorData; + +typedef struct another_additional_actor_data { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s16 unk10; + u8 unk12; + u8 unk13; // Used in func_806925AC +} AnotherAdditionalActorData; + +typedef struct race_additional_actor_data { + s16 unk0; + s16 unk2; // used + f32 unk4; + s16 unk8; + s16 unkA; + f32 unkC; + f32 unk10; + f32 unk14; + s16 unk18; + s16 unk1A; + u16 unk1C; + s8 unk1E; + s8 unk1F; + s32 unk20; + u8 unk24; + u8 unk25; + s8 unk26; + s8 unk27; + s8 unk28; + s8 unk29; // Used + s16 unk2A; + s32 unk2C; + s32 unk30; + u8 unk34; + u8 unk35; + u8 unk36; + u8 unk37; + s32 unk38; + u8 unk3C; + u8 unk3D; + u8 unk3E; + u8 unk3F; + s16 unk40; + u8 unk42; // Used + u8 unk43; + u8 unk44; + u8 unk45; // Used +} RaceAdditionalActorData; + +typedef struct race_additional_actor_data2 { + u8 unk0; // Used + u8 unk1; + u8 unk2; + u8 unk3; + u8 pad2[0x24 - 0x4]; + u8 unk24; + u8 pad25[0x36 - 0x25]; + u8 unk36; // Used +} RaceAdditionalActorData2; + +typedef struct yaad5 { + f32 unk0; // Used + f32 unk4; // Used + u32 unk8; + u32 unkC; + Actor* unk10; // Used + s16 unk14; // Used + s16 unk16; // Used + u16 unk18; + s16 unk1A; // Used + s16 unk1C; // Used + s8 unk1E; // Used +} YetAnotherAdditionalActorData5; + + +typedef struct yet_another_additional_actor_data { + Actor *unk0; + u16 unk4; + u16 unk6; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s16 unk20; + s16 unk22; + f32 unk24; + s16 unk28; + s16 unk2A; + s32 unk2C; + s32 unk30; + s32 unk34; + s16 unk38; + s16 unk3A; + s32 unk3C; +} YetAnotherAdditionalActorData; + +typedef struct yaad4 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s16 unk10; // Used + s16 unk12; // Used + s16 unk14; // Used +} YetAnotherAdditionalActorData4; + +typedef struct menu_additional_actor_data { + //u8 pad0[0x17]; + f32 unk0; + f32 unk4; + f32 unk8; + s32 unkC; + s16 unk10; + s8 unk12; + s8 unk13; + s16 unk14; + s8 unk16; + s8 unk17; +} MenuAdditionalActorData; + +typedef struct player_additional_actor_data { + s32 unk0; // TODO: May be s16 (see func_806CF580), but changing that causes some matching functions to break + f32 unk4; + s16 unk8; // Used + s16 unkA; // Used, Actor->y_rotation copied here + s16 unkC; // Used + s16 unkE; // Used + s16 unk10; // Used + s16 unk12; // Used + s16 unk14; // Used + s8 unk16; + s8 unk17; // Used, set to current file selection? + u16 unk18; // Used + u16 unk1A; + f32 unk1C; // Used + f32 unk20; // Used + s16 unk24; // Used + s16 unk26; + s16 unk28; // Used + s16 unk2A; + f32 unk2C; // Used + f32 unk30; // Used + f32 unk34; // Used + f32 unk38; // Used + s16 unk3C; + s16 unk3E; // Used + s16 unk40; + u8 unk42; // Used, related to distance from floor + u8 unk43; + u8 unk44; + u8 unk45; // Used, VehicleAdditionalActorData + u8 unk46; + u8 unk47; + s16 unk48; // Used + s16 unk4A; + s16 unk4C; // Used + s16 unk4E; + s16 unk50; // Used + s16 unk52; + f32 unk54; + s32 unk58; // Used, related to D_80767CC0 + s32 unk5C; + s32 unk60; + s16 unk64; // Used + s16 unk66; + f32 unk68; + f32 unk6C; // Used + s16 unk70; // Used, y rotation? + s16 unk72; + s32 unk74; + s32 unk78; + s32 unk7C; + s32 unk80; + s32 unk84; + Actor* vehicle_actor_pointer; // Used + u8 unk8C; // Used + u8 unk8D; // Used + s16 unk8E; + s32 unk90; + f32 unk94; // Used + f32 unk98; + f32 unk9C; // Used + f32 unkA0; // Used + f32 unkA4; // Used + f32 unkA8; // Used + s32 unkAC; // Used // TODO: Float? Datatype conflicts in CEAEO.c + s16 unkB0; + s16 unkB2; // Used + s32 unkB4; + f32 unkB8; // Used + s16 unkBC; // Used + s16 unkBE; + s16 unkC0; + s16 unkC2; // Used + s32 unkC4; + s16 unkC8; + u8 unkCA; // Used + s8 unkCB; + s32 unkCC; + s32 unkD0; + s16 unkD4; // Used + s16 unkD6; + s32 unkD8; + Actor *unkDC; // Used + s32 unkE0; + s32 unkE4; + s32 unkE8; + u8 unkEC; + u8 unkED; + u8 unkEE; + u8 unkEF; // Used + u8 unkF0; // TODO: Might be float, see func_806ECAC4 + u8 unkF1; // Used + u8 unkF2; + u8 unkF3; // Used + u8 unkF4; + u8 unkF5; + u8 unkF6; // Used + u8 unkF7; + s32 unkF8; + u8 unkFC; // Used + u8 unkFD; + u8 unkFE; + u8 unkFF; + s32 unk100; + Actor *unk104; // Used, Actor*? + f32 unk108; // Used + s8 unk10C; // Used + u8 unk10D; + u8 unk10E; + u8 unk10F; + s32 unk110; + s32 unk114; + s32 unk118; + u8 unk11C; // Used, VehicleAdditionalActorData? + u8 unk11D; + u8 unk11E; + u8 unk11F; + s32 unk120; + f32 unk124; // Used + s32 unk128; + s32 unk12C; + s32 unk130; + s32 unk134; + s32 unk138; + s32 unk13C; + s32 unk140; + s32 unk144; + s32 unk148; + s32 unk14C; + s32 unk150; + s32 unk154; + s32 unk158; + s32 unk15C; + s32 unk160; + s32 unk164; + s32 unk168; + s32 unk16C; + s32 unk170; + s32 unk174; + s32 unk178; + s32 unk17C; + s32 unk180; + s32 unk184; + s32 unk188; + s32 unk18C; + s32 unk190; + s32 unk194; + s32 unk198; + s16 unk19C; // Used + s16 unk19E; // Used + u16 unk1A0; // Used + u8 unk1A2; + u8 unk1A3; // Used + u8 unk1A4; // Used, playerIndex? + u8 unk1A5; + u8 unk1A6; + u8 unk1A7; + Actor *unk1A8; + Actor *unk1AC; // TODO: Is this correct? + s32 unk1B0; + s32 unk1B4; + s32 unk1B8; + f32 unk1BC; // Used + f32 unk1C0; // Used + f32 unk1C4; // Used + f32 unk1C8; // Used + f32 unk1CC; // Used + f32 unk1D0; // Used, y scale + f32 unk1D4; // Used, z scale + f32 unk1D8; // Used + f32 unk1DC; // Used + f32 unk1E0; // Used + s32 unk1E4; + s32 unk1E8; + s16 unk1EC; + s16 unk1EE; // Used + s32 unk1F0; // Used, bitfield // TODO: Proper bitfield syntax + s32 unk1F4; + s32 unk1F8; + u8 unk1FC; // Used + u8 unk1FD; + u16 unk1FE; // Used + s16 unk200; // Used + s16 unk202; + s32 unk204; + s32 unk208; + s32 unk20C; + s32 unk210; + s32 unk214; + s32 unk218; + s16 unk21C; + u16 unk21E; // Used + f32 unk220; // Used, x + f32 unk224; // Used, y + f32 unk228; // Used, z + f32 unk22C; // Used, x + f32 unk230; // Used, y + f32 unk234; // Used, z + f32 unk238; // Used + u16 unk23C; // Used + u8 unk23E; + u8 unk23F; // Used + s16 unk240; + u16 unk242; // Used + s16 unk244; + s8 unk246; // Used func_806CA26C + s8 unk247; // Used func_806CA26C + s8 unk248; + s8 unk249; + s8 unk24A; + s8 unk24B; // Used + u16 unk24C; // Used // TODO: s16? func_806CA1B4 uses this as u16 + u16 unk24E; // Used // TODO: s16? func_806CA1B4 uses this as u16 + s32 unk250; +} PlayerAdditionalActorData; + +//f32 at unk8 doesn't match with what's in structs.h (s16) +//for PlayerAdditionalActorData so making this struct +typedef struct { + u8 pad0[0x8]; + f32 unk8; +} PaaD0; + +// Bonus func_800253E4 +typedef struct { + Actor* unk0; +} BaaD2; + +typedef struct TempAAD { + s8 unk0; + u8 pad0[0x14 - 0x1]; + s16 unk14; + s16 unk16; + s16 unk18; + s16 unk1A; + u8 pad1[0x24 - 0x1C]; + s8 unk24; +} TempAAD; + +// TODO: This appears to be a "texture renderer" according to ScriptHawk, needs a better name though. Linked list at Actor->unk158 +typedef struct global_asm_struct_60 GlobalASMStruct60; + +struct global_asm_struct_60 { + s32 *unk0; // Used + GlobalASMStruct60 *unk4; // Used? Might be wrong datatype, see func_80688638 + s16 unk8; + s16 unkA; // Used + s16 unkC; // Used - Texture index? + s16 unkE; + f32 unk10; // Used + f32 unk14; // Used + s16 unk18; // Used + s16 unk1A; // Used + s16 unk1C; // Used + s16 unk1E; // Used + s8 unk20; // Used + s8 unk21; // Used + u8 unk22; // Used + u8 unk23; + GlobalASMStruct60 *next; // at 0x24 +}; + +struct actor { + u32 *unk0; // Small header on top of DisplayList Pointer // TODO: Proper type + ActorAnimationState *animation_state; + u32 *unk8; // Current bone array Pointer // TODO: Proper type + s16 unkC; + s16 unkE; + u32 unk10; + u32 unk14; + u32 unk18; + u32 unk1C; + u32 unk20; + u32 unk24; + u32 unk28; + f32 unk2C; + u32 unk30; + u32 unk34; + u32 unk38; + u32 unk3C; + u32 unk40; + u32 unk44; + u32 unk48; + u32 unk4C; + u32 unk50; + u32 unk54; + u32 unk58; + u16 interactable; // Bitfield at 0x5C + u16 unk5E; + u32 object_properties_bitfield; // at 0x60 + s32 unk64; // Another bitfield + u16 unk68; + u16 unk6A; // is_grounded? + u16 unk6C; + s16 unk6E; + u16 unk70; + u16 unk72; + u32 unk74; + u8 unk78; + u8 unk79; + u8 unk7A; + u8 unk7B; + f32 x_position; // at 0x7C + f32 y_position; // at 0x80 + f32 z_position; // at 0x84 + f32 unk88; + f32 unk8C; + f32 unk90; + f32 unk94; + f32 unk98; + f32 unk9C; + f32 unkA0; + f32 floor; // at 0xA4 + f32 unkA8; // Used + f32 unkAC; + u32 unkB0; + f32 distance_from_floor; // at 0xB4 + f32 unkB8; // at 0xB8 // velocity? + f32 unkBC; // at 0xBC + f32 y_velocity; // at 0xC0 + f32 y_acceleration; // at 0xC4 + f32 terminal_velocity; // at 0xC8 + u8 unkCC; // Used + u8 unkCD; + u8 unkCE; + u8 unkCF; + u8 unkD0; + u8 unkD1; // Used + u8 unkD2; + u8 unkD3; + u32 unkD4; + s16 unkD8; // Used + s16 unkDA; // Used + s16 unkDC; // Used + s16 unkDE; + f32 unkE0; + s16 x_rotation; // at 0xE4 + s16 y_rotation; // at 0xE6 + s16 z_rotation; // at 0xE8 + s16 unkEA; + s16 unkEC; // Something to do with shadow opacity + s16 unkEE; // TODO: Interacts with rotation, maybe a copy of it? + u16 unkF0; + s16 unkF2; + s16 unkF4; + s16 unkF6; + s16 unkF8; + u16 unkFA; + u8 unkFC; + u8 unkFD; + u8 unkFE; + u8 unkFF; + f32 unk100; // Used + f32 unk104; // Used + f32 unk108; // Used + s16 unk10C; + u8 unk10E; // Used + u8 unk10F; + u8 locked_to_pad; // at 0x110 + u8 unk111; + u8 unk112; + u8 unk113; + u32 unk114; + u32 unk118; + Actor *unk11C; + f32 unk120; + u32 unk124; + s16 shadow_opacity; // at 0x128, max value 0xFF + s16 draw_distance; // at 0x12A + s16 unk12C; // Used + s16 unk12E; + u8 unk130; // Used + u8 unk131; // Used + s16 unk132; // Used + s16 health; + s16 unk136; + u32 unk138; + ActorCollision *collision_queue_pointer; // at 0x13C + LedgeInfo *ledge_info_pointer; // at 0x140 + u8 noclip_byte; // at 0x144 + u8 unk145; + u16 unk146; // used (0x147 hand state? 0x146 seems to be u16) + u32 unk148; // Used + u32 unk14C; // Used + void *unk150; // TODO: Floor Triangle Pointer + u8 control_state; // at 0x154 + u8 control_state_progress; // at 0x155 + u8 unk156; + u8 unk157; + GlobalASMStruct60 *unk158; // Texture renderer linked list + u8 unk15C; + u8 unk15D; + u8 unk15E; + u8 unk15F; // Used, set to 0x01, 0x06, 0x0B in some cases + f64 unk160; // TODO: Probably not correct + s16 unk168; // Used + u8 unk16A; + u8 unk16B; + u8 unk16C; + u8 unk16D; + u8 unk16E; + u8 unk16F; + u8 unk170; + u8 unk171; + u8 unk172; + u8 unk173; + union { + void *additional_actor_data; // For when you don't know which one it's using + OtherAdditionalActorData *OaaD; + AnotherAdditionalActorData *AaaD; + RaceAdditionalActorData *RaaD; + RaceAdditionalActorData2 *RaaD2; + YetAnotherAdditionalActorData *YaaD; + YetAnotherAdditionalActorData4 *YaaD4; + YetAnotherAdditionalActorData5 *YaaD5; + MenuAdditionalActorData *MaaD; + PlayerAdditionalActorData *PaaD; + PaaD0 *PaaD0; // TODO: Figure this out + BaaD2 *BaaD2; // TODO: Figure this out + TempAAD *TaaD; // TODO: Figure this out (race overlay) + void *additional_data_pointer; //legacy + }; + union { + Actor178 *unk178; + RaceActor178 *race178; + BossActor178 *boss178; + }; + union { + Actor17C *unk17C; + }; +}; + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; // Used +} CharacterChange294; + +typedef struct { + u8 does_player_exist; // bitfield? 0x00 + u8 unk1; + u8 unk2; + u8 unk3; + Actor* player_pointer; // 0x04 + u8 pad_unknown[0x208]; + f32 look_at_eye_x; // 0x210 maybe an array? + f32 look_at_eye_y; // 0x214 + f32 look_at_eye_z; // 0x218 + f32 unk21C; // Used + f32 unk220; // Used + f32 unk224; // Used + f32 look_at_at_x; // 0x228 maybe an array? + f32 look_at_at_y; // 0x22C + f32 look_at_at_z; // 0x230 + f32 unk234; // Used + f32 unk238; // Used + f32 unk23C; // Used + f32 look_at_up_x; // 0x240 maybe an array? + f32 look_at_up_y; // 0x244 + f32 look_at_up_z; // 0x248; + s32 unk24C; + u8 pad_unknown2[0x270 - 0x250]; + s16 unk270; // Used, related to map chunk "deload" value + s16 unk272; // Used, related to map chunk "deload" value + s16 unk274; // Used, related to map chunk "deload" value + s16 unk276; // Used, related to map chunk "deload" value + s16 unk278; + s16 unk27A; + f32 fov_y; // 0x27C + f32 unk280; + f32 near; // 0x284 + f32 far; // 0x288 + s32 unk28C; + u16 chunk; // 0x290 + s16 unk292; + CharacterChange294 *unk294; // Used + s32 new_controller_inputs; // bitfield 0x298 + s16 action_initiated; // 0x29C + s16 unk29E; + Actor* unk2A0; + s32 unk2A4; + s32 unk2A8; // Used + s32 unk2AC; + s32 unk2B0; // Used + u8 pad_unknown3[0x2C0 - 0x2B4]; + u8 unk2C0; // Used + u8 unk2C1; // Used + u8 unk2C2; // Used + u8 unk2C3; // Used + s32 unk2C4; + s16 unk2C8; // Used + s16 unk2CA; + u8 pad_unknown4[0x2E2 - 0x2CC]; + u16 unk2E2; + u8 unk2E4; + u8 unk2E5; + u8 unk2E6; + u8 unk2E7; + u8 unk2E8; + u8 unk2E9; + u8 unk2EA; + u8 unk2EB; + u8 unk2EC; + u8 unk2ED; + u8 unk2EE; + u8 unk2EF; +} CharacterChange; + +typedef struct chunk_14 Chunk14; + +struct chunk_14 { + s32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + f32 unk10; + Chunk14 *next; + Chunk14 *next2; + s16 unk1C; + s16 unk1E; + s16 unk20; + u8 unk22; // Used + u8 unk23; // Used + u8 unk24; // Used +}; + +typedef struct { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s32 unk8; + s16 unkC; + s16 unkE; + s16 unk10; + u8 unk12; + u8 unk13; +} Chunk78_7C; + +typedef struct { + u8 loaded; + u8 unk1; // used + u8 unk2; + u8 unk3; + u8 unk4; + u8 visible; // 0x5 -- if 0x02 visible, else invisible + u8 unk6; + u8 unk7; + s32 unk8; + s32 unkC; + s32 unk10; + Chunk14 *unk14; + s32 unk18; + Chunk14 *unk1C; // TODO: Same struct as unk14? + s32 unk20; + s32 unk24; + u8 pad8[0x68 - 0x28]; + s32 deload1; // 0x68 + s32 deload2; // 0x6C + s32 deload3; // 0x70 + s32 deload4; // 0x74 + Chunk78_7C *unk78; // First in array? + Chunk78_7C *unk7C; // Last in array? + s16 unk80; // Used + s16 unk82; // Used + s16 unk84; // Used + s16 unk86; // Used + u8 pad2[0x1C8 - 0x88]; // total size 0x1C8 +} Chunk; + +// func_80712944, func_8060AC34 +typedef struct global_asm_struct_12 { + u16 unk0; + s8 unk2; + s8 unk3; + s16 unk4; + u16 unk6; + s8 unk8; + s8 unk9; + u16 unkA; + u16 unkC; + s8 unkE; + s8 unkF; + u16 unk10; + u16 unk12; + s8 unk14; + s8 unk15; +} GlobalASMStruct12; + +typedef struct { + u8 pad0[0x6 - 0x0]; + s16 unk6; + u8 unk8; + u8 unk9; + u8 unkA; // Used // TODO: Type conflict with u16? s16? + u8 unkB; + u8 unkC; // Used + u8 unkD; + u8 unkE; + u8 unkF; + u8 unk10; // Used + u8 unk11; + u8 unk12; + u8 unk13; // Used +} CharacterSpawner; + +typedef struct global_asm_struct_17 { + u16 unk0; + s8 unk2; + s8 unk3; +} GlobalASMStruct17; + +typedef struct JetpacStruct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + u8 unk10; + u8 unk11; + u8 unk12; + u8 unk13; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + u8 pad1[0x44 - 0x3C]; + s32 unk44; + void (*unk48)(); + s32 *unk4C; +} JetpacStruct; + +typedef struct JetpacItem { + u8 unk0; +} JetpacItem; + +typedef struct Competitor { + s32 level; + s32 current_score; + s32 lives; + s32 lives_consumed; + s32 unk10; //used + u8 pad0[0x114 - 0x14]; + s32 unk114; //used + u8 pad2[0x144 - 0x118]; + s32 unk_144; + JetpacItem next_item_pointer; + u8 unk14C[4]; + float unk150; + u8 pad1[0x18C - 0x154]; + void (*fun_ptr)(JetpacItem*); + void (*fun_ptr2)(JetpacItem*,u8); + //u8 unk_190[4]; +} Competitor; + +typedef struct JetpacPlayerStruct { + s32 unk0; + u8 header[0x1C - 0x4]; + Competitor player[2]; + s32 player_index; +} JetpacPlayerStruct; + +typedef struct ActorSpawner ActorSpawner; + +struct ActorSpawner { + u16 actor_type; // At 0x0 + u16 unk2; + f32 x_position; // At 0x4 + f32 y_position; // At 0x8 + f32 z_position; // At 0xC + f32 unk10; + f32 unk14; + f32 unk18; + s16 y_rotation; // At 0x1C + u16 unk1E; + u16 unk20; + u8 pad22[0x32 - 0x22]; + s16 unk32; + u8 pad34[0x44 - 0x34]; + Actor* tied_actor; // At 0x44 + u8 unk48; // Used + u8 unk49; + s16 unk4A; + u8 unk4C; // Used + u8 unk4D; + s32 unk50; // TODO: Actor*? + f32 unk54; + s16 unk58; + s16 id; // At 0x5A + s32 (*unk5C)(s32); // At 0x5C + s32 (*drawing_code)(s32); // At 0x60 + ActorSpawner* previous_spawner; // At 0x64 + ActorSpawner* next_spawner; // At 0x68 + u8 pad6C[0x80 - 0x6C]; +}; + +// TODO: Use that clever tuple thing from BKomp +typedef struct { + s16 coords_0[3]; // 0x0 + s16 coords_1[3]; // 0x6 + s16 coords_2[3]; // 0xC + s16 coords_3[3]; // 0x12 + s16 coords_4[3]; // 0x18 +} EnemyAggressionBox; + +typedef struct { + s16 x_pos_0; // 0x0 + s16 z_pos_0; // 0x2 + s16 x_pos_1; // 0x4 + s16 z_pos_1; // 0x6 + EnemyAggressionBox *aggression_box_pointer; // = 0xC, -- u32 +} EnemyMovementBox; + +typedef struct { + u8 enemy_value; // 0x0 + u8 unk1; + u16 y_rot; // 0x2 + s16 x_pos; // 0x4 + s16 y_pos; // 0x6 + s16 z_pos; // 0x8 + u8 cs_model; // 0xA + u8 unkB; + u8 max_idle_speed; // 0xC + u8 max_aggro_speed; // 0xD + u8 unkE; + u8 scale; // 0xF + u8 aggro; // 0x10 + u8 unk11; + u8 something_spawn_state; // 0x12 + u8 spawn_trigger; // 0x13 + u8 respawn_timer_init; // 0x14 - Result is multiplied by 30 to get actual respawn timer + u8 unk15; + u8 unk16; + u8 unk17; + Actor *tied_actor; // 0x18 + EnemyMovementBox *movement_box_pointer; // 0x1C + void *unk20; // 0x20 + s16 respawn_time; // 0x24 + s16 unk26; + s32 unk28; + f32 unk2C; // 0x2C initially written to 0.01 + f32 unk30; // 0x30 initially written to 1 + f32 animation_speed; // 0x34 + u32 unk38; // 0x38 TODO: maybe float, based on alt enemy type + u32 unk3C; + s16 chunk; // 0x40 + u8 spawn_state; // 0x42 + u8 counter; // 0x43 + u8 alternative_enemy_spawn; // 0x44 + + // 1000 0000 0000 0000 - ? + // 0100 0000 0000 0000 - ? Resets on Respawn + // 0010 0000 0000 0000 - ? Resets on Respawn + // 0001 0000 0000 0000 - ? + + // 0000 1000 0000 0000 - ? + // 0000 0100 0000 0000 - ? + // 0000 0010 0000 0000 - ? + // 0000 0001 0000 0000 - ? + + // 0000 0000 1000 0000 - ? + // 0000 0000 0100 0000 - Ignores instrument plays + // 0000 0000 0010 0000 - Ignores movement boundaries + // 0000 0000 0001 0000 - ? + + // 0000 0000 0000 1000 - ? Reset on respawn + // 0000 0000 0000 0100 - ? + // 0000 0000 0000 0010 - Won't Respawn + // 0000 0000 0000 0001 - Spawned from respawn pending + + // TODO: proper bitfield syntax + u16 properties_bitfield; // = 0x46 bitfield -- TODO: Document this, find where this comes from so we can display stuff pre-load +} EnemySpawner; // 807FDC8C pointer to array of structs, count at 807FDC88 + +typedef struct Struct807FDC90 Struct807FDC90; + +// Use this for D_807FDC90 +struct Struct807FDC90 { + Struct807FDC90 *unk0; // TODO: This type may not be correct + Actor *unk4; + s16 unk8; + s16 unkA; + s16 unkC; // Used + s16 unkE; + s32 unk10; + s32 unk14; + u16 unk18; + u16 unk1A; + u8 unk1C; + u8 unk1D; + u8 unk1E; + u8 unk1F; + u8 unk20; + u8 unk21; + u8 unk22; + u8 unk23; + u8 unk24; + u8 unk25; + u8 unk26; + u8 unk27; + s32 unk28; + s16 unk2C; + s16 unk2E; // TODO: This might not be correct + f32 unk30; // Used + u8 unk34; + u8 unk35; // Used + u8 unk36; + u8 unk37; + u8 unk38; +}; + +typedef struct ExitData { + s16 x_pos; // At 0x00 + s16 y_pos; // At 0x02 + s16 z_pos; // At 0x04 + u8 angle; // At 0x06 + u8 unk7; // At 0x07 + u8 has_autowalk; // At 0x08 + u8 size; // At 0x0A +} ExitData; + +// From Practice ROM +typedef struct spriteDisplay { + /* 0x000 */ s32 disappear; + /* 0x004 */ s8 unk_04[0x11]; + /* 0x015 */ s8 unk_15; +} spriteDisplay; + +typedef struct spriteControl { + /* 0x000 */ f32 movement_style; + /* 0x004 */ f32 pointer_offset_0x15; + /* 0x008 */ f32 xPos; + /* 0x00C */ f32 yPos; + /* 0x010 */ f32 scale; + /* 0x014 */ f32 unk_14; + /* 0x018 */ s32 unk_18; + /* 0x01C */ s32 unk_1C; +} spriteControl; + +typedef struct otherSpriteControl { + /* 0x000 */ s8 unk_000[0x28]; + /* 0x028 */ u8 left_stretch; + /* 0x029 */ u8 right_stretch; + /* 0x02A */ u8 up_stretch; + /* 0x02B */ u8 down_stretch; + /* 0x02C */ s8 unk_02C[0x340-0x2C]; + /* 0x340 */ f32 xPos; + /* 0x344 */ f32 yPos; + /* 0x348 */ f32 unk_348; + /* 0x34C */ s8 unk_34C[4]; + /* 0x350 */ s8 gif_update_frequency; + /* 0x351 */ s8 unk_351[0xB]; + /* 0x35C */ spriteControl* gif_control_pointer; + /* 0x360 */ f32 xScale; + /* 0x364 */ f32 yScale; + /* 0x368 */ s8 unk_368[0x2]; + /* 0x36A */ s8 transparency1; + /* 0x36B */ s8 transparency2; + /* 0x36C */ s8 transparency3; + /* 0x36D */ s8 transparency4; + /* 0x36E */ s8 unk_36E[0x384-0x36E]; + /* 0x384 */ void* some_pointer; +} otherSpriteControl; + +#endif diff --git a/include/synthinternal.h b/include/synthinternal.h new file mode 100644 index 00000000..6970dde0 --- /dev/null +++ b/include/synthinternal.h @@ -0,0 +1,335 @@ +/*==================================================================== + * audioInternals.h + * + * Synopsis: + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __audioInternals__ +#define __audioInternals__ + +#include + +/* + * filter message ids + */ +enum { + AL_FILTER_FREE_VOICE, + AL_FILTER_SET_SOURCE, + AL_FILTER_ADD_SOURCE, + AL_FILTER_ADD_UPDATE, + AL_FILTER_RESET, + AL_FILTER_SET_WAVETABLE, +/* AL_FILTER_SET_DMA_PROC,*/ +/* AL_FILTER_SKIP_LOOP,*/ + AL_FILTER_SET_DRAM, + AL_FILTER_SET_PITCH, + AL_FILTER_SET_UNITY_PITCH, + AL_FILTER_START, +/* AL_FILTER_SET_DECAY,*/ +/* AL_FILTER_SET_FC,*/ + AL_FILTER_SET_STATE, + AL_FILTER_SET_VOLUME, + AL_FILTER_SET_PAN, + AL_FILTER_START_VOICE_ALT, + AL_FILTER_START_VOICE, + AL_FILTER_STOP_VOICE, + AL_FILTER_SET_FXAMT +}; + +#define AL_MAX_RSP_SAMPLES 0xB8 + +/* + * buffer locations based on AL_MAX_RSP_SAMPLES + */ +#define AL_DECODER_IN 0 +#define AL_RESAMPLER_OUT 0 +#define AL_TEMP_0 0 +#define AL_DECODER_OUT 320 +#define AL_TEMP_1 320 +#define AL_TEMP_2 640 +#define AL_MAIN_L_OUT 1088 +#define AL_MAIN_R_OUT 1408 +#define AL_AUX_L_OUT 1728 +#define AL_AUX_R_OUT 2048 + +/* + * filter types + */ +enum { + AL_ADPCM, + AL_RESAMPLE, + AL_BUFFER, + AL_SAVE, + AL_ENVMIX, + AL_FX, + AL_AUXBUS, + AL_MAINBUS +}; + +typedef struct ALParam_s { + struct ALParam_s *next; + s32 delta; + s16 type; + union { + f32 f; + s32 i; + } data; + union { + f32 f; + s32 i; + } moredata; + union { + f32 f; + s32 i; + } stillmoredata; + union { + f32 f; + s32 i; + } yetstillmoredata; +} ALParam; + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + s16 unity; /* disable resampler */ + f32 pitch; + s16 volume; + ALPan pan; + u8 fxMix; + s32 samples; + struct ALWaveTable_s *wave; +} ALStartParamAlt; + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + s16 unity; /* disable resampler */ + struct ALWaveTable_s *wave; +} ALStartParam; + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + struct PVoice_s *pvoice; +} ALFreeParam; + +typedef Acmd *(*ALCmdHandler)(void *, s16 *, s32, s32, Acmd *); +typedef s32 (*ALSetParam)(void *, s32, void *); + +typedef struct ALFilter_s { + struct ALFilter_s *source; + ALCmdHandler handler; + ALSetParam setParam; + s16 inp; + s16 outp; + s32 type; +} ALFilter; + +void alFilterNew(ALFilter *f, ALCmdHandler h, ALSetParam s, s32 type); + +#define AL_MAX_ADPCM_STATES 3 /* Depends on number of subframes + * per frame and loop length + */ +typedef struct { + ALFilter filter; + ADPCM_STATE *state; + ADPCM_STATE *lstate; + ALRawLoop loop; + struct ALWaveTable_s *table; + s32 bookSize; + ALDMAproc dma; + void *dmaState; + s32 sample; + s32 lastsam; + s32 first; + s32 memin; +} ALLoadFilter; + +void alLoadNew(ALLoadFilter *f, ALDMANew dma, ALHeap *hp); +Acmd *alAdpcmPull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); +Acmd *alRaw16Pull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); +s32 alLoadParam(void *filter, s32 paramID, void *param); + +typedef struct ALResampler_s { + ALFilter filter; + RESAMPLE_STATE *state; + f32 ratio; + s32 upitch; + f32 delta; + s32 first; + ALParam *ctrlList; + ALParam *ctrlTail; + s32 motion; +} ALResampler; + +typedef struct { + s16 fc; + s16 fgain; + union { + s16 fccoef[16]; + s64 force_aligned; + } fcvec; + POLEF_STATE *fstate; + s32 first; +} ALLowPass; + +typedef struct { + u32 input; + u32 output; + s16 ffcoef; + s16 fbcoef; + s16 gain; + f32 rsinc; + f32 rsval; + s32 rsdelta; + f32 rsgain; + ALLowPass *lp; + ALResampler *rs; +} ALDelay; + +typedef s32 (*ALSetFXParam)(void *, s32, void *); +typedef struct { + struct ALFilter_s filter; + s16 *base; + s16 *input; + u32 length; + ALDelay *delay; + u8 section_count; + ALSetFXParam paramHdl; +} ALFx; + +void alFxNew(ALFx *r, ALSynConfig *c, ALHeap *hp); +Acmd *alFxPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alFxParam(void *filter, s32 paramID, void *param); +s32 alFxParamHdl(void *filter, s32 paramID, void *param); + +#define AL_MAX_MAIN_BUS_SOURCES 1 +typedef struct ALMainBus_s { + ALFilter filter; + s32 sourceCount; + s32 maxSources; + ALFilter **sources; +} ALMainBus; + +void alMainBusNew(ALMainBus *m, void *ptr, s32 len); +Acmd *alMainBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alMainBusParam(void *filter, s32 paramID, void *param); + +#define AL_MAX_AUX_BUS_SOURCES 8 +#define AL_MAX_AUX_BUS_FX 1 +typedef struct ALAuxBus_s { + ALFilter filter; + s32 sourceCount; + s32 maxSources; + ALFilter **sources; + ALFx fx[AL_MAX_AUX_BUS_FX]; +} ALAuxBus; + +void alAuxBusNew(ALAuxBus *m, void *ptr, s32 len); +Acmd *alAuxBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alAuxBusParam(void *filter, s32 paramID, void *param); + +void alResampleNew(ALResampler *r, ALHeap *hp); +Acmd *alResamplePull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alResampleParam(void *f, s32 paramID, void *param); + +typedef struct ALSave_s { + ALFilter filter; + s32 dramout; + s32 first; +} ALSave; + +void alSaveNew(ALSave *r); +Acmd *alSavePull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alSaveParam(void *f, s32 paramID, void *param); + +typedef struct ALEnvMixer_s { + ALFilter filter; + ENVMIX_STATE *state; + s16 pan; + s16 volume; + s16 cvolL; + s16 cvolR; + s16 dryamt; + s16 wetamt; + u16 lratl; + s16 lratm; + s16 ltgt; + u16 rratl; + s16 rratm; + s16 rtgt; + s32 delta; + s32 segEnd; + s32 first; + ALParam *ctrlList; + ALParam *ctrlTail; + ALFilter **sources; + s32 motion; +} ALEnvMixer; + +void alEnvmixerNew(ALEnvMixer *e, ALHeap *hp); +Acmd *alEnvmixerPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alEnvmixerParam(void *filter, s32 paramID, void *param); + + +/* + * heap stuff + */ +typedef struct { + s32 magic; /* check structure integrety */ + s32 size; /* size of this allocated block */ + u8 *file; /* file that this alloc was called from */ + s32 line; /* line that it was called from */ + s32 count; /* heap call number */ + s32 pad0; + s32 pad1; + s32 pad2; /* Make it 32 bytes */ +} HeapInfo; + +#define AL_CACHE_ALIGN 15 + +/* + * synth stuff + */ + +typedef struct PVoice_s { + ALLink node; + struct ALVoice_s *vvoice; + ALFilter *channelKnob; + ALLoadFilter decoder; + ALResampler resampler; + ALEnvMixer envmixer; + s32 offset; +} PVoice; + +/* + * prototypes for private driver functions + */ +ALParam *__allocParam(void); +void __freeParam(ALParam *param); +void _freePVoice(ALSynth *drvr, PVoice *pvoice); +void _collectPVoices(ALSynth *drvr); + +s32 _timeToSamples(ALSynth *ALSynth, s32 micros); +ALMicroTime _samplesToTime(ALSynth *synth, s32 samples); + +#endif diff --git a/include/variables.h b/include/variables.h new file mode 100644 index 00000000..4b42daed --- /dev/null +++ b/include/variables.h @@ -0,0 +1,297 @@ +extern s8 story_skip; +extern s8 widescreen_enabled; +extern PlayerAdditionalActorData *extra_player_info_pointer; +extern Actor *current_actor_pointer; +extern Actor *D_807FBB44; +extern Actor *D_807FBB48; +extern GlobalASMStruct35 D_807FBB70[]; +extern Actor *D_807FBD6C; +extern Actor *D_807FDC94; +extern EnemyInfo *D_807FDC98; +extern u8 current_character_index[]; +extern CharacterChange *character_change_array; +extern Actor *player_pointer; +extern u8 cc_player_index; // index into character_change_array, current_character_index[] +extern u8 cc_number_of_players; +extern s32 global_properties_bitfield; +extern Maps current_map; +extern s32 current_exit; +extern Maps next_map; +extern s32 next_exit; +extern u8 is_cutscene_active; +extern u8 game_mode; +extern u8 game_mode_copy; +extern u16 newly_pressed_input; +extern u16 newly_pressed_input_copy; +extern Struct807FDC90 *D_807FDC90; // Array? +extern CharacterSpawner *D_807FDC9C; // Character spawner array +extern s32 object_timer; +extern u8 is_autowalking; +extern ActorSpawner *actor_spawner_pointer; +extern PlayerProgress D_807FC950[4]; +extern u16 enemies_killed; +extern Chunk *chunk_array_pointer; +extern u8 current_file; + +extern s32 D_807FBB64; // shadow_display_bitfield, shockwave_bitfield, long_distance_actor_spawn + +extern u8 D_8076A0AB; // Map +extern s16 D_807F6240[]; + +typedef struct { + s32 unk0; // Used + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; // Used +} Struct807552E4; + +extern Struct807552E4 D_807552E4; + +typedef struct Struct807FD610 { + s32 unk0; // Timer that ticks up once per frame + f32 unk4; // Probably float + f32 unk8; // Probably float + f32 unkC; // Probably float + f32 unk10; + f32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; // Probably s16 + s32 unk24; // Probably s16 + s16 unk28; // Used + u16 unk2A; // Used, controller button bitfield + u16 unk2C; // Used, controller button bitfield + s8 unk2E; // Used + s8 unk2F; // Used + u8 unk30; // Used + u8 unk31; + s16 unk32; +} Struct807FD610; + +extern Struct807FD610 D_807FD610[]; // Often indexed by cc_player_index +extern OSPfs D_807F02D0[]; + +typedef struct { + s32 unk0; + s32 unk4; + f32 unk8; // Used +} GlobalASMStruct20_unk18; + +typedef struct { + u8 pad0[0x18]; + GlobalASMStruct20_unk18 *unk18; // Used + s32 unk1C; // Used + s32 unk20; + s32 unk24; + s32 unk28; // Used + s32 unk2C; + u16 unk30; // Flags? +} GlobalASMStruct20; +extern GlobalASMStruct20 *D_8076BF20[]; + +// TODO: What is this datatype? +typedef struct Struct807FDCA0 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; // TODO: Pointer to an array of structs 0xA big? See boss func_8003392C + s32 unk18; + s32 unk1C; + s8 unk20; +} Struct807FDCA0; +extern Struct807FDCA0 *D_807FDCA0; // TODO: What is this datatype? + +typedef struct Struct807F0470 { + s32 unk0; + u8 unk4; + u8 unk5; + s16 unk6; + s32 unk8; + s32 unkC; + u16 unk10; + u8 unk12; + u8 unk13; +} Struct807F0470; + +extern Struct807F0470 D_807F0470[]; + +typedef struct { + Actor* unk0; + s32 unk4; +} GlobalASMStruct53; + +extern GlobalASMStruct53 D_807FB930[]; + +typedef struct global_asm_struct_58 GlobalASMStruct58; + +struct global_asm_struct_58 { + void *unk0; // used, at least 0x65 big (func_80661264, func_8065F5F0), not sure what datatype though + f32 unk4; // used + f32 unk8; // used + f32 unkC; // used + f32 unk10; // used + f32 unk14; // used + f32 unk18; // used + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s16 unk48; + s8 unk4A; // used + s8 unk4B; // used + s8 unk4C; // used + s8 unk4D; + s16 unk4E; + GlobalASMStruct58 *next; // used +}; + +extern GlobalASMStruct58 *D_807F93C0; + +// Array of structs 0x10 big +// TODO: What are these actually? +typedef struct Temp10Big { + s32 unk0; + s16 unk4; + s8 unk6; + s8 unk7; + s32 unk8; + s32 unkC; +} Temp10Big; +extern Temp10Big D_8075C410[]; + +typedef struct DKTVExtraData { + s32 unk0; + s32 unk4; + s32 unk8; + s16 unkC; + u8 map; + u8 exit; +} DKTVExtraData; + +extern DKTVExtraData D_807ECE20; + +typedef struct model_2_model_50_b8 Model2Model50_B8; + +struct model_2_model_50_b8 { + s32 unk0[4]; + s32 unk10[4]; + s32 unk20[4]; + s32 unk30; + s32 unk34; + s16 unk38; // Used + s16 unk3A; // Used + s32 unk3C; + s32 unk40; + s32 unk44; + u8 unk48; // Used + u8 unk49; // used + u8 unk4A; + u8 unk4B; + s32 unk4C; + s32 unk50; // Used + s32 unk54; // Used + s32 unk58; + s32 unk5C; + s32 unk60[4]; + s32 unk70[4]; + s32 unk80[4]; + s32 unk90[4]; + s32 unkA0[4]; + s32 unkB0[4]; + s32 unkC0[4]; + s32 unkD0; + Model2Model50_B8 *next; // unkD4 +}; + +typedef struct { + s32 unk0[4]; + s32 unk10[4]; + s32 unk20[4]; + s32 unk30[4]; + s32 unk40; + s32 unk44; + s32 unk48; + s16 unk4C; + u8 unk4E; // Used + u8 unk4F; // Used + Model2Model50_B8 *unk50; // Used, pointer + s32 unk54; + s32 unk58; + s32 unk5C; + s32 unk60[4]; + s32 unk70[4]; + s32 unk80[4]; + s32 unk90[4]; + s32 unkA0[4]; + s32 unkB0; + s32 unkB4; + Model2Model50_B8 *unkB8; // Used, pointer +} Model2Model; + +typedef struct object_model2 { + f32 x_position; // at 0x00 + f32 y_position; // at 0x04 + f32 z_position; // at 0x08 + f32 hitbox_scale; // at 0x0C + f32 x_rotation; // at 0x10 + f32 y_rotation; // at 0x14 + f32 z_rotation; // at 0x18 + s32 unk1C; + Model2Model *model_pointer; // at 0x20 + void *unk24; // labelled behavior_type_pointer in ScriptHawk + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s32 unk48; + s32 unk4C; + s32 unk50; + s32 unk54; + s32 unk58; + s32 unk5C; + s32 unk60; + s32 unk64; + s32 unk68; + s32 unk6C; + s32 unk70; + s32 unk74; + void *unk78; // used in func_80650AD8, weird format + void *unk7C; // labelled behavior_pointer in ScriptHawk + s32 unk80; + s16 object_type; // at 0x84 + s16 unk86; + s16 unk88; + s16 unk8A; + s32 unk8C; // bitfield, collectable state (u8) +} ObjectModel2; + +extern ObjectModel2 *D_807F6000; + +extern u16 D_80744710[]; // = { // Permanent flag index lookup array +// 26, // Key 1 Collected +// 74, // key 2 Collected +// 138, // Key 3 Collected +// 168, // Key 4 Collected +// 236, // Key 5 Collected +// 292, // Key 6 Collected +// 317, // Key 7 Collected +// 380, // Key 8 Collected +// }; // Permanent flag index lookup array diff --git a/include/viint.h b/include/viint.h new file mode 100755 index 00000000..2887afb3 --- /dev/null +++ b/include/viint.h @@ -0,0 +1,70 @@ +#ifndef _VIINT_H +#define _VIINT_H +#include + +#define OS_TV_TYPE_PAL 0 +#define OS_TV_TYPE_NTSC 1 +#define OS_TV_TYPE_MPAL 2 + +//TODO: figure out what this is +#define VI_STATE_01 0x01 +#define VI_STATE_XSCALE_UPDATED 0x02 +#define VI_STATE_YSCALE_UPDATED 0x04 +#define VI_STATE_08 0x08 //related to control regs changing +#define VI_STATE_10 0x10 //swap buffer +#define VI_STATE_BLACK 0x20 //probably related to a black screen +#define VI_STATE_REPEATLINE 0x40 //repeat line? +#define VI_STATE_FADE 0x80 //fade + +#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */ +#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */ +#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */ + +#define VI_SCALE_MASK 0xfff //see rcp scale_x/scale_y +#define VI_2_10_FPART_MASK 0x3ff +#define VI_SUBPIXEL_SH 0x10 + +#define BURST(hsync_width, color_width, vsync_width, color_start) \ + (hsync_width | (color_width << 8) | (vsync_width << 16) | (color_start << 20)) +#define WIDTH(v) v +#define VSYNC(v) v +#define HSYNC(duration, leap) (duration | (leap << 16)) +#define LEAP(upper, lower) ((upper << 16) | lower) +#define START(start, end) ((start << 16) | end) + +#define FTOFIX(val, i, f) ((u32)(val * (f32)(1 << f)) & ((1 << (i + f)) - 1)) + +#define F210(val) FTOFIX(val, 2, 10) +#define SCALE(scaleup, off) (F210((1.0f / (f32)scaleup)) | (F210((f32)off) << 16)) + +#define VCURRENT(v) v //seemingly unused +#define ORIGIN(v) v +#define VINTR(v) v +#define HSTART START + +typedef struct +{ + /* 0x0 */ f32 factor; + /* 0x4 */ u16 offset; + /* 0x8 */ u32 scale; +} __OSViScale; + +typedef struct +{ + /* 0x0 */ u16 state; + /* 0x2 */ u16 retraceCount; + /* 0x4 */ void *framep; + /* 0x8 */ OSViMode *modep; + /* 0xC */ u32 control; + /* 0x10 */ OSMesgQueue *msgq; + /* 0x14 */ OSMesg msg; + /* 0x18 */ __OSViScale x; + /* 0x24 */ __OSViScale y; +} __OSViContext; + +void __osViSwapContext(void); +extern __OSViContext *__osViCurr; +extern __OSViContext *__osViNext; +__OSViContext *__osViGetCurrentContext(void); +void __osViInit(void); +#endif diff --git a/progress/progress.arcade.csv b/progress/progress.arcade.csv new file mode 100644 index 00000000..3cb5d00d --- /dev/null +++ b/progress/progress.arcade.csv @@ -0,0 +1,99 @@ +version,section,function,length,matching +us,.code,func_80030C70,124,yes +us,.code,func_80024764,84,yes +us,.code,func_8002451C,296,yes +us,.code,arcade_nintendo_coin_update,316,yes +us,.code,func_8002B390,1292,no +us,.code,func_80029ACC,516,yes +us,.code,arcade_pie_update,360,yes +us,.code,func_8002AF2C,120,yes +us,.code,func_80030FEC,500,yes +us,.code,arcade_75m_setup,1792,yes +us,.code,func_8002E3D4,780,no +us,.code,func_800252D8,452,yes +us,.code,func_8002F82C,1532,no +us,.code,arcade_100m_setup,1460,yes +us,.code,arcade_25m_setup,1328,yes +us,.code,func_80030CEC,708,no +us,.code,arcade_help_text_update,356,yes +us,.code,func_8002628C,352,yes +us,.code,func_800244E4,36,yes +us,.code,func_80024320,236,yes +us,.code,func_80029CD0,556,no +us,.code,func_800319D4,2124,no +us,.code,func_800263EC,300,yes +us,.code,func_80027A38,1108,no +us,.code,func_800255A8,76,yes +us,.code,func_80029968,356,yes +us,.code,func_80024508,20,yes +us,.code,func_8002419C,388,yes +us,.code,func_800268AC,1608,no +us,.code,func_800246EC,120,yes +us,.code,arcade_pauline_bottom_update,268,yes +us,.code,arcade_bonus_item_update,260,yes +us,.code,func_800247B8,56,yes +us,.code,func_8002AFA4,796,yes +us,.code,func_80024E84,852,yes +us,.code,func_8002AC54,728,yes +us,.code,arcade_rivet_update,388,yes +us,.code,func_8002440C,216,yes +us,.code,func_800247F0,56,yes +us,.code,arcade_get_object_type_count,104,yes +us,.code,func_800259D0,568,yes +us,.code,__arcade_abs_w,24,yes +us,.code,arcade_dk_50m_update,460,yes +us,.code,func_8002A390,120,yes +us,.code,func_8002B89C,4924,no +us,.code,arcade_dk_title_update,692,yes +us,.code,func_80027E8C,128,yes +us,.code,func_8002D6FC,2652,no +us,.code,func_8002A264,300,no +us,.code,func_800251D8,104,yes +us,.code,func_800311E0,472,no +us,.code,func_80024CF8,152,yes +us,.code,func_80030734,332,yes +us,.code,func_80025C08,1096,yes +us,.code,func_8002B2C0,184,yes +us,.code,func_8002CBD8,396,yes +us,.code,func_80026EF4,1516,no +us,.code,func_80025240,100,yes +us,.code,func_80029EFC,872,no +us,.code,func_80024000,412,yes +us,.code,func_8002EEB8,2420,no +us,.code,func_800257D8,392,yes +us,.code,func_80024C34,196,yes +us,.code,func_80024644,48,yes +us,.code,func_800255F4,484,yes +us,.code,func_80025960,112,yes +us,.code,arcade_barrel_stack_update,60,yes +us,.code,func_80026518,360,yes +us,.code,func_80026050,572,yes +us,.code,func_80024A50,180,no +us,.code,func_800274E0,264,no +us,.code,func_8002E158,636,no +us,.code,arcade_pulley_update,196,yes +us,.code,func_8002549C,268,yes +us,.code,func_80026680,556,yes +us,.code,func_80030A04,260,no +us,.code,func_8002A734,752,yes +us,.code,func_800252A4,52,yes +us,.code,func_80024828,56,yes +us,.code,func_80024D90,244,yes +us,.code,func_800275E8,1104,no +us,.code,arcade_50m_setup,2168,yes +us,.code,func_8003159C,940,yes +us,.code,func_8002CD64,2456,no +us,.code,func_8002AA24,560,yes +us,.code,func_8002FE28,540,no +us,.code,arcade_add_points_to_score,84,yes +us,.code,arcade_hammer_update,892,yes +us,.code,func_8002A474,704,yes +us,.code,arcade_pauline_top_update,180,yes +us,.code,func_80024940,272,no +us,.code,func_80031948,140,yes +us,.code,func_8002A408,108,no +us,.code,func_800313B8,484,yes +us,.code,func_80024B04,304,no +us,.code,arcade_points_text_update,164,yes +us,.code,func_80024860,120,yes +us,.code,func_800246C8,36,yes diff --git a/progress/progress.bonus.csv b/progress/progress.bonus.csv new file mode 100644 index 00000000..8fe9b7c2 --- /dev/null +++ b/progress/progress.bonus.csv @@ -0,0 +1,48 @@ +version,section,function,length,matching +us,.code,func_8002AED8,2632,no +us,.code,func_80027308,52,yes +us,.code,func_8002BF98,2388,no +us,.code,func_8002563C,136,yes +us,.code,func_8002881C,1568,no +us,.code,func_800264E0,224,yes +us,.code,func_80024E38,1128,no +us,.code,func_80024D8C,172,no +us,.code,func_8002BE44,340,no +us,.code,func_8002D7E8,112,yes +us,.code,func_800240F0,104,yes +us,.code,func_800256C4,72,no +us,.code,func_8002D2F0,1032,no +us,.code,func_800277F8,1820,no +us,.code,func_800284C0,392,no +us,.code,func_80026CF0,1220,no +us,.code,func_80028648,468,no +us,.code,func_80025480,48,no +us,.code,func_800271B4,340,no +us,.code,func_8002CC08,1032,no +us,.code,func_80024D3C,80,no +us,.code,func_8002B920,1316,no +us,.code,func_80024158,3044,no +us,.code,func_8002A398,1804,no +us,.code,func_8002AAA4,620,no +us,.code,func_80028E3C,1320,no +us,.code,func_800261B8,808,no +us,.code,func_80029B9C,696,no +us,.code,func_80029364,2104,no +us,.code,func_8002733C,356,no +us,.code,func_80024000,240,no +us,.code,func_8002AD10,456,no +us,.code,func_8002C8EC,796,no +us,.code,func_800265C0,200,yes +us,.code,func_8002D010,736,no +us,.code,func_8002570C,2732,no +us,.code,func_80026940,944,no +us,.code,func_800253E4,156,yes +us,.code,func_800274A0,168,yes +us,.code,func_80029E54,444,no +us,.code,func_80026690,688,no +us,.code,func_800254B0,396,no +us,.code,func_8002D6F8,240,no +us,.code,func_800252A0,324,no +us,.code,func_80027F14,1452,no +us,.code,func_8002A010,904,no +us,.code,func_80027548,688,no diff --git a/progress/progress.boss.csv b/progress/progress.boss.csv new file mode 100644 index 00000000..7af53e76 --- /dev/null +++ b/progress/progress.boss.csv @@ -0,0 +1,81 @@ +version,section,function,length,matching +us,.code,func_8002920C,160,yes +us,.code,func_80033AF0,7276,no +us,.code,func_80033A80,112,yes +us,.code,func_80028478,520,no +us,.code,func_80029140,204,yes +us,.code,func_8002C748,132,yes +us,.code,func_800254D0,8864,no +us,.code,func_8003340C,152,yes +us,.code,func_8002531C,72,yes +us,.code,func_80024EAC,252,yes +us,.code,func_80024300,524,no +us,.code,func_8002C5F4,340,yes +us,.code,func_80027A30,376,no +us,.code,func_80030C30,288,yes +us,.code,func_8002E82C,396,yes +us,.code,func_80030D50,264,yes +us,.code,func_8002FEC0,180,yes +us,.code,func_8002DCE0,156,yes +us,.code,func_8002A5CC,748,yes +us,.code,func_80024568,2372,no +us,.code,func_80028878,2140,no +us,.code,func_8002E9B8,92,yes +us,.code,func_8002FC98,352,no +us,.code,func_8002DD7C,136,yes +us,.code,func_8003392C,172,no +us,.code,func_8002EA7C,1668,no +us,.code,func_8002DC60,128,yes +us,.code,func_80031AA0,4200,no +us,.code,func_8002C520,212,yes +us,.code,func_8002FDF8,200,yes +us,.code,func_80030888,152,no +us,.code,func_8002EA14,104,yes +us,.code,func_8002C964,2252,no +us,.code,func_80028458,32,yes +us,.code,func_8002FF74,2324,no +us,.code,func_8002450C,24,no +us,.code,func_800251A0,380,yes +us,.code,func_800292B0,272,yes +us,.code,func_80024FA8,504,yes +us,.code,func_8002A8B8,116,yes +us,.code,func_80030AE0,336,yes +us,.code,func_80025364,72,yes +us,.code,func_800336C0,196,yes +us,.code,func_8002FC48,80,yes +us,.code,func_80028818,8,yes +us,.code,func_80030EC4,3036,no +us,.code,func_800253AC,292,no +us,.code,func_80032B08,1480,no +us,.code,func_80029468,3544,no +us,.code,func_80027840,180,no +us,.code,func_800290D4,108,yes +us,.code,func_800334A4,540,no +us,.code,func_80024000,316,no +us,.code,func_8002D230,2608,no +us,.code,func_80027950,224,no +us,.code,func_80030920,448,no +us,.code,func_8002A92C,7156,no +us,.code,func_80028820,88,yes +us,.code,func_80030E58,108,yes +us,.code,func_8002FB7C,204,yes +us,.code,func_8002A41C,320,yes +us,.code,func_800278F4,92,yes +us,.code,func_80024524,68,no +us,.code,func_8002E7A0,140,yes +us,.code,func_8002A240,476,no +us,.code,func_800330D0,828,no +us,.code,func_8002A55C,112,yes +us,.code,func_800293C0,168,yes +us,.code,func_8002C8B4,176,yes +us,.code,func_80027BA8,2224,no +us,.code,func_8002C7CC,232,yes +us,.code,func_800339D8,168,yes +us,.code,func_8003575C,328,yes +us,.code,func_800286B8,352,no +us,.code,func_8002413C,452,no +us,.code,func_8002DE04,2460,no +us,.code,func_8002F100,2684,no +us,.code,func_80033784,424,no +us,.code,func_80028680,56,yes +us,.code,func_80027770,208,no diff --git a/progress/progress.dk64_boot.csv b/progress/progress.dk64_boot.csv new file mode 100644 index 00000000..9caabf87 --- /dev/null +++ b/progress/progress.dk64_boot.csv @@ -0,0 +1,233 @@ +version,section,function,length,matching +us,boot,func_80005A70,16,no +us,boot,func_800058BC,92,no +us,boot,osDestroyThread,260,yes +us,boot,guSprite2DInit,80,no +us,boot,func_8000102C,144,yes +us,boot,osRecvMesg,312,yes +us,boot,osGetThreadId,24,yes +us,boot,osCreateViManager,384,no +us,boot,func_80002F18,60,no +us,boot,func_80002750,52,yes +us,boot,__osContDataCrc,160,no +us,boot,func_80002ECC,76,no +us,boot,__osSetCompare,16,yes +us,boot,guMtxL2F,184,no +us,boot,__osPiCreateAccessQueue,80,no +us,boot,func_800005A8,984,no +us,boot,func_80007360,112,no +us,boot,__osDispatchThread,396,yes +us,boot,guTranslate,84,yes +us,boot,func_80000D8C,188,yes +us,boot,__osAiDeviceBusy,48,yes +us,boot,osEepromLongRead,140,yes +us,boot,func_80001700,1012,no +us,boot,func_80002790,152,no +us,boot,func_800022D4,288,no +us,boot,func_80002724,44,no +us,boot,__osPackRamWriteDataSafe,128,no +us,boot,func_80005948,96,no +us,boot,func_80005818,60,no +us,boot,osDpGetStatus,12,yes +us,boot,func_8000BE20,480,no +us,boot,osEPiRawReadIo,352,no +us,boot,__osEepStatus,428,no +us,boot,guLookAtHiliteF,1848,no +us,boot,osMotorStartStop,360,no +us,boot,osViGetCurrentFramebuffer,64,yes +us,boot,__osDevMgrMain,1168,no +us,boot,guAlign,80,no +us,boot,__osExceptionPreamble,16,yes +us,boot,__osSpSetStatus,12,yes +us,boot,func_80002D60,132,no +us,boot,func_800075CC,28,no +us,boot,func_800010C0,1600,no +us,boot,func_800004F4,180,yes +us,boot,func_800075E8,160,no +us,boot,osSendMesg,332,yes +us,boot,func_8000DB90,288,no +us,boot,sqrtf,16,yes +us,boot,__osPfsGetStatus,208,no +us,boot,__osSetGlobalIntMask,76,yes +us,boot,osUnmapTLBAll,80,yes +us,boot,__osPiGetAccess,68,no +us,boot,osSetThreadPri,224,yes +us,boot,__osSpGetStatus,12,yes +us,boot,memcpy,288,no +us,boot,func_800024E0,196,yes +us,boot,osMotorInit,348,yes +us,boot,osVirtualToPhysical,124,yes +us,boot,guMtxIdent,48,yes +us,boot,osEepromRead,452,no +us,boot,_MakeMotorData,268,no +us,boot,func_80007754,52,no +us,boot,osYieldThread,76,yes +us,boot,osPiReadIo,64,yes +us,boot,func_80002A64,88,no +us,boot,func_80002ABC,80,no +us,boot,__ull_to_f,28,no +us,boot,osViSwapBuffer,80,yes +us,boot,func_80005918,48,no +us,boot,__osContRamWrite,592,no +us,boot,func_80000980,80,yes +us,boot,osEepromProbe,112,no +us,boot,__osSetTimerIntr,116,yes +us,boot,guOrthoF,340,yes +us,boot,__osSetSR,16,yes +us,boot,osStartThread,336,yes +us,boot,guLookAtHilite,184,yes +us,boot,func_800057B0,44,no +us,boot,osSetIntMask,160,no +us,boot,func_80007724,24,no +us,boot,osGetCount,16,yes +us,boot,osContInit,368,no +us,boot,osPiStartDma,268,yes +us,boot,__osSumcalc,116,no +us,boot,func_80002E98,52,no +us,boot,bzero,160,yes +us,boot,__osInsertTimer,392,yes +us,boot,__osEnqueueAndYield,256,yes +us,boot,__osSpDeviceBusy,44,yes +us,boot,cosf,368,no +us,boot,osSpTaskYield,32,yes +us,boot,guMtxCatF,360,yes +us,boot,__osPopThread,16,yes +us,boot,func_80000AA0,564,no +us,boot,osGetTime,132,yes +us,boot,osCreateMesgQueue,44,yes +us,boot,guLookAt,120,yes +us,boot,func_800025A4,384,no +us,boot,__osSpRawStartDma,140,yes +us,boot,guPerspective,88,yes +us,boot,__osSiRawReadIo,80,yes +us,boot,__osIdCheckSum,252,no +us,boot,osViGetCurrentMode,72,yes +us,boot,func_8000320C,4884,no +us,boot,func_800057DC,60,no +us,boot,guOrtho,104,yes +us,boot,func_80002BB8,188,no +us,boot,func_80005880,60,no +us,boot,guNormalize,132,yes +us,boot,__osRestoreInt,32,yes +us,boot,__osViGetCurrentContext,12,yes +us,boot,osSetTime,36,yes +us,boot,osViSetMode,104,yes +us,boot,__osPiRelAccess,44,no +us,boot,func_80002DE4,180,no +us,boot,osInitialize,704,no +us,boot,func_800031E0,44,no +us,boot,func_80002828,184,no +us,boot,__osPackEepWriteData,172,no +us,boot,osPfsIsPlug,416,no +us,boot,send_mesg,232,yes +us,boot,__osEnqueueThread,72,yes +us,boot,osEPiRawWriteIo,352,no +us,boot,guLookAtF,696,yes +us,boot,guAlignF,448,no +us,boot,__osTimerInterrupt,376,yes +us,boot,osPiGetCmdQueue,40,yes +us,boot,__osProbeTLB,192,yes +us,boot,bcopy,784,yes +us,boot,osPiRawReadIo,84,yes +us,boot,func_80003120,192,no +us,boot,osSpTaskYielded,128,yes +us,boot,osGetThreadPri,24,yes +us,boot,guTranslateF,72,yes +us,boot,osInvalICache,128,yes +us,boot,osSetEventMesg,104,yes +us,boot,func_800023F4,236,no +us,boot,guRotateF,404,no +us,boot,guMtxCatL,88,yes +us,boot,func_80002CE8,120,no +us,boot,__osSiCreateAccessQueue,80,no +us,boot,__osSiDeviceBusy,48,no +us,boot,func_80005070,336,no +us,boot,__osTimerServicesInit,140,no +us,boot,func_80001AF4,340,no +us,boot,__osPfsRequestOneChannel,196,no +us,boot,__osSiRawWriteIo,76,yes +us,boot,guRotate,92,no +us,boot,osAiGetLength,12,yes +us,boot,func_8000D7E0,212,no +us,boot,osInvalDCache,176,yes +us,boot,__osPfsGetOneChannelData,156,no +us,boot,osJamMesg,336,yes +us,boot,__osSpSetPc,52,yes +us,boot,func_80007788,56,no +us,boot,func_80001C48,360,no +us,boot,osViGetNextFramebuffer,64,yes +us,boot,guPosition,112,no +us,boot,func_80000EEC,320,no +us,boot,__osResetGlobalIntMask,96,no +us,boot,__osException,1316,yes +us,boot,__osContGetInitData,208,no +us,boot,__osGetFpcCsr,16,yes +us,boot,__osSiRawStartDma,176,no +us,boot,guScale,72,yes +us,boot,osAiSetNextBuffer,164,yes +us,boot,__osDisableInt,32,yes +us,boot,__osViInit,316,yes +us,boot,func_80001DB0,1316,no +us,boot,func_80000E48,164,no +us,boot,__osPackRequestData,256,no +us,boot,osPiRawStartDma,224,yes +us,boot,func_800004B4,64,yes +us,boot,osStopThread,192,yes +us,boot,guMtxXFMF,160,yes +us,boot,__osRepairPackId,848,no +us,boot,func_80007688,156,no +us,boot,func_800028E0,268,no +us,boot,func_800073D0,132,yes +us,boot,osPiGetStatus,12,yes +us,boot,osSpTaskStartGo,64,yes +us,boot,func_80000CD4,184,yes +us,boot,sinf,448,no +us,boot,__osPfsRequestData,208,no +us,boot,func_80005A44,44,no +us,boot,func_800029EC,68,no +us,boot,func_800074E0,208,no +us,boot,func_800009D0,88,yes +us,boot,guMtxXFML,96,yes +us,boot,func_80000450,100,yes +us,boot,osSetTimer,212,yes +us,boot,osMapTLBRdb,96,yes +us,boot,func_80005854,44,no +us,boot,__osGetId,428,no +us,boot,osCreatePiManager,368,no +us,boot,func_80000A30,112,no +us,boot,func_8000D8B4,732,no +us,boot,osCreateThread,336,no +us,boot,func_800059A8,156,no +us,boot,osViBlack,112,yes +us,boot,func_80002C74,116,no +us,boot,func_800055D0,156,yes +us,boot,func_8000773C,24,no +us,boot,__osPackEepReadData,140,no +us,boot,osEepromWrite,376,no +us,boot,func_80002F54,172,no +us,boot,osWritebackDCache,128,yes +us,boot,osDpSetStatus,12,yes +us,boot,__osSetFpcCsr,16,yes +us,boot,__osSiRelAccess,44,no +us,boot,osSpTaskLoad,400,yes +us,boot,osViSetSpecialFeatures,440,yes +us,boot,__osGetSR,16,yes +us,boot,guMtxIdentF,136,yes +us,boot,func_80007454,140,no +us,boot,__osPfsGetInitData,208,no +us,boot,__osViSwapContext,768,no +us,boot,viMgrMain,400,no +us,boot,__osContRamReadData,560,no +us,boot,guMtxF2L,256,yes +us,boot,func_800056F0,112,no +us,boot,guPerspectiveF,560,yes +us,boot,func_80002B0C,172,no +us,boot,__osSiGetAccess,68,no +us,boot,guScaleF,84,yes +us,boot,func_80002A30,52,no +us,boot,__osCheckPackId,356,no +us,boot,__osContAddressCrc,208,no +us,boot,func_80000400,80,yes +us,boot,osWriteBackDCacheAll,48,yes +us,boot,__osDequeueThread,64,yes +us,boot,guPositionF,432,no diff --git a/progress/progress.global_asm.csv b/progress/progress.global_asm.csv new file mode 100644 index 00000000..2c644807 --- /dev/null +++ b/progress/progress.global_asm.csv @@ -0,0 +1,3303 @@ +version,section,function,length,matching +us,.code,func_80680908,232,yes +us,.code,func_806C4414,1264,no +us,.code,func_8072E5B0,76,yes +us,.code,func_8069902C,32,yes +us,.code,func_806436A4,60,yes +us,.code,func_80688E68,60,yes +us,.code,func_8071F2F8,200,no +us,.code,func_806D3608,196,yes +us,.code,func_80666290,204,yes +us,.code,func_8071D0F0,368,no +us,.code,func_8073726C,560,no +us,.code,func_80651BC0,32,yes +us,.code,func_8071B8EC,552,no +us,.code,func_8060B430,108,no +us,.code,func_8060042C,40,yes +us,.code,func_8066EB40,16,yes +us,.code,func_806EDFF8,52,yes +us,.code,func_8067E764,32,yes +us,.code,func_80738C6C,180,no +us,.code,func_805FFFC8,124,yes +us,.code,func_80652EBC,104,yes +us,.code,func_80666AEC,12,yes +us,.code,func_8066BF0C,228,yes +us,.code,func_80643B24,232,no +us,.code,func_806ED6B0,2376,no +us,.code,func_806EB364,156,yes +us,.code,func_806FA504,160,no +us,.code,func_806679BC,2916,no +us,.code,func_806F8CB0,76,yes +us,.code,func_80679DC4,728,no +us,.code,func_8068408C,160,yes +us,.code,func_80724B5C,208,no +us,.code,func_8073801C,100,no +us,.code,func_80647170,168,no +us,.code,func_80697184,160,yes +us,.code,func_80658DAC,172,no +us,.code,func_806B513C,416,yes +us,.code,func_80610C74,344,no +us,.code,func_8064C134,284,no +us,.code,func_8067E4D4,60,yes +us,.code,func_806458C8,412,no +us,.code,func_8066A584,200,no +us,.code,func_806688B8,132,no +us,.code,func_8071B758,324,no +us,.code,func_80646978,1100,no +us,.code,func_807105D4,1740,no +us,.code,func_806E8244,608,no +us,.code,func_80687EE0,156,no +us,.code,func_80663BE8,120,no +us,.code,func_806BF218,1800,no +us,.code,func_80712548,44,yes +us,.code,func_80695BAC,1272,no +us,.code,func_8060956C,1556,no +us,.code,func_80738320,144,no +us,.code,func_806EBA04,112,yes +us,.code,n_alSynNew,1540,no +us,.code,func_8066D4DC,1636,no +us,.code,func_8062AC68,192,no +us,.code,func_80675E3C,164,no +us,.code,func_80712BD4,776,no +us,.code,func_8060A900,188,yes +us,.code,func_8065D964,48,yes +us,.code,func_806E35D8,220,yes +us,.code,func_806506E8,172,yes +us,.code,func_807149B8,16,yes +us,.code,func_80686CF8,328,no +us,.code,func_806E6DE8,148,yes +us,.code,func_8068581C,112,yes +us,.code,func_805FD030,88,yes +us,.code,func_806521F8,212,no +us,.code,func_8063D1D8,176,yes +us,.code,func_8063D494,16,yes +us,.code,func_8063BBB0,784,no +us,.code,func_80650BBC,108,no +us,.code,func_80605314,108,no +us,.code,func_806C1CCC,376,yes +us,.code,func_8062D2AC,68,yes +us,.code,func_80662110,72,yes +us,.code,func_80687D50,400,no +us,.code,func_80672F94,272,no +us,.code,func_8065D244,16,yes +us,.code,func_806B91E0,2768,no +us,.code,func_806A6094,40,yes +us,.code,func_806335B0,204,no +us,.code,func_806F8004,364,yes +us,.code,func_8066FC0C,352,no +us,.code,func_8066A64C,272,no +us,.code,func_806951B0,56,yes +us,.code,func_8069D098,32,yes +us,.code,func_806A7B4C,36,yes +us,.code,func_8065C240,244,no +us,.code,func_806C2D7C,120,yes +us,.code,func_806C8DE0,120,no +us,.code,func_806323C0,380,no +us,.code,func_80698FEC,32,yes +us,.code,func_806C55D8,8,yes +us,.code,func_80689114,196,no +us,.code,func_80714778,460,no +us,.code,func_806B7830,904,no +us,.code,func_8068EB3C,440,no +us,.code,n_alSynDelete,28,yes +us,.code,func_8071C004,584,no +us,.code,func_80675380,248,no +us,.code,func_80732DEC,292,no +us,.code,func_8067B3F4,56,yes +us,.code,func_8067BD08,32,yes +us,.code,func_8060F208,76,no +us,.code,func_807180F4,48,yes +us,.code,func_8066DB40,500,no +us,.code,func_80700088,548,no +us,.code,func_80695B50,92,yes +us,.code,func_80677FA8,108,no +us,.code,func_806734E4,548,no +us,.code,func_8063E0D4,1248,no +us,.code,func_806E1BA4,404,no +us,.code,func_806E93F8,112,yes +us,.code,func_80719A0C,380,no +us,.code,func_80668B28,264,no +us,.code,func_80718124,100,yes +us,.code,func_8073C820,176,no +us,.code,func_806E1D38,284,yes +us,.code,func_806547A8,644,no +us,.code,func_8073E8A0,20,no +us,.code,func_806A61D0,96,yes +us,.code,func_80600950,12,yes +us,.code,func_80711410,1344,no +us,.code,func_806D1568,1088,no +us,.code,func_806E9ACC,112,yes +us,.code,func_806ACFFC,612,no +us,.code,func_8060CBBC,1260,no +us,.code,func_805FF158,16,yes +us,.code,func_8067AE90,108,yes +us,.code,func_8065FB04,96,yes +us,.code,func_8063393C,224,no +us,.code,func_80674E14,876,no +us,.code,func_806F14BC,428,no +us,.code,func_806C71D0,8,yes +us,.code,func_8065EACC,40,yes +us,.code,func_805FF018,24,yes +us,.code,func_806EA2D8,92,yes +us,.code,func_806CFF9C,436,no +us,.code,func_8060C2C4,124,yes +us,.code,func_806B83E4,712,no +us,.code,func_806F9D8C,1048,no +us,.code,func_805FF2F4,132,yes +us,.code,func_806EE634,44,yes +us,.code,func_8067BE30,284,no +us,.code,func_807315D4,128,no +us,.code,func_806BA240,1324,no +us,.code,func_80601A10,688,no +us,.code,func_806B3D18,140,yes +us,.code,func_80632860,1456,no +us,.code,func_80671E00,340,no +us,.code,func_806449C0,88,yes +us,.code,func_807138CC,476,no +us,.code,func_8060D788,32,yes +us,.code,func_807002AC,144,no +us,.code,func_80738230,112,no +us,.code,func_806FD094,1020,no +us,.code,func_806E5044,472,yes +us,.code,func_80737E30,8,yes +us,.code,func_8060B84C,172,no +us,.code,func_806EE1C4,168,yes +us,.code,func_80684D98,648,no +us,.code,func_8061116C,32,yes +us,.code,func_80669C6C,72,yes +us,.code,func_80676ED0,632,no +us,.code,func_8066EE50,540,no +us,.code,func_806F9608,100,no +us,.code,func_806608FC,1084,no +us,.code,func_806C71D8,8,yes +us,.code,func_806E88AC,44,yes +us,.code,func_806EA628,448,no +us,.code,func_806ACC64,132,yes +us,.code,func_806D24A8,60,yes +us,.code,func_806AD9F4,996,yes +us,.code,func_807095E4,684,no +us,.code,func_806903BC,180,yes +us,.code,func_806A63A8,96,yes +us,.code,func_80653A70,256,yes +us,.code,func_8069D2AC,172,yes +us,.code,func_8065F4F4,252,no +us,.code,areAllKeysTurnedIn,92,yes +us,.code,func_80666A94,12,yes +us,.code,func_806349FC,716,no +us,.code,func_806E34D8,84,yes +us,.code,func_806438B8,620,no +us,.code,func_8066CCD8,248,no +us,.code,func_806D5218,232,yes +us,.code,func_8064F6C0,56,no +us,.code,func_8065CE4C,364,no +us,.code,func_80688A6C,452,no +us,.code,func_806333F8,376,no +us,.code,func_8064DE04,344,no +us,.code,func_8065092C,108,no +us,.code,func_806B9EB4,636,yes +us,.code,func_8060193C,124,no +us,.code,func_8069FDA0,1004,no +us,.code,func_80652B04,196,yes +us,.code,func_806E9BA8,308,no +us,.code,func_8067E278,108,yes +us,.code,func_806A018C,356,no +us,.code,func_80726164,844,no +us,.code,func_80684BB0,488,no +us,.code,func_806E8AF0,56,yes +us,.code,func_8060B700,80,yes +us,.code,func_80704108,40,yes +us,.code,func_807359A0,148,no +us,.code,func_8066BD54,140,no +us,.code,func_80663844,392,yes +us,.code,func_80731D20,328,no +us,.code,func_8069D0D8,32,yes +us,.code,func_80664A38,632,no +us,.code,func_806EE7F4,132,yes +us,.code,func_806C7B00,52,yes +us,.code,func_8064F308,80,yes +us,.code,func_8063253C,16,yes +us,.code,func_806FBB9C,152,yes +us,.code,func_806627CC,108,yes +us,.code,func_806A3B78,244,no +us,.code,func_80642C78,444,no +us,.code,func_80648C50,52,yes +us,.code,func_80641F70,508,no +us,.code,func_80629148,44,yes +us,.code,func_806CF0D0,104,yes +us,.code,func_80652F9C,64,yes +us,.code,func_8067BCC8,32,yes +us,.code,func_80647610,316,no +us,.code,func_8073A7B8,260,no +us,.code,func_8071B2EC,352,no +us,.code,func_806E9CFC,32,yes +us,.code,func_806EFD50,172,yes +us,.code,func_80678814,8,yes +us,.code,func_8060F54C,484,no +us,.code,func_806F007C,64,yes +us,.code,func_80725DC0,276,no +us,.code,func_806FB714,412,no +us,.code,func_80654418,444,no +us,.code,func_8072B324,12,yes +us,.code,func_8069E724,80,no +us,.code,func_8062B3C4,180,no +us,.code,func_80737B48,8,yes +us,.code,func_80668E9C,1772,no +us,.code,func_80604D70,724,no +us,.code,func_806F544C,76,yes +us,.code,func_805FEEB8,76,yes +us,.code,func_80701CA0,1864,no +us,.code,func_806A0F78,144,yes +us,.code,func_80663A0C,116,yes +us,.code,func_806809F0,4388,no +us,.code,func_806D79E4,68,yes +us,.code,func_805FF800,152,yes +us,.code,func_806A7B04,36,yes +us,.code,func_80659320,48,yes +us,.code,func_8072B438,356,no +us,.code,func_80704130,360,no +us,.code,func_8070C2D8,696,no +us,.code,func_80647B74,384,no +us,.code,func_8071B24C,160,no +us,.code,func_806D1420,328,yes +us,.code,func_806D06A0,708,yes +us,.code,func_80678F9C,116,no +us,.code,func_8062F538,264,no +us,.code,func_80630324,120,yes +us,.code,func_80723380,52,yes +us,.code,func_80705F5C,1116,no +us,.code,func_80655CF8,216,no +us,.code,func_806A62D4,116,yes +us,.code,func_8066C610,484,no +us,.code,func_806CD424,1140,no +us,.code,func_8070AC74,688,no +us,.code,func_80658134,452,no +us,.code,func_80723284,52,yes +us,.code,func_807024E0,3732,no +us,.code,func_80652A08,252,yes +us,.code,func_8064BCB0,124,yes +us,.code,func_806DFF34,108,no +us,.code,func_806BDEC8,468,yes +us,.code,func_80654E84,360,no +us,.code,func_8068C080,52,yes +us,.code,func_8060A398,312,no +us,.code,func_80682AB4,832,no +us,.code,func_806921DC,804,no +us,.code,func_8064EC04,92,no +us,.code,func_806BD7B0,1404,no +us,.code,func_80732444,140,no +us,.code,func_80699914,68,yes +us,.code,func_806E67D8,608,yes +us,.code,func_806710E0,384,no +us,.code,func_806AE588,2176,no +us,.code,func_806FDAB8,52,yes +us,.code,func_8072EE7C,256,no +us,.code,func_806D374C,128,yes +us,.code,func_80688638,168,no +us,.code,func_80724C78,44,yes +us,.code,func_80610350,1692,no +us,.code,func_8064B9E0,276,no +us,.code,func_806F0D68,736,no +us,.code,func_8060C430,536,no +us,.code,func_806C6B50,80,yes +us,.code,func_80726DEC,116,no +us,.code,func_8072E22C,132,yes +us,.code,func_807324D0,100,no +us,.code,func_8070D82C,148,no +us,.code,func_80659110,128,yes +us,.code,func_80676220,56,yes +us,.code,func_80738118,88,no +us,.code,func_806DED44,780,no +us,.code,func_8060EC54,44,yes +us,.code,func_8062BB2C,412,no +us,.code,func_806A495C,552,no +us,.code,func_80654BC0,268,no +us,.code,func_806B3680,1456,no +us,.code,func_806E4740,920,no +us,.code,func_8060E930,40,yes +us,.code,func_80737E38,8,yes +us,.code,func_8063A38C,1212,no +us,.code,func_806338B4,64,no +us,.code,func_8063B8D8,728,no +us,.code,func_806644B0,264,no +us,.code,func_8063D9D0,112,no +us,.code,func_806FDB8C,912,no +us,.code,func_80665AAC,32,no +us,.code,func_8068A764,32,no +us,.code,func_8070B324,1224,no +us,.code,func_8060BEA8,220,no +us,.code,func_806FA1A4,864,no +us,.code,func_8067BF84,820,no +us,.code,func_806B1DD4,212,yes +us,.code,func_806A2B08,24,yes +us,.code,func_80664044,348,no +us,.code,func_8071458C,108,yes +us,.code,func_806D6F0C,88,yes +us,.code,func_806CE928,540,no +us,.code,func_80666AA0,12,yes +us,.code,func_8062D094,56,yes +us,.code,func_80669CB4,336,no +us,.code,func_807195D4,480,no +us,.code,func_8070CC54,56,yes +us,.code,func_8072DAA4,196,yes +us,.code,func_8065FD88,304,no +us,.code,func_8072881C,308,no +us,.code,func_806998F0,36,yes +us,.code,func_8064C250,408,no +us,.code,func_806D9184,32,yes +us,.code,func_806EBF34,64,yes +us,.code,func_8067BF4C,56,yes +us,.code,func_8067DCC0,644,no +us,.code,func_8064A194,196,no +us,.code,func_80740100,1704,no +us,.code,func_8070E8F0,2520,no +us,.code,func_8070E8DC,16,yes +us,.code,func_806DABE4,444,yes +us,.code,func_806EC014,48,yes +us,.code,func_8068ECF4,608,no +us,.code,func_8067BC88,32,yes +us,.code,func_8069904C,32,yes +us,.code,func_8066AEE4,92,yes +us,.code,func_806689F0,312,no +us,.code,func_80636C00,312,no +us,.code,func_8064B7C0,20,yes +us,.code,func_805FF5A0,136,yes +us,.code,func_806EE74C,108,yes +us,.code,func_806A7518,232,yes +us,.code,func_807383B0,60,no +us,.code,func_807146A4,60,no +us,.code,func_8073B9B0,176,no +us,.code,func_80688EA4,64,yes +us,.code,func_80688D20,232,no +us,.code,func_806C498C,68,yes +us,.code,func_806EA7E8,92,yes +us,.code,func_80627B58,172,yes +us,.code,func_80671528,724,no +us,.code,func_806010A0,128,yes +us,.code,func_806C13AC,368,no +us,.code,func_8064B150,64,no +us,.code,func_806D9D58,632,no +us,.code,func_80712798,28,yes +us,.code,func_80737C20,212,no +us,.code,func_80685520,488,yes +us,.code,func_8067ACC0,28,yes +us,.code,func_80723C98,52,yes +us,.code,func_8067B288,8,yes +us,.code,func_8071375C,8,yes +us,.code,func_8071268C,36,yes +us,.code,func_806C4948,68,yes +us,.code,func_8069DC80,192,no +us,.code,func_8072E54C,100,no +us,.code,func_806330C4,820,no +us,.code,func_806641A0,548,no +us,.code,func_80665E48,76,no +us,.code,func_806645B8,100,no +us,.code,func_80639FC0,972,no +us,.code,func_8070CDD0,592,no +us,.code,func_806E8F68,264,yes +us,.code,func_806E6234,228,yes +us,.code,func_80662AB4,220,no +us,.code,func_80657974,828,no +us,.code,func_80652374,300,no +us,.code,func_80666AF8,656,no +us,.code,func_806DA7EC,176,yes +us,.code,func_8060A7C0,320,no +us,.code,func_806D9AD4,644,no +us,.code,func_806C49D0,244,yes +us,.code,func_806D6F64,308,no +us,.code,func_806E9DE0,236,no +us,.code,func_8069DA54,444,no +us,.code,func_805FF188,40,yes +us,.code,func_806E2DE8,132,yes +us,.code,func_806D0150,92,yes +us,.code,func_8062AD28,1132,no +us,.code,func_806C7240,8,yes +us,.code,func_80715E94,4220,no +us,.code,func_80654A2C,404,no +us,.code,func_8060F254,760,no +us,.code,func_8071338C,172,no +us,.code,func_8070B05C,684,no +us,.code,func_806686F4,236,no +us,.code,func_80712944,252,no +us,.code,func_806F6204,848,no +us,.code,func_8063039C,40,yes +us,.code,func_806C9D20,92,yes +us,.code,func_806E98F8,108,yes +us,.code,func_80677D58,36,yes +us,.code,func_806348B4,84,no +us,.code,func_806AD84C,352,yes +us,.code,func_806951E8,1340,no +us,.code,func_8068B8FC,52,no +us,.code,func_806DF050,336,yes +us,.code,func_8071D260,44,no +us,.code,func_8060E430,120,yes +us,.code,func_8062B194,140,yes +us,.code,func_8069B010,1004,no +us,.code,func_806FDA8C,44,yes +us,.code,func_806F1048,160,yes +us,.code,func_80723484,1104,no +us,.code,func_8068086C,156,yes +us,.code,func_8060866C,96,yes +us,.code,func_8064F1C4,76,yes +us,.code,func_8066B5C8,44,yes +us,.code,func_80690F30,1664,no +us,.code,func_807278C0,152,no +us,.code,func_80665AE4,308,no +us,.code,func_80676C10,84,no +us,.code,func_8066E6C8,100,yes +us,.code,func_80659190,12,yes +us,.code,func_8066EAEC,84,no +us,.code,func_8064F404,64,yes +us,.code,func_806EFA3C,272,no +us,.code,func_8063CA7C,96,yes +us,.code,func_8060EE60,880,no +us,.code,func_80690470,144,no +us,.code,func_8068A10C,12,yes +us,.code,func_806FB914,580,no +us,.code,func_80690BE8,120,yes +us,.code,func_8063C248,96,yes +us,.code,func_8070C89C,88,yes +us,.code,func_806A1F28,60,yes +us,.code,func_80657508,100,yes +us,.code,func_806E8E00,120,yes +us,.code,func_806C7248,8,yes +us,.code,func_806E5E68,64,yes +us,.code,func_80672CBC,424,no +us,.code,func_8066F4AC,928,no +us,.code,func_8064DF5C,536,no +us,.code,func_806F0930,184,yes +us,.code,func_8064A804,704,no +us,.code,func_8066A988,648,no +us,.code,func_806C9F00,68,yes +us,.code,func_806A2B20,24,yes +us,.code,func_8070E2AC,160,no +us,.code,func_8068450C,32,yes +us,.code,func_8064BFD0,356,no +us,.code,func_806EE700,76,yes +us,.code,func_80674B90,644,no +us,.code,func_807130D4,148,yes +us,.code,func_80650D04,136,no +us,.code,func_8063C2A8,128,no +us,.code,func_80689EA4,64,yes +us,.code,func_80676B38,56,yes +us,.code,func_806E04E0,372,yes +us,.code,func_80707980,2524,no +us,.code,func_806858E8,156,no +us,.code,func_806B11C0,208,yes +us,.code,func_8072ECFC,148,no +us,.code,func_8068EF54,2008,no +us,.code,func_8068842C,52,yes +us,.code,func_80677ED0,216,no +us,.code,func_806D3D5C,136,yes +us,.code,func_806A3E9C,1000,no +us,.code,func_806C8E58,144,no +us,.code,func_8071F444,540,no +us,.code,func_80732B3C,580,no +us,.code,func_8064431C,200,no +us,.code,func_80692500,32,yes +us,.code,func_8070D464,260,no +us,.code,func_80674688,132,no +us,.code,func_806634A4,240,no +us,.code,func_80665C18,456,no +us,.code,func_806DC3A4,108,yes +us,.code,func_806BE674,124,yes +us,.code,func_806FD7A8,236,no +us,.code,func_806E9ECC,192,no +us,.code,func_806FD8E0,112,no +us,.code,func_8066CDD0,40,yes +us,.code,func_806E5E60,8,yes +us,.code,func_806621D0,508,no +us,.code,func_8069B3FC,1120,no +us,.code,func_807273A8,388,no +us,.code,func_8068ABE0,412,no +us,.code,func_806E52D0,440,no +us,.code,func_806E8B28,124,yes +us,.code,func_80608528,180,no +us,.code,func_806877C8,68,yes +us,.code,func_8073CAC0,468,no +us,.code,func_806663F8,36,yes +us,.code,func_8073198C,76,no +us,.code,func_806AD9AC,72,yes +us,.code,func_8065756C,100,yes +us,.code,func_806F9B64,364,no +us,.code,func_80702464,124,no +us,.code,func_806836D0,944,no +us,.code,func_806767E0,44,yes +us,.code,func_8060B750,116,yes +us,.code,func_80731B60,40,yes +us,.code,func_8067ACDC,216,yes +us,.code,func_80729B00,876,no +us,.code,func_80645614,236,yes +us,.code,func_806D0EBC,452,yes +us,.code,func_806E61D0,100,no +us,.code,func_8065E0CC,88,yes +us,.code,func_8072E7DC,140,no +us,.code,func_80672680,92,yes +us,.code,func_80636074,240,no +us,.code,func_806767B4,44,yes +us,.code,func_806D9FD0,848,no +us,.code,func_806FBEF0,1600,no +us,.code,func_806C71B8,8,yes +us,.code,func_8066E2C0,780,no +us,.code,func_806E4C6C,168,no +us,.code,func_8066D250,164,no +us,.code,func_80658C10,188,no +us,.code,func_80659620,80,yes +us,.code,func_8065E040,140,yes +us,.code,func_8065EFF0,324,no +us,.code,func_806ABA6C,300,no +us,.code,func_80692588,36,yes +us,.code,func_8073F328,740,no +us,.code,func_806F142C,112,yes +us,.code,func_8063CE64,168,yes +us,.code,func_80728300,1308,no +us,.code,func_8066ACA4,252,no +us,.code,func_806419F8,128,no +us,.code,func_8060A9BC,72,no +us,.code,func_806A4DDC,920,no +us,.code,func_8069E040,72,yes +us,.code,func_8064216C,152,yes +us,.code,func_80635588,84,yes +us,.code,func_80653684,384,yes +us,.code,func_80687474,120,yes +us,.code,func_806D2C54,88,yes +us,.code,func_80636380,188,no +us,.code,func_8062D0CC,220,no +us,.code,func_806019B8,88,no +us,.code,func_806F9CD0,188,no +us,.code,func_80676A0C,100,no +us,.code,func_806E41B4,56,yes +us,.code,func_8065E81C,552,no +us,.code,func_80697988,868,no +us,.code,func_8062F318,16,yes +us,.code,func_8063A848,124,no +us,.code,func_806E380C,32,yes +us,.code,func_806AD260,748,no +us,.code,func_806D28E4,32,yes +us,.code,func_806DF494,268,no +us,.code,func_805FE634,232,no +us,.code,func_80652BC8,492,yes +us,.code,func_806E2FE8,88,yes +us,.code,func_8064BD2C,300,no +us,.code,func_80712F10,184,yes +us,.code,func_806F37BC,176,no +us,.code,func_80674884,472,no +us,.code,func_8072334C,52,yes +us,.code,func_8072B330,264,yes +us,.code,func_806F7FD0,52,yes +us,.code,func_806B4904,84,yes +us,.code,func_806FFEAC,176,no +us,.code,func_806CEC04,608,no +us,.code,func_806D3224,156,no +us,.code,func_80697CEC,1076,no +us,.code,func_8061159C,12,yes +us,.code,func_80715270,1532,no +us,.code,func_806F00BC,144,yes +us,.code,func_806CC8B8,56,yes +us,.code,func_806E2E6C,60,yes +us,.code,func_806EAE04,92,yes +us,.code,func_8071509C,468,no +us,.code,func_80738BA0,8,yes +us,.code,func_806CEFBC,276,no +us,.code,func_8073749C,324,no +us,.code,func_80650998,108,no +us,.code,func_806A0310,32,yes +us,.code,func_8073B750,224,no +us,.code,func_8071EDEC,184,no +us,.code,func_8062F388,24,yes +us,.code,func_8067E348,136,yes +us,.code,func_806E0050,44,yes +us,.code,func_806C28B8,428,no +us,.code,func_80673A94,228,no +us,.code,func_806A05D4,40,yes +us,.code,func_8064BF58,120,yes +us,.code,func_806D2DC4,216,no +us,.code,func_8066EA64,44,yes +us,.code,func_8062BAE4,72,yes +us,.code,func_806D5834,432,no +us,.code,func_806013A0,72,yes +us,.code,func_806D0A84,864,no +us,.code,func_806D9134,80,yes +us,.code,func_8072A714,200,yes +us,.code,func_8072A7DC,144,yes +us,.code,func_8063DB3C,156,yes +us,.code,func_8070E808,192,no +us,.code,func_806D03BC,76,yes +us,.code,func_806EFC38,280,yes +us,.code,func_80602E6C,1236,no +us,.code,func_806B5A90,2384,no +us,.code,func_80689F2C,84,no +us,.code,func_806AFB58,1940,no +us,.code,func_806E5D60,248,yes +us,.code,func_806A02F0,32,yes +us,.code,func_80654380,152,no +us,.code,func_8070A220,1576,no +us,.code,func_8070CD14,48,yes +us,.code,func_806AB808,612,no +us,.code,func_80667174,12,yes +us,.code,func_8064F028,412,yes +us,.code,func_806D7704,372,no +us,.code,func_80678428,48,yes +us,.code,func_8062FBC8,840,no +us,.code,func_80649BF0,388,no +us,.code,func_806D3FA0,112,yes +us,.code,func_806ECAC4,272,no +us,.code,func_80738BA8,8,yes +us,.code,func_80725B38,108,no +us,.code,func_806EAFEC,8,yes +us,.code,func_80738470,384,no +us,.code,func_806F1378,8,yes +us,.code,func_80610DCC,184,no +us,.code,func_8070D8C0,104,no +us,.code,func_80643274,224,no +us,.code,func_80680774,248,yes +us,.code,func_8064FB64,1404,no +us,.code,func_806C7C94,172,no +us,.code,func_8070CB2C,120,yes +us,.code,func_80659350,120,no +us,.code,func_80688460,44,yes +us,.code,func_806018B4,32,yes +us,.code,playSong,204,no +us,.code,func_806761EC,28,yes +us,.code,func_8067E3D0,108,yes +us,.code,func_806E64D0,236,yes +us,.code,func_806487C4,1164,no +us,.code,func_80681E18,1252,no +us,.code,func_806F54E0,960,no +us,.code,func_806CC14C,68,yes +us,.code,func_806F9518,176,no +us,.code,func_806FF32C,44,yes +us,.code,func_8064D418,1128,no +us,.code,func_8068A4C8,64,yes +us,.code,func_80663040,76,yes +us,.code,func_80706F90,1916,no +us,.code,func_8073AD50,828,no +us,.code,func_80672AFC,32,yes +us,.code,func_806C4AC4,968,no +us,.code,func_8060E7EC,224,yes +us,.code,func_80657CB0,372,no +us,.code,func_80684A00,432,yes +us,.code,func_806874EC,732,no +us,.code,func_8060FA5C,72,no +us,.code,func_80714944,12,yes +us,.code,func_8068A24C,88,yes +us,.code,func_806E9388,112,yes +us,.code,func_80653B70,16,yes +us,.code,func_806D8A64,164,yes +us,.code,func_8062E608,116,yes +us,.code,func_806612B4,76,yes +us,.code,func_8071E028,232,no +us,.code,func_806D2CAC,140,yes +us,.code,func_8060E980,168,yes +us,.code,func_80611690,80,no +us,.code,func_806EA8FC,92,yes +us,.code,func_806D1DEC,164,yes +us,.code,func_80730E18,536,no +us,.code,func_8066BECC,64,yes +us,.code,func_80636D38,452,no +us,.code,func_806FAB20,324,no +us,.code,func_80672C70,76,yes +us,.code,func_806D3AC8,32,yes +us,.code,func_806DE9F4,176,yes +us,.code,func_80717DB4,360,no +us,.code,func_805FF938,116,yes +us,.code,func_806F0B34,228,yes +us,.code,func_806F9470,60,yes +us,.code,func_8068A1B8,20,yes +us,.code,func_8065F678,748,no +us,.code,func_806A2E30,2244,no +us,.code,func_8065A648,12,yes +us,.code,func_80714A68,52,yes +us,.code,func_8068D8C8,276,no +us,.code,func_8064F804,72,yes +us,.code,func_8073B640,112,no +us,.code,func_8073CF00,176,no +us,.code,func_80662B90,1200,no +us,.code,func_806D281C,200,yes +us,.code,func_806F4F50,376,no +us,.code,func_806EBDC4,200,yes +us,.code,func_80664CB0,112,no +us,.code,func_807102AC,308,no +us,.code,func_806D332C,392,no +us,.code,func_8071498C,12,yes +us,.code,func_8071DC90,920,no +us,.code,func_805FF628,56,yes +us,.code,func_80724308,720,no +us,.code,func_80685390,400,no +us,.code,func_806CEE64,116,yes +us,.code,func_8066BA2C,140,no +us,.code,func_8060151C,196,yes +us,.code,func_806022DC,56,no +us,.code,func_8071E3EC,1144,no +us,.code,func_8063524C,540,no +us,.code,func_8062CEA8,492,no +us,.code,func_80737A74,40,no +us,.code,func_806C7BAC,100,yes +us,.code,func_8072EE0C,112,no +us,.code,func_806CA26C,64,yes +us,.code,func_8064DB98,620,no +us,.code,func_806A92B4,3560,no +us,.code,func_80674150,368,no +us,.code,func_806ACF10,236,no +us,.code,func_806DECD4,112,yes +us,.code,func_806F0624,128,yes +us,.code,func_8071AF30,636,no +us,.code,func_806CBE90,636,yes +us,.code,func_80735A50,80,no +us,.code,func_806EE454,336,yes +us,.code,func_80605044,720,no +us,.code,func_806ADFE0,720,no +us,.code,func_8063EA14,4148,no +us,.code,func_806E6B98,592,no +us,.code,func_8060BF84,832,no +us,.code,func_8064B900,224,yes +us,.code,func_806EB5C8,272,no +us,.code,func_806496B0,1344,no +us,.code,func_806A664C,1896,no +us,.code,func_806017E8,96,yes +us,.code,func_8070C9E8,68,yes +us,.code,func_8070D654,132,no +us,.code,func_806A5FA4,96,yes +us,.code,func_806ECF1C,128,yes +us,.code,func_806D3DE4,444,yes +us,.code,func_806D4758,452,no +us,.code,func_806765E8,168,yes +us,.code,func_806ECF9C,180,yes +us,.code,func_80728950,96,yes +us,.code,func_806C9EA0,48,yes +us,.code,func_806EC044,356,yes +us,.code,func_80687C48,128,yes +us,.code,func_80724D28,136,no +us,.code,func_8073CC94,316,no +us,.code,func_806907F0,36,yes +us,.code,func_806766E0,80,yes +us,.code,func_80705B14,28,yes +us,.code,func_8064CC80,188,no +us,.code,func_80678E14,88,yes +us,.code,func_8060E128,128,no +us,.code,func_807145F8,16,yes +us,.code,func_8064F450,624,no +us,.code,func_80666AC4,28,yes +us,.code,func_8064B2AC,196,no +us,.code,func_806FA5A4,512,no +us,.code,gameIsInQuitGameMode,84,yes +us,.code,func_806E0694,84,yes +us,.code,func_8063B4A4,28,yes +us,.code,func_806592B4,108,no +us,.code,func_806F2754,748,no +us,.code,func_806368F0,340,no +us,.code,func_807319D8,44,yes +us,.code,func_80690500,696,no +us,.code,func_806F6E58,132,yes +us,.code,func_80678CC8,272,no +us,.code,func_806D4010,556,yes +us,.code,func_8072F230,632,no +us,.code,func_80689BAC,116,yes +us,.code,func_8069EF50,208,yes +us,.code,func_80735DBC,4604,no +us,.code,func_807381D8,88,no +us,.code,func_806787EC,8,yes +us,.code,func_806F8CFC,92,yes +us,.code,func_806AC07C,2572,no +us,.code,func_806307CC,196,yes +us,.code,func_806C7210,8,yes +us,.code,func_806E84C0,56,yes +us,.code,func_8062C29C,1792,no +us,.code,func_806443E4,1500,no +us,.code,func_8066BDE0,64,yes +us,.code,func_80651BE0,76,no +us,.code,func_80610A88,252,no +us,.code,func_806D6558,1100,no +us,.code,func_80630300,36,yes +us,.code,func_8063C3C0,88,yes +us,.code,func_806FFC04,680,no +us,.code,func_806F3190,1488,no +us,.code,func_8072FDD4,140,no +us,.code,func_80600174,460,no +us,.code,func_806F5EB4,120,no +us,.code,func_80683A80,88,no +us,.code,func_806F1AE0,120,yes +us,.code,func_80675D70,96,no +us,.code,func_806E78F8,8,yes +us,.code,func_807124B8,108,yes +us,.code,func_8073A98C,232,no +us,.code,func_80642500,252,no +us,.code,func_80701C90,16,yes +us,.code,func_80704960,412,no +us,.code,func_8062BA0C,104,yes +us,.code,func_806791DC,16,yes +us,.code,func_8060C758,216,no +us,.code,func_806A3DA0,252,no +us,.code,func_80637B6C,5968,no +us,.code,func_806EC1A8,292,yes +us,.code,func_806CC10C,64,yes +us,.code,func_8071CDE0,784,no +us,.code,getPointerTableFile,812,no +us,.code,func_8073DA30,1312,no +us,.code,func_80611614,116,no +us,.code,func_806015E0,152,yes +us,.code,func_80661AB4,208,no +us,.code,func_8068848C,44,yes +us,.code,func_806D7E88,192,yes +us,.code,func_80602104,64,no +us,.code,func_8070C808,148,no +us,.code,func_80634EDC,56,yes +us,.code,func_80740F48,296,no +us,.code,func_8072B608,404,no +us,.code,func_8071A674,572,no +us,.code,func_80723CCC,700,no +us,.code,func_806C7218,8,yes +us,.code,func_806844EC,32,yes +us,.code,func_80735CF4,200,no +us,.code,func_8068E7B4,508,no +us,.code,func_8071495C,16,yes +us,.code,func_806C9DE0,48,yes +us,.code,func_806EE26C,76,yes +us,.code,func_8069329C,464,no +us,.code,func_80712524,36,yes +us,.code,func_80632084,828,no +us,.code,func_8067C6DC,32,yes +us,.code,func_806C8984,924,no +us,.code,func_8064BAF4,88,no +us,.code,func_8066F400,172,yes +us,.code,func_80708DA4,1440,no +us,.code,func_806787F4,8,yes +us,.code,func_8070F2C8,52,yes +us,.code,func_806FAC64,132,yes +us,.code,func_806F79E0,1520,no +us,.code,func_806F3760,92,yes +us,.code,func_8068EA38,260,no +us,.code,func_8073B5D0,112,no +us,.code,func_8070DA74,264,no +us,.code,func_80635214,56,no +us,.code,func_8072FA14,688,no +us,.code,func_80735624,576,no +us,.code,func_80631B80,12,yes +us,.code,func_8060AA04,84,no +us,.code,func_8062B8E4,296,no +us,.code,func_80676308,48,yes +us,.code,func_806A370C,1132,no +us,.code,func_8066BAB8,140,no +us,.code,func_8070DED4,984,no +us,.code,func_80676CB0,80,no +us,.code,func_80653F68,60,yes +us,.code,func_8065A6F8,16,yes +us,.code,func_80673708,456,no +us,.code,func_8068A404,196,no +us,.code,func_806E0454,140,yes +us,.code,func_80688C30,84,yes +us,.code,func_806B6600,856,no +us,.code,func_8064C9F8,324,no +us,.code,func_8061118C,48,no +us,.code,func_8063DA78,148,no +us,.code,func_806B42A8,1476,no +us,.code,func_8066DD34,1256,no +us,.code,playerCanThrowOrange,292,yes +us,.code,func_8071F1D0,296,no +us,.code,func_80714670,52,yes +us,.code,func_8066FD6C,156,no +us,.code,func_806A6348,96,yes +us,.code,func_806CA5F8,3908,no +us,.code,func_80732730,196,no +us,.code,func_806782C0,40,yes +us,.code,func_8064D880,248,no +us,.code,func_80673324,448,no +us,.code,func_80672A70,140,yes +us,.code,func_806CCC54,2000,no +us,.code,func_8060C724,52,yes +us,.code,func_80652FDC,476,no +us,.code,func_806EF830,276,yes +us,.code,func_807245F0,644,no +us,.code,func_807280C8,196,no +us,.code,func_8071C9E8,1016,no +us,.code,func_806B52DC,480,yes +us,.code,func_80686340,80,yes +us,.code,func_8062BF24,668,no +us,.code,func_80724DB0,152,no +us,.code,func_80712574,168,no +us,.code,func_805FBC5C,424,no +us,.code,func_80665F24,144,no +us,.code,func_806CFE30,76,yes +us,.code,func_806F5FA0,72,yes +us,.code,func_80641A78,136,yes +us,.code,func_8062D26C,64,no +us,.code,func_8062B660,480,no +us,.code,func_806BB874,2060,no +us,.code,func_806D428C,792,yes +us,.code,func_806BA93C,2544,no +us,.code,func_80665E94,144,yes +us,.code,func_80714C08,184,yes +us,.code,func_806A7B28,36,yes +us,.code,func_806EA5CC,52,yes +us,.code,func_8060D768,32,yes +us,.code,func_8067443C,108,no +us,.code,func_8060AB48,224,no +us,.code,func_80661398,80,yes +us,.code,func_8071F078,344,no +us,.code,func_80629190,12,yes +us,.code,func_8068DC54,2080,no +us,.code,func_806D266C,108,yes +us,.code,func_8068B830,116,no +us,.code,func_80708C24,384,no +us,.code,func_806317D4,496,no +us,.code,func_807255A8,1424,no +us,.code,func_806362C4,188,no +us,.code,func_80673A40,84,no +us,.code,func_806625D0,72,yes +us,.code,func_8073E8C0,2340,no +us,.code,func_806594C8,124,yes +us,.code,func_8072C870,168,yes +us,.code,func_8060BCA0,520,no +us,.code,func_806FD9A0,20,yes +us,.code,func_80672E6C,32,yes +us,.code,func_8070D07C,644,no +us,.code,func_806D57F0,68,yes +us,.code,func_80665548,16,yes +us,.code,func_806B3DA4,100,yes +us,.code,func_8064E48C,108,no +us,.code,func_806B48B8,76,yes +us,.code,func_8064D978,544,no +us,.code,func_80645F40,280,no +us,.code,func_80724CA4,132,no +us,.code,func_8073C948,120,no +us,.code,func_80676A70,72,yes +us,.code,func_806B3E7C,192,yes +us,.code,func_80713270,108,yes +us,.code,func_8071C818,252,no +us,.code,func_80737E50,64,no +us,.code,func_80658930,472,no +us,.code,func_8060FAE4,1292,no +us,.code,func_8060D7A8,1172,yes +us,.code,func_8070DCA4,116,no +us,.code,func_80670C5C,680,no +us,.code,func_806F1768,240,no +us,.code,func_80737B2C,28,no +us,.code,func_80665FB4,220,no +us,.code,func_80673B78,188,no +us,.code,func_806D0378,68,yes +us,.code,func_806D61B8,928,no +us,.code,func_8072707C,68,yes +us,.code,func_80732924,8,yes +us,.code,func_8071910C,1224,no +us,.code,func_8067457C,268,no +us,.code,func_8065A570,216,yes +us,.code,func_806C71B0,8,yes +us,.code,func_80689F80,108,yes +us,.code,func_8064F2F0,24,yes +us,.code,func_8071BE04,512,no +us,.code,func_8060F1D0,56,yes +us,.code,func_8060DEA8,32,yes +us,.code,func_80688CC4,48,no +us,.code,func_805FF4D8,108,yes +us,.code,func_806E9070,284,no +us,.code,func_806526E0,176,yes +us,.code,func_80668C30,620,no +us,.code,func_806291A8,12,yes +us,.code,func_806E341C,188,no +us,.code,func_8065214C,172,no +us,.code,func_806E007C,252,yes +us,.code,func_806CFE7C,40,yes +us,.code,func_8073A690,296,no +us,.code,func_8064F6F8,268,no +us,.code,func_80710174,312,no +us,.code,func_806F09F0,324,no +us,.code,func_806E8E78,140,yes +us,.code,func_8066A08C,1272,no +us,.code,func_80676338,228,no +us,.code,func_8072EC94,104,no +us,.code,func_80676788,44,yes +us,.code,func_80634D64,172,yes +us,.code,func_806533C4,284,no +us,.code,func_80712EDC,52,yes +us,.code,func_806C9974,364,no +us,.code,func_8067B2A8,8,yes +us,.code,func_80672630,80,yes +us,.code,func_806A36F4,8,yes +us,.code,func_8071A440,564,no +us,.code,func_80647CF4,136,yes +us,.code,func_8060B8F8,112,yes +us,.code,func_8066AC10,148,no +us,.code,func_806E1864,8,yes +us,.code,func_806DB0C4,744,no +us,.code,func_80738BB0,8,yes +us,.code,func_806F70A8,84,yes +us,.code,func_80738E58,576,no +us,.code,func_806FDF54,292,no +us,.code,func_806F18F4,156,no +us,.code,func_806B0770,216,no +us,.code,func_806B86AC,460,no +us,.code,func_806F5A48,488,no +us,.code,func_80724E48,1888,no +us,.code,func_8068C2F8,88,yes +us,.code,func_80661440,68,yes +us,.code,func_806FB488,8,yes +us,.code,func_8069E5B8,168,yes +us,.code,func_806C9C1C,100,yes +us,.code,func_806B8B20,188,yes +us,.code,func_80709464,96,yes +us,.code,func_8063C450,88,yes +us,.code,func_806B4958,88,yes +us,.code,func_8067BC68,32,yes +us,.code,func_8069D0B8,32,yes +us,.code,func_806C1300,172,yes +us,.code,func_806EB544,132,yes +us,.code,func_8064B798,40,no +us,.code,func_807127F4,60,yes +us,.code,func_8064C814,484,no +us,.code,func_8066164C,12,yes +us,.code,func_806DF280,272,yes +us,.code,func_806D1E90,152,yes +us,.code,func_806355DC,540,no +us,.code,func_806CC5DC,92,yes +us,.code,func_80679334,348,no +us,.code,func_8069D078,32,yes +us,.code,func_806E63B8,280,yes +us,.code,func_8073AA74,140,no +us,.code,func_806BF920,364,no +us,.code,func_805FD088,4880,no +us,.code,func_80687FC8,788,no +us,.code,func_80699284,1604,no +us,.code,func_8069B85C,172,no +us,.code,func_80733B88,172,no +us,.code,func_806A615C,116,yes +us,.code,func_806D4C7C,360,no +us,.code,func_806907E0,16,yes +us,.code,func_806FB480,8,yes +us,.code,func_80603340,272,no +us,.code,func_80688CF4,44,no +us,.code,func_8062D1A8,56,yes +us,.code,func_806B7EA0,1348,no +us,.code,func_8068D264,1636,no +us,.code,func_806C151C,204,yes +us,.code,func_80737F38,8,yes +us,.code,func_80676208,24,yes +us,.code,func_80739098,500,no +us,.code,func_80601484,152,yes +us,.code,func_806109EC,156,no +us,.code,func_80652858,292,yes +us,.code,func_8072FE60,604,no +us,.code,func_80738BB8,180,no +us,.code,func_806E7568,240,yes +us,.code,func_806B3420,608,yes +us,.code,func_80641DA0,456,no +us,.code,func_8062E898,800,no +us,.code,func_8068DAF4,176,no +us,.code,func_8070CD8C,68,yes +us,.code,func_8060A4D0,48,yes +us,.code,func_806D205C,392,no +us,.code,func_806FF01C,296,no +us,.code,func_80715E38,92,yes +us,.code,func_80657F14,236,no +us,.code,func_806C15E8,88,yes +us,.code,func_806898A8,80,yes +us,.code,isIntroStoryPlaying,12,yes +us,.code,func_80718BF4,1304,no +us,.code,func_8066C904,84,no +us,.code,func_80708BB8,108,yes +us,.code,func_8068F72C,2068,no +us,.code,func_80602488,16,yes +us,.code,func_806C9F74,100,yes +us,.code,func_80679200,144,no +us,.code,func_806E7658,180,yes +us,.code,func_807370A4,244,no +us,.code,func_8073A130,372,no +us,.code,func_806A2A10,248,no +us,.code,func_806726DC,532,yes +us,.code,func_806DF390,64,yes +us,.code,func_806F22A8,1196,no +us,.code,func_8060E958,40,yes +us,.code,func_8064409C,640,no +us,.code,func_8072E868,552,no +us,.code,func_806F5F2C,116,yes +us,.code,func_807289E8,4284,no +us,.code,func_8066E5F8,52,yes +us,.code,func_806EB2B8,172,yes +us,.code,func_806F5D80,120,yes +us,.code,func_8060EC80,236,no +us,.code,func_806D3B48,128,yes +us,.code,func_806F0344,128,yes +us,.code,func_8063E6B4,120,no +us,.code,func_80686A5C,668,no +us,.code,func_80653804,620,no +us,.code,func_806011A0,52,yes +us,.code,func_806DAADC,264,yes +us,.code,func_806ED244,476,no +us,.code,func_80634D14,80,yes +us,.code,func_80678824,120,no +us,.code,func_806F58A0,424,no +us,.code,func_8072F8D4,320,yes +us,.code,func_80669E04,648,no +us,.code,func_806E03C8,140,yes +us,.code,func_806DADA0,444,yes +us,.code,func_8071A038,428,no +us,.code,func_8062FF10,1008,no +us,.code,func_806852C4,204,yes +us,.code,func_80687F7C,76,yes +us,.code,func_8063367C,192,no +us,.code,func_805FB5C4,396,no +us,.code,func_80717F1C,356,no +us,.code,func_80633D30,144,no +us,.code,func_8073C8D0,120,no +us,.code,func_80666428,1632,no +us,.code,func_806AA09C,616,no +us,.code,func_806EBC60,144,yes +us,.code,func_8066D2F4,488,no +us,.code,func_807383EC,8,yes +us,.code,func_806E8DB4,76,yes +us,.code,func_806A8158,4044,no +us,.code,func_806A80C0,152,yes +us,.code,func_8066E8E4,172,no +us,.code,func_8066CB88,336,no +us,.code,func_807040E0,40,yes +us,.code,func_8070E8C8,20,yes +us,.code,func_8065051C,48,yes +us,.code,func_805FE71C,152,no +us,.code,func_806C9658,108,yes +us,.code,func_8060FFF0,84,no +us,.code,func_8067B2A0,8,yes +us,.code,func_806AFA60,248,no +us,.code,func_807329AC,400,no +us,.code,func_806DB08C,56,yes +us,.code,__n_freeParam,44,yes +us,.code,func_80676280,64,yes +us,.code,func_8068A508,604,no +us,.code,func_805FF670,400,no +us,.code,func_80732894,144,no +us,.code,func_8060B140,752,no +us,.code,func_80737E9C,8,yes +us,.code,func_80601780,52,yes +us,.code,func_806614D0,80,yes +us,.code,func_806896F0,32,yes +us,.code,func_806E2F3C,172,yes +us,.code,func_807266E8,92,yes +us,.code,func_8060B7F0,92,yes +us,.code,func_806CD898,84,yes +us,.code,func_806EB8CC,152,yes +us,.code,func_807407A8,744,no +us,.code,func_806C7260,8,yes +us,.code,func_8073F60C,528,no +us,.code,func_80714998,16,yes +us,.code,func_806F73A0,1600,no +us,.code,func_80714A38,32,yes +us,.code,func_806623D4,72,yes +us,.code,func_80732158,296,no +us,.code,func_806F4EBC,148,yes +us,.code,func_806AB4EC,796,no +us,.code,func_80646770,520,no +us,.code,func_80688370,44,yes +us,.code,func_80627EA8,92,yes +us,.code,func_8067E69C,40,yes +us,.code,func_80669650,80,no +us,.code,func_80688FC0,164,no +us,.code,func_8067A99C,84,yes +us,.code,func_806E3D14,300,yes +us,.code,func_806E56EC,1344,no +us,.code,func_806FAFE4,564,no +us,.code,func_8060A670,48,yes +us,.code,func_806ACCE8,552,yes +us,.code,func_806C7268,8,yes +us,.code,func_806F3DC8,68,yes +us,.code,func_8068B80C,16,yes +us,.code,func_80690094,252,yes +us,.code,func_80732064,56,no +us,.code,func_806C1E44,1064,no +us,.code,func_8065F49C,88,yes +us,.code,func_8072827C,132,no +us,.code,func_8064384C,108,yes +us,.code,func_80627A00,344,no +us,.code,func_806E6EE0,148,yes +us,.code,func_8067A7EC,120,yes +us,.code,func_806C6BA0,40,yes +us,.code,func_80714B84,132,yes +us,.code,func_8067BA3C,64,yes +us,.code,func_8070E750,184,no +us,.code,func_8073FD90,880,no +us,.code,func_8062E1F8,444,no +us,.code,func_8072B79C,48,no +us,.code,func_8068C350,80,yes +us,.code,func_806C9E40,48,yes +us,.code,func_80661F0C,508,no +us,.code,func_8062F3A0,128,no +us,.code,func_8063CF3C,668,no +us,.code,func_8067E2E4,100,yes +us,.code,func_8068839C,44,yes +us,.code,func_806EA0A4,348,yes +us,.code,func_806615BC,144,yes +us,.code,func_8069E210,640,no +us,.code,func_8062EFA0,176,no +us,.code,func_806CDD24,1104,no +us,.code,func_80649F64,92,yes +us,.code,func_8061130C,64,no +us,.code,func_806883F4,56,yes +us,.code,func_807248B0,228,no +us,.code,func_80630588,328,yes +us,.code,func_80717B64,388,no +us,.code,func_80634CC8,76,yes +us,.code,func_806FFF88,256,no +us,.code,func_806A921C,152,no +us,.code,func_80717760,180,no +us,.code,func_80650B50,108,no +us,.code,func_8068412C,960,yes +us,.code,func_807138A4,40,yes +us,.code,func_806485A0,548,no +us,.code,func_8062D620,1236,no +us,.code,func_806417BC,184,no +us,.code,func_806769A8,100,no +us,.code,gameIsInDKTheatreMode,52,yes +us,.code,func_806E14DC,340,yes +us,.code,func_80739FE0,144,no +us,.code,func_8064B3F8,180,no +us,.code,func_80643C0C,812,no +us,.code,func_8070C27C,92,no +us,.code,func_80636A8C,92,yes +us,.code,func_806F5270,264,no +us,.code,func_80671880,492,no +us,.code,func_8064911C,216,no +us,.code,func_806B7BB8,188,yes +us,.code,func_80660070,1200,no +us,.code,gameIsInSnidesBonusGameMode,52,yes +us,.code,func_806F3E0C,1820,no +us,.code,func_80651904,608,no +us,.code,func_8071720C,504,no +us,.code,func_8061138C,124,yes +us,.code,func_806970CC,184,no +us,.code,func_806DA3E4,244,no +us,.code,func_8062D3E4,48,yes +us,.code,func_80714464,84,yes +us,.code,func_8070E34C,508,no +us,.code,func_806E3E40,884,no +us,.code,func_8064BE80,216,no +us,.code,func_8062DAF4,124,no +us,.code,func_80714D08,916,no +us,.code,func_8073BA60,176,no +us,.code,func_8062B478,440,yes +us,.code,func_80652E58,100,yes +us,.code,func_806E84F8,84,yes +us,.code,func_8062E3B4,404,no +us,.code,func_806C4EE0,124,yes +us,.code,func_806EB744,392,yes +us,.code,func_806E4AD8,404,no +us,.code,func_8066C2B4,24,yes +us,.code,func_806E1334,424,yes +us,.code,func_806E8BA4,88,yes +us,.code,func_806CFF1C,128,yes +us,.code,func_80636A44,72,yes +us,.code,func_8066308C,1048,no +us,.code,func_806A736C,428,yes +us,.code,func_806BC080,100,yes +us,.code,func_8066EB50,164,yes +us,.code,func_80735864,244,no +us,.code,func_806C3F10,1176,no +us,.code,func_806BE09C,1496,no +us,.code,func_806E0D40,620,no +us,.code,func_806F46B0,160,no +us,.code,func_806574B8,80,no +us,.code,func_80660830,204,no +us,.code,func_8073E63C,256,no +us,.code,func_8071E864,448,no +us,.code,func_806D10D0,64,yes +us,.code,func_80600044,60,yes +us,.code,func_806D2BB0,32,yes +us,.code,func_8066A75C,216,no +us,.code,func_8063DA40,56,yes +us,.code,func_80654FEC,620,no +us,.code,func_806500E0,1084,no +us,.code,func_806CC190,244,yes +us,.code,func_806ABB98,252,no +us,.code,func_80737990,188,no +us,.code,func_806303C4,452,yes +us,.code,func_80601258,52,yes +us,.code,func_806ABE3C,524,no +us,.code,func_80731A04,164,yes +us,.code,func_80602C0C,96,yes +us,.code,func_80688EE4,144,yes +us,.code,func_8063CB40,804,no +us,.code,func_806D19A8,440,yes +us,.code,func_805FF0C8,80,yes +us,.code,func_80636784,364,no +us,.code,func_80668520,192,no +us,.code,func_8068C0B4,120,yes +us,.code,func_80689A80,144,yes +us,.code,func_80651708,508,no +us,.code,getFlagBlockAddress,340,no +us,.code,func_806D7510,500,no +us,.code,func_80689EE4,72,yes +us,.code,func_80729EB0,1440,no +us,.code,func_80732D80,44,no +us,.code,func_807149A8,16,yes +us,.code,func_8062B86C,56,yes +us,.code,func_8071BB14,364,no +us,.code,func_805FFEF8,208,yes +us,.code,func_80645A64,312,no +us,.code,func_806EB0C0,184,yes +us,.code,func_8065D994,1708,no +us,.code,func_80658BD0,64,no +us,.code,func_80641BCC,204,no +us,.code,func_8060AC7C,1172,no +us,.code,func_807382A0,128,no +us,.code,func_806A5F44,96,yes +us,.code,func_806F4528,392,no +us,.code,func_8068452C,32,yes +us,.code,func_806C9AE0,316,no +us,.code,func_8071EEE0,252,no +us,.code,func_806D3B08,32,yes +us,.code,func_80635114,256,no +us,.code,func_8068A350,80,yes +us,.code,func_807327F4,160,no +us,.code,func_8070A934,832,no +us,.code,func_8073B08C,324,no +us,.code,func_806C8D2C,180,yes +us,.code,func_80728004,196,no +us,.code,func_8062CA0C,100,yes +us,.code,func_8065D254,1808,no +us,.code,func_80714060,632,no +us,.code,func_807289B0,56,yes +us,.code,func_8069E490,80,yes +us,.code,func_80636014,96,yes +us,.code,func_80611844,8,yes +us,.code,func_806742C0,112,no +us,.code,func_8060A60C,40,yes +us,.code,func_8063254C,228,no +us,.code,func_8065BE74,164,no +us,.code,func_806E0FAC,904,no +us,.code,func_8066BE20,172,yes +us,.code,func_806EFDFC,312,yes +us,.code,func_806E352C,172,yes +us,.code,func_80631BCC,84,yes +us,.code,func_806364C4,268,no +us,.code,func_80658CCC,224,no +us,.code,func_806F2FC0,464,no +us,.code,func_806D25CC,160,yes +us,.code,func_8065CDB0,156,no +us,.code,func_8072752C,332,no +us,.code,func_806B50F4,72,yes +us,.code,func_80722E48,420,no +us,.code,func_806C90C4,512,yes +us,.code,func_806E7C70,388,no +us,.code,func_8070DC40,100,no +us,.code,func_806A6468,268,no +us,.code,func_806F386C,228,no +us,.code,func_8065D170,60,no +us,.code,func_80692520,32,yes +us,.code,func_806C7C10,132,yes +us,.code,func_806D5CCC,1260,yes +us,.code,func_8064E4F8,100,no +us,.code,func_806D1278,84,yes +us,.code,func_80732F10,624,no +us,.code,func_806EB6D8,108,yes +us,.code,func_80654CCC,440,no +us,.code,func_806EACEC,280,yes +us,.code,func_806FBB58,68,yes +us,.code,func_80692E50,1100,no +us,.code,func_80727678,584,no +us,.code,func_806D2AA0,240,yes +us,.code,func_806F1C04,684,no +us,.code,func_80643440,612,no +us,.code,func_8066E664,100,yes +us,.code,func_80661658,72,yes +us,.code,func_80602430,44,no +us,.code,func_806944BC,1164,no +us,.code,func_806CC638,624,no +us,.code,func_8064A258,1452,no +us,.code,func_8067ADB4,88,yes +us,.code,func_806CE7A0,392,no +us,.code,func_806D09E8,108,yes +us,.code,func_806588E0,80,yes +us,.code,func_8060E8EC,68,yes +us,.code,func_80659600,16,yes +us,.code,func_806850D0,320,no +us,.code,func_80649E00,52,yes +us,.code,func_8071D28C,816,no +us,.code,func_80610B84,84,no +us,.code,func_8060DC3C,620,no +us,.code,func_806B88B8,616,no +us,.code,func_806BE6F0,460,no +us,.code,func_8073202C,56,no +us,.code,func_8067AF44,48,yes +us,.code,func_806E17F4,112,yes +us,.code,func_8070C210,108,yes +us,.code,func_806B6DB0,2116,no +us,.code,func_8070D3CC,152,no +us,.code,func_80695724,1068,no +us,.code,func_806C71E0,8,yes +us,.code,func_80732DAC,64,no +us,.code,func_8067A170,108,no +us,.code,func_8060CB74,40,yes +us,.code,func_80636164,172,no +us,.code,func_8065054C,164,yes +us,.code,func_806C4E8C,40,yes +us,.code,func_806F4DC0,180,no +us,.code,func_80738170,104,no +us,.code,func_80678DD8,60,yes +us,.code,func_806D1110,236,yes +us,.code,func_8068780C,1084,no +us,.code,func_806A57C0,168,no +us,.code,func_806F01D8,96,yes +us,.code,func_806C9E10,48,yes +us,.code,func_80652790,200,yes +us,.code,func_806DA89C,176,yes +us,.code,func_806D1270,8,yes +us,.code,func_806F69A8,1200,no +us,.code,func_807313BC,84,yes +us,.code,func_8073BB10,356,no +us,.code,func_806AC048,52,yes +us,.code,func_80732280,212,no +us,.code,func_80737028,124,no +us,.code,func_806C7D40,932,no +us,.code,func_8072A86C,180,no +us,.code,func_8068C2EC,12,yes +us,.code,func_8062A274,212,yes +us,.code,func_806B63E0,44,yes +us,.code,func_8067BDB8,64,yes +us,.code,func_807035C4,652,no +us,.code,func_80685210,180,yes +us,.code,func_8067A864,164,yes +us,.code,func_8069FA40,864,no +us,.code,n_alClose,76,yes +us,.code,func_806C9304,224,no +us,.code,func_806422D8,208,yes +us,.code,func_806C80E4,248,yes +us,.code,func_8066E62C,56,yes +us,.code,func_8066B5F4,360,no +us,.code,func_8060F960,252,no +us,.code,func_8068C12C,224,yes +us,.code,func_80661BF0,580,no +us,.code,func_8068A2FC,80,yes +us,.code,func_806BC1AC,48,yes +us,.code,func_806D87FC,616,no +us,.code,func_80666A88,12,yes +us,.code,func_806E9468,280,yes +us,.code,func_8062BA74,112,no +us,.code,func_806A5174,1612,no +us,.code,func_806C71E8,8,yes +us,.code,func_8062B630,48,no +us,.code,func_806623CC,8,yes +us,.code,func_806B0354,1052,no +us,.code,func_80671260,388,no +us,.code,func_806C93E4,80,yes +us,.code,func_80713764,320,no +us,.code,func_80708574,88,yes +us,.code,func_8065E634,488,no +us,.code,func_806D6B00,1036,yes +us,.code,func_806789E4,288,no +us,.code,func_80633DC0,2472,no +us,.code,func_8060B4D4,136,no +us,.code,func_8066B8C8,92,no +us,.code,func_8070D380,76,yes +us,.code,func_806A1008,180,no +us,.code,func_8065FEB8,440,no +us,.code,func_805FE7B4,72,no +us,.code,func_806C9F44,48,yes +us,.code,func_8073F81C,132,no +us,.code,func_80675C70,256,no +us,.code,func_806BE8BC,2396,no +us,.code,func_80672BD4,92,yes +us,.code,func_8064B868,152,yes +us,.code,func_80609B80,1584,no +us,.code,func_806725E4,76,yes +us,.code,func_80675234,160,no +us,.code,func_8064EB9C,104,no +us,.code,func_80678804,8,yes +us,.code,func_8062DBDC,1124,no +us,.code,func_806A0B74,1028,no +us,.code,func_80610E84,356,no +us,.code,func_8060B6CC,52,yes +us,.code,func_806F006C,8,yes +us,.code,func_80642BF0,136,yes +us,.code,func_806EC708,248,yes +us,.code,func_807132DC,176,no +us,.code,func_8070DB9C,164,no +us,.code,func_8067A1DC,1216,no +us,.code,func_806A7EF0,384,no +us,.code,func_8063A968,2876,no +us,.code,func_806D2330,72,yes +us,.code,func_8067ACB4,12,yes +us,.code,func_806F07CC,172,yes +us,.code,func_806A4284,1752,no +us,.code,func_806E225C,2244,no +us,.code,func_8071C48C,404,no +us,.code,func_8070D300,116,yes +us,.code,func_806011D4,16,yes +us,.code,func_80666F04,196,yes +us,.code,func_806C27DC,220,yes +us,.code,func_806D36CC,128,yes +us,.code,func_806B75F4,40,yes +us,.code,func_80639CD0,588,no +us,.code,func_8064B574,48,yes +us,.code,func_806886E0,608,no +us,.code,func_80713438,380,no +us,.code,func_80631C3C,336,no +us,.code,func_80660520,784,no +us,.code,func_80714A08,32,yes +us,.code,func_8070CAB4,120,yes +us,.code,func_8064D0C4,292,no +us,.code,func_806891D8,120,yes +us,.code,func_806A7B70,36,yes +us,.code,func_806B54BC,1492,no +us,.code,func_80659574,60,no +us,.code,func_806534E0,420,no +us,.code,func_80724994,140,no +us,.code,func_8064AB1C,268,no +us,.code,func_8068B81C,20,yes +us,.code,func_8066E5CC,44,yes +us,.code,func_806C8F8C,312,no +us,.code,func_80648000,620,no +us,.code,func_806CF2EC,172,no +us,.code,func_806BFA8C,296,no +us,.code,func_80675DD0,108,no +us,.code,func_8069084C,228,no +us,.code,func_80655DD0,3528,no +us,.code,func_80649FC0,448,no +us,.code,func_80630890,736,no +us,.code,func_806B1EE8,32,yes +us,.code,func_806A10BC,112,no +us,.code,func_805FC98C,216,no +us,.code,func_8065F614,100,yes +us,.code,func_806EBDAC,24,yes +us,.code,func_8060B110,48,no +us,.code,func_80636210,180,no +us,.code,func_8064C3E8,348,no +us,.code,func_8072D9D4,140,yes +us,.code,func_806DAF5C,304,yes +us,.code,func_806B13B4,2500,no +us,.code,func_80666D88,380,no +us,.code,func_8063495C,160,no +us,.code,func_806CB53C,2312,yes +us,.code,func_807245D8,24,yes +us,.code,func_80601CF0,52,yes +us,.code,func_806EE2B8,412,yes +us,.code,func_806D2744,64,yes +us,.code,func_80636AE8,104,no +us,.code,alSeqpSetSeq,76,yes +us,.code,func_806B3F90,516,no +us,.code,_n_freePVoice,64,yes +us,.code,func_8063D990,64,no +us,.code,func_806E65BC,540,no +us,.code,func_806D3AE8,32,yes +us,.code,func_80655AD0,288,no +us,.code,func_80698120,3788,no +us,.code,func_80645C04,272,yes +us,.code,func_80697230,1740,no +us,.code,func_806111BC,60,yes +us,.code,func_80725ED4,656,no +us,.code,func_8065A660,152,yes +us,.code,getLevelIndex,152,yes +us,.code,func_80703374,592,no +us,.code,func_806531B8,524,no +us,.code,func_8060B7C4,12,yes +us,.code,func_80737630,8,yes +us,.code,func_80648C84,1176,no +us,.code,func_8073F1E4,324,no +us,.code,func_80610268,168,no +us,.code,func_8071C620,504,no +us,.code,func_80715B30,776,no +us,.code,func_8065EA44,84,yes +us,.code,func_806ECA74,80,yes +us,.code,func_80655410,1728,no +us,.code,func_806C5FEC,476,no +us,.code,func_8064E65C,1004,no +us,.code,func_806713E4,324,no +us,.code,func_80717D84,48,no +us,.code,func_80688540,68,yes +us,.code,func_807135B4,424,no +us,.code,func_8066BFF0,236,no +us,.code,func_8062A348,168,yes +us,.code,func_8071ABDC,852,no +us,.code,func_80723428,92,yes +us,.code,func_806A7BB8,36,yes +us,.code,func_8071BC80,388,no +us,.code,func_806EB964,160,yes +us,.code,func_8070B7EC,2580,no +us,.code,func_806FB8B0,100,no +us,.code,func_806CFD68,64,yes +us,.code,func_807380CC,76,no +us,.code,func_806D22A0,32,yes +us,.code,func_806392BC,1576,no +us,.code,func_80663594,556,no +us,.code,func_80662158,40,yes +us,.code,func_8065776C,520,no +us,.code,func_806436E0,364,no +us,.code,func_806E1F8C,256,yes +us,.code,func_8072E1A4,136,yes +us,.code,func_806A1580,808,no +us,.code,func_80729E6C,68,yes +us,.code,func_80678050,624,no +us,.code,func_80632E10,100,no +us,.code,func_806CA540,184,yes +us,.code,func_8073B6B0,160,no +us,.code,func_80690930,248,no +us,.code,func_80737638,748,no +us,.code,func_806EAE60,268,yes +us,.code,func_8066B75C,80,no +us,.code,func_80724874,60,no +us,.code,func_8062A774,92,yes +us,.code,func_80676730,44,yes +us,.code,func_80646DC4,836,no +us,.code,func_8073928C,148,no +us,.code,func_806A2B90,672,no +us,.code,func_8065D008,244,no +us,.code,func_8066785C,352,no +us,.code,func_8060C340,240,yes +us,.code,func_8060E574,240,yes +us,.code,func_807232EC,52,yes +us,.code,func_806307AC,32,yes +us,.code,func_80673D48,660,no +us,.code,func_806BDD90,312,no +us,.code,func_8064C644,196,no +us,.code,func_80735958,72,no +us,.code,func_806D32C0,108,yes +us,.code,func_8070C590,632,no +us,.code,func_8063D2E4,388,no +us,.code,func_8065919C,280,no +us,.code,func_8070D568,236,no +us,.code,func_806C7230,8,yes +us,.code,func_8064EE08,544,no +us,.code,func_80713EA8,8,yes +us,.code,func_806978FC,140,no +us,.code,func_80611160,12,yes +us,.code,func_806E7088,20,yes +us,.code,func_8068FF40,280,no +us,.code,func_8064BE58,40,yes +us,.code,func_80673C34,276,no +us,.code,func_806FD950,80,no +us,.code,func_806F8DC4,240,yes +us,.code,func_80666AAC,12,yes +us,.code,func_8071A8B0,556,no +us,.code,func_806846B4,412,yes +us,.code,func_80674A5C,128,no +us,.code,func_806CCB0C,136,yes +us,.code,func_806EBCF0,188,yes +us,.code,func_8067E724,64,yes +us,.code,func_80600D50,848,no +us,.code,func_80678F64,56,yes +us,.code,func_8072A450,708,no +us,.code,func_8069346C,2644,no +us,.code,func_80730408,1764,no +us,.code,func_805FF118,64,yes +us,.code,func_806D1B60,476,yes +us,.code,func_807311C4,216,no +us,.code,func_806D26D8,108,yes +us,.code,func_8063B758,384,no +us,.code,func_8068B930,132,no +us,.code,func_806DE264,1740,no +us,.code,func_806E4580,180,yes +us,.code,func_80691830,256,yes +us,.code,func_8061032C,36,no +us,.code,func_8067C6FC,32,yes +us,.code,func_806F8D58,108,yes +us,.code,func_8068588C,92,yes +us,.code,func_80650AD8,120,no +us,.code,func_806E4634,268,yes +us,.code,func_8069D424,1292,no +us,.code,func_8073CA04,188,no +us,.code,func_806F3DB0,24,yes +us,.code,func_806A5868,1016,no +us,.code,func_806E7B48,296,yes +us,.code,func_80690814,56,yes +us,.code,func_80723020,612,no +us,.code,func_806BC1E0,3512,no +us,.code,func_8062BCC8,232,no +us,.code,_n_timeToSamplesNoRound,100,yes +us,.code,func_806744A8,212,no +us,.code,func_80688514,44,yes +us,.code,func_8071F758,396,no +us,.code,func_806D9924,28,yes +us,.code,func_806F03C4,608,no +us,.code,func_806EFF34,312,yes +us,.code,func_80678530,164,yes +us,.code,func_806C7238,8,yes +us,.code,func_806E1A50,340,yes +us,.code,func_80684550,104,yes +us,.code,func_8066B9F4,56,yes +us,.code,func_806D12CC,340,yes +us,.code,func_8063FA48,7388,no +us,.code,func_8068A830,40,yes +us,.code,func_80719B88,120,no +us,.code,func_806CC948,40,yes +us,.code,func_8071EFDC,88,no +us,.code,func_807318AC,176,no +us,.code,func_8063CF0C,48,yes +us,.code,func_80658E8C,644,no +us,.code,func_80631EB8,160,no +us,.code,func_8060EE58,8,yes +us,.code,func_806E9964,248,yes +us,.code,func_80647834,480,no +us,.code,func_80712B80,84,yes +us,.code,func_806418E8,180,no +us,.code,func_806C81DC,68,yes +us,.code,func_8064C544,256,no +us,.code,func_80675478,304,no +us,.code,func_8070CC8C,56,yes +us,.code,func_8062BDB0,372,no +us,.code,func_8070C8F4,156,yes +us,.code,func_806755A8,616,no +us,.code,func_806E5EA8,44,yes +us,.code,func_806D7A28,976,no +us,.code,func_806CA2AC,56,yes +us,.code,func_80731B88,408,no +us,.code,func_8067641C,188,no +us,.code,func_80731AA8,116,yes +us,.code,func_806DDAB0,1972,no +us,.code,func_806582F8,532,no +us,.code,func_80667180,312,no +us,.code,func_80693EC0,1532,no +us,.code,func_806D0DE4,216,no +us,.code,func_806EACBC,48,yes +us,.code,func_806B1F08,32,yes +us,.code,func_80712FC8,192,yes +us,.code,func_8070C200,16,no +us,.code,func_806F1EB0,1016,no +us,.code,func_806B7660,68,yes +us,.code,func_80601224,52,yes +us,.code,func_80733A88,256,no +us,.code,func_80641B00,204,no +us,.code,func_806F3BEC,452,no +us,.code,func_8070943C,40,yes +us,.code,func_8067E43C,152,no +us,.code,func_80639968,668,no +us,.code,func_805FBFF4,700,no +us,.code,func_80731784,120,no +us,.code,func_806FA7A4,24,yes +us,.code,func_806025AC,40,yes +us,.code,func_806E527C,84,no +us,.code,func_806A1ABC,8,yes +us,.code,func_8060E1A8,180,yes +us,.code,func_80649E34,304,no +us,.code,func_80735A34,16,no +us,.code,func_805FFE50,168,yes +us,.code,func_806FCC88,1036,no +us,.code,func_8062E67C,540,no +us,.code,func_806CFC90,216,yes +us,.code,func_8067AF74,168,yes +us,.code,func_806357F8,240,no +us,.code,func_8073AB00,584,no +us,.code,func_8066EBF4,120,yes +us,.code,func_806D8FCC,360,yes +us,.code,func_806FBC34,296,no +us,.code,func_8068B8A4,88,no +us,.code,func_806BB400,516,no +us,.code,func_806CFDA8,68,yes +us,.code,func_8067AE58,56,yes +us,.code,func_806A60E4,40,yes +us,.code,func_80669A6C,380,no +us,.code,func_806F2EDC,228,no +us,.code,func_80652F24,120,yes +us,.code,func_807271F4,436,no +us,.code,func_806CA0E8,204,yes +us,.code,func_8060C648,112,yes +us,.code,func_806D72D4,572,no +us,.code,func_806E8A8C,100,yes +us,.code,func_806C9434,412,yes +us,.code,alEvtqFlushType,208,yes +us,.code,func_80714A9C,232,yes +us,.code,func_8068DBA4,176,no +us,.code,func_8070033C,848,no +us,.code,func_8066C7F4,188,no +us,.code,func_80611594,8,yes +us,.code,func_806782E8,212,yes +us,.code,func_8072D714,648,no +us,.code,func_8072DCF4,284,no +us,.code,func_806425FC,332,no +us,.code,func_806B6C88,296,yes +us,.code,func_8066B7AC,72,yes +us,.code,func_8071E110,184,no +us,.code,func_8062E040,440,no +us,.code,func_80682E38,532,no +us,.code,func_8067B290,8,yes +us,.code,func_806A081C,72,yes +us,.code,func_8066BC00,92,no +us,.code,getEEPROMSaveSlot,68,yes +us,.code,func_806B02EC,104,yes +us,.code,func_8063DC58,528,no +us,.code,func_80662618,436,no +us,.code,func_80647A14,352,no +us,.code,func_8072B59C,108,yes +us,.code,func_8068A2AC,88,yes +us,.code,getExitData,364,yes +us,.code,func_8071497C,16,yes +us,.code,func_8065C990,1040,no +us,.code,func_8068613C,516,no +us,.code,func_806E384C,692,no +us,.code,func_806AD7AC,160,yes +us,.code,func_806F4778,1528,no +us,.code,func_806DEAA4,560,no +us,.code,func_80696574,1272,no +us,.code,func_806E8F04,100,yes +us,.code,func_80709890,572,no +us,.code,func_806685E0,276,no +us,.code,func_80726744,1592,no +us,.code,func_8064FA7C,232,no +us,.code,func_8060D0A8,164,yes +us,.code,func_805FF544,92,yes +us,.code,func_8066E854,144,yes +us,.code,func_806D7878,364,yes +us,.code,func_80650C28,112,no +us,.code,func_806D1F28,308,yes +us,.code,func_80647108,104,yes +us,.code,func_806D8B08,1220,no +us,.code,func_8064AC28,1264,no +us,.code,func_8070CC1C,56,yes +us,.code,func_8060FAA4,64,yes +us,.code,func_8073C040,1476,no +us,.code,func_8073E460,476,no +us,.code,func_8066F250,36,yes +us,.code,func_806F7378,40,yes +us,.code,func_80669BE8,132,yes +us,.code,func_80704B20,4084,no +us,.code,func_806728F0,384,yes +us,.code,func_8060E4D0,164,yes +us,.code,func_806EAA44,92,yes +us,.code,func_806593C8,168,no +us,.code,func_8071D5BC,456,no +us,.code,func_806508B4,120,no +us,.code,func_8064F954,40,yes +us,.code,func_807270C0,212,yes +us,.code,func_807189BC,568,no +us,.code,func_80715908,308,no +us,.code,func_806D423C,80,yes +us,.code,func_80627F04,4676,no +us,.code,func_80656B98,704,no +us,.code,func_806358E8,1544,no +us,.code,func_8069A614,316,no +us,.code,func_80711950,640,no +us,.code,func_8060DEC8,608,yes +us,.code,func_80669830,256,no +us,.code,func_806EE7B8,60,yes +us,.code,func_8069D058,32,yes +us,.code,func_8060AA58,224,no +us,.code,func_80717D4C,56,no +us,.code,func_806E2ECC,112,yes +us,.code,func_80659610,16,yes +us,.code,func_806EB194,292,yes +us,.code,func_805FC668,804,no +us,.code,func_806F5C30,180,yes +us,.code,func_80704298,428,no +us,.code,func_806EA460,264,yes +us,.code,func_806EBF74,92,yes +us,.code,func_806EBB44,140,yes +us,.code,func_8065F964,416,no +us,.code,func_80719C00,756,no +us,.code,func_806D7170,200,yes +us,.code,func_806E1E54,312,yes +us,.code,func_80673240,104,no +us,.code,func_8067A69C,112,yes +us,.code,func_80690190,556,no +us,.code,func_8060AC28,12,yes +us,.code,func_80709344,248,yes +us,.code,func_8067DF44,820,no +us,.code,func_806C61C8,872,no +us,.code,func_806B761C,68,yes +us,.code,func_8070F5CC,1164,no +us,.code,func_8067B01C,228,no +us,.code,func_8065D1AC,152,no +us,.code,func_806FE078,3384,no +us,.code,func_806EAB44,328,yes +us,.code,func_8071B520,568,no +us,.code,func_806EC3BC,240,yes +us,.code,func_8062D414,524,no +us,.code,func_806D0A54,48,yes +us,.code,func_806CC364,632,no +us,.code,func_8067AA58,96,yes +us,.code,func_806EE994,200,yes +us,.code,func_80718380,372,no +us,.code,func_8063D288,92,yes +us,.code,func_8070FCCC,928,no +us,.code,func_806F9AF0,116,no +us,.code,func_8067E510,396,no +us,.code,alSepqSetVol,76,yes +us,.code,func_8068A1CC,64,yes +us,.code,func_80689064,176,no +us,.code,n_alInit,108,yes +us,.code,func_80679064,144,yes +us,.code,func_806FA9C0,352,no +us,.code,func_806EA568,100,no +us,.code,func_806B4194,276,yes +us,.code,func_806B8BDC,156,yes +us,.code,func_806D80A8,608,yes +us,.code,func_806C1734,704,no +us,.code,func_80610310,28,no +us,.code,func_8063C4C4,532,no +us,.code,func_80676690,80,yes +us,.code,func_80696A6C,1632,no +us,.code,func_806C2A64,200,yes +us,.code,func_80666FC8,328,yes +us,.code,func_8065D0FC,116,yes +us,.code,func_80671C0C,260,no +us,.code,func_806057F8,11568,no +us,.code,func_80710CA0,1904,no +us,.code,func_8062A944,804,no +us,.code,func_807186C8,756,no +us,.code,func_8069E660,196,yes +us,.code,func_806EA958,92,yes +us,.code,func_80670FA4,316,no +us,.code,func_806787FC,8,yes +us,.code,func_8070DA28,76,no +us,.code,func_807238D4,964,no +us,.code,func_8067B2C0,28,yes +us,.code,func_8068C3A0,520,no +us,.code,func_806925AC,148,yes +us,.code,func_80704444,64,no +us,.code,func_806CD8EC,156,yes +us,.code,func_80714A58,16,yes +us,.code,func_806B9CB0,48,yes +us,.code,func_806F8170,264,yes +us,.code,func_8069DD40,536,no +us,.code,func_80661520,156,no +us,.code,func_8067C6BC,32,yes +us,.code,func_8067618C,68,yes +us,.code,func_806F5378,116,yes +us,.code,func_80724A20,124,no +us,.code,func_8066641C,12,yes +us,.code,func_8066B0EC,12,yes +us,.code,func_80714708,112,no +us,.code,func_8071A1E4,604,no +us,.code,func_80666AE0,12,yes +us,.code,func_80644D50,220,no +us,.code,func_806E7050,56,yes +us,.code,func_80661264,80,no +us,.code,func_8063C7C4,696,no +us,.code,func_80704AFC,36,yes +us,.code,func_806C9830,324,yes +us,.code,func_8070770C,628,no +us,.code,func_806A6134,40,yes +us,.code,func_806EE6B0,80,yes +us,.code,func_8063162C,424,no +us,.code,func_806896D0,32,yes +us,.code,func_80678BBC,268,yes +us,.code,func_806CF42C,140,yes +us,.code,func_806EB4F8,76,yes +us,.code,func_80676260,32,yes +us,.code,func_806115A8,108,no +us,.code,func_806E0BEC,340,yes +us,.code,func_80601728,88,yes +us,.code,func_806111F8,276,no +us,.code,func_80653FA4,988,no +us,.code,func_80730D60,184,yes +us,.code,func_806B3C30,100,yes +us,.code,func_806C4904,68,yes +us,.code,func_806ABC94,424,no +us,.code,func_806F8EDC,728,no +us,.code,func_8063DFEC,140,no +us,.code,func_80641724,152,no +us,.code,func_806C7200,8,yes +us,.code,func_806BB604,536,no +us,.code,func_8060B7D0,28,yes +us,.code,func_8063DB0C,48,yes +us,.code,func_80604C80,60,yes +us,.code,func_805FF1B0,324,no +us,.code,func_806FB3D0,72,no +us,.code,func_806E0178,284,yes +us,.code,func_806D239C,268,yes +us,.code,func_8065E138,1276,no +us,.code,func_8073B900,176,no +us,.code,func_806E9F8C,192,no +us,.code,func_806CD9A0,900,no +us,.code,func_8067B450,120,no +us,.code,func_806E9B3C,108,yes +us,.code,func_8063373C,376,no +us,.code,n_alAudioFrame,548,no +us,.code,func_8065EA98,52,yes +us,.code,func_806D0468,568,no +us,.code,func_8071EA24,332,no +us,.code,func_80713088,76,yes +us,.code,func_806E0294,308,yes +us,.code,func_8071EB70,636,no +us,.code,func_806E7484,228,yes +us,.code,func_80650D8C,148,no +us,.code,func_80737A4C,40,no +us,.code,func_8062A844,8,yes +us,.code,func_80663A80,360,no +us,.code,func_806D2BD0,132,yes +us,.code,func_806CCB94,124,yes +us,.code,func_80656F14,1444,no +us,.code,func_806EBE8C,68,no +us,.code,func_806D2A14,140,yes +us,.code,func_80669588,200,no +us,.code,func_807375E0,32,no +us,.code,func_8070CA2C,68,yes +us,.code,playerCanDive,116,yes +us,.code,func_806EE878,172,yes +us,.code,func_807146E0,20,yes +us,.code,func_806EA8A0,92,yes +us,.code,func_806CF398,148,yes +us,.code,func_80662108,8,yes +us,.code,func_80731E68,452,no +us,.code,func_80737600,8,yes +us,.code,func_806E78E0,24,yes +us,.code,func_8071EEA4,60,no +us,.code,func_80632630,560,no +us,.code,func_806915B0,640,no +us,.code,func_806EE5A4,144,yes +us,.code,func_806F1350,40,yes +us,.code,func_8062DB70,108,no +us,.code,func_80701098,3064,no +us,.code,func_80631D8C,300,no +us,.code,func_80727194,96,no +us,.code,func_80733180,2312,no +us,.code,func_806EAFF4,100,yes +us,.code,func_806B2D64,1724,no +us,.code,func_8072AA80,244,no +us,.code,func_80600454,220,yes +us,.code,func_806B0848,2424,no +us,.code,func_80679178,100,yes +us,.code,func_8066C2D0,832,no +us,.code,func_806524A0,244,yes +us,.code,func_806CFEF4,40,yes +us,.code,func_80714CC0,72,yes +us,.code,func_8068E474,832,no +us,.code,func_8070D6D8,124,yes +us,.code,func_8062B840,44,yes +us,.code,func_80634F14,140,yes +us,.code,func_8067B1E0,88,yes +us,.code,func_806DFFA0,60,yes +us,.code,func_80732930,124,no +us,.code,func_8065C334,1628,no +us,.code,func_806F93EC,64,yes +us,.code,func_806CF9CC,708,no +us,.code,func_80602C6C,116,yes +us,.code,func_8068C5A8,3260,no +us,.code,func_806505F0,148,yes +us,.code,func_8063DBD8,128,yes +us,.code,func_8062CA70,1080,no +us,.code,func_80713DFC,172,yes +us,.code,func_8063D854,208,yes +us,.code,func_8073E800,160,no +us,.code,func_8066466C,456,no +us,.code,func_806E7780,312,yes +us,.code,func_806F1B58,56,no +us,.code,func_80666280,16,yes +us,.code,func_806DC170,564,no +us,.code,func_806A18A8,532,no +us,.code,func_806A6004,144,yes +us,.code,func_806595B0,64,no +us,.code,func_806651FC,452,no +us,.code,func_806FB218,120,yes +us,.code,func_806FB290,40,yes +us,.code,func_8064954C,356,no +us,.code,func_8064B190,116,no +us,.code,func_806C7208,8,yes +us,.code,func_80630DCC,2144,no +us,.code,func_8073B830,208,no +us,.code,func_8064ED68,160,yes +us,.code,func_8073D160,144,no +us,.code,func_80727F20,228,no +us,.code,func_806118FC,152,yes +us,.code,func_80601120,76,yes +us,.code,func_806E7338,332,yes +us,.code,func_806C226C,1392,no +us,.code,func_806BFBF4,5292,no +us,.code,func_806B6958,816,yes +us,.code,func_806E1630,248,yes +us,.code,func_80719EF4,324,no +us,.code,func_806A610C,40,yes +us,.code,func_806E3CEC,40,yes +us,.code,func_806C9ED0,48,yes +us,.code,func_806D69A4,348,yes +us,.code,func_806CA1B4,184,yes +us,.code,func_806DA94C,200,yes +us,.code,func_806338F4,72,no +us,.code,func_806ADDD8,520,no +us,.code,func_806E3C14,36,yes +us,.code,func_80688940,300,yes +us,.code,func_806998C8,32,yes +us,.code,func_806ECE2C,240,yes +us,.code,func_80685F60,476,no +us,.code,func_8060B55C,100,yes +us,.code,func_806F027C,200,yes +us,.code,func_806E9A5C,112,yes +us,.code,func_8072E02C,124,yes +us,.code,func_806E31FC,272,yes +us,.code,func_806C850C,1144,no +us,.code,func_8071321C,84,yes +us,.code,func_806C6530,852,no +us,.code,func_80737B50,8,yes +us,.code,func_8066FE08,1856,no +us,.code,func_806CEB44,192,no +us,.code,func_80703CF8,984,no +us,.code,func_807149C8,52,yes +us,.code,func_8064B514,96,no +us,.code,func_80726E60,128,no +us,.code,func_80737CF4,316,no +us,.code,func_806E709C,404,yes +us,.code,setFlag,288,yes +us,.code,func_80600C68,232,no +us,.code,func_806EAC8C,48,yes +us,.code,func_80691930,176,yes +us,.code,func_80644EC8,504,no +us,.code,func_806A6574,216,no +us,.code,func_80602B60,172,no +us,.code,func_8067A70C,120,yes +us,.code,func_806A5C60,400,no +us,.code,func_8065850C,280,no +us,.code,gameIsInMainMenuMode,20,yes +us,.code,func_8071B89C,80,no +us,.code,func_806B3C94,132,yes +us,.code,func_806E4D14,112,yes +us,.code,func_807158C0,72,no +us,.code,func_806CE174,880,no +us,.code,func_806E6F74,124,yes +us,.code,func_806398E4,132,no +us,.code,func_80662188,72,yes +us,.code,func_806AE2B0,228,yes +us,.code,func_807069A4,1516,no +us,.code,func_80678E6C,248,yes +us,.code,func_8064F84C,264,no +us,.code,func_8072E0A8,252,no +us,.code,func_806F96CC,120,no +us,.code,func_806F149C,32,yes +us,.code,func_806D3B28,32,yes +us,.code,func_80736FB8,112,no +us,.code,func_807094D0,276,no +us,.code,func_8060B49C,56,yes +us,.code,func_806B3E08,116,yes +us,.code,func_806A1FD8,848,no +us,.code,func_8060131C,132,yes +us,.code,func_8062B220,420,no +us,.code,func_806ED420,232,yes +us,.code,func_806E560C,224,no +us,.code,func_806E918C,508,no +us,.code,func_8060A6A0,288,no +us,.code,func_8060AB38,16,yes +us,.code,func_80676BCC,68,no +us,.code,func_80629300,3632,no +us,.code,func_806F014C,56,yes +us,.code,func_80740A90,448,no +us,.code,func_806833DC,756,no +us,.code,func_80729AA4,80,yes +us,.code,func_805FEF10,100,no +us,.code,func_80690A28,136,no +us,.code,func_806E2B20,340,no +us,.code,func_8060E8CC,32,yes +us,.code,func_8062A7D0,56,yes +us,.code,func_807085D0,1512,no +us,.code,func_806E521C,96,yes +us,.code,func_806B1348,108,yes +us,.code,__n_allocParam,96,yes +us,.code,func_806F6EDC,76,yes +us,.code,func_806EBA74,128,yes +us,.code,func_8070F570,92,yes +us,.code,func_806A112C,1108,no +us,.code,func_8062D1E0,140,no +us,.code,func_806E5ED4,204,yes +us,.code,func_80676B70,92,yes +us,.code,func_806F06A4,92,yes +us,.code,func_80603450,5500,no +us,.code,func_8062A228,36,yes +us,.code,func_8060116C,52,yes +us,.code,func_80717CE8,100,no +us,.code,func_806717FC,132,yes +us,.code,func_806EE10C,184,yes +us,.code,func_8064B118,56,yes +us,.code,func_8073CDD0,304,no +us,.code,func_8067C71C,5540,no +us,.code,func_806DF3D0,124,yes +us,.code,func_806FD894,76,no +us,.code,func_8067B4C8,1396,no +us,.code,func_8063C784,64,yes +us,.code,func_80692540,36,yes +us,.code,func_806C9FD8,112,yes +us,.code,func_807103E0,500,no +us,.code,func_8065A708,380,no +us,.code,func_8064B7E8,64,yes +us,.code,func_8068A858,904,no +us,.code,func_80684900,256,yes +us,.code,func_806D2E9C,904,no +us,.code,func_8064E174,692,no +us,.code,func_806D024C,300,yes +us,.code,func_806E884C,52,yes +us,.code,func_8069B908,5268,no +us,.code,func_806A734C,32,yes +us,.code,func_80688320,80,yes +us,.code,func_8070D754,216,no +us,.code,func_80714608,48,yes +us,.code,func_8073D060,224,no +us,.code,func_8060CB9C,32,yes +us,.code,func_8067B280,8,yes +us,.code,func_806907B8,40,yes +us,.code,func_806A1F64,108,yes +us,.code,func_806FEDB0,460,no +us,.code,func_8068AD7C,2704,no +us,.code,func_8072E320,556,no +us,.code,func_806CF4B8,200,no +us,.code,func_806E41EC,916,yes +us,.code,func_80635548,64,no +us,.code,func_80670548,1812,no +us,.code,func_806C71C0,8,yes +us,.code,func_80604BE8,152,yes +us,.code,func_80717100,268,no +us,.code,func_806A7BDC,788,no +us,.code,gameIsInMysteryMenuMinigameMode,52,yes +us,.code,func_8062E548,192,no +us,.code,func_80650794,288,no +us,.code,func_8073E8B4,8,yes +us,.code,func_806F70FC,636,no +us,.code,func_806D3A38,144,yes +us,.code,func_806ECC48,148,yes +us,.code,func_80636448,124,yes +us,.code,func_80611724,12,yes +us,.code,func_8060BB18,200,no +us,.code,func_806C71C8,8,yes +us,.code,func_806F833C,1872,no +us,.code,func_80737AC4,104,no +us,.code,func_8062F640,856,no +us,.code,func_806EA04C,88,yes +us,.code,func_8063A8C4,164,no +us,.code,func_80737198,212,no +us,.code,func_80647D7C,644,no +us,.code,func_8063C418,56,yes +us,.code,func_8060245C,44,yes +us,.code,func_80600530,96,yes +us,.code,func_80650C98,108,no +us,.code,func_8066B4AC,40,yes +us,.code,func_8073A070,192,no +us,.code,func_8067B2B8,8,yes +us,.code,func_806D11FC,60,yes +us,.code,func_80634FA0,120,yes +us,.code,func_8066893C,180,no +us,.code,func_806C4F5C,1660,no +us,.code,func_806017B4,52,yes +us,.code,func_80717404,860,no +us,.code,func_806AE394,500,no +us,.code,func_806D850C,752,yes +us,.code,func_8064EB3C,96,yes +us,.code,func_8073D1F0,2112,no +us,.code,func_80657E24,240,no +us,.code,func_806F0C18,336,no +us,.code,func_806E8880,44,yes +us,.code,func_806A5EAC,152,no +us,.code,func_806639CC,64,yes +us,.code,func_806E5488,388,yes +us,.code,func_80709ACC,248,no +us,.code,func_8068A20C,64,yes +us,.code,func_8067AE0C,76,yes +us,.code,func_806790F4,132,no +us,.code,func_8067B2DC,280,yes +us,.code,func_806D34B4,124,no +us,.code,func_80694D20,1168,no +us,.code,func_8069DC10,112,no +us,.code,func_806DD24C,1576,no +us,.code,func_80714360,52,yes +us,.code,func_8064F210,224,no +us,.code,func_8060ED6C,100,yes +us,.code,func_806794EC,2264,no +us,.code,func_806D97A4,124,yes +us,.code,func_80683158,412,no +us,.code,func_806F9848,680,no +us,.code,func_8068A3A0,100,no +us,.code,func_8072F120,272,no +us,.code,func_806653C0,392,no +us,.code,func_806F1B90,116,yes +us,.code,func_806884B8,44,yes +us,.code,func_8071D94C,552,no +us,.code,func_806F5498,72,yes +us,.code,func_80699958,3260,no +us,.code,func_80703AB0,584,no +us,.code,func_806CD988,24,yes +us,.code,func_8064EC60,264,no +us,.code,func_80682DF4,68,no +us,.code,func_8070DB7C,32,no +us,.code,func_806FB418,96,yes +us,.code,func_8073C9C0,68,no +us,.code,func_806FB490,644,no +us,.code,func_8069E088,388,yes +us,.code,func_80631B8C,64,yes +us,.code,func_806E7900,584,yes +us,.code,func_8072F4A8,244,yes +us,.code,func_806D24E4,232,yes +us,.code,func_80676AB8,128,no +us,.code,func_80646058,1816,no +us,.code,func_80731030,60,no +us,.code,func_80650A70,104,no +us,.code,alSeqpStop,64,yes +us,.code,func_80632F20,84,no +us,.code,func_806BD0CC,152,yes +us,.code,func_8063D608,48,yes +us,.code,func_8067E6E4,32,yes +us,.code,func_8072F59C,824,no +us,.code,func_80737B58,200,no +us,.code,func_8068304C,268,no +us,.code,func_806D2D38,140,yes +us,.code,func_806E6318,80,yes +us,.code,func_806DA320,196,yes +us,.code,func_806C6884,716,no +us,.code,func_8070068C,300,no +us,.code,func_8060C6B8,108,yes +us,.code,func_8063C4A8,28,yes +us,.code,func_806F9744,260,no +us,.code,func_8069E4E0,216,yes +us,.code,func_80737608,40,no +us,.code,func_806E607C,340,yes +us,.code,func_8065297C,140,yes +us,.code,func_806F6644,868,no +us,.code,func_80635018,128,yes +us,.code,func_80642748,252,no +us,.code,func_80690AB0,312,no +us,.code,func_8068A074,152,yes +us,.code,func_80677148,1220,no +us,.code,func_806D0964,132,yes +us,.code,func_805FF898,96,yes +us,.code,func_80672E90,44,no +us,.code,func_806013E8,156,yes +us,.code,func_8064AAC4,88,no +us,.code,func_806B1F50,1384,no +us,.code,func_80686390,1500,no +us,.code,func_8064B260,76,no +us,.code,func_80632FCC,248,no +us,.code,func_80731B20,64,yes +us,.code,func_8072DC7C,120,yes +us,.code,func_8072DB68,276,yes +us,.code,func_8066B7F4,212,no +us,.code,func_8069E018,40,yes +us,.code,func_80663C60,312,yes +us,.code,func_806BD094,56,yes +us,.code,func_80679010,84,no +us,.code,func_806B9CE0,468,yes +us,.code,func_805FE544,240,yes +us,.code,func_806F1250,172,yes +us,.code,func_806A1FD0,8,yes +us,.code,func_8073A900,140,no +us,.code,func_80641874,116,no +us,.code,func_80601EE4,544,no +us,.code,func_8060A1B0,488,no +us,.code,func_80602498,276,no +us,.code,func_80643F38,356,no +us,.code,func_8060EA28,556,yes +us,.code,func_806A7B94,36,yes +us,.code,func_8072EA90,516,no +us,.code,func_8068C20C,224,no +us,.code,func_80636EFC,256,no +us,.code,func_806EA334,300,yes +us,.code,func_8072E2B0,112,yes +us,.code,func_80714A28,16,yes +us,.code,func_806E78B8,40,yes +us,.code,func_80713168,84,yes +us,.code,func_806B1D78,92,yes +us,.code,func_805FF660,16,yes +us,.code,func_806C7250,8,yes +us,.code,func_807040D0,16,yes +us,.code,func_8067A784,104,yes +us,.code,func_805FC2B0,952,no +us,.code,func_80713AA8,152,no +us,.code,func_80705C00,860,no +us,.code,func_806A8070,72,yes +us,.code,func_8060F730,292,no +us,.code,func_8067AC38,124,yes +us,.code,func_8060C830,124,yes +us,.code,func_8067B100,224,no +us,.code,func_80724C2C,76,yes +us,.code,func_806575D0,412,no +us,.code,func_80666AB8,12,yes +us,.code,func_806F1668,256,yes +us,.code,func_8067C2B8,964,no +us,.code,func_80713C8C,368,no +us,.code,func_806CC8F0,48,yes +us,.code,func_806B49B0,1052,no +us,.code,func_806E9CDC,32,yes +us,.code,func_8071D784,456,no +us,.code,func_80733C34,344,no +us,.code,func_8067B2B0,8,yes +us,.code,func_80689DD4,196,no +us,.code,func_8070D970,60,no +us,.code,func_806545D4,468,no +us,.code,func_806BC0E4,100,yes +us,.code,func_8072C670,512,no +us,.code,func_806D9320,1156,no +us,.code,func_806E854C,472,no +us,.code,func_806D2238,104,yes +us,.code,func_806CC284,224,yes +us,.code,func_806EC994,224,yes +us,.code,func_806FB370,96,no +us,.code,func_8063D930,96,no +us,.code,func_80689C20,436,no +us,.code,func_8067889C,328,no +us,.code,func_807314F4,224,no +us,.code,func_806C7258,8,yes +us,.code,func_806D45A4,436,yes +us,.code,func_806E6A38,352,yes +us,.code,func_806B1EC8,32,yes +us,.code,func_806EFB4C,236,yes +us,.code,func_806E8D54,96,yes +us,.code,func_8072DE10,52,yes +us,.code,func_8072C918,1744,no +us,.code,func_80726D7C,68,yes +us,.code,func_806CEED8,228,no +us,.code,func_80712634,36,yes +us,.code,func_806730A4,412,no +us,.code,func_806D3BC8,268,yes +us,.code,func_80631FAC,216,no +us,.code,func_806F8AD4,240,yes +us,.code,func_806F5FE8,84,yes +us,.code,func_806F942C,68,yes +us,.code,func_806A4B84,600,no +us,.code,func_806D22C0,112,yes +us,.code,func_80636B50,176,no +us,.code,func_8060095C,48,yes +us,.code,func_806F6F28,384,yes +us,.code,func_806F53EC,96,yes +us,.code,func_806FD490,792,no +us,.code,func_806A6408,96,yes +us,.code,func_80738400,112,no +us,.code,func_806F0074,8,yes +us,.code,func_80662180,8,yes +us,.code,func_806D1D84,104,yes +us,.code,func_806F1990,136,no +us,.code,func_806D1080,80,yes +us,.code,func_806A9124,248,no +us,.code,func_806FDF1C,56,yes +us,.code,func_8067605C,304,no +us,.code,func_80601D24,448,no +us,.code,func_8068D9DC,280,no +us,.code,func_8064F97C,256,no +us,.code,func_806DF6D4,2144,no +us,.code,func_8064B7D4,20,yes +us,.code,func_80676590,88,yes +us,.code,func_806A60BC,40,yes +us,.code,func_806A285C,428,yes +us,.code,func_80635098,124,yes +us,.code,func_806EC4AC,604,no +us,.code,func_806D0430,56,yes +us,.code,func_8073F8A0,1264,no +us,.code,func_80611534,96,no +us,.code,func_8067881C,8,yes +us,.code,func_8072DA60,68,yes +us,.code,func_806A2B38,72,no +us,.code,func_806E4E88,444,yes +us,.code,func_806493C4,392,no +us,.code,func_8067AB20,160,yes +us,.code,func_8067A09C,212,no +us,.code,func_80686F90,240,yes +us,.code,func_806B8878,32,yes +us,.code,func_8066B4D4,244,no +us,.code,func_80652DB4,164,no +us,.code,func_8065FB64,548,no +us,.code,func_806882DC,68,yes +us,.code,func_80602144,408,no +us,.code,func_806D7FE8,136,yes +us,.code,func_806C7B34,28,yes +us,.code,func_80600340,172,no +us,.code,func_8067C67C,32,yes +us,.code,func_806637C0,132,no +us,.code,func_8064B5A4,500,no +us,.code,func_8068B9B4,120,no +us,.code,func_806E8BFC,48,yes +us,.code,func_8071F034,68,no +us,.code,func_806D4A70,524,no +us,.code,func_8064E55C,100,no +us,.code,func_8073C604,540,no +us,.code,func_80634768,332,no +us,.code,func_806EB178,28,yes +us,.code,func_806DF1A0,224,yes +us,.code,func_80712830,276,yes +us,.code,func_806E208C,180,no +us,.code,func_8071F8E4,412,no +us,.code,func_8064199C,92,no +us,.code,func_80737924,108,no +us,.code,func_80661B84,108,yes +us,.code,func_806F397C,108,yes +us,.code,func_806BA130,272,yes +us,.code,func_80687CC8,128,yes +us,.code,func_8070CD44,72,yes +us,.code,func_80732420,28,no +us,.code,func_806B76B0,384,no +us,.code,func_806ED5C0,240,yes +us,.code,func_8067E784,4932,no +us,.code,func_80689710,224,yes +us,.code,func_806DB670,1172,no +us,.code,func_806EA200,108,yes +us,.code,func_806B640C,500,no +us,.code,func_8063C1EC,92,yes +us,.code,func_80644A18,680,no +us,.code,func_8062C22C,112,yes +us,.code,func_8069900C,32,yes +us,.code,func_8060098C,388,no +us,.code,func_806BB81C,88,yes +us,.code,func_8063BF34,696,no +us,.code,func_8068A810,32,yes +us,.code,func_80689B10,156,yes +us,.code,func_806F4E74,72,yes +us,.code,func_806B24B8,728,no +us,.code,func_80732534,228,no +us,.code,func_806ACA88,376,no +us,.code,func_80679290,164,no +us,.code,func_8065996C,1092,no +us,.code,func_80692640,768,no +us,.code,func_8067470C,376,no +us,.code,func_80650684,100,yes +us,.code,func_80664834,516,no +us,.code,func_8066EABC,48,no +us,.code,func_80685D84,244,yes +us,.code,func_806CC920,40,yes +us,.code,func_806B1290,184,yes +us,.code,func_80724A9C,192,no +us,.code,func_806CFEA4,40,yes +us,.code,func_80732618,280,no +us,.code,func_806E5E58,8,yes +us,.code,func_8067E704,32,yes +us,.code,func_8071DB74,284,no +us,.code,func_806C8EE8,164,yes +us,.code,func_806F0238,68,yes +us,.code,func_8063DED0,284,no +us,.code,func_805FE398,316,no +us,.code,func_807131BC,96,yes +us,.code,func_8062D2F0,244,no +us,.code,func_80611850,172,no +us,.code,gameIsInAdventureMode,52,yes +us,.code,func_806319C4,444,no +us,.code,func_806B1F28,32,yes +us,.code,func_806B904C,404,no +us,.code,func_80658E58,52,yes +us,.code,func_8069CF54,196,no +us,.code,func_80647508,264,yes +us,.code,func_807127B4,64,yes +us,.code,func_8065F5F0,36,no +us,.code,func_8065A884,4636,no +us,.code,func_80718080,116,no +us,.code,func_806D91A4,380,no +us,.code,func_806BFBB4,64,yes +us,.code,func_8067A908,148,yes +us,.code,func_806CCC10,68,no +us,.code,func_8066F1F8,88,yes +us,.code,func_80685B44,576,no +us,.code,func_8062A3F0,900,no +us,.code,func_8073E73C,196,no +us,.code,func_80664D20,1088,no +us,.code,func_80643354,236,no +us,.code,func_80730AEC,628,no +us,.code,func_80655BF0,264,yes +us,.code,func_80677EC8,8,yes +us,.code,func_80692940,1296,no +us,.code,func_806CE4E4,700,no +us,.code,alUnlink,64,yes +us,.code,func_80671A6C,416,no +us,.code,func_8060128C,72,yes +us,.code,func_806C5C20,972,no +us,.code,func_80642844,252,no +us,.code,func_80672EBC,216,no +us,.code,func_806C55E0,1600,no +us,.code,func_80661054,528,no +us,.code,func_80661484,76,yes +us,.code,func_8062C99C,112,no +us,.code,func_80600080,244,yes +us,.code,func_8070D020,92,yes +us,.code,func_806A3700,12,yes +us,.code,func_80636FFC,2928,no +us,.code,func_8072D13C,1496,no +us,.code,func_80723320,44,yes +us,.code,func_8064B828,64,yes +us,.code,func_80733D8C,6296,no +us,.code,func_8073209C,188,no +us,.code,func_806D5008,528,no +us,.code,func_80669930,148,no +us,.code,func_806F5DF8,188,no +us,.code,func_80610BD8,156,no +us,.code,func_806C71A8,8,yes +us,.code,func_805FCA64,48,yes +us,.code,func_806BA8C8,116,yes +us,.code,func_805FEF74,140,yes +us,.code,isFlagSet,184,yes +us,.code,func_806DE930,196,yes +us,.code,func_807383F4,8,yes +us,.code,func_80642204,212,yes +us,.code,func_80739E24,56,no +us,.code,func_8071006C,264,no +us,.code,func_8066C8B0,84,yes +us,.code,func_80634908,84,no +us,.code,func_806732A8,124,no +us,.code,func_8070CA70,68,yes +us,.code,func_806EEA5C,156,yes +us,.code,func_806C71F0,8,yes +us,.code,func_806752D4,172,no +us,.code,func_8064E428,100,no +us,.code,func_806ECBD4,116,yes +us,.code,func_806D1238,56,yes +us,.code,func_8073DF50,792,no +us,.code,func_8067AAB8,104,yes +us,.code,func_806EBBD0,144,yes +us,.code,func_80665ACC,24,yes +us,.code,func_8067A9F0,104,yes +us,.code,func_8060F928,56,no +us,.code,clearGlobalFlags,80,yes +us,.code,func_8072E740,156,yes +us,.code,func_806776A0,1548,no +us,.code,func_80722E00,72,yes +us,.code,func_8062B8A4,64,yes +us,.code,func_806D7DF8,144,yes +us,.code,func_806C9C80,160,yes +us,.code,func_8066E21C,164,yes +us,.code,func_806F966C,96,no +us,.code,func_80659F7C,1524,no +us,.code,func_8071F660,248,no +us,.code,func_806B2790,1484,no +us,.code,func_80627C10,76,yes +us,.code,func_80661E34,144,no +us,.code,func_806CC8A8,16,yes +us,.code,func_806BD170,628,no +us,.code,func_8062A130,248,yes +us,.code,func_806B4DCC,808,yes +us,.code,func_8071586C,84,no +us,.code,func_8060EDD0,136,no +us,.code,alLink,52,yes +us,.code,func_806A05FC,544,no +us,.code,func_806C71F8,8,yes +us,.code,func_8066635C,156,yes +us,.code,func_8067B238,72,yes +us,.code,func_806AA304,4584,no +us,.code,func_806A3C6C,308,no +us,.code,func_807317FC,176,no +us,.code,func_8071E1C8,548,no +us,.code,func_80714638,40,yes +us,.code,func_80644CC0,144,no +us,.code,func_80650ECC,2108,no +us,.code,func_806EA9B4,144,yes +us,.code,func_806116E0,68,no +us,.code,func_8070C990,88,yes +us,.code,func_8064E5C0,156,no +us,.code,func_80659470,88,yes +us,.code,func_80633A1C,788,no +us,.code,func_8069D0F8,436,no +us,.code,func_8067675C,44,yes +us,.code,func_806884E4,48,yes +us,.code,func_806D38AC,396,yes +us,.code,func_806BA76C,348,no +us,.code,func_806EFA08,20,yes +us,.code,func_80687080,348,no +us,.code,func_80645238,988,no +us,.code,func_806FB2B8,184,no +us,.code,func_8062EDA8,160,no +us,.code,func_806CF918,180,no +us,.code,func_806ACC00,100,yes +us,.code,func_8065F134,140,no +us,.code,func_8070DD44,152,no +us,.code,func_80712490,40,yes +us,.code,func_8063DE68,104,no +us,.code,func_80690058,60,yes +us,.code,func_80717930,564,no +us,.code,func_8060E4B0,32,yes +us,.code,func_806450C0,376,no +us,.code,func_806DB3AC,708,no +us,.code,func_806643C4,236,no +us,.code,func_80675EE0,380,no +us,.code,func_806A62B4,32,yes +us,.code,func_805FF378,352,yes +us,.code,func_8064B4AC,104,no +us,.code,func_806C43A8,108,yes +us,.code,func_806BB32C,212,yes +us,.code,func_80737EA4,104,no +us,.code,func_806A6230,132,yes +us,.code,func_8066F274,396,no +us,.code,func_80642E34,400,no +us,.code,func_806613E8,88,yes +us,.code,func_80660D38,788,no +us,.code,func_806739D8,104,no +us,.code,func_8067BCE8,32,yes +us,.code,func_8064BB78,96,yes +us,.code,func_806E2EA8,36,yes +us,.code,func_80604CBC,180,no +us,.code,func_80735AA0,596,no +us,.code,func_806DBB04,1644,no +us,.code,func_80601678,88,yes +us,.code,func_806FEF7C,160,no +us,.code,func_805FCFD8,88,yes +us,.code,func_80689958,296,no +us,.code,func_80713B40,332,no +us,.code,func_80653DF0,184,no +us,.code,func_80632F74,88,no +us,.code,func_806DF44C,72,yes +us,.code,func_80634EA4,56,yes +us,.code,func_80683AD8,1460,no +us,.code,func_80689250,456,no +us,.code,func_8065CDA0,16,yes +us,.code,func_80635EF0,292,no +us,.code,func_806365D0,436,no +us,.code,func_8063D638,540,no +us,.code,func_806E3C38,180,yes +us,.code,func_80688C84,64,no +us,.code,func_806F0184,84,yes +us,.code,func_80611408,300,no +us,.code,func_80644E2C,156,no +us,.code,func_80656E58,188,no +us,.code,func_8066F84C,960,no +us,.code,func_80642480,128,yes +us,.code,func_806C19F4,348,yes +us,.code,func_80731410,228,yes +us,.code,func_80677D80,328,no +us,.code,func_806E4D84,260,yes +us,.code,func_8060E664,132,yes +us,.code,func_8073195C,48,yes +us,.code,func_8066F06C,396,no +us,.code,func_806699C4,168,no +us,.code,func_8066B06C,112,yes +us,.code,func_8067BD28,144,yes +us,.code,func_806BC148,100,yes +us,.code,func_8068A784,44,no +us,.code,func_8065EB10,1248,no +us,.code,func_80639F1C,164,no +us,.code,func_80718188,244,no +us,.code,func_806AEE84,2052,no +us,.code,func_80727958,1480,no +us,.code,func_8065BAA0,980,no +us,.code,func_80676540,80,yes +us,.code,func_8064CD3C,904,no +us,.code,func_806BD3E4,972,no +us,.code,func_80631C20,28,yes +us,.code,func_806D9940,404,yes +us,.code,func_80674ADC,180,no +us,.code,func_807144B8,212,yes +us,.code,func_80689418,696,no +us,.code,func_8064826C,820,no +us,.code,func_806EBED0,100,yes +us,.code,func_80738D20,312,no +us,.code,func_80679490,92,yes +us,.code,func_806DCF60,748,no +us,.code,func_806C2DF4,3224,no +us,.code,func_806E5C2C,72,yes +us,.code,func_806F5CE4,156,yes +us,.code,func_806CA048,160,yes +us,.code,func_806DCA7C,1252,no +us,.code,func_8066ADA0,324,no +us,.code,func_806F4750,40,yes +us,.code,func_80684850,176,yes +us,.code,func_806E0654,64,yes +us,.code,func_8068A118,76,yes +us,.code,func_806F10E8,360,no +us,.code,func_80675810,748,no +us,.code,func_8065CFB8,80,yes +us,.code,func_8065F1C0,732,no +us,.code,func_8060E79C,80,yes +us,.code,func_807007B8,572,no +us,.code,func_80678B04,184,yes +us,.code,func_80627C5C,588,no +us,.code,func_8066EC6C,484,no +us,.code,func_806085DC,144,no +us,.code,func_806011E4,64,yes +us,.code,func_806D37CC,224,yes +us,.code,func_80631F58,84,no +us,.code,func_806D4DE4,548,no +us,.code,func_806C10A0,608,yes +us,.code,func_8063D5AC,92,yes +us,.code,func_80714950,12,yes +us,.code,func_806A7600,1284,no +us,.code,func_8065BF18,808,no +us,.code,func_80653B80,624,no +us,.code,func_8069D930,292,no +us,.code,func_80659544,48,yes +us,.code,func_80723F88,460,no +us,.code,func_806F13C8,100,yes +us,.code,func_806C3A8C,1156,no +us,.code,func_8066B020,76,yes +us,.code,func_806EE02C,64,yes +us,.code,func_806ECCDC,248,yes +us,.code,func_80726DC0,44,yes +us,.code,func_806F50C8,424,no +us,.code,func_80716F10,164,no +us,.code,func_80712A40,320,no +us,.code,func_806E8C2C,296,no +us,.code,func_806012D4,72,yes +us,.code,func_806E7DF4,1104,no +us,.code,func_8073AD48,8,yes +us,.code,func_806D491C,340,yes +us,.code,func_8060E3B0,128,yes +us,.code,func_8066CDF8,236,no +us,.code,func_806DAA14,200,yes +us,.code,func_806E2140,284,yes +us,.code,func_806F8EB4,40,yes +us,.code,func_806F94AC,108,no +us,.code,func_806F91B4,568,no +us,.code,func_80649D74,140,no +us,.code,func_806E07F8,1012,no +us,.code,func_8072FCC4,272,no +us,.code,func_806E9580,644,no +us,.code,func_806EB058,100,yes +us,.code,func_806D21E4,84,yes +us,.code,func_80688F74,76,yes +us,.code,func_8065A654,12,yes +us,.code,func_806C8220,748,no +us,.code,func_807126B0,196,yes +us,.code,func_806049CC,540,no +us,.code,func_8060D2C8,1184,no +us,.code,func_806306D0,60,no +us,.code,func_8070D928,72,no +us,.code,func_8066134C,76,yes +us,.code,func_8072F09C,132,no +us,.code,func_806C7220,8,yes +us,.code,func_8060F854,212,no +us,.code,func_80611730,276,no +us,.code,func_80632E74,172,no +us,.code,func_8069F020,2276,no +us,.code,func_806883C8,44,yes +us,.code,func_8072E5FC,324,no +us,.code,func_80672C30,64,yes +us,.code,func_80659670,764,no +us,.code,func_806DF670,100,yes +us,.code,func_806F603C,456,no +us,.code,func_8067AEFC,72,yes +us,.code,func_806762C0,72,yes +us,.code,func_80676D00,464,no +us,.code,func_8072A920,352,no +us,.code,func_80672E64,8,yes +us,.code,func_806E186C,484,yes +us,.code,func_8060B968,104,no +us,.code,func_8064EA48,108,yes +us,.code,func_80685E78,232,no +us,.code,func_80633570,64,no +us,.code,func_80661EC4,72,yes +us,.code,func_80630B70,604,no +us,.code,func_80602D4C,120,yes +us,.code,func_80681B14,196,no +us,.code,func_806E5FA0,220,yes +us,.code,func_8072DE44,100,yes +us,.code,func_806C8D20,12,yes +us,.code,func_806E84A4,28,yes +us,.code,func_80662838,636,no +us,.code,func_806DF5A0,208,no +us,.code,func_806EB400,180,no +us,.code,func_80712628,12,yes +us,.code,alEvtqPostEvent,384,yes +us,.code,func_8064B204,92,no +us,.code,func_8060C8AC,712,no +us,.code,func_805FCA94,1348,no +us,.code,func_8064BB4C,44,yes +us,.code,func_8072ED90,12,yes +us,.code,func_806E06E8,148,yes +us,.code,func_8066CEE4,876,no +us,.code,func_8064CB3C,324,no +us,.code,func_806AEE08,124,yes +us,.code,func_806D3530,216,yes +us,.code,func_806738D0,264,no +us,.code,func_8070CCC4,80,yes +us,.code,func_806ECDD4,88,yes +us,.code,func_805FE7FC,1672,no +us,.code,func_806ED508,184,yes +us,.code,func_8062EBB8,496,no +us,.code,func_805FB750,148,yes +us,.code,func_80658B08,200,no +us,.code,func_8061134C,64,no +us,.code,func_806D7238,156,yes +us,.code,func_8063C328,104,yes +us,.code,func_806C6BC8,1496,no +us,.code,func_806EEAF8,3384,no +us,.code,func_806003EC,64,yes +us,.code,func_806EFA1C,32,yes +us,.code,func_80672B1C,184,yes +us,.code,func_806725A0,68,yes +us,.code,func_80665DE0,104,yes +us,.code,func_8071C24C,576,no +us,.code,func_806E36B4,344,no +us,.code,func_806EA844,92,yes +us,.code,func_806898F8,96,yes +us,.code,func_806D5300,1264,yes +us,.code,func_8060A634,60,yes +us,.code,gameIsInDKTVMode,84,yes +us,.code,func_8066104C,8,yes +us,.code,func_8072EF7C,288,no +us,.code,func_8073BE54,492,no +us,.code,func_806EC8C4,208,no +us,.code,func_8064774C,232,no +us,.code,func_8064EAB4,136,yes +us,.code,func_80651B64,92,yes +us,.code,func_806F39E8,516,no +us,.code,func_806DC410,1644,no +us,.code,func_8064A180,20,yes +us,.code,func_806CF580,760,no +us,.code,func_805FB300,708,no +us,.code,func_8060E6E8,180,yes +us,.code,func_806791EC,20,yes +us,.code,func_80659DB0,460,no +us,.code,func_80726EE0,412,no +us,.code,func_806696A0,400,no +us,.code,func_806FD9B4,72,no +us,.code,func_8068BBF8,1160,no +us,.code,func_806D0408,40,yes +us,.code,func_806897F0,184,yes +us,.code,func_8066BB44,188,no +us,.code,func_8060D14C,380,no +us,.code,func_80650E20,172,no +us,.code,func_806EB4B4,68,yes +us,.code,func_806998E8,8,yes +us,.code,func_8070DDDC,248,no +us,.code,func_806EE660,80,yes +us,.code,func_807063B8,576,no +us,.code,func_806D27A4,120,yes +us,.code,func_80688E08,96,yes +us,.code,func_8068E9B0,136,no +us,.code,func_807233B4,116,no +us,.code,func_8067BCA8,32,yes +us,.code,func_8072D99C,56,yes +us,.code,func_8062F420,280,no +us,.code,func_806D1D3C,72,yes +us,.code,func_805FE4D4,112,no +us,.code,func_807009F4,240,no +us,.code,func_80713EB0,432,no +us,.code,func_8068696C,240,no +us,.code,func_8072818C,240,no +us,.code,func_80690C60,720,no +us,.code,func_806CF138,436,no +us,.code,func_806D7F48,160,yes +us,.code,func_805FB7E4,352,no +us,.code,func_80700BF4,1188,no +us,.code,func_806CA2E4,604,yes +us,.code,func_806761D0,28,yes +us,.code,func_806E9804,112,yes +us,.code,func_806D5B44,392,yes +us,.code,func_8060A500,268,no +us,.code,func_80600B10,172,no +us,.code,func_80634E10,148,yes +us,.code,func_806C7228,8,yes +us,.code,func_80645D14,556,no +us,.code,func_80737F40,152,no +us,.code,func_80605510,744,no +us,.code,func_806FD9FC,144,no +us,.code,func_8071B44C,212,no +us,.code,func_806F2A40,520,no +us,.code,func_806764D8,104,yes +us,.code,func_80672328,632,no +us,.code,func_80714660,8,yes +us,.code,func_806F1858,156,no +us,.code,func_8067BDF8,56,yes +us,.code,func_806845B8,252,yes +us,.code,func_8066E990,92,no +us,.code,func_806A2B80,16,yes +us,.code,func_8062C1C0,108,yes +us,.code,func_8070F2FC,628,no +us,.code,func_80600BBC,172,no +us,.code,func_806D8070,56,yes +us,.code,func_80671D64,156,no +us,.code,func_80737E90,12,no +us,.code,func_806EA600,40,yes +us,.code,func_8063643C,12,yes +us,.code,func_80600674,732,no +us,.code,func_806CC970,412,no +us,.code,func_807300BC,844,no +us,.code,func_806FF628,308,no +us,.code,func_806960A4,1232,no +us,.code,func_806DD874,572,yes +us,.code,func_80611688,8,yes +us,.code,func_8063E5B4,256,no +us,.code,func_80699070,184,no +us,.code,func_80685708,276,no +us,.code,func_806025D4,1216,no +us,.code,func_806A0864,784,no +us,.code,func_806E3040,444,no +us,.code,func_80645700,456,no +us,.code,func_80605380,400,no +us,.code,func_8067BA7C,492,no +us,.code,func_80671F54,480,no +us,.code,func_80608DA8,920,no +us,.code,func_8069F904,316,no +us,.code,func_807232B8,52,yes +us,.code,func_8073A488,144,no +us,.code,func_8070E548,520,no +us,.code,func_8071827C,260,no +us,.code,func_8070A848,236,no +us,.code,func_80601CC0,48,yes +us,.code,func_806FA7BC,516,no +us,.code,func_8066C958,560,no +us,.code,func_8073A8BC,68,no +us,.code,func_8066E9EC,120,no +us,.code,func_8062F050,712,no +us,.code,func_80658624,700,no +us,.code,func_8069D358,204,no +us,.code,func_80737FD8,68,no +us,.code,func_806CF878,160,yes +us,.code,func_806ED050,172,yes +us,.code,func_805FF9AC,1188,no +us,.code,func_806D2954,192,yes +us,.code,func_80735A44,8,yes +us,.code,func_8068BA2C,460,no +us,.code,func_80689FEC,136,yes +us,.code,func_806FACE8,764,no +us,.code,func_8063E078,92,no +us,.code,func_80738080,76,no +us,.code,func_806E6E7C,100,yes +us,.code,func_8067680C,412,no +us,.code,func_806FDAEC,160,no +us,.code,func_80663FCC,120,yes +us,.code,func_80686E40,336,no +us,.code,func_80661300,76,yes +us,.code,func_80725BA4,540,no +us,.code,func_80639C04,204,no +us,.code,func_806FF358,720,no +us,.code,func_806F6554,240,no +us,.code,func_806E1728,204,yes +us,.code,func_80689E98,12,yes +us,.code,func_8072CFE8,164,no +us,.code,func_80671D10,84,yes +us,.code,func_806822FC,1976,no +us,.code,func_80655258,440,no +us,.code,func_80602DC4,168,no +us,.code,func_8070CBA4,120,yes +us,.code,func_806EE06C,160,yes +us,.code,func_8068A7B0,96,yes +us,.code,func_8063070C,160,no +us,.code,clearPermanentFlags,80,yes +us,.code,func_80665558,12,yes +us,.code,func_807023E8,124,no +us,.code,func_8060B5C0,268,yes +us,.code,func_806F4D70,80,yes +us,.code,func_806D2904,80,yes +us,.code,func_806EAAA0,164,yes +us,.code,func_80611154,12,yes +us,.code,func_807184F4,468,no +us,.code,func_8066AF40,224,no +us,.code,func_8069A750,120,no +us,.code,func_806EBFD0,68,yes +us,.code,func_80600590,228,no +us,.code,func_80737E40,8,yes +us,.code,func_806E9D1C,196,yes +us,.code,func_806291B4,332,no +us,.code,func_80709BC4,1628,no +us,.code,func_807264B0,568,no +us,.code,func_80715A3C,244,no +us,.code,func_806E3B00,276,yes +us,.code,func_806C75A4,1372,no +us,.code,func_8066715C,24,yes +us,.code,func_806F8BC4,236,yes +us,.code,func_8067760C,148,no +us,.code,func_806EAF6C,128,yes +us,.code,alEvtqNextEvent,164,yes +us,.code,func_805FF8F8,64,yes +us,.code,func_806871DC,548,no +us,.code,alEvtqNew,156,yes +us,.code,func_8060188C,40,yes +us,.code,func_8064F358,172,no +us,.code,func_806672B8,1444,no +us,.code,func_80687400,116,yes +us,.code,func_8064B370,136,yes +us,.code,func_8067FAC8,164,no +us,.code,func_806C71A0,8,yes +us,.code,func_806D3CD4,136,yes +us,.code,func_805FF168,32,yes +us,.code,func_8069D018,64,yes +us,.code,func_8063D468,44,yes +us,.code,func_8067ABC0,120,yes +us,.code,func_80737F0C,44,no +us,.code,setIntroStoryPlaying,16,yes +us,.code,func_8069CD9C,440,no +us,.code,func_806E2C74,80,no +us,.code,func_8063D4A4,264,no +us,.code,func_8063BEC0,116,no +us,.code,func_806E9874,132,yes +us,.code,func_80678458,216,yes +us,.code,func_806F8278,196,no +us,.code,func_806EC2CC,240,yes +us,.code,func_8066BC5C,248,no +us,.code,func_8066C0DC,472,no +us,.code,func_806F8A8C,72,yes +us,.code,func_8062EE48,344,no +us,.code,func_80642FC4,688,no +us,.code,func_80602CE0,108,no +us,.code,func_80724154,436,no +us,.code,func_80692564,36,yes +us,.code,func_8072DEA8,388,no +us,.code,func_80717814,284,no +us,.code,func_8062A24C,40,yes +us,.code,func_806F0878,184,yes +us,.code,func_8069AFF0,32,yes +us,.code,func_8070DD18,44,no +us,.code,func_8063E72C,744,no +us,.code,func_806618A0,532,no +us,.code,func_806CBE44,76,yes +us,.code,func_806687E0,216,no +us,.code,func_80700AE4,272,no +us,.code,func_806E382C,32,yes +us,.code,func_806C4EB4,44,yes +us,.code,func_806FF144,488,no +us,.code,func_807385F0,380,no +us,.code,func_80641F68,8,yes +us,.code,func_80658000,308,no +us,.code,func_806522CC,168,yes +us,.code,func_80737A9C,40,no +us,.code,func_80642940,688,no +us,.code,func_806EA26C,108,yes +us,.code,func_80635468,224,no +us,.code,func_805FEE84,52,yes +us,.code,func_806E6FF0,96,yes +us,.code,func_8062F998,560,no +us,.code,func_8071496C,16,yes +us,.code,func_8069E774,2012,no +us,.code,func_80699128,348,no +us,.code,func_806FC530,1880,no +us,.code,func_806DFFDC,116,yes +us,.code,func_80678014,60,yes +us,.code,func_8063C390,48,yes +us,.code,func_8064D1E8,560,no +us,.code,func_806DA4D8,788,no +us,.code,func_8071AADC,256,no +us,.code,func_8060AC34,72,no +us,.code,func_806E7230,264,yes +us,.code,func_80653EA8,192,no +us,.code,func_806EBAF4,80,yes +us,.code,func_8066E72C,296,yes +us,.code,func_806785D4,504,yes +us,.code,func_8062F328,96,no +us,.code,func_8067FB6C,3080,no +us,.code,func_80645B9C,104,no +us,.code,func_80602314,284,no +us,.code,func_80694948,984,no +us,.code,func_8060BBE0,192,no +us,.code,func_8073A3C4,196,no +us,.code,func_8072D08C,176,no +us,.code,func_8066A834,340,no +us,.code,func_8073BC74,336,no +us,.code,func_806018D4,104,no +us,.code,func_80712774,36,yes +us,.code,func_806F12FC,84,yes +us,.code,func_806A6DB4,1432,no +us,.code,func_806E077C,124,yes +us,.code,func_8066B0DC,16,yes +us,.code,func_8073239C,132,yes +us,.code,func_806D01AC,160,yes +us,.code,func_806E8724,296,yes +us,.code,func_806ED0FC,328,yes +us,.code,func_80674330,268,no +us,.code,func_8066EA90,44,yes +us,.code,func_806B2D5C,8,yes +us,.code,func_806F95C8,64,yes +us,.code,func_8067E6C4,32,yes +us,.code,func_80670F04,160,yes +us,.code,func_80685984,448,no +us,.code,func_806E330C,272,yes +us,.code,func_806B7C74,556,no +us,.code,func_806EE924,112,yes +us,.code,func_80677CAC,172,yes +us,.code,func_80666090,496,no +us,.code,func_806B3F3C,84,yes +us,.code,func_80740C50,760,no +us,.code,func_80667110,76,yes +us,.code,func_806A5DF0,188,no +us,.code,func_806D2B90,32,yes +us,.code,func_807149FC,12,yes +us,.code,func_8065EAF4,20,yes +us,.code,func_806787CC,32,yes +us,.code,func_8073243C,8,yes +us,.code,func_806832F4,232,no +us,.code,func_80647218,752,no +us,.code,func_806783BC,108,yes +us,.code,func_8066B434,120,yes +us,.code,func_806C1B50,380,no +us,.code,func_8070FC40,140,no +us,.code,func_807197B4,600,no +us,.code,func_8068A164,84,yes +us,.code,func_806BCF98,252,no +us,.code,func_806FFF5C,44,yes +us,.code,func_806A0330,676,no +us,.code,func_8069A7C8,940,no +us,.code,func_8071F3C0,132,no +us,.code,func_8064C708,268,no +us,.code,func_80681BD8,576,no +us,.code,func_806D7098,216,yes +us,.code,func_80675180,180,no +us,.code,func_8066B424,16,yes +us,.code,func_806423A8,216,no +us,.code,func_806086CC,1756,no +us,.code,func_80672134,500,no +us,.code,func_8073E268,504,no +us,.code,func_80663DA0,556,no +us,.code,playSound,1068,no +us,.code,func_806C9D7C,96,yes +us,.code,func_806D8308,516,no +us,.code,func_8072B7CC,3748,no +us,.code,func_806F2C48,660,no +us,.code,func_806016D0,88,yes +us,.code,func_8073A518,376,no +us,.code,func_806EF944,196,yes +us,.code,func_8070835C,536,no +us,.code,func_8060BA14,260,yes +us,.code,func_80641C98,264,no +us,.code,func_806919E0,2044,no +us,.code,func_8065E124,20,yes +us,.code,func_8062A808,60,yes +us,.code,_n_collectPVoices,108,yes +us,.code,func_80610044,548,no +us,.code,func_80705B30,208,yes +us,.code,func_80665160,156,yes +us,.code,func_807122B4,476,no +us,.code,func_806D2784,32,yes +us,.code,func_8073CFB0,176,no +us,.code,func_806C1640,244,yes +us,.code,func_8063B4C0,664,no +us,.code,func_806C7270,820,no +us,.code,func_806CFDEC,68,yes +us,.code,func_806AF688,984,no +us,.code,func_8066241C,436,no +us,.code,func_8073B560,112,no +us,.code,func_806C92C4,64,yes +us,.code,func_806A2328,1332,no +us,.code,func_8071261C,12,yes +us,.code,func_806B1EA8,32,yes +us,.code,func_80674080,208,no +us,.code,func_8071C914,212,no +us,.code,func_806AD54C,608,yes +us,.code,func_8073A2A4,288,no +us,.code,func_806F1A18,200,yes +us,.code,func_8070D9AC,124,no +us,.code,func_8062A850,244,no +us,.code,func_8062919C,12,yes +us,.code,func_8071B1AC,160,no +us,.code,func_8064BBD8,216,no +us,.code,func_8067880C,8,yes +us,.code,func_805FBE04,496,yes +us,.code,func_806A1AC4,1124,no +us,.code,func_807146F4,20,yes +us,.code,func_806B486C,76,yes +us,.code,func_80722FEC,52,yes +us,.code,func_806B8C78,980,no +us,.code,func_8069AB74,1148,no +us,.code,func_806FBEAC,68,no +us,.code,malloc,364,no +us,.code,func_8072ED9C,112,no +us,.code,func_80676C64,76,yes +us,.code,func_806E88D8,436,no +us,.code,func_806D2378,36,yes +us,.code,func_806E5C74,236,yes +us,.code,func_806E6368,80,yes +us,.code,func_8069DF58,192,no +us,.code,func_80650A04,108,no +us,.code,func_8070FA58,488,no +us,.code,func_807065F8,940,no +us,.code,func_806C7B50,92,no +us,.code,func_8072AB74,1968,no +us,.code,func_8067B298,8,yes +us,.code,func_806F3950,44,yes +us,.code,func_806C9E70,48,yes +us,.code,func_80651C2C,1312,no +us,.code,func_80675AFC,372,no +us,.code,func_80711F90,804,no +us,.code,func_806C2B2C,592,no +us,.code,func_806595F0,16,yes +us,.code,func_806491F4,464,no +us,.code,func_806D9820,260,no +us,.code,func_80731654,304,no +us,.code,func_8066461C,80,yes +us,.code,func_8063CADC,100,yes +us,.code,func_806FFB2C,216,no +us,.code,func_806F1380,72,yes +us,.code,func_80716FB4,332,no +us,.code,func_80685020,176,yes +us,.code,func_80673FDC,164,no +us,.code,func_8067B42C,32,yes +us,.code,func_8070AF24,312,no +us,.code,func_806D59E4,352,yes +us,.code,func_8063C6D8,172,yes +us,.code,func_805FB944,792,no +us,.code,func_80665564,1352,no +us,.code,func_806F0700,204,yes +us,.code,func_80703850,608,no +us,.code,func_80601848,68,yes +us,.code,loadExits,136,yes +us,.code,func_8073876C,1076,no +us,.code,func_8066B924,208,no +us,.code,func_806FBD5C,336,no +us,.code,func_806FF75C,976,no +us,.code,func_806616A0,512,no +us,.code,func_806EC800,196,yes +us,.code,func_8067C69C,32,yes +us,.code,func_806CFECC,40,yes +us,.code,func_80704484,1244,no +us,.code,func_805FF000,24,yes +us,.code,func_8073BDC4,144,no +us,.code,func_80629174,24,yes +us,.code,func_806B8898,32,yes +us,.code,func_80688584,180,yes +us,.code,func_80652594,332,no +us,.code,func_80711BD0,960,no +us,.code,func_80732354,72,yes diff --git a/progress/progress.jetpac.csv b/progress/progress.jetpac.csv new file mode 100644 index 00000000..7137de24 --- /dev/null +++ b/progress/progress.jetpac.csv @@ -0,0 +1,109 @@ +version,section,function,length,matching +us,.code,func_800274C0,80,yes +us,.code,func_80025B70,72,yes +us,.code,func_80029F7C,728,no +us,.code,func_80025FC4,280,no +us,.code,func_8002A8F0,84,no +us,.code,func_8002ABDC,432,no +us,.code,func_8002976C,280,no +us,.code,func_8002466C,564,no +us,.code,func_80025904,348,no +us,.code,func_80025A60,272,no +us,.code,func_80028FC0,164,no +us,.code,func_8002AEC8,52,yes +us,.code,func_80026D48,128,no +us,.code,func_80029AF8,152,yes +us,.code,func_80024390,120,no +us,.code,func_800298C8,100,yes +us,.code,func_80024A4C,64,yes +us,.code,func_800292C4,396,no +us,.code,func_8002A374,444,no +us,.code,func_80027728,1216,no +us,.code,func_80029C1C,496,no +us,.code,func_80024408,564,no +us,.code,func_80028BD0,108,yes +us,.code,func_80029E0C,368,no +us,.code,func_80026A3C,116,yes +us,.code,func_80028CF8,268,no +us,.code,func_80025C40,96,no +us,.code,func_80028E88,312,no +us,.code,func_80029064,328,no +us,.code,func_8002A2DC,152,no +us,.code,func_80024A8C,516,no +us,.code,func_80028C3C,188,yes +us,.code,func_80027510,228,no +us,.code,func_80025368,248,no +us,.code,func_800260DC,572,no +us,.code,func_8002419C,500,no +us,.code,func_80027D64,348,no +us,.code,func_80027108,264,yes +us,.code,func_8002A530,332,no +us,.code,func_80026FE0,48,yes +us,.code,func_8002AD8C,116,no +us,.code,func_80024F64,56,yes +us,.code,func_8002992C,96,yes +us,.code,func_800250A0,200,yes +us,.code,func_80027410,108,yes +us,.code,func_80027060,168,yes +us,.code,func_800254B8,284,no +us,.code,func_8002463C,48,yes +us,.code,func_800291AC,88,yes +us,.code,func_80027480,64,yes +us,.code,func_80026318,1828,no +us,.code,func_80028E04,132,no +us,.code,func_8002998C,364,no +us,.code,func_80028544,152,no +us,.code,func_80025F48,124,no +us,.code,func_80028340,172,no +us,.code,func_80028B54,124,no +us,.code,func_8002A944,48,yes +us,.code,func_80025BB8,136,no +us,.code,func_8002A6C0,152,yes +us,.code,func_80025168,512,no +us,.code,func_800285DC,88,yes +us,.code,func_8002A67C,68,yes +us,.code,func_8002A758,408,no +us,.code,func_8002A2AC,48,no +us,.code,func_80029884,68,no +us,.code,func_80024E70,180,no +us,.code,func_800286D0,640,no +us,.code,func_800289EC,360,no +us,.code,func_80024000,412,no +us,.code,func_8002A974,352,no +us,.code,func_800275F4,308,no +us,.code,func_8002AE00,148,no +us,.code,func_80027010,72,yes +us,.code,func_80024F9C,260,no +us,.code,func_8002A254,88,yes +us,.code,func_80029450,156,no +us,.code,func_80029B90,140,yes +us,.code,func_80026CEC,92,no +us,.code,func_80026AB0,500,no +us,.code,func_800248A0,72,yes +us,.code,func_8002AAD4,264,no +us,.code,func_80027EC0,1152,no +us,.code,func_800283EC,344,no +us,.code,func_80026DC8,536,no +us,.code,func_80027BE8,380,no +us,.code,func_80027210,64,yes +us,.code,func_80029640,300,no +us,.code,func_80027250,224,no +us,.code,func_80024C90,184,yes +us,.code,func_8002AEFC,404,no +us,.code,func_80028950,156,no +us,.code,func_80024D48,296,no +us,.code,func_80025CB0,664,no +us,.code,func_80028634,156,no +us,.code,func_800294EC,340,no +us,.code,func_80027380,72,yes +us,.code,func_800273C8,72,yes +us,.code,func_80026CA4,72,yes +us,.code,func_800255D4,300,yes +us,.code,func_80027330,80,yes +us,.code,func_80025CA0,16,yes +us,.code,func_80025700,516,no +us,.code,func_80029204,192,yes +us,.code,func_800248E8,356,no +us,.code,func_80024F24,64,no +us,.code,func_8002AE94,52,yes +us,.code,func_80025460,88,yes diff --git a/progress/progress.menu.csv b/progress/progress.menu.csv new file mode 100644 index 00000000..459fe278 --- /dev/null +++ b/progress/progress.menu.csv @@ -0,0 +1,115 @@ +version,section,function,length,matching +us,.code,func_80028C18,8,yes +us,.code,func_8002A36C,252,yes +us,.code,func_8003264C,736,no +us,.code,func_8002AB80,340,no +us,.code,func_8003292C,1572,no +us,.code,func_80025B64,432,no +us,.code,func_80026250,64,yes +us,.code,func_800270E0,1292,no +us,.code,func_80031980,220,no +us,.code,func_80026B28,644,no +us,.code,func_8002AD50,120,no +us,.code,func_8002C584,176,yes +us,.code,func_8002ECE8,304,no +us,.code,func_80030258,232,no +us,.code,func_80027E60,212,yes +us,.code,func_8002EF68,796,no +us,.code,func_800297A8,16,yes +us,.code,func_8002E420,1176,no +us,.code,func_80025D44,72,yes +us,.code,func_800291CC,1500,no +us,.code,func_80030250,8,yes +us,.code,func_80026290,24,yes +us,.code,func_8002AB28,88,no +us,.code,func_80024BFC,180,yes +us,.code,func_8002D520,716,no +us,.code,func_80026874,692,no +us,.code,func_80024EF0,956,no +us,.code,func_80026DAC,636,no +us,.code,func_80028C20,284,yes +us,.code,func_8002F980,520,no +us,.code,func_80032550,252,yes +us,.code,func_8002D8AC,816,no +us,.code,func_80025FB4,524,no +us,.code,func_8002FC1C,284,yes +us,.code,func_80024154,148,yes +us,.code,func_800322D0,52,yes +us,.code,func_80029EF8,400,yes +us,.code,func_80025E04,432,yes +us,.code,func_8002AA98,144,no +us,.code,func_8002B708,2496,no +us,.code,func_800241E8,60,yes +us,.code,func_80027F34,12,yes +us,.code,func_8002F6C8,148,yes +us,.code,func_80026684,108,yes +us,.code,func_800317E8,408,no +us,.code,func_80027E10,80,yes +us,.code,func_8002DEE8,192,yes +us,.code,func_8002FE08,180,yes +us,.code,func_8002A638,1120,no +us,.code,func_8002F8EC,148,yes +us,.code,func_8002A468,464,yes +us,.code,func_8002CFA4,1404,no +us,.code,func_8002C634,744,no +us,.code,func_8002CB18,1164,no +us,.code,func_8002FB88,148,no +us,.code,func_800266F0,276,yes +us,.code,func_8003155C,652,no +us,.code,func_800275FC,316,no +us,.code,func_80024CB0,576,no +us,.code,func_8002907C,152,no +us,.code,func_800261C0,144,yes +us,.code,func_8002DBDC,780,no +us,.code,func_80026804,112,yes +us,.code,func_80030A90,388,no +us,.code,func_80025AE0,8,yes +us,.code,func_8002ADC8,2368,no +us,.code,func_8002F284,1092,no +us,.code,func_80028D3C,364,no +us,.code,func_800252AC,2100,no +us,.code,func_80030340,1364,no +us,.code,func_80027738,208,no +us,.code,func_80031B08,1308,no +us,.code,func_800275EC,16,yes +us,.code,func_80029AAC,264,yes +us,.code,func_80024000,188,no +us,.code,func_800244EC,668,no +us,.code,func_8002FEBC,916,no +us,.code,func_80025D8C,120,yes +us,.code,func_8002C91C,508,no +us,.code,func_80027028,184,yes +us,.code,func_80027FAC,1820,no +us,.code,func_80025AF0,116,no +us,.code,func_800240BC,152,yes +us,.code,func_80032304,456,no +us,.code,func_80029D30,456,no +us,.code,func_80027DEC,32,yes +us,.code,func_8002E8B8,1072,no +us,.code,func_800324CC,132,no +us,.code,func_80032024,684,no +us,.code,func_80029BB4,380,no +us,.code,func_8002ACD4,124,no +us,.code,func_8002C0C8,1212,no +us,.code,func_80027808,384,no +us,.code,func_8002D7EC,192,yes +us,.code,func_80024788,1140,no +us,.code,func_80028EA8,468,yes +us,.code,func_8002FD38,208,yes +us,.code,func_80025D14,48,yes +us,.code,func_80030894,508,no +us,.code,func_80027988,1124,no +us,.code,func_80031A5C,172,no +us,.code,func_80028834,996,no +us,.code,func_80024224,500,no +us,.code,func_8002EE18,336,yes +us,.code,func_8002F75C,400,no +us,.code,func_8002DFA8,1144,no +us,.code,func_8002A088,740,no +us,.code,func_800286C8,364,no +us,.code,func_80029114,184,yes +us,.code,func_80027F40,108,yes +us,.code,func_800262A8,988,no +us,.code,func_800297B8,756,no +us,.code,func_80024418,212,yes +us,.code,func_80030C14,2376,no diff --git a/progress/progress.minecart.csv b/progress/progress.minecart.csv new file mode 100644 index 00000000..d43c418f --- /dev/null +++ b/progress/progress.minecart.csv @@ -0,0 +1,26 @@ +version,section,function,length,matching +us,.code,func_8002430C,1116,no +us,.code,func_80024B00,888,no +us,.code,func_80024768,296,yes +us,.code,func_80024E78,344,no +us,.code,func_80024914,492,no +us,.code,func_80027E04,228,no +us,.code,func_80024254,184,no +us,.code,func_80027778,1404,no +us,.code,func_80026DA8,2512,no +us,.code,func_8002835C,912,no +us,.code,func_800286EC,1188,no +us,.code,func_800241A0,180,yes +us,.code,func_800253C0,4656,no +us,.code,func_80027CF4,172,no +us,.code,func_80026C54,340,yes +us,.code,func_80027EE8,468,no +us,.code,func_800280BC,672,no +us,.code,func_80024000,220,yes +us,.code,func_800240DC,196,yes +us,.code,func_80027DA0,100,no +us,.code,func_800265F0,1404,no +us,.code,func_80026B6C,232,yes +us,.code,func_8002538C,52,yes +us,.code,func_80024FD0,956,no +us,.code,func_80024890,132,no diff --git a/progress/progress.multiplayer.csv b/progress/progress.multiplayer.csv new file mode 100644 index 00000000..0671fa7b --- /dev/null +++ b/progress/progress.multiplayer.csv @@ -0,0 +1,32 @@ +version,section,function,length,matching +us,.code,func_800245B0,316,no +us,.code,func_8002698C,60,yes +us,.code,func_80025654,320,no +us,.code,func_80025B48,416,no +us,.code,func_800253C8,60,yes +us,.code,func_80025CE8,668,no +us,.code,func_80026E20,336,no +us,.code,func_80024254,168,no +us,.code,func_80025FFC,152,no +us,.code,func_80026BD8,360,no +us,.code,func_800246EC,748,no +us,.code,func_80025608,76,no +us,.code,func_80024CA4,1472,no +us,.code,func_80026B0C,204,yes +us,.code,func_8002452C,132,yes +us,.code,func_80025794,948,no +us,.code,func_800242FC,204,yes +us,.code,func_80025264,276,no +us,.code,func_800243C8,212,no +us,.code,func_80024000,500,no +us,.code,func_80025404,516,no +us,.code,func_80026D40,224,yes +us,.code,func_800268C0,28,yes +us,.code,func_80026094,2092,no +us,.code,func_800269C8,324,no +us,.code,func_800249D8,716,no +us,.code,func_800241F4,96,no +us,.code,func_80025378,80,no +us,.code,func_80025F84,120,no +us,.code,func_800268DC,176,no +us,.code,func_8002449C,144,yes diff --git a/progress/progress.race.csv b/progress/progress.race.csv new file mode 100644 index 00000000..3613e099 --- /dev/null +++ b/progress/progress.race.csv @@ -0,0 +1,114 @@ +version,section,function,length,matching +us,.code,func_800274C0,496,no +us,.code,func_8002D2C0,120,no +us,.code,func_8002DD70,48,yes +us,.code,func_80027AF8,56,yes +us,.code,func_8002CAC8,292,no +us,.code,func_800282D8,252,no +us,.code,func_800294A8,740,no +us,.code,func_80024634,92,yes +us,.code,func_8002D40C,148,no +us,.code,func_8002578C,24,yes +us,.code,func_8002F420,112,no +us,.code,func_8002DF38,656,no +us,.code,func_8002E960,76,no +us,.code,func_8002B6C8,44,yes +us,.code,func_80026B20,392,no +us,.code,func_8002B6F4,120,yes +us,.code,func_8002DE78,192,no +us,.code,func_8002D338,40,yes +us,.code,func_80027710,368,no +us,.code,func_80024690,4320,no +us,.code,func_8002A7F8,1652,no +us,.code,castleCarRaceSetup,76,yes +us,.code,func_80027BD0,144,no +us,.code,func_8002DC24,204,no +us,.code,func_8002D72C,40,yes +us,.code,func_80026F04,1468,no +us,.code,func_80029F88,248,no +us,.code,func_80026EE4,32,yes +us,.code,func_8002AE6C,48,yes +us,.code,func_8002F490,756,no +us,.code,func_8002D360,172,no +us,.code,func_80026354,1996,no +us,.code,func_80027C60,136,yes +us,.code,func_8002F0AC,468,no +us,.code,func_8002DDA0,216,no +us,.code,func_8002D224,156,no +us,.code,func_8002DB90,148,yes +us,.code,func_80028E20,564,no +us,.code,func_80027CE8,1024,no +us,.code,func_8002E1C8,256,no +us,.code,sealRaceSetup,32,yes +us,.code,func_8002ECD4,48,yes +us,.code,func_8002F280,132,no +us,.code,func_8002E2C8,412,no +us,.code,func_8002E9AC,76,no +us,.code,func_8002BBD0,92,yes +us,.code,func_8002D0B0,76,yes +us,.code,func_80026D2C,440,no +us,.code,func_800283D4,108,no +us,.code,func_8002F304,104,yes +us,.code,func_80027B30,160,no +us,.code,func_8002BDDC,268,no +us,.code,func_8002F90C,68,yes +us,.code,func_800292B0,32,yes +us,.code,func_80026004,76,yes +us,.code,func_80029054,604,no +us,.code,func_8002978C,2044,no +us,.code,func_8002CFF0,116,yes +us,.code,func_800292D0,440,no +us,.code,func_80025FDC,40,yes +us,.code,setupRaceOnMapLoad,204,yes +us,.code,func_800280E8,496,no +us,.code,func_8002BCD4,264,no +us,.code,func_8002E464,32,yes +us,.code,func_8002A0AC,1444,no +us,.code,func_8002A080,44,yes +us,.code,func_800276B0,96,no +us,.code,func_80024000,1588,no +us,.code,func_8002597C,1312,no +us,.code,func_80026CA8,132,yes +us,.code,func_8002F36C,180,no +us,.code,func_8002D0FC,76,yes +us,.code,func_8002B180,920,no +us,.code,func_8002B610,184,no +us,.code,func_8002C63C,304,no +us,.code,func_80026050,72,yes +us,.code,func_800261E0,372,no +us,.code,func_8002DCF0,128,no +us,.code,func_80027880,160,no +us,.code,func_80025770,28,yes +us,.code,func_8002F950,448,no +us,.code,func_8002CBEC,1028,no +us,.code,func_8002B76C,504,no +us,.code,func_80028AD0,848,no +us,.code,func_8002AE9C,740,no +us,.code,func_8002F04C,96,no +us,.code,func_8002E8EC,116,no +us,.code,func_8002BEE8,612,no +us,.code,func_8002B518,248,no +us,.code,func_8002F784,392,no +us,.code,func_8002E9F8,528,no +us,.code,func_8002EDD4,632,no +us,.code,func_8002D148,220,no +us,.code,func_8002D754,36,yes +us,.code,func_8002B964,620,no +us,.code,func_80026098,328,no +us,.code,func_80028440,1680,no +us,.code,func_8002D524,520,no +us,.code,func_8002BC2C,132,no +us,.code,func_8002ED04,208,yes +us,.code,func_8002E484,448,no +us,.code,func_80025E9C,320,no +us,.code,func_80027920,472,no +us,.code,initializeCastleCarRace,424,no +us,.code,func_8002C14C,412,no +us,.code,func_8002C76C,860,no +us,.code,func_800257A4,472,no +us,.code,func_8002DA68,296,yes +us,.code,func_8002C2E8,852,no +us,.code,func_8002BCB0,36,no +us,.code,func_8002D778,752,no +us,.code,func_8002E644,680,no +us,.code,func_8002D4A0,132,yes diff --git a/progress/progress.total.csv b/progress/progress.total.csv new file mode 100644 index 00000000..fbb0fb8e --- /dev/null +++ b/progress/progress.total.csv @@ -0,0 +1,4216 @@ +version,section,function,length,matching +us,.code,func_80680908,232,yes +us,.code,func_806C4414,1264,no +us,.code,func_8072E5B0,76,yes +us,.code,func_8069902C,32,yes +us,.code,func_806436A4,60,yes +us,.code,func_80688E68,60,yes +us,.code,func_8071F2F8,200,no +us,.code,func_806D3608,196,yes +us,.code,func_80666290,204,yes +us,.code,func_8071D0F0,368,no +us,.code,func_8073726C,560,no +us,.code,func_80651BC0,32,yes +us,.code,func_8071B8EC,552,no +us,.code,func_8060B430,108,no +us,.code,func_8060042C,40,yes +us,.code,func_8066EB40,16,yes +us,.code,func_806EDFF8,52,yes +us,.code,func_8067E764,32,yes +us,.code,func_80738C6C,180,no +us,.code,func_805FFFC8,124,yes +us,.code,func_80652EBC,104,yes +us,.code,func_80666AEC,12,yes +us,.code,func_8066BF0C,228,yes +us,.code,func_80643B24,232,no +us,.code,func_806ED6B0,2376,no +us,.code,func_806EB364,156,yes +us,.code,func_806FA504,160,no +us,.code,func_806679BC,2916,no +us,.code,func_806F8CB0,76,yes +us,.code,func_80679DC4,728,no +us,.code,func_8068408C,160,yes +us,.code,func_80724B5C,208,no +us,.code,func_8073801C,100,no +us,.code,func_80647170,168,no +us,.code,func_80697184,160,yes +us,.code,func_80658DAC,172,no +us,.code,func_806B513C,416,yes +us,.code,func_80610C74,344,no +us,.code,func_8064C134,284,no +us,.code,func_8067E4D4,60,yes +us,.code,func_806458C8,412,no +us,.code,func_8066A584,200,no +us,.code,func_806688B8,132,no +us,.code,func_8071B758,324,no +us,.code,func_80646978,1100,no +us,.code,func_807105D4,1740,no +us,.code,func_806E8244,608,no +us,.code,func_80687EE0,156,no +us,.code,func_80663BE8,120,no +us,.code,func_806BF218,1800,no +us,.code,func_80712548,44,yes +us,.code,func_80695BAC,1272,no +us,.code,func_8060956C,1556,no +us,.code,func_80738320,144,no +us,.code,func_806EBA04,112,yes +us,.code,n_alSynNew,1540,no +us,.code,func_8066D4DC,1636,no +us,.code,func_8062AC68,192,no +us,.code,func_80675E3C,164,no +us,.code,func_80712BD4,776,no +us,.code,func_8060A900,188,yes +us,.code,func_8065D964,48,yes +us,.code,func_806E35D8,220,yes +us,.code,func_806506E8,172,yes +us,.code,func_807149B8,16,yes +us,.code,func_80686CF8,328,no +us,.code,func_806E6DE8,148,yes +us,.code,func_8068581C,112,yes +us,.code,func_805FD030,88,yes +us,.code,func_806521F8,212,no +us,.code,func_8063D1D8,176,yes +us,.code,func_8063D494,16,yes +us,.code,func_8063BBB0,784,no +us,.code,func_80650BBC,108,no +us,.code,func_80605314,108,no +us,.code,func_806C1CCC,376,yes +us,.code,func_8062D2AC,68,yes +us,.code,func_80662110,72,yes +us,.code,func_80687D50,400,no +us,.code,func_80672F94,272,no +us,.code,func_8065D244,16,yes +us,.code,func_806B91E0,2768,no +us,.code,func_806A6094,40,yes +us,.code,func_806335B0,204,no +us,.code,func_806F8004,364,yes +us,.code,func_8066FC0C,352,no +us,.code,func_8066A64C,272,no +us,.code,func_806951B0,56,yes +us,.code,func_8069D098,32,yes +us,.code,func_806A7B4C,36,yes +us,.code,func_8065C240,244,no +us,.code,func_806C2D7C,120,yes +us,.code,func_806C8DE0,120,no +us,.code,func_806323C0,380,no +us,.code,func_80698FEC,32,yes +us,.code,func_806C55D8,8,yes +us,.code,func_80689114,196,no +us,.code,func_80714778,460,no +us,.code,func_806B7830,904,no +us,.code,func_8068EB3C,440,no +us,.code,n_alSynDelete,28,yes +us,.code,func_8071C004,584,no +us,.code,func_80675380,248,no +us,.code,func_80732DEC,292,no +us,.code,func_8067B3F4,56,yes +us,.code,func_8067BD08,32,yes +us,.code,func_8060F208,76,no +us,.code,func_807180F4,48,yes +us,.code,func_8066DB40,500,no +us,.code,func_80700088,548,no +us,.code,func_80695B50,92,yes +us,.code,func_80677FA8,108,no +us,.code,func_806734E4,548,no +us,.code,func_8063E0D4,1248,no +us,.code,func_806E1BA4,404,no +us,.code,func_806E93F8,112,yes +us,.code,func_80719A0C,380,no +us,.code,func_80668B28,264,no +us,.code,func_80718124,100,yes +us,.code,func_8073C820,176,no +us,.code,func_806E1D38,284,yes +us,.code,func_806547A8,644,no +us,.code,func_8073E8A0,20,no +us,.code,func_806A61D0,96,yes +us,.code,func_80600950,12,yes +us,.code,func_80711410,1344,no +us,.code,func_806D1568,1088,no +us,.code,func_806E9ACC,112,yes +us,.code,func_806ACFFC,612,no +us,.code,func_8060CBBC,1260,no +us,.code,func_805FF158,16,yes +us,.code,func_8067AE90,108,yes +us,.code,func_8065FB04,96,yes +us,.code,func_8063393C,224,no +us,.code,func_80674E14,876,no +us,.code,func_806F14BC,428,no +us,.code,func_806C71D0,8,yes +us,.code,func_8065EACC,40,yes +us,.code,func_805FF018,24,yes +us,.code,func_806EA2D8,92,yes +us,.code,func_806CFF9C,436,no +us,.code,func_8060C2C4,124,yes +us,.code,func_806B83E4,712,no +us,.code,func_806F9D8C,1048,no +us,.code,func_805FF2F4,132,yes +us,.code,func_806EE634,44,yes +us,.code,func_8067BE30,284,no +us,.code,func_807315D4,128,no +us,.code,func_806BA240,1324,no +us,.code,func_80601A10,688,no +us,.code,func_806B3D18,140,yes +us,.code,func_80632860,1456,no +us,.code,func_80671E00,340,no +us,.code,func_806449C0,88,yes +us,.code,func_807138CC,476,no +us,.code,func_8060D788,32,yes +us,.code,func_807002AC,144,no +us,.code,func_80738230,112,no +us,.code,func_806FD094,1020,no +us,.code,func_806E5044,472,yes +us,.code,func_80737E30,8,yes +us,.code,func_8060B84C,172,no +us,.code,func_806EE1C4,168,yes +us,.code,func_80684D98,648,no +us,.code,func_8061116C,32,yes +us,.code,func_80669C6C,72,yes +us,.code,func_80676ED0,632,no +us,.code,func_8066EE50,540,no +us,.code,func_806F9608,100,no +us,.code,func_806608FC,1084,no +us,.code,func_806C71D8,8,yes +us,.code,func_806E88AC,44,yes +us,.code,func_806EA628,448,no +us,.code,func_806ACC64,132,yes +us,.code,func_806D24A8,60,yes +us,.code,func_806AD9F4,996,yes +us,.code,func_807095E4,684,no +us,.code,func_806903BC,180,yes +us,.code,func_806A63A8,96,yes +us,.code,func_80653A70,256,yes +us,.code,func_8069D2AC,172,yes +us,.code,func_8065F4F4,252,no +us,.code,areAllKeysTurnedIn,92,yes +us,.code,func_80666A94,12,yes +us,.code,func_806349FC,716,no +us,.code,func_806E34D8,84,yes +us,.code,func_806438B8,620,no +us,.code,func_8066CCD8,248,no +us,.code,func_806D5218,232,yes +us,.code,func_8064F6C0,56,no +us,.code,func_8065CE4C,364,no +us,.code,func_80688A6C,452,no +us,.code,func_806333F8,376,no +us,.code,func_8064DE04,344,no +us,.code,func_8065092C,108,no +us,.code,func_806B9EB4,636,yes +us,.code,func_8060193C,124,no +us,.code,func_8069FDA0,1004,no +us,.code,func_80652B04,196,yes +us,.code,func_806E9BA8,308,no +us,.code,func_8067E278,108,yes +us,.code,func_806A018C,356,no +us,.code,func_80726164,844,no +us,.code,func_80684BB0,488,no +us,.code,func_806E8AF0,56,yes +us,.code,func_8060B700,80,yes +us,.code,func_80704108,40,yes +us,.code,func_807359A0,148,no +us,.code,func_8066BD54,140,no +us,.code,func_80663844,392,yes +us,.code,func_80731D20,328,no +us,.code,func_8069D0D8,32,yes +us,.code,func_80664A38,632,no +us,.code,func_806EE7F4,132,yes +us,.code,func_806C7B00,52,yes +us,.code,func_8064F308,80,yes +us,.code,func_8063253C,16,yes +us,.code,func_806FBB9C,152,yes +us,.code,func_806627CC,108,yes +us,.code,func_806A3B78,244,no +us,.code,func_80642C78,444,no +us,.code,func_80648C50,52,yes +us,.code,func_80641F70,508,no +us,.code,func_80629148,44,yes +us,.code,func_806CF0D0,104,yes +us,.code,func_80652F9C,64,yes +us,.code,func_8067BCC8,32,yes +us,.code,func_80647610,316,no +us,.code,func_8073A7B8,260,no +us,.code,func_8071B2EC,352,no +us,.code,func_806E9CFC,32,yes +us,.code,func_806EFD50,172,yes +us,.code,func_80678814,8,yes +us,.code,func_8060F54C,484,no +us,.code,func_806F007C,64,yes +us,.code,func_80725DC0,276,no +us,.code,func_806FB714,412,no +us,.code,func_80654418,444,no +us,.code,func_8072B324,12,yes +us,.code,func_8069E724,80,no +us,.code,func_8062B3C4,180,no +us,.code,func_80737B48,8,yes +us,.code,func_80668E9C,1772,no +us,.code,func_80604D70,724,no +us,.code,func_806F544C,76,yes +us,.code,func_805FEEB8,76,yes +us,.code,func_80701CA0,1864,no +us,.code,func_806A0F78,144,yes +us,.code,func_80663A0C,116,yes +us,.code,func_806809F0,4388,no +us,.code,func_806D79E4,68,yes +us,.code,func_805FF800,152,yes +us,.code,func_806A7B04,36,yes +us,.code,func_80659320,48,yes +us,.code,func_8072B438,356,no +us,.code,func_80704130,360,no +us,.code,func_8070C2D8,696,no +us,.code,func_80647B74,384,no +us,.code,func_8071B24C,160,no +us,.code,func_806D1420,328,yes +us,.code,func_806D06A0,708,yes +us,.code,func_80678F9C,116,no +us,.code,func_8062F538,264,no +us,.code,func_80630324,120,yes +us,.code,func_80723380,52,yes +us,.code,func_80705F5C,1116,no +us,.code,func_80655CF8,216,no +us,.code,func_806A62D4,116,yes +us,.code,func_8066C610,484,no +us,.code,func_806CD424,1140,no +us,.code,func_8070AC74,688,no +us,.code,func_80658134,452,no +us,.code,func_80723284,52,yes +us,.code,func_807024E0,3732,no +us,.code,func_80652A08,252,yes +us,.code,func_8064BCB0,124,yes +us,.code,func_806DFF34,108,no +us,.code,func_806BDEC8,468,yes +us,.code,func_80654E84,360,no +us,.code,func_8068C080,52,yes +us,.code,func_8060A398,312,no +us,.code,func_80682AB4,832,no +us,.code,func_806921DC,804,no +us,.code,func_8064EC04,92,no +us,.code,func_806BD7B0,1404,no +us,.code,func_80732444,140,no +us,.code,func_80699914,68,yes +us,.code,func_806E67D8,608,yes +us,.code,func_806710E0,384,no +us,.code,func_806AE588,2176,no +us,.code,func_806FDAB8,52,yes +us,.code,func_8072EE7C,256,no +us,.code,func_806D374C,128,yes +us,.code,func_80688638,168,no +us,.code,func_80724C78,44,yes +us,.code,func_80610350,1692,no +us,.code,func_8064B9E0,276,no +us,.code,func_806F0D68,736,no +us,.code,func_8060C430,536,no +us,.code,func_806C6B50,80,yes +us,.code,func_80726DEC,116,no +us,.code,func_8072E22C,132,yes +us,.code,func_807324D0,100,no +us,.code,func_8070D82C,148,no +us,.code,func_80659110,128,yes +us,.code,func_80676220,56,yes +us,.code,func_80738118,88,no +us,.code,func_806DED44,780,no +us,.code,func_8060EC54,44,yes +us,.code,func_8062BB2C,412,no +us,.code,func_806A495C,552,no +us,.code,func_80654BC0,268,no +us,.code,func_806B3680,1456,no +us,.code,func_806E4740,920,no +us,.code,func_8060E930,40,yes +us,.code,func_80737E38,8,yes +us,.code,func_8063A38C,1212,no +us,.code,func_806338B4,64,no +us,.code,func_8063B8D8,728,no +us,.code,func_806644B0,264,no +us,.code,func_8063D9D0,112,no +us,.code,func_806FDB8C,912,no +us,.code,func_80665AAC,32,no +us,.code,func_8068A764,32,no +us,.code,func_8070B324,1224,no +us,.code,func_8060BEA8,220,no +us,.code,func_806FA1A4,864,no +us,.code,func_8067BF84,820,no +us,.code,func_806B1DD4,212,yes +us,.code,func_806A2B08,24,yes +us,.code,func_80664044,348,no +us,.code,func_8071458C,108,yes +us,.code,func_806D6F0C,88,yes +us,.code,func_806CE928,540,no +us,.code,func_80666AA0,12,yes +us,.code,func_8062D094,56,yes +us,.code,func_80669CB4,336,no +us,.code,func_807195D4,480,no +us,.code,func_8070CC54,56,yes +us,.code,func_8072DAA4,196,yes +us,.code,func_8065FD88,304,no +us,.code,func_8072881C,308,no +us,.code,func_806998F0,36,yes +us,.code,func_8064C250,408,no +us,.code,func_806D9184,32,yes +us,.code,func_806EBF34,64,yes +us,.code,func_8067BF4C,56,yes +us,.code,func_8067DCC0,644,no +us,.code,func_8064A194,196,no +us,.code,func_80740100,1704,no +us,.code,func_8070E8F0,2520,no +us,.code,func_8070E8DC,16,yes +us,.code,func_806DABE4,444,yes +us,.code,func_806EC014,48,yes +us,.code,func_8068ECF4,608,no +us,.code,func_8067BC88,32,yes +us,.code,func_8069904C,32,yes +us,.code,func_8066AEE4,92,yes +us,.code,func_806689F0,312,no +us,.code,func_80636C00,312,no +us,.code,func_8064B7C0,20,yes +us,.code,func_805FF5A0,136,yes +us,.code,func_806EE74C,108,yes +us,.code,func_806A7518,232,yes +us,.code,func_807383B0,60,no +us,.code,func_807146A4,60,no +us,.code,func_8073B9B0,176,no +us,.code,func_80688EA4,64,yes +us,.code,func_80688D20,232,no +us,.code,func_806C498C,68,yes +us,.code,func_806EA7E8,92,yes +us,.code,func_80627B58,172,yes +us,.code,func_80671528,724,no +us,.code,func_806010A0,128,yes +us,.code,func_806C13AC,368,no +us,.code,func_8064B150,64,no +us,.code,func_806D9D58,632,no +us,.code,func_80712798,28,yes +us,.code,func_80737C20,212,no +us,.code,func_80685520,488,yes +us,.code,func_8067ACC0,28,yes +us,.code,func_80723C98,52,yes +us,.code,func_8067B288,8,yes +us,.code,func_8071375C,8,yes +us,.code,func_8071268C,36,yes +us,.code,func_806C4948,68,yes +us,.code,func_8069DC80,192,no +us,.code,func_8072E54C,100,no +us,.code,func_806330C4,820,no +us,.code,func_806641A0,548,no +us,.code,func_80665E48,76,no +us,.code,func_806645B8,100,no +us,.code,func_80639FC0,972,no +us,.code,func_8070CDD0,592,no +us,.code,func_806E8F68,264,yes +us,.code,func_806E6234,228,yes +us,.code,func_80662AB4,220,no +us,.code,func_80657974,828,no +us,.code,func_80652374,300,no +us,.code,func_80666AF8,656,no +us,.code,func_806DA7EC,176,yes +us,.code,func_8060A7C0,320,no +us,.code,func_806D9AD4,644,no +us,.code,func_806C49D0,244,yes +us,.code,func_806D6F64,308,no +us,.code,func_806E9DE0,236,no +us,.code,func_8069DA54,444,no +us,.code,func_805FF188,40,yes +us,.code,func_806E2DE8,132,yes +us,.code,func_806D0150,92,yes +us,.code,func_8062AD28,1132,no +us,.code,func_806C7240,8,yes +us,.code,func_80715E94,4220,no +us,.code,func_80654A2C,404,no +us,.code,func_8060F254,760,no +us,.code,func_8071338C,172,no +us,.code,func_8070B05C,684,no +us,.code,func_806686F4,236,no +us,.code,func_80712944,252,no +us,.code,func_806F6204,848,no +us,.code,func_8063039C,40,yes +us,.code,func_806C9D20,92,yes +us,.code,func_806E98F8,108,yes +us,.code,func_80677D58,36,yes +us,.code,func_806348B4,84,no +us,.code,func_806AD84C,352,yes +us,.code,func_806951E8,1340,no +us,.code,func_8068B8FC,52,no +us,.code,func_806DF050,336,yes +us,.code,func_8071D260,44,no +us,.code,func_8060E430,120,yes +us,.code,func_8062B194,140,yes +us,.code,func_8069B010,1004,no +us,.code,func_806FDA8C,44,yes +us,.code,func_806F1048,160,yes +us,.code,func_80723484,1104,no +us,.code,func_8068086C,156,yes +us,.code,func_8060866C,96,yes +us,.code,func_8064F1C4,76,yes +us,.code,func_8066B5C8,44,yes +us,.code,func_80690F30,1664,no +us,.code,func_807278C0,152,no +us,.code,func_80665AE4,308,no +us,.code,func_80676C10,84,no +us,.code,func_8066E6C8,100,yes +us,.code,func_80659190,12,yes +us,.code,func_8066EAEC,84,no +us,.code,func_8064F404,64,yes +us,.code,func_806EFA3C,272,no +us,.code,func_8063CA7C,96,yes +us,.code,func_8060EE60,880,no +us,.code,func_80690470,144,no +us,.code,func_8068A10C,12,yes +us,.code,func_806FB914,580,no +us,.code,func_80690BE8,120,yes +us,.code,func_8063C248,96,yes +us,.code,func_8070C89C,88,yes +us,.code,func_806A1F28,60,yes +us,.code,func_80657508,100,yes +us,.code,func_806E8E00,120,yes +us,.code,func_806C7248,8,yes +us,.code,func_806E5E68,64,yes +us,.code,func_80672CBC,424,no +us,.code,func_8066F4AC,928,no +us,.code,func_8064DF5C,536,no +us,.code,func_806F0930,184,yes +us,.code,func_8064A804,704,no +us,.code,func_8066A988,648,no +us,.code,func_806C9F00,68,yes +us,.code,func_806A2B20,24,yes +us,.code,func_8070E2AC,160,no +us,.code,func_8068450C,32,yes +us,.code,func_8064BFD0,356,no +us,.code,func_806EE700,76,yes +us,.code,func_80674B90,644,no +us,.code,func_807130D4,148,yes +us,.code,func_80650D04,136,no +us,.code,func_8063C2A8,128,no +us,.code,func_80689EA4,64,yes +us,.code,func_80676B38,56,yes +us,.code,func_806E04E0,372,yes +us,.code,func_80707980,2524,no +us,.code,func_806858E8,156,no +us,.code,func_806B11C0,208,yes +us,.code,func_8072ECFC,148,no +us,.code,func_8068EF54,2008,no +us,.code,func_8068842C,52,yes +us,.code,func_80677ED0,216,no +us,.code,func_806D3D5C,136,yes +us,.code,func_806A3E9C,1000,no +us,.code,func_806C8E58,144,no +us,.code,func_8071F444,540,no +us,.code,func_80732B3C,580,no +us,.code,func_8064431C,200,no +us,.code,func_80692500,32,yes +us,.code,func_8070D464,260,no +us,.code,func_80674688,132,no +us,.code,func_806634A4,240,no +us,.code,func_80665C18,456,no +us,.code,func_806DC3A4,108,yes +us,.code,func_806BE674,124,yes +us,.code,func_806FD7A8,236,no +us,.code,func_806E9ECC,192,no +us,.code,func_806FD8E0,112,no +us,.code,func_8066CDD0,40,yes +us,.code,func_806E5E60,8,yes +us,.code,func_806621D0,508,no +us,.code,func_8069B3FC,1120,no +us,.code,func_807273A8,388,no +us,.code,func_8068ABE0,412,no +us,.code,func_806E52D0,440,no +us,.code,func_806E8B28,124,yes +us,.code,func_80608528,180,no +us,.code,func_806877C8,68,yes +us,.code,func_8073CAC0,468,no +us,.code,func_806663F8,36,yes +us,.code,func_8073198C,76,no +us,.code,func_806AD9AC,72,yes +us,.code,func_8065756C,100,yes +us,.code,func_806F9B64,364,no +us,.code,func_80702464,124,no +us,.code,func_806836D0,944,no +us,.code,func_806767E0,44,yes +us,.code,func_8060B750,116,yes +us,.code,func_80731B60,40,yes +us,.code,func_8067ACDC,216,yes +us,.code,func_80729B00,876,no +us,.code,func_80645614,236,yes +us,.code,func_806D0EBC,452,yes +us,.code,func_806E61D0,100,no +us,.code,func_8065E0CC,88,yes +us,.code,func_8072E7DC,140,no +us,.code,func_80672680,92,yes +us,.code,func_80636074,240,no +us,.code,func_806767B4,44,yes +us,.code,func_806D9FD0,848,no +us,.code,func_806FBEF0,1600,no +us,.code,func_806C71B8,8,yes +us,.code,func_8066E2C0,780,no +us,.code,func_806E4C6C,168,no +us,.code,func_8066D250,164,no +us,.code,func_80658C10,188,no +us,.code,func_80659620,80,yes +us,.code,func_8065E040,140,yes +us,.code,func_8065EFF0,324,no +us,.code,func_806ABA6C,300,no +us,.code,func_80692588,36,yes +us,.code,func_8073F328,740,no +us,.code,func_806F142C,112,yes +us,.code,func_8063CE64,168,yes +us,.code,func_80728300,1308,no +us,.code,func_8066ACA4,252,no +us,.code,func_806419F8,128,no +us,.code,func_8060A9BC,72,no +us,.code,func_806A4DDC,920,no +us,.code,func_8069E040,72,yes +us,.code,func_8064216C,152,yes +us,.code,func_80635588,84,yes +us,.code,func_80653684,384,yes +us,.code,func_80687474,120,yes +us,.code,func_806D2C54,88,yes +us,.code,func_80636380,188,no +us,.code,func_8062D0CC,220,no +us,.code,func_806019B8,88,no +us,.code,func_806F9CD0,188,no +us,.code,func_80676A0C,100,no +us,.code,func_806E41B4,56,yes +us,.code,func_8065E81C,552,no +us,.code,func_80697988,868,no +us,.code,func_8062F318,16,yes +us,.code,func_8063A848,124,no +us,.code,func_806E380C,32,yes +us,.code,func_806AD260,748,no +us,.code,func_806D28E4,32,yes +us,.code,func_806DF494,268,no +us,.code,func_805FE634,232,no +us,.code,func_80652BC8,492,yes +us,.code,func_806E2FE8,88,yes +us,.code,func_8064BD2C,300,no +us,.code,func_80712F10,184,yes +us,.code,func_806F37BC,176,no +us,.code,func_80674884,472,no +us,.code,func_8072334C,52,yes +us,.code,func_8072B330,264,yes +us,.code,func_806F7FD0,52,yes +us,.code,func_806B4904,84,yes +us,.code,func_806FFEAC,176,no +us,.code,func_806CEC04,608,no +us,.code,func_806D3224,156,no +us,.code,func_80697CEC,1076,no +us,.code,func_8061159C,12,yes +us,.code,func_80715270,1532,no +us,.code,func_806F00BC,144,yes +us,.code,func_806CC8B8,56,yes +us,.code,func_806E2E6C,60,yes +us,.code,func_806EAE04,92,yes +us,.code,func_8071509C,468,no +us,.code,func_80738BA0,8,yes +us,.code,func_806CEFBC,276,no +us,.code,func_8073749C,324,no +us,.code,func_80650998,108,no +us,.code,func_806A0310,32,yes +us,.code,func_8073B750,224,no +us,.code,func_8071EDEC,184,no +us,.code,func_8062F388,24,yes +us,.code,func_8067E348,136,yes +us,.code,func_806E0050,44,yes +us,.code,func_806C28B8,428,no +us,.code,func_80673A94,228,no +us,.code,func_806A05D4,40,yes +us,.code,func_8064BF58,120,yes +us,.code,func_806D2DC4,216,no +us,.code,func_8066EA64,44,yes +us,.code,func_8062BAE4,72,yes +us,.code,func_806D5834,432,no +us,.code,func_806013A0,72,yes +us,.code,func_806D0A84,864,no +us,.code,func_806D9134,80,yes +us,.code,func_8072A714,200,yes +us,.code,func_8072A7DC,144,yes +us,.code,func_8063DB3C,156,yes +us,.code,func_8070E808,192,no +us,.code,func_806D03BC,76,yes +us,.code,func_806EFC38,280,yes +us,.code,func_80602E6C,1236,no +us,.code,func_806B5A90,2384,no +us,.code,func_80689F2C,84,no +us,.code,func_806AFB58,1940,no +us,.code,func_806E5D60,248,yes +us,.code,func_806A02F0,32,yes +us,.code,func_80654380,152,no +us,.code,func_8070A220,1576,no +us,.code,func_8070CD14,48,yes +us,.code,func_806AB808,612,no +us,.code,func_80667174,12,yes +us,.code,func_8064F028,412,yes +us,.code,func_806D7704,372,no +us,.code,func_80678428,48,yes +us,.code,func_8062FBC8,840,no +us,.code,func_80649BF0,388,no +us,.code,func_806D3FA0,112,yes +us,.code,func_806ECAC4,272,no +us,.code,func_80738BA8,8,yes +us,.code,func_80725B38,108,no +us,.code,func_806EAFEC,8,yes +us,.code,func_80738470,384,no +us,.code,func_806F1378,8,yes +us,.code,func_80610DCC,184,no +us,.code,func_8070D8C0,104,no +us,.code,func_80643274,224,no +us,.code,func_80680774,248,yes +us,.code,func_8064FB64,1404,no +us,.code,func_806C7C94,172,no +us,.code,func_8070CB2C,120,yes +us,.code,func_80659350,120,no +us,.code,func_80688460,44,yes +us,.code,func_806018B4,32,yes +us,.code,playSong,204,no +us,.code,func_806761EC,28,yes +us,.code,func_8067E3D0,108,yes +us,.code,func_806E64D0,236,yes +us,.code,func_806487C4,1164,no +us,.code,func_80681E18,1252,no +us,.code,func_806F54E0,960,no +us,.code,func_806CC14C,68,yes +us,.code,func_806F9518,176,no +us,.code,func_806FF32C,44,yes +us,.code,func_8064D418,1128,no +us,.code,func_8068A4C8,64,yes +us,.code,func_80663040,76,yes +us,.code,func_80706F90,1916,no +us,.code,func_8073AD50,828,no +us,.code,func_80672AFC,32,yes +us,.code,func_806C4AC4,968,no +us,.code,func_8060E7EC,224,yes +us,.code,func_80657CB0,372,no +us,.code,func_80684A00,432,yes +us,.code,func_806874EC,732,no +us,.code,func_8060FA5C,72,no +us,.code,func_80714944,12,yes +us,.code,func_8068A24C,88,yes +us,.code,func_806E9388,112,yes +us,.code,func_80653B70,16,yes +us,.code,func_806D8A64,164,yes +us,.code,func_8062E608,116,yes +us,.code,func_806612B4,76,yes +us,.code,func_8071E028,232,no +us,.code,func_806D2CAC,140,yes +us,.code,func_8060E980,168,yes +us,.code,func_80611690,80,no +us,.code,func_806EA8FC,92,yes +us,.code,func_806D1DEC,164,yes +us,.code,func_80730E18,536,no +us,.code,func_8066BECC,64,yes +us,.code,func_80636D38,452,no +us,.code,func_806FAB20,324,no +us,.code,func_80672C70,76,yes +us,.code,func_806D3AC8,32,yes +us,.code,func_806DE9F4,176,yes +us,.code,func_80717DB4,360,no +us,.code,func_805FF938,116,yes +us,.code,func_806F0B34,228,yes +us,.code,func_806F9470,60,yes +us,.code,func_8068A1B8,20,yes +us,.code,func_8065F678,748,no +us,.code,func_806A2E30,2244,no +us,.code,func_8065A648,12,yes +us,.code,func_80714A68,52,yes +us,.code,func_8068D8C8,276,no +us,.code,func_8064F804,72,yes +us,.code,func_8073B640,112,no +us,.code,func_8073CF00,176,no +us,.code,func_80662B90,1200,no +us,.code,func_806D281C,200,yes +us,.code,func_806F4F50,376,no +us,.code,func_806EBDC4,200,yes +us,.code,func_80664CB0,112,no +us,.code,func_807102AC,308,no +us,.code,func_806D332C,392,no +us,.code,func_8071498C,12,yes +us,.code,func_8071DC90,920,no +us,.code,func_805FF628,56,yes +us,.code,func_80724308,720,no +us,.code,func_80685390,400,no +us,.code,func_806CEE64,116,yes +us,.code,func_8066BA2C,140,no +us,.code,func_8060151C,196,yes +us,.code,func_806022DC,56,no +us,.code,func_8071E3EC,1144,no +us,.code,func_8063524C,540,no +us,.code,func_8062CEA8,492,no +us,.code,func_80737A74,40,no +us,.code,func_806C7BAC,100,yes +us,.code,func_8072EE0C,112,no +us,.code,func_806CA26C,64,yes +us,.code,func_8064DB98,620,no +us,.code,func_806A92B4,3560,no +us,.code,func_80674150,368,no +us,.code,func_806ACF10,236,no +us,.code,func_806DECD4,112,yes +us,.code,func_806F0624,128,yes +us,.code,func_8071AF30,636,no +us,.code,func_806CBE90,636,yes +us,.code,func_80735A50,80,no +us,.code,func_806EE454,336,yes +us,.code,func_80605044,720,no +us,.code,func_806ADFE0,720,no +us,.code,func_8063EA14,4148,no +us,.code,func_806E6B98,592,no +us,.code,func_8060BF84,832,no +us,.code,func_8064B900,224,yes +us,.code,func_806EB5C8,272,no +us,.code,func_806496B0,1344,no +us,.code,func_806A664C,1896,no +us,.code,func_806017E8,96,yes +us,.code,func_8070C9E8,68,yes +us,.code,func_8070D654,132,no +us,.code,func_806A5FA4,96,yes +us,.code,func_806ECF1C,128,yes +us,.code,func_806D3DE4,444,yes +us,.code,func_806D4758,452,no +us,.code,func_806765E8,168,yes +us,.code,func_806ECF9C,180,yes +us,.code,func_80728950,96,yes +us,.code,func_806C9EA0,48,yes +us,.code,func_806EC044,356,yes +us,.code,func_80687C48,128,yes +us,.code,func_80724D28,136,no +us,.code,func_8073CC94,316,no +us,.code,func_806907F0,36,yes +us,.code,func_806766E0,80,yes +us,.code,func_80705B14,28,yes +us,.code,func_8064CC80,188,no +us,.code,func_80678E14,88,yes +us,.code,func_8060E128,128,no +us,.code,func_807145F8,16,yes +us,.code,func_8064F450,624,no +us,.code,func_80666AC4,28,yes +us,.code,func_8064B2AC,196,no +us,.code,func_806FA5A4,512,no +us,.code,gameIsInQuitGameMode,84,yes +us,.code,func_806E0694,84,yes +us,.code,func_8063B4A4,28,yes +us,.code,func_806592B4,108,no +us,.code,func_806F2754,748,no +us,.code,func_806368F0,340,no +us,.code,func_807319D8,44,yes +us,.code,func_80690500,696,no +us,.code,func_806F6E58,132,yes +us,.code,func_80678CC8,272,no +us,.code,func_806D4010,556,yes +us,.code,func_8072F230,632,no +us,.code,func_80689BAC,116,yes +us,.code,func_8069EF50,208,yes +us,.code,func_80735DBC,4604,no +us,.code,func_807381D8,88,no +us,.code,func_806787EC,8,yes +us,.code,func_806F8CFC,92,yes +us,.code,func_806AC07C,2572,no +us,.code,func_806307CC,196,yes +us,.code,func_806C7210,8,yes +us,.code,func_806E84C0,56,yes +us,.code,func_8062C29C,1792,no +us,.code,func_806443E4,1500,no +us,.code,func_8066BDE0,64,yes +us,.code,func_80651BE0,76,no +us,.code,func_80610A88,252,no +us,.code,func_806D6558,1100,no +us,.code,func_80630300,36,yes +us,.code,func_8063C3C0,88,yes +us,.code,func_806FFC04,680,no +us,.code,func_806F3190,1488,no +us,.code,func_8072FDD4,140,no +us,.code,func_80600174,460,no +us,.code,func_806F5EB4,120,no +us,.code,func_80683A80,88,no +us,.code,func_806F1AE0,120,yes +us,.code,func_80675D70,96,no +us,.code,func_806E78F8,8,yes +us,.code,func_807124B8,108,yes +us,.code,func_8073A98C,232,no +us,.code,func_80642500,252,no +us,.code,func_80701C90,16,yes +us,.code,func_80704960,412,no +us,.code,func_8062BA0C,104,yes +us,.code,func_806791DC,16,yes +us,.code,func_8060C758,216,no +us,.code,func_806A3DA0,252,no +us,.code,func_80637B6C,5968,no +us,.code,func_806EC1A8,292,yes +us,.code,func_806CC10C,64,yes +us,.code,func_8071CDE0,784,no +us,.code,getPointerTableFile,812,no +us,.code,func_8073DA30,1312,no +us,.code,func_80611614,116,no +us,.code,func_806015E0,152,yes +us,.code,func_80661AB4,208,no +us,.code,func_8068848C,44,yes +us,.code,func_806D7E88,192,yes +us,.code,func_80602104,64,no +us,.code,func_8070C808,148,no +us,.code,func_80634EDC,56,yes +us,.code,func_80740F48,296,no +us,.code,func_8072B608,404,no +us,.code,func_8071A674,572,no +us,.code,func_80723CCC,700,no +us,.code,func_806C7218,8,yes +us,.code,func_806844EC,32,yes +us,.code,func_80735CF4,200,no +us,.code,func_8068E7B4,508,no +us,.code,func_8071495C,16,yes +us,.code,func_806C9DE0,48,yes +us,.code,func_806EE26C,76,yes +us,.code,func_8069329C,464,no +us,.code,func_80712524,36,yes +us,.code,func_80632084,828,no +us,.code,func_8067C6DC,32,yes +us,.code,func_806C8984,924,no +us,.code,func_8064BAF4,88,no +us,.code,func_8066F400,172,yes +us,.code,func_80708DA4,1440,no +us,.code,func_806787F4,8,yes +us,.code,func_8070F2C8,52,yes +us,.code,func_806FAC64,132,yes +us,.code,func_806F79E0,1520,no +us,.code,func_806F3760,92,yes +us,.code,func_8068EA38,260,no +us,.code,func_8073B5D0,112,no +us,.code,func_8070DA74,264,no +us,.code,func_80635214,56,no +us,.code,func_8072FA14,688,no +us,.code,func_80735624,576,no +us,.code,func_80631B80,12,yes +us,.code,func_8060AA04,84,no +us,.code,func_8062B8E4,296,no +us,.code,func_80676308,48,yes +us,.code,func_806A370C,1132,no +us,.code,func_8066BAB8,140,no +us,.code,func_8070DED4,984,no +us,.code,func_80676CB0,80,no +us,.code,func_80653F68,60,yes +us,.code,func_8065A6F8,16,yes +us,.code,func_80673708,456,no +us,.code,func_8068A404,196,no +us,.code,func_806E0454,140,yes +us,.code,func_80688C30,84,yes +us,.code,func_806B6600,856,no +us,.code,func_8064C9F8,324,no +us,.code,func_8061118C,48,no +us,.code,func_8063DA78,148,no +us,.code,func_806B42A8,1476,no +us,.code,func_8066DD34,1256,no +us,.code,playerCanThrowOrange,292,yes +us,.code,func_8071F1D0,296,no +us,.code,func_80714670,52,yes +us,.code,func_8066FD6C,156,no +us,.code,func_806A6348,96,yes +us,.code,func_806CA5F8,3908,no +us,.code,func_80732730,196,no +us,.code,func_806782C0,40,yes +us,.code,func_8064D880,248,no +us,.code,func_80673324,448,no +us,.code,func_80672A70,140,yes +us,.code,func_806CCC54,2000,no +us,.code,func_8060C724,52,yes +us,.code,func_80652FDC,476,no +us,.code,func_806EF830,276,yes +us,.code,func_807245F0,644,no +us,.code,func_807280C8,196,no +us,.code,func_8071C9E8,1016,no +us,.code,func_806B52DC,480,yes +us,.code,func_80686340,80,yes +us,.code,func_8062BF24,668,no +us,.code,func_80724DB0,152,no +us,.code,func_80712574,168,no +us,.code,func_805FBC5C,424,no +us,.code,func_80665F24,144,no +us,.code,func_806CFE30,76,yes +us,.code,func_806F5FA0,72,yes +us,.code,func_80641A78,136,yes +us,.code,func_8062D26C,64,no +us,.code,func_8062B660,480,no +us,.code,func_806BB874,2060,no +us,.code,func_806D428C,792,yes +us,.code,func_806BA93C,2544,no +us,.code,func_80665E94,144,yes +us,.code,func_80714C08,184,yes +us,.code,func_806A7B28,36,yes +us,.code,func_806EA5CC,52,yes +us,.code,func_8060D768,32,yes +us,.code,func_8067443C,108,no +us,.code,func_8060AB48,224,no +us,.code,func_80661398,80,yes +us,.code,func_8071F078,344,no +us,.code,func_80629190,12,yes +us,.code,func_8068DC54,2080,no +us,.code,func_806D266C,108,yes +us,.code,func_8068B830,116,no +us,.code,func_80708C24,384,no +us,.code,func_806317D4,496,no +us,.code,func_807255A8,1424,no +us,.code,func_806362C4,188,no +us,.code,func_80673A40,84,no +us,.code,func_806625D0,72,yes +us,.code,func_8073E8C0,2340,no +us,.code,func_806594C8,124,yes +us,.code,func_8072C870,168,yes +us,.code,func_8060BCA0,520,no +us,.code,func_806FD9A0,20,yes +us,.code,func_80672E6C,32,yes +us,.code,func_8070D07C,644,no +us,.code,func_806D57F0,68,yes +us,.code,func_80665548,16,yes +us,.code,func_806B3DA4,100,yes +us,.code,func_8064E48C,108,no +us,.code,func_806B48B8,76,yes +us,.code,func_8064D978,544,no +us,.code,func_80645F40,280,no +us,.code,func_80724CA4,132,no +us,.code,func_8073C948,120,no +us,.code,func_80676A70,72,yes +us,.code,func_806B3E7C,192,yes +us,.code,func_80713270,108,yes +us,.code,func_8071C818,252,no +us,.code,func_80737E50,64,no +us,.code,func_80658930,472,no +us,.code,func_8060FAE4,1292,no +us,.code,func_8060D7A8,1172,yes +us,.code,func_8070DCA4,116,no +us,.code,func_80670C5C,680,no +us,.code,func_806F1768,240,no +us,.code,func_80737B2C,28,no +us,.code,func_80665FB4,220,no +us,.code,func_80673B78,188,no +us,.code,func_806D0378,68,yes +us,.code,func_806D61B8,928,no +us,.code,func_8072707C,68,yes +us,.code,func_80732924,8,yes +us,.code,func_8071910C,1224,no +us,.code,func_8067457C,268,no +us,.code,func_8065A570,216,yes +us,.code,func_806C71B0,8,yes +us,.code,func_80689F80,108,yes +us,.code,func_8064F2F0,24,yes +us,.code,func_8071BE04,512,no +us,.code,func_8060F1D0,56,yes +us,.code,func_8060DEA8,32,yes +us,.code,func_80688CC4,48,no +us,.code,func_805FF4D8,108,yes +us,.code,func_806E9070,284,no +us,.code,func_806526E0,176,yes +us,.code,func_80668C30,620,no +us,.code,func_806291A8,12,yes +us,.code,func_806E341C,188,no +us,.code,func_8065214C,172,no +us,.code,func_806E007C,252,yes +us,.code,func_806CFE7C,40,yes +us,.code,func_8073A690,296,no +us,.code,func_8064F6F8,268,no +us,.code,func_80710174,312,no +us,.code,func_806F09F0,324,no +us,.code,func_806E8E78,140,yes +us,.code,func_8066A08C,1272,no +us,.code,func_80676338,228,no +us,.code,func_8072EC94,104,no +us,.code,func_80676788,44,yes +us,.code,func_80634D64,172,yes +us,.code,func_806533C4,284,no +us,.code,func_80712EDC,52,yes +us,.code,func_806C9974,364,no +us,.code,func_8067B2A8,8,yes +us,.code,func_80672630,80,yes +us,.code,func_806A36F4,8,yes +us,.code,func_8071A440,564,no +us,.code,func_80647CF4,136,yes +us,.code,func_8060B8F8,112,yes +us,.code,func_8066AC10,148,no +us,.code,func_806E1864,8,yes +us,.code,func_806DB0C4,744,no +us,.code,func_80738BB0,8,yes +us,.code,func_806F70A8,84,yes +us,.code,func_80738E58,576,no +us,.code,func_806FDF54,292,no +us,.code,func_806F18F4,156,no +us,.code,func_806B0770,216,no +us,.code,func_806B86AC,460,no +us,.code,func_806F5A48,488,no +us,.code,func_80724E48,1888,no +us,.code,func_8068C2F8,88,yes +us,.code,func_80661440,68,yes +us,.code,func_806FB488,8,yes +us,.code,func_8069E5B8,168,yes +us,.code,func_806C9C1C,100,yes +us,.code,func_806B8B20,188,yes +us,.code,func_80709464,96,yes +us,.code,func_8063C450,88,yes +us,.code,func_806B4958,88,yes +us,.code,func_8067BC68,32,yes +us,.code,func_8069D0B8,32,yes +us,.code,func_806C1300,172,yes +us,.code,func_806EB544,132,yes +us,.code,func_8064B798,40,no +us,.code,func_807127F4,60,yes +us,.code,func_8064C814,484,no +us,.code,func_8066164C,12,yes +us,.code,func_806DF280,272,yes +us,.code,func_806D1E90,152,yes +us,.code,func_806355DC,540,no +us,.code,func_806CC5DC,92,yes +us,.code,func_80679334,348,no +us,.code,func_8069D078,32,yes +us,.code,func_806E63B8,280,yes +us,.code,func_8073AA74,140,no +us,.code,func_806BF920,364,no +us,.code,func_805FD088,4880,no +us,.code,func_80687FC8,788,no +us,.code,func_80699284,1604,no +us,.code,func_8069B85C,172,no +us,.code,func_80733B88,172,no +us,.code,func_806A615C,116,yes +us,.code,func_806D4C7C,360,no +us,.code,func_806907E0,16,yes +us,.code,func_806FB480,8,yes +us,.code,func_80603340,272,no +us,.code,func_80688CF4,44,no +us,.code,func_8062D1A8,56,yes +us,.code,func_806B7EA0,1348,no +us,.code,func_8068D264,1636,no +us,.code,func_806C151C,204,yes +us,.code,func_80737F38,8,yes +us,.code,func_80676208,24,yes +us,.code,func_80739098,500,no +us,.code,func_80601484,152,yes +us,.code,func_806109EC,156,no +us,.code,func_80652858,292,yes +us,.code,func_8072FE60,604,no +us,.code,func_80738BB8,180,no +us,.code,func_806E7568,240,yes +us,.code,func_806B3420,608,yes +us,.code,func_80641DA0,456,no +us,.code,func_8062E898,800,no +us,.code,func_8068DAF4,176,no +us,.code,func_8070CD8C,68,yes +us,.code,func_8060A4D0,48,yes +us,.code,func_806D205C,392,no +us,.code,func_806FF01C,296,no +us,.code,func_80715E38,92,yes +us,.code,func_80657F14,236,no +us,.code,func_806C15E8,88,yes +us,.code,func_806898A8,80,yes +us,.code,isIntroStoryPlaying,12,yes +us,.code,func_80718BF4,1304,no +us,.code,func_8066C904,84,no +us,.code,func_80708BB8,108,yes +us,.code,func_8068F72C,2068,no +us,.code,func_80602488,16,yes +us,.code,func_806C9F74,100,yes +us,.code,func_80679200,144,no +us,.code,func_806E7658,180,yes +us,.code,func_807370A4,244,no +us,.code,func_8073A130,372,no +us,.code,func_806A2A10,248,no +us,.code,func_806726DC,532,yes +us,.code,func_806DF390,64,yes +us,.code,func_806F22A8,1196,no +us,.code,func_8060E958,40,yes +us,.code,func_8064409C,640,no +us,.code,func_8072E868,552,no +us,.code,func_806F5F2C,116,yes +us,.code,func_807289E8,4284,no +us,.code,func_8066E5F8,52,yes +us,.code,func_806EB2B8,172,yes +us,.code,func_806F5D80,120,yes +us,.code,func_8060EC80,236,no +us,.code,func_806D3B48,128,yes +us,.code,func_806F0344,128,yes +us,.code,func_8063E6B4,120,no +us,.code,func_80686A5C,668,no +us,.code,func_80653804,620,no +us,.code,func_806011A0,52,yes +us,.code,func_806DAADC,264,yes +us,.code,func_806ED244,476,no +us,.code,func_80634D14,80,yes +us,.code,func_80678824,120,no +us,.code,func_806F58A0,424,no +us,.code,func_8072F8D4,320,yes +us,.code,func_80669E04,648,no +us,.code,func_806E03C8,140,yes +us,.code,func_806DADA0,444,yes +us,.code,func_8071A038,428,no +us,.code,func_8062FF10,1008,no +us,.code,func_806852C4,204,yes +us,.code,func_80687F7C,76,yes +us,.code,func_8063367C,192,no +us,.code,func_805FB5C4,396,no +us,.code,func_80717F1C,356,no +us,.code,func_80633D30,144,no +us,.code,func_8073C8D0,120,no +us,.code,func_80666428,1632,no +us,.code,func_806AA09C,616,no +us,.code,func_806EBC60,144,yes +us,.code,func_8066D2F4,488,no +us,.code,func_807383EC,8,yes +us,.code,func_806E8DB4,76,yes +us,.code,func_806A8158,4044,no +us,.code,func_806A80C0,152,yes +us,.code,func_8066E8E4,172,no +us,.code,func_8066CB88,336,no +us,.code,func_807040E0,40,yes +us,.code,func_8070E8C8,20,yes +us,.code,func_8065051C,48,yes +us,.code,func_805FE71C,152,no +us,.code,func_806C9658,108,yes +us,.code,func_8060FFF0,84,no +us,.code,func_8067B2A0,8,yes +us,.code,func_806AFA60,248,no +us,.code,func_807329AC,400,no +us,.code,func_806DB08C,56,yes +us,.code,__n_freeParam,44,yes +us,.code,func_80676280,64,yes +us,.code,func_8068A508,604,no +us,.code,func_805FF670,400,no +us,.code,func_80732894,144,no +us,.code,func_8060B140,752,no +us,.code,func_80737E9C,8,yes +us,.code,func_80601780,52,yes +us,.code,func_806614D0,80,yes +us,.code,func_806896F0,32,yes +us,.code,func_806E2F3C,172,yes +us,.code,func_807266E8,92,yes +us,.code,func_8060B7F0,92,yes +us,.code,func_806CD898,84,yes +us,.code,func_806EB8CC,152,yes +us,.code,func_807407A8,744,no +us,.code,func_806C7260,8,yes +us,.code,func_8073F60C,528,no +us,.code,func_80714998,16,yes +us,.code,func_806F73A0,1600,no +us,.code,func_80714A38,32,yes +us,.code,func_806623D4,72,yes +us,.code,func_80732158,296,no +us,.code,func_806F4EBC,148,yes +us,.code,func_806AB4EC,796,no +us,.code,func_80646770,520,no +us,.code,func_80688370,44,yes +us,.code,func_80627EA8,92,yes +us,.code,func_8067E69C,40,yes +us,.code,func_80669650,80,no +us,.code,func_80688FC0,164,no +us,.code,func_8067A99C,84,yes +us,.code,func_806E3D14,300,yes +us,.code,func_806E56EC,1344,no +us,.code,func_806FAFE4,564,no +us,.code,func_8060A670,48,yes +us,.code,func_806ACCE8,552,yes +us,.code,func_806C7268,8,yes +us,.code,func_806F3DC8,68,yes +us,.code,func_8068B80C,16,yes +us,.code,func_80690094,252,yes +us,.code,func_80732064,56,no +us,.code,func_806C1E44,1064,no +us,.code,func_8065F49C,88,yes +us,.code,func_8072827C,132,no +us,.code,func_8064384C,108,yes +us,.code,func_80627A00,344,no +us,.code,func_806E6EE0,148,yes +us,.code,func_8067A7EC,120,yes +us,.code,func_806C6BA0,40,yes +us,.code,func_80714B84,132,yes +us,.code,func_8067BA3C,64,yes +us,.code,func_8070E750,184,no +us,.code,func_8073FD90,880,no +us,.code,func_8062E1F8,444,no +us,.code,func_8072B79C,48,no +us,.code,func_8068C350,80,yes +us,.code,func_806C9E40,48,yes +us,.code,func_80661F0C,508,no +us,.code,func_8062F3A0,128,no +us,.code,func_8063CF3C,668,no +us,.code,func_8067E2E4,100,yes +us,.code,func_8068839C,44,yes +us,.code,func_806EA0A4,348,yes +us,.code,func_806615BC,144,yes +us,.code,func_8069E210,640,no +us,.code,func_8062EFA0,176,no +us,.code,func_806CDD24,1104,no +us,.code,func_80649F64,92,yes +us,.code,func_8061130C,64,no +us,.code,func_806883F4,56,yes +us,.code,func_807248B0,228,no +us,.code,func_80630588,328,yes +us,.code,func_80717B64,388,no +us,.code,func_80634CC8,76,yes +us,.code,func_806FFF88,256,no +us,.code,func_806A921C,152,no +us,.code,func_80717760,180,no +us,.code,func_80650B50,108,no +us,.code,func_8068412C,960,yes +us,.code,func_807138A4,40,yes +us,.code,func_806485A0,548,no +us,.code,func_8062D620,1236,no +us,.code,func_806417BC,184,no +us,.code,func_806769A8,100,no +us,.code,gameIsInDKTheatreMode,52,yes +us,.code,func_806E14DC,340,yes +us,.code,func_80739FE0,144,no +us,.code,func_8064B3F8,180,no +us,.code,func_80643C0C,812,no +us,.code,func_8070C27C,92,no +us,.code,func_80636A8C,92,yes +us,.code,func_806F5270,264,no +us,.code,func_80671880,492,no +us,.code,func_8064911C,216,no +us,.code,func_806B7BB8,188,yes +us,.code,func_80660070,1200,no +us,.code,gameIsInSnidesBonusGameMode,52,yes +us,.code,func_806F3E0C,1820,no +us,.code,func_80651904,608,no +us,.code,func_8071720C,504,no +us,.code,func_8061138C,124,yes +us,.code,func_806970CC,184,no +us,.code,func_806DA3E4,244,no +us,.code,func_8062D3E4,48,yes +us,.code,func_80714464,84,yes +us,.code,func_8070E34C,508,no +us,.code,func_806E3E40,884,no +us,.code,func_8064BE80,216,no +us,.code,func_8062DAF4,124,no +us,.code,func_80714D08,916,no +us,.code,func_8073BA60,176,no +us,.code,func_8062B478,440,yes +us,.code,func_80652E58,100,yes +us,.code,func_806E84F8,84,yes +us,.code,func_8062E3B4,404,no +us,.code,func_806C4EE0,124,yes +us,.code,func_806EB744,392,yes +us,.code,func_806E4AD8,404,no +us,.code,func_8066C2B4,24,yes +us,.code,func_806E1334,424,yes +us,.code,func_806E8BA4,88,yes +us,.code,func_806CFF1C,128,yes +us,.code,func_80636A44,72,yes +us,.code,func_8066308C,1048,no +us,.code,func_806A736C,428,yes +us,.code,func_806BC080,100,yes +us,.code,func_8066EB50,164,yes +us,.code,func_80735864,244,no +us,.code,func_806C3F10,1176,no +us,.code,func_806BE09C,1496,no +us,.code,func_806E0D40,620,no +us,.code,func_806F46B0,160,no +us,.code,func_806574B8,80,no +us,.code,func_80660830,204,no +us,.code,func_8073E63C,256,no +us,.code,func_8071E864,448,no +us,.code,func_806D10D0,64,yes +us,.code,func_80600044,60,yes +us,.code,func_806D2BB0,32,yes +us,.code,func_8066A75C,216,no +us,.code,func_8063DA40,56,yes +us,.code,func_80654FEC,620,no +us,.code,func_806500E0,1084,no +us,.code,func_806CC190,244,yes +us,.code,func_806ABB98,252,no +us,.code,func_80737990,188,no +us,.code,func_806303C4,452,yes +us,.code,func_80601258,52,yes +us,.code,func_806ABE3C,524,no +us,.code,func_80731A04,164,yes +us,.code,func_80602C0C,96,yes +us,.code,func_80688EE4,144,yes +us,.code,func_8063CB40,804,no +us,.code,func_806D19A8,440,yes +us,.code,func_805FF0C8,80,yes +us,.code,func_80636784,364,no +us,.code,func_80668520,192,no +us,.code,func_8068C0B4,120,yes +us,.code,func_80689A80,144,yes +us,.code,func_80651708,508,no +us,.code,getFlagBlockAddress,340,no +us,.code,func_806D7510,500,no +us,.code,func_80689EE4,72,yes +us,.code,func_80729EB0,1440,no +us,.code,func_80732D80,44,no +us,.code,func_807149A8,16,yes +us,.code,func_8062B86C,56,yes +us,.code,func_8071BB14,364,no +us,.code,func_805FFEF8,208,yes +us,.code,func_80645A64,312,no +us,.code,func_806EB0C0,184,yes +us,.code,func_8065D994,1708,no +us,.code,func_80658BD0,64,no +us,.code,func_80641BCC,204,no +us,.code,func_8060AC7C,1172,no +us,.code,func_807382A0,128,no +us,.code,func_806A5F44,96,yes +us,.code,func_806F4528,392,no +us,.code,func_8068452C,32,yes +us,.code,func_806C9AE0,316,no +us,.code,func_8071EEE0,252,no +us,.code,func_806D3B08,32,yes +us,.code,func_80635114,256,no +us,.code,func_8068A350,80,yes +us,.code,func_807327F4,160,no +us,.code,func_8070A934,832,no +us,.code,func_8073B08C,324,no +us,.code,func_806C8D2C,180,yes +us,.code,func_80728004,196,no +us,.code,func_8062CA0C,100,yes +us,.code,func_8065D254,1808,no +us,.code,func_80714060,632,no +us,.code,func_807289B0,56,yes +us,.code,func_8069E490,80,yes +us,.code,func_80636014,96,yes +us,.code,func_80611844,8,yes +us,.code,func_806742C0,112,no +us,.code,func_8060A60C,40,yes +us,.code,func_8063254C,228,no +us,.code,func_8065BE74,164,no +us,.code,func_806E0FAC,904,no +us,.code,func_8066BE20,172,yes +us,.code,func_806EFDFC,312,yes +us,.code,func_806E352C,172,yes +us,.code,func_80631BCC,84,yes +us,.code,func_806364C4,268,no +us,.code,func_80658CCC,224,no +us,.code,func_806F2FC0,464,no +us,.code,func_806D25CC,160,yes +us,.code,func_8065CDB0,156,no +us,.code,func_8072752C,332,no +us,.code,func_806B50F4,72,yes +us,.code,func_80722E48,420,no +us,.code,func_806C90C4,512,yes +us,.code,func_806E7C70,388,no +us,.code,func_8070DC40,100,no +us,.code,func_806A6468,268,no +us,.code,func_806F386C,228,no +us,.code,func_8065D170,60,no +us,.code,func_80692520,32,yes +us,.code,func_806C7C10,132,yes +us,.code,func_806D5CCC,1260,yes +us,.code,func_8064E4F8,100,no +us,.code,func_806D1278,84,yes +us,.code,func_80732F10,624,no +us,.code,func_806EB6D8,108,yes +us,.code,func_80654CCC,440,no +us,.code,func_806EACEC,280,yes +us,.code,func_806FBB58,68,yes +us,.code,func_80692E50,1100,no +us,.code,func_80727678,584,no +us,.code,func_806D2AA0,240,yes +us,.code,func_806F1C04,684,no +us,.code,func_80643440,612,no +us,.code,func_8066E664,100,yes +us,.code,func_80661658,72,yes +us,.code,func_80602430,44,no +us,.code,func_806944BC,1164,no +us,.code,func_806CC638,624,no +us,.code,func_8064A258,1452,no +us,.code,func_8067ADB4,88,yes +us,.code,func_806CE7A0,392,no +us,.code,func_806D09E8,108,yes +us,.code,func_806588E0,80,yes +us,.code,func_8060E8EC,68,yes +us,.code,func_80659600,16,yes +us,.code,func_806850D0,320,no +us,.code,func_80649E00,52,yes +us,.code,func_8071D28C,816,no +us,.code,func_80610B84,84,no +us,.code,func_8060DC3C,620,no +us,.code,func_806B88B8,616,no +us,.code,func_806BE6F0,460,no +us,.code,func_8073202C,56,no +us,.code,func_8067AF44,48,yes +us,.code,func_806E17F4,112,yes +us,.code,func_8070C210,108,yes +us,.code,func_806B6DB0,2116,no +us,.code,func_8070D3CC,152,no +us,.code,func_80695724,1068,no +us,.code,func_806C71E0,8,yes +us,.code,func_80732DAC,64,no +us,.code,func_8067A170,108,no +us,.code,func_8060CB74,40,yes +us,.code,func_80636164,172,no +us,.code,func_8065054C,164,yes +us,.code,func_806C4E8C,40,yes +us,.code,func_806F4DC0,180,no +us,.code,func_80738170,104,no +us,.code,func_80678DD8,60,yes +us,.code,func_806D1110,236,yes +us,.code,func_8068780C,1084,no +us,.code,func_806A57C0,168,no +us,.code,func_806F01D8,96,yes +us,.code,func_806C9E10,48,yes +us,.code,func_80652790,200,yes +us,.code,func_806DA89C,176,yes +us,.code,func_806D1270,8,yes +us,.code,func_806F69A8,1200,no +us,.code,func_807313BC,84,yes +us,.code,func_8073BB10,356,no +us,.code,func_806AC048,52,yes +us,.code,func_80732280,212,no +us,.code,func_80737028,124,no +us,.code,func_806C7D40,932,no +us,.code,func_8072A86C,180,no +us,.code,func_8068C2EC,12,yes +us,.code,func_8062A274,212,yes +us,.code,func_806B63E0,44,yes +us,.code,func_8067BDB8,64,yes +us,.code,func_807035C4,652,no +us,.code,func_80685210,180,yes +us,.code,func_8067A864,164,yes +us,.code,func_8069FA40,864,no +us,.code,n_alClose,76,yes +us,.code,func_806C9304,224,no +us,.code,func_806422D8,208,yes +us,.code,func_806C80E4,248,yes +us,.code,func_8066E62C,56,yes +us,.code,func_8066B5F4,360,no +us,.code,func_8060F960,252,no +us,.code,func_8068C12C,224,yes +us,.code,func_80661BF0,580,no +us,.code,func_8068A2FC,80,yes +us,.code,func_806BC1AC,48,yes +us,.code,func_806D87FC,616,no +us,.code,func_80666A88,12,yes +us,.code,func_806E9468,280,yes +us,.code,func_8062BA74,112,no +us,.code,func_806A5174,1612,no +us,.code,func_806C71E8,8,yes +us,.code,func_8062B630,48,no +us,.code,func_806623CC,8,yes +us,.code,func_806B0354,1052,no +us,.code,func_80671260,388,no +us,.code,func_806C93E4,80,yes +us,.code,func_80713764,320,no +us,.code,func_80708574,88,yes +us,.code,func_8065E634,488,no +us,.code,func_806D6B00,1036,yes +us,.code,func_806789E4,288,no +us,.code,func_80633DC0,2472,no +us,.code,func_8060B4D4,136,no +us,.code,func_8066B8C8,92,no +us,.code,func_8070D380,76,yes +us,.code,func_806A1008,180,no +us,.code,func_8065FEB8,440,no +us,.code,func_805FE7B4,72,no +us,.code,func_806C9F44,48,yes +us,.code,func_8073F81C,132,no +us,.code,func_80675C70,256,no +us,.code,func_806BE8BC,2396,no +us,.code,func_80672BD4,92,yes +us,.code,func_8064B868,152,yes +us,.code,func_80609B80,1584,no +us,.code,func_806725E4,76,yes +us,.code,func_80675234,160,no +us,.code,func_8064EB9C,104,no +us,.code,func_80678804,8,yes +us,.code,func_8062DBDC,1124,no +us,.code,func_806A0B74,1028,no +us,.code,func_80610E84,356,no +us,.code,func_8060B6CC,52,yes +us,.code,func_806F006C,8,yes +us,.code,func_80642BF0,136,yes +us,.code,func_806EC708,248,yes +us,.code,func_807132DC,176,no +us,.code,func_8070DB9C,164,no +us,.code,func_8067A1DC,1216,no +us,.code,func_806A7EF0,384,no +us,.code,func_8063A968,2876,no +us,.code,func_806D2330,72,yes +us,.code,func_8067ACB4,12,yes +us,.code,func_806F07CC,172,yes +us,.code,func_806A4284,1752,no +us,.code,func_806E225C,2244,no +us,.code,func_8071C48C,404,no +us,.code,func_8070D300,116,yes +us,.code,func_806011D4,16,yes +us,.code,func_80666F04,196,yes +us,.code,func_806C27DC,220,yes +us,.code,func_806D36CC,128,yes +us,.code,func_806B75F4,40,yes +us,.code,func_80639CD0,588,no +us,.code,func_8064B574,48,yes +us,.code,func_806886E0,608,no +us,.code,func_80713438,380,no +us,.code,func_80631C3C,336,no +us,.code,func_80660520,784,no +us,.code,func_80714A08,32,yes +us,.code,func_8070CAB4,120,yes +us,.code,func_8064D0C4,292,no +us,.code,func_806891D8,120,yes +us,.code,func_806A7B70,36,yes +us,.code,func_806B54BC,1492,no +us,.code,func_80659574,60,no +us,.code,func_806534E0,420,no +us,.code,func_80724994,140,no +us,.code,func_8064AB1C,268,no +us,.code,func_8068B81C,20,yes +us,.code,func_8066E5CC,44,yes +us,.code,func_806C8F8C,312,no +us,.code,func_80648000,620,no +us,.code,func_806CF2EC,172,no +us,.code,func_806BFA8C,296,no +us,.code,func_80675DD0,108,no +us,.code,func_8069084C,228,no +us,.code,func_80655DD0,3528,no +us,.code,func_80649FC0,448,no +us,.code,func_80630890,736,no +us,.code,func_806B1EE8,32,yes +us,.code,func_806A10BC,112,no +us,.code,func_805FC98C,216,no +us,.code,func_8065F614,100,yes +us,.code,func_806EBDAC,24,yes +us,.code,func_8060B110,48,no +us,.code,func_80636210,180,no +us,.code,func_8064C3E8,348,no +us,.code,func_8072D9D4,140,yes +us,.code,func_806DAF5C,304,yes +us,.code,func_806B13B4,2500,no +us,.code,func_80666D88,380,no +us,.code,func_8063495C,160,no +us,.code,func_806CB53C,2312,yes +us,.code,func_807245D8,24,yes +us,.code,func_80601CF0,52,yes +us,.code,func_806EE2B8,412,yes +us,.code,func_806D2744,64,yes +us,.code,func_80636AE8,104,no +us,.code,alSeqpSetSeq,76,yes +us,.code,func_806B3F90,516,no +us,.code,_n_freePVoice,64,yes +us,.code,func_8063D990,64,no +us,.code,func_806E65BC,540,no +us,.code,func_806D3AE8,32,yes +us,.code,func_80655AD0,288,no +us,.code,func_80698120,3788,no +us,.code,func_80645C04,272,yes +us,.code,func_80697230,1740,no +us,.code,func_806111BC,60,yes +us,.code,func_80725ED4,656,no +us,.code,func_8065A660,152,yes +us,.code,getLevelIndex,152,yes +us,.code,func_80703374,592,no +us,.code,func_806531B8,524,no +us,.code,func_8060B7C4,12,yes +us,.code,func_80737630,8,yes +us,.code,func_80648C84,1176,no +us,.code,func_8073F1E4,324,no +us,.code,func_80610268,168,no +us,.code,func_8071C620,504,no +us,.code,func_80715B30,776,no +us,.code,func_8065EA44,84,yes +us,.code,func_806ECA74,80,yes +us,.code,func_80655410,1728,no +us,.code,func_806C5FEC,476,no +us,.code,func_8064E65C,1004,no +us,.code,func_806713E4,324,no +us,.code,func_80717D84,48,no +us,.code,func_80688540,68,yes +us,.code,func_807135B4,424,no +us,.code,func_8066BFF0,236,no +us,.code,func_8062A348,168,yes +us,.code,func_8071ABDC,852,no +us,.code,func_80723428,92,yes +us,.code,func_806A7BB8,36,yes +us,.code,func_8071BC80,388,no +us,.code,func_806EB964,160,yes +us,.code,func_8070B7EC,2580,no +us,.code,func_806FB8B0,100,no +us,.code,func_806CFD68,64,yes +us,.code,func_807380CC,76,no +us,.code,func_806D22A0,32,yes +us,.code,func_806392BC,1576,no +us,.code,func_80663594,556,no +us,.code,func_80662158,40,yes +us,.code,func_8065776C,520,no +us,.code,func_806436E0,364,no +us,.code,func_806E1F8C,256,yes +us,.code,func_8072E1A4,136,yes +us,.code,func_806A1580,808,no +us,.code,func_80729E6C,68,yes +us,.code,func_80678050,624,no +us,.code,func_80632E10,100,no +us,.code,func_806CA540,184,yes +us,.code,func_8073B6B0,160,no +us,.code,func_80690930,248,no +us,.code,func_80737638,748,no +us,.code,func_806EAE60,268,yes +us,.code,func_8066B75C,80,no +us,.code,func_80724874,60,no +us,.code,func_8062A774,92,yes +us,.code,func_80676730,44,yes +us,.code,func_80646DC4,836,no +us,.code,func_8073928C,148,no +us,.code,func_806A2B90,672,no +us,.code,func_8065D008,244,no +us,.code,func_8066785C,352,no +us,.code,func_8060C340,240,yes +us,.code,func_8060E574,240,yes +us,.code,func_807232EC,52,yes +us,.code,func_806307AC,32,yes +us,.code,func_80673D48,660,no +us,.code,func_806BDD90,312,no +us,.code,func_8064C644,196,no +us,.code,func_80735958,72,no +us,.code,func_806D32C0,108,yes +us,.code,func_8070C590,632,no +us,.code,func_8063D2E4,388,no +us,.code,func_8065919C,280,no +us,.code,func_8070D568,236,no +us,.code,func_806C7230,8,yes +us,.code,func_8064EE08,544,no +us,.code,func_80713EA8,8,yes +us,.code,func_806978FC,140,no +us,.code,func_80611160,12,yes +us,.code,func_806E7088,20,yes +us,.code,func_8068FF40,280,no +us,.code,func_8064BE58,40,yes +us,.code,func_80673C34,276,no +us,.code,func_806FD950,80,no +us,.code,func_806F8DC4,240,yes +us,.code,func_80666AAC,12,yes +us,.code,func_8071A8B0,556,no +us,.code,func_806846B4,412,yes +us,.code,func_80674A5C,128,no +us,.code,func_806CCB0C,136,yes +us,.code,func_806EBCF0,188,yes +us,.code,func_8067E724,64,yes +us,.code,func_80600D50,848,no +us,.code,func_80678F64,56,yes +us,.code,func_8072A450,708,no +us,.code,func_8069346C,2644,no +us,.code,func_80730408,1764,no +us,.code,func_805FF118,64,yes +us,.code,func_806D1B60,476,yes +us,.code,func_807311C4,216,no +us,.code,func_806D26D8,108,yes +us,.code,func_8063B758,384,no +us,.code,func_8068B930,132,no +us,.code,func_806DE264,1740,no +us,.code,func_806E4580,180,yes +us,.code,func_80691830,256,yes +us,.code,func_8061032C,36,no +us,.code,func_8067C6FC,32,yes +us,.code,func_806F8D58,108,yes +us,.code,func_8068588C,92,yes +us,.code,func_80650AD8,120,no +us,.code,func_806E4634,268,yes +us,.code,func_8069D424,1292,no +us,.code,func_8073CA04,188,no +us,.code,func_806F3DB0,24,yes +us,.code,func_806A5868,1016,no +us,.code,func_806E7B48,296,yes +us,.code,func_80690814,56,yes +us,.code,func_80723020,612,no +us,.code,func_806BC1E0,3512,no +us,.code,func_8062BCC8,232,no +us,.code,_n_timeToSamplesNoRound,100,yes +us,.code,func_806744A8,212,no +us,.code,func_80688514,44,yes +us,.code,func_8071F758,396,no +us,.code,func_806D9924,28,yes +us,.code,func_806F03C4,608,no +us,.code,func_806EFF34,312,yes +us,.code,func_80678530,164,yes +us,.code,func_806C7238,8,yes +us,.code,func_806E1A50,340,yes +us,.code,func_80684550,104,yes +us,.code,func_8066B9F4,56,yes +us,.code,func_806D12CC,340,yes +us,.code,func_8063FA48,7388,no +us,.code,func_8068A830,40,yes +us,.code,func_80719B88,120,no +us,.code,func_806CC948,40,yes +us,.code,func_8071EFDC,88,no +us,.code,func_807318AC,176,no +us,.code,func_8063CF0C,48,yes +us,.code,func_80658E8C,644,no +us,.code,func_80631EB8,160,no +us,.code,func_8060EE58,8,yes +us,.code,func_806E9964,248,yes +us,.code,func_80647834,480,no +us,.code,func_80712B80,84,yes +us,.code,func_806418E8,180,no +us,.code,func_806C81DC,68,yes +us,.code,func_8064C544,256,no +us,.code,func_80675478,304,no +us,.code,func_8070CC8C,56,yes +us,.code,func_8062BDB0,372,no +us,.code,func_8070C8F4,156,yes +us,.code,func_806755A8,616,no +us,.code,func_806E5EA8,44,yes +us,.code,func_806D7A28,976,no +us,.code,func_806CA2AC,56,yes +us,.code,func_80731B88,408,no +us,.code,func_8067641C,188,no +us,.code,func_80731AA8,116,yes +us,.code,func_806DDAB0,1972,no +us,.code,func_806582F8,532,no +us,.code,func_80667180,312,no +us,.code,func_80693EC0,1532,no +us,.code,func_806D0DE4,216,no +us,.code,func_806EACBC,48,yes +us,.code,func_806B1F08,32,yes +us,.code,func_80712FC8,192,yes +us,.code,func_8070C200,16,no +us,.code,func_806F1EB0,1016,no +us,.code,func_806B7660,68,yes +us,.code,func_80601224,52,yes +us,.code,func_80733A88,256,no +us,.code,func_80641B00,204,no +us,.code,func_806F3BEC,452,no +us,.code,func_8070943C,40,yes +us,.code,func_8067E43C,152,no +us,.code,func_80639968,668,no +us,.code,func_805FBFF4,700,no +us,.code,func_80731784,120,no +us,.code,func_806FA7A4,24,yes +us,.code,func_806025AC,40,yes +us,.code,func_806E527C,84,no +us,.code,func_806A1ABC,8,yes +us,.code,func_8060E1A8,180,yes +us,.code,func_80649E34,304,no +us,.code,func_80735A34,16,no +us,.code,func_805FFE50,168,yes +us,.code,func_806FCC88,1036,no +us,.code,func_8062E67C,540,no +us,.code,func_806CFC90,216,yes +us,.code,func_8067AF74,168,yes +us,.code,func_806357F8,240,no +us,.code,func_8073AB00,584,no +us,.code,func_8066EBF4,120,yes +us,.code,func_806D8FCC,360,yes +us,.code,func_806FBC34,296,no +us,.code,func_8068B8A4,88,no +us,.code,func_806BB400,516,no +us,.code,func_806CFDA8,68,yes +us,.code,func_8067AE58,56,yes +us,.code,func_806A60E4,40,yes +us,.code,func_80669A6C,380,no +us,.code,func_806F2EDC,228,no +us,.code,func_80652F24,120,yes +us,.code,func_807271F4,436,no +us,.code,func_806CA0E8,204,yes +us,.code,func_8060C648,112,yes +us,.code,func_806D72D4,572,no +us,.code,func_806E8A8C,100,yes +us,.code,func_806C9434,412,yes +us,.code,alEvtqFlushType,208,yes +us,.code,func_80714A9C,232,yes +us,.code,func_8068DBA4,176,no +us,.code,func_8070033C,848,no +us,.code,func_8066C7F4,188,no +us,.code,func_80611594,8,yes +us,.code,func_806782E8,212,yes +us,.code,func_8072D714,648,no +us,.code,func_8072DCF4,284,no +us,.code,func_806425FC,332,no +us,.code,func_806B6C88,296,yes +us,.code,func_8066B7AC,72,yes +us,.code,func_8071E110,184,no +us,.code,func_8062E040,440,no +us,.code,func_80682E38,532,no +us,.code,func_8067B290,8,yes +us,.code,func_806A081C,72,yes +us,.code,func_8066BC00,92,no +us,.code,getEEPROMSaveSlot,68,yes +us,.code,func_806B02EC,104,yes +us,.code,func_8063DC58,528,no +us,.code,func_80662618,436,no +us,.code,func_80647A14,352,no +us,.code,func_8072B59C,108,yes +us,.code,func_8068A2AC,88,yes +us,.code,getExitData,364,yes +us,.code,func_8071497C,16,yes +us,.code,func_8065C990,1040,no +us,.code,func_8068613C,516,no +us,.code,func_806E384C,692,no +us,.code,func_806AD7AC,160,yes +us,.code,func_806F4778,1528,no +us,.code,func_806DEAA4,560,no +us,.code,func_80696574,1272,no +us,.code,func_806E8F04,100,yes +us,.code,func_80709890,572,no +us,.code,func_806685E0,276,no +us,.code,func_80726744,1592,no +us,.code,func_8064FA7C,232,no +us,.code,func_8060D0A8,164,yes +us,.code,func_805FF544,92,yes +us,.code,func_8066E854,144,yes +us,.code,func_806D7878,364,yes +us,.code,func_80650C28,112,no +us,.code,func_806D1F28,308,yes +us,.code,func_80647108,104,yes +us,.code,func_806D8B08,1220,no +us,.code,func_8064AC28,1264,no +us,.code,func_8070CC1C,56,yes +us,.code,func_8060FAA4,64,yes +us,.code,func_8073C040,1476,no +us,.code,func_8073E460,476,no +us,.code,func_8066F250,36,yes +us,.code,func_806F7378,40,yes +us,.code,func_80669BE8,132,yes +us,.code,func_80704B20,4084,no +us,.code,func_806728F0,384,yes +us,.code,func_8060E4D0,164,yes +us,.code,func_806EAA44,92,yes +us,.code,func_806593C8,168,no +us,.code,func_8071D5BC,456,no +us,.code,func_806508B4,120,no +us,.code,func_8064F954,40,yes +us,.code,func_807270C0,212,yes +us,.code,func_807189BC,568,no +us,.code,func_80715908,308,no +us,.code,func_806D423C,80,yes +us,.code,func_80627F04,4676,no +us,.code,func_80656B98,704,no +us,.code,func_806358E8,1544,no +us,.code,func_8069A614,316,no +us,.code,func_80711950,640,no +us,.code,func_8060DEC8,608,yes +us,.code,func_80669830,256,no +us,.code,func_806EE7B8,60,yes +us,.code,func_8069D058,32,yes +us,.code,func_8060AA58,224,no +us,.code,func_80717D4C,56,no +us,.code,func_806E2ECC,112,yes +us,.code,func_80659610,16,yes +us,.code,func_806EB194,292,yes +us,.code,func_805FC668,804,no +us,.code,func_806F5C30,180,yes +us,.code,func_80704298,428,no +us,.code,func_806EA460,264,yes +us,.code,func_806EBF74,92,yes +us,.code,func_806EBB44,140,yes +us,.code,func_8065F964,416,no +us,.code,func_80719C00,756,no +us,.code,func_806D7170,200,yes +us,.code,func_806E1E54,312,yes +us,.code,func_80673240,104,no +us,.code,func_8067A69C,112,yes +us,.code,func_80690190,556,no +us,.code,func_8060AC28,12,yes +us,.code,func_80709344,248,yes +us,.code,func_8067DF44,820,no +us,.code,func_806C61C8,872,no +us,.code,func_806B761C,68,yes +us,.code,func_8070F5CC,1164,no +us,.code,func_8067B01C,228,no +us,.code,func_8065D1AC,152,no +us,.code,func_806FE078,3384,no +us,.code,func_806EAB44,328,yes +us,.code,func_8071B520,568,no +us,.code,func_806EC3BC,240,yes +us,.code,func_8062D414,524,no +us,.code,func_806D0A54,48,yes +us,.code,func_806CC364,632,no +us,.code,func_8067AA58,96,yes +us,.code,func_806EE994,200,yes +us,.code,func_80718380,372,no +us,.code,func_8063D288,92,yes +us,.code,func_8070FCCC,928,no +us,.code,func_806F9AF0,116,no +us,.code,func_8067E510,396,no +us,.code,alSepqSetVol,76,yes +us,.code,func_8068A1CC,64,yes +us,.code,func_80689064,176,no +us,.code,n_alInit,108,yes +us,.code,func_80679064,144,yes +us,.code,func_806FA9C0,352,no +us,.code,func_806EA568,100,no +us,.code,func_806B4194,276,yes +us,.code,func_806B8BDC,156,yes +us,.code,func_806D80A8,608,yes +us,.code,func_806C1734,704,no +us,.code,func_80610310,28,no +us,.code,func_8063C4C4,532,no +us,.code,func_80676690,80,yes +us,.code,func_80696A6C,1632,no +us,.code,func_806C2A64,200,yes +us,.code,func_80666FC8,328,yes +us,.code,func_8065D0FC,116,yes +us,.code,func_80671C0C,260,no +us,.code,func_806057F8,11568,no +us,.code,func_80710CA0,1904,no +us,.code,func_8062A944,804,no +us,.code,func_807186C8,756,no +us,.code,func_8069E660,196,yes +us,.code,func_806EA958,92,yes +us,.code,func_80670FA4,316,no +us,.code,func_806787FC,8,yes +us,.code,func_8070DA28,76,no +us,.code,func_807238D4,964,no +us,.code,func_8067B2C0,28,yes +us,.code,func_8068C3A0,520,no +us,.code,func_806925AC,148,yes +us,.code,func_80704444,64,no +us,.code,func_806CD8EC,156,yes +us,.code,func_80714A58,16,yes +us,.code,func_806B9CB0,48,yes +us,.code,func_806F8170,264,yes +us,.code,func_8069DD40,536,no +us,.code,func_80661520,156,no +us,.code,func_8067C6BC,32,yes +us,.code,func_8067618C,68,yes +us,.code,func_806F5378,116,yes +us,.code,func_80724A20,124,no +us,.code,func_8066641C,12,yes +us,.code,func_8066B0EC,12,yes +us,.code,func_80714708,112,no +us,.code,func_8071A1E4,604,no +us,.code,func_80666AE0,12,yes +us,.code,func_80644D50,220,no +us,.code,func_806E7050,56,yes +us,.code,func_80661264,80,no +us,.code,func_8063C7C4,696,no +us,.code,func_80704AFC,36,yes +us,.code,func_806C9830,324,yes +us,.code,func_8070770C,628,no +us,.code,func_806A6134,40,yes +us,.code,func_806EE6B0,80,yes +us,.code,func_8063162C,424,no +us,.code,func_806896D0,32,yes +us,.code,func_80678BBC,268,yes +us,.code,func_806CF42C,140,yes +us,.code,func_806EB4F8,76,yes +us,.code,func_80676260,32,yes +us,.code,func_806115A8,108,no +us,.code,func_806E0BEC,340,yes +us,.code,func_80601728,88,yes +us,.code,func_806111F8,276,no +us,.code,func_80653FA4,988,no +us,.code,func_80730D60,184,yes +us,.code,func_806B3C30,100,yes +us,.code,func_806C4904,68,yes +us,.code,func_806ABC94,424,no +us,.code,func_806F8EDC,728,no +us,.code,func_8063DFEC,140,no +us,.code,func_80641724,152,no +us,.code,func_806C7200,8,yes +us,.code,func_806BB604,536,no +us,.code,func_8060B7D0,28,yes +us,.code,func_8063DB0C,48,yes +us,.code,func_80604C80,60,yes +us,.code,func_805FF1B0,324,no +us,.code,func_806FB3D0,72,no +us,.code,func_806E0178,284,yes +us,.code,func_806D239C,268,yes +us,.code,func_8065E138,1276,no +us,.code,func_8073B900,176,no +us,.code,func_806E9F8C,192,no +us,.code,func_806CD9A0,900,no +us,.code,func_8067B450,120,no +us,.code,func_806E9B3C,108,yes +us,.code,func_8063373C,376,no +us,.code,n_alAudioFrame,548,no +us,.code,func_8065EA98,52,yes +us,.code,func_806D0468,568,no +us,.code,func_8071EA24,332,no +us,.code,func_80713088,76,yes +us,.code,func_806E0294,308,yes +us,.code,func_8071EB70,636,no +us,.code,func_806E7484,228,yes +us,.code,func_80650D8C,148,no +us,.code,func_80737A4C,40,no +us,.code,func_8062A844,8,yes +us,.code,func_80663A80,360,no +us,.code,func_806D2BD0,132,yes +us,.code,func_806CCB94,124,yes +us,.code,func_80656F14,1444,no +us,.code,func_806EBE8C,68,no +us,.code,func_806D2A14,140,yes +us,.code,func_80669588,200,no +us,.code,func_807375E0,32,no +us,.code,func_8070CA2C,68,yes +us,.code,playerCanDive,116,yes +us,.code,func_806EE878,172,yes +us,.code,func_807146E0,20,yes +us,.code,func_806EA8A0,92,yes +us,.code,func_806CF398,148,yes +us,.code,func_80662108,8,yes +us,.code,func_80731E68,452,no +us,.code,func_80737600,8,yes +us,.code,func_806E78E0,24,yes +us,.code,func_8071EEA4,60,no +us,.code,func_80632630,560,no +us,.code,func_806915B0,640,no +us,.code,func_806EE5A4,144,yes +us,.code,func_806F1350,40,yes +us,.code,func_8062DB70,108,no +us,.code,func_80701098,3064,no +us,.code,func_80631D8C,300,no +us,.code,func_80727194,96,no +us,.code,func_80733180,2312,no +us,.code,func_806EAFF4,100,yes +us,.code,func_806B2D64,1724,no +us,.code,func_8072AA80,244,no +us,.code,func_80600454,220,yes +us,.code,func_806B0848,2424,no +us,.code,func_80679178,100,yes +us,.code,func_8066C2D0,832,no +us,.code,func_806524A0,244,yes +us,.code,func_806CFEF4,40,yes +us,.code,func_80714CC0,72,yes +us,.code,func_8068E474,832,no +us,.code,func_8070D6D8,124,yes +us,.code,func_8062B840,44,yes +us,.code,func_80634F14,140,yes +us,.code,func_8067B1E0,88,yes +us,.code,func_806DFFA0,60,yes +us,.code,func_80732930,124,no +us,.code,func_8065C334,1628,no +us,.code,func_806F93EC,64,yes +us,.code,func_806CF9CC,708,no +us,.code,func_80602C6C,116,yes +us,.code,func_8068C5A8,3260,no +us,.code,func_806505F0,148,yes +us,.code,func_8063DBD8,128,yes +us,.code,func_8062CA70,1080,no +us,.code,func_80713DFC,172,yes +us,.code,func_8063D854,208,yes +us,.code,func_8073E800,160,no +us,.code,func_8066466C,456,no +us,.code,func_806E7780,312,yes +us,.code,func_806F1B58,56,no +us,.code,func_80666280,16,yes +us,.code,func_806DC170,564,no +us,.code,func_806A18A8,532,no +us,.code,func_806A6004,144,yes +us,.code,func_806595B0,64,no +us,.code,func_806651FC,452,no +us,.code,func_806FB218,120,yes +us,.code,func_806FB290,40,yes +us,.code,func_8064954C,356,no +us,.code,func_8064B190,116,no +us,.code,func_806C7208,8,yes +us,.code,func_80630DCC,2144,no +us,.code,func_8073B830,208,no +us,.code,func_8064ED68,160,yes +us,.code,func_8073D160,144,no +us,.code,func_80727F20,228,no +us,.code,func_806118FC,152,yes +us,.code,func_80601120,76,yes +us,.code,func_806E7338,332,yes +us,.code,func_806C226C,1392,no +us,.code,func_806BFBF4,5292,no +us,.code,func_806B6958,816,yes +us,.code,func_806E1630,248,yes +us,.code,func_80719EF4,324,no +us,.code,func_806A610C,40,yes +us,.code,func_806E3CEC,40,yes +us,.code,func_806C9ED0,48,yes +us,.code,func_806D69A4,348,yes +us,.code,func_806CA1B4,184,yes +us,.code,func_806DA94C,200,yes +us,.code,func_806338F4,72,no +us,.code,func_806ADDD8,520,no +us,.code,func_806E3C14,36,yes +us,.code,func_80688940,300,yes +us,.code,func_806998C8,32,yes +us,.code,func_806ECE2C,240,yes +us,.code,func_80685F60,476,no +us,.code,func_8060B55C,100,yes +us,.code,func_806F027C,200,yes +us,.code,func_806E9A5C,112,yes +us,.code,func_8072E02C,124,yes +us,.code,func_806E31FC,272,yes +us,.code,func_806C850C,1144,no +us,.code,func_8071321C,84,yes +us,.code,func_806C6530,852,no +us,.code,func_80737B50,8,yes +us,.code,func_8066FE08,1856,no +us,.code,func_806CEB44,192,no +us,.code,func_80703CF8,984,no +us,.code,func_807149C8,52,yes +us,.code,func_8064B514,96,no +us,.code,func_80726E60,128,no +us,.code,func_80737CF4,316,no +us,.code,func_806E709C,404,yes +us,.code,setFlag,288,yes +us,.code,func_80600C68,232,no +us,.code,func_806EAC8C,48,yes +us,.code,func_80691930,176,yes +us,.code,func_80644EC8,504,no +us,.code,func_806A6574,216,no +us,.code,func_80602B60,172,no +us,.code,func_8067A70C,120,yes +us,.code,func_806A5C60,400,no +us,.code,func_8065850C,280,no +us,.code,gameIsInMainMenuMode,20,yes +us,.code,func_8071B89C,80,no +us,.code,func_806B3C94,132,yes +us,.code,func_806E4D14,112,yes +us,.code,func_807158C0,72,no +us,.code,func_806CE174,880,no +us,.code,func_806E6F74,124,yes +us,.code,func_806398E4,132,no +us,.code,func_80662188,72,yes +us,.code,func_806AE2B0,228,yes +us,.code,func_807069A4,1516,no +us,.code,func_80678E6C,248,yes +us,.code,func_8064F84C,264,no +us,.code,func_8072E0A8,252,no +us,.code,func_806F96CC,120,no +us,.code,func_806F149C,32,yes +us,.code,func_806D3B28,32,yes +us,.code,func_80736FB8,112,no +us,.code,func_807094D0,276,no +us,.code,func_8060B49C,56,yes +us,.code,func_806B3E08,116,yes +us,.code,func_806A1FD8,848,no +us,.code,func_8060131C,132,yes +us,.code,func_8062B220,420,no +us,.code,func_806ED420,232,yes +us,.code,func_806E560C,224,no +us,.code,func_806E918C,508,no +us,.code,func_8060A6A0,288,no +us,.code,func_8060AB38,16,yes +us,.code,func_80676BCC,68,no +us,.code,func_80629300,3632,no +us,.code,func_806F014C,56,yes +us,.code,func_80740A90,448,no +us,.code,func_806833DC,756,no +us,.code,func_80729AA4,80,yes +us,.code,func_805FEF10,100,no +us,.code,func_80690A28,136,no +us,.code,func_806E2B20,340,no +us,.code,func_8060E8CC,32,yes +us,.code,func_8062A7D0,56,yes +us,.code,func_807085D0,1512,no +us,.code,func_806E521C,96,yes +us,.code,func_806B1348,108,yes +us,.code,__n_allocParam,96,yes +us,.code,func_806F6EDC,76,yes +us,.code,func_806EBA74,128,yes +us,.code,func_8070F570,92,yes +us,.code,func_806A112C,1108,no +us,.code,func_8062D1E0,140,no +us,.code,func_806E5ED4,204,yes +us,.code,func_80676B70,92,yes +us,.code,func_806F06A4,92,yes +us,.code,func_80603450,5500,no +us,.code,func_8062A228,36,yes +us,.code,func_8060116C,52,yes +us,.code,func_80717CE8,100,no +us,.code,func_806717FC,132,yes +us,.code,func_806EE10C,184,yes +us,.code,func_8064B118,56,yes +us,.code,func_8073CDD0,304,no +us,.code,func_8067C71C,5540,no +us,.code,func_806DF3D0,124,yes +us,.code,func_806FD894,76,no +us,.code,func_8067B4C8,1396,no +us,.code,func_8063C784,64,yes +us,.code,func_80692540,36,yes +us,.code,func_806C9FD8,112,yes +us,.code,func_807103E0,500,no +us,.code,func_8065A708,380,no +us,.code,func_8064B7E8,64,yes +us,.code,func_8068A858,904,no +us,.code,func_80684900,256,yes +us,.code,func_806D2E9C,904,no +us,.code,func_8064E174,692,no +us,.code,func_806D024C,300,yes +us,.code,func_806E884C,52,yes +us,.code,func_8069B908,5268,no +us,.code,func_806A734C,32,yes +us,.code,func_80688320,80,yes +us,.code,func_8070D754,216,no +us,.code,func_80714608,48,yes +us,.code,func_8073D060,224,no +us,.code,func_8060CB9C,32,yes +us,.code,func_8067B280,8,yes +us,.code,func_806907B8,40,yes +us,.code,func_806A1F64,108,yes +us,.code,func_806FEDB0,460,no +us,.code,func_8068AD7C,2704,no +us,.code,func_8072E320,556,no +us,.code,func_806CF4B8,200,no +us,.code,func_806E41EC,916,yes +us,.code,func_80635548,64,no +us,.code,func_80670548,1812,no +us,.code,func_806C71C0,8,yes +us,.code,func_80604BE8,152,yes +us,.code,func_80717100,268,no +us,.code,func_806A7BDC,788,no +us,.code,gameIsInMysteryMenuMinigameMode,52,yes +us,.code,func_8062E548,192,no +us,.code,func_80650794,288,no +us,.code,func_8073E8B4,8,yes +us,.code,func_806F70FC,636,no +us,.code,func_806D3A38,144,yes +us,.code,func_806ECC48,148,yes +us,.code,func_80636448,124,yes +us,.code,func_80611724,12,yes +us,.code,func_8060BB18,200,no +us,.code,func_806C71C8,8,yes +us,.code,func_806F833C,1872,no +us,.code,func_80737AC4,104,no +us,.code,func_8062F640,856,no +us,.code,func_806EA04C,88,yes +us,.code,func_8063A8C4,164,no +us,.code,func_80737198,212,no +us,.code,func_80647D7C,644,no +us,.code,func_8063C418,56,yes +us,.code,func_8060245C,44,yes +us,.code,func_80600530,96,yes +us,.code,func_80650C98,108,no +us,.code,func_8066B4AC,40,yes +us,.code,func_8073A070,192,no +us,.code,func_8067B2B8,8,yes +us,.code,func_806D11FC,60,yes +us,.code,func_80634FA0,120,yes +us,.code,func_8066893C,180,no +us,.code,func_806C4F5C,1660,no +us,.code,func_806017B4,52,yes +us,.code,func_80717404,860,no +us,.code,func_806AE394,500,no +us,.code,func_806D850C,752,yes +us,.code,func_8064EB3C,96,yes +us,.code,func_8073D1F0,2112,no +us,.code,func_80657E24,240,no +us,.code,func_806F0C18,336,no +us,.code,func_806E8880,44,yes +us,.code,func_806A5EAC,152,no +us,.code,func_806639CC,64,yes +us,.code,func_806E5488,388,yes +us,.code,func_80709ACC,248,no +us,.code,func_8068A20C,64,yes +us,.code,func_8067AE0C,76,yes +us,.code,func_806790F4,132,no +us,.code,func_8067B2DC,280,yes +us,.code,func_806D34B4,124,no +us,.code,func_80694D20,1168,no +us,.code,func_8069DC10,112,no +us,.code,func_806DD24C,1576,no +us,.code,func_80714360,52,yes +us,.code,func_8064F210,224,no +us,.code,func_8060ED6C,100,yes +us,.code,func_806794EC,2264,no +us,.code,func_806D97A4,124,yes +us,.code,func_80683158,412,no +us,.code,func_806F9848,680,no +us,.code,func_8068A3A0,100,no +us,.code,func_8072F120,272,no +us,.code,func_806653C0,392,no +us,.code,func_806F1B90,116,yes +us,.code,func_806884B8,44,yes +us,.code,func_8071D94C,552,no +us,.code,func_806F5498,72,yes +us,.code,func_80699958,3260,no +us,.code,func_80703AB0,584,no +us,.code,func_806CD988,24,yes +us,.code,func_8064EC60,264,no +us,.code,func_80682DF4,68,no +us,.code,func_8070DB7C,32,no +us,.code,func_806FB418,96,yes +us,.code,func_8073C9C0,68,no +us,.code,func_806FB490,644,no +us,.code,func_8069E088,388,yes +us,.code,func_80631B8C,64,yes +us,.code,func_806E7900,584,yes +us,.code,func_8072F4A8,244,yes +us,.code,func_806D24E4,232,yes +us,.code,func_80676AB8,128,no +us,.code,func_80646058,1816,no +us,.code,func_80731030,60,no +us,.code,func_80650A70,104,no +us,.code,alSeqpStop,64,yes +us,.code,func_80632F20,84,no +us,.code,func_806BD0CC,152,yes +us,.code,func_8063D608,48,yes +us,.code,func_8067E6E4,32,yes +us,.code,func_8072F59C,824,no +us,.code,func_80737B58,200,no +us,.code,func_8068304C,268,no +us,.code,func_806D2D38,140,yes +us,.code,func_806E6318,80,yes +us,.code,func_806DA320,196,yes +us,.code,func_806C6884,716,no +us,.code,func_8070068C,300,no +us,.code,func_8060C6B8,108,yes +us,.code,func_8063C4A8,28,yes +us,.code,func_806F9744,260,no +us,.code,func_8069E4E0,216,yes +us,.code,func_80737608,40,no +us,.code,func_806E607C,340,yes +us,.code,func_8065297C,140,yes +us,.code,func_806F6644,868,no +us,.code,func_80635018,128,yes +us,.code,func_80642748,252,no +us,.code,func_80690AB0,312,no +us,.code,func_8068A074,152,yes +us,.code,func_80677148,1220,no +us,.code,func_806D0964,132,yes +us,.code,func_805FF898,96,yes +us,.code,func_80672E90,44,no +us,.code,func_806013E8,156,yes +us,.code,func_8064AAC4,88,no +us,.code,func_806B1F50,1384,no +us,.code,func_80686390,1500,no +us,.code,func_8064B260,76,no +us,.code,func_80632FCC,248,no +us,.code,func_80731B20,64,yes +us,.code,func_8072DC7C,120,yes +us,.code,func_8072DB68,276,yes +us,.code,func_8066B7F4,212,no +us,.code,func_8069E018,40,yes +us,.code,func_80663C60,312,yes +us,.code,func_806BD094,56,yes +us,.code,func_80679010,84,no +us,.code,func_806B9CE0,468,yes +us,.code,func_805FE544,240,yes +us,.code,func_806F1250,172,yes +us,.code,func_806A1FD0,8,yes +us,.code,func_8073A900,140,no +us,.code,func_80641874,116,no +us,.code,func_80601EE4,544,no +us,.code,func_8060A1B0,488,no +us,.code,func_80602498,276,no +us,.code,func_80643F38,356,no +us,.code,func_8060EA28,556,yes +us,.code,func_806A7B94,36,yes +us,.code,func_8072EA90,516,no +us,.code,func_8068C20C,224,no +us,.code,func_80636EFC,256,no +us,.code,func_806EA334,300,yes +us,.code,func_8072E2B0,112,yes +us,.code,func_80714A28,16,yes +us,.code,func_806E78B8,40,yes +us,.code,func_80713168,84,yes +us,.code,func_806B1D78,92,yes +us,.code,func_805FF660,16,yes +us,.code,func_806C7250,8,yes +us,.code,func_807040D0,16,yes +us,.code,func_8067A784,104,yes +us,.code,func_805FC2B0,952,no +us,.code,func_80713AA8,152,no +us,.code,func_80705C00,860,no +us,.code,func_806A8070,72,yes +us,.code,func_8060F730,292,no +us,.code,func_8067AC38,124,yes +us,.code,func_8060C830,124,yes +us,.code,func_8067B100,224,no +us,.code,func_80724C2C,76,yes +us,.code,func_806575D0,412,no +us,.code,func_80666AB8,12,yes +us,.code,func_806F1668,256,yes +us,.code,func_8067C2B8,964,no +us,.code,func_80713C8C,368,no +us,.code,func_806CC8F0,48,yes +us,.code,func_806B49B0,1052,no +us,.code,func_806E9CDC,32,yes +us,.code,func_8071D784,456,no +us,.code,func_80733C34,344,no +us,.code,func_8067B2B0,8,yes +us,.code,func_80689DD4,196,no +us,.code,func_8070D970,60,no +us,.code,func_806545D4,468,no +us,.code,func_806BC0E4,100,yes +us,.code,func_8072C670,512,no +us,.code,func_806D9320,1156,no +us,.code,func_806E854C,472,no +us,.code,func_806D2238,104,yes +us,.code,func_806CC284,224,yes +us,.code,func_806EC994,224,yes +us,.code,func_806FB370,96,no +us,.code,func_8063D930,96,no +us,.code,func_80689C20,436,no +us,.code,func_8067889C,328,no +us,.code,func_807314F4,224,no +us,.code,func_806C7258,8,yes +us,.code,func_806D45A4,436,yes +us,.code,func_806E6A38,352,yes +us,.code,func_806B1EC8,32,yes +us,.code,func_806EFB4C,236,yes +us,.code,func_806E8D54,96,yes +us,.code,func_8072DE10,52,yes +us,.code,func_8072C918,1744,no +us,.code,func_80726D7C,68,yes +us,.code,func_806CEED8,228,no +us,.code,func_80712634,36,yes +us,.code,func_806730A4,412,no +us,.code,func_806D3BC8,268,yes +us,.code,func_80631FAC,216,no +us,.code,func_806F8AD4,240,yes +us,.code,func_806F5FE8,84,yes +us,.code,func_806F942C,68,yes +us,.code,func_806A4B84,600,no +us,.code,func_806D22C0,112,yes +us,.code,func_80636B50,176,no +us,.code,func_8060095C,48,yes +us,.code,func_806F6F28,384,yes +us,.code,func_806F53EC,96,yes +us,.code,func_806FD490,792,no +us,.code,func_806A6408,96,yes +us,.code,func_80738400,112,no +us,.code,func_806F0074,8,yes +us,.code,func_80662180,8,yes +us,.code,func_806D1D84,104,yes +us,.code,func_806F1990,136,no +us,.code,func_806D1080,80,yes +us,.code,func_806A9124,248,no +us,.code,func_806FDF1C,56,yes +us,.code,func_8067605C,304,no +us,.code,func_80601D24,448,no +us,.code,func_8068D9DC,280,no +us,.code,func_8064F97C,256,no +us,.code,func_806DF6D4,2144,no +us,.code,func_8064B7D4,20,yes +us,.code,func_80676590,88,yes +us,.code,func_806A60BC,40,yes +us,.code,func_806A285C,428,yes +us,.code,func_80635098,124,yes +us,.code,func_806EC4AC,604,no +us,.code,func_806D0430,56,yes +us,.code,func_8073F8A0,1264,no +us,.code,func_80611534,96,no +us,.code,func_8067881C,8,yes +us,.code,func_8072DA60,68,yes +us,.code,func_806A2B38,72,no +us,.code,func_806E4E88,444,yes +us,.code,func_806493C4,392,no +us,.code,func_8067AB20,160,yes +us,.code,func_8067A09C,212,no +us,.code,func_80686F90,240,yes +us,.code,func_806B8878,32,yes +us,.code,func_8066B4D4,244,no +us,.code,func_80652DB4,164,no +us,.code,func_8065FB64,548,no +us,.code,func_806882DC,68,yes +us,.code,func_80602144,408,no +us,.code,func_806D7FE8,136,yes +us,.code,func_806C7B34,28,yes +us,.code,func_80600340,172,no +us,.code,func_8067C67C,32,yes +us,.code,func_806637C0,132,no +us,.code,func_8064B5A4,500,no +us,.code,func_8068B9B4,120,no +us,.code,func_806E8BFC,48,yes +us,.code,func_8071F034,68,no +us,.code,func_806D4A70,524,no +us,.code,func_8064E55C,100,no +us,.code,func_8073C604,540,no +us,.code,func_80634768,332,no +us,.code,func_806EB178,28,yes +us,.code,func_806DF1A0,224,yes +us,.code,func_80712830,276,yes +us,.code,func_806E208C,180,no +us,.code,func_8071F8E4,412,no +us,.code,func_8064199C,92,no +us,.code,func_80737924,108,no +us,.code,func_80661B84,108,yes +us,.code,func_806F397C,108,yes +us,.code,func_806BA130,272,yes +us,.code,func_80687CC8,128,yes +us,.code,func_8070CD44,72,yes +us,.code,func_80732420,28,no +us,.code,func_806B76B0,384,no +us,.code,func_806ED5C0,240,yes +us,.code,func_8067E784,4932,no +us,.code,func_80689710,224,yes +us,.code,func_806DB670,1172,no +us,.code,func_806EA200,108,yes +us,.code,func_806B640C,500,no +us,.code,func_8063C1EC,92,yes +us,.code,func_80644A18,680,no +us,.code,func_8062C22C,112,yes +us,.code,func_8069900C,32,yes +us,.code,func_8060098C,388,no +us,.code,func_806BB81C,88,yes +us,.code,func_8063BF34,696,no +us,.code,func_8068A810,32,yes +us,.code,func_80689B10,156,yes +us,.code,func_806F4E74,72,yes +us,.code,func_806B24B8,728,no +us,.code,func_80732534,228,no +us,.code,func_806ACA88,376,no +us,.code,func_80679290,164,no +us,.code,func_8065996C,1092,no +us,.code,func_80692640,768,no +us,.code,func_8067470C,376,no +us,.code,func_80650684,100,yes +us,.code,func_80664834,516,no +us,.code,func_8066EABC,48,no +us,.code,func_80685D84,244,yes +us,.code,func_806CC920,40,yes +us,.code,func_806B1290,184,yes +us,.code,func_80724A9C,192,no +us,.code,func_806CFEA4,40,yes +us,.code,func_80732618,280,no +us,.code,func_806E5E58,8,yes +us,.code,func_8067E704,32,yes +us,.code,func_8071DB74,284,no +us,.code,func_806C8EE8,164,yes +us,.code,func_806F0238,68,yes +us,.code,func_8063DED0,284,no +us,.code,func_805FE398,316,no +us,.code,func_807131BC,96,yes +us,.code,func_8062D2F0,244,no +us,.code,func_80611850,172,no +us,.code,gameIsInAdventureMode,52,yes +us,.code,func_806319C4,444,no +us,.code,func_806B1F28,32,yes +us,.code,func_806B904C,404,no +us,.code,func_80658E58,52,yes +us,.code,func_8069CF54,196,no +us,.code,func_80647508,264,yes +us,.code,func_807127B4,64,yes +us,.code,func_8065F5F0,36,no +us,.code,func_8065A884,4636,no +us,.code,func_80718080,116,no +us,.code,func_806D91A4,380,no +us,.code,func_806BFBB4,64,yes +us,.code,func_8067A908,148,yes +us,.code,func_806CCC10,68,no +us,.code,func_8066F1F8,88,yes +us,.code,func_80685B44,576,no +us,.code,func_8062A3F0,900,no +us,.code,func_8073E73C,196,no +us,.code,func_80664D20,1088,no +us,.code,func_80643354,236,no +us,.code,func_80730AEC,628,no +us,.code,func_80655BF0,264,yes +us,.code,func_80677EC8,8,yes +us,.code,func_80692940,1296,no +us,.code,func_806CE4E4,700,no +us,.code,alUnlink,64,yes +us,.code,func_80671A6C,416,no +us,.code,func_8060128C,72,yes +us,.code,func_806C5C20,972,no +us,.code,func_80642844,252,no +us,.code,func_80672EBC,216,no +us,.code,func_806C55E0,1600,no +us,.code,func_80661054,528,no +us,.code,func_80661484,76,yes +us,.code,func_8062C99C,112,no +us,.code,func_80600080,244,yes +us,.code,func_8070D020,92,yes +us,.code,func_806A3700,12,yes +us,.code,func_80636FFC,2928,no +us,.code,func_8072D13C,1496,no +us,.code,func_80723320,44,yes +us,.code,func_8064B828,64,yes +us,.code,func_80733D8C,6296,no +us,.code,func_8073209C,188,no +us,.code,func_806D5008,528,no +us,.code,func_80669930,148,no +us,.code,func_806F5DF8,188,no +us,.code,func_80610BD8,156,no +us,.code,func_806C71A8,8,yes +us,.code,func_805FCA64,48,yes +us,.code,func_806BA8C8,116,yes +us,.code,func_805FEF74,140,yes +us,.code,isFlagSet,184,yes +us,.code,func_806DE930,196,yes +us,.code,func_807383F4,8,yes +us,.code,func_80642204,212,yes +us,.code,func_80739E24,56,no +us,.code,func_8071006C,264,no +us,.code,func_8066C8B0,84,yes +us,.code,func_80634908,84,no +us,.code,func_806732A8,124,no +us,.code,func_8070CA70,68,yes +us,.code,func_806EEA5C,156,yes +us,.code,func_806C71F0,8,yes +us,.code,func_806752D4,172,no +us,.code,func_8064E428,100,no +us,.code,func_806ECBD4,116,yes +us,.code,func_806D1238,56,yes +us,.code,func_8073DF50,792,no +us,.code,func_8067AAB8,104,yes +us,.code,func_806EBBD0,144,yes +us,.code,func_80665ACC,24,yes +us,.code,func_8067A9F0,104,yes +us,.code,func_8060F928,56,no +us,.code,clearGlobalFlags,80,yes +us,.code,func_8072E740,156,yes +us,.code,func_806776A0,1548,no +us,.code,func_80722E00,72,yes +us,.code,func_8062B8A4,64,yes +us,.code,func_806D7DF8,144,yes +us,.code,func_806C9C80,160,yes +us,.code,func_8066E21C,164,yes +us,.code,func_806F966C,96,no +us,.code,func_80659F7C,1524,no +us,.code,func_8071F660,248,no +us,.code,func_806B2790,1484,no +us,.code,func_80627C10,76,yes +us,.code,func_80661E34,144,no +us,.code,func_806CC8A8,16,yes +us,.code,func_806BD170,628,no +us,.code,func_8062A130,248,yes +us,.code,func_806B4DCC,808,yes +us,.code,func_8071586C,84,no +us,.code,func_8060EDD0,136,no +us,.code,alLink,52,yes +us,.code,func_806A05FC,544,no +us,.code,func_806C71F8,8,yes +us,.code,func_8066635C,156,yes +us,.code,func_8067B238,72,yes +us,.code,func_806AA304,4584,no +us,.code,func_806A3C6C,308,no +us,.code,func_807317FC,176,no +us,.code,func_8071E1C8,548,no +us,.code,func_80714638,40,yes +us,.code,func_80644CC0,144,no +us,.code,func_80650ECC,2108,no +us,.code,func_806EA9B4,144,yes +us,.code,func_806116E0,68,no +us,.code,func_8070C990,88,yes +us,.code,func_8064E5C0,156,no +us,.code,func_80659470,88,yes +us,.code,func_80633A1C,788,no +us,.code,func_8069D0F8,436,no +us,.code,func_8067675C,44,yes +us,.code,func_806884E4,48,yes +us,.code,func_806D38AC,396,yes +us,.code,func_806BA76C,348,no +us,.code,func_806EFA08,20,yes +us,.code,func_80687080,348,no +us,.code,func_80645238,988,no +us,.code,func_806FB2B8,184,no +us,.code,func_8062EDA8,160,no +us,.code,func_806CF918,180,no +us,.code,func_806ACC00,100,yes +us,.code,func_8065F134,140,no +us,.code,func_8070DD44,152,no +us,.code,func_80712490,40,yes +us,.code,func_8063DE68,104,no +us,.code,func_80690058,60,yes +us,.code,func_80717930,564,no +us,.code,func_8060E4B0,32,yes +us,.code,func_806450C0,376,no +us,.code,func_806DB3AC,708,no +us,.code,func_806643C4,236,no +us,.code,func_80675EE0,380,no +us,.code,func_806A62B4,32,yes +us,.code,func_805FF378,352,yes +us,.code,func_8064B4AC,104,no +us,.code,func_806C43A8,108,yes +us,.code,func_806BB32C,212,yes +us,.code,func_80737EA4,104,no +us,.code,func_806A6230,132,yes +us,.code,func_8066F274,396,no +us,.code,func_80642E34,400,no +us,.code,func_806613E8,88,yes +us,.code,func_80660D38,788,no +us,.code,func_806739D8,104,no +us,.code,func_8067BCE8,32,yes +us,.code,func_8064BB78,96,yes +us,.code,func_806E2EA8,36,yes +us,.code,func_80604CBC,180,no +us,.code,func_80735AA0,596,no +us,.code,func_806DBB04,1644,no +us,.code,func_80601678,88,yes +us,.code,func_806FEF7C,160,no +us,.code,func_805FCFD8,88,yes +us,.code,func_80689958,296,no +us,.code,func_80713B40,332,no +us,.code,func_80653DF0,184,no +us,.code,func_80632F74,88,no +us,.code,func_806DF44C,72,yes +us,.code,func_80634EA4,56,yes +us,.code,func_80683AD8,1460,no +us,.code,func_80689250,456,no +us,.code,func_8065CDA0,16,yes +us,.code,func_80635EF0,292,no +us,.code,func_806365D0,436,no +us,.code,func_8063D638,540,no +us,.code,func_806E3C38,180,yes +us,.code,func_80688C84,64,no +us,.code,func_806F0184,84,yes +us,.code,func_80611408,300,no +us,.code,func_80644E2C,156,no +us,.code,func_80656E58,188,no +us,.code,func_8066F84C,960,no +us,.code,func_80642480,128,yes +us,.code,func_806C19F4,348,yes +us,.code,func_80731410,228,yes +us,.code,func_80677D80,328,no +us,.code,func_806E4D84,260,yes +us,.code,func_8060E664,132,yes +us,.code,func_8073195C,48,yes +us,.code,func_8066F06C,396,no +us,.code,func_806699C4,168,no +us,.code,func_8066B06C,112,yes +us,.code,func_8067BD28,144,yes +us,.code,func_806BC148,100,yes +us,.code,func_8068A784,44,no +us,.code,func_8065EB10,1248,no +us,.code,func_80639F1C,164,no +us,.code,func_80718188,244,no +us,.code,func_806AEE84,2052,no +us,.code,func_80727958,1480,no +us,.code,func_8065BAA0,980,no +us,.code,func_80676540,80,yes +us,.code,func_8064CD3C,904,no +us,.code,func_806BD3E4,972,no +us,.code,func_80631C20,28,yes +us,.code,func_806D9940,404,yes +us,.code,func_80674ADC,180,no +us,.code,func_807144B8,212,yes +us,.code,func_80689418,696,no +us,.code,func_8064826C,820,no +us,.code,func_806EBED0,100,yes +us,.code,func_80738D20,312,no +us,.code,func_80679490,92,yes +us,.code,func_806DCF60,748,no +us,.code,func_806C2DF4,3224,no +us,.code,func_806E5C2C,72,yes +us,.code,func_806F5CE4,156,yes +us,.code,func_806CA048,160,yes +us,.code,func_806DCA7C,1252,no +us,.code,func_8066ADA0,324,no +us,.code,func_806F4750,40,yes +us,.code,func_80684850,176,yes +us,.code,func_806E0654,64,yes +us,.code,func_8068A118,76,yes +us,.code,func_806F10E8,360,no +us,.code,func_80675810,748,no +us,.code,func_8065CFB8,80,yes +us,.code,func_8065F1C0,732,no +us,.code,func_8060E79C,80,yes +us,.code,func_807007B8,572,no +us,.code,func_80678B04,184,yes +us,.code,func_80627C5C,588,no +us,.code,func_8066EC6C,484,no +us,.code,func_806085DC,144,no +us,.code,func_806011E4,64,yes +us,.code,func_806D37CC,224,yes +us,.code,func_80631F58,84,no +us,.code,func_806D4DE4,548,no +us,.code,func_806C10A0,608,yes +us,.code,func_8063D5AC,92,yes +us,.code,func_80714950,12,yes +us,.code,func_806A7600,1284,no +us,.code,func_8065BF18,808,no +us,.code,func_80653B80,624,no +us,.code,func_8069D930,292,no +us,.code,func_80659544,48,yes +us,.code,func_80723F88,460,no +us,.code,func_806F13C8,100,yes +us,.code,func_806C3A8C,1156,no +us,.code,func_8066B020,76,yes +us,.code,func_806EE02C,64,yes +us,.code,func_806ECCDC,248,yes +us,.code,func_80726DC0,44,yes +us,.code,func_806F50C8,424,no +us,.code,func_80716F10,164,no +us,.code,func_80712A40,320,no +us,.code,func_806E8C2C,296,no +us,.code,func_806012D4,72,yes +us,.code,func_806E7DF4,1104,no +us,.code,func_8073AD48,8,yes +us,.code,func_806D491C,340,yes +us,.code,func_8060E3B0,128,yes +us,.code,func_8066CDF8,236,no +us,.code,func_806DAA14,200,yes +us,.code,func_806E2140,284,yes +us,.code,func_806F8EB4,40,yes +us,.code,func_806F94AC,108,no +us,.code,func_806F91B4,568,no +us,.code,func_80649D74,140,no +us,.code,func_806E07F8,1012,no +us,.code,func_8072FCC4,272,no +us,.code,func_806E9580,644,no +us,.code,func_806EB058,100,yes +us,.code,func_806D21E4,84,yes +us,.code,func_80688F74,76,yes +us,.code,func_8065A654,12,yes +us,.code,func_806C8220,748,no +us,.code,func_807126B0,196,yes +us,.code,func_806049CC,540,no +us,.code,func_8060D2C8,1184,no +us,.code,func_806306D0,60,no +us,.code,func_8070D928,72,no +us,.code,func_8066134C,76,yes +us,.code,func_8072F09C,132,no +us,.code,func_806C7220,8,yes +us,.code,func_8060F854,212,no +us,.code,func_80611730,276,no +us,.code,func_80632E74,172,no +us,.code,func_8069F020,2276,no +us,.code,func_806883C8,44,yes +us,.code,func_8072E5FC,324,no +us,.code,func_80672C30,64,yes +us,.code,func_80659670,764,no +us,.code,func_806DF670,100,yes +us,.code,func_806F603C,456,no +us,.code,func_8067AEFC,72,yes +us,.code,func_806762C0,72,yes +us,.code,func_80676D00,464,no +us,.code,func_8072A920,352,no +us,.code,func_80672E64,8,yes +us,.code,func_806E186C,484,yes +us,.code,func_8060B968,104,no +us,.code,func_8064EA48,108,yes +us,.code,func_80685E78,232,no +us,.code,func_80633570,64,no +us,.code,func_80661EC4,72,yes +us,.code,func_80630B70,604,no +us,.code,func_80602D4C,120,yes +us,.code,func_80681B14,196,no +us,.code,func_806E5FA0,220,yes +us,.code,func_8072DE44,100,yes +us,.code,func_806C8D20,12,yes +us,.code,func_806E84A4,28,yes +us,.code,func_80662838,636,no +us,.code,func_806DF5A0,208,no +us,.code,func_806EB400,180,no +us,.code,func_80712628,12,yes +us,.code,alEvtqPostEvent,384,yes +us,.code,func_8064B204,92,no +us,.code,func_8060C8AC,712,no +us,.code,func_805FCA94,1348,no +us,.code,func_8064BB4C,44,yes +us,.code,func_8072ED90,12,yes +us,.code,func_806E06E8,148,yes +us,.code,func_8066CEE4,876,no +us,.code,func_8064CB3C,324,no +us,.code,func_806AEE08,124,yes +us,.code,func_806D3530,216,yes +us,.code,func_806738D0,264,no +us,.code,func_8070CCC4,80,yes +us,.code,func_806ECDD4,88,yes +us,.code,func_805FE7FC,1672,no +us,.code,func_806ED508,184,yes +us,.code,func_8062EBB8,496,no +us,.code,func_805FB750,148,yes +us,.code,func_80658B08,200,no +us,.code,func_8061134C,64,no +us,.code,func_806D7238,156,yes +us,.code,func_8063C328,104,yes +us,.code,func_806C6BC8,1496,no +us,.code,func_806EEAF8,3384,no +us,.code,func_806003EC,64,yes +us,.code,func_806EFA1C,32,yes +us,.code,func_80672B1C,184,yes +us,.code,func_806725A0,68,yes +us,.code,func_80665DE0,104,yes +us,.code,func_8071C24C,576,no +us,.code,func_806E36B4,344,no +us,.code,func_806EA844,92,yes +us,.code,func_806898F8,96,yes +us,.code,func_806D5300,1264,yes +us,.code,func_8060A634,60,yes +us,.code,gameIsInDKTVMode,84,yes +us,.code,func_8066104C,8,yes +us,.code,func_8072EF7C,288,no +us,.code,func_8073BE54,492,no +us,.code,func_806EC8C4,208,no +us,.code,func_8064774C,232,no +us,.code,func_8064EAB4,136,yes +us,.code,func_80651B64,92,yes +us,.code,func_806F39E8,516,no +us,.code,func_806DC410,1644,no +us,.code,func_8064A180,20,yes +us,.code,func_806CF580,760,no +us,.code,func_805FB300,708,no +us,.code,func_8060E6E8,180,yes +us,.code,func_806791EC,20,yes +us,.code,func_80659DB0,460,no +us,.code,func_80726EE0,412,no +us,.code,func_806696A0,400,no +us,.code,func_806FD9B4,72,no +us,.code,func_8068BBF8,1160,no +us,.code,func_806D0408,40,yes +us,.code,func_806897F0,184,yes +us,.code,func_8066BB44,188,no +us,.code,func_8060D14C,380,no +us,.code,func_80650E20,172,no +us,.code,func_806EB4B4,68,yes +us,.code,func_806998E8,8,yes +us,.code,func_8070DDDC,248,no +us,.code,func_806EE660,80,yes +us,.code,func_807063B8,576,no +us,.code,func_806D27A4,120,yes +us,.code,func_80688E08,96,yes +us,.code,func_8068E9B0,136,no +us,.code,func_807233B4,116,no +us,.code,func_8067BCA8,32,yes +us,.code,func_8072D99C,56,yes +us,.code,func_8062F420,280,no +us,.code,func_806D1D3C,72,yes +us,.code,func_805FE4D4,112,no +us,.code,func_807009F4,240,no +us,.code,func_80713EB0,432,no +us,.code,func_8068696C,240,no +us,.code,func_8072818C,240,no +us,.code,func_80690C60,720,no +us,.code,func_806CF138,436,no +us,.code,func_806D7F48,160,yes +us,.code,func_805FB7E4,352,no +us,.code,func_80700BF4,1188,no +us,.code,func_806CA2E4,604,yes +us,.code,func_806761D0,28,yes +us,.code,func_806E9804,112,yes +us,.code,func_806D5B44,392,yes +us,.code,func_8060A500,268,no +us,.code,func_80600B10,172,no +us,.code,func_80634E10,148,yes +us,.code,func_806C7228,8,yes +us,.code,func_80645D14,556,no +us,.code,func_80737F40,152,no +us,.code,func_80605510,744,no +us,.code,func_806FD9FC,144,no +us,.code,func_8071B44C,212,no +us,.code,func_806F2A40,520,no +us,.code,func_806764D8,104,yes +us,.code,func_80672328,632,no +us,.code,func_80714660,8,yes +us,.code,func_806F1858,156,no +us,.code,func_8067BDF8,56,yes +us,.code,func_806845B8,252,yes +us,.code,func_8066E990,92,no +us,.code,func_806A2B80,16,yes +us,.code,func_8062C1C0,108,yes +us,.code,func_8070F2FC,628,no +us,.code,func_80600BBC,172,no +us,.code,func_806D8070,56,yes +us,.code,func_80671D64,156,no +us,.code,func_80737E90,12,no +us,.code,func_806EA600,40,yes +us,.code,func_8063643C,12,yes +us,.code,func_80600674,732,no +us,.code,func_806CC970,412,no +us,.code,func_807300BC,844,no +us,.code,func_806FF628,308,no +us,.code,func_806960A4,1232,no +us,.code,func_806DD874,572,yes +us,.code,func_80611688,8,yes +us,.code,func_8063E5B4,256,no +us,.code,func_80699070,184,no +us,.code,func_80685708,276,no +us,.code,func_806025D4,1216,no +us,.code,func_806A0864,784,no +us,.code,func_806E3040,444,no +us,.code,func_80645700,456,no +us,.code,func_80605380,400,no +us,.code,func_8067BA7C,492,no +us,.code,func_80671F54,480,no +us,.code,func_80608DA8,920,no +us,.code,func_8069F904,316,no +us,.code,func_807232B8,52,yes +us,.code,func_8073A488,144,no +us,.code,func_8070E548,520,no +us,.code,func_8071827C,260,no +us,.code,func_8070A848,236,no +us,.code,func_80601CC0,48,yes +us,.code,func_806FA7BC,516,no +us,.code,func_8066C958,560,no +us,.code,func_8073A8BC,68,no +us,.code,func_8066E9EC,120,no +us,.code,func_8062F050,712,no +us,.code,func_80658624,700,no +us,.code,func_8069D358,204,no +us,.code,func_80737FD8,68,no +us,.code,func_806CF878,160,yes +us,.code,func_806ED050,172,yes +us,.code,func_805FF9AC,1188,no +us,.code,func_806D2954,192,yes +us,.code,func_80735A44,8,yes +us,.code,func_8068BA2C,460,no +us,.code,func_80689FEC,136,yes +us,.code,func_806FACE8,764,no +us,.code,func_8063E078,92,no +us,.code,func_80738080,76,no +us,.code,func_806E6E7C,100,yes +us,.code,func_8067680C,412,no +us,.code,func_806FDAEC,160,no +us,.code,func_80663FCC,120,yes +us,.code,func_80686E40,336,no +us,.code,func_80661300,76,yes +us,.code,func_80725BA4,540,no +us,.code,func_80639C04,204,no +us,.code,func_806FF358,720,no +us,.code,func_806F6554,240,no +us,.code,func_806E1728,204,yes +us,.code,func_80689E98,12,yes +us,.code,func_8072CFE8,164,no +us,.code,func_80671D10,84,yes +us,.code,func_806822FC,1976,no +us,.code,func_80655258,440,no +us,.code,func_80602DC4,168,no +us,.code,func_8070CBA4,120,yes +us,.code,func_806EE06C,160,yes +us,.code,func_8068A7B0,96,yes +us,.code,func_8063070C,160,no +us,.code,clearPermanentFlags,80,yes +us,.code,func_80665558,12,yes +us,.code,func_807023E8,124,no +us,.code,func_8060B5C0,268,yes +us,.code,func_806F4D70,80,yes +us,.code,func_806D2904,80,yes +us,.code,func_806EAAA0,164,yes +us,.code,func_80611154,12,yes +us,.code,func_807184F4,468,no +us,.code,func_8066AF40,224,no +us,.code,func_8069A750,120,no +us,.code,func_806EBFD0,68,yes +us,.code,func_80600590,228,no +us,.code,func_80737E40,8,yes +us,.code,func_806E9D1C,196,yes +us,.code,func_806291B4,332,no +us,.code,func_80709BC4,1628,no +us,.code,func_807264B0,568,no +us,.code,func_80715A3C,244,no +us,.code,func_806E3B00,276,yes +us,.code,func_806C75A4,1372,no +us,.code,func_8066715C,24,yes +us,.code,func_806F8BC4,236,yes +us,.code,func_8067760C,148,no +us,.code,func_806EAF6C,128,yes +us,.code,alEvtqNextEvent,164,yes +us,.code,func_805FF8F8,64,yes +us,.code,func_806871DC,548,no +us,.code,alEvtqNew,156,yes +us,.code,func_8060188C,40,yes +us,.code,func_8064F358,172,no +us,.code,func_806672B8,1444,no +us,.code,func_80687400,116,yes +us,.code,func_8064B370,136,yes +us,.code,func_8067FAC8,164,no +us,.code,func_806C71A0,8,yes +us,.code,func_806D3CD4,136,yes +us,.code,func_805FF168,32,yes +us,.code,func_8069D018,64,yes +us,.code,func_8063D468,44,yes +us,.code,func_8067ABC0,120,yes +us,.code,func_80737F0C,44,no +us,.code,setIntroStoryPlaying,16,yes +us,.code,func_8069CD9C,440,no +us,.code,func_806E2C74,80,no +us,.code,func_8063D4A4,264,no +us,.code,func_8063BEC0,116,no +us,.code,func_806E9874,132,yes +us,.code,func_80678458,216,yes +us,.code,func_806F8278,196,no +us,.code,func_806EC2CC,240,yes +us,.code,func_8066BC5C,248,no +us,.code,func_8066C0DC,472,no +us,.code,func_806F8A8C,72,yes +us,.code,func_8062EE48,344,no +us,.code,func_80642FC4,688,no +us,.code,func_80602CE0,108,no +us,.code,func_80724154,436,no +us,.code,func_80692564,36,yes +us,.code,func_8072DEA8,388,no +us,.code,func_80717814,284,no +us,.code,func_8062A24C,40,yes +us,.code,func_806F0878,184,yes +us,.code,func_8069AFF0,32,yes +us,.code,func_8070DD18,44,no +us,.code,func_8063E72C,744,no +us,.code,func_806618A0,532,no +us,.code,func_806CBE44,76,yes +us,.code,func_806687E0,216,no +us,.code,func_80700AE4,272,no +us,.code,func_806E382C,32,yes +us,.code,func_806C4EB4,44,yes +us,.code,func_806FF144,488,no +us,.code,func_807385F0,380,no +us,.code,func_80641F68,8,yes +us,.code,func_80658000,308,no +us,.code,func_806522CC,168,yes +us,.code,func_80737A9C,40,no +us,.code,func_80642940,688,no +us,.code,func_806EA26C,108,yes +us,.code,func_80635468,224,no +us,.code,func_805FEE84,52,yes +us,.code,func_806E6FF0,96,yes +us,.code,func_8062F998,560,no +us,.code,func_8071496C,16,yes +us,.code,func_8069E774,2012,no +us,.code,func_80699128,348,no +us,.code,func_806FC530,1880,no +us,.code,func_806DFFDC,116,yes +us,.code,func_80678014,60,yes +us,.code,func_8063C390,48,yes +us,.code,func_8064D1E8,560,no +us,.code,func_806DA4D8,788,no +us,.code,func_8071AADC,256,no +us,.code,func_8060AC34,72,no +us,.code,func_806E7230,264,yes +us,.code,func_80653EA8,192,no +us,.code,func_806EBAF4,80,yes +us,.code,func_8066E72C,296,yes +us,.code,func_806785D4,504,yes +us,.code,func_8062F328,96,no +us,.code,func_8067FB6C,3080,no +us,.code,func_80645B9C,104,no +us,.code,func_80602314,284,no +us,.code,func_80694948,984,no +us,.code,func_8060BBE0,192,no +us,.code,func_8073A3C4,196,no +us,.code,func_8072D08C,176,no +us,.code,func_8066A834,340,no +us,.code,func_8073BC74,336,no +us,.code,func_806018D4,104,no +us,.code,func_80712774,36,yes +us,.code,func_806F12FC,84,yes +us,.code,func_806A6DB4,1432,no +us,.code,func_806E077C,124,yes +us,.code,func_8066B0DC,16,yes +us,.code,func_8073239C,132,yes +us,.code,func_806D01AC,160,yes +us,.code,func_806E8724,296,yes +us,.code,func_806ED0FC,328,yes +us,.code,func_80674330,268,no +us,.code,func_8066EA90,44,yes +us,.code,func_806B2D5C,8,yes +us,.code,func_806F95C8,64,yes +us,.code,func_8067E6C4,32,yes +us,.code,func_80670F04,160,yes +us,.code,func_80685984,448,no +us,.code,func_806E330C,272,yes +us,.code,func_806B7C74,556,no +us,.code,func_806EE924,112,yes +us,.code,func_80677CAC,172,yes +us,.code,func_80666090,496,no +us,.code,func_806B3F3C,84,yes +us,.code,func_80740C50,760,no +us,.code,func_80667110,76,yes +us,.code,func_806A5DF0,188,no +us,.code,func_806D2B90,32,yes +us,.code,func_807149FC,12,yes +us,.code,func_8065EAF4,20,yes +us,.code,func_806787CC,32,yes +us,.code,func_8073243C,8,yes +us,.code,func_806832F4,232,no +us,.code,func_80647218,752,no +us,.code,func_806783BC,108,yes +us,.code,func_8066B434,120,yes +us,.code,func_806C1B50,380,no +us,.code,func_8070FC40,140,no +us,.code,func_807197B4,600,no +us,.code,func_8068A164,84,yes +us,.code,func_806BCF98,252,no +us,.code,func_806FFF5C,44,yes +us,.code,func_806A0330,676,no +us,.code,func_8069A7C8,940,no +us,.code,func_8071F3C0,132,no +us,.code,func_8064C708,268,no +us,.code,func_80681BD8,576,no +us,.code,func_806D7098,216,yes +us,.code,func_80675180,180,no +us,.code,func_8066B424,16,yes +us,.code,func_806423A8,216,no +us,.code,func_806086CC,1756,no +us,.code,func_80672134,500,no +us,.code,func_8073E268,504,no +us,.code,func_80663DA0,556,no +us,.code,playSound,1068,no +us,.code,func_806C9D7C,96,yes +us,.code,func_806D8308,516,no +us,.code,func_8072B7CC,3748,no +us,.code,func_806F2C48,660,no +us,.code,func_806016D0,88,yes +us,.code,func_8073A518,376,no +us,.code,func_806EF944,196,yes +us,.code,func_8070835C,536,no +us,.code,func_8060BA14,260,yes +us,.code,func_80641C98,264,no +us,.code,func_806919E0,2044,no +us,.code,func_8065E124,20,yes +us,.code,func_8062A808,60,yes +us,.code,_n_collectPVoices,108,yes +us,.code,func_80610044,548,no +us,.code,func_80705B30,208,yes +us,.code,func_80665160,156,yes +us,.code,func_807122B4,476,no +us,.code,func_806D2784,32,yes +us,.code,func_8073CFB0,176,no +us,.code,func_806C1640,244,yes +us,.code,func_8063B4C0,664,no +us,.code,func_806C7270,820,no +us,.code,func_806CFDEC,68,yes +us,.code,func_806AF688,984,no +us,.code,func_8066241C,436,no +us,.code,func_8073B560,112,no +us,.code,func_806C92C4,64,yes +us,.code,func_806A2328,1332,no +us,.code,func_8071261C,12,yes +us,.code,func_806B1EA8,32,yes +us,.code,func_80674080,208,no +us,.code,func_8071C914,212,no +us,.code,func_806AD54C,608,yes +us,.code,func_8073A2A4,288,no +us,.code,func_806F1A18,200,yes +us,.code,func_8070D9AC,124,no +us,.code,func_8062A850,244,no +us,.code,func_8062919C,12,yes +us,.code,func_8071B1AC,160,no +us,.code,func_8064BBD8,216,no +us,.code,func_8067880C,8,yes +us,.code,func_805FBE04,496,yes +us,.code,func_806A1AC4,1124,no +us,.code,func_807146F4,20,yes +us,.code,func_806B486C,76,yes +us,.code,func_80722FEC,52,yes +us,.code,func_806B8C78,980,no +us,.code,func_8069AB74,1148,no +us,.code,func_806FBEAC,68,no +us,.code,malloc,364,no +us,.code,func_8072ED9C,112,no +us,.code,func_80676C64,76,yes +us,.code,func_806E88D8,436,no +us,.code,func_806D2378,36,yes +us,.code,func_806E5C74,236,yes +us,.code,func_806E6368,80,yes +us,.code,func_8069DF58,192,no +us,.code,func_80650A04,108,no +us,.code,func_8070FA58,488,no +us,.code,func_807065F8,940,no +us,.code,func_806C7B50,92,no +us,.code,func_8072AB74,1968,no +us,.code,func_8067B298,8,yes +us,.code,func_806F3950,44,yes +us,.code,func_806C9E70,48,yes +us,.code,func_80651C2C,1312,no +us,.code,func_80675AFC,372,no +us,.code,func_80711F90,804,no +us,.code,func_806C2B2C,592,no +us,.code,func_806595F0,16,yes +us,.code,func_806491F4,464,no +us,.code,func_806D9820,260,no +us,.code,func_80731654,304,no +us,.code,func_8066461C,80,yes +us,.code,func_8063CADC,100,yes +us,.code,func_806FFB2C,216,no +us,.code,func_806F1380,72,yes +us,.code,func_80716FB4,332,no +us,.code,func_80685020,176,yes +us,.code,func_80673FDC,164,no +us,.code,func_8067B42C,32,yes +us,.code,func_8070AF24,312,no +us,.code,func_806D59E4,352,yes +us,.code,func_8063C6D8,172,yes +us,.code,func_805FB944,792,no +us,.code,func_80665564,1352,no +us,.code,func_806F0700,204,yes +us,.code,func_80703850,608,no +us,.code,func_80601848,68,yes +us,.code,loadExits,136,yes +us,.code,func_8073876C,1076,no +us,.code,func_8066B924,208,no +us,.code,func_806FBD5C,336,no +us,.code,func_806FF75C,976,no +us,.code,func_806616A0,512,no +us,.code,func_806EC800,196,yes +us,.code,func_8067C69C,32,yes +us,.code,func_806CFECC,40,yes +us,.code,func_80704484,1244,no +us,.code,func_805FF000,24,yes +us,.code,func_8073BDC4,144,no +us,.code,func_80629174,24,yes +us,.code,func_806B8898,32,yes +us,.code,func_80688584,180,yes +us,.code,func_80652594,332,no +us,.code,func_80711BD0,960,no +us,.code,func_80732354,72,yes +version,section,function,length,matching +us,.code,func_80028C18,8,yes +us,.code,func_8002A36C,252,yes +us,.code,func_8003264C,736,no +us,.code,func_8002AB80,340,no +us,.code,func_8003292C,1572,no +us,.code,func_80025B64,432,no +us,.code,func_80026250,64,yes +us,.code,func_800270E0,1292,no +us,.code,func_80031980,220,no +us,.code,func_80026B28,644,no +us,.code,func_8002AD50,120,no +us,.code,func_8002C584,176,yes +us,.code,func_8002ECE8,304,no +us,.code,func_80030258,232,no +us,.code,func_80027E60,212,yes +us,.code,func_8002EF68,796,no +us,.code,func_800297A8,16,yes +us,.code,func_8002E420,1176,no +us,.code,func_80025D44,72,yes +us,.code,func_800291CC,1500,no +us,.code,func_80030250,8,yes +us,.code,func_80026290,24,yes +us,.code,func_8002AB28,88,no +us,.code,func_80024BFC,180,yes +us,.code,func_8002D520,716,no +us,.code,func_80026874,692,no +us,.code,func_80024EF0,956,no +us,.code,func_80026DAC,636,no +us,.code,func_80028C20,284,yes +us,.code,func_8002F980,520,no +us,.code,func_80032550,252,yes +us,.code,func_8002D8AC,816,no +us,.code,func_80025FB4,524,no +us,.code,func_8002FC1C,284,yes +us,.code,func_80024154,148,yes +us,.code,func_800322D0,52,yes +us,.code,func_80029EF8,400,yes +us,.code,func_80025E04,432,yes +us,.code,func_8002AA98,144,no +us,.code,func_8002B708,2496,no +us,.code,func_800241E8,60,yes +us,.code,func_80027F34,12,yes +us,.code,func_8002F6C8,148,yes +us,.code,func_80026684,108,yes +us,.code,func_800317E8,408,no +us,.code,func_80027E10,80,yes +us,.code,func_8002DEE8,192,yes +us,.code,func_8002FE08,180,yes +us,.code,func_8002A638,1120,no +us,.code,func_8002F8EC,148,yes +us,.code,func_8002A468,464,yes +us,.code,func_8002CFA4,1404,no +us,.code,func_8002C634,744,no +us,.code,func_8002CB18,1164,no +us,.code,func_8002FB88,148,no +us,.code,func_800266F0,276,yes +us,.code,func_8003155C,652,no +us,.code,func_800275FC,316,no +us,.code,func_80024CB0,576,no +us,.code,func_8002907C,152,no +us,.code,func_800261C0,144,yes +us,.code,func_8002DBDC,780,no +us,.code,func_80026804,112,yes +us,.code,func_80030A90,388,no +us,.code,func_80025AE0,8,yes +us,.code,func_8002ADC8,2368,no +us,.code,func_8002F284,1092,no +us,.code,func_80028D3C,364,no +us,.code,func_800252AC,2100,no +us,.code,func_80030340,1364,no +us,.code,func_80027738,208,no +us,.code,func_80031B08,1308,no +us,.code,func_800275EC,16,yes +us,.code,func_80029AAC,264,yes +us,.code,func_80024000,188,no +us,.code,func_800244EC,668,no +us,.code,func_8002FEBC,916,no +us,.code,func_80025D8C,120,yes +us,.code,func_8002C91C,508,no +us,.code,func_80027028,184,yes +us,.code,func_80027FAC,1820,no +us,.code,func_80025AF0,116,no +us,.code,func_800240BC,152,yes +us,.code,func_80032304,456,no +us,.code,func_80029D30,456,no +us,.code,func_80027DEC,32,yes +us,.code,func_8002E8B8,1072,no +us,.code,func_800324CC,132,no +us,.code,func_80032024,684,no +us,.code,func_80029BB4,380,no +us,.code,func_8002ACD4,124,no +us,.code,func_8002C0C8,1212,no +us,.code,func_80027808,384,no +us,.code,func_8002D7EC,192,yes +us,.code,func_80024788,1140,no +us,.code,func_80028EA8,468,yes +us,.code,func_8002FD38,208,yes +us,.code,func_80025D14,48,yes +us,.code,func_80030894,508,no +us,.code,func_80027988,1124,no +us,.code,func_80031A5C,172,no +us,.code,func_80028834,996,no +us,.code,func_80024224,500,no +us,.code,func_8002EE18,336,yes +us,.code,func_8002F75C,400,no +us,.code,func_8002DFA8,1144,no +us,.code,func_8002A088,740,no +us,.code,func_800286C8,364,no +us,.code,func_80029114,184,yes +us,.code,func_80027F40,108,yes +us,.code,func_800262A8,988,no +us,.code,func_800297B8,756,no +us,.code,func_80024418,212,yes +us,.code,func_80030C14,2376,no +version,section,function,length,matching +us,.code,func_800245B0,316,no +us,.code,func_8002698C,60,yes +us,.code,func_80025654,320,no +us,.code,func_80025B48,416,no +us,.code,func_800253C8,60,yes +us,.code,func_80025CE8,668,no +us,.code,func_80026E20,336,no +us,.code,func_80024254,168,no +us,.code,func_80025FFC,152,no +us,.code,func_80026BD8,360,no +us,.code,func_800246EC,748,no +us,.code,func_80025608,76,no +us,.code,func_80024CA4,1472,no +us,.code,func_80026B0C,204,yes +us,.code,func_8002452C,132,yes +us,.code,func_80025794,948,no +us,.code,func_800242FC,204,yes +us,.code,func_80025264,276,no +us,.code,func_800243C8,212,no +us,.code,func_80024000,500,no +us,.code,func_80025404,516,no +us,.code,func_80026D40,224,yes +us,.code,func_800268C0,28,yes +us,.code,func_80026094,2092,no +us,.code,func_800269C8,324,no +us,.code,func_800249D8,716,no +us,.code,func_800241F4,96,no +us,.code,func_80025378,80,no +us,.code,func_80025F84,120,no +us,.code,func_800268DC,176,no +us,.code,func_8002449C,144,yes +version,section,function,length,matching +us,.code,func_8002430C,1116,no +us,.code,func_80024B00,888,no +us,.code,func_80024768,296,yes +us,.code,func_80024E78,344,no +us,.code,func_80024914,492,no +us,.code,func_80027E04,228,no +us,.code,func_80024254,184,no +us,.code,func_80027778,1404,no +us,.code,func_80026DA8,2512,no +us,.code,func_8002835C,912,no +us,.code,func_800286EC,1188,no +us,.code,func_800241A0,180,yes +us,.code,func_800253C0,4656,no +us,.code,func_80027CF4,172,no +us,.code,func_80026C54,340,yes +us,.code,func_80027EE8,468,no +us,.code,func_800280BC,672,no +us,.code,func_80024000,220,yes +us,.code,func_800240DC,196,yes +us,.code,func_80027DA0,100,no +us,.code,func_800265F0,1404,no +us,.code,func_80026B6C,232,yes +us,.code,func_8002538C,52,yes +us,.code,func_80024FD0,956,no +us,.code,func_80024890,132,no +version,section,function,length,matching +us,.code,func_800274C0,496,no +us,.code,func_8002D2C0,120,no +us,.code,func_8002DD70,48,yes +us,.code,func_80027AF8,56,yes +us,.code,func_8002CAC8,292,no +us,.code,func_800282D8,252,no +us,.code,func_800294A8,740,no +us,.code,func_80024634,92,yes +us,.code,func_8002D40C,148,no +us,.code,func_8002578C,24,yes +us,.code,func_8002F420,112,no +us,.code,func_8002DF38,656,no +us,.code,func_8002E960,76,no +us,.code,func_8002B6C8,44,yes +us,.code,func_80026B20,392,no +us,.code,func_8002B6F4,120,yes +us,.code,func_8002DE78,192,no +us,.code,func_8002D338,40,yes +us,.code,func_80027710,368,no +us,.code,func_80024690,4320,no +us,.code,func_8002A7F8,1652,no +us,.code,castleCarRaceSetup,76,yes +us,.code,func_80027BD0,144,no +us,.code,func_8002DC24,204,no +us,.code,func_8002D72C,40,yes +us,.code,func_80026F04,1468,no +us,.code,func_80029F88,248,no +us,.code,func_80026EE4,32,yes +us,.code,func_8002AE6C,48,yes +us,.code,func_8002F490,756,no +us,.code,func_8002D360,172,no +us,.code,func_80026354,1996,no +us,.code,func_80027C60,136,yes +us,.code,func_8002F0AC,468,no +us,.code,func_8002DDA0,216,no +us,.code,func_8002D224,156,no +us,.code,func_8002DB90,148,yes +us,.code,func_80028E20,564,no +us,.code,func_80027CE8,1024,no +us,.code,func_8002E1C8,256,no +us,.code,sealRaceSetup,32,yes +us,.code,func_8002ECD4,48,yes +us,.code,func_8002F280,132,no +us,.code,func_8002E2C8,412,no +us,.code,func_8002E9AC,76,no +us,.code,func_8002BBD0,92,yes +us,.code,func_8002D0B0,76,yes +us,.code,func_80026D2C,440,no +us,.code,func_800283D4,108,no +us,.code,func_8002F304,104,yes +us,.code,func_80027B30,160,no +us,.code,func_8002BDDC,268,no +us,.code,func_8002F90C,68,yes +us,.code,func_800292B0,32,yes +us,.code,func_80026004,76,yes +us,.code,func_80029054,604,no +us,.code,func_8002978C,2044,no +us,.code,func_8002CFF0,116,yes +us,.code,func_800292D0,440,no +us,.code,func_80025FDC,40,yes +us,.code,setupRaceOnMapLoad,204,yes +us,.code,func_800280E8,496,no +us,.code,func_8002BCD4,264,no +us,.code,func_8002E464,32,yes +us,.code,func_8002A0AC,1444,no +us,.code,func_8002A080,44,yes +us,.code,func_800276B0,96,no +us,.code,func_80024000,1588,no +us,.code,func_8002597C,1312,no +us,.code,func_80026CA8,132,yes +us,.code,func_8002F36C,180,no +us,.code,func_8002D0FC,76,yes +us,.code,func_8002B180,920,no +us,.code,func_8002B610,184,no +us,.code,func_8002C63C,304,no +us,.code,func_80026050,72,yes +us,.code,func_800261E0,372,no +us,.code,func_8002DCF0,128,no +us,.code,func_80027880,160,no +us,.code,func_80025770,28,yes +us,.code,func_8002F950,448,no +us,.code,func_8002CBEC,1028,no +us,.code,func_8002B76C,504,no +us,.code,func_80028AD0,848,no +us,.code,func_8002AE9C,740,no +us,.code,func_8002F04C,96,no +us,.code,func_8002E8EC,116,no +us,.code,func_8002BEE8,612,no +us,.code,func_8002B518,248,no +us,.code,func_8002F784,392,no +us,.code,func_8002E9F8,528,no +us,.code,func_8002EDD4,632,no +us,.code,func_8002D148,220,no +us,.code,func_8002D754,36,yes +us,.code,func_8002B964,620,no +us,.code,func_80026098,328,no +us,.code,func_80028440,1680,no +us,.code,func_8002D524,520,no +us,.code,func_8002BC2C,132,no +us,.code,func_8002ED04,208,yes +us,.code,func_8002E484,448,no +us,.code,func_80025E9C,320,no +us,.code,func_80027920,472,no +us,.code,initializeCastleCarRace,424,no +us,.code,func_8002C14C,412,no +us,.code,func_8002C76C,860,no +us,.code,func_800257A4,472,no +us,.code,func_8002DA68,296,yes +us,.code,func_8002C2E8,852,no +us,.code,func_8002BCB0,36,no +us,.code,func_8002D778,752,no +us,.code,func_8002E644,680,no +us,.code,func_8002D4A0,132,yes +version,section,function,length,matching +us,.code,func_8002AED8,2632,no +us,.code,func_80027308,52,yes +us,.code,func_8002BF98,2388,no +us,.code,func_8002563C,136,yes +us,.code,func_8002881C,1568,no +us,.code,func_800264E0,224,yes +us,.code,func_80024E38,1128,no +us,.code,func_80024D8C,172,no +us,.code,func_8002BE44,340,no +us,.code,func_8002D7E8,112,yes +us,.code,func_800240F0,104,yes +us,.code,func_800256C4,72,no +us,.code,func_8002D2F0,1032,no +us,.code,func_800277F8,1820,no +us,.code,func_800284C0,392,no +us,.code,func_80026CF0,1220,no +us,.code,func_80028648,468,no +us,.code,func_80025480,48,no +us,.code,func_800271B4,340,no +us,.code,func_8002CC08,1032,no +us,.code,func_80024D3C,80,no +us,.code,func_8002B920,1316,no +us,.code,func_80024158,3044,no +us,.code,func_8002A398,1804,no +us,.code,func_8002AAA4,620,no +us,.code,func_80028E3C,1320,no +us,.code,func_800261B8,808,no +us,.code,func_80029B9C,696,no +us,.code,func_80029364,2104,no +us,.code,func_8002733C,356,no +us,.code,func_80024000,240,no +us,.code,func_8002AD10,456,no +us,.code,func_8002C8EC,796,no +us,.code,func_800265C0,200,yes +us,.code,func_8002D010,736,no +us,.code,func_8002570C,2732,no +us,.code,func_80026940,944,no +us,.code,func_800253E4,156,yes +us,.code,func_800274A0,168,yes +us,.code,func_80029E54,444,no +us,.code,func_80026690,688,no +us,.code,func_800254B0,396,no +us,.code,func_8002D6F8,240,no +us,.code,func_800252A0,324,no +us,.code,func_80027F14,1452,no +us,.code,func_8002A010,904,no +us,.code,func_80027548,688,no +version,section,function,length,matching +us,.code,func_8002658C,744,no +us,.code,func_800255C4,528,no +us,.code,func_80027118,552,no +us,.code,func_800247F4,900,no +us,.code,func_80024C88,672,no +us,.code,func_800288A8,500,no +us,.code,func_8002904C,196,no +us,.code,func_80027340,264,no +us,.code,func_80029110,8,yes +us,.code,func_80026874,144,no +us,.code,func_80025DB8,388,no +us,.code,func_80024578,64,yes +us,.code,func_80025F8C,144,yes +us,.code,func_80025F3C,80,yes +us,.code,func_80025A3C,148,no +us,.code,func_80025500,196,no +us,.code,func_80026530,92,yes +us,.code,func_80024154,296,no +us,.code,func_80028840,104,yes +us,.code,func_80026410,92,yes +us,.code,func_80026B78,292,no +us,.code,func_800296DC,276,no +us,.code,func_80026E0C,452,no +us,.code,func_80026C9C,368,no +us,.code,func_80028EE8,356,no +us,.code,func_80026298,40,yes +us,.code,func_80024518,96,no +us,.code,func_80029118,1476,no +us,.code,func_80027DC0,864,no +us,.code,func_80028DE8,256,no +us,.code,func_80028120,1824,no +us,.code,func_80026904,344,no +us,.code,func_80025AD0,588,no +us,.code,func_8002427C,528,no +us,.code,func_800245B8,572,no +us,.code,func_80026338,216,yes +us,.code,func_8002601C,636,no +us,.code,func_80024000,156,no +us,.code,func_80024F28,580,no +us,.code,func_80028A9C,844,no +us,.code,func_8002516C,916,no +us,.code,func_80026A5C,284,yes +us,.code,func_80024B78,272,no +us,.code,func_80025D1C,156,no +us,.code,func_800262C0,120,no +us,.code,func_8002646C,196,yes +us,.code,func_80026FD0,100,yes +us,.code,func_800257D4,220,no +us,.code,func_80027448,2424,no +us,.code,func_8002448C,140,no +us,.code,func_800258B0,396,no +us,.code,func_80027034,88,yes +us,.code,func_8002708C,140,no +us,.code,func_800240EC,104,yes +us,.code,func_8002409C,80,yes +version,section,function,length,matching +us,.code,func_80030C70,124,yes +us,.code,func_80024764,84,yes +us,.code,func_8002451C,296,yes +us,.code,arcade_nintendo_coin_update,316,yes +us,.code,func_8002B390,1292,no +us,.code,func_80029ACC,516,yes +us,.code,arcade_pie_update,360,yes +us,.code,func_8002AF2C,120,yes +us,.code,func_80030FEC,500,yes +us,.code,arcade_75m_setup,1792,yes +us,.code,func_8002E3D4,780,no +us,.code,func_800252D8,452,yes +us,.code,func_8002F82C,1532,no +us,.code,arcade_100m_setup,1460,yes +us,.code,arcade_25m_setup,1328,yes +us,.code,func_80030CEC,708,no +us,.code,arcade_help_text_update,356,yes +us,.code,func_8002628C,352,yes +us,.code,func_800244E4,36,yes +us,.code,func_80024320,236,yes +us,.code,func_80029CD0,556,no +us,.code,func_800319D4,2124,no +us,.code,func_800263EC,300,yes +us,.code,func_80027A38,1108,no +us,.code,func_800255A8,76,yes +us,.code,func_80029968,356,yes +us,.code,func_80024508,20,yes +us,.code,func_8002419C,388,yes +us,.code,func_800268AC,1608,no +us,.code,func_800246EC,120,yes +us,.code,arcade_pauline_bottom_update,268,yes +us,.code,arcade_bonus_item_update,260,yes +us,.code,func_800247B8,56,yes +us,.code,func_8002AFA4,796,yes +us,.code,func_80024E84,852,yes +us,.code,func_8002AC54,728,yes +us,.code,arcade_rivet_update,388,yes +us,.code,func_8002440C,216,yes +us,.code,func_800247F0,56,yes +us,.code,arcade_get_object_type_count,104,yes +us,.code,func_800259D0,568,yes +us,.code,__arcade_abs_w,24,yes +us,.code,arcade_dk_50m_update,460,yes +us,.code,func_8002A390,120,yes +us,.code,func_8002B89C,4924,no +us,.code,arcade_dk_title_update,692,yes +us,.code,func_80027E8C,128,yes +us,.code,func_8002D6FC,2652,no +us,.code,func_8002A264,300,no +us,.code,func_800251D8,104,yes +us,.code,func_800311E0,472,no +us,.code,func_80024CF8,152,yes +us,.code,func_80030734,332,yes +us,.code,func_80025C08,1096,yes +us,.code,func_8002B2C0,184,yes +us,.code,func_8002CBD8,396,yes +us,.code,func_80026EF4,1516,no +us,.code,func_80025240,100,yes +us,.code,func_80029EFC,872,no +us,.code,func_80024000,412,yes +us,.code,func_8002EEB8,2420,no +us,.code,func_800257D8,392,yes +us,.code,func_80024C34,196,yes +us,.code,func_80024644,48,yes +us,.code,func_800255F4,484,yes +us,.code,func_80025960,112,yes +us,.code,arcade_barrel_stack_update,60,yes +us,.code,func_80026518,360,yes +us,.code,func_80026050,572,yes +us,.code,func_80024A50,180,no +us,.code,func_800274E0,264,no +us,.code,func_8002E158,636,no +us,.code,arcade_pulley_update,196,yes +us,.code,func_8002549C,268,yes +us,.code,func_80026680,556,yes +us,.code,func_80030A04,260,no +us,.code,func_8002A734,752,yes +us,.code,func_800252A4,52,yes +us,.code,func_80024828,56,yes +us,.code,func_80024D90,244,yes +us,.code,func_800275E8,1104,no +us,.code,arcade_50m_setup,2168,yes +us,.code,func_8003159C,940,yes +us,.code,func_8002CD64,2456,no +us,.code,func_8002AA24,560,yes +us,.code,func_8002FE28,540,no +us,.code,arcade_add_points_to_score,84,yes +us,.code,arcade_hammer_update,892,yes +us,.code,func_8002A474,704,yes +us,.code,arcade_pauline_top_update,180,yes +us,.code,func_80024940,272,no +us,.code,func_80031948,140,yes +us,.code,func_8002A408,108,no +us,.code,func_800313B8,484,yes +us,.code,func_80024B04,304,no +us,.code,arcade_points_text_update,164,yes +us,.code,func_80024860,120,yes +us,.code,func_800246C8,36,yes +version,section,function,length,matching +us,.code,func_800274C0,80,yes +us,.code,func_80025B70,72,yes +us,.code,func_80029F7C,728,no +us,.code,func_80025FC4,280,no +us,.code,func_8002A8F0,84,no +us,.code,func_8002ABDC,432,no +us,.code,func_8002976C,280,no +us,.code,func_8002466C,564,no +us,.code,func_80025904,348,no +us,.code,func_80025A60,272,no +us,.code,func_80028FC0,164,no +us,.code,func_8002AEC8,52,yes +us,.code,func_80026D48,128,no +us,.code,func_80029AF8,152,yes +us,.code,func_80024390,120,no +us,.code,func_800298C8,100,yes +us,.code,func_80024A4C,64,yes +us,.code,func_800292C4,396,no +us,.code,func_8002A374,444,no +us,.code,func_80027728,1216,no +us,.code,func_80029C1C,496,no +us,.code,func_80024408,564,no +us,.code,func_80028BD0,108,yes +us,.code,func_80029E0C,368,no +us,.code,func_80026A3C,116,yes +us,.code,func_80028CF8,268,no +us,.code,func_80025C40,96,no +us,.code,func_80028E88,312,no +us,.code,func_80029064,328,no +us,.code,func_8002A2DC,152,no +us,.code,func_80024A8C,516,no +us,.code,func_80028C3C,188,yes +us,.code,func_80027510,228,no +us,.code,func_80025368,248,no +us,.code,func_800260DC,572,no +us,.code,func_8002419C,500,no +us,.code,func_80027D64,348,no +us,.code,func_80027108,264,yes +us,.code,func_8002A530,332,no +us,.code,func_80026FE0,48,yes +us,.code,func_8002AD8C,116,no +us,.code,func_80024F64,56,yes +us,.code,func_8002992C,96,yes +us,.code,func_800250A0,200,yes +us,.code,func_80027410,108,yes +us,.code,func_80027060,168,yes +us,.code,func_800254B8,284,no +us,.code,func_8002463C,48,yes +us,.code,func_800291AC,88,yes +us,.code,func_80027480,64,yes +us,.code,func_80026318,1828,no +us,.code,func_80028E04,132,no +us,.code,func_8002998C,364,no +us,.code,func_80028544,152,no +us,.code,func_80025F48,124,no +us,.code,func_80028340,172,no +us,.code,func_80028B54,124,no +us,.code,func_8002A944,48,yes +us,.code,func_80025BB8,136,no +us,.code,func_8002A6C0,152,yes +us,.code,func_80025168,512,no +us,.code,func_800285DC,88,yes +us,.code,func_8002A67C,68,yes +us,.code,func_8002A758,408,no +us,.code,func_8002A2AC,48,no +us,.code,func_80029884,68,no +us,.code,func_80024E70,180,no +us,.code,func_800286D0,640,no +us,.code,func_800289EC,360,no +us,.code,func_80024000,412,no +us,.code,func_8002A974,352,no +us,.code,func_800275F4,308,no +us,.code,func_8002AE00,148,no +us,.code,func_80027010,72,yes +us,.code,func_80024F9C,260,no +us,.code,func_8002A254,88,yes +us,.code,func_80029450,156,no +us,.code,func_80029B90,140,yes +us,.code,func_80026CEC,92,no +us,.code,func_80026AB0,500,no +us,.code,func_800248A0,72,yes +us,.code,func_8002AAD4,264,no +us,.code,func_80027EC0,1152,no +us,.code,func_800283EC,344,no +us,.code,func_80026DC8,536,no +us,.code,func_80027BE8,380,no +us,.code,func_80027210,64,yes +us,.code,func_80029640,300,no +us,.code,func_80027250,224,no +us,.code,func_80024C90,184,yes +us,.code,func_8002AEFC,404,no +us,.code,func_80028950,156,no +us,.code,func_80024D48,296,no +us,.code,func_80025CB0,664,no +us,.code,func_80028634,156,no +us,.code,func_800294EC,340,no +us,.code,func_80027380,72,yes +us,.code,func_800273C8,72,yes +us,.code,func_80026CA4,72,yes +us,.code,func_800255D4,300,yes +us,.code,func_80027330,80,yes +us,.code,func_80025CA0,16,yes +us,.code,func_80025700,516,no +us,.code,func_80029204,192,yes +us,.code,func_800248E8,356,no +us,.code,func_80024F24,64,no +us,.code,func_8002AE94,52,yes +us,.code,func_80025460,88,yes +version,section,function,length,matching +us,.code,func_8002920C,160,yes +us,.code,func_80033AF0,7276,no +us,.code,func_80033A80,112,yes +us,.code,func_80028478,520,no +us,.code,func_80029140,204,yes +us,.code,func_8002C748,132,yes +us,.code,func_800254D0,8864,no +us,.code,func_8003340C,152,yes +us,.code,func_8002531C,72,yes +us,.code,func_80024EAC,252,yes +us,.code,func_80024300,524,no +us,.code,func_8002C5F4,340,yes +us,.code,func_80027A30,376,no +us,.code,func_80030C30,288,yes +us,.code,func_8002E82C,396,yes +us,.code,func_80030D50,264,yes +us,.code,func_8002FEC0,180,yes +us,.code,func_8002DCE0,156,yes +us,.code,func_8002A5CC,748,yes +us,.code,func_80024568,2372,no +us,.code,func_80028878,2140,no +us,.code,func_8002E9B8,92,yes +us,.code,func_8002FC98,352,no +us,.code,func_8002DD7C,136,yes +us,.code,func_8003392C,172,no +us,.code,func_8002EA7C,1668,no +us,.code,func_8002DC60,128,yes +us,.code,func_80031AA0,4200,no +us,.code,func_8002C520,212,yes +us,.code,func_8002FDF8,200,yes +us,.code,func_80030888,152,no +us,.code,func_8002EA14,104,yes +us,.code,func_8002C964,2252,no +us,.code,func_80028458,32,yes +us,.code,func_8002FF74,2324,no +us,.code,func_8002450C,24,no +us,.code,func_800251A0,380,yes +us,.code,func_800292B0,272,yes +us,.code,func_80024FA8,504,yes +us,.code,func_8002A8B8,116,yes +us,.code,func_80030AE0,336,yes +us,.code,func_80025364,72,yes +us,.code,func_800336C0,196,yes +us,.code,func_8002FC48,80,yes +us,.code,func_80028818,8,yes +us,.code,func_80030EC4,3036,no +us,.code,func_800253AC,292,no +us,.code,func_80032B08,1480,no +us,.code,func_80029468,3544,no +us,.code,func_80027840,180,no +us,.code,func_800290D4,108,yes +us,.code,func_800334A4,540,no +us,.code,func_80024000,316,no +us,.code,func_8002D230,2608,no +us,.code,func_80027950,224,no +us,.code,func_80030920,448,no +us,.code,func_8002A92C,7156,no +us,.code,func_80028820,88,yes +us,.code,func_80030E58,108,yes +us,.code,func_8002FB7C,204,yes +us,.code,func_8002A41C,320,yes +us,.code,func_800278F4,92,yes +us,.code,func_80024524,68,no +us,.code,func_8002E7A0,140,yes +us,.code,func_8002A240,476,no +us,.code,func_800330D0,828,no +us,.code,func_8002A55C,112,yes +us,.code,func_800293C0,168,yes +us,.code,func_8002C8B4,176,yes +us,.code,func_80027BA8,2224,no +us,.code,func_8002C7CC,232,yes +us,.code,func_800339D8,168,yes +us,.code,func_8003575C,328,yes +us,.code,func_800286B8,352,no +us,.code,func_8002413C,452,no +us,.code,func_8002DE04,2460,no +us,.code,func_8002F100,2684,no +us,.code,func_80033784,424,no +us,.code,func_80028680,56,yes +us,.code,func_80027770,208,no +version,section,function,length,matching +us,boot,func_80005A70,16,no +us,boot,func_800058BC,92,no +us,boot,osDestroyThread,260,yes +us,boot,guSprite2DInit,80,no +us,boot,func_8000102C,144,yes +us,boot,osRecvMesg,312,yes +us,boot,osGetThreadId,24,yes +us,boot,osCreateViManager,384,no +us,boot,func_80002F18,60,no +us,boot,func_80002750,52,yes +us,boot,__osContDataCrc,160,no +us,boot,func_80002ECC,76,no +us,boot,__osSetCompare,16,yes +us,boot,guMtxL2F,184,no +us,boot,__osPiCreateAccessQueue,80,no +us,boot,func_800005A8,984,no +us,boot,func_80007360,112,no +us,boot,__osDispatchThread,396,yes +us,boot,guTranslate,84,yes +us,boot,func_80000D8C,188,yes +us,boot,__osAiDeviceBusy,48,yes +us,boot,osEepromLongRead,140,yes +us,boot,func_80001700,1012,no +us,boot,func_80002790,152,no +us,boot,func_800022D4,288,no +us,boot,func_80002724,44,no +us,boot,__osPackRamWriteDataSafe,128,no +us,boot,func_80005948,96,no +us,boot,func_80005818,60,no +us,boot,osDpGetStatus,12,yes +us,boot,func_8000BE20,480,no +us,boot,osEPiRawReadIo,352,no +us,boot,__osEepStatus,428,no +us,boot,guLookAtHiliteF,1848,no +us,boot,osMotorStartStop,360,no +us,boot,osViGetCurrentFramebuffer,64,yes +us,boot,__osDevMgrMain,1168,no +us,boot,guAlign,80,no +us,boot,__osExceptionPreamble,16,yes +us,boot,__osSpSetStatus,12,yes +us,boot,func_80002D60,132,no +us,boot,func_800075CC,28,no +us,boot,func_800010C0,1600,no +us,boot,func_800004F4,180,yes +us,boot,func_800075E8,160,no +us,boot,osSendMesg,332,yes +us,boot,func_8000DB90,288,no +us,boot,sqrtf,16,yes +us,boot,__osPfsGetStatus,208,no +us,boot,__osSetGlobalIntMask,76,yes +us,boot,osUnmapTLBAll,80,yes +us,boot,__osPiGetAccess,68,no +us,boot,osSetThreadPri,224,yes +us,boot,__osSpGetStatus,12,yes +us,boot,memcpy,288,no +us,boot,func_800024E0,196,yes +us,boot,osMotorInit,348,yes +us,boot,osVirtualToPhysical,124,yes +us,boot,guMtxIdent,48,yes +us,boot,osEepromRead,452,no +us,boot,_MakeMotorData,268,no +us,boot,func_80007754,52,no +us,boot,osYieldThread,76,yes +us,boot,osPiReadIo,64,yes +us,boot,func_80002A64,88,no +us,boot,func_80002ABC,80,no +us,boot,__ull_to_f,28,no +us,boot,osViSwapBuffer,80,yes +us,boot,func_80005918,48,no +us,boot,__osContRamWrite,592,no +us,boot,func_80000980,80,yes +us,boot,osEepromProbe,112,no +us,boot,__osSetTimerIntr,116,yes +us,boot,guOrthoF,340,yes +us,boot,__osSetSR,16,yes +us,boot,osStartThread,336,yes +us,boot,guLookAtHilite,184,yes +us,boot,func_800057B0,44,no +us,boot,osSetIntMask,160,no +us,boot,func_80007724,24,no +us,boot,osGetCount,16,yes +us,boot,osContInit,368,no +us,boot,osPiStartDma,268,yes +us,boot,__osSumcalc,116,no +us,boot,func_80002E98,52,no +us,boot,bzero,160,yes +us,boot,__osInsertTimer,392,yes +us,boot,__osEnqueueAndYield,256,yes +us,boot,__osSpDeviceBusy,44,yes +us,boot,cosf,368,no +us,boot,osSpTaskYield,32,yes +us,boot,guMtxCatF,360,yes +us,boot,__osPopThread,16,yes +us,boot,func_80000AA0,564,no +us,boot,osGetTime,132,yes +us,boot,osCreateMesgQueue,44,yes +us,boot,guLookAt,120,yes +us,boot,func_800025A4,384,no +us,boot,__osSpRawStartDma,140,yes +us,boot,guPerspective,88,yes +us,boot,__osSiRawReadIo,80,yes +us,boot,__osIdCheckSum,252,no +us,boot,osViGetCurrentMode,72,yes +us,boot,func_8000320C,4884,no +us,boot,func_800057DC,60,no +us,boot,guOrtho,104,yes +us,boot,func_80002BB8,188,no +us,boot,func_80005880,60,no +us,boot,guNormalize,132,yes +us,boot,__osRestoreInt,32,yes +us,boot,__osViGetCurrentContext,12,yes +us,boot,osSetTime,36,yes +us,boot,osViSetMode,104,yes +us,boot,__osPiRelAccess,44,no +us,boot,func_80002DE4,180,no +us,boot,osInitialize,704,no +us,boot,func_800031E0,44,no +us,boot,func_80002828,184,no +us,boot,__osPackEepWriteData,172,no +us,boot,osPfsIsPlug,416,no +us,boot,send_mesg,232,yes +us,boot,__osEnqueueThread,72,yes +us,boot,osEPiRawWriteIo,352,no +us,boot,guLookAtF,696,yes +us,boot,guAlignF,448,no +us,boot,__osTimerInterrupt,376,yes +us,boot,osPiGetCmdQueue,40,yes +us,boot,__osProbeTLB,192,yes +us,boot,bcopy,784,yes +us,boot,osPiRawReadIo,84,yes +us,boot,func_80003120,192,no +us,boot,osSpTaskYielded,128,yes +us,boot,osGetThreadPri,24,yes +us,boot,guTranslateF,72,yes +us,boot,osInvalICache,128,yes +us,boot,osSetEventMesg,104,yes +us,boot,func_800023F4,236,no +us,boot,guRotateF,404,no +us,boot,guMtxCatL,88,yes +us,boot,func_80002CE8,120,no +us,boot,__osSiCreateAccessQueue,80,no +us,boot,__osSiDeviceBusy,48,no +us,boot,func_80005070,336,no +us,boot,__osTimerServicesInit,140,no +us,boot,func_80001AF4,340,no +us,boot,__osPfsRequestOneChannel,196,no +us,boot,__osSiRawWriteIo,76,yes +us,boot,guRotate,92,no +us,boot,osAiGetLength,12,yes +us,boot,func_8000D7E0,212,no +us,boot,osInvalDCache,176,yes +us,boot,__osPfsGetOneChannelData,156,no +us,boot,osJamMesg,336,yes +us,boot,__osSpSetPc,52,yes +us,boot,func_80007788,56,no +us,boot,func_80001C48,360,no +us,boot,osViGetNextFramebuffer,64,yes +us,boot,guPosition,112,no +us,boot,func_80000EEC,320,no +us,boot,__osResetGlobalIntMask,96,no +us,boot,__osException,1316,yes +us,boot,__osContGetInitData,208,no +us,boot,__osGetFpcCsr,16,yes +us,boot,__osSiRawStartDma,176,no +us,boot,guScale,72,yes +us,boot,osAiSetNextBuffer,164,yes +us,boot,__osDisableInt,32,yes +us,boot,__osViInit,316,yes +us,boot,func_80001DB0,1316,no +us,boot,func_80000E48,164,no +us,boot,__osPackRequestData,256,no +us,boot,osPiRawStartDma,224,yes +us,boot,func_800004B4,64,yes +us,boot,osStopThread,192,yes +us,boot,guMtxXFMF,160,yes +us,boot,__osRepairPackId,848,no +us,boot,func_80007688,156,no +us,boot,func_800028E0,268,no +us,boot,func_800073D0,132,yes +us,boot,osPiGetStatus,12,yes +us,boot,osSpTaskStartGo,64,yes +us,boot,func_80000CD4,184,yes +us,boot,sinf,448,no +us,boot,__osPfsRequestData,208,no +us,boot,func_80005A44,44,no +us,boot,func_800029EC,68,no +us,boot,func_800074E0,208,no +us,boot,func_800009D0,88,yes +us,boot,guMtxXFML,96,yes +us,boot,func_80000450,100,yes +us,boot,osSetTimer,212,yes +us,boot,osMapTLBRdb,96,yes +us,boot,func_80005854,44,no +us,boot,__osGetId,428,no +us,boot,osCreatePiManager,368,no +us,boot,func_80000A30,112,no +us,boot,func_8000D8B4,732,no +us,boot,osCreateThread,336,no +us,boot,func_800059A8,156,no +us,boot,osViBlack,112,yes +us,boot,func_80002C74,116,no +us,boot,func_800055D0,156,yes +us,boot,func_8000773C,24,no +us,boot,__osPackEepReadData,140,no +us,boot,osEepromWrite,376,no +us,boot,func_80002F54,172,no +us,boot,osWritebackDCache,128,yes +us,boot,osDpSetStatus,12,yes +us,boot,__osSetFpcCsr,16,yes +us,boot,__osSiRelAccess,44,no +us,boot,osSpTaskLoad,400,yes +us,boot,osViSetSpecialFeatures,440,yes +us,boot,__osGetSR,16,yes +us,boot,guMtxIdentF,136,yes +us,boot,func_80007454,140,no +us,boot,__osPfsGetInitData,208,no +us,boot,__osViSwapContext,768,no +us,boot,viMgrMain,400,no +us,boot,__osContRamReadData,560,no +us,boot,guMtxF2L,256,yes +us,boot,func_800056F0,112,no +us,boot,guPerspectiveF,560,yes +us,boot,func_80002B0C,172,no +us,boot,__osSiGetAccess,68,no +us,boot,guScaleF,84,yes +us,boot,func_80002A30,52,no +us,boot,__osCheckPackId,356,no +us,boot,__osContAddressCrc,208,no +us,boot,func_80000400,80,yes +us,boot,osWriteBackDCacheAll,48,yes +us,boot,__osDequeueThread,64,yes +us,boot,guPositionF,432,no diff --git a/progress/progress.water.csv b/progress/progress.water.csv new file mode 100644 index 00000000..7da973ad --- /dev/null +++ b/progress/progress.water.csv @@ -0,0 +1,56 @@ +version,section,function,length,matching +us,.code,func_8002658C,744,no +us,.code,func_800255C4,528,no +us,.code,func_80027118,552,no +us,.code,func_800247F4,900,no +us,.code,func_80024C88,672,no +us,.code,func_800288A8,500,no +us,.code,func_8002904C,196,no +us,.code,func_80027340,264,no +us,.code,func_80029110,8,yes +us,.code,func_80026874,144,no +us,.code,func_80025DB8,388,no +us,.code,func_80024578,64,yes +us,.code,func_80025F8C,144,yes +us,.code,func_80025F3C,80,yes +us,.code,func_80025A3C,148,no +us,.code,func_80025500,196,no +us,.code,func_80026530,92,yes +us,.code,func_80024154,296,no +us,.code,func_80028840,104,yes +us,.code,func_80026410,92,yes +us,.code,func_80026B78,292,no +us,.code,func_800296DC,276,no +us,.code,func_80026E0C,452,no +us,.code,func_80026C9C,368,no +us,.code,func_80028EE8,356,no +us,.code,func_80026298,40,yes +us,.code,func_80024518,96,no +us,.code,func_80029118,1476,no +us,.code,func_80027DC0,864,no +us,.code,func_80028DE8,256,no +us,.code,func_80028120,1824,no +us,.code,func_80026904,344,no +us,.code,func_80025AD0,588,no +us,.code,func_8002427C,528,no +us,.code,func_800245B8,572,no +us,.code,func_80026338,216,yes +us,.code,func_8002601C,636,no +us,.code,func_80024000,156,no +us,.code,func_80024F28,580,no +us,.code,func_80028A9C,844,no +us,.code,func_8002516C,916,no +us,.code,func_80026A5C,284,yes +us,.code,func_80024B78,272,no +us,.code,func_80025D1C,156,no +us,.code,func_800262C0,120,no +us,.code,func_8002646C,196,yes +us,.code,func_80026FD0,100,yes +us,.code,func_800257D4,220,no +us,.code,func_80027448,2424,no +us,.code,func_8002448C,140,no +us,.code,func_800258B0,396,no +us,.code,func_80027034,88,yes +us,.code,func_8002708C,140,no +us,.code,func_800240EC,104,yes +us,.code,func_8002409C,80,yes diff --git a/progress/progress_arcade.svg b/progress/progress_arcade.svg new file mode 100644 index 00000000..75740947 --- /dev/null +++ b/progress/progress_arcade.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + arcade + arcade + + + 49.9240% + 49.9240% + + \ No newline at end of file diff --git a/progress/progress_bonus.svg b/progress/progress_bonus.svg new file mode 100644 index 00000000..21d44038 --- /dev/null +++ b/progress/progress_bonus.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + bonus + bonus + + + 2.9943% + 2.9943% + + \ No newline at end of file diff --git a/progress/progress_boss.svg b/progress/progress_boss.svg new file mode 100644 index 00000000..d716c3a6 --- /dev/null +++ b/progress/progress_boss.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + boss + boss + + + 12.0240% + 12.0240% + + \ No newline at end of file diff --git a/progress/progress_dk64_boot.svg b/progress/progress_dk64_boot.svg new file mode 100644 index 00000000..d88b2314 --- /dev/null +++ b/progress/progress_dk64_boot.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + dk64_boot + dk64_boot + + + 32.0883% + 32.0883% + + \ No newline at end of file diff --git a/progress/progress_global_asm.svg b/progress/progress_global_asm.svg new file mode 100644 index 00000000..6b7fb363 --- /dev/null +++ b/progress/progress_global_asm.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + global_asm + global_asm + + + 15.5530% + 15.5530% + + \ No newline at end of file diff --git a/progress/progress_jetpac.svg b/progress/progress_jetpac.svg new file mode 100644 index 00000000..75d10c69 --- /dev/null +++ b/progress/progress_jetpac.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + jetpac + jetpac + + + 13.8951% + 13.8951% + + \ No newline at end of file diff --git a/progress/progress_menu.svg b/progress/progress_menu.svg new file mode 100644 index 00000000..55e2b8c3 --- /dev/null +++ b/progress/progress_menu.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + menu + menu + + + 11.9679% + 11.9679% + + \ No newline at end of file diff --git a/progress/progress_minecart.svg b/progress/progress_minecart.svg new file mode 100644 index 00000000..f4b65f95 --- /dev/null +++ b/progress/progress_minecart.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + minecart + minecart + + + 7.8371% + 7.8371% + + \ No newline at end of file diff --git a/progress/progress_multiplayer.svg b/progress/progress_multiplayer.svg new file mode 100644 index 00000000..dd874e4b --- /dev/null +++ b/progress/progress_multiplayer.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + multiplayer + multiplayer + + + 8.6957% + 8.6957% + + \ No newline at end of file diff --git a/progress/progress_race.svg b/progress/progress_race.svg new file mode 100644 index 00000000..e1764762 --- /dev/null +++ b/progress/progress_race.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + race + race + + + 5.9472% + 5.9472% + + \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg new file mode 100644 index 00000000..19afb108 --- /dev/null +++ b/progress/progress_total.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + Donkey Kong 64 (US) + Donkey Kong 64 (US) + + + 16.1737% + 16.1737% + + \ No newline at end of file diff --git a/progress/progress_water.svg b/progress/progress_water.svg new file mode 100644 index 00000000..6b61b8d4 --- /dev/null +++ b/progress/progress_water.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + water + water + + + 7.5160% + 7.5160% + + \ No newline at end of file diff --git a/src/arcade/code_0.c b/src/arcade/code_0.c new file mode 100644 index 00000000..cd6e0666 --- /dev/null +++ b/src/arcade/code_0.c @@ -0,0 +1,3293 @@ +#include "arcade_int.h" + +extern u8 D_80032D50; +extern u8 D_80032CA8; +extern u8 D_800342B8; +extern uSprite D_8004BC20[2]; +extern uSprite D_8004BC50[2]; + +extern void func_8060A9BC(void); +extern void func_8060AC7C(void); +extern void func_80610044(Gfx *, s32, s32, s32, s32, s32); +extern Gfx *func_806FD490(Gfx *, s32, s32, s32, s32 *); +extern void func_8070F2FC(Gfx **arg0, s16 arg1, s16 arg2); +extern void func_8070E8F0(Gfx**, Sprite*); +extern void func_8070F2C8(s32, s16, s32, u8); + +void func_8002419C(void *arg0, Gfx **arg1); +void func_80024940(Gfx **gpp); +void func_80024CF8(Gfx **arg0); +void func_800251D8(Gfx **arg0); +void func_800252D8(Gfx **arg0); +void func_800257D8(void); +void func_80025960(Gfx **arg0); +void func_800275E8(Gfx **arg0); +void func_80027A38(Gfx **arg0); +void func_800311E0(void); + +/* .code */ +void func_80024000(void) { + Gfx *sp2C; + s32 sp28; + + func_8060A9BC(); + func_80610044(D_8076A050[D_807444FC], D_8076A088, 3, 1, 0x4D2, 1); + D_807444FC ^= 1; + object_timer++; + D_8076A048 = D_807444FC * 0x11B0 + &D_80767CE8; + func_8060AC7C(); + if (((D_8076A0B1 & 1) != 0) && (D_807FD888 == 31.0f)) { + sp2C = D_8076A050[D_807444FC]; + } else { + func_8002419C(D_8076A048, &sp2C); + } + sp2C = func_80704484(sp2C, 0); + if (is_cutscene_active != 3) { + sp28 = D_8076A048 + 0xDB0; + func_805FE71C(sp2C, D_807444FC, &D_8076A088, 0); + func_805FE7B4(sp28, D_8076A048, &D_8076A08C, 1); + return; + } + func_805FE71C(sp2C, D_807444FC, &D_8076A088, 1); +} + +void func_8002419C(void *arg0, Gfx **arg1) { + Gfx *sp44 = (Gfx *)D_8076A050[D_807444FC]; + gSPSegment(sp44++, 0x00, NULL); + gSPSegment(sp44++, 0x02, osVirtualToPhysical(arg0)); + gSPSegment(sp44++, 0x01, osVirtualToPhysical(D_8076A080)); + gSPDisplayList(sp44++, &D_1000090); + gSPDisplayList(sp44++, &D_1000040); + gDPPipeSync(sp44++); + sp44 = func_805FE4D4(sp44); + gDPSetColorDither(sp44++,G_CD_MAGICSQ); + gDPSetAlphaDither(sp44++,G_AD_PATTERN); + gDPSetFillColor(sp44++, 0x00050005); + gDPFillRectangle(sp44++, 0, 0, 319, 239); + func_80024940(&sp44); + *arg1 = sp44; +} + +void func_80024320(void) { + s32 i; + + for (i = 0; i < 5; i++) { + func_8060C648(0x15, 0, i, 0, arcade_saved_high_scores[i]); + func_8060C648(0x12, 0, i, 0, arcade_saved_high_score_initials[i][0]); + func_8060C648(0x13, 0, i, 0, arcade_saved_high_score_initials[i][1]); + func_8060C648(0x14, 0, i, 0, arcade_saved_high_score_initials[i][2]); + } + D_8004A760 = arcade_saved_high_scores[0]; + func_8060DEA8(); +} + +void func_8002440C(void) { + s32 i; + + for (i = 0; i < 5; i++) { + arcade_saved_high_scores[i] = func_8060C6B8(0x15, 0, i, 0); + arcade_saved_high_score_initials[i][0] = func_8060C6B8(0x12, 0, i, 0); + arcade_saved_high_score_initials[i][1] = func_8060C6B8(0x13, 0, i, 0); + arcade_saved_high_score_initials[i][2] = func_8060C6B8(0x14, 0, i, 0); + } + D_8004A760 = arcade_saved_high_scores[0]; +} + +void func_800244E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + D_8004C725 = arg0; + D_8004C726 = arg1; + D_8004C727 = arg2; + D_8004C728 = arg3; +} + +void func_80024508(s32 arg0, s32 arg1) { + D_8004C72C = arg0; + D_8004C730 = arg1; +} + +void func_8002451C(Gfx **gpp, s32 *arg1) { + Gfx *gp = *gpp; + gDPPipeSync(gp++); + gDPSetCycleType(gp++, G_CYC_1CYCLE); + gSPClearGeometryMode(gp++, -1); + gSPSetGeometryMode(gp++, G_SHADE | 0x200000); + gDPSetPrimColor(gp++, 0, 0, D_8004C725, D_8004C726, D_8004C727, D_8004C728); + gDPSetCombineMode(gp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetRenderMode(gp++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + *gpp = func_806FD490(gp, 2, D_8004C72E, D_8004C732, arg1); +} + +// cycle_rng +s32 func_80024644(void) { + D_8004A738 = (D_8004A738 * 0x41C64E6D) + 12345; + return D_8004A738 >> 0x10 & 0x7FFF; +} + +void arcade_add_points_to_score(s32 round_points) { + s32 oldScore; + + oldScore = arcade_current_score; + arcade_current_score += round_points; + if ((arcade_current_score >= 10000) && (oldScore < 10000)) { + arcade_lives_internal++; + arcade_lives_visual++; + } +} + +//arcade_maxf +f32 func_800246C8(f32 arg0, f32 arg1) { + if (arg1 < arg0) { + return arg1; + } + return arg0; +} + +//get_first_empty_obj_slot +s32 func_800246EC(void) { + s32 i; + for (i = 0; i <= 0x4F; i++) { + if (D_8004BCD0[i].unk18 == 0) { + return i; + } + } + return 0; +} + +//get_first_empty_obj_slot_after_player +s32 func_80024764(void) { + s32 i; + for (i = D_8004C71F + 1; i < 0x50; i++) { + if (D_8004BCD0[i].unk18 == 0) { + return i; + } + } + return 0; +} + +//get_last_empty_obj_slot +s32 func_800247B8(void) { + s32 i; + for (i = 0x4F; i >= 0; i--) { + if (D_8004BCD0[i].unk18 == 0) { + return i; + } + } + return 0; +} + +s32 func_800247F0(void) { + s32 i; + for (i = 0x27; i >= 0; i--) { + if (D_8004BCD0[i].unk18 == 0) { + return i; + } + } + return 0; +} + +s32 func_80024828(void) { + s32 i; + for (i = 0x24; i >= 0; i--) { + if (D_8004BCD0[i].unk18 == 0) { + return i; + } + } + return 0; +} + +s32 func_80024860(enum ARCADE_OBJ_E arg0) { + s32 i; + for (i = 0; i < 0x50; i++) { + if (arg0 == D_8004BCD0[i].unk18) { + return i; + } + } + return -1; +} + +s32 arcade_get_object_type_count(enum ARCADE_OBJ_E arg0) { + s32 i; + s32 count = 0; + for (i = 0; i < 0x50; i++) { + if (arg0 == D_8004BCD0[i].unk18) { + count++; + } + } + return count; +} + +#ifndef NONMATCHING //needs .rodata and .data sections defined +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80024940.s") +#else +void func_80024940(Gfx **gpp) { + Gfx* sp1C; + //static D_8004A78C = 1; + //static D_8004A790 = 0; + + sp1C = *gpp; + if (D_8004A78C) { + D_8004A78C = 0; + arcade_background_visual = 1; + func_80024D90(); + func_8002440C(); + } + switch(D_8004C724) { + case 0:// 800249A8 + func_80024E84(&sp1C); + break; + case 1:// 800249B8 + func_800251D8(&sp1C); + break; + case 5:// 800249C8 + func_800252D8(&sp1C); + break; + case 4:// 800249D8 + func_800255F4(&sp1C); + break; + case 3:// 800249E8 + func_80024CF8(&sp1C); + break; + case 2:// 800249F8 + default: + func_80025960(&sp1C); + break; + } + func_800319D4(&sp1C); + D_8004C6D8++; + *gpp = --sp1C; + D_8004A790++; +} +#endif + +// struct, score, big offset, loops, aaa +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80024A50.s") +#else +void func_80024A50(s32 arg0) { + /* adds score to high scores */ + u8 pad[0x10]; + volatile u8 spC = D_8004A794; //static??? + int i, j; + + + for (i = 4; arg0 < i; i--) { + arcade_saved_high_scores[i] = arcade_saved_high_scores[i - 1]; + for (j = 0; j < 3; j++) { + arcade_saved_high_score_initials[i][j] = arcade_saved_high_score_initials[i - 1][j]; + } + } + arcade_saved_high_scores[arg0] = arcade_current_score; + for (j = 0; j < 3; j++) { + arcade_saved_high_score_initials[arg0][j] = spC; + } +} +#endif + +// update saved scores +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80024B04.s") +#else +void func_80024B04(void) { + int i; + for (i = 0; i < (u8)5; i++) { + if (arcade_saved_high_scores[i] < arcade_current_score) { + func_80024A50(i); + break; + } + } + for (i = 0; i < 3; i++) { + D_8004A774[i] = ' '; + } + D_8004C724 = 3; + arcade_background_visual = 0; + D_8004C6DC = 0; + D_8004C720 = 0; + for (i = 0; i < 0x50; i++) { + D_8004BCD0[i].unk18 = 0; + D_8004BCD0[0] = D_8004BCD0[i]; + } +} +#endif + +void func_80024C34(void) { + if (D_8004A73C == 0) { + if (D_8004A770 && D_8004A740 && !isFlagSet(0x84, FLAG_TYPE_PERMANENT)) { + // Arcade Golden Banana Collected + if (isFlagSet(0x82, FLAG_TYPE_PERMANENT)) { + // Nintendo Coin Spawn Pending + setFlag(0x11, TRUE, FLAG_TYPE_TEMPORARY); + } else { + // Arcade GB Spawn Pending + setFlag(0x10, TRUE, FLAG_TYPE_TEMPORARY); + } + } + if (D_8004A740) { // arcade_is_in_nintendo_coin_mode + func_805FF898(); + } else { + func_805FF378(MAP_MAIN_MENU, 0); + } + D_8004A73C = 1; + } +} + +void func_80024CF8(Gfx **arg0) { + Gfx *sp1C; + sp1C = *arg0; + D_8004C6DC++; + func_800259D0(&sp1C); + func_80030FEC(); //update objects + func_8002B2C0(&sp1C); + if (D_8004C6DC >= 1981) { // arcade_internal_timer + if (D_8004A740) { // arcade_is_in_nintendo_coin_mode + func_80024C34(); + } else { + func_80024D90(); + } + } + *arg0 = sp1C; +} + +void func_80024D90(void) { + s32 temp_v1; + ArcadeStruct1 *iPtr; + + D_8004C724 = 0; // arcade_should_reload_level + D_8004A740 = isFlagSet(0x63, FLAG_TYPE_TEMPORARY); // arcade_is_in_nintendo_coin_mode + arcade_background_visual = 0; + D_8004C6DC = 0x200; // arcade_internal_timer + arcade_game_state = 1; + + for (iPtr = D_8004BCD0; iPtr < &D_8004BCD0[0x50]; iPtr++) { + iPtr->unk18 = 0; + } + + temp_v1 = func_800246EC(); + + D_8004BCD0[temp_v1] = arcade_dk_title_obj_template; + D_8004BCD0[temp_v1].x_position = 138.0f; + D_8004BCD0[temp_v1].y_position = 180.0f; + D_8004BCD0[temp_v1].unk14 = &D_800424D0; +} + +void func_80024E84(Gfx **arg0) { + Gfx *sp24; + int i; + + sp24 = *arg0; + D_8004C6DC++; + func_800259D0(&sp24); + if (D_8004C6DC & 0x200) { + func_8002B2C0(&sp24); + } + if (D_8004A740 && D_8004C6DC == 0x5FE || newly_pressed_input & 0x9000) { + arcade_current_score = 0; + D_8004C723 = 0; + arcade_lives_internal = 2; + if (D_8004A740) { + arcade_lives_internal = 0; + // Nintendo Coin Collected + if (isFlagSet(0x84, FLAG_TYPE_PERMANENT)) { + D_8004C723 = 8; + // Arcade Golden Banana Collected + } else if (isFlagSet(0x82, FLAG_TYPE_PERMANENT)) { + D_8004C723 = 4; + } + }//L80024F74 + if (D_8004C723 / 4 + 1 >= 0xA) { + D_8004A76C = 9; + } else { + D_8004A76C = D_8004C723 / 4 + 1; + } + arcade_lives_visual = arcade_lives_internal + 1; + arcade_background_visual = 1; + D_8004C724 = 1; + D_8004C6DC = 0; + arcade_game_state = 1; + D_8004C721 = 0; + for (i = 0; i < 80; i++) { + D_8004BCD0[i].unk18 = 0; + } + D_8004BCD0[func_800246EC()] = arcade_pauline_bottom_obj_template; + D_8004BCD0[func_800246EC()] = arcade_pauline_top_obj_template; + D_8004BCD0[func_800246EC()] = arcade_dk_title_obj_template; + if (D_8004A76C == 2 && D_8004A740) { + D_8004BCD0[func_800246EC()] = arcade_nintendo_coin_obj_template; + } + D_8004C708 = 0; + }//L800251BC + *arg0 = sp24; +} + +void func_800251D8(Gfx **arg0) { + Gfx *sp1C; + sp1C = *arg0; + + func_80030FEC(); //update objects + func_800259D0(&sp1C); + func_8002B2C0(&sp1C); + if (D_8004C6DC++ >= 761) { // arcade_internal_timer + func_800257D8(); + } + *arg0 = sp1C; +} + +void func_80025240(void) { // queue_arcade_sfx() + if (arcade_background_visual == 1) { + arcade_next_sfx = SFX_4D_ARCADE_25M; + return; + } + if (arcade_background_visual == 2) { + arcade_next_sfx = SFX_4F_ARCADE_50M; + return; + } + if (arcade_background_visual == 4) { + arcade_next_sfx = SFX_4E_ARCADE_100M; + return; + } + arcade_next_sfx = -1; +} + +void func_800252A4(SFX_E arg0) { + arcade_next_sfx = arg0; + if (D_80770DF8 != 0) { + func_80737924(D_80770DF8); + } +} + +void func_800252D8(Gfx **arg0) { + Gfx *sp34; + s32 temp; + + sp34 = *arg0; + func_800259D0(&sp34); + if (D_8004C71E < 0xA) { // arcade_bonus_timer + if ((arcade_next_sfx == SFX_4D_ARCADE_25M) + || (arcade_next_sfx == SFX_4E_ARCADE_100M) + || (arcade_next_sfx == SFX_4F_ARCADE_50M) + || (arcade_next_sfx == -1)) { + func_800252A4(SFX_48_ARCADE_RUNNING_OUT_OF_TIME); // playSFX(runningOutOfTimeJingle) + } + } + if (D_80770DF8 == 0 && arcade_next_sfx > 0) { + temp = (s16) arcade_next_sfx; + func_80737638(D_8076D1F8, temp, 0x7FFF, 0x3F, 1.0f, 0, &D_80770DF8); + } + if (D_8004A760 < arcade_current_score) { + D_8004A760 = arcade_current_score; + } + if (D_8004C6DC++ == 0x3C) { + arcade_lives_visual = arcade_lives_internal; + arcade_game_state = 0; + D_8004BCD0[func_80024860(0xD)].unk19 = 2; + } + func_80030FEC(); //update objects + func_8002B2C0(&sp34); + if (arcade_game_state == 0) { + if (arcade_background_visual == 2) { + func_800313B8(); //100m_flame_spawn_check + } + if (arcade_background_visual == 4) { + func_800311E0(); //50m_pie_spawn_check + } + if ((newly_pressed_input & START_BUTTON) != 0) { + func_8002549C(); + D_8004C724 = 4; + } + } + *arg0 = sp34; +} + +void func_8002549C(void) { + int x, y; + s32 index; + for (x = 0x60; x < 0xe0; x += 0x10) { + for (y = 0x8C; y < 0xCC; y += 0x10) { + index = func_800247B8(); + D_8004BCD0[index] = D_8004A6B8; + D_8004BCD0[index].x_position = x; + D_8004BCD0[index].y_position = y; + } + } + D_8004A768 = 0; + D_8004C70C = D_807ECDE8->unk3; + D_8004A744 = 0; +} + +void func_800255A8(void) { + s32 temp_v0; + do { + temp_v0 = func_80024860(0x1C); + if (temp_v0 >= 0) { + D_8004BCD0[temp_v0].unk18 = 0; + } + } while (temp_v0 >= 0); +} + +void func_800255F4(Gfx **arg0) { + Gfx *sp2C; + + sp2C = *arg0; + func_800259D0(&sp2C); + func_8002B2C0(&sp2C); + if (newly_pressed_input & U_JPAD + || (D_807ECDE8->unk3 >= 0x1F && D_8004C70C < 0x1F) + ) { + D_8004A768--; + } + if (newly_pressed_input & D_JPAD + || (D_807ECDE8->unk3 < -0x1E && D_8004C70C >= -0x1E) + ) { + D_8004A768++; + } + + if (D_8004A768 >= 3) { + D_8004A768 = 0; + } + + if (D_8004A768 < 0) { + D_8004A768 = 2; + } + D_8004C70C = D_807ECDE8->unk3; + if (newly_pressed_input & CONT_START) { + func_800255A8(); + D_8004C724 = 5; + } + + if (newly_pressed_input & (CONT_A | CONT_B)) { + switch(D_8004A768) { + case 0: + func_800255A8(); + D_8004C724 = 5; + break; + case 1: + if (!D_8004A744) { + func_8060C8AC(2); + func_8002440C(); + func_80024320(); + if (D_8004A760 < arcade_current_score) + D_8004A760 = arcade_current_score; + D_8004A744 = 1; + } + break; + case 2: + func_80024C34(); + break; + } + } + *arg0 = sp2C; +} + +void func_800257D8(void) { + int i; + ArcadeStruct1 *tmp_v1; + for (i = 0; i < 80; i++) { + D_8004BCD0[i].unk18 = 0; + } + for (i = 0; i < (D_8004C723 & 3) + 1; i++) { + tmp_v1 = &D_8004BCD0[func_800246EC()]; + *tmp_v1 = arcade_dk_how_high_obj_template; + tmp_v1->y_position -= i * 0x20; + }//L800258C0 + + D_8004C6DC = 0; + if (D_8004C723 / 4 + 1 >= 0xA) { + D_8004A76C = 9; + } else { + D_8004A76C = D_8004C723 / 4 + 1; + } + func_80737638(D_8076D1F8, 0x47, 0x7fff, 0x3f, 1.0f, 0, 0); + D_8004C724 = 2; + arcade_game_state = 1; +} + +void func_80025960(Gfx **arg0) { + Gfx *sp1C = *arg0; + func_800259D0(&sp1C); + func_8002B2C0(&sp1C); + if (D_8004C6DC++ >= 0xa1) { + func_80029968(); //setup stage + D_8004C724 = 5; + } + *arg0 = sp1C; +} + +void func_800259D0(Gfx **arg0) { + Gfx *sp4C = *arg0; + gDPSetAlphaCompare(sp4C++, G_AC_NONE); + gDPSetTexturePersp(sp4C++, G_TP_NONE); + gDPSetTextureFilter(sp4C++, G_TF_BILERP); + gDPSetTextureConvert(sp4C++, G_TC_FILT); + gDPSetTextureDetail(sp4C++, G_TD_CLAMP); + gDPSetTextureLOD(sp4C++, G_TL_TILE); + gDPSetTextureLUT(sp4C++, G_TT_NONE); + gDPSetPrimColor(sp4C++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); + gDPSetRenderMode(sp4C++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(sp4C++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); + gDPSetScissor(sp4C++, G_SC_NON_INTERLACE, 48, 36, 272, 232); + + switch(D_8004C724) { + case 0://L80025B68 + if (D_8004C6DC & 0x200) { + func_80026680(&sp4C); + } + break; + case 1: + case 4: + case 5://L80025B88 + switch(arcade_background_visual) { + case 1: + func_800268AC(&sp4C); + break; + case 2: + func_80026EF4(&sp4C); + break; + case 3: + func_800275E8(&sp4C); + break; + default: + func_80027A38(&sp4C); + break; + } + break; + } + *arg0 = sp4C; +} + +void func_80025C08(Gfx **arg0, s32 arg1, s32 arg2, s32 arg3) { + int i; + Gfx *sp60; + + D_8004C719 = 8; + D_8004C71A = 4; + D_8004C6D4 = 0x400; + if (arcade_background_visual == 2) { D_8004C6D0 = &D_80032B90; } + else if (arcade_background_visual == 4) { D_8004C6D0 = &D_80032BD8; } + else { D_8004C6D0 = &D_80032B48; }//L80025CC0 + + guSprite2DInit( + D_8004BB30 + D_807444FC, D_8004C6D0, NULL, + D_8004C719, D_8004C719, D_8004C71A, G_IM_FMT_RGBA, + G_IM_SIZ_16b, 0, 0 + ); + + guSprite2DInit( + D_8004BB60 + D_807444FC, D_8004C6D0, NULL, + D_8004C719, D_8004C719, 1, G_IM_FMT_RGBA, + G_IM_SIZ_16b, 0, 0 + ); + + guSprite2DInit( + D_8004BB90 + D_807444FC, D_8004C6D0, NULL, + D_8004C719, D_8004C719, 2, G_IM_FMT_RGBA, + G_IM_SIZ_16b, 0, 0 + ); + + guSprite2DInit( + D_8004BBC0 + D_807444FC, D_8004C6D0, NULL, + D_8004C719, D_8004C719, 3, G_IM_FMT_RGBA, + G_IM_SIZ_16b, 0, 0 + ); + sp60 = *arg0; + func_8070E8F0(&sp60, D_8004BB30 + D_807444FC); + func_8070F2C8(0x400, D_8004C6D6, 0, 0); + + for (i = 0; i < arg3 / 4; i++) { + func_8070F2FC(&sp60, 4 * arg1, 4.0 * (f64)(arg2 + 4 * i + 8)); + }//L80025ED8 + D_8004C71A = arg3 % 4; + if (D_8004C71A) { + switch(D_8004C71A) { + case 1: + func_8070E8F0(&sp60, D_8004BB60 + D_807444FC); + break; + case 2: + func_8070E8F0(&sp60, D_8004BB90 + D_807444FC); + break; + case 3: + func_8070E8F0(&sp60, D_8004BBC0 + D_807444FC); + break; + } + func_8070F2C8(0x400, D_8004C6D6, 0, 0); + func_8070F2FC(&sp60, 4 * arg1, 4.0 * (f64)(arg2 + 4 * i + 8)); + } + *arg0 = sp60; +} + +void func_80026050(Gfx **arg0) { + Gfx *sp2C; + s32 sp28; + + sp2C = *arg0; + func_80025C08(&sp2C, 0x70, 0x1C, 0x2E); + func_80025C08(&sp2C, 0x80, 0x1C, 0x2E); + func_80025C08(&sp2C, 0xB0, 0x38, 0x12); + if (D_8004C724 == 1) { + if (D_8004C6DC < 0x190) { + sp28 = 0x82 - ((D_8004C6DC-0x3C)/0x14)*8; + if (sp28 >= 0x83) { + sp28 = 0x82; + } + if (sp28 < 0x22) + sp28 = 0x22; + func_80025C08(&sp2C, 0xA0, 0x51, sp28); + func_80025C08(&sp2C, 0xb0, 0x51, sp28); + } + }//L80026134 + else { + func_80025C08(&sp2C, 0x88, 0x50, 0x4); + func_80025C08(&sp2C, 0x88, 0x5b, 0xc); + func_80025C08(&sp2C, 0xe8, 0x53, 0xe); + func_80025C08(&sp2C, 0x50, 0x70, 0xe); + func_80025C08(&sp2C, 0x78, 0x6e, 0x12); + func_80025C08(&sp2C, 0xd8, 0x69, 0x8); + func_80025C08(&sp2C, 0xd8, 0x7d, 0x8); + func_80025C08(&sp2C, 0x70, 0x87, 0x5); + func_80025C08(&sp2C, 0x70, 0x99, 0x8); + func_80025C08(&sp2C, 0xA8, 0x89, 0x16); + func_80025C08(&sp2C, 0xE8, 0x8D, 0xE); + func_80025C08(&sp2C, 0x50, 0xAA, 0xE); + func_80025C08(&sp2C, 0x90, 0xA6, 0x15); + func_80025C08(&sp2C, 0x80, 0xC1, 0x4); + func_80025C08(&sp2C, 0x80, 0xD1, 0x8); + func_80025C08(&sp2C, 0xE8, 0xC7, 0xE); + } + //L8002626C + *arg0 = sp2C; +} + +void func_8002628C(Gfx **arg0) { + Gfx *sp24; + sp24 = *arg0; + func_80025C08(&sp24, 0x38, 0xBD, 0x1C); + func_80025C08(&sp24, 0x100, 0xBD, 0x1C); + func_80025C08(&sp24, 0x40, 0x9B, 0x1C); + func_80025C08(&sp24, 0xF8, 0x9B, 0x1C); + func_80025C08(&sp24, 0x48, 0x7A, 0x1A); + func_80025C08(&sp24, 0xF0, 0x7A, 0x1A); + func_80025C08(&sp24, 0x50, 0x58, 0x1C); + func_80025C08(&sp24, 0xE8, 0x58, 0x1C); + if (D_8004C708 == 0) { + func_80025C08(&sp24, 0x98, 0xBD, 0x1C); + func_80025C08(&sp24, 0x78, 0x9B, 0x1C); + func_80025C08(&sp24, 0xC0, 0x9B, 0x1C); + func_80025C08(&sp24, 0x98, 0x7A, 0x1A); + func_80025C08(&sp24, 0x70, 0x58, 0x1C); + func_80025C08(&sp24, 0xC8, 0x58, 0x1C); + } + *arg0 = sp24; +} + +void func_800263EC(Gfx **arg0) { + Gfx *sp24; + sp24 = *arg0; + func_80025C08(&sp24, 0x70, 0x1C, 0x31); + func_80025C08(&sp24, 0x80, 0x1C, 0x31); + func_80025C08(&sp24, 0xB0, 0x38, 0x15); + func_80025C08(&sp24, 0xD0, 0x54, 0x15); + func_80025C08(&sp24, 0x100, 0x62, 0x1C); + func_80025C08(&sp24, 0xB8, 0x77, 0x15); + func_80025C08(&sp24, 0x40, 0x7E, 0x2A); + func_80025C08(&sp24, 0x70, 0x7E, 0x38); + func_80025C08(&sp24, 0x80, 0x7E, 0x38); + func_80025C08(&sp24, 0xE8, 0x85, 0x15); + func_80025C08(&sp24, 0x100, 0xA8, 0xE); + func_80025C08(&sp24, 0x38, 0xAF, 0x1C); + *arg0 = sp24; +} + +void func_80026518(Gfx **arg0) { + Gfx *sp24; + sp24 = *arg0; + func_80025C08(&sp24, 0x70, 0x1C, 0x31); + func_80025C08(&sp24, 0x80, 0x1C, 0x31); + func_80025C08(&sp24, 0xB0, 0x38, 0x15); + func_80025C08(&sp24, 0x48, 0xBD, 0x1C); + func_80025C08(&sp24, 0x80, 0xBD, 0x1C); + func_80025C08(&sp24, 0xB8, 0xBD, 0x1C); + func_80025C08(&sp24, 0xF0, 0xBD, 0x1C); + func_80025C08(&sp24, 0x70, 0x9A, 0x1C); + func_80025C08(&sp24, 0xC0, 0x9A, 0x1C); + func_80025C08(&sp24, 0x48, 0x77, 0x1C); + func_80025C08(&sp24, 0x80, 0x77, 0x1C); + func_80025C08(&sp24, 0xB8, 0x77, 0x1C); + func_80025C08(&sp24, 0xF0, 0x77, 0x1C); + func_80025C08(&sp24, 0x40, 0x62, 0xE); + func_80025C08(&sp24, 0xF8, 0x62, 0xE); + *arg0 = sp24; +} + +void func_80026680(Gfx **gpp) { + int i; + int j; + Gfx *sp94; + s32 sp64[0xC] = D_8004A798; + s32 word; + + sp94 = *gpp; + D_8004C719 = 8; + D_8004C71A = 8; + D_8004C6D4 = 0x400; + if (D_8004C6DC & 0x182) D_8004C6D0 = &D_80032C20; + else D_8004C6D0 = &D_80032DF8; + + func_80005A90(&D_8004BB00[D_807444FC], D_8004C6D0, 0, + D_8004C719, D_8004C719, D_8004C71A, 0, 2, 0, 0 + ); + func_8070E8F0(&sp94, &D_8004BB00[D_807444FC]); + func_8070F2C8(0x400, D_8004C6D4, 0, 0); + for (i = 0; i < 0xC; i++) {//L80026800 + word = sp64[i]; + for (j = 0; j < 0x19; j++) {//L8002680C + if ((1 << j) & word) { + func_8070F2FC(&sp94, 0x3E0 - j * 0x20, ((i * 8 + 0x3F) * 4.0)); + } + } + } + *gpp = sp94; +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_800268AC.s") +#else +void func_800268AC(Gfx **gpp) { + int i; + Gfx *sp68; + int x; + int y; + + D_8004C719 = 8; + D_8004C71A = 8; + D_8004C6D4 = 0x492; + + D_8004C6D0 = &D_80034568; + func_80005A90(&D_8004BB00[D_807444FC], D_8004C6D0, 0, + D_8004C719, D_8004C719, D_8004C71A, 0, 2, 0, 0 + ); + sp68 = *gpp; + + + func_8070E8F0(&sp68, &D_8004BB00[D_807444FC]); + func_8070F2C8(0x400, D_8004C6D4, 0, 0); + for (i = 0; i < 6; i++) { + func_8070F2FC(&sp68, 0x220 + i*0x20, 0xE0); + } + + if (!((s32)D_8004C708 < 6)) { + for (i = 0; i < 0xE; i++) {////L800269FC + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x380); + } + for (i = 0xE; i < 0x1C; i++) {//L80026A50 + func_8070F2FC(&sp68, 0xC0 + i*0x20, ((0xf7 - (i-0xC)/2)*0.875 + 8.0)*4.0); + } + } else {//L80026AC0 + for (i = 0; i < 0x1C; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x368); + } + }//L80026B0C + + if (!((s32)D_8004C708 < 5)) { + for (i = 0; i < 0x1A; i++) {//L80026B30 + func_8070F2FC(&sp68, 0xC0 + i*0x20, ((0xCF + (i/2))*0.875 + 8.0)*4.0); + } + } else {//L80026B98 + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x2f4); + } + }//L80026BC0 + + + if (!((s32)D_8004C708 < 4)) { + for (i = 2; i < 0x1C; i++) {//L80026B30 + func_8070F2FC(&sp68, 0xC0 + i*0x20, ((0xbb - (i/2))*0.875 + 8.0)*4.0); + } + } else {//L80026C50 + for (i = 2; i < 0x1C; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x281); + } + }//L80026C74 + + if (!((s32)D_8004C708 < 3)) { + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, ((0x8d + (i/2))*0.875 + 8.0)*4.0); + } + } else {//L80026D04 + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x20d); + } + }//L80026D24 + + if (!((s32)D_8004C708 < 2)) { + for (i = 2; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, ((0x79 - (i/2))*0.875 + 8.0)*4.0); + } + } else {//L80026DB4 + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0x100 + i*0x20, 0x19a); + } + }//L80026DD8 + + if (!((s32)D_8004C708 < 1)) { + for (i = 0; i < 0x12; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x142); + } + for (i = 0x12; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, ((0x53 + ((i - 0x10)/2))*0.875 + 8.0)*4.0); + } + } else {//L80026E90 + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp68, 0xC0 + i*0x20, 0x142); + } + } + + func_80026050(&sp68); + *gpp = sp68; +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80026EF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_800274E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_800275E8.s") + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80027A38.s") +#else +//arcade_50m_draw +void func_80027A38(Gfx **arg0) { + int i, j; + Gfx *sp6C; + + sp6C = *arg0; + D_8004C719 = 8; + D_8004C71A = 10; + D_8004C6D4 = 1170; + + //50m solid beam + D_8004C6D0 = &D_80032D50; + func_80005A90(&D_8004BB00[D_807444FC], D_8004C6D0, 0, + D_8004C719, D_8004C719, D_8004C71A, 0, 2, 0, 0 + ); + func_8070E8F0(&sp6C, &D_8004BB00[D_807444FC]); + func_8070F2C8(0x400, D_8004C6D6, 0, 0); + for (i = 0; i <0x6; i++) { + func_8070F2FC(&sp6C, 0x220 + 0x20*i, 0xe0); + } + for (i = 0; i <0x1C; i++) { + func_8070F2FC(&sp6C, 0xC0 + 0x20*i, 0x380); + } + for (i = 1; i < 0x1B; i++) { + if (i != 6 && i != 7 && i != 0x13 && i != 0x14) { + func_8070F2FC(&sp6C, 0xC0 + 0x20*i, 0x268); + } + } + + //50m conveyer belt + D_8004C6D0 = &D_80032CA8; + func_80005A90(&D_8004BC20[D_807444FC], D_8004C6D0, 0, + D_8004C719, D_8004C719, D_8004C71A, 0, 2, 0, 0 + ); + func_8070E8F0(&sp6C, &D_8004BC20[D_807444FC]); + func_8070F2C8(0x400, D_8004C6D6, 0, 0); + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp6C, 0xE0 + 0x20*i, 0x150); + } + for (i = 0; i < 0x1C; i++) { + if (i < 0xC || i >= 0x10) { + func_8070F2FC(&sp6C, 0xC0 + 0x20*i, 0x1DC); + } + } + for (i = 0; i < 0x1A; i++) { + func_8070F2FC(&sp6C, 0xE0 + 0x20*i, 0x2f4); + } + + //50m background grate + D_8004C6D0 = &D_800342B8; + func_80005A90(&D_8004BC50[D_807444FC], D_8004C6D0, 0, + D_8004C719, D_8004C719, D_8004C71A, 0, 2, 0, 0 + ); + func_8070E8F0(&sp6C, &D_8004BC50[D_807444FC]); + func_8070F2C8(0x400, D_8004C6D6, 0, 0); + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + func_8070F2FC(&sp6C, 0x240 + 0x20*i, ((0x9f - 8*j)*0.875 + 8.0)*4.0); + } + } + func_80026518(&sp6C); + *arg0 = sp6C; +} +#endif + +// death()? +void func_80027E8C(void) { + func_800252A4(SFX_0_SILENCE); + func_80737638(D_8076D1F8, SFX_42_ARCADE_JUMPMAN_HIT, 0x7FFF, 0x3F, 1.0f, 0, 0); + D_8004BCD0[D_8004C71F].unk19 = 8; + D_8004BCD0[D_8004C71F].x_velocity = 0.0f; + D_8004BCD0[D_8004C71F].unk10 = 0.0f; + arcade_game_state = 1; +} + +void arcade_25m_setup(void) { + int v1 = 0x25; + D_8004BCD0[func_800246EC()] = arcade_pauline_bottom_obj_template; + D_8004BCD0[func_800246EC()] = arcade_pauline_top_obj_template; + D_8004BCD0[func_800246EC()] = arcade_help_text_obj_template; + D_8004BCD0[func_800246EC()] = arcade_dk_25m_obj_template; + if (D_8004A76C == 2 && D_8004A740) + D_8004BCD0[func_800246EC()] = arcade_nintendo_coin_obj_template; + D_8004BCD0[func_800246EC()] = arcade_bonus_osd_obj_template; + D_8004C71F = func_800246EC(); + D_8004BCD0[D_8004C71F] = arcade_jumpman_obj_template; + D_8004BCD0[v1] = arcade_oil_drum_obj_template; + v1--; + + D_8004BCD0[v1] = arcade_hammer_obj_template; + v1--; + + D_8004BCD0[v1] = arcade_hammer_obj_template; + D_8004BCD0[v1].x_position = 68.0f; + D_8004BCD0[v1].y_position = 110.0f; + v1--; + + D_8004BCD0[v1--] = arcade_barrel_stack_obj_template; + + D_8004BCD0[v1] = arcade_barrel_stack_obj_template; + D_8004BCD0[v1].x_position = 48.0f; + D_8004BCD0[v1--].unk1C = 1; + + D_8004BCD0[v1] = arcade_barrel_stack_obj_template; + D_8004BCD0[v1].y_position = 65.0f; + D_8004BCD0[v1--].unk1C = 2; + + D_8004BCD0[v1] = arcade_barrel_stack_obj_template; + D_8004BCD0[v1].x_position = 48.0f; + D_8004BCD0[v1].y_position = 65.0f; + D_8004BCD0[v1].unk1C = 3; + + D_8004C708 = 7; +} + +void arcade_100m_setup(void) { + s32 i; + s32 indx; + f32 f6; + + u8 sp3C[8][2] = D_8004A81C; + u32 s1 = 1; + + D_8004BCD0[func_800246EC()] = arcade_pauline_bottom_obj_template; + D_8004BCD0[func_800246EC()] = arcade_pauline_top_obj_template; + D_8004BCD0[func_800246EC()] = arcade_help_text_obj_template; + D_8004BCD0[func_800246EC()] = arcade_dk_100m_obj_template; + if (D_8004A76C == 2 && D_8004A740) + D_8004BCD0[func_800246EC()] = arcade_nintendo_coin_obj_template; + + for (i = 0; i < 8; i++) { + indx = func_800246EC(); + D_8004BCD0[indx] = arcade_rivet_obj_template; + D_8004BCD0[indx].x_position = (f32)sp3C[i][0]; + D_8004BCD0[indx].y_position = (f32)sp3C[i][1]; + D_8004BCD0[indx].unk1C = s1; + s1 <<= 1; + } + + indx = func_800246EC(); + D_8004BCD0[indx] = arcade_bonus_osd_obj_template; + D_8004BCD0[indx].unk14 = &D_800335D8; + + D_8004C71F = func_800246EC(); + D_8004BCD0[D_8004C71F] = arcade_jumpman_obj_template; + + D_8004BCD0[0x25] = arcade_bonus_item_obj_template; + D_8004BCD0[0x25].unk14 = &D_80038FE8; + + D_8004BCD0[0x24] = arcade_bonus_item_obj_template; + D_8004BCD0[0x24].x_position = 252.0f; + D_8004BCD0[0x24].y_position = 208.0f; + + D_8004BCD0[0x23] = arcade_bonus_item_obj_template; + D_8004BCD0[0x23].unk14 = &D_800391F0; + D_8004BCD0[0x23].x_position = 84.0f; + D_8004BCD0[0x23].y_position = 93.0f; + + D_8004BCD0[0x22] = arcade_hammer_obj_template; + D_8004BCD0[0x22].x_position = 60.0f; + D_8004BCD0[0x22].y_position = 152.0f; + + D_8004BCD0[0x21] = arcade_hammer_obj_template; + D_8004BCD0[0x21].x_position = 156.0f; + D_8004BCD0[0x21].y_position = 114.0f; +} + +void arcade_75m_setup(void) { + s32 a0 = 0x25; + s32 tmp; + f32 tmp_f2; + + D_8004BCD0[func_800246EC()] = arcade_pauline_bottom_obj_template; + D_8004BCD0[func_800246EC()] = arcade_pauline_top_obj_template; + D_8004BCD0[func_800246EC()] = arcade_help_text_obj_template; + D_8004BCD0[func_800246EC()] = arcade_dk_75m_obj_template; + if (D_8004A76C == 2 && D_8004A740) + D_8004BCD0[func_800246EC()] = arcade_nintendo_coin_obj_template; + D_8004BCD0[func_800246EC()] = arcade_bonus_osd_obj_template; + D_8004C71F = func_800246EC(); + D_8004BCD0[D_8004C71F] = arcade_jumpman_obj_template; + D_8004BCD0[D_8004C71F].x_position = 56.0; + D_8004BCD0[D_8004C71F].y_position = 231.0; + + D_8004BCD0[a0--] = arcade_elevator_obj_template; + + D_8004BCD0[a0] = arcade_elevator_obj_template; + D_8004BCD0[a0--].x_position = 144.0f; + + D_8004BCD0[a0] = arcade_elevator_obj_template; + D_8004BCD0[a0].y_position = 238.0f; + D_8004BCD0[a0--].unk1B = 1; + + D_8004BCD0[a0] = arcade_elevator_obj_template; + D_8004BCD0[a0].x_position = 144.0f; + D_8004BCD0[a0].y_position = 238.0f; + D_8004BCD0[a0--].unk1B = 1; + + D_8004BCD0[a0] = arcade_bonus_item_obj_template; + D_8004BCD0[a0].x_position = 260.0f; + D_8004BCD0[a0].y_position = 103.0f; + D_8004BCD0[a0--].unk14 = &D_80038FE8; + + D_8004BCD0[a0] = arcade_bonus_item_obj_template; + D_8004BCD0[a0].x_position = 60.0f; + D_8004BCD0[a0].y_position = 135.0f; + D_8004BCD0[a0--].unk14 = &D_800391F0; + + tmp = func_800246EC(); + D_8004BCD0[tmp] = arcade_flame_enemy_obj_template; + D_8004BCD0[tmp].x_velocity = 0.5; + D_8004BCD0[tmp].unk1A = 1; + D_8004BCD0[tmp].x_position = 114.0f; + D_8004BCD0[tmp].y_position = 135.0f; + + tmp = func_800246EC(); + D_8004BCD0[tmp] = arcade_flame_enemy_obj_template; + D_8004BCD0[tmp].x_velocity = 0.5; + D_8004BCD0[tmp].unk1A = 1; + D_8004BCD0[tmp].x_position = 260.0f; + D_8004BCD0[tmp].y_position = 103.0f; + + D_8004BC88[0][0] = 40.0f; + D_8004BC88[1][0] = 40.0f; + D_8004BC88[2][0] = 40.0f; + D_8004BC88[3][0] = 104.0f; + D_8004BC88[4][0] = 104.0f; + D_8004BC88[5][0] = 104.0f; + D_8004BC88[0][1] = 95.0f; + D_8004BC88[3][1] = 95.0f; + D_8004BC88[1][1] = 143.0f; + D_8004BC88[4][1] = 143.0f; + D_8004BC88[2][1] = 191.0f; + D_8004BC88[5][1] = 191.0f; + tmp_f2 = (func_800246C8(D_8004A76C, 4.0f) - 2.0)/16 + 0.5; + D_8004BC88[3][2] = tmp_f2; + D_8004BC88[0][2] = -tmp_f2; + D_8004BC88[1][2] = -tmp_f2; + D_8004BC88[2][2] = -tmp_f2; + D_8004BC88[4][2] = tmp_f2; + D_8004BC88[5][2] = tmp_f2; +} + +void arcade_50m_setup(void) { + s32 i; + int v1 = 0x25; + D_8004BCD0[func_800246EC()] = arcade_moving_ladder_obj_template; + i = func_800246EC(); + D_8004BCD0[i] = arcade_moving_ladder_obj_template; + D_8004BCD0[i].x_position = 244.0f; + D_8004BCD0[func_800246EC()] = arcade_pauline_bottom_obj_template; + D_8004BCD0[func_800246EC()] = arcade_pauline_top_obj_template; + D_8004BCD0[func_800246EC()] = arcade_help_text_obj_template; + D_8004BCD0[func_800246EC()] = arcade_dk_50m_obj_template; + if (D_8004A76C == 2 && D_8004A740) + D_8004BCD0[func_800246EC()] = arcade_nintendo_coin_obj_template; + + i = func_800246EC(); + D_8004BCD0[i] = arcade_bonus_osd_obj_template; + D_8004BCD0[i].unk14 = &D_80033C48; + + D_8004C71F = func_800246EC(); + D_8004BCD0[D_8004C71F] = arcade_jumpman_obj_template; + + D_8004BCD0[0x25] = arcade_oil_drum_obj_template; + D_8004BCD0[0x25].x_position = 152.0f; + D_8004BCD0[0x25].y_position = 127.0f; + + D_8004BCD0[0x24] = arcade_oil_drum_flame_obj_template; + D_8004BCD0[0x24].x_position = 152.0f; + D_8004BCD0[0x24].y_position = 113.0f; + + D_8004BCD0[0x23] = arcade_bonus_item_obj_template; + D_8004BCD0[0x23].unk14 = &D_80038FE8; + D_8004BCD0[0x23].x_position = 172.0f; + + D_8004BCD0[0x22] = arcade_bonus_item_obj_template; + D_8004BCD0[0x22].y_position = 167.0f; + D_8004BCD0[0x22].x_position = 116.0f; + + D_8004BCD0[0x21] = arcade_bonus_item_obj_template; + D_8004BCD0[0x21].unk14 = &D_800391F0; + D_8004BCD0[0x21].y_position = 167.0f; + D_8004BCD0[0x21].x_position = 252.0f; + + D_8004BCD0[0x20] = arcade_hammer_obj_template; + D_8004BCD0[0x20].x_position = 68.0f; + D_8004BCD0[0x20].y_position = 148.0f; + + D_8004BCD0[0x1F] = arcade_hammer_obj_template; + D_8004BCD0[0x1F].x_position = 156.0f; + D_8004BCD0[0x1F].y_position = 188.0f; + + D_8004BCD0[0x1E] = arcade_pulley_obj_template; + + D_8004BCD0[0x1D] = arcade_pulley_obj_template; + D_8004BCD0[0x1D].unk1A = 1; + D_8004BCD0[0x1D].unk1B = 1; + D_8004BCD0[0x1D].unk1C = 0; + D_8004BCD0[0x1D].x_position = 256.0f; + D_8004BCD0[0x1D].y_position = 84.0f; + + D_8004BCD0[0x1C] = arcade_pulley_obj_template; + D_8004BCD0[0x1C].unk1A = 1; + D_8004BCD0[0x1C].unk1B = 1; + D_8004BCD0[0x1C].unk1C = 1; + D_8004BCD0[0x1C].y_position = 124.0f; + D_8004BCD0[0x1C].x_position = 139.0f; + + D_8004BCD0[0x1B] = arcade_pulley_obj_template; + D_8004BCD0[0x1B].y_position = 124.0f; + D_8004BCD0[0x1B].unk1C = 2; + D_8004BCD0[0x1B].x_position = 165.0f; + + D_8004BCD0[0x1A] = arcade_pulley_obj_template; + D_8004BCD0[0x1A].y_position = 204.0f; + D_8004BCD0[0x1A].unk1C = 3; + D_8004BCD0[0x1A].x_position = 48.0f; + + D_8004BCD0[0x19] = arcade_pulley_obj_template; + D_8004BCD0[0x19].unk1A = 1; + D_8004BCD0[0x19].unk1B = 1; + D_8004BCD0[0x19].x_position = 256.0f; + D_8004BCD0[0x19].y_position = 204.0f; + D_8004BCD0[0x19].unk1C = 3; +} + +void func_80029968(void) { + int i; + int tmp_v0; + + D_8004C708 = 0; + arcade_background_visual = D_8004A788[D_8004C723 & 3]; + for (i = 0; i < 0x50; i++) { //clear arcade_obj_array + D_8004BCD0[i].unk18 = 0; + } + + switch(arcade_background_visual) { + case 1: + arcade_25m_setup(); + break; + case 2: + arcade_100m_setup(); + break; + case 3: + arcade_75m_setup(); + break; + default: + arcade_50m_setup(); + break; + } + func_80025240(); //queue stage music + tmp_v0 = D_8004A76C * 0xA + 0x28; + if (tmp_v0 >= 0x5B) { + D_8004C71E = 0x5A; + } else { + D_8004C71E = tmp_v0; + } + D_8004C710 = 0; + D_8004C718 = 0xFF; + D_8004A764 = 0; + D_8004C6DC = 0; + arcade_game_state = 1; + D_8004C6F8 = 1; + D_8004C721 = 1; + D_8004A308[0] = 0; + D_8004A308[1] = 0; + D_8004A308[2] = 0; + D_8004A308[3] = 0; + +} + +s32 func_80029ACC(s32 arg0, s32 arg1) { + s32 phi_v1; + + if (arg1 < 0x5D) { + D_8004C6F0 = 0x88; + } else { + D_8004C6F0 = 0x36; + } + D_8004C6F4 = 0x10A; + if (arg1 < 0x3F) { + D_8004C6F8 = 0; + if ((arg0 >= 0x85) && (arg0 < 0xBC)) { + phi_v1 = 0x37; + } else { + phi_v1 = 0xF8; + } + } else if (arg1 < 0x5D) { + D_8004C6F8 = 1; + phi_v1 = arg0 / 0x10; + if (arg0 / 0x10 < 0xB) { + phi_v1 = 0xB; + } + phi_v1 += 0x48; + if (arg0 >= 0x105) { + phi_v1 = 0xF8; + } + } else if (arg1 < 0x7F) { + D_8004C6F8 = 2; + phi_v1 = 0x7C - (arg0 / 0x10); + if (arg0 < 0x3C) { + phi_v1 = 0xF8; + } + } else if (arg1 < 0xA0) { + D_8004C6F8 = 3; + phi_v1 = (arg0 / 0x10) + 0x8A; + if (arg0 >= 0x105) { + phi_v1 = 0xF8; + } + } else if (arg1 < 0xC3) { + D_8004C6F8 = 4; + phi_v1 = 0xBE - (arg0 / 0x10); + if (arg0 < 0x3C) { + phi_v1 = 0xF8; + } + } else if (arg1 < 0xE1) { + D_8004C6F8 = 5; + phi_v1 = (arg0 / 0x10) + 0xCC; + if (arg0 >= 0x105) { + phi_v1 = 0xF8; + } + } else { + D_8004C6F8 = 6; + phi_v1 = 0x100 - (arg0 / 0x10); + if (phi_v1 >= 0xF8) { + phi_v1 = 0xF7; + } + } + if (phi_v1 < arg1) { + D_8004C6F8++; + } + return phi_v1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80029CD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80029EFC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002A264.s") + +s32 func_8002A390(s32 arg0, s32 arg1) { + if (arcade_background_visual == 1) { + func_80029ACC(arg0, arg1); + return; + } + if (arcade_background_visual == 2) { + func_80029CD0(arg0, arg1); + return; + } + if (arcade_background_visual == 3) { + func_80029EFC(arg0, arg1); + return; + } + return func_8002A264(arg0, arg1); +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002A408.s") +#else +s32 func_8002A408(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { + if ((arg1 < arg3 ^ 1) & (arg5 < arg1 ^ 1) & (arg2 - 4 < arg0) & (arg0 < arg2 + 3)) { + D_8004C6E0 = arg2; + D_8004C6E4 = arg3; + D_8004C6E8 = arg5; + D_8004C6EC = arg4; + return 1; + } + return 0; +} +#endif + + +s32 func_8002A474(s32 arg0, s32 arg1) { + if (func_8002A408(arg0, arg1, 0x84, 0xD4, 0xEB, 0xF7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xEC, 0xDA, 0xDA, 0xF2)) { + return 2; + } + if (func_8002A408(arg0, arg1, 0x94, 0xB5, 0xB5, 0xD5)) { + return 3; + } + if (func_8002A408(arg0, arg1, 0x54, 0xB9, 0xB9, 0xD1)) { + return 4; + } + if (func_8002A408(arg0, arg1, 0x74, 0x91, 0xAB, 0xB7)) { + return 5; + } + if (func_8002A408(arg0, arg1, 0xAC, 0x94, 0x94, 0xB4)) { + return 6; + } + if (func_8002A408(arg0, arg1, 0xEC, 0x98, 0x98, 0xB0)) { + return 7; + } + if (func_8002A408(arg0, arg1, 0xDC, 0x6F, 0x8B, 0x97)) { + return 8; + } + if (func_8002A408(arg0, arg1, 0x7C, 0x75, 0x75, 0x91)) { + return 9; + } + if (func_8002A408(arg0, arg1, 0x54, 0x77, 0x77, 0x8F)) { + return 0xA; + } + if (func_8002A408(arg0, arg1, 0x8C, 0x53, 0x64, 0x74)) { + return 0xB; + } + if (func_8002A408(arg0, arg1, 0xEC, 0x56, 0x56, 0x6E)) { + return 0xC; + } + if (func_8002A408(arg0, arg1, 0xB4, 0x37, 0x37, 0x53)) { + return 0xD; + } + D_8004C6E0 = 0; + D_8004C6E4 = 300; + D_8004C6EC = 300; + D_8004C6E8 = 1; + return 0; +} + +s32 func_8002A734(s32 arg0, s32 arg1) { + if (func_8002A408(arg0, arg1, 0x3C, 0xD0, 0xD0, 0xF7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x9C, 0xD0, 0xD0, 0xF7)) { + return 2; + } + if (func_8002A408(arg0, arg1, 0x104, 0xD0, 0xD0, 0xF7)) { + return 3; + } + if (func_8002A408(arg0, arg1, 0x44, 0xAA, 0xAA, 0xD0)) { + return 4; + } + if (func_8002A408(arg0, arg1, 0x7C, 0xAA, 0xAA, 0xD0)) { + return 5; + } + if (func_8002A408(arg0, arg1, 0xC4, 0xAA, 0xAA, 0xD0)) { + return 6; + } + if (func_8002A408(arg0, arg1, 0xFC, 0xAA, 0xAA, 0xD0)) { + return 7; + } + if (func_8002A408(arg0, arg1, 0x4C, 0x84, 0x84, 0xAA)) { + return 8; + } + if (func_8002A408(arg0, arg1, 0x9C, 0x84, 0x84, 0xAA)) { + return 9; + } + if (func_8002A408(arg0, arg1, 0xF4, 0x84, 0x84, 0xAA)) { + return 0xA; + } + if (func_8002A408(arg0, arg1, 0x54, 0x5D, 0x5D, 0x84)) { + return 0xB; + } + if (func_8002A408(arg0, arg1, 0x74, 0x5D, 0x5D, 0x84)) { + return 0xC; + } + if (func_8002A408(arg0, arg1, 0xCC, 0x5D, 0x5D, 0x84)) { + return 0xD; + } + if (func_8002A408(arg0, arg1, 0xEC, 0x5D, 0x5D, 0x84)) { + return 0xE; + } + D_8004C6E0 = 0; + D_8004C6E4 = 300; + D_8004C6EC = 300; + D_8004C6E8 = 1; + return 0; +} + +s32 func_8002AA24(s32 arg0, s32 arg1) { + if (func_8002A408(arg0, arg1, 0xB4, 0x37, 0x37, 0x57)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xD4, 0x57, 0x57, 0x77)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x104, 0x67, 0x67, 0x8F)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xBC, 0x7F, 0x7F, 0x9F)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xEC, 0x8F, 0x8F, 0xAF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x104, 0xB7, 0xB7, 0xCF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x44, 0x87, 0x87, 0xBF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x74, 0x87, 0x87, 0xCF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x84, 0x87, 0x87, 0xCF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x3C, 0xBF, 0xBF, 0xE7)) { + return 1; + } + D_8004C6E0 = 0; + D_8004C6E4 = 300; + D_8004C6EC = 300; + D_8004C6E8 = 1; + return 0; +} + +s32 func_8002AC54(s32 arg0, s32 arg1) { + s32 phi_v0; + + if (func_8002A408(arg0, arg1, 0x4C, 0xCF, 0xCF, 0xF7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x84, 0xCF, 0xCF, 0xF7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xBC, 0xCF, 0xCF, 0xF7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xF4, 0xCF, 0xCF, 0xF7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x74, 0xA7, 0xA7, 0xCF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xC4, 0xA7, 0xA7, 0xCF)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x4C, 0x7F, 0x7F, 0xA7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0x84, 0x7F, 0x7F, 0xA7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xBC, 0x7F, 0x7F, 0xA7)) { + return 1; + } + if (func_8002A408(arg0, arg1, 0xF4, 0x7F, 0x7F, 0xA7)) { + return 1; + } + phi_v0 = D_8004BCD0[0].y_position; + if (phi_v0 == 0x61) { + phi_v0 = 0x57; + } else { + phi_v0 = 0x74; + } + if (func_8002A408(arg0, arg1, 0x44, 0x57, phi_v0, 0x7F)) { + return 1; + } + + phi_v0 = D_8004BCD0[1].y_position; + if (phi_v0 == 0x61) { + phi_v0 = 0x57; + } else { + phi_v0 = 0x74; + } + if (func_8002A408(arg0, arg1, 0xFC, 0x57, phi_v0, 0x7F)) { + return 1; + } + D_8004C6E0 = 0; + D_8004C6E4 = 300; + D_8004C6EC = 300; + D_8004C6E8 = 1; + return 0; +} + +s32 func_8002AF2C(s32 arg0, s32 arg1) { + if (arcade_background_visual == 1) { + return func_8002A474(arg0, arg1); + } + if (arcade_background_visual == 2) { + return func_8002A734(arg0, arg1); + } + if (arcade_background_visual == 3) { + return func_8002AA24(arg0, arg1); + } + return func_8002AC54(arg0, arg1); +} + +void func_8002AFA4(Gfx **arg0, s32 arg1) { + Gfx *sp4C; + s32 tmp_v0; + f32 phi_f0; + + if (D_8004A338[D_8004BCD0[arg1].unk18] & 1) { + phi_f0 = 1024.0f; + } else { + phi_f0 = D_8004AA18; + } + guSprite2DInit( + &D_8004AC00[D_807444FC].sprite[arg1], D_8004BCD0[arg1].unk14, 0, + D_8004BCD0[arg1].unk1E, D_8004BCD0[arg1].unk1E, D_8004BCD0[arg1].unk1F, G_IM_FMT_RGBA, + G_IM_SIZ_16b, 0, 0 + ); + sp4C = *arg0; + func_8070E8F0(&sp4C, &D_8004AC00[D_807444FC].sprite[arg1]); + func_8070F2C8(0x400, phi_f0, 1 & D_8004BCD0[arg1].unk1A & 1, D_8004BCD0[arg1].unk1B); + + if (D_8004A338[D_8004BCD0[arg1].unk18] & 2) { + func_8070F2FC(&sp4C, + (s32)(D_8004BCD0[arg1].x_position - (f32)D_8004A358[D_8004BCD0[arg1].unk18])*4, + (s32)((D_8004BCD0[arg1].y_position - (f32)D_8004A378[D_8004BCD0[arg1].unk18])*0.875 + 8)*4); + } else {//L8002B1AC + if (D_8004BCD0[arg1].unk18 == 2) { + tmp_v0 = (s32)D_8004BCD0[arg1].unk10; + if (tmp_v0 > 2) { + tmp_v0 = 5 - tmp_v0; + } + } else { + tmp_v0 = 0; + } + func_8070F2FC(&sp4C, + (s32)(D_8004BCD0[arg1].x_position - D_8004A358[D_8004BCD0[arg1].unk18])*4, + (s32)(4*((D_8004BCD0[arg1].y_position - tmp_v0 - D_8004A378[D_8004BCD0[arg1].unk18])*0.875 + 8.0))); + }//L8002B2A4 + *arg0 = sp4C; +} + +void func_8002B2C0(Gfx **arg0) { + s32 i; + Gfx *sp38; + + sp38 = *arg0; + for (i = 0; i < 0x50; i++) { + if ((D_8004BCD0[i].unk18 != 0) && (D_8004BCD0[i].unk14 != 0)) { + if ((D_8004BCD0[i].unk18 >= 8) || (arcade_game_state < 2)) { + func_8002AFA4(&sp38, i); + } + } + } + *arg0 = sp38; +} + +s32 __arcade_abs_w(s32 arg0) { + if (arg0 >= 0) { + return arg0; + } + return -arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002B390.s") + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002B89C.s") +#else + extern f32 D_8004AA1C; + extern f64 D_8004AA20; + extern f32 D_8004AA28; + extern f64 D_8004AA30; + extern f32 D_8004AA38; + extern f64 D_8004AA40; + extern f32 D_8004AA64; + extern f64 D_8004AA68; + extern f64 D_8004AA78; + extern f64 D_8004AA80; + extern f64 D_8004AA88; + extern f32 D_8004AA90; + extern s32 D_8004BC80; + extern s32 D_8004BC84; + extern s32 D_8004C700; + + extern s32 D_80770DFC; + +void func_8002B89C(s32 arg0) { + f32 sp44; + s32 sp40; + s32 sp3C; + s32 sp38; + ArcadeStruct1 *sp30 = D_8004BCD0 + arg0; + s32 tmp_v0; + int i; + int pointIndx; + ArcadeStruct1 *stagePtr; + + if (sp30->unk19 == 8 || arcade_game_state == 0) { + if (sp30->unk19 == 2) { + func_8002A390(sp30->unk0, sp30->unk4); + if (sp30->unk8 < 0.0f) { + sp30->unk1A &= 1; + } else if (0.0f < sp30->unk8) { + sp30->unk1A |= 2; + } + if (( D_807ECDE8->unk0 & 0x200 || D_807ECDE8->unk2 < -0x14 ) + && D_8004C6F0 < sp30->unk0 + ) { + D_8004BC80 += 3; + sp30->unk8 = D_8004AA1C; + sp30->unk10 += D_8004AA20; + } else if ((D_807ECDE8->unk0 & 0x100 || D_807ECDE8->unk2 >= 0x15) + && D_8004C6F4 < sp30->unk0 + ) {//L8002B9DC + D_8004BC80 += 3; + sp30->unk8 = D_8004AA28; + sp30->unk10 += D_8004AA30; + } else { + sp30->unk8 = 0.0f; + }//L8002BA5C + if (newly_pressed_input & (A_BUTTON | B_BUTTON | Z_TRIG) && !D_8004C710) { + func_80737638(D_8076D1F8, SFX_41_ARCADE_JUMPMAN_JUMPING, 0x7fff, 0x3F, 1.0f, 0, 0); + sp30->unk10 = 0.0f; + sp30->unkC = D_8004AA38; + sp30->unk8 *= D_8004AA40; + sp30->unk1D = (s8) (u32) sp30->unk4; + sp30->unk19 = 3; + } + }//L8002BB74 + if (sp30->unk4 < func_8002A390( sp30->unk8 + sp30->unk0,sp30->unk4) + 3) { + sp30->unk0 += sp30->unk8; + } else { + sp30->unk8 = 0.0f; + } + if (sp30->unk19 != 8 + && arcade_background_visual == 3 + && ( (76.0f < sp30->unk0 && sp30->unk0 < 140.0f) || (140.0f < sp30->unk0 && sp30->unk0 < 164.0f)) + && ( (sp30->unk4 < 116.0f && 239.0f < sp30->unk4) || (239.0f < sp30->unk4)) + ) { + func_80027E8C(); + } else {////L8002BCC4 + D_8004C700 = func_8002AF2C(sp30->unk0, sp30->unk4); + sp40 = func_8002A390(sp30->unk0, sp30->unk4); + D_8004C6FC = D_8004C6F8; + switch (sp30->unk19) { + case 2:// 8002BD64 + if (D_8004C6FC == 0) + D_8004BCD0[D_8004C71F].unk0 += D_8004A308[0]; + if (D_8004C6FC == 1) + D_8004BCD0[D_8004C71F].unk0 += D_8004A308[1]; + if (D_8004C6FC == 2) + D_8004BCD0[D_8004C71F].unk0 += D_8004A308[2]; + if (D_8004C6FC == 3) + D_8004BCD0[D_8004C71F].unk0 += D_8004A308[3]; + + if (sp30->unk0 <= D_8004C6F0 - 1) + sp30->unk0 = D_8004C6F0; + if (D_8004C6F4 + 1 <= sp30->unk0) + sp30->unk0 = D_8004C6F4; + + if (D_8004C6EC < sp30->unk4 + && ((D_807ECDE8->unk0 & 0x800) | ((D_807ECDE8->unk3 < 0x15) ^ 1)) + && D_807ECDE8->unk2 < 0x29 && D_807ECDE8->unk2 >= -0x28 + && !(D_807ECDE8->unk0 & 0x300) + && !D_8004C710 + ) { + sp30->unk19 = 5; + sp30->unk8 = 0.0f; + sp30->unk4--; + sp30->unk0 = D_8004C6E0; + } else if ( + sp30->unk4 < D_8004C6E8 + && D_8004C6EC <= sp30->unk4 + && !(D_807ECDE8->unk0 & 0x300) + && D_807ECDE8->unk2 < 0x29 && D_807ECDE8->unk2 >= -0x28 + && ((D_807ECDE8->unk0 & 0x400) | (D_807ECDE8->unk3 < -0x14)) + && !D_8004C710 + ) { + sp30->unk19 = 5; + sp30->unk8 = 0.0f; + sp30->unk4++; + sp30->unk0 = D_8004C6E0; + } else if (sp40 - sp30->unk4 < 2.0f) { + sp30->unk4 = sp40; + } else { + sp30->unk19 = 3; + sp30->unk8 = 0.0f; + sp30->unkC = 0.0f; + sp30->unk1D = (s8) (u32) sp30->unk4; + } + sp3C = 4; + break; + case 5:// 8002C0FC + if (sp40 == sp30->unk4 + && ( ( (D_807ECDE8->unk0 & 0x300) | (D_807ECDE8->unk2 < 0x15)^1 | (D_807ECDE8->unk2 < -0x14)) + || (D_8004C6FC == 2 && D_8004A308[2]) + || (D_8004C6FC == 1 && D_8004A308[1]) + || (D_8004C6FC == 3 && D_8004A308[3]) + ) + ) { + sp30->unk19 = 2; + } else if ( + sp40 == sp30->unk4 + && newly_pressed_input & (A_BUTTON | B_BUTTON | Z_TRIG) + ) {//L8002C198 + func_80737638(D_8076D1F8, SFX_41_ARCADE_JUMPMAN_JUMPING, 0x7fff, 0x3f, 1.0f, 0, NULL); + sp30->unk10 = 0.0f; + sp30->unkC = D_8004AA64; + sp30->unk8 *= D_8004AA68; + sp30->unk19 = 3; + sp30->unk1D = (s8) (u32) sp30->unk4; + } else {//L8002C2AC + //TODO: FINISH THIS + } + break; + case 3:// 8002C420 + if (D_8004C6F4 < sp30->unk0) { + sp30->unk0 = D_8004C6F4; + if (sp30->unkC < D_8004AA78) { + sp30->unk1A &= 1; + sp30->unk8 = -sp30->unk8; + sp30->unkC = -sp30->unkC; + } + } else { //L8002C490 + if (sp30->unk0 < D_8004C6F0) { + sp30->unk0 = D_8004C6F0; + if (sp30->unkC < D_8004AA80) { + sp30->unk1A |= 2; + sp30->unk8 = -sp30->unk8; + sp30->unkC = -sp30->unkC; + } + } + }//L8002C4F8 + sp30->unk4 += sp30->unkC; + sp30->unkC += D_8004AA88; + if (0.0f <= sp30->unkC && sp30->unkC < D_8004AA88) { + sp38 = 0; + for (i = 0; i < 0x50; i++) { + if (D_8004BCD0[i].unk18 == 1 || D_8004BCD0[i].unk18 == 2) { + if (__arcade_abs_w(D_8004BCD0[i].unk0) < 0xD + && D_8004BCD0[i].unk0 - sp30->unk0 < 24.0f + && sp30->unk0 < D_8004BCD0[i].unk0 + ) { + sp38++; + } + }//L8002C5EC + } + if (sp38) { + pointIndx = func_800247F0(); + D_8004BCD0[pointIndx] = arcade_points_text_obj_template; + D_8004BCD0[pointIndx].unk0 = sp30->unk0; + D_8004BCD0[pointIndx].unk4 = sp30->unk4; + if (sp38 == 1) { + arcade_add_points_to_score(100); + } else if (sp38 == 2) { + D_8004BCD0[pointIndx].unk14 = &D_800383B8; + arcade_add_points_to_score(300); + } else if (sp38 == 3) { + D_8004BCD0[pointIndx].unk14 = &D_800385C0; + arcade_add_points_to_score(500); + } + } + }//L8002C70C + if (15.0f < sp30->unk4 - sp30->unk1D) { + func_80737638(D_8076D1F8, SFX_44_ARCADE_SPRING_FALL, 0x7fff, 0x3f, 1.0f, 0, NULL); + sp30->unk1D = 0xff; + } + if (2.5 < sp30->unkC) { + sp30->unkC = 2.5f; + } + if (sp40 < sp30->unk4 && sp30->unk4 - sp40 < 3.0f) { + sp30->unk4 = sp40; + if (sp30->unk1D == 0xff) { + func_80027E8C(); + } else { + sp30->unk19 = 4; + sp30->unkC = 0.0f; + sp30->unk8 = 0.0f; + sp30->unk10 = 4.0f; + } + }//L8002C850 + break; + case 4:// 8002C858 + if (0.0f == sp30->unk10) { + sp30->unk19 = 2; + } + break; + case 8:// 8002C898 + sp30->unk10 += 0.125; + if (8.0f == sp30->unk10) { + func_80737638(D_8076D1F8, SFX_54_ARCADE_JUMPMAN_DEATH, 0x7fff, 0x3f, 1.0, 0, NULL); + } + break; + }// 8002C908 + if (!(D_8004BC80 < 0x24)) { + D_8004BC80 = 0; + tmp_v0 = D_8004BC84; + tmp_v0++; + if (tmp_v0 == 7) + tmp_v0 = 0; + if (tmp_v0 & 1) { + sp44 = 1.0f; + } else { + sp44 = D_8004AA90; + } + func_80737638(D_8076D1F8, SFX_40_ARCADE_JUMPMAN_MOVING, 0x7fff, 0x3f, 1.0f, 0, &D_80770DFC); + func_80737AC4(D_80770DFC, 0x10, sp44); + }//L8002C9C0 + sp40 = func_8002A390(sp30->unk0, sp30->unk4); + sp30->unk1C = D_8004C6F8; + D_8004C704 = sp30->unk4 - D_8004C6E4; + if (D_8004C71E < 0 && sp30->unk19 != 8) { + func_80027E8C(); + } + if (D_8004C6F8 == 0 && sp40 == sp30->unk4) { + func_80737638(D_8076D1F8, SFX_4C_ARCADE_PAULINE_SAVED_STAGE, 0x7fff, 0x3f, 1.0f, 0, NULL); + func_800252A4(0); + if (arcade_background_visual == 1) { + stagePtr = func_80024860(ARCADE_OBJ_16_DK_25M); + } else if (arcade_background_visual == 3) { + stagePtr = func_80024860(ARCADE_OBJ_18_DK_75M); + } else if (arcade_background_visual == 4) { + stagePtr = func_80024860(ARCADE_OBJ_19_DK_50M); + } + //L8002CB6C + stagePtr->unk19 = 5; + if (arcade_background_visual != 4) { + stagePtr->unk18 = ARCADE_OBJ_18_DK_75M; + } + stagePtr->unk10 = 0.0f; + arcade_game_state = 3; + sp30->unk14 = &D_8003B180; + sp30->unk1A = 0; + + } else {//L8002CBB4 + if (sp30->unk19) + func_8002B390(arg0); + } + } + }//L8002CBC8 +} +#endif + +//arcade_barrel_update_sprite +void func_8002CBD8(s32 arg0) { + ArcadeStruct1 *v0 = D_8004BCD0 + arg0; + s32 v1 = v0->unk10; + + if (v0->unk19 == 5 + || v0->unk19 == 7 + || v0->unk19 == 1 + ) { //on ladder + if (v0->unk1D) { //blue barrel + switch(v1 & 1) { + case 0: + v0->unk14 = &D_80035AE0; + break; + case 1: + v0->unk14 = &D_80035CE8; + break; + } + } else { //red barrel + switch(v1 & 1) { + case 0: + v0->unk14 = &D_80035650; + break; + case 1: + v0->unk14 = &D_80035898; + break; + } + } + } else {// normal rolling + if (v0->unk1D) { + switch(v1 & 3) { //blue barrel + case 0: + v0->unk14 = &D_80035448; + break; + case 1: + v0->unk14 = &D_80035240; + break; + case 2: + v0->unk14 = &D_80035038; + break; + case 3: + v0->unk14 = &D_80034E30; + break; + } + } else { + switch(v1 & 3) { //red barrel + case 0: + v0->unk14 = &D_80034C28; + break; + case 1: + v0->unk14 = &D_80034A20; + break; + case 2: + v0->unk14 = &D_80034818; + break; + case 3: + v0->unk14 = &D_80034610; + break; + } + } + } +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002CD64.s") +#else + +extern f64 D_8004AAB8; +extern f64 D_8004AAC0; +extern f64 D_8004AAC8; +extern f64 D_8004AAD0; +extern f64 D_8004AAD8; +extern f32 D_8004AAE0; + +void func_8002CD64(s32 arg0) { + s32 sp3C; + s32 sp34; + f32 sp30; + ArcadeStruct1 *this; + f32 tmp_f12; + s32 flame_indx; + + + if (arcade_game_state != 0) + return; + + this = &D_8004BCD0[arg0]; + if (this->unk19 == 0 || this->unk19 == 1) { + func_8002CBD8(arg0); + } + else { + this->unk0 += this->unk8; + sp3C = func_8002A390( this->unk0, this->unk4); + func_8002AF2C( this->unk0, this->unk4); + switch(this->unk19) { + case 2: //L8002CE70 + this->unk8 = (f32)(1 - (this->unk1A << 1)); + this->unk10 += D_8004AA98; + if ((this->unk4 < D_8004C6E8) + && ( D_8004C6F8 + 1 < D_8004C6FC + || (D_8004C6FC == this->unk1C && D_8004C704 < 0x12) + || (D_8004BCD0[0].unk19 != 5)) + ) { + if (this->unk1C & 0x80) + break; + + this->unk1C &= 0xF; + if (this->unk1C & 0xFF > 0) { + this->unk1C--; + this->unk19 = 5; + this->unk4 += 1.0f; + this->unkC = 1.0f; + this->unk8 = 0.0f; + this->unk0 = D_8004C6E0; + } + else { + this->unk1C |= 0x80; + } + } + else {//L8002CFDC + if (!(this->unk1C & 0x47)) { + this->unk1C = 0x40 | (4096.0f + func_800246C8((f32)D_8004A76C, 5.0f) * 1512.0f > (f32)func_80024644()) ? TRUE : FALSE; + }//L8002D074 + if ((f32)sp3C - this->unk4 < 3.0f) { + this->unk4 = sp3C; + } + else { + this->unk19 = 3; + this->unkC = 0.0f; + this->unk8 = this->unk8/2; + } + } + break; + case 3: //L8002D0FC + this->unk10 += D_8004AAA0; + this->unk4 += this->unkC; + this->unkC += D_8004AAA8; + if (sp3C < this->unk4 + && this->unk4 - sp3C < 3.0f + ) { + this->unk4 = sp3C; + this->unkC = -this->unkC/3.0f; + if (D_8004AAB0 < this->unkC) + this->unk19 = 2; + }//L8002D1C8 + break; + case 5: //L8002D1E4 + this->unk10 += D_8004AAB8; + this->unk4 += this->unkC; + if (D_8004C6E8 < this->unk4) { + this->unk1A = (1 - this->unk1A); + this->unk19 = 2; + this->unk4 = sp3C; + this->unk8 = 1 - 2*this->unk1A; + }//L8002D28C + break; + case 7: //L8002D2A8 + this->unk10 += D_8004AAC0; + this->unk4 += this->unkC; + this->unkC += D_8004AAC8; + tmp_f12 = func_8002A390(this->unk0, this->unk4); + if (tmp_f12 < this->unk4 + && this->unk4 - tmp_f12 < 8.0f + && this->unk1C < D_8004C6F8 + ) { + this->unkC = 0.0f; + if (this->unk1D == 2) { + sp34 = func_80024644(); + this->unk8 = (func_800246C8(3.0f, D_8004A76C)*(sp34 - 0.0f))/D_8004AAD0 + (-this->unk8)*D_8004AAD8; + }//L8002D414 + if (230.0f < this->unk4) { + this->unk19 = 3; + this->unk1A = 1; + this->unk8 = -1.0f; + this->unkC = D_8004AAE0; + } + }//L8002D454 + break; + }//L8002D47C + if (!(D_8004BCD0[D_8004C71F].unk1C < D_8004C6F8) + || this->unk1D + ) { + if (270.0f < this->unk0) { + this->unk1A = 1; + this->unk8 = (1 - ((s8)this->unk1A) << 1); + } + else if (this->unk0 < 50.0f) { + this->unk1A = 0; + this->unk8 = (1 - ((s8)this->unk1A) << 1); + } + }//L8002D504 + if ((278.0f < this->unk0) || (this->unk0 < 2.0f)) { + this->unk18 = 0; + }//L8002D548 + if (( 242.0f < this->unk4) & ( this->unk0 < 74.0f)) { + if (this->unk1D) { + func_80737638(D_8076D1F8, SFX_42_ARCADE_JUMPMAN_HIT, 0x7fff, 0x3f, D_8004BCD0[D_8004C71F].unk0, 0, NULL); + flame_indx = func_80024860(ARCADE_OBJ_13_OIL_DRUM_FLAMES); + if (flame_indx < 0) + flame_indx = func_800246EC(); + D_8004BCD0[flame_indx] = arcade_oil_drum_flame_obj_template; + D_8004BCD0[flame_indx].unk19 = 3; + this->unk18 = 0; + }//L8002D668 + else { + this->unk18 = 0; + } + }//L8002D674 + if (this->unk0 - D_8004BCD0[D_8004C71F].unk0 < 8.0f + && D_8004BCD0[D_8004C71F].unk0 - this->unk0 < 8.0f + && this->unk4 - D_8004BCD0[D_8004C71F].unk4 < 3.0f + && D_8004BCD0[D_8004C71F].unk4 - this->unk4 < 3.0f + ) { + func_80027E8C(); + } + func_8002CBD8(arg0); + } +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002D6FC.s") + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002E158.s") +#else +extern u8 D_80037788[]; +extern u8 D_80037990[]; + +extern f64 D_8004AB10; +extern f64 D_8004AB18; +extern f32 D_8004AB20; + +void func_8002E158(s32 arg0) { + f32 tmp_f0; + + if (arcade_game_state != 0) + return; + + D_8004BCD0[arg0].unk0 += D_8004BCD0[arg0].unk8; + D_8004BCD0[arg0].unk10 += D_8004AB10; + switch((s32)D_8004BCD0[arg0].unk10 & 0x1) { + case 0: + D_8004BCD0[arg0].unk14 = &D_80037788; + break; + case 1: + D_8004BCD0[arg0].unk14 = &D_80037990; + break; + } + D_8004BCD0[arg0].unk4 += 5.0f; + if (D_8004BCD0[arg0].unkC < 5.0f) { + D_8004BCD0[arg0].unkC += D_8004AB18; + } + if (81.0f < D_8004BCD0[arg0].unk4) { + if (D_8004BCD0[arg0].unk0 < 220.0f) { + D_8004BCD0[arg0].unk4 = 81.0f; + D_8004BCD0[arg0].unkC = -3.5f; + if (40.0f < D_8004BCD0[arg0].unk0) { + func_80737638(D_8076D1F8, SFX_43_ARCADE_SPRING_SPRINGING, 0x7fff, 0x3f, 1.0f, 0, NULL); + }//L8002E2B4 + }//L8002E2C0 + else if (0.0f != D_8004BCD0[arg0].unk8) { + D_8004BCD0[arg0].unk8 = 0.0f; + func_80737638(D_8076D1F8, SFX_44_ARCADE_SPRING_FALL, 0x7fff, 0x3f, 1.0f, 0, NULL); + } + }//L8002E30C + if (D_8004AB20 < D_8004BCD0[arg0].unk4) { + D_8004BCD0[arg0].unk18 = 0; + } + if (__arcade_abs_w(D_8004BCD0[arg0].unk0 - D_8004BCD0[D_8004C71F].unk0) < 7) { + tmp_f0 = D_8004BCD0[arg0].unk4 - D_8004BCD0[D_8004C71F].unk4; + if (tmp_f0 < 4.0f && -8.0f < tmp_f0 ) { + func_80027E8C(); + } + } +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002E3D4.s") + +void arcade_pauline_top_update(s32 arg0) { + ArcadeStruct1 *pauline = & D_8004BCD0[arg0]; + s32 tmp_v1 = 2; + if (arcade_background_visual == tmp_v1) { + pauline->unk1A = (D_8004BCD0[D_8004C71F].x_position < 160.0f); + pauline->x_position = 152.0f; + if (D_8004C708 == tmp_v1) { + pauline->unk1A = 0; + pauline->y_position = 63.0f; + } + }//L8002E764 + if (!D_8004C721) { + pauline->unk14 = NULL; + return; + } + pauline->unk14 = &D_8003E438; +} + +void arcade_pauline_bottom_update(s32 arg0) { + ArcadeStruct1 *pauline = & D_8004BCD0[arg0]; + s32 tmp_v1 = 2; + if (arcade_background_visual == tmp_v1) { + pauline->unk1A = (D_8004BCD0[D_8004C71F].x_position < 160.0f); + pauline->x_position = 152.0f; + if (D_8004C708 == tmp_v1) { + pauline->unk1A = 0; + pauline->y_position = 79.0f; + } + }//L8002E818 + if (!D_8004C721) { + pauline->unk14 = NULL; + return; + } + if (pauline->unk14 == NULL) + pauline->unk14 = &D_8003DB18; + + if (arcade_game_state == 0) { + tmp_v1 = pauline->unk1C++ & 0xC8; + if (tmp_v1 || D_8004C724 == 1) { + pauline->unk14 = &D_8003DB18; + } + else { + pauline->unk14 = &D_8003DD60; + } + } +} + +void arcade_nintendo_coin_update(s32 arg0) { + D_8004BCD0[arg0].unk14 = &D_8003AE58; + if (D_8004C721) { + D_8004BCD0[arg0].y_position = D_8004BCD0[func_80024860(ARCADE_OBJ_1A_PAULINE_BOTTOM)].y_position - 8.0f; + D_8004BCD0[arg0].x_position = D_8004BCD0[func_80024860(ARCADE_OBJ_1A_PAULINE_BOTTOM)].x_position; + }//L8002E924 + else { + if (D_8004BCD0[arg0 - 1].unk14 == NULL) { + D_8004BCD0[arg0].unk14 = NULL; + } + D_8004BCD0[arg0].y_position = D_8004BCD0[arg0 - 1].y_position + 20.0f; + D_8004BCD0[arg0].x_position = D_8004BCD0[arg0 - 1].x_position + 30.0f; + } + D_8004BCD0[func_80024860(ARCADE_OBJ_1A_PAULINE_BOTTOM)].unk14 = NULL; + D_8004BCD0[func_80024860(ARCADE_OBJ_1B_PAULINE_TOP)].unk14 = NULL; + if (func_80024860(ARCADE_OBJ_1D_HELP_TEXT) >= 0) { + if ((u32) D_8004BCD0[func_80024860(ARCADE_OBJ_1D_HELP_TEXT)].unk14 != (u32)&D_800389D0) + { + D_8004BCD0[func_80024860(ARCADE_OBJ_1D_HELP_TEXT)].unk14 = NULL; + } + } +} + +void arcade_help_text_update(s32 arg0) { + s32 tmp_a3 = 2; + s32 tmp_v0 = 0x10; + + if (arcade_background_visual == tmp_a3) { + D_8004BCD0[arg0].x_position = 0x80 + 0x28 * (160.0f <= D_8004BCD0[D_8004C71F].x_position); + if (D_8004C708 == tmp_a3) { + D_8004BCD0[arg0].y_position = 63.0f; + D_8004BCD0[arg0].unk1A = 0; + } + }//L8002EA68 + + if (arcade_game_state == 3) { + if (D_8004C721 == 0) + D_8004BCD0[arg0].unk14 = &D_80038BD8; + else + D_8004BCD0[arg0].unk14 = &D_800389D0; + D_8004BCD0[arg0].unk1F = D_8004BCD0[arg0].unk1E = tmp_v0; + }//L8002EAC8 + else if (!D_8004C721) { + D_8004BCD0[arg0].unk14 = NULL; + } + else if (arcade_game_state == 0) { + if (!(D_8004BCD0[arg0].unk1C++ & 0xC0)) { + if (arcade_background_visual == tmp_a3 || arcade_background_visual == 4) + D_8004BCD0[arg0].unk14 = &D_8003E868; + else + D_8004BCD0[arg0].unk14 = &D_8003E680; + } + else { + D_8004BCD0[arg0].unk14 = NULL; + } + }//L8002EB38 +} + +void arcade_pulley_update(s32 arg0) { + if (arcade_game_state == 0) { + D_8004BCD0[arg0].unk1D += D_8004A308[D_8004BCD0[arg0].unk1C]; + if (D_8004BCD0[arg0].unk1D < 0) { + D_8004BCD0[arg0].unk1D += 0x2EE00; + } + switch ((D_8004BCD0[arg0].unk1D / 8) % 3) { + case 0: + D_8004BCD0[arg0].unk14 = &D_80037B98; + break; + case 1: + D_8004BCD0[arg0].unk14 = &D_80037DA0; + break; + case 2: + D_8004BCD0[arg0].unk14 = &D_80037FA8; + break; + default: + break; + } + } +} + +void arcade_dk_title_update(s32 arg0) { + s32 phi_v1; + + phi_v1 = D_8004C6DC; + if (phi_v1 == 0x3C) { + func_80737638(D_8076D1F8, SFX_46_ARCADE_INTRO, 0x7FFF, 0x3F, 1.0f, 0, 0); + phi_v1 = D_8004C6DC; + } + if (phi_v1 >= 0x3C) { + if (phi_v1 >= 0x169) { + D_8004BCD0[arg0].y_velocity += D_8004AB28; + //D_8004BCD0[arg0].unkC += 0.05; + D_8004BCD0[arg0].y_position += D_8004BCD0[arg0].y_velocity; + D_8004BCD0[arg0].x_position += D_8004BCD0[arg0].x_velocity; + if ((D_8004BCD0[arg0].y_velocity > 0.0f) && (D_8004BCD0[arg0].y_position >= 38.0f)) { + D_8004C721 = 1; + D_8004BCD0[arg0].y_position = 38.0f; + if (phi_v1 == 0x26C) { + func_80737638(D_8076D1F8, SFX_53_ARCADE_DK_GRUNT, 0x7FFF, 0x3F, 1.0f, 0, 0); + D_8004BCD0[arg0].unk14 = &D_80041508; + phi_v1 = D_8004C6DC; + } + if ((phi_v1 == 0x2D0) || (phi_v1 < 0x26C)) { + D_8004BCD0[arg0].unk14 = &D_80040540; + } + if (D_8004AB30 < D_8004BCD0[arg0].y_velocity) { + //if (0.06 < D_8004BCD0[arg0].unkC) { + D_8004C708 = (s32) (D_8004C708 + 1); + func_80737638(D_8076D1F8, SFX_42_ARCADE_JUMPMAN_HIT, 0x7FFF, 0x3F, 1.0f, 0, 0); + } + if ((D_8004BCD0[arg0].x_position > 74.0f) && !(D_8004C6DC < 0x1A5)) { + D_8004BCD0[arg0].x_velocity = -0.5f; + D_8004BCD0[arg0].y_velocity = D_8004AB38; + //D_8004BCD0[arg0].unkC = -0.81f; + } + else { + D_8004BCD0[arg0].x_velocity = 0.0f; + D_8004BCD0[arg0].y_velocity = 0.0f; + } + } + } else { + if (D_8004BCD0[arg0].y_position > 74.0f) { + D_8004BCD0[arg0].y_velocity = -2.0f; + D_8004BCD0[arg0].x_velocity = 0.0f; + D_8004BCD0[arg0].y_position = (f32) (0xC5 - ((s32) (phi_v1 - 0x3C) / 2)); + if ((phi_v1 & 8)) + D_8004BCD0[arg0].unk14 = &D_80044460; + else + D_8004BCD0[arg0].unk14 = &D_80045428; + } + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002EEB8.s") +/* +void func_8002EEB8(s32 arg0) { + ArcadeStruct1 *DK; + s32 sp28; + s32 sp24; + + DK = &D_8004BCD0[arg0]; + if (arcade_game_state == 0 || DK->unk19 == 5) { + switch(DK->unk19) { + case 12: //8002EF20 + DK->unk1C--; + if (DK->unk1C == 0) { + DK->unk1C = 0x14; + DK->unk19 = 9; + DK->unk14 = &D_8003E9F0; + DK->unk19 = 0; + DK->unk1D = func_800246EC(); + DK->unk10 += 1.0f; + + D_8004BCD0[DK->unk1D] = arcade_barrel_obj_template; + sp28 = DK->unk10; + if (!(sp28 & 7)) + D_8004BCD0[DK->unk1D].unk1D; + + if (sp28 == 2 && D_8004C723) + DK->unk1C = 2; + else if (sp28 == 1) { + if (!D_8004C723) + DK->unk1C = 2; + else + DK->unk1C = 5; + } + else if (sp28) { + if (!(func_80024644() < func_800246C8(D_8004A76C, 3.0f)*2000.0f + 2048.0f)) + break; + } + }//L8002F280 + else { + D_8004C71E--; + } + break; + case 9: //8002F29C + break; + case 11: //8002F338 + break; + case 10: //8002F45C + break; + case 5: //8002F668 + break; + } + }//L8002F81C +} +//*/ + +// big +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002F82C.s") + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_8002FE28.s") +#else +// TODO: Regalloc and some other minor stuff +void func_8002FE28(s32 arg0) { + if (arcade_game_state == 0) { + D_8004BCD0[arg0].unk10 += 1.0f; + if (((s8) D_8004BCD0[arg0].unk10 & 0xFF) < 0xA0) { + D_8004BCD0[arg0].unk14 = &D_80040540; + } else { + if (((s32) D_8004BCD0[arg0].unk10 & 0x1F) == 0) { + func_80737638(D_8076D1F8, SFX_42_ARCADE_JUMPMAN_HIT, 0x7FFF, 0x3F, 1.0f, 0, 0); + } + D_8004BCD0[arg0].unk14 = &D_800424D0; + D_8004BCD0[arg0].unk1A = ((((s32)D_8004BCD0[arg0].unk10 & 0x20) / 0x20) == 0); + } + if (((s32) D_8004BCD0[arg0].unk10 % (0x72 - ((s32) func_800246C8(D_8004A76C, 4.0f) * 0xC))) == 0) { + D_8004C71E--; + arg0 = func_800246EC(); + D_8004BCD0[arg0] = arcade_spring_obj_template; + D_8004BCD0[arg0].unk0 = ((func_80024644() & 0xF) - 0x1C); + D_8004BCD0[arg0].unk19 = 2; + } + } +} +#endif + +void arcade_dk_50m_update(s32 arg0) { + switch(D_8004BCD0[arg0].unk19) { + case 2://L8003007C + if (arcade_game_state != 0) + return; + + if ((D_8004C6DC % 0x78) == 0) { + D_8004C71E--; + } + + if (204.0f < D_8004BCD0[arg0].x_position) { + D_8004BCD0[arg0].x_velocity = -1.0; + } + + if (D_8004BCD0[arg0].x_position < 68.0f) { + D_8004BCD0[arg0].x_velocity = 1.0f; + } + + D_8004BCD0[arg0].unk10++; + if (((s32)D_8004BCD0[arg0].unk10 & 0xff) < 0xA0) { + D_8004BCD0[arg0].unk14 = &D_80040540; + } + else { + D_8004BCD0[arg0].unk14 = &D_800424D0; + D_8004BCD0[arg0].unk1A = !(((s32)D_8004BCD0[arg0].unk10 & 0x20)/0x20); + } + break; + case 5://L80030170 + if (100.0f < D_8004BCD0[arg0].x_position) { + D_8004BCD0[arg0].x_velocity = -1.0f; + } + else if (D_8004BCD0[arg0].x_position < 100.0f) { + D_8004BCD0[arg0].x_velocity = 1.0f; + } + else { + D_8004BCD0[arg0].x_velocity = 0.0f; + D_8004BCD0[arg0].unk18 = 0x16; + D_8004BCD0[arg0].unk10 = 41.0f; + } + break; + } + if ((D_8004C6DC & 1) == 0) { + D_8004A308[0] = D_8004BCD0[arg0].x_velocity; + D_8004BCD0[arg0].x_position += D_8004BCD0[arg0].x_velocity; + } +} + +void arcade_points_text_update(s32 arg0) { + s32 phi_v1; + + if (D_8004BCD0[arg0].unk10 == 0.0f) { + func_80737638(D_8076D1F8, SFX_45_ARCADE_POINTS, 0x7FFF, 0x3F, 1.0f, 0, 0); + } + phi_v1 = 0; + if (D_8004BCD0[arg0].unk10 > 40.0f) { + phi_v1 = 1; + } + D_8004BCD0[arg0].unk10++; + if (phi_v1) { + D_8004BCD0[arg0].unk18 = 0; + } +} + +void arcade_bonus_item_update(s32 arg0) { + if ((D_8004BCD0[arg0].x_position == (s32) D_8004BCD0[D_8004C71F].x_position) + && (D_8004BCD0[arg0].y_position == (s32) D_8004BCD0[D_8004C71F].y_position) + ) { + D_8004BCD0[arg0].unk18 = ARCADE_OBJ_14_POINTS_TEXT; + if (D_8004A76C == 1) { + D_8004BCD0[arg0].unk14 = &D_800383B8; + arcade_add_points_to_score(300); + return; + } + if (D_8004A76C == 2) { + D_8004BCD0[arg0].unk14 = &D_800385C0; + arcade_add_points_to_score(500); + return; + } + D_8004BCD0[arg0].unk14 = &D_800387C8; + arcade_add_points_to_score(800); + } +} + +void arcade_hammer_update(u8 arg0) { + ArcadeStruct1 *s2; + ArcadeStruct1 *v1; + u8 i; + + if (arcade_game_state != 0) + return; + s2 = &D_8004BCD0[arg0]; + switch(s2->unk19) { + case 0: //L80030418 + { + v1 = &D_8004BCD0[D_8004C71F]; + if (s2->x_position - v1->x_position < 8.0f && -8.0f < s2->x_position - v1->x_position ) { + if (s2->y_position - v1->y_position < 8.0f && -8.0f < s2->y_position - v1->y_position ) { + func_800252A4(SFX_49_ARCADE_HAMMER_MUSIC); + D_8004C710 = 0x258; + s2->unk19 = 2; + } + } + break; + } + case 2: //L800304B0 + { + v1 = &D_8004BCD0[D_8004C71F]; + s2->unk1A = v1->unk1A; + if ((D_8004C710 & 8) || v1->unk19 != 2) { + if (!(D_8004C710 < 0xf1) || D_8004C710 & 0x4) + s2->unk14 = &D_800393F8; + else + s2->unk14 = &D_80039888; + + s2->x_position = v1->x_position; + s2->y_position = v1->y_position - 16.0f; + } + else {//L80030538 + if (!(D_8004C710 < 0xf1) || D_8004C710 & 0x4) + s2->unk14 = &D_80039640; + else + s2->unk14 = &D_80039AD0; + + if (s2->unk1A) + s2->x_position = v1->x_position + 15.0f; + else + s2->x_position = v1->x_position - 15.0f; + + s2->y_position = v1->y_position; + } + for (i = 0; i < 0x50; i++) { + ArcadeStruct1 *iPtr; + ArcadeStruct1 *v1; + + iPtr = &D_8004BCD0[(u8)i]; + + if ((iPtr->unk18 == ARCADE_OBJ_01_BARREL) + || (iPtr->unk18 == ARCADE_OBJ_04_PIE) + || (iPtr->unk18 == ARCADE_OBJ_02_FLAME_ENEMY) + ) { + if (__arcade_abs_w((s32)(iPtr->x_position - s2->x_position)) < 0xD + && __arcade_abs_w((s32)(iPtr->y_position - s2->y_position)) < 0x8 + ) { + func_80737638(D_8076D1F8, SFX_4B_ARCADE_HAMMER_ATTACK, 0x7fff, 0x3f, 1.0f, 0, 0); + v1 = &D_8004BCD0[(u8)func_800247F0()]; + *v1 = arcade_bonus_item_obj_template; + v1->unk18 = ARCADE_OBJ_07_HAMMER_PARTICLES; + v1->unk1D = iPtr->unk18; + v1->x_position = s2->x_position; + v1->y_position = s2->y_position; + iPtr->unk18 = 0; + arcade_game_state = 1; + } + } + } + if (D_8004C710-- == 1) { + s2->unk18 = 0; //destroy hammer + func_800252A4(SFX_0_SILENCE); //play_sfx + func_80025240(); //queue_background_music + } + break; + } + }//L8003071C +} + +void func_80030734(u8 arg0) { + u8 temp_a0; + u8 temp_v0; + ArcadeStruct1 *temp_s0 = &D_8004BCD0[arg0]; + + if (temp_s0->unk1C >= 0x37) { + temp_s0->unk14 = &D_8003A3F0; + } else { + temp_a0 = temp_s0->unk1C / 6 % 3; + if (temp_a0 == 0) { + temp_s0->unk14 = &D_80039D18; + } else if (temp_a0 == 1) { + temp_s0->unk14 = &D_80039F60; + } else { + temp_s0->unk14 = &D_8003A1A8; + } + } + + + if (temp_s0->unk1C++ == 0x42) { + temp_s0->unk18 = ARCADE_OBJ_14_POINTS_TEXT; + temp_v0 = func_80024644() & 3; + + if ((temp_s0->unk1D == 2) && (temp_v0 == 0)) { + temp_s0->unk14 = &D_800387C8; + arcade_add_points_to_score(800); + } else if ((temp_s0->unk1D == 2) && (temp_v0 == 1)) { + temp_s0->unk14 = &D_800385C0; + arcade_add_points_to_score(500); + } else { + temp_s0->unk14 = &D_800383B8; + arcade_add_points_to_score(300); + } + temp_s0->unk10 = 0.0f; + arcade_game_state = 0; + } +} + +void arcade_rivet_update(u8 arg0) { + u8 temp_t6; + + if (D_8004BCD0[arg0].x_position == (s32) D_8004BCD0[D_8004C71F].x_position + && (D_8004BCD0[arg0].y_position - D_8004BCD0[D_8004C71F].y_position < 20.0f) + && (D_8004BCD0[arg0].y_position - D_8004BCD0[D_8004C71F].y_position > -2.0f) + ) { + D_8004BCD0[arg0].unk1D = 1; + } + else if (D_8004BCD0[arg0].unk1D) { + D_8004BCD0[arg0].unk18 = 0; + D_8004C718 = D_8004C718 ^ D_8004BCD0[arg0].unk1C; + if (D_8004C718) { + temp_t6 = func_800247F0(); + D_8004BCD0[temp_t6] = arcade_points_text_obj_template; + D_8004BCD0[temp_t6].x_position = D_8004BCD0[D_8004C71F].x_position; + D_8004BCD0[temp_t6].y_position = D_8004BCD0[D_8004C71F].y_position + 14.0f; + D_8004BCD0[temp_t6].unk10 = 0.0f; + + arcade_add_points_to_score(100); + } + } +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80030A04.s") +#else +void func_80030A04(u8 index) { + f32 phi_f0; + if (arcade_game_state == 0) { + D_8004BCD0[index].unk10--; + if (D_8004BCD0[index].unk10 < 0.0f) { + D_8004BCD0[index].unk10 = (f32)((func_80024644() & 0x7F) + 0x1C2); + } + if (D_8004BCD0[index].unk10 < 200.0f) { + phi_f0 = 0.2f; + } else { + phi_f0 = -0.2f; + } + D_8004BCD0[index].unk4 += phi_f0; + if (97.0f > D_8004BCD0[index].unk4) { + D_8004BCD0[index].unk4 = 97.0f; + } + if (110.0f < D_8004BCD0[index].unk4) { + D_8004BCD0[index].unk4 = 110.0f; + } + } +} +#endif + +void arcade_pie_update(u8 arg0) { + if (arcade_game_state == 0) { + D_8004BCD0[arg0].x_position += D_8004A308[D_8004BCD0[arg0].unk1C]; + if ((D_8004BCD0[arg0].x_position > 288.0f) + || (D_8004BCD0[arg0].x_position < 32.0f) + || ((D_8004BCD0[arg0].x_position == 160.0f) && (D_8004BCD0[arg0].y_position == 127.0f)) + ) { + D_8004BCD0[arg0].unk18 = 0; + } + if ((__arcade_abs_w(D_8004BCD0[arg0].x_position - D_8004BCD0[D_8004C71F].x_position) < 0xC) + && (D_8004BCD0[arg0].y_position - D_8004BCD0[D_8004C71F].y_position < 4.0f) + && (D_8004BCD0[arg0].y_position - D_8004BCD0[D_8004C71F].y_position > -8.0f) + ) { + func_80027E8C(); + } + } +} + + +void func_80030C70(u8 arg0) { + if (!(D_8004BCD0[func_80024860(0x17)].unk10 > 460.0f)) { + D_8004BCD0[arg0].unk1A = (D_8004BCD0[arg0].unk1C++ / 8) & 1; + } +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_80030CEC.s") +#else +void func_80030CEC(u8 arg0) { + u8 a0; + if (D_8004BCD0[arg0].unk19 == 4) + return; + if ((D_807ECDE8->unk0 & 0x200) || D_807ECDE8->unk2 < -0x14) { + D_8004C720--; + switch(D_8004C720) { + case 0://L80030D74 + D_8004C720 = 8; + case 0xb://L80030D80 + D_8004BCD0[arg0].unk1D--; + if (D_8004BCD0[arg0].unk1D >= 0x29) { + D_8004BCD0[arg0].unk1D = 0x1d; + } + break; + } + } else if ((D_807ECDE8->unk0 & 0x100) || D_807ECDE8->unk2 >= 0x15) {//L80030DB0 + D_8004C720--; + switch(D_8004C720) { + case 0://L80030D74 + D_8004C720 = 8; + case 0xb://L80030D80 + D_8004BCD0[arg0].unk1D++; + if (D_8004BCD0[arg0].unk1D >= 0x1e) { + D_8004BCD0[arg0].unk1D -= 0x1e; + } + break; + } + } else {//L80030E2C + D_8004C720 = 0xC; + }//L80030E40 + a0 = D_8004BCD0[arg0].unk1D; + D_8004BCD0[arg0].unk0 = (f32) (((a0 % 0x10) * 0x10) + 0x54); + D_8004BCD0[arg0].unk4 = (f32) (((s32) ((a0 / 0xA) << 7) / 7) + 0x4A); + if (newly_pressed_input & 0x8000) { + if ((a0 = 0x1D) || (D_8004C6DC == 0x708)) { + D_8004C6DC = 0x744; + D_8004BCD0[arg0].unk19 = 4; + arcade_saved_high_score_initials[D_8004BCD0[arg0].unk1C][0] = D_8004A774[0]; + arcade_saved_high_score_initials[D_8004BCD0[arg0].unk1C][1] = D_8004A774[1]; + arcade_saved_high_score_initials[D_8004BCD0[arg0].unk1C][2] = D_8004A774[2]; + func_80024320(); + } else if (a0 = 0x1C && D_8004BCD0[arg0].unk19) {//L80030F2C + D_8004BCD0[arg0].unk19--; + D_8004A774[D_8004BCD0[arg0].unk19] = D_80746800[0x1C]; + } else if (D_8004BCD0[arg0].unk19 < 3) {//L80030F70 + D_8004A774[D_8004BCD0[arg0].unk19] = D_80746800[D_8004BCD0[arg0].unk1D]; + D_8004BCD0[arg0].unk19++; + } + } +} +#endif + +void arcade_barrel_stack_update(u8 arg0) { + if (D_8004BCD0[arg0].unk1C >= D_8004C71E) + D_8004BCD0[arg0].unk18 = 0; +} + +//arcade update objects +void func_80030FEC(void) { + u8 i; + for (i = 0; i < 0x50; i++) { + switch(D_8004BCD0[i].unk18) { + case ARCADE_OBJ_01_BARREL: //80031030 + func_8002CD64(i); + break; + case ARCADE_OBJ_02_FLAME_ENEMY: //80031040 + func_8002D6FC(i); + break; + case ARCADE_OBJ_03_SPRING: //80031050 + func_8002E158(i); + break; + case ARCADE_OBJ_13_OIL_DRUM_FLAMES: //80031060 + func_8002E3D4(i); + break; + case ARCADE_OBJ_0D_JUMPMAN://80031070 + func_8002B89C(i); + break; + case ARCADE_OBJ_1A_PAULINE_BOTTOM://80031080 + arcade_pauline_bottom_update(i); + break; + case ARCADE_OBJ_1E_NINTENDO_COIN://80031090 + arcade_nintendo_coin_update(i); + break; + case ARCADE_OBJ_1D_HELP_TEXT://800310A0 + arcade_help_text_update(i); + break; + case ARCADE_OBJ_1B_PAULINE_TOP://800310B0 + arcade_pauline_top_update(i); + break; + case ARCADE_OBJ_12_PULLEY://800310C0 + arcade_pulley_update(i); + break; + case ARCADE_OBJ_15_DK_TITLE://800310D0 + arcade_dk_title_update(i); + break; + case ARCADE_OBJ_16_DK_25M://800310E0 + func_8002EEB8(i); + break; + case ARCADE_OBJ_17_DK_100M://800310F0 + func_8002F82C(i); + break; + case ARCADE_OBJ_18_DK_75M://80031100 + func_8002FE28(i); + break; + case ARCADE_OBJ_19_DK_50M://80031110 + arcade_dk_50m_update(i); + break; + case ARCADE_OBJ_14_POINTS_TEXT://80031120 + arcade_points_text_update(i); + break; + case ARCADE_OBJ_05_BONUS_ITEM://80031130 + arcade_bonus_item_update(i); + break; + case ARCADE_OBJ_06_HAMMER://80031140 + arcade_hammer_update(i); + break; + case ARCADE_OBJ_07_HAMMER_PARTICLES://80031150 + func_80030734(i); + break; + case ARCADE_OBJ_0B_RIVET://80031160 + arcade_rivet_update(i); + break; + case ARCADE_OBJ_0C_MOVING_LADDER://80031170 + func_80030A04(i); + break; + case ARCADE_OBJ_09_NAME_SELECT_CURSOR: //80031180 + func_80030CEC(i); + break; + case ARCADE_OBJ_04_PIE: //80031190 + arcade_pie_update(i); + break; + case ARCADE_OBJ_0F_100M_COMPLETE_PARTICLE: //800311A0 + func_80030C70(i); + break; + case ARCADE_OBJ_0A_BARREL_STACK: //800311B0 + arcade_barrel_stack_update(i); + break; + default: + break; + } + } +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_800311E0.s") +#else +void func_800311E0(void) { + u8 sp1F; + u8 i; + + if (!(D_8004C6DC & 1)) { + D_8004A308[1] = 1; + D_8004A308[2] = -1; + if ((D_8004C6DC/0x15e) & 1) { + D_8004A308[3] = 1; + } else { + D_8004A308[3] = -1; + } + } else {//L80031238 + for (i = 0; i < 4; i++) {\ + D_8004A308[i] = 0; + } + } + + if (D_8004C6DC%0x78 == 0 && arcade_get_object_type_count(ARCADE_OBJ_04_PIE) < 5) { + sp1F = func_80024764(); + D_8004BCD0[sp1F] = arcade_pie_obj_template; + if (func_80024644() >= 0x4001) { + if ((D_8004C6DC/ 350) & 1) + D_8004BCD0[sp1F].unk0 = 40.0f; + else + D_8004BCD0[sp1F].unk0 = 280.0f; + } else {//L80031354 + D_8004BCD0[sp1F].unk4 = 127.0f; + if (func_80024644() >= 0x4001) { + D_8004BCD0[sp1F].unk1C = 1; + D_8004BCD0[sp1F].unk0 = 40.0f; + } else { + D_8004BCD0[sp1F].unk1C = 2; + D_8004BCD0[sp1F].unk0 = 40.0f; + } + } + }//L800313AC +} +#endif + +void func_800313B8(void) { + u8 sp1f; + u8 temp_v1; + s32 t3 = 1; + + if (D_8004C6DC % 0xC8 == 0 + && arcade_get_object_type_count(ARCADE_OBJ_02_FLAME_ENEMY) < 5 + ) { + sp1f = func_80024764(); + D_8004BCD0[sp1f] = arcade_flame_enemy_obj_template; + D_8004BCD0[sp1f].unk1A = 0; + D_8004BCD0[sp1f].x_velocity = -0.5f; + D_8004BCD0[sp1f].x_position = 244.0f; + temp_v1 = func_80024644() & 0x7; + if (temp_v1 >= 4) { + temp_v1 = 1; + } + D_8004BCD0[sp1f].x_position = D_8004A318[2*temp_v1]; + D_8004BCD0[sp1f].y_position = D_8004A318[2*temp_v1 + 1]; + if (160.0f < D_8004BCD0[D_8004C71F].x_position) { + D_8004BCD0[sp1f].unk1A = 1 - D_8004BCD0[sp1f].unk1A; + D_8004BCD0[sp1f].x_velocity = -D_8004BCD0[sp1f].x_velocity; + D_8004BCD0[sp1f].x_position = 320.0f - D_8004BCD0[sp1f].x_position; + } + }//L80031534 + if (!D_8004C718) { + func_800252A4(SFX_0_SILENCE); + D_8004C718 = 1; + D_8004C708 = t3; + arcade_game_state = 2; + D_8004BCD0[func_80024860(ARCADE_OBJ_17_DK_100M)].unk19 = 8; + } +} + +void func_8003159C(Gfx **arg0) { + u8 padA4; + Gfx *spA0; + char sp50[0x50]; + int i; + + spA0 = *arg0; + if (D_8004C724 == 3) { + func_800244E4(0x00, 0xff, 0xff, 0xff); + func_80024508(0x78, 0x3b); + func_800031E0(sp50, &D_8004A840, &D_8004A774); + //func_800031E0(sp50, "NAME %.3s", &D_8004A774); + func_8002451C(&spA0, sp50); + func_80024508(0xA0, 0x41); + func_800031E0(sp50, &D_8004A84C); + //func_800031E0(sp50, "---"); + func_8002451C(&spA0, sp50); + if (D_8004C6DC < 1800) { + func_80024508(0x60, 0x7b); + func_800031E0(sp50, &D_8004A850, 30 - D_8004C6DC/60); + //func_800031E0(sp50, "REGI TIME <%02d>", 30 - D_8004C6DC/60); + } else {//L800316A0 + func_80024508(0x40, 0x7b); + func_800031E0(sp50, &D_8004A864); + //func_800031E0(sp50, "YOUR NAME WAS"); + func_8002451C(&spA0, sp50); + + func_80024508(0xb0, 0x7b); + func_800031E0(sp50, &D_8004A874); + //func_800031E0(sp50, "REGISTERED."); + + }//L800316E8 + func_8002451C(&spA0, sp50); + func_800244E4(0xff, 0x00, 0x00, 0xff); + func_80024508(0x58, 0x2b); + func_800031E0(sp50, &D_8004A880); + //func_800031E0(sp50, "NAME REGISTRATION"); + func_8002451C(&spA0, sp50); + + func_800244E4(0x00, 0xff, 0x00, 0xff); + func_80024508(0x58, 0x4b); + func_800031E0(sp50, &D_8004A894); + //func_800031E0(sp50, "A B C D E F G H I J"); + func_8002451C(&spA0, sp50); + + func_80024508(0x58, 0x5b); + func_800031E0(sp50, &D_8004A8A8); + //func_800031E0(sp50, "K L M N O P Q R S T"); + func_8002451C(&spA0, sp50); + + func_80024508(0x58, 0x6b); + func_800031E0(sp50, &D_8004A8BC); + //func_800031E0(sp50, "U V W X Y Z . -"); + func_8002451C(&spA0, sp50); + + func_80024508(0xd4, 0x6b); + func_800031E0(sp50, &D_8004A8CC); + //func_800031E0(sp50, "ba"); + func_8002451C(&spA0, sp50); + }//L800317E0 + + func_800244E4(0xFF, 0x00, 0x00, 0xff); + for (i = 0; i < 5; i++) { + if (i == 3) + func_800244E4(0xFF, 0xFF, 0x00, 0xff); + func_80024508(0x38, 0x8b + i*0x10); + if (i == D_8004BCD0[0].unk1C + && D_8004C6DC & 0x20 + && D_8004C724 == 3 + ) { + func_800031E0(sp50, &D_8004A8D0, &D_8004A82C[i]); + } else {//L80031888 + func_800031E0(sp50, &D_8004A8D8, D_8004A82C[i], arcade_saved_high_scores[i], arcade_saved_high_score_initials[i]); + }//L800318B8 + func_8002451C(&spA0, sp50); + } + + func_800244E4(0x00, 0xff, 0x00, 0xff); + func_80024508(0xb8, 0xdb); + func_800031E0(sp50, &D_8004A8EC); + func_8002451C(&spA0, sp50); + + *arg0 = spA0; +} + +void func_80031948(s8 arg0) { + if (arg0 == D_8004A768) { + func_800244E4(0xff, 0xff, 0xff, 0xff); + } else if (arcade_background_visual == 2) { + func_800244E4(0xff, 0xa0, 0x10, 0xff); + } else { + func_800244E4(0, 0xff, 0xff, 0xff); + } +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/arcade/code_0/func_800319D4.s") +#else +void func_800319D4(Gfx **arg0) { + int i; + Gfx *sp90; + char sp40[0x50]; + s32 score; + u8 sp3B; + + sp90 = *arg0; + gDPSetScissor(sp90++, G_SC_NON_INTERLACE, 0, 0, 320, 240); + D_8004C6D4 = 0x400; + D_8004C719 = 8; + D_8004C6D0 = &D_8003DA90; + D_8004C71A = 8; + guSprite2DInit(&D_8004BBF0[D_807444FC], D_8004C6D0, 0, + D_8004C719, D_8004C719, D_8004C71A, + G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0 + ); + func_8070E8F0(&sp90, &D_8004BBF0[D_807444FC]); + func_8070F2C8(0x400, D_8004C6D6, 0, 0); + for (i = 0; i < arcade_lives_visual; i++) { + func_8070F2FC(&sp90, (s16)(0x360 + i * 0x20), 0x4C, i); + } + func_800244E4(0xff, 0, 00, 0xff); + if ((D_8004C6D8 & 0x10) || !D_8004C724) { + func_80024508(0x48, 0x13); + func_800031E0(sp40, "1UP"); + func_8002451C(&sp90, sp40); + }//L80031B78 + + func_80024508(0x78, 0x13); + func_800031E0(sp40, "HIGH SCORE"); + func_8002451C(&sp90, sp40); + + func_800244E4(0, 0, 0xff, 0xff); + func_80024508(0xd8, 0x1b); + func_800031E0(sp40, "L=%02d", D_8004A76C); + func_8002451C(&sp90, sp40); + + func_800244E4(0xff, 0xff, 0xff, 0xff); + func_80024508(0x38, 0x1b); + func_800031E0(sp40, "%06d %06d", arcade_current_score, D_8004A760); + func_8002451C(&sp90, sp40); + + if (D_8004C724 == 5 || D_8004C724 == 4) {//L80031C50 + if (D_8004A764) { + if (arcade_background_visual == 2) { + func_800244E4(0xff, 0xa0, 0x10, 0xff); + } else if (arcade_background_visual == 4) {//L80031C8C + func_800244E4(0xff, 0xff, 0xff, 0xff); + } else { + func_800244E4(0, 0xff, 0xff, 0xff); + } //L80031CC4 + func_80024508(0x78, 0xa3); + func_800031E0(sp40, "GAME OVER"); + func_8002451C(&sp90, sp40); + }//L80031CF4 + if (D_8004C724 == 4) { + if (!D_8004A768 || arcade_background_visual == 4) { + func_800244E4(0xff, 0xff, 0xff, 0xff); + } else if (arcade_background_visual == 2) { + func_800244E4(0xff, 0xa0, 0x10, 0xff); + } else { + func_800244E4(0, 0xff, 0xff, 0xff); + }//L80031D64 + func_80031948(0); + func_80024508(0x88, 0x8b); + func_800031E0(sp40, "RETURN"); + func_8002451C(&sp90, sp40); + + func_80031948(1); + func_80024508(0x68, 0x9b); + func_800031E0(sp40, "DELETE HISCORE"); + func_8002451C(&sp90, sp40); + + func_80031948(2); + func_80024508(0x68, 0xab); + func_800031E0(sp40, "EXIT DK ARCADE"); + func_8002451C(&sp90, sp40); + }//L80031DF8 + if (arcade_background_visual == 2) { + if (D_8004C71E < 0xA) { + func_800244E4(0, 0, 0xff, 0xff); + } else { + func_800244E4(0xff, 0xa0, 0x10, 0xff); + } + } else if (arcade_background_visual == 4) {//L80031E54 + if (D_8004C71E < 0xA) { + func_800244E4(0xf0, 0x30, 0, 0xff); + } else { + func_800244E4(0xff, 0xff, 0xff, 0xff); + } + } else { + if (D_8004C71E < 0xA) { + func_800244E4(0xff, 0, 0, 0xff); + } else { + func_800244E4(0x60, 0xe0, 0xff, 0xff); + } + }//L80031EE4 + func_80024508(0xe0, 0x30); + score = MAX(D_8004C71E, 0); + func_800031E0(sp40, "%02d00", score, score); + func_8002451C(&sp90, sp40); + + }//L80031F30 + if (D_8004C724 == 2) { + sp3B = (D_8004C723 & 3) + 1; + func_800244E4(0xff, 0xff, 0xff, 0xff); + func_80024508(0x48, 0xd7); + func_800031E0(sp40, "HOW HIGH CAN YOU GET ?"); + func_8002451C(&sp90, sp40); + func_80024508(0x58, 0xc9); + func_800031E0(sp40, "@%%m"); + func_8002451C(&sp90, sp40); + //sp34 = sp3B; + if (sp3B >= 2) { + func_80024508(0x58, 0xad); + func_800031E0(sp40, "%%)m"); + func_8002451C(&sp90, sp40); + } + if (sp3B >= 3) { + func_80024508(0x58, 0x91); + func_800031E0(sp40, "&%%m"); + func_8002451C(&sp90, sp40); + } + if (sp3B >= 4) { + func_80024508(0x50, 0x75); + func_800031E0(sp40, "!))m"); + func_8002451C(&sp90, sp40); + } + }//L80032054 + if (D_8004C724 == 3) { + func_8003159C(&sp90); + }//L80032078 + if (D_8004C724 == 0) { + if (!(D_8004C6DC & 0x200)) { + func_800244E4(0, 0xff, 0xff, 0xff); + func_80024508(0x70, 0x33); + func_800031E0(sp40, "INSERT COIN"); + func_8002451C(&sp90, sp40); + + func_80024508(0x68, 0x43); + func_800031E0(sp40, "PLAYER COIN"); + func_8002451C(&sp90, sp40); + + func_80024508(0x78, 0x53); + func_800031E0(sp40, "1 1"); + func_8002451C(&sp90, sp40); + + func_80024508(0x38, 0x7b); + func_800031E0(sp40, "RANK SCORE NAME"); + func_8002451C(&sp90, sp40); + func_8003159C(&sp90); + func_800244E4(0xff, 0, 0, 0xff); + + func_80024508(0x78, 0x63); + func_800031E0(sp40, "2 2"); + func_8002451C(&sp90, sp40); + } else {//L80032190 + if (D_8004C6DC & 0x182) { + func_800244E4(0xff, 0xa0, 0x10, 0xff); + } else { + func_800244E4(0xff, 0xff, 0xff, 0xff); + } + func_80024508(0x68, 0xd7); + func_800031E0(sp40, "c NINTENDO 1981"); + func_8002451C(&sp90, sp40); + } + }//L800321EC + *arg0 = sp90; + D_8004A83C++; +} +#endif diff --git a/src/bonus/code_0.c b/src/bonus/code_0.c new file mode 100644 index 00000000..235cbb2d --- /dev/null +++ b/src/bonus/code_0.c @@ -0,0 +1,29 @@ +#include +#include "functions.h" +#include "variables.h" + + +//display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_0/func_80024000.s") + +void func_800240F0() { + func_8072707C(1, 0x40, 0); + func_8072707C(2, 0x40, 0); + func_8072707C(3, 0x40, 0); + func_8072707C(4, 0x40, 0); + func_8072707C(5, 0x40, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_0/func_80024158.s") + +//display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_0/func_80024D3C.s") + +extern void (*D_8002DB2C[])(); + +// Jumptable ^ +// Very sus, returns with no labels on a switch case +// Polymorphic code? +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_0/func_80024D8C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_0/func_80024E38.s") diff --git a/src/bonus/code_12A0.c b/src/bonus/code_12A0.c new file mode 100644 index 00000000..786e316a --- /dev/null +++ b/src/bonus/code_12A0.c @@ -0,0 +1,70 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_12A0/func_800252A0.s") + +s32 func_80677FA8(s32, s32); // spawnActorWrapper() +void func_80627948(Actor*, s32, s32, s32); +void func_8069D2AC(s32,s32,u8, s32, s32, s32, s32, s32); +u8 func_8070E750(u8, s32, s32); +void func_8061C464(s32, Actor*, s32, s32, s32, s32, s32, s32, s32, s32, f32); + +extern f32 D_8002DCB8; + +Actor* func_800253E4(s32 arg0, s16 arg1, s16 arg2, s16 arg3) { + BaaD2 *tmp; + if (func_80677FA8(0xDB, arg0)) { // Spawn actor 219 (slot, BBB I guess?) + tmp = D_807FBB44->BaaD2; + D_807FBB44->x_position = arg1; + D_807FBB44->y_position = arg2; + D_807FBB44->z_position = arg3; + tmp->unk0 = current_actor_pointer; + } + return D_807FBB44; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_12A0/func_80025480.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_12A0/func_800254B0.s") + +void func_8002563C(s32 arg0) { + PlayerAdditionalActorData *PaaD = player_pointer->PaaD; + func_8061C464(PaaD->unk104, player_pointer, 4, 0, 0xAA, 0, 0, 0, 0, 0, D_8002DCB8); + current_actor_pointer->control_state = 3; + current_actor_pointer->control_state_progress = 1; + current_actor_pointer->unk168 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_12A0/func_800256C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_12A0/func_8002570C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_12A0/func_800261B8.s") + +void func_800264E0(u8 arg0, u8 arg1) { + playSound(0x143, 0x7FFF, 63.0f, 1.0f, 0, 0); + func_8069D2AC(0x81, 0, 0x78, func_8070E750(0x1A, arg1, 1), 0, 0x28, 8, 8); + current_actor_pointer->unk11C->control_state = 0; + playSong(0x28, 1.0f); + func_806EB0C0(0x44, NULL, 0); + current_actor_pointer->control_state++; + if (arg0 != 0) { + func_80627948(player_pointer, 5, 0x21, 5); + } +} + +void func_800265C0(u8 arg0, u8 arg1) { + u8 temp; + + current_actor_pointer->unk11C->control_state = 0; + temp = (u8) arg1; + func_8069D2AC(0x81, 0, 0x78, func_8070E750(0x1A, temp, 1), 0, 0x28, 8, 8); + playSong(0x57, 1.0f); + func_806EB0C0(0x43, NULL, 0); + current_actor_pointer->control_state++; + if (arg0 != 0) { + func_80627948(player_pointer, 5, 0x21, 5); + } +} diff --git a/src/bonus/code_2690.c b/src/bonus/code_2690.c new file mode 100644 index 00000000..b1036218 --- /dev/null +++ b/src/bonus/code_2690.c @@ -0,0 +1,140 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80026690.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80026940.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80026CF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_800271B4.s") + +typedef struct bonus_struct_0 { + u8 pad0[0x9]; + u8 unk9; +} BonusStruct0; + +void func_80027308(BonusStruct0 *arg0, s32 *arg1) { + *(arg1 + (arg0->unk9)) = 0; + func_806782C0(current_actor_pointer); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002733C.s") + +void func_806907F0(f32, f32, f32); +void func_80690A28(s32, s32, f32, f32, f32, f32, f32, Actor *); +extern f32 D_8002DD28; + +void func_800274A0(f32 arg0, f32 arg1, f32 arg2) { + Actor *temp_v0; + + playSound(0x59, 0x7FFF, 63.0f, 1.0f, 0x1E, 0); + temp_v0 = current_actor_pointer; + func_806907F0(temp_v0->x_position, temp_v0->y_position - 10.0f, temp_v0->z_position); + func_80690A28(0x23, 1, 0.6f, arg0, arg1, arg2, D_8002DD28, current_actor_pointer); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80027548.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_800277F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80027F14.s") + +// Baad2 Use? +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_800284C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80028648.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002881C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80028E3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80029364.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80029B9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_80029E54.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002A010.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002A398.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002AAA4.s") + +// AnimationState, aaD +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002AD10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002AED8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002B920.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002BE44.s") + +/* +// TODO: what a mess +void func_80613C48(Actor*, s16, f32, f32); +void func_80614644(Actor *, ActorAnimationState *, s32); +void func_806319C4(Actor *, s32); +extern f32 D_8002DE50; +extern f64 D_8002DE58; +typedef struct BonusStruct1 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s16 unk10; +} BonusStruct1; + +typedef struct bonus_additional_actor_data { + s32 unk0; + BonusStruct1* unk4; + s32 unk8; + s32 unkC; + s32 unk10; + u8 pad0[0x7C - 0x14]; + f32 x_position; + f32 y_position; + f32 z_position; +} BonusAdditionalActorData; + +void func_8002BE44() { + ActorAnimationState *sp24; + BonusAdditionalActorData *temp_a0; + BonusStruct1 *temp_t8; + s16 phi_a1; + + temp_a0 = ((BonusAdditionalActorData*)current_actor_pointer->additional_data_pointer); + sp24 = current_actor_pointer->animation_state; + temp_t8 = temp_a0->unk4; + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + current_actor_pointer->z_rotation = 0; + current_actor_pointer->y_rotation = 0x800; + func_80613C48(temp_a0, 0x5FB, 0, 0); + current_actor_pointer->animation_state->scale_x =// D_8002DE50; + current_actor_pointer->animation_state->scale_z =// D_8002DE50; + current_actor_pointer->animation_state->scale_y = D_8002DE50; + } + current_actor_pointer->x_position = temp_a0->x_position; + current_actor_pointer->y_position = temp_a0->y_position - D_8002DE58; + current_actor_pointer->z_position = temp_a0->z_position; + if (sp24 && temp_t8) { + phi_a1 = temp_t8->unk10; + if (phi_a1 == 0x5FD) { + phi_a1 = 0x5FE; + } + if (phi_a1 != sp24->unk10) { + func_80613C48(current_actor_pointer, phi_a1, 0, 0); + } + func_80614644(current_actor_pointer, sp24, temp_t8->unk4); + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002BF98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002C8EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_2690/func_8002CC08.s") diff --git a/src/bonus/code_9010.c b/src/bonus/code_9010.c new file mode 100644 index 00000000..ab696e0e --- /dev/null +++ b/src/bonus/code_9010.c @@ -0,0 +1,26 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s8 D_8002D92C; +extern s8 D_8002D930; +extern s8 D_8002DEF0[]; + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_9010/func_8002D010.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_9010/func_8002D2F0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/bonus/code_9010/func_8002D6F8.s") + +void func_8002D7E8(s16 arg0) { + s8 phi_v0 = arg0 == 0xD4 ? 0xA : 2; + + if (D_8002D92C < 6) { + D_8002DEF0[D_8002D92C] = phi_v0; + D_8002D92C++; + D_8002D930 = 0x14; + } + if (D_8002D92C >= 5) { + D_8002D930 = 0; + } +} diff --git a/src/boss/code_0.c b/src/boss/code_0.c new file mode 100644 index 00000000..515636fc --- /dev/null +++ b/src/boss/code_0.c @@ -0,0 +1,146 @@ +#include +#include "functions.h" +#include "variables.h" + + +void func_80614D00(Actor*, f32, f32); +s32 func_806CC10C(s16, s16); +void func_8072AB74(s32, f32, f32, s32, f32); +s32 func_80024568(s32, s32, f32, f32, f32); +void func_8002450C(s32, s32, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80024000.s") + +// Flag check, animation state, unrolled loops +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_8002413C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80024300.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_8002450C.s") + +// Actor->animation_state->unk1C struct array pointer? +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80024524.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80024568.s") + +void func_80024EAC(void) { + s32 temp_v0_2; + u16 sp2A; + + sp2A = current_actor_pointer->animation_state->unk64; + func_806CC10C(D_807FDC90->unk8, current_actor_pointer->y_rotation); + func_8072AB74(0x45, D_807FDC94->x_position, D_807FDC94->z_position, 0x16, 0.0f); + temp_v0_2 = func_806CC10C(D_807FDC90->unk8, current_actor_pointer->y_rotation); + if (temp_v0_2 > 0) { + if (sp2A != 0x260) { + func_80614EBC(current_actor_pointer, 0x260); + } + } else if (temp_v0_2 < 0) { + if (sp2A != 0x25F) { + func_80614EBC(current_actor_pointer, 0x25F); + } + } else if (sp2A != 0x25A) { + func_80614EBC(current_actor_pointer, 0x25A); + func_80614D00(current_actor_pointer, 1.0f, 0.0f); + } +} + +void func_80024FA8(s32 arg0, s32 arg1, s32 arg2, u8 *arg3) { + u8 i = 0; + u8 phi_v0_2 = 0; + + switch (current_actor_pointer->control_state_progress) { + case 2: + while (arg3[i] != 0xFF) { + func_8002450C(arg1, arg3[i++] & 0xFF, 1); + } + current_actor_pointer->control_state_progress = 3; + return; + case 3: + while (arg3[i] != 0xFF) { + if ((current_actor_pointer->control_state == 0x27) || (current_actor_pointer->control_state == 0x2E)) { + phi_v0_2 = func_80024568(arg1, arg3[i++] & 0xFF, 50.0f, 70.0f, 90.0f); + } else { + phi_v0_2 = func_80024568(arg1, arg3[i++] & 0xFF, 10.0f, 15.0f, 50.0f); + } + } + if (phi_v0_2 != 0) { + current_actor_pointer->control_state_progress = 4; + func_8068842C(current_actor_pointer, 1, 1); + } + return; + } +} + +void func_800251A0(s32 arg0, s32 arg1, s32 arg2, u8 *arg3) { + u8 i = 0; + s32 phi_v1 = 0; + + switch (current_actor_pointer->control_state_progress) { + case 2: + while (arg3[i] != 0xFF) { + func_8002450C(arg1, arg3[i++] & 0xFF, 3); + } + current_actor_pointer->control_state_progress = 3; + break; + case 3: + while (arg3[i] != 0xFF) { + phi_v1 = func_80024568(arg1, arg3[i++] & 0xFF, 10.0f, 20.0f, 30.0f) & 0xFF; + } + if (phi_v1 != 0) { + current_actor_pointer->control_state_progress = 4; + func_8068842C(current_actor_pointer, 1, 1); + } + break; + } +} + +void func_8002531C(void) { + func_8066EA90(current_actor_pointer, 3); + func_8066EA90(current_actor_pointer, 4); + func_8066EA90(current_actor_pointer, 5); +} + +void func_80025364(void) { + func_8066EA64(current_actor_pointer, 3); + func_8066EA64(current_actor_pointer, 4); + func_8066EA64(current_actor_pointer, 5); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_800253AC.s") + +extern f64 D_80035D50; +extern f64 D_80035D58; +extern f64 D_80035D60; +extern void *D_8071AF30; +extern void *D_80720120; + +void func_80714C08(void*, f32, Actor*, s32, s32); + +/* +// Doable, just need the energy +void func_800253AC(void) { + void *temp; + f64 phi_f2; + + phi_f2 = MAX(current_actor_pointer->y_velocity, 0.0); + func_807149B8(1); + func_8071498C(&D_8071AF30); + func_807149A8(1000); + func_80714950(current_actor_pointer); + phi_f2 /= D_80035D50; + phi_f2 *= D_80035D58; + phi_f2 += D_80035D60; + phi_f2 *= 4.0f; + func_80714C08(&D_80720120, phi_f2, current_actor_pointer, 3, 0); + func_807149B8(1); + func_8071498C(&D_8071AF30); + func_807149A8(1000); + func_80714950(current_actor_pointer); + func_80714C08(&D_80720120, phi_f2, current_actor_pointer, 4, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_800254D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80027770.s") diff --git a/src/boss/code_3840.c b/src/boss/code_3840.c new file mode 100644 index 00000000..192e1789 --- /dev/null +++ b/src/boss/code_3840.c @@ -0,0 +1,128 @@ +#include +#include "functions.h" +#include "variables.h" + +// malloc, needs struct definitions +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_80027840.s") + +typedef struct BossStruct2 { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} BossStruct2; + +void func_800278F4(BossStruct2 *arg0, f32 arg1, s16 arg2, s16 arg3) { + arg0->unkC += ((arg2 - arg0->unkC) * arg1); + arg0->unk8 += ((arg3 - arg0->unk8) * arg1); +} + +// Loop, needs some more struct definitions I think +// Looks doable though +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_80027950.s") + +// Loop, needs some more struct definitions I think +// Looks doable though +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_80027A30.s") + +// Jumptable, 2224 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_80027BA8.s") + +void func_80028458() { + func_805FF8F8(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_80028478.s") + +extern f32 D_80036050; +extern s32 D_8074E880[]; +extern void func_8071CDE0(); + +void func_806A5DF0(s32, f32, f32, f32, s32, s32, s16, s32); + +/* +// TODO: Very close, might need .rodata defined for D_80036050 +void func_80028478(s32 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, u8 arg5) { + s16 i; + + playSong(0x36, 1.0f); + if (isFlagSet(arg0, FLAG_TYPE_PERMANENT)) { + func_80028458(); + return; + } + + for (i = 0; i < 6; i++) { + func_8071498C(&func_8071CDE0); + func_807149FC(-1); + func_807149B8(1); + func_80714950(D_807FDC94); + func_80714CC0(D_8074E880[((rand() >> 0xF) % 1000) % 3], D_80036050, D_807FDC94->x_position, D_807FDC94->y_position + D_807FDC94->unk15E, D_807FDC94->z_position); + } + func_806A5DF0(0x48, arg1, arg2, arg3, arg4, arg5, arg0, 0); +} +*/ + +void func_80028680() { + func_806A2A10(-0x7F83, 0xD2, 0xB4); + func_806A2B08(current_actor_pointer->unk11C); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_800286B8.s") + +void func_80028818() { + +} + +void func_80028820() { + // K. Rool Tiny Phase Toes Complete + setFlag(0x51, FALSE, FLAG_TYPE_TEMPORARY); + setFlag(0x52, FALSE, FLAG_TYPE_TEMPORARY); + setFlag(0x53, FALSE, FLAG_TYPE_TEMPORARY); + setFlag(0x54, FALSE, FLAG_TYPE_TEMPORARY); +} + +// Jumptable, 2140 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_3840/func_80028878.s") + +void func_800290D4(u8 arg0) { + if (arg0) { + func_8066EA64(current_actor_pointer, 2); + func_8066EA64(current_actor_pointer, 3); + } else { + func_8066EA90(current_actor_pointer, 2); + func_8066EA90(current_actor_pointer, 3); + } +} + +typedef struct BossStruct1 { + u8 unk0; // Map + u8 unk1; + s16 unk2; // Flag + u8 unk4; + u8 unk5; +} BossStruct1; + +extern BossStruct1 D_800359D0[]; + +void func_80029140(s16* arg0) { + s16 i = 0; + while (D_800359D0[i].unk0 != 0 && D_800359D0[i].unk0 != current_map) { + i++; + } + if (D_800359D0[i].unk0 != 0 && D_800359D0[i].unk4 == *arg0) { + if (isFlagSet(D_800359D0[i].unk2, FLAG_TYPE_TEMPORARY)) { + *arg0 = D_800359D0[i].unk5; + } + } +} + +void func_8002920C(void) { + s16 i = 0; + while (D_800359D0[i].unk0 != 0 && D_800359D0[i].unk0 != current_map) { + i++; + } + if (D_800359D0[i].unk0 != 0) { + setFlag(D_800359D0[i].unk2, TRUE, FLAG_TYPE_TEMPORARY); + } +} diff --git a/src/boss/code_52B0.c b/src/boss/code_52B0.c new file mode 100644 index 00000000..b5fd9f5c --- /dev/null +++ b/src/boss/code_52B0.c @@ -0,0 +1,33 @@ +#include +#include "functions.h" +#include "variables.h" + +extern f32 D_800361B0; +extern f32 D_800361B4; + +void func_80691830(s32, f32, s32, s32, s32, s32, f32, f32, f32, f32); +void func_806086CC(f32, f32, f32, s32, s32, s32, s32, s32, f32, s32); +void func_80613C48(Actor*, s32, f32, f32); +void func_80614D00(Actor*, f32, f32); + +void func_800292B0(f32 arg0) { + func_80691830(0x6A, 1.2f, 0, 0x96, 0xFF, 0xB, D_800361B0, 0.0f, 0.0f, 0.0f); + func_806086CC(current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0x221, 0x80, 0x7F, 1, 0, D_800361B4, 0); + D_807FBB44->y_position = current_actor_pointer->y_position; + D_807FBB44->animation_state->scale_y *= arg0; + func_80613C48(D_807FBB44, 0x4F9, 0.0f, 0.0f); + func_80614D00(D_807FBB44, 1.5f, 0.0f); +} + +void func_8068588C(Actor*, s16, f32, f32, f32, f32, s16); + +void func_800293C0(void) { + rand(); + func_807149B8(1); + func_80714998(3); + func_807149C8(0x78, 0x78, 0x78, 0xC8); + func_8068588C(current_actor_pointer, (((rand() >> 0xF) % 32767) % 16) + 3, 2.0f, 0.0f, 0.0f, 0.0f, -0x96); +} + +// Jumptable, 3544 bytes of code, oof +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_52B0/func_80029468.s") diff --git a/src/boss/code_6240.c b/src/boss/code_6240.c new file mode 100644 index 00000000..1c83d3a7 --- /dev/null +++ b/src/boss/code_6240.c @@ -0,0 +1,123 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern s32 D_80720120; +extern s32 D_8071720C; +extern s32 D_8071EDEC; +extern s32 D_8074E880[]; + +s32 func_80725BA4(s16, s16, s32); +void func_8071498C(void*); +void func_80714C08(void*, f32, Actor*, s32, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_6240/func_8002A240.s") + +f32 func_80612794(s16); + +/* +// TODO: Pretty close, missing some float instructions near the bottom though +void func_8002A240(void) { + Actor17C *temp_s0; + f32 temp_f10; + + temp_s0 = current_actor_pointer->unk17C; + if (temp_s0->unk4 != 0) { + temp_s0->unk4--; + temp_f10 = func_80612794(((temp_s0->unk4 / 10.0) * ((temp_s0->unk8 * 0) - 0x400)) + (temp_s0->unk8 + 0x400)) * 20.0; + current_actor_pointer->x_position += temp_f10 * func_80612794(temp_s0->unk6); + current_actor_pointer->z_position += temp_f10 * func_80612790(temp_s0->unk6); + if (temp_s0->unk4 == 0) { + temp_s0->unk8 += 0x400; + } + } else if (((rand() >> 0xF) % 1000) >= 0x3AD) { + temp_s0->unk4 = 0xA; + } + current_actor_pointer->y_position += 8.0 * func_80612794(object_timer * 200.0); +} +*/ + +void func_8002A41C(u8 arg0) { + s32 pad; + s32 temp_v0; + void *sp2C; + + switch (arg0) { + case 0: + temp_v0 = func_8067ADB4(0x61); // TNT Barrel Spawner (Dogadon) + if (temp_v0) { + func_8067AB20(current_actor_pointer, temp_v0, 0x1000000, 1, &sp2C, 0); + return; + } + return; + case 1: + temp_v0 = func_8067ADB4(0x60); // Hunky Chunky Barrel (Dogadon) + if (temp_v0) { + func_8067AB20(current_actor_pointer, temp_v0, 0x1000000, 1, &sp2C, 0); + } + temp_v0 = func_8067ADB4(0x61); // TNT Barrel Spawner (Dogadon) + if (temp_v0) { + func_8067AB20(current_actor_pointer, temp_v0, 0x1000000, 3, &sp2C, 0); + return; + } + break; + case 2: + temp_v0 = func_8067ADB4(0x60); // Hunky Chunky Barrel (Dogadon) + if (temp_v0) { + func_8067AB20(current_actor_pointer, temp_v0, 0x1000000, 1, &sp2C, 0); + } + temp_v0 = func_8067ADB4(0x61); // TNT Barrel Spawner (Dogadon) + if (temp_v0) { + func_8067AB20(current_actor_pointer, temp_v0, 0x1000000, 2, &sp2C, 0); + } + break; + } +} + +void func_8002A55C(u8 arg0, f32 arg1) { + if (!(arg0 & object_timer)) { + func_807149B8(1); + func_807149C8(0xFF, 0xD7, 0x58, 0xFF); + func_80714C08(&D_80720120, arg1, current_actor_pointer, 1, 0); + } +} + +void func_8002A5CC(void) { + f32 sp6C; + f32 sp68; + f32 sp64; + s16 phi_s0; + s32 tmp_s2; + + func_80671C0C(current_actor_pointer, 1, &sp6C, &sp68, &sp64); + sp6C += ((rand() >> 0xF) % 80) - 40; + sp68 += ((rand() >> 0xF) % 100) + 50; + sp64 += ((rand() >> 0xF) % 80) - 40; + func_807149B8(1); + func_8071498C(&D_8071EDEC); + func_80714950(current_actor_pointer); + func_807149C8(0xFF, 0xD7, 0x58, 0xFF); + func_80714CC0(&D_80720120, 1.5f, sp6C, sp68, sp64); + tmp_s2 = &D_8071720C; + for (phi_s0 = 0; phi_s0 < 4; phi_s0++) { + func_80714998(2); + func_8071498C(tmp_s2); + func_807149B8(1); + func_80714C08(D_8074E880[((rand() >> 0xF) % 1000) % 3], + 1.5f, + current_actor_pointer, + (((rand() >> 0xF) % 32767) % 22) + 2, + 0); + } +} + +void func_8002A8B8(s32 arg0) { + if (func_80725BA4(player_pointer->x_position, player_pointer->z_position, arg0) == 0) { + player_pointer->x_position = player_pointer->unk88; + player_pointer->z_position = player_pointer->unk90; + } +} + +// Jumptable, huge +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_6240/func_8002A92C.s") diff --git a/src/boss/code_8520.c b/src/boss/code_8520.c new file mode 100644 index 00000000..ec3ccf3a --- /dev/null +++ b/src/boss/code_8520.c @@ -0,0 +1,88 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806883F4(Actor*, s32, s16, f32); +void func_80690814(Actor*, s32); +void func_80690A28(s16, s16, f32, f32, f32, f32, f32, Actor*); + +void func_8068842C(Actor*, s32, s32); +void func_80688460(Actor*, s32, s32); + +void func_8002C520(s16, s16, s16); + +void func_807271F4(s32, s16, s16, s16, s16, s32, s32); + +f32 func_80612794(s16); + +void func_8002C520(s16 arg0, s16 arg1, s16 arg2) { + func_807271F4(arg0, + current_actor_pointer->x_position + (func_80612794(arg2) * arg1), + D_807FDC9C[0].unk6, + current_actor_pointer->z_position + (func_80612790(arg2) * arg1), + 0, + 0, + 0); + D_807FBB44->terminal_velocity *= 2; + D_807FBB44->draw_distance = 2000; +} + +void func_8002C5F4(void) { + func_8002C520(2, ((rand() >> 0xF) % 100) + 300, (rand() >> 0xF) % 4096); + func_8002C520(3, ((rand() >> 0xF) % 100) + 300, (rand() >> 0xF) % 4096); + func_8002C520(4, ((rand() >> 0xF) % 100) + 300, (rand() >> 0xF) % 4096); + if (!(D_807FDC90[0].unk1A & 0x8000)) { + D_807FDC90[0].unk1A |= 0x8000; + playCutscene(D_807FBB44, 2, 1); + } +} + +void func_8002C748(u8 arg0) { + D_807FDC90->unk28 = 2; + func_8068842C(current_actor_pointer, arg0, 1); + func_80688460(current_actor_pointer, arg0, 1); + func_806883F4(current_actor_pointer, arg0, D_807FDC90->unk28 & 0xF, 0); +} + +void func_8002C7CC(void) { + u16 sp26; + u8 sp25; + u8 sp20; + + sp25 = D_807FDC90->unk28 & 0x80; + sp20 = D_807FDC90->unk28 & 0xF; + sp26 = 0; + if (sp25) { + sp20++; + if (sp20 >= 2) { + sp25 = 0; + } else { + sp26 = 0x8000; + } + } else { + sp20--; + if (sp20 <= 0) { + sp25 = 0x80; + } else { + sp26 = 0x8000; + } + } + func_806883F4(current_actor_pointer, 0, sp20, 0); + func_806883F4(current_actor_pointer, 1, sp20, 0); + D_807FDC90->unk28 = sp26 | sp20 | sp25; +} + +void func_8002C8B4(void) { + func_80690814(current_actor_pointer, 1); + func_80690A28(0x116, + (((rand() >> 0xF) % 3) + 1), + 1.0f, + D_807FDC94->x_position, + D_807FDC94->y_position + D_807FDC94->unk15E, + D_807FDC94->z_position, + 300.0f, + current_actor_pointer); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_8520/func_8002C964.s") diff --git a/src/boss/code_9230.c b/src/boss/code_9230.c new file mode 100644 index 00000000..9eba37f8 --- /dev/null +++ b/src/boss/code_9230.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + +// Jumptable, 2608 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9230/func_8002D230.s") diff --git a/src/boss/code_9C60.c b/src/boss/code_9C60.c new file mode 100644 index 00000000..b18c8951 --- /dev/null +++ b/src/boss/code_9C60.c @@ -0,0 +1,201 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80613CA8(Actor*, s16, f32, f32); +f32 func_80612794(s16); +void func_8002FB7C(u8); + +extern u16 D_807FBB34; +extern f64 D_80036A18; + +void func_8002DC60(void) { + BossActor178 *sp1C = current_actor_pointer->unk178; + func_80677FA8(0xDD, 0xE3); // Spawn actor 221 "light piece" (lanky phase) + D_807FBB44->object_properties_bitfield |= 0x400; + D_807FBB44->unk11C = current_actor_pointer; + sp1C->unk0 = D_807FBB44; + func_8067B238(D_807FBB44, current_actor_pointer, current_actor_pointer->animation_state->scale_y); +} + +void func_8002DCE0(void) { + func_8067B238(current_actor_pointer, current_actor_pointer->unk11C, current_actor_pointer->animation_state->scale_y); + current_actor_pointer->animation_state->unk48 = current_actor_pointer->unk11C->animation_state->unk48; + if (current_actor_pointer->animation_state->unk0->unk10 == 0x675) { + if (current_actor_pointer->animation_state->unk0->unk24 == 0.0f) { + func_806782C0(current_actor_pointer); + } + } + func_806319C4(current_actor_pointer, 0); +} + +void func_8002DD7C(void) { + Actor *temp_a0; + s16 i; + + for (i = 0; i < D_807FBB34; i++) { + temp_a0 = D_807FB930[i].unk0; + // Actor behaviour: Damage Source (K. Rool's Glove) + if (temp_a0->unk58 == 0xAA) { + func_806782C0(temp_a0); + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9C60/func_8002DE04.s") + +void func_8002E7A0(Actor *arg0) { + Actor *temp_a0; + s16 i; + + for (i = 0; i < D_807FBB34; i++) { + temp_a0 = D_807FB930[i].unk0; + if (!arg0 || temp_a0 != arg0) { + // Actor behaviour: Banana Peel (Lanky Phase) + if (temp_a0->unk58 == 0xDE) { + temp_a0->object_properties_bitfield &= ~0x8000; + temp_a0->control_state = 1; + temp_a0->control_state_progress = 0; + } + } + } +} + +void func_8002E82C(void) { + Actor *temp_v0_2; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_8002E7A0(current_actor_pointer); + current_actor_pointer->unk168 = 600; + current_actor_pointer->noclip_byte = 2; + } + if (player_pointer->control_state != 0x67) { + if (current_actor_pointer->unk168 != 0) { + current_actor_pointer->unk168--; + } else { + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->control_state = 1; + current_actor_pointer->control_state_progress = 0; + } + } + if ((D_807FBB70[0].unk15 != 0) || (D_807FBB70[0].unk200 == 9)) { + temp_v0_2 = D_807FBB70[0].unk1FC; + if ((temp_v0_2->control_state == 0x2B) && (temp_v0_2->control_state_progress == 3)) { + current_actor_pointer->control_state = 1; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->unk11C->control_state = 0x64; + current_actor_pointer->unk11C->control_state_progress = 0; + temp_v0_2->control_state_progress = 0; + temp_v0_2->control_state = 0x31; + } + } + if (current_actor_pointer->control_state == 1) { + current_actor_pointer->noclip_byte = 1; + current_actor_pointer->shadow_opacity -= 0xA; + if (current_actor_pointer->shadow_opacity < 0) { + func_806782C0(current_actor_pointer); + } + } + func_806319C4(current_actor_pointer, 0); +} + +void func_8002E9B8(s32 arg0, s16 arg1) { + BossActor178 *sp1C = current_actor_pointer->boss178; + func_80614EBC(current_actor_pointer, arg0); + func_80614D90(current_actor_pointer); + func_80613CA8(sp1C->unk0, arg1, 0.0f, 6.0f); +} + +void func_8002EA14() { + // TODO: BossActor178? + Actor178 *sp1C = current_actor_pointer->unk178; + func_8002E9B8(0x406, 0x674); + func_8072B324(current_actor_pointer, D_807FDC9C[0].unkC + (sp1C->unk14 * 0xA) + 0xF); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9C60/func_8002EA7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9C60/func_8002F100.s") + +void func_8002FB7C(u8 arg0) { + AnimationStateUnk20 *temp_v0; + + temp_v0 = current_actor_pointer->animation_state->unk20; + temp_v0->unk0 = 2; + temp_v0->unk1 = 4; + temp_v0->unk4 = 1; + temp_v0->unk4 += arg0 * (D_80036A18 + D_80036A18 * func_80612794(object_timer << 7)); + temp_v0->unk8 = temp_v0->unk4; + temp_v0->unkC = 1; +} + +void func_806883F4(Actor*, s32, s16, f32); + +void func_8002FC48(s32 arg0, u8 arg1) { + func_8068842C(arg0, 0, 1); + func_80688460(arg0, 0, 1); + func_806883F4(arg0, 0, arg1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9C60/func_8002FC98.s") + +extern u8 D_807FBD70; + +void func_8002FDF8(s32 arg0, u8 arg1) { + s32 phi_v0; + Actor *temp; + + if (current_actor_pointer->unk15F == 2) { + phi_v0 = 4; + } else { + phi_v0 = arg1; + } + func_8002FB7C(phi_v0); + if (D_807FBD70 == 4) { + func_8002FC98(arg0, 0xF, 0, 0); + // Note: This temporary variable appears to be required for this function to match + temp = current_actor_pointer; + func_8002FC48(temp, 0xA - temp->health); + func_80614EBC(current_actor_pointer, 0x415); + } + if ((D_807FBD70 == 5) || (D_807FBD70 == 4)) { + func_8072DA60(); + } +} + +void func_8002FEC0(Actor* arg0[], u8 arg1, s32 arg2) { + func_80677FA8(0xE5, arg2); // Spawn actor 229 (K. Rool's toe) + func_8067B238(D_807FBB44, current_actor_pointer, current_actor_pointer->animation_state->scale_y); + D_807FBB44->object_properties_bitfield |= 0x1400; + D_807FBB44->unk11C = current_actor_pointer; + D_807FBB44->noclip_byte = current_actor_pointer->noclip_byte; + D_807FBB44->object_properties_bitfield = current_actor_pointer->object_properties_bitfield; + arg0[arg1] = D_807FBB44; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9C60/func_8002FF74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_9C60/func_80030888.s") + +/* +// TODO: Not bad, EOF issue +void func_8002FDF8(Actor*, u8, Actor*); +void func_806319C4(Actor*, s32); +void func_80724DB0(s32, s32, Actor*); + +void func_80030888(void) { + u8 phi_v0_2; + Actor* temp; + + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_80724DB0(2, 1, current_actor_pointer->unk11C); + } + //temp = current_actor_pointer->unk11C; + phi_v0_2 = 0U; + if (current_actor_pointer->unk15F == 1) { + phi_v0_2 = ((Actor178*)current_actor_pointer->unk11C->unk178)->unk14; + } + func_8002FDF8(current_actor_pointer->unk11C, phi_v0_2, current_actor_pointer->unk11C); + func_806319C4(current_actor_pointer, 0); +} +*/ diff --git a/src/boss/code_C920.c b/src/boss/code_C920.c new file mode 100644 index 00000000..a245608a --- /dev/null +++ b/src/boss/code_C920.c @@ -0,0 +1,104 @@ +#include +#include "functions.h" +#include "variables.h" + +s16 func_80665DE0(f32, f32, f32, f32); +void func_8061C464(s32, Actor*, s32, s32, s32, s32, s32, s32, s32, s32, f32); +void func_806086CC(f32, f32, f32, s32, s32, s32, s32, s32, f32, s32); +f32 func_80612794(s16); +void func_8063DA40(s32, s16); + +extern s32 D_807F5D10; +extern f32 D_80036AB0; +extern f32 D_80036AB4; +extern f64 D_80036AB8; +extern s32 D_807F5D10; + +typedef struct BossStruct3 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + u8 unk14; // Used +} BossStruct3; + +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_C920/func_80030920.s") + +/* +// TODO: Regalloc :( +void func_80030920(s32 arg0) { + extra_player_info_pointer->unk1FE = 1; + func_800290D4(1); + current_actor_pointer->noclip_byte = 0x24; + func_806EB0C0(0x19, current_actor_pointer, 0); + func_80724B5C(1, 8, ¤t_actor_pointer->x_position, ¤t_actor_pointer->y_position, ¤t_actor_pointer->z_position); + D_807FDC90->unkA = current_actor_pointer->x_position; + D_807FDC90->unkC = current_actor_pointer->y_position; + D_807FDC90->unkE = current_actor_pointer->z_position; + func_80724B5C(1, 0x20, &player_pointer->x_position, &player_pointer->y_position, &player_pointer->z_position); + player_pointer->y_rotation = func_80665DE0(current_actor_pointer->x_position, current_actor_pointer->z_position, player_pointer->x_position, player_pointer->z_position); + current_actor_pointer->unkEE = \ + current_actor_pointer->y_rotation = player_pointer->y_rotation + 0x800; + func_80614EBC(current_actor_pointer, 0x3F9); + if (func_8061CB50()) { + func_8061D4E4(D_807F5D10); + } + func_8061C464(D_807F5D10, player_pointer, 4, 0x800, 0x5A, 0, 0x46, 0x64, 0x3A, 0, D_80036AB0); +} +*/ + +void func_80030AE0(BossStruct3 *arg0) { + func_800290D4(0); + extra_player_info_pointer->unk1F4 = 0; + if (player_pointer->control_state != 0x36) { + func_806CFF9C(player_pointer); + } + func_806224CC(D_807F5D10, player_pointer); + extra_player_info_pointer->unk1D8 = D_80036AB4; + func_8063DA40(0xB, arg0->unk14 <= 0 ? 0 : 4); + func_8063DA40(0xC, arg0->unk14 < 2 ? 0 : 4); + func_8063DA40(0xD, arg0->unk14 < 3 ? 0 : 4); + func_8063DA40(0xE, arg0->unk14 < 4 ? 0 : 4); + func_8063DA40(0xA, 0xA); +} + +void func_80030C30(f32 arg0) { + f64 temp_f0; + + temp_f0 = D_80036AB8; + current_actor_pointer->x_position = ((player_pointer->x_position - D_807FDC90->unkA) * current_actor_pointer->unk160) + D_807FDC90->unkA; + current_actor_pointer->y_position = ((player_pointer->y_position - D_807FDC90->unkC) * current_actor_pointer->unk160) + D_807FDC90->unkC; + current_actor_pointer->z_position = ((player_pointer->z_position - D_807FDC90->unkE) * current_actor_pointer->unk160) + D_807FDC90->unkE; + current_actor_pointer->unk160 += arg0; + if (temp_f0 < current_actor_pointer->unk160) { + current_actor_pointer->unk160 = temp_f0; + } +} + +void func_80030D50(void) { + s32 temp; // TODO: Can this be removed somehow? Messes up a stack offset + f32 sp20; + + sp20 = func_80612794(current_actor_pointer->unk160 * 10240.0); + current_actor_pointer->x_position += 80.0f * func_80612794(current_actor_pointer->y_rotation + 0x400) * sp20; + sp20 = func_80612794(current_actor_pointer->unk160 * 10240.0); + current_actor_pointer->z_position += 80.0f * func_80612790(current_actor_pointer->y_rotation + 0x400) * sp20; +} + +void func_80030E58() { + D_807FDC90->unk1A |= 1; + func_806086CC(current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position, + 0x2E2, 0xFF, 0x65, 0, 0, 0.0f, 0); +} + +// Jumptable, 3036 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_C920/func_80030EC4.s") + +// Jumptable, 4200 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_C920/func_80031AA0.s") + +// Quite an interesting Actor + float function, quite big but doable, but might need some struct and array definitions +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_C920/func_80032B08.s") diff --git a/src/boss/code_F0D0.c b/src/boss/code_F0D0.c new file mode 100644 index 00000000..c2b913aa --- /dev/null +++ b/src/boss/code_F0D0.c @@ -0,0 +1,130 @@ +#include +#include "functions.h" +#include "variables.h" + +// Quite big but pretty doable, needs some struct/array definitions +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_F0D0/func_800330D0.s") + +void func_80614D90(Actor*); +void func_8061EF4C(s32, s32, s32, f32, f32, f32, f32, f32); + +extern f64 D_80036C58; +extern s32 D_8071720C; // TODO: Datatype +extern void *D_8074E880[]; +extern f32 D_80036DB4; +extern s32 D_807F5D10; + +typedef struct BossStruct0 { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u8 unk4; +} BossStruct0; + +typedef struct BossStruct2 { + u8 pad0[0x14]; + u8 unk14; + u8 unk15; + u8 unk16; +} BossStruct2; + +void func_8003340C(BossStruct0 *arg0) { + if ((current_actor_pointer->animation_state->unk64 != 0x223) && (arg0->unk1 == arg0->unk3)) { + func_80614EBC(current_actor_pointer, 0x223); + func_80614D90(current_actor_pointer); + return; + } + if ((current_actor_pointer->animation_state->unk64 != 0x224) && (arg0->unk1 != arg0->unk3)) { + func_80614EBC(current_actor_pointer, 0x224); + func_80614D90(current_actor_pointer); + } +} + +// Doable, needs some struct definitions +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_F0D0/func_800334A4.s") + +void func_800336C0(void) { + f32 sp24; + + sp24 = current_actor_pointer->animation_state->scale_y / D_80036C58; + func_80714998(2); + func_8071498C(&D_8071720C); + func_807149B8(1); + func_80714950(1); + func_80714CC0(D_8074E880[((rand() >> 0xF) % 1000) % 3], + (f64)sp24, + current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position); +} + +// Oof, I had a crack at this one but it's very fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_F0D0/func_80033784.s") + +// Very doable, just gotta figure out some structs +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_F0D0/func_8003392C.s") + +/* +void func_8003392C(void *arg0) { + void *temp_v0; + void *temp_v1; + + func_80690814(current_actor_pointer, 1); + temp_v0 = D_807FDCA0->unk14 + (arg0->unk3 * 0xA); + func_80690A28(0x2C, 2, current_actor_pointer->animation_state->scale_y, temp_v0->unk0, temp_v0->unk2, temp_v0->unk4, 1200.0f, temp_v1); +} +*/ + +u8 func_800339D8(BossStruct2 *arg0, u8 *arg1) { + if ((player_pointer->y_position < current_actor_pointer->y_position - 10.0f)) { + if (arg0->unk14 < 5) { + arg0->unk15 = arg0->unk16; + current_actor_pointer->control_state = arg1[arg0->unk15++]; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0); + return TRUE; + } + } + return FALSE; +} + +void func_80033A80(s8 arg0) { + current_actor_pointer->shadow_opacity += arg0; + if (current_actor_pointer->shadow_opacity < 0) { + current_actor_pointer->shadow_opacity = 0; + current_actor_pointer->control_state_progress++; + return; + } + if (current_actor_pointer->shadow_opacity >= 0x100) { + current_actor_pointer->shadow_opacity = 0xFF; + current_actor_pointer->control_state_progress++; + } +} + +// Jumptable, 7276 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_F0D0/func_80033AF0.s") + +void func_8003575C(void) { + f32 dx, dz; + + switch (current_actor_pointer->control_state_progress) { + case 1: + if (current_actor_pointer->control_state == 0) { + dx = player_pointer->x_position - current_actor_pointer->x_position; + dz = player_pointer->z_position - current_actor_pointer->z_position; + if (((dx * dx) + (dz * dz)) < D_80036DB4) { + if (player_pointer->control_state != 0x31) { + func_806EB0C0(0x2E, current_actor_pointer, 0); + } + current_actor_pointer->control_state++; + } + } + break; + case 3: + func_806782C0(current_actor_pointer); + break; + } + func_8061EF4C(D_807F5D10, 5, 0x14, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 200.0f, 400.0f); + func_806319C4(current_actor_pointer, 0); +} diff --git a/src/dk64_boot/cosf.c b/src/dk64_boot/cosf.c new file mode 100644 index 00000000..23863e00 --- /dev/null +++ b/src/dk64_boot/cosf.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/cosf/cosf.s") diff --git a/src/dk64_boot/dk64_boot_1050.c b/src/dk64_boot/dk64_boot_1050.c new file mode 100644 index 00000000..05cb9815 --- /dev/null +++ b/src/dk64_boot/dk64_boot_1050.c @@ -0,0 +1,165 @@ +#include +#include "functions.h" +#include "variables.h" + +typedef struct { + void *unk0; + void *unk4; + u8 pad8[0x10]; +} dk64_boot_struct_0; + +extern u8 D_1050; +extern u8 D_11320; +extern u8 D_113F0; +extern u8 D_CBE70; +extern u8 D_D4B00; +extern u8 D_D6B00; +extern u8 D_D9A40; +extern u8 D_DF600; +extern u8 D_E6780; +extern u8 D_EA0B0; +extern u8 D_F41A0; +extern u8 D_FD2F0; +extern u8 D_101A40; +extern u8 romAssetBin; +extern u8 D_188AF20; +extern u8 D_1897860; +extern u8 D_1A97280; +extern u8 D_1ABCBF0; +extern u8 D_1FED020; + +extern s8 D_8000DCB0; +extern s32 D_8000DCB4; +extern dk64_boot_struct_0 D_8000DCC4[]; +extern OSViMode D_8000EF20[]; +extern s32 D_8000DE74[3]; + +extern OSMesg D_80011520; +extern OSMesgQueue D_80011548; +extern OSThread D_80011560; +extern OSThread D_80012710; +extern u32 D_800138C0; + +void func_80000450(s32 devAddr, s32 arg1, void *dramAddr) { + u32 size = arg1 - devAddr; + osInvalDCache(dramAddr, size); + osPiRawStartDma(OS_READ, devAddr, dramAddr, size); + do { } while(osPiGetStatus() & PI_STATUS_DMA_BUSY); +} + +void func_800004B4(s32 *arg0, s32 *arg1) { + func_800024E0(arg0, arg1, 0x804FAE00); + func_800024E0(arg0, arg1, 0x804FAE00); +} + +void func_800004F4(s32 arg0) { + OSMesg sp24; + void (*gaFunc)(OSMesgQueue *, s32); + osRecvMesg(&D_80011548, &sp24, OS_MESG_BLOCK); + switch((u32)sp24) { + case 0x29d://L80000538 + if (D_8000DCB0) { + gaFunc = 0x805fb300; + gaFunc(&D_80011548, 2); + break; + } + osViBlack(1); + while(1); + case 0x309: //L80000570 + osSetThreadPri(NULL, 0x12); + gaFunc = 0x805fb300; + gaFunc(&D_80011548, 1); + while(1); + } +} + +#ifndef NONMATCHING +void func_800005A8(s32 arg0); +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1050/func_800005A8.s") +#else +void func_800005A8(s32 arg0) { + u32 sp34; + u32 sp30; + s32 sp20[3] = D_8000DE74; + + osCreateMesgQueue(&D_80011548, &D_80011520, OS_MESG_TYPE_LOOPBACK); + osSetEventMesg(OS_EVENT_PRENMI, &D_80011548, (OSMesg)0x29D); + osCreateThread(&D_80011560, 0xB, func_800004F4, NULL, &D_80012710, 0x64); + osStartThread(&D_80011560); + osCreateViManager(0xFE); + osViSetMode(D_8000EF20 + sp20[osTvType]); + osViBlack(1); + if (osMemSize < 0x80 || osTvType == OS_TV_PAL) { + D_8000DCC4[11].unk0 = &romAssetBin; + D_8000DCC4[11].unk4 = &D_188AF20; + func_80000A30(); + } else { + func_80000450(&D_11320, &D_113F0, 0x805FB000); + D_8000DCB4 = func_80005070(0x5622); + bzero(0x805FB300, 0x204D00); + sp34 = 0x80020000; + sp30 = 0x805FB300; + func_80000450(&D_113F0, &D_CBE70, 0x80020000); + func_800004B4(&sp34, &sp30); + osInvalICache(0x805FB300, sp30 + 0x7FA04D00); + osWriteBackDCacheAll(); + D_8000DCC4[0].unk4 = &D_11320; + D_8000DCC4[0].unk0 = &D_1050; + D_8000DCC4[1].unk4 = &D_CBE70; + D_8000DCC4[1].unk0 = &D_113F0; + D_8000DCC4[2].unk4 = &D_D6B00; + D_8000DCC4[2].unk0 = &D_D4B00; + D_8000DCC4[3].unk4 = &D_D9A40; + D_8000DCC4[3].unk0 = &D_D6B00; + D_8000DCC4[4].unk4 = &D_DF600; + D_8000DCC4[4].unk0 = &D_D9A40; + D_8000DCC4[5].unk4 = &D_E6780; + D_8000DCC4[5].unk0 = &D_DF600; + D_8000DCC4[6].unk4 = &D_EA0B0; + D_8000DCC4[6].unk0 = &D_E6780; + D_8000DCC4[6].unk4 = &D_EA0B0; + D_8000DCC4[6].unk0 = &D_E6780; + D_8000DCC4[7].unk4 = &D_F41A0; + D_8000DCC4[7].unk0 = &D_EA0B0; + D_8000DCC4[8].unk4 = &D_FD2F0; + D_8000DCC4[8].unk0 = &D_F41A0; + D_8000DCC4[9].unk4 = &D_101A40; + D_8000DCC4[9].unk0 = &D_FD2F0; + D_8000DCC4[10].unk0 = &D_CBE70; + D_8000DCC4[10].unk4 = &D_D4B00; + D_8000DCC4[11].unk0 = &romAssetBin; + D_8000DCC4[11].unk4 = &D_188AF20; + D_8000DCC4[12].unk0 = &D_101A40; + D_8000DCC4[12].unk4 = &romAssetBin; + D_8000DCC4[13].unk0 = &romAssetBin; + D_8000DCC4[13].unk4 = &romAssetBin; + D_8000DCC4[14].unk0 = &D_1897860; + D_8000DCC4[14].unk4 = &D_1A97280; + D_8000DCC4[15].unk4 = &D_1897860; + D_8000DCC4[15].unk0 = &D_188AF20; + D_8000DCC4[16].unk4 = &D_1ABCBF0; + D_8000DCC4[16].unk0 = &D_1A97280; + D_8000DCC4[17].unk4 = &D_1FED020; + D_8000DCC4[17].unk0 = &D_1ABCBF0; + + osSetThreadPri(NULL, 0); + D_8000DCB0 = 1; + ((void (*)(OSMesgQueue *, s32))0x805FB300)(&D_80011548, 0); + } + while(1); +} +#endif + +void func_80000980(void) { + osCreateThread(&D_80012710, 1, func_800005A8, NULL, &D_800138C0, 0); + osStartThread(&D_80012710); +} + +void func_800009D0(void) { + u32 *tmp_a0; + osInitialize(); + tmp_a0 = 0xA02FE1C0; + while(0xAD170014 != *tmp_a0); + *tmp_a0 = 0xF0F0F0F0; + func_80000980(); +} diff --git a/src/dk64_boot/dk64_boot_1630.c b/src/dk64_boot/dk64_boot_1630.c new file mode 100644 index 00000000..804ac55b --- /dev/null +++ b/src/dk64_boot/dk64_boot_1630.c @@ -0,0 +1,108 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80000AA0(void); +void func_80000D8C(void *arg0); +void func_80000E48(void *arg0, s32 arg1, s32 arg2, u8 *arg3); +void func_80000EEC(s16* arg0[8][8], s32 arg1, s32 arg2, u8 arg3); +void func_8000102C(s32 arg0, s32 arg1, void *arg2); + +extern u8 *D_8000DDCC; +extern u8 D_8000ED24; +extern u8 D_8000ED40; +extern u8 D_8000ED58; +extern u8 D_8000ED78; +extern u8 D_8000ED9C; +extern u8 D_8000EDC0; + +extern OSThread D_800138C0; +extern void *D_80013A70[]; + +extern u16 D_80100000[0]; +extern void *D_80133E80; + +typedef struct{ + s32 unk0; + s32 unk4; +} dk64_boot_struct_1_s; + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1630/func_80000A30.s") + +/* +void func_80000A30(void) { + D_80013A70[0] = &D_80133E80; + osCreateThread(&D_800138C0, 2, func_80000AA0, NULL, &D_80133E80, 0xA); + osStartThread(&D_800138C0); + while (TRUE) {}; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1630/func_80000AA0.s") + +void func_80000CD4(void) { + s16 *tmp_v0 = 0x80100000; + int i; + s32 pad0; + void * sp38; + s32 sp34; + dk64_boot_struct_1_s *tmp_s0; + s32 pad1; + s32 pad2; + + if (osTvType == OS_TV_PAL) { + i = 0; + do { + tmp_v0[i++] = 0; + } while(i < 0x12C00); + } else { + tmp_s0 = 0x80280000; + func_8000102C(0x38, 0x10, tmp_s0); + func_8000102C(tmp_s0->unk0 + 0x4C, 0x10, tmp_s0); + func_8000102C(tmp_s0->unk0, tmp_s0->unk4 - tmp_s0->unk0, tmp_s0); + sp38 = tmp_s0; + sp34 = 0x80380000; + func_800024E0(&sp38, &sp34, 0x803C0000); + func_80000D8C(0x80100000); + } +} + +void func_80000D8C(void *arg0) { + if (osTvType != OS_TV_PAL) { + func_80000E48(arg0, 0x15, 0x8C, &D_8000ED24); + func_80000E48(arg0, 0x15, 0x96, &D_8000ED40); + func_80000E48(arg0, 0x15, 0xAA, &D_8000ED58); + func_80000E48(arg0, 0x15, 0xb4, &D_8000ED78); + func_80000E48(arg0, 0x15, 0xbe, &D_8000ED9C); + func_80000E48(arg0, 0x15, 0xc8, &D_8000EDC0); + } +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1630/func_80000E48.s") +#else +void func_80000E48(void *arg0, s32 arg1, s32 arg2, u8 *arg3) { + int i; + for (i = 0; arg3[i]; arg1 += 9, i++) { + if (0x20 != arg3[i]) { + func_80000EEC(arg0, arg1, arg2, arg3[i]); + } else { + arg1 -= 2; + } + } + osWritebackDCache(arg0, 0x25800); +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1630/func_80000EEC.s") + +void func_8000102C(s32 offset, s32 size, void *dramAddr) { + while(size & 0xf) + { + size++; + } + osWritebackDCache(dramAddr, size); + osPiRawStartDma(OS_READ, D_8000DDCC + offset, dramAddr, size); + do{}while(osPiGetStatus() & PI_STATUS_DMA_BUSY); + osInvalDCache(dramAddr, size); +} diff --git a/src/dk64_boot/dk64_boot_1CC0.c b/src/dk64_boot/dk64_boot_1CC0.c new file mode 100644 index 00000000..88496142 --- /dev/null +++ b/src/dk64_boot/dk64_boot_1CC0.c @@ -0,0 +1,18 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_800010C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001700.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001AF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001C48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001DB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_800022D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_800023F4.s") diff --git a/src/dk64_boot/dk64_boot_30E0.c b/src/dk64_boot/dk64_boot_30E0.c new file mode 100644 index 00000000..91573bb3 --- /dev/null +++ b/src/dk64_boot/dk64_boot_30E0.c @@ -0,0 +1,60 @@ +#include +#include "functions.h" +#include "variables.h" + + +void func_80002750(void); + +s32 D_8000EEE0; + +void *D_80013AB0; +u8 *D_80013AC0; +s32 D_80013AC4; +s32 D_80013AD8; +s32 D_80013ADC; +s32 D_80013AE8; +s32 D_80013AEC; +s32 D_80013AF0; + +void func_800024E0(u8 **arg0, s32 *arg1, void *arg2) { + D_80013AC0 = *arg0; + D_80013AC4 = *arg1; + D_80013AB0 = arg2; + func_80002750(); + if (D_80013AC0[D_80013AEC] != 0x1F) { + D_80013AEC++; + } + D_8000EEE0 = func_800025A4(); + if (D_8000EEE0 >= 0) { + func_800023F4(); + (*arg0) += D_80013AEC; + (*arg1) += D_80013AF0; + } + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_30E0/func_800025A4.s") + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_30E0/func_80002724.s") +#else +u32 func_80002724(u32 arg0, s32 arg1) { + u32 v1 = 0; + do { + v1 |= (arg0 & 1); + arg1--; + arg0 >>= 1; + v1 <<= 1; + } while (arg1 > 0); + return v1 >> 1; +} +#endif + +// Lol +void func_80002750(void) { + D_80013AF0 = 0; + D_80013AE8 = \ + D_80013AEC = 0; + D_80013AD8 = \ + D_80013ADC = 0; +} diff --git a/src/dk64_boot/dk64_boot_3390.c b/src/dk64_boot/dk64_boot_3390.c new file mode 100644 index 00000000..d6789614 --- /dev/null +++ b/src/dk64_boot/dk64_boot_3390.c @@ -0,0 +1,38 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002790.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002828.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_800028E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_800029EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002A30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002A64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002ABC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002B0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002BB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002C74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002CE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002D60.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002DE4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002E98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002ECC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002F18.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3390/func_80002F54.s") diff --git a/src/dk64_boot/dk64_boot_3C00.c b/src/dk64_boot/dk64_boot_3C00.c new file mode 100644 index 00000000..40fa22e6 --- /dev/null +++ b/src/dk64_boot/dk64_boot_3C00.c @@ -0,0 +1,45 @@ +#include +#include "functions.h" +#include "variables.h" + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3C00/memcpy.s") + +// TODO: Need some extra compiler flags to make it use ld instruction? +/* +void *memcpy(u32 dest, u32 src, u32 n) +{ + void* _dest = dest; + if (n != 0) + { + if ((((n | 7) ^ 7) != n) || (((dest | 7) ^ 7) != dest) || (((src | 7) ^ 7) != src)) + { + if ((((n | 3) ^ 3) != n) || (((dest | 3) ^ 3) != dest) || (((src | 3) ^ 3) != src)) + { + if ((((n | 1) ^ 1) != n) || (((dest | 1) ^ 1) != dest) || (((src | 1) ^ 1) != src)) + { + while(n > 0) { + *((u8 *)dest)++ = *((u8 *)src)++; + n--; + } + } else { + while(n > 0) { + *((u16 *)dest)++ = *((u16 *)src)++; + n -= sizeof(u16); + } + } + } else { + while(n > 0) { + *((u32 *)dest)++ = *((u32 *)src)++; + n -= sizeof(u32); + } + } + } else { + while(n > 0) { + *((u64 *)dest)++ = *((u64 *)src)++; + n -= sizeof(u64); + } + } + } + return _dest; +} +*/ \ No newline at end of file diff --git a/src/dk64_boot/dk64_boot_3D20.c b/src/dk64_boot/dk64_boot_3D20.c new file mode 100644 index 00000000..b8c3b133 --- /dev/null +++ b/src/dk64_boot/dk64_boot_3D20.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3D20/func_80003120.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3D20/func_800031E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_3D20/func_8000320C.s") diff --git a/src/dk64_boot/dk64_boot_5C70.c b/src/dk64_boot/dk64_boot_5C70.c new file mode 100644 index 00000000..37701053 --- /dev/null +++ b/src/dk64_boot/dk64_boot_5C70.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_5C70/func_80005070.s") diff --git a/src/dk64_boot/dk64_boot_61D0.c b/src/dk64_boot/dk64_boot_61D0.c new file mode 100644 index 00000000..79bff25c --- /dev/null +++ b/src/dk64_boot/dk64_boot_61D0.c @@ -0,0 +1,30 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern u8 D_80015004; +extern u8 D_80015005; +extern u8 D_80015006; +extern u8 D_80015007; +extern u8 D_80015008; + +extern u8 D_8001507C; +extern u8 D_8001507D; +extern u8 D_8001507E; +extern u8 D_8001507F; +extern u8 D_80015080; + +void func_800055D0(void) { + D_80015004 = 7; + D_80015005 = IO_READ(PI_BSD_DOM1_LAT_REG); + D_80015008 = IO_READ(PI_BSD_DOM1_PWD_REG); + D_80015006 = IO_READ(PI_BSD_DOM1_PGS_REG); + D_80015007 = IO_READ(PI_BSD_DOM1_RLS_REG); + + D_8001507C = 7; + D_8001507D = IO_READ(PI_BSD_DOM2_LAT_REG); + D_80015080 = IO_READ(PI_BSD_DOM2_PWD_REG); + D_8001507E = IO_READ(PI_BSD_DOM2_PGS_REG); + D_8001507F = IO_READ(PI_BSD_DOM2_RLS_REG); +} diff --git a/src/dk64_boot/dk64_boot_62F0.c b/src/dk64_boot/dk64_boot_62F0.c new file mode 100644 index 00000000..f8c0d26a --- /dev/null +++ b/src/dk64_boot/dk64_boot_62F0.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_62F0/func_800056F0.s") diff --git a/src/dk64_boot/dk64_boot_63B0.c b/src/dk64_boot/dk64_boot_63B0.c new file mode 100644 index 00000000..b73c1fc1 --- /dev/null +++ b/src/dk64_boot/dk64_boot_63B0.c @@ -0,0 +1,26 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_800057B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_800057DC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005818.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005854.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005880.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_800058BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005918.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005948.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_800059A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005A44.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_63B0/func_80005A70.s") diff --git a/src/dk64_boot/dk64_boot_7F60.c b/src/dk64_boot/dk64_boot_7F60.c new file mode 100644 index 00000000..10aad31d --- /dev/null +++ b/src/dk64_boot/dk64_boot_7F60.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_7F60/func_80007360.s") diff --git a/src/dk64_boot/dk64_boot_7FD0.c b/src/dk64_boot/dk64_boot_7FD0.c new file mode 100644 index 00000000..49a5efad --- /dev/null +++ b/src/dk64_boot/dk64_boot_7FD0.c @@ -0,0 +1,25 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 __osContLastCmd; +extern s32 *D_80014DC0; + +s32 func_800073D0(OSMesgQueue *arg0) { + s32 temp_v0; + + __osSiGetAccess(); + if (__osContLastCmd != 1) { + func_800074E0(); + __osSiRawStartDma(1, &D_80014DC0); + osRecvMesg(arg0, NULL, 1); + } + temp_v0 = __osSiRawStartDma(0, &D_80014DC0); + __osContLastCmd = 1; + __osSiRelAccess(); + return temp_v0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_7FD0/func_80007454.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_7FD0/func_800074E0.s") diff --git a/src/dk64_boot/dk64_boot_CA20.c b/src/dk64_boot/dk64_boot_CA20.c new file mode 100644 index 00000000..8dae5c87 --- /dev/null +++ b/src/dk64_boot/dk64_boot_CA20.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_CA20/func_8000BE20.s") diff --git a/src/dk64_boot/dk64_boot_E790.c b/src/dk64_boot/dk64_boot_E790.c new file mode 100644 index 00000000..36112b6f --- /dev/null +++ b/src/dk64_boot/dk64_boot_E790.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_E790/func_8000DB90.s") diff --git a/src/dk64_boot/gu/lookat.c b/src/dk64_boot/gu/lookat.c new file mode 100644 index 00000000..384ec6d5 --- /dev/null +++ b/src/dk64_boot/gu/lookat.c @@ -0,0 +1,71 @@ +#include "guint.h" + +void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp) +{ + float len, xLook, yLook, zLook, xRight, yRight, zRight; + + guMtxIdentF(mf); + + xLook = xAt - xEye; + yLook = yAt - yEye; + zLook = zAt - zEye; + + /* Negate because positive Z is behind us: */ + len = -1.0 / sqrtf (xLook*xLook + yLook*yLook + zLook*zLook); + xLook *= len; + yLook *= len; + zLook *= len; + + /* Right = Up x Look */ + + xRight = yUp * zLook - zUp * yLook; + yRight = zUp * xLook - xUp * zLook; + zRight = xUp * yLook - yUp * xLook; + len = 1.0 / sqrtf (xRight*xRight + yRight*yRight + zRight*zRight); + xRight *= len; + yRight *= len; + zRight *= len; + + /* Up = Look x Right */ + + xUp = yLook * zRight - zLook * yRight; + yUp = zLook * xRight - xLook * zRight; + zUp = xLook * yRight - yLook * xRight; + len = 1.0 / sqrtf (xUp*xUp + yUp*yUp + zUp*zUp); + xUp *= len; + yUp *= len; + zUp *= len; + + mf[0][0] = xRight; + mf[1][0] = yRight; + mf[2][0] = zRight; + mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight); + + mf[0][1] = xUp; + mf[1][1] = yUp; + mf[2][1] = zUp; + mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp); + + mf[0][2] = xLook; + mf[1][2] = yLook; + mf[2][2] = zLook; + mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook); + + mf[0][3] = 0; + mf[1][3] = 0; + mf[2][3] = 0; + mf[3][3] = 1; +} + +void guLookAt (Mtx *m, float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp) +{ + Matrix mf; + + guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); + + guMtxF2L(mf, m); +} diff --git a/src/dk64_boot/gu/mtxcatf.c b/src/dk64_boot/gu/mtxcatf.c new file mode 100644 index 00000000..55952e62 --- /dev/null +++ b/src/dk64_boot/gu/mtxcatf.c @@ -0,0 +1,30 @@ +#include "guint.h" + +void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4]) +{ + int i, j, k; + float temp[4][4]; + + for (i=0; i<4; i++) { + for (j=0; j<4; j++) { + temp[i][j] = 0.0; + for (k=0; k<4; k++) { + temp[i][j] += mf[i][k] * nf[k][j]; + } + } + } + + /* make sure we handle case where result is an input */ + for (i=0; i<4; i++) { + for (j=0; j<4; j++) { + res[i][j] = temp[i][j]; + } + } +} + +void guMtxXFMF(float mf[4][4], float x, float y, float z, float *ox, float *oy, float *oz) +{ + *ox = mf[0][0]*x + mf[1][0]*y + mf[2][0]*z + mf[3][0]; + *oy = mf[0][1]*x + mf[1][1]*y + mf[2][1]*z + mf[3][1]; + *oz = mf[0][2]*x + mf[1][2]*y + mf[2][2]*z + mf[3][2]; +} diff --git a/src/dk64_boot/gu/mtxcatl.c b/src/dk64_boot/gu/mtxcatl.c new file mode 100644 index 00000000..8158b7b7 --- /dev/null +++ b/src/dk64_boot/gu/mtxcatl.c @@ -0,0 +1,22 @@ +#include "guint.h" + +void guMtxCatL(Mtx *m, Mtx *n, Mtx *res) +{ + float mf[4][4], nf[4][4], resf[4][4]; + + guMtxL2F(mf, m); + guMtxL2F(nf, n); + + guMtxCatF(mf, nf, resf); + + guMtxF2L(resf, res); +} + +void guMtxXFML(Mtx *m, float x, float y, float z, float *ox, float *oy, float *oz) +{ + float mf[4][4]; + + guMtxL2F(mf, m); + + guMtxXFMF(mf, x, y, z, ox, oy, oz); +} diff --git a/src/dk64_boot/gu/nonmatching/align.c b/src/dk64_boot/gu/nonmatching/align.c new file mode 100644 index 00000000..ee53e3fa --- /dev/null +++ b/src/dk64_boot/gu/nonmatching/align.c @@ -0,0 +1,60 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/align/guAlignF.s") + +/* +void guAlignF(float mf[4][4], float a, float x, float y, float z) +{ + static float dtor = 3.1415926f / 180.0f; // TODO: Need .rodata, .data, .bss defined? I don't really understand + float s, c, h, hinv; + + guNormalize(&x, &y, &z); + + a *= dtor; + s = sinf(a); + c = cosf(a); + h = sqrtf(x * x + z * z); + + guMtxIdentF(mf); + + if (h != 0) { + hinv = 1 / h; + + mf[0][0] = (-z*c - s*y*x) * hinv; + mf[1][0] = (z*s - c*y*x) * hinv; + mf[2][0] = -x; + mf[3][0] = 0; + + mf[0][1] = s*h; + mf[1][1] = c*h; + mf[2][1] = -y; + mf[3][1] = 0; + + mf[0][2] = (c*x - s*y*z) * hinv; + mf[1][2] = (-s*x - c*y*z) * hinv; + mf[2][2] = -z; + mf[3][2] = 0; + + mf[0][3] = 0; + mf[1][3] = 0; + mf[2][3] = 0; + mf[3][3] = 1; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/align/guAlign.s") + +/* +void guAlign(Mtx *m, f32 a, f32 x, f32 y, f32 z) +{ + f32 mf[4][4]; + + guAlignF(mf, a, x, y, z); + + guMtxF2L(mf, m); +} +*/ diff --git a/src/dk64_boot/gu/nonmatching/lookathil.c b/src/dk64_boot/gu/nonmatching/lookathil.c new file mode 100644 index 00000000..4ad48894 --- /dev/null +++ b/src/dk64_boot/gu/nonmatching/lookathil.c @@ -0,0 +1,12 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/lookathil/guLookAtHiliteF.s") + +void guLookAtHilite(Mtx *m, 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) { + float sp58[4][4]; + guLookAtHiliteF(&sp58[0], l, h, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp, xl1, yl1, zl1, xl2, yl2, zl2, twidth, theight); + guMtxF2L(&sp58[0], m); +} diff --git a/src/dk64_boot/gu/nonmatching/mtxutil.c b/src/dk64_boot/gu/nonmatching/mtxutil.c new file mode 100644 index 00000000..1bb3ad19 --- /dev/null +++ b/src/dk64_boot/gu/nonmatching/mtxutil.c @@ -0,0 +1,66 @@ +#include +#include "functions.h" +#include "variables.h" + +void guMtxF2L(f32 mf[4][4], Mtx *m) { + s32 r, c; + s32 tmp1; + s32 tmp2; + s32 *m1 = &m->m[0][0]; + s32 *m2 = &m->m[2][0]; + for (r = 0; r < 4; r++) { + for (c = 0; c < 2; c++) { + tmp1 = mf[r][2 * c] * 65536.0f; + tmp2 = mf[r][2 * c + 1] * 65536.0f; + *m1++ = (tmp1 & 0xffff0000) | ((tmp2 >> 0x10) & 0xffff); + *m2++ = ((tmp1 << 0x10) & 0xffff0000) | (tmp2 & 0xffff); + } + } +} + +void guMtxIdentF(f32 (*mf)[4]) { + s32 r, c; + for (r = 0; r < 4; r++) { + for (c = 0; c < 4; c++) { + if (r == c) { + mf[r][c] = 1.0f; + } else { + mf[r][c] = 0.0f; + } + } + } +} + +void guMtxIdent(Mtx *m) { + Mtx sp18; + + guMtxIdentF(&sp18); + guMtxF2L(&sp18, m); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/mtxutil/guMtxL2F.s") + +/* +void guMtxL2F(float mf[4][4], Mtx *m) { + int r, c; + u32 tmp1; + u32 tmp2; + u32 *m1; + u32 *m2; + s32 stmp1, stmp2; + m1 = (u32 *)&m->m[0][0]; + m2 = (u32 *)&m->m[2][0]; + for (r = 0; r < 4; r++) + { + for (c = 0; c < 2; c++) + { + tmp1 = (*m1 & 0xffff0000) | ((*m2 >> 0x10) & 0xffff); + tmp2 = ((*m1++ << 0x10) & 0xffff0000) | (*m2++ & 0xffff); + stmp1 = *(s32 *)&tmp1; + stmp2 = *(s32 *)&tmp2; + mf[r][c * 2 + 0] = stmp1 / 65536.0f; + mf[r][c * 2 + 1] = stmp2 / 65536.0f; + } + } +} +*/ \ No newline at end of file diff --git a/src/dk64_boot/gu/nonmatching/position.c b/src/dk64_boot/gu/nonmatching/position.c new file mode 100644 index 00000000..d437bd06 --- /dev/null +++ b/src/dk64_boot/gu/nonmatching/position.c @@ -0,0 +1,18 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/position/guPositionF.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/position/guPosition.s") + +/* +// TODO: Not sure why this doesn't match +// Calling convention? Compiler flag? +void guPosition(Mtx *m, float r, float p, float h, float s, float x, float y, float z) { + float mf[4][4]; + guPositionF(&mf, r, p, h, s, x, y, z); + guMtxF2L(&mf, m); +} +*/ diff --git a/src/dk64_boot/gu/nonmatching/rotate.c b/src/dk64_boot/gu/nonmatching/rotate.c new file mode 100644 index 00000000..e9f352eb --- /dev/null +++ b/src/dk64_boot/gu/nonmatching/rotate.c @@ -0,0 +1,16 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/rotate/guRotateF.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/rotate/guRotate.s") + +/* +void guRotate(Mtx *m, float a, float x, float y, float z) { + float sp20[4][4]; + guRotateF(&sp20, a, x, y, z); + guMtxF2L(&sp20, m); +} +*/ diff --git a/src/dk64_boot/gu/nonmatching/usprite.c b/src/dk64_boot/gu/nonmatching/usprite.c new file mode 100644 index 00000000..a6968fea --- /dev/null +++ b/src/dk64_boot/gu/nonmatching/usprite.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/gu/nonmatching/usprite/guSprite2DInit.s") diff --git a/src/dk64_boot/gu/normalize.c b/src/dk64_boot/gu/normalize.c new file mode 100644 index 00000000..78addf96 --- /dev/null +++ b/src/dk64_boot/gu/normalize.c @@ -0,0 +1,11 @@ +#include "guint.h" + +void guNormalize(float *x, float *y, float *z) +{ + float m; + + m = 1/sqrtf((*x)*(*x) + (*y)*(*y) + (*z)*(*z)); + *x *= m; + *y *= m; + *z *= m; +} diff --git a/src/dk64_boot/gu/ortho.c b/src/dk64_boot/gu/ortho.c new file mode 100644 index 00000000..ffc8e5b2 --- /dev/null +++ b/src/dk64_boot/gu/ortho.c @@ -0,0 +1,29 @@ +#include "guint.h" + +void guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale) +{ + int i, j; + + guMtxIdentF(mf); + + mf[0][0] = 2/(r-l); + mf[1][1] = 2/(t-b); + mf[2][2] = -2/(f-n); + mf[3][0] = -(r+l)/(r-l); + mf[3][1] = -(t+b)/(t-b); + mf[3][2] = -(f+n)/(f-n); + mf[3][3] = 1; + + for (i=0; i<4; i++) + for (j=0; j<4; j++) + mf[i][j] *= scale; +} + +void guOrtho(Mtx *m, float l, float r, float b, float t, float n, float f, float scale) +{ + Matrix mf; + + guOrthoF(mf, l, r, b, t, n, f, scale); + + guMtxF2L(mf, m); +} diff --git a/src/dk64_boot/gu/perspective.c b/src/dk64_boot/gu/perspective.c new file mode 100644 index 00000000..c2d0de75 --- /dev/null +++ b/src/dk64_boot/gu/perspective.c @@ -0,0 +1,43 @@ +#include "guint.h" +#include + +void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale) +{ + float cot; + int i, j; + + guMtxIdentF(mf); + + fovy *= 3.1415926 / 180.0; + cot = cosf (fovy/2) / sinf (fovy/2); + + mf[0][0] = cot / aspect; + mf[1][1] = cot; + mf[2][2] = (near + far) / (near - far); + mf[2][3] = -1; + mf[3][2] = (2 * near * far) / (near - far); + mf[3][3] = 0; + + for (i=0; i<4; i++) + for (j=0; j<4; j++) + mf[i][j] *= scale; + + if (perspNorm != (u16 *) NULL) { + if (near+far<=2.0) { + *perspNorm = (u16) 0xFFFF; + } else { + *perspNorm = (u16) ((2.0*65536.0)/(near+far)); + if (*perspNorm<=0) + *perspNorm = (u16) 0x0001; + } + } +} + +void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, float scale) +{ + Matrix mf; + + guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale); + + guMtxF2L(mf, m); +} diff --git a/src/dk64_boot/gu/scale.c b/src/dk64_boot/gu/scale.c new file mode 100644 index 00000000..127e8a29 --- /dev/null +++ b/src/dk64_boot/gu/scale.c @@ -0,0 +1,20 @@ +#include "guint.h" + +void guScaleF(float mf[4][4], float x, float y, float z) +{ + guMtxIdentF(mf); + + mf[0][0] = x; + mf[1][1] = y; + mf[2][2] = z; + mf[3][3] = 1; +} + +void guScale(Mtx *m, float x, float y, float z) +{ + Matrix mf; + + guScaleF(mf, x, y, z); + + guMtxF2L(mf, m); +} diff --git a/src/dk64_boot/gu/translate.c b/src/dk64_boot/gu/translate.c new file mode 100644 index 00000000..65e72855 --- /dev/null +++ b/src/dk64_boot/gu/translate.c @@ -0,0 +1,19 @@ +#include "guint.h" + +void guTranslateF(float mf[4][4], float x, float y, float z) +{ + guMtxIdentF(mf); + + mf[3][0] = x; + mf[3][1] = y; + mf[3][2] = z; +} + +void guTranslate(Mtx *m, float x, float y, float z) +{ + Matrix mf; + + guTranslateF(mf, x, y, z); + + guMtxF2L(mf, m); +} diff --git a/src/dk64_boot/io/ai.c b/src/dk64_boot/io/ai.c new file mode 100644 index 00000000..529aba81 --- /dev/null +++ b/src/dk64_boot/io/ai.c @@ -0,0 +1,11 @@ +#include + +s32 __osAiDeviceBusy(void) +{ + register s32 status = IO_READ(AI_STATUS_REG); + if (status & AI_STATUS_FIFO_FULL) + + return 1; + + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/aigetlen.c b/src/dk64_boot/io/aigetlen.c new file mode 100644 index 00000000..cdf329b6 --- /dev/null +++ b/src/dk64_boot/io/aigetlen.c @@ -0,0 +1,7 @@ + +#include + +u32 osAiGetLength(void) +{ + return IO_READ(AI_LEN_REG); +} \ No newline at end of file diff --git a/src/dk64_boot/io/aisetnextbuf.c b/src/dk64_boot/io/aisetnextbuf.c new file mode 100644 index 00000000..5d54f005 --- /dev/null +++ b/src/dk64_boot/io/aisetnextbuf.c @@ -0,0 +1,24 @@ +#include +#include +#include "osint.h" + +u8 hdwrBugFlag = 0; + +s32 osAiSetNextBuffer(void *bufPtr, u32 size) +{ + char *bptr = bufPtr; + if (hdwrBugFlag != 0) + bptr -= 0x2000; + + if ((((u32)bufPtr + size) & 0x1fff) == 0) + hdwrBugFlag = 1; + else + hdwrBugFlag = 0; + + if (__osAiDeviceBusy()) + return -1; + + IO_WRITE(AI_DRAM_ADDR_REG, osVirtualToPhysical(bptr)); + IO_WRITE(AI_LEN_REG, size); + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/conteeplongread.c b/src/dk64_boot/io/conteeplongread.c new file mode 100644 index 00000000..951f26d2 --- /dev/null +++ b/src/dk64_boot/io/conteeplongread.c @@ -0,0 +1,16 @@ +#include +#include "controller.h" + +s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length) +{ + s32 ret; + ret = 0; + while (length > 0) + { + ERRCK(osEepromRead(mq, address, buffer)); + length -= EEPROM_BLOCK_SIZE; + address++; + buffer += EEPROM_BLOCK_SIZE; + } + return ret; +} diff --git a/src/dk64_boot/io/conteepprobe.c b/src/dk64_boot/io/conteepprobe.c new file mode 100644 index 00000000..3a81bd6e --- /dev/null +++ b/src/dk64_boot/io/conteepprobe.c @@ -0,0 +1,4 @@ +#include "controller.h" +#include "siint.h" + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/conteepprobe/osEepromProbe.s") diff --git a/src/dk64_boot/io/conteepread.c b/src/dk64_boot/io/conteepread.c new file mode 100644 index 00000000..ae4ee9d2 --- /dev/null +++ b/src/dk64_boot/io/conteepread.c @@ -0,0 +1,8 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/conteepread/osEepromRead.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/conteepread/__osPackEepReadData.s") diff --git a/src/dk64_boot/io/conteepwrite.c b/src/dk64_boot/io/conteepwrite.c new file mode 100644 index 00000000..5f7eb4a9 --- /dev/null +++ b/src/dk64_boot/io/conteepwrite.c @@ -0,0 +1,70 @@ +#include +#include "controller.h" +#include "siint.h" +#include + +void __osPackEepWriteData(u8 address, u8 *buffer); + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/conteepwrite/osEepromWrite.s") +#else +s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) +{ + + s32 ret; + int i; + u32 type; + u8 *ptr; + __OSContEepromFormat eepromformat; + OSContStatus sdata; + + ret = 0; + __osSiGetAccess(); + ret = __osEepStatus(mq, &sdata); + + if (!ret) { + type = sdata.type & (CONT_EEPROM | CONT_EEP16K); + switch (type) { + default: + ret = CONT_NO_RESPONSE_ERROR; + break; + case CONT_EEPROM://L800079B0 + if (address >= EEPROM_MAXBLOCKS) + ret = -1; + break; + case CONT_EEPROM | CONT_EEP16K://L800079C4 + if (address >= EEP16K_MAXBLOCKS) + ret = -1; + break; + } + } + if (ret) { + __osSiRelAccess(); + return ret; + } + + while (sdata.status & CONT_EEPROM_BUSY) + { + __osEepStatus(mq, &sdata); + } + __osPackEepWriteData(address, buffer); + __osSiRawStartDma(OS_WRITE, &__osEepPifRam); //send command to pif + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osEepPifRam); //recv response + __osContLastCmd = CONT_CMD_WRITE_EEPROM; + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + ptr = (u8*)__osEepPifRam.ramarray + 4; + eepromformat = *(__OSContEepromFormat *)ptr; + + //probably indicates an error, from PIF + ret = CHNL_ERR(eepromformat); //TODO: remove magic constants + + __osSiRelAccess(); + return ret; +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/conteepwrite/__osPackEepWriteData.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/conteepwrite/__osEepStatus.s") diff --git a/src/dk64_boot/io/contpfs.c b/src/dk64_boot/io/contpfs.c new file mode 100644 index 00000000..5f6a66c0 --- /dev/null +++ b/src/dk64_boot/io/contpfs.c @@ -0,0 +1,56 @@ +#include +#include "controller.h" + + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/__osSumcalc.s") +#else +u16 __osSumcalc(u8 *ptr, int length) +{ + int i; + u32 sum; + u8 *tmp; + + sum = 0; + tmp = ptr; + for (i = 0; i < length; i++) + { + sum += *tmp++; + } + return sum & 0xffff; +} +#endif + +#ifndef NONMATHCING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/__osIdCheckSum.s") +#else +s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum) +{ + u16 data; + u32 j; + data = 0; + *icsum = 0; + *csum = *icsum; + for (j = 0; j < 28; j += 2) + { + //feels like this should be a compiler optimization not manual.. + //but it doesn't match and I'm pretty sure this is just -O1 + /* ^comment copies from libreultra, I'm pretty positive this file is NOT -O1 for DK64*/ + data = *(u16 *)((u8 *)ptr + j); + //data = ptr[j]; + *csum += data; + *icsum += ~data; + } + return 0; +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/__osRepairPackId.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/__osCheckPackId.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/__osGetId.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/func_8000D7E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contpfs/func_8000D8B4.s") diff --git a/src/dk64_boot/io/contramread.c b/src/dk64_boot/io/contramread.c new file mode 100644 index 00000000..643e3b2f --- /dev/null +++ b/src/dk64_boot/io/contramread.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contramread/__osContRamReadData.s") diff --git a/src/dk64_boot/io/contramwrite.c b/src/dk64_boot/io/contramwrite.c new file mode 100644 index 00000000..6d42dbc0 --- /dev/null +++ b/src/dk64_boot/io/contramwrite.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contramwrite/__osContRamWrite.s") diff --git a/src/dk64_boot/io/contramwritesafe.c b/src/dk64_boot/io/contramwritesafe.c new file mode 100644 index 00000000..8a240bcc --- /dev/null +++ b/src/dk64_boot/io/contramwritesafe.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/contramwritesafe/__osPackRamWriteDataSafe.s") diff --git a/src/dk64_boot/io/controller.c b/src/dk64_boot/io/controller.c new file mode 100644 index 00000000..88826250 --- /dev/null +++ b/src/dk64_boot/io/controller.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/controller/osContInit.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/controller/__osContGetInitData.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/controller/__osPackRequestData.s") diff --git a/src/dk64_boot/io/crc.c b/src/dk64_boot/io/crc.c new file mode 100644 index 00000000..ec80c092 --- /dev/null +++ b/src/dk64_boot/io/crc.c @@ -0,0 +1,6 @@ +#include + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/crc/__osContAddressCrc.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/crc/__osContDataCrc.s") diff --git a/src/dk64_boot/io/devmgr.c b/src/dk64_boot/io/devmgr.c new file mode 100644 index 00000000..535f15e5 --- /dev/null +++ b/src/dk64_boot/io/devmgr.c @@ -0,0 +1,5 @@ +#include +#include "piint.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/devmgr/__osDevMgrMain.s") diff --git a/src/dk64_boot/io/dpgetstat.c b/src/dk64_boot/io/dpgetstat.c new file mode 100644 index 00000000..a612932d --- /dev/null +++ b/src/dk64_boot/io/dpgetstat.c @@ -0,0 +1,6 @@ +#include +#include + +u32 osDpGetStatus() { + return IO_READ(DPC_STATUS_REG); +} diff --git a/src/dk64_boot/io/dpsetstat.c b/src/dk64_boot/io/dpsetstat.c new file mode 100644 index 00000000..dc33c498 --- /dev/null +++ b/src/dk64_boot/io/dpsetstat.c @@ -0,0 +1,7 @@ + #include +#include + +void osDpSetStatus(u32 data) +{ + IO_WRITE(DPC_STATUS_REG, data); +} diff --git a/src/dk64_boot/io/epirawread.c b/src/dk64_boot/io/epirawread.c new file mode 100644 index 00000000..a0c6bca6 --- /dev/null +++ b/src/dk64_boot/io/epirawread.c @@ -0,0 +1,22 @@ +#include +#include +#include "piint.h" + +#define UPDATE_REG(reg, var) \ + if (cHandle->var != pihandle->var) \ + IO_WRITE(reg, pihandle->var); + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/epirawread/osEPiRawReadIo.s") +#else +s32 osEPiRawReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) +{ + register u32 stat; + register u32 domain; + + EPI_SYNC(pihandle,stat,domain); + + *data = IO_READ(pihandle->baseAddress | devAddr); + return 0; +} +#endif \ No newline at end of file diff --git a/src/dk64_boot/io/epirawwrite.c b/src/dk64_boot/io/epirawwrite.c new file mode 100644 index 00000000..4cdfb99b --- /dev/null +++ b/src/dk64_boot/io/epirawwrite.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/epirawwrite/osEPiRawWriteIo.s") diff --git a/src/dk64_boot/io/motor.c b/src/dk64_boot/io/motor.c new file mode 100644 index 00000000..ff71b7c4 --- /dev/null +++ b/src/dk64_boot/io/motor.c @@ -0,0 +1,124 @@ +#include +#include "controller.h" +#include "siint.h" + +extern u8 D_80014E00; +extern OSPifRam D_80014E50[]; + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/motor/osMotorStartStop.s") +#else +s32 osMotorStartStop(OSPfs *pfs, int arg1) +{ + + int i; + s32 ret; + u8 *ptr; + __OSContRamReadFormat *ramreadformat; + + ramreadformat = (__OSContRamReadFormat *) D_80014E50[pfs->channel].ramarray; + + if (!(pfs->status & 0x8)) + return PFS_ERR_INVALID; + + __osSiGetAccess(); + D_80014E50[pfs->channel].pifstatus = 1; + + for (i = 0; i < 0x20; i++) + ramreadformat->data[i] = arg1; + + D_80014E00 = CONT_CMD_END; + __osSiRawStartDma(OS_WRITE, D_80014E50[pfs->channel].ramarray); + osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, D_80014E50[pfs->channel].ramarray); + osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); + ret = ramreadformat->rxsize & CHNL_ERR_MASK; + if (ret == 0) { + if (!arg1) { + if (ramreadformat->datacrc != 0) + ret = PFS_ERR_CONTRFAIL; + } else { + if (ramreadformat->datacrc != 0xEB) + ret = PFS_ERR_CONTRFAIL; + } + } + __osSiRelAccess(); + return ret; +} +#endif + + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/motor/_MakeMotorData.s") +#else +static void _MakeMotorData(int channel, OSPifRam *mdata) +{ + u8 *ptr; + __OSContRamReadFormat ramreadformat; + int i; + + ramreadformat.dummy = CONT_CMD_NOP; + ramreadformat.txsize = CONT_CMD_WRITE_MEMPACK_TX; + ramreadformat.rxsize = CONT_CMD_WRITE_MEMPACK_RX; + ramreadformat.cmd = CONT_CMD_WRITE_MEMPACK; + ramreadformat.unk4 = 0x600 >> 3; + + ptr = (u8 *)mdata->ramarray; + ramreadformat.unk5 = (0x600 << 5) | __osContAddressCrc(0x600); + + if (channel != 0) + { + for (i = 0; i < channel; i++) + { + *ptr++ = 0; + } + } + *(__OSContRamReadFormat *)ptr = ramreadformat; + ptr += sizeof(__OSContRamReadFormat); + ptr[0] = CONT_CMD_END; +} +#endif + +s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) +{ + s32 ret; + u8 temp[32]; + pfs->queue = mq; + pfs->channel = channel; + pfs->activebank = 0xff; + pfs->status = 0; + + ret = __osPackRamWriteDataSafe(pfs, 254); + if (ret == 2) //TODO: remove magic constant + ret = __osPackRamWriteDataSafe(pfs, 128); + if (ret != 0) + return ret; + + ret = __osContRamReadData(mq, channel, 1024, temp); // ret = __osContRamRead(mq, channel, 1024, temp); + if (ret == 2) + ret = PFS_ERR_CONTRFAIL; //is this right? + if (ret != 0) + return ret; + if (temp[31] == 254) + return PFS_ERR_DEVICE; + + ret = __osPackRamWriteDataSafe(pfs, 128); + if (ret == 2) //TODO: remove magic constant + ret = PFS_ERR_CONTRFAIL; + if (ret != 0) + return ret; + + ret = __osContRamReadData(mq, channel, 1024, temp); // ret = __osContRamRead(mq, channel, 1024, temp); + if (ret == 2) + ret = PFS_ERR_CONTRFAIL; + if (ret != 0) + return ret; + if (temp[31] != 128) + return PFS_ERR_DEVICE; + + if (!(pfs->status & 0x8)) { + _MakeMotorData(channel, &D_80014E50[channel]); + } + pfs->status = 0x8; + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/pfsgetstatus.c b/src/dk64_boot/io/pfsgetstatus.c new file mode 100644 index 00000000..f9b43ad0 --- /dev/null +++ b/src/dk64_boot/io/pfsgetstatus.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pfsgetstatus/__osPfsGetStatus.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pfsgetstatus/__osPfsRequestOneChannel.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pfsgetstatus/__osPfsGetOneChannelData.s") diff --git a/src/dk64_boot/io/pfsisplug.c b/src/dk64_boot/io/pfsisplug.c new file mode 100644 index 00000000..2d285e6c --- /dev/null +++ b/src/dk64_boot/io/pfsisplug.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pfsisplug/osPfsIsPlug.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pfsisplug/__osPfsRequestData.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pfsisplug/__osPfsGetInitData.s") diff --git a/src/dk64_boot/io/piacs.c b/src/dk64_boot/io/piacs.c new file mode 100644 index 00000000..a0fc7fa6 --- /dev/null +++ b/src/dk64_boot/io/piacs.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/piacs/__osPiCreateAccessQueue.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/piacs/__osPiGetAccess.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/piacs/__osPiRelAccess.s") diff --git a/src/dk64_boot/io/pigetcmdq.c b/src/dk64_boot/io/pigetcmdq.c new file mode 100644 index 00000000..2b630133 --- /dev/null +++ b/src/dk64_boot/io/pigetcmdq.c @@ -0,0 +1,13 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern OSDevMgr __osPiDevMgr; + +OSMesgQueue *osPiGetCmdQueue(void) { + if (!__osPiDevMgr.active) + return NULL; + return __osPiDevMgr.cmdQueue; + +} \ No newline at end of file diff --git a/src/dk64_boot/io/pigetstat.c b/src/dk64_boot/io/pigetstat.c new file mode 100644 index 00000000..850b8238 --- /dev/null +++ b/src/dk64_boot/io/pigetstat.c @@ -0,0 +1,7 @@ +#include +#include "piint.h" + +u32 osPiGetStatus() +{ + return IO_READ(PI_STATUS_REG); +} diff --git a/src/dk64_boot/io/pimgr.c b/src/dk64_boot/io/pimgr.c new file mode 100644 index 00000000..97e9e5b9 --- /dev/null +++ b/src/dk64_boot/io/pimgr.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/pimgr/osCreatePiManager.s") diff --git a/src/dk64_boot/io/pirawdma.c b/src/dk64_boot/io/pirawdma.c new file mode 100644 index 00000000..95c23f93 --- /dev/null +++ b/src/dk64_boot/io/pirawdma.c @@ -0,0 +1,22 @@ +#include +#include "piint.h" + +s32 osPiRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) +{ + register u32 stat; + WAIT_ON_IOBUSY(stat); + IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); + IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS((u32)osRomBase | devAddr)); + switch (direction) + { + case OS_READ: + IO_WRITE(PI_WR_LEN_REG, size - 1); + break; + case OS_WRITE: + IO_WRITE(PI_RD_LEN_REG, size - 1); + break; + default: + return -1; + } + return 0; +} diff --git a/src/dk64_boot/io/pirawread.c b/src/dk64_boot/io/pirawread.c new file mode 100644 index 00000000..d7145053 --- /dev/null +++ b/src/dk64_boot/io/pirawread.c @@ -0,0 +1,10 @@ +#include +#include "piint.h" + +s32 osPiRawReadIo(u32 devAddr, u32 *data) +{ + register u32 stat; + WAIT_ON_IOBUSY(stat); + *data = IO_READ((u32)osRomBase | devAddr); + return 0; +} diff --git a/src/dk64_boot/io/piread.c b/src/dk64_boot/io/piread.c new file mode 100644 index 00000000..e2e1c1e4 --- /dev/null +++ b/src/dk64_boot/io/piread.c @@ -0,0 +1,11 @@ +#include +#include "piint.h" + +s32 osPiReadIo(u32 devAddr, u32 *data) +{ + register s32 ret; + __osPiGetAccess(); + ret = osPiRawReadIo(devAddr, data); + __osPiRelAccess(); + return ret; +} \ No newline at end of file diff --git a/src/dk64_boot/io/si.c b/src/dk64_boot/io/si.c new file mode 100644 index 00000000..5f46fe85 --- /dev/null +++ b/src/dk64_boot/io/si.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/si/__osSiDeviceBusy.s") diff --git a/src/dk64_boot/io/siacs.c b/src/dk64_boot/io/siacs.c new file mode 100644 index 00000000..31f22028 --- /dev/null +++ b/src/dk64_boot/io/siacs.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/siacs/__osSiCreateAccessQueue.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/siacs/__osSiGetAccess.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/siacs/__osSiRelAccess.s") diff --git a/src/dk64_boot/io/sirawdma.c b/src/dk64_boot/io/sirawdma.c new file mode 100644 index 00000000..99ea28c7 --- /dev/null +++ b/src/dk64_boot/io/sirawdma.c @@ -0,0 +1,28 @@ +#include +#include "functions.h" +#include "variables.h" + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/sirawdma/__osSiRawStartDma.s") +#else +s32 __osSiRawStartDma(s32 direction, void *dramAddr) +{ + if (IO_READ(SI_STATUS_REG) & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) + return -1; + + if (direction == OS_WRITE) + osWritebackDCache(dramAddr, 64); + + IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); + + if (direction == OS_READ) + IO_WRITE(SI_PIF_ADDR_RD64B_REG, 0x1FC007C0); + else + IO_WRITE(SI_PIF_ADDR_WR64B_REG, 0x1FC007C0); + + if (direction == OS_READ) + osInvalDCache(dramAddr, 64);//bzero(dramAddr, 64); + + return 0; +} +#endif \ No newline at end of file diff --git a/src/dk64_boot/io/sirawread.c b/src/dk64_boot/io/sirawread.c new file mode 100644 index 00000000..1e981259 --- /dev/null +++ b/src/dk64_boot/io/sirawread.c @@ -0,0 +1,9 @@ +#include + +s32 __osSiRawReadIo(u32 devAddr, u32 *data) +{ + if (__osSiDeviceBusy()) + return -1; + *data = IO_READ(devAddr); + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/sirawwrite.c b/src/dk64_boot/io/sirawwrite.c new file mode 100644 index 00000000..6152d19b --- /dev/null +++ b/src/dk64_boot/io/sirawwrite.c @@ -0,0 +1,10 @@ +#include +#include "osint.h" + +s32 __osSiRawWriteIo(u32 devAddr, u32 data) +{ + if (__osSiDeviceBusy()) + return -1; + IO_WRITE(devAddr, data); + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/sp.c b/src/dk64_boot/io/sp.c new file mode 100644 index 00000000..2e85015a --- /dev/null +++ b/src/dk64_boot/io/sp.c @@ -0,0 +1,9 @@ +#include + +int __osSpDeviceBusy() +{ + register u32 stat = IO_READ(SP_STATUS_REG); + if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) + return 1; + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/spgetstat.c b/src/dk64_boot/io/spgetstat.c new file mode 100644 index 00000000..d0cecb35 --- /dev/null +++ b/src/dk64_boot/io/spgetstat.c @@ -0,0 +1,6 @@ +#include + +u32 __osSpGetStatus() +{ + return IO_READ(SP_STATUS_REG); +} \ No newline at end of file diff --git a/src/dk64_boot/io/sprawdma.c b/src/dk64_boot/io/sprawdma.c new file mode 100644 index 00000000..feaad912 --- /dev/null +++ b/src/dk64_boot/io/sprawdma.c @@ -0,0 +1,16 @@ +#include +#include "functions.h" +#include "variables.h" + +s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) +{ + if (__osSpDeviceBusy()) + return -1; + IO_WRITE(SP_MEM_ADDR_REG, devAddr); + IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); + if (direction == OS_READ) + IO_WRITE(SP_WR_LEN_REG, size - 1); + else + IO_WRITE(SP_RD_LEN_REG, size - 1); + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/spsetpc.c b/src/dk64_boot/io/spsetpc.c new file mode 100644 index 00000000..fc956fbe --- /dev/null +++ b/src/dk64_boot/io/spsetpc.c @@ -0,0 +1,15 @@ +#include +#include "functions.h" +#include "variables.h" + +s32 __osSpSetPc(u32 data) +{ + register u32 stat = IO_READ(SP_STATUS_REG); + if (!(stat & SP_STATUS_HALT)) + return -1; + else + { + IO_WRITE(SP_PC_REG, data); + } + return 0; +} \ No newline at end of file diff --git a/src/dk64_boot/io/spsetstat.c b/src/dk64_boot/io/spsetstat.c new file mode 100644 index 00000000..636a5fe8 --- /dev/null +++ b/src/dk64_boot/io/spsetstat.c @@ -0,0 +1,6 @@ +#include +#include + +void __osSpSetStatus(u32 data) { + IO_WRITE(SP_STATUS_REG, data); +} diff --git a/src/dk64_boot/io/sptask.c b/src/dk64_boot/io/sptask.c new file mode 100644 index 00000000..038d51f3 --- /dev/null +++ b/src/dk64_boot/io/sptask.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include "osint.h" + +#define _osVirtualToPhysical(ptr) \ + if (ptr != NULL) \ + { \ + ptr = (void *)osVirtualToPhysical(ptr); \ + } + +OSTask tmp_task; +static OSTask *_VirtualToPhysicalTask(OSTask *intp) +{ + OSTask *tp; + tp = &tmp_task; + bcopy(intp, tp, sizeof(OSTask)); + + _osVirtualToPhysical(tp->t.ucode); + _osVirtualToPhysical(tp->t.ucode_data); + _osVirtualToPhysical(tp->t.dram_stack); + _osVirtualToPhysical(tp->t.output_buff); + _osVirtualToPhysical(tp->t.output_buff_size); + _osVirtualToPhysical(tp->t.data_ptr); + _osVirtualToPhysical(tp->t.yield_data_ptr); + return tp; +} +void osSpTaskLoad(OSTask *intp) +{ + + OSTask *tp; + tp = _VirtualToPhysicalTask(intp); + if (tp->t.flags & OS_TASK_YIELDED) + { + tp->t.ucode_data = tp->t.yield_data_ptr; + tp->t.ucode_data_size = tp->t.yield_data_size; + intp->t.flags &= ~OS_TASK_YIELDED; + if (tp->t.flags & OS_TASK_LOADABLE) + tp->t.ucode = (u64 *)IO_READ((u32)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4); + } + osWritebackDCache(tp, sizeof(OSTask)); + __osSpSetStatus(SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | SP_SET_INTR_BREAK); + while (__osSpSetPc(SP_IMEM_START) == -1) + ; + + while (__osSpRawStartDma(1, (SP_IMEM_START - sizeof(*tp)), tp, + sizeof(OSTask)) == -1) + ; + + while (__osSpDeviceBusy()) + ; + + while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucode_boot, + tp->t.ucode_boot_size) == -1) + ; +} +void osSpTaskStartGo(OSTask *tp) +{ + + while (__osSpDeviceBusy()) + ; + + __osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT); + +} diff --git a/src/dk64_boot/io/sptaskyield.c b/src/dk64_boot/io/sptaskyield.c new file mode 100644 index 00000000..61d62f5c --- /dev/null +++ b/src/dk64_boot/io/sptaskyield.c @@ -0,0 +1,7 @@ +#include +#include + +void osSpTaskYield(void) +{ + __osSpSetStatus(SP_SET_YIELD); +} diff --git a/src/dk64_boot/io/sptaskyielded.c b/src/dk64_boot/io/sptaskyielded.c new file mode 100644 index 00000000..f036be12 --- /dev/null +++ b/src/dk64_boot/io/sptaskyielded.c @@ -0,0 +1,20 @@ +#include +#include +#include + +OSYieldResult osSpTaskYielded(OSTask *tp) +{ + u32 status; + OSYieldResult result; + status = __osSpGetStatus(); + if (status & SP_STATUS_YIELDED) + result = OS_TASK_YIELDED; + else + result = 0; + if (status & SP_STATUS_YIELD) + { + tp->t.flags |= result; + tp->t.flags &= ~(OS_TASK_DP_WAIT); + } + return result; +} diff --git a/src/dk64_boot/io/vi.c b/src/dk64_boot/io/vi.c new file mode 100644 index 00000000..b957913a --- /dev/null +++ b/src/dk64_boot/io/vi.c @@ -0,0 +1,39 @@ +#include +#include "viint.h" + +extern s32 osTvType; +extern OSViMode D_80010210; +extern OSViMode D_80010260; +extern OSViMode D_800102B0; + +static __OSViContext vi[2] = {0}; +__OSViContext *__osViCurr = &vi[0]; +__OSViContext *__osViNext = &vi[1]; +void __osViInit(void) +{ + bzero(vi, sizeof(vi)); + __osViCurr = &vi[0]; + __osViNext = &vi[1]; + __osViNext->retraceCount = 1; + __osViCurr->retraceCount = 1; + __osViNext->framep = (void*)K0BASE; + __osViCurr->framep = (void*)K0BASE; + if (osTvType == OS_TV_TYPE_PAL) + { + __osViNext->modep = &D_80010210; + } + else if (osTvType == OS_TV_TYPE_MPAL) + { + __osViNext->modep = &D_80010260; + } + else + { + __osViNext->modep = &D_800102B0; + } + __osViNext->state = VI_STATE_BLACK; + __osViNext->control = __osViNext->modep->comRegs.ctrl; + while (IO_READ(VI_CURRENT_REG) > 10) //wait for vsync? + ; + IO_WRITE(VI_CONTROL_REG, 0); //pixel size blank (no data, no sync) + __osViSwapContext(); +} diff --git a/src/dk64_boot/io/viblack.c b/src/dk64_boot/io/viblack.c new file mode 100644 index 00000000..76cd0b29 --- /dev/null +++ b/src/dk64_boot/io/viblack.c @@ -0,0 +1,11 @@ +#include +#include "viint.h" +void osViBlack(u8 active) +{ + register u32 saveMask = __osDisableInt(); + if (active) + __osViNext->state |= VI_STATE_BLACK; + else + __osViNext->state &= ~VI_STATE_BLACK; + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/io/vigetcurrcontext.c b/src/dk64_boot/io/vigetcurrcontext.c new file mode 100644 index 00000000..50e372b2 --- /dev/null +++ b/src/dk64_boot/io/vigetcurrcontext.c @@ -0,0 +1,7 @@ +#include +#include "viint.h" + +__OSViContext *__osViGetCurrentContext(void) +{ + return __osViCurr; +} \ No newline at end of file diff --git a/src/dk64_boot/io/vigetcurrframebuf.c b/src/dk64_boot/io/vigetcurrframebuf.c new file mode 100644 index 00000000..58942cd2 --- /dev/null +++ b/src/dk64_boot/io/vigetcurrframebuf.c @@ -0,0 +1,12 @@ +#include +#include "viint.h" + +void *osViGetCurrentFramebuffer(void) +{ + register u32 saveMask; + void *framep; + saveMask = __osDisableInt(); + framep = __osViCurr->framep; + __osRestoreInt(saveMask); + return framep; +} diff --git a/src/dk64_boot/io/vigetmode.c b/src/dk64_boot/io/vigetmode.c new file mode 100644 index 00000000..5eb39f80 --- /dev/null +++ b/src/dk64_boot/io/vigetmode.c @@ -0,0 +1,12 @@ +#include +#include "viint.h" + +u32 osViGetCurrentMode(void) +{ + register u32 savedMask; + register u32 modeType; + savedMask = __osDisableInt(); + modeType = __osViCurr->modep->type; + __osRestoreInt(savedMask); + return modeType; +} diff --git a/src/dk64_boot/io/vigetnextframebuf.c b/src/dk64_boot/io/vigetnextframebuf.c new file mode 100644 index 00000000..6a23fddd --- /dev/null +++ b/src/dk64_boot/io/vigetnextframebuf.c @@ -0,0 +1,13 @@ +#include +#include "viint.h" + +void *osViGetNextFramebuffer(void) +{ + + register u32 saveMask; + void *framep; + saveMask = __osDisableInt(); + framep = __osViNext->framep; + __osRestoreInt(saveMask); + return framep; +} diff --git a/src/dk64_boot/io/vimgr.c b/src/dk64_boot/io/vimgr.c new file mode 100644 index 00000000..84d16519 --- /dev/null +++ b/src/dk64_boot/io/vimgr.c @@ -0,0 +1,12 @@ +#include +#include +#include "viint.h" +#include "osint.h" + +OSDevMgr __osViDevMgr = {0}; +u32 D_8000EF1C = 0; + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/vimgr/osCreateViManager.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/vimgr/viMgrMain.s") diff --git a/src/dk64_boot/io/visetmode.c b/src/dk64_boot/io/visetmode.c new file mode 100644 index 00000000..f25ce5b2 --- /dev/null +++ b/src/dk64_boot/io/visetmode.c @@ -0,0 +1,13 @@ +#include +#include "viint.h" + +void osViSetMode(OSViMode *modep) +{ + register u32 saveMask; + saveMask = __osDisableInt(); + __osViNext->modep = modep; + __osViNext->state = VI_STATE_01; + __osViNext->control = __osViNext->modep->comRegs.ctrl; + __osRestoreInt(saveMask); +} + diff --git a/src/dk64_boot/io/visetspecial.c b/src/dk64_boot/io/visetspecial.c new file mode 100644 index 00000000..42b5f085 --- /dev/null +++ b/src/dk64_boot/io/visetspecial.c @@ -0,0 +1,38 @@ +#include +#include +#include "viint.h" + +void osViSetSpecialFeatures(u32 func) { + + register u32 saveMask; + saveMask = __osDisableInt(); + if ((func & OS_VI_GAMMA_ON) != 0) { + __osViNext->control |= VI_CTRL_GAMMA_ON; + } + if ((func & OS_VI_GAMMA_OFF) != 0) { + __osViNext->control &= ~VI_CTRL_GAMMA_ON; + } + if ((func & OS_VI_GAMMA_DITHER_ON) != 0) { + __osViNext->control |= VI_CTRL_GAMMA_DITHER_ON; + } + if ((func & OS_VI_GAMMA_DITHER_OFF) != 0) { + __osViNext->control &= ~VI_CTRL_GAMMA_DITHER_ON; + } + if ((func & OS_VI_DIVOT_ON) != 0) { + __osViNext->control |= VI_CTRL_DIVOT_ON; + } + if ((func & OS_VI_DIVOT_OFF) != 0) { + __osViNext->control &= ~VI_CTRL_DIVOT_ON; + } + if ((func & OS_VI_DITHER_FILTER_ON) != 0) { + __osViNext->control |= VI_CTRL_DITHER_FILTER_ON; + __osViNext->control &= ~VI_CTRL_ANTIALIAS_MASK; + } + if ((func & OS_VI_DITHER_FILTER_OFF) != 0) { + __osViNext->control &= ~VI_CTRL_DITHER_FILTER_ON; + __osViNext->control |= __osViNext->modep->comRegs.ctrl & VI_CTRL_ANTIALIAS_MASK; + } + __osViNext->state |= VI_STATE_08; + + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/io/viswapbuf.c b/src/dk64_boot/io/viswapbuf.c new file mode 100644 index 00000000..6e0f74f5 --- /dev/null +++ b/src/dk64_boot/io/viswapbuf.c @@ -0,0 +1,9 @@ +#include +#include "viint.h" + +void osViSwapBuffer(void* frameBufPtr) { + u32 saveMask = __osDisableInt(); + __osViNext->framep = frameBufPtr; + __osViNext->state |= VI_STATE_10; + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/io/viswapcontext.c b/src/dk64_boot/io/viswapcontext.c new file mode 100644 index 00000000..4aaaece8 --- /dev/null +++ b/src/dk64_boot/io/viswapcontext.c @@ -0,0 +1,4 @@ +#include +#include "viint.h" + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/viswapcontext/__osViSwapContext.s") diff --git a/src/dk64_boot/libc/llcvt.c b/src/dk64_boot/libc/llcvt.c new file mode 100644 index 00000000..4869cdca --- /dev/null +++ b/src/dk64_boot/libc/llcvt.c @@ -0,0 +1,20 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/__ull_to_f.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_800075CC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_800075E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_80007688.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_80007724.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_8000773C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_80007754.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/libc/llcvt/func_80007788.s") diff --git a/src/dk64_boot/os/createmesgqueue.c b/src/dk64_boot/os/createmesgqueue.c new file mode 100644 index 00000000..65d75da9 --- /dev/null +++ b/src/dk64_boot/os/createmesgqueue.c @@ -0,0 +1,12 @@ +#include +#include "osint.h" + +void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 msgCount) +{ + mq->mtqueue = (OSThread *)&__osThreadTail; + mq->fullqueue = (OSThread *)&__osThreadTail; + mq->validCount = 0; + mq->first = 0; + mq->msgCount = msgCount; + mq->msg = msg; +} diff --git a/src/dk64_boot/os/createthread.c b/src/dk64_boot/os/createthread.c new file mode 100644 index 00000000..f3b8b242 --- /dev/null +++ b/src/dk64_boot/os/createthread.c @@ -0,0 +1,36 @@ +#include +#include + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/os/createthread/osCreateThread.s") + +/* +// TODO: Needs __osCleanupThread(void) address +void __osCleanupThread(void); +extern OSThread *__osActiveQueue; + +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.sr = SR_IMASK | SR_EXL | SR_IE; + t->context.rcp = (mask & 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/dk64_boot/os/destroythread.c b/src/dk64_boot/os/destroythread.c new file mode 100644 index 00000000..604ab716 --- /dev/null +++ b/src/dk64_boot/os/destroythread.c @@ -0,0 +1,45 @@ +#include +#include "osint.h" + +void osDestroyThread(OSThread *t) +{ + register u32 saveMask; + register OSThread *pred; + register OSThread *succ; + saveMask = __osDisableInt(); + if (t == NULL) + { + t = __osRunningThread; + } + else + { + if (t->state != OS_STATE_STOPPED) + { + __osDequeueThread(t->queue, t); + } + } + if (__osActiveQueue == t) + { + __osActiveQueue = __osActiveQueue->tlnext; + } + else + { + pred = __osActiveQueue; + + while (pred->priority != -1) + { + succ = pred->tlnext; + if (succ == t) + { + pred->tlnext = t->tlnext; + break; + } + pred = succ; + } + } + if (t == __osRunningThread) + { + __osDispatchThread(); + } + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/os/getthreadid.c b/src/dk64_boot/os/getthreadid.c new file mode 100644 index 00000000..898c4504 --- /dev/null +++ b/src/dk64_boot/os/getthreadid.c @@ -0,0 +1,9 @@ +#include +#include "osint.h" + +OSId osGetThreadId(OSThread *thread) +{ + if (thread == NULL) + thread = __osRunningThread; + return thread->id; +} diff --git a/src/dk64_boot/os/getthreadpri.c b/src/dk64_boot/os/getthreadpri.c new file mode 100644 index 00000000..efeaf729 --- /dev/null +++ b/src/dk64_boot/os/getthreadpri.c @@ -0,0 +1,12 @@ +#include +#include "functions.h" +#include "variables.h" + +extern OSThread *__osRunningThread; + +OSPri osGetThreadPri(OSThread *thread) +{ + if (thread == NULL) + thread = __osRunningThread; + return thread->priority; +} diff --git a/src/dk64_boot/os/gettime.c b/src/dk64_boot/os/gettime.c new file mode 100644 index 00000000..e7aa4f7a --- /dev/null +++ b/src/dk64_boot/os/gettime.c @@ -0,0 +1,16 @@ +#include +#include "osint.h" + +OSTime osGetTime() +{ + u32 tmptime; + u32 elapseCount; + OSTime currentCount; + register u32 saveMask; + saveMask = __osDisableInt(); + tmptime = osGetCount(); + elapseCount = tmptime - __osBaseCounter; + currentCount = __osCurrentTime; + __osRestoreInt(saveMask); + return currentCount + elapseCount; +} diff --git a/src/dk64_boot/os/initialize.c b/src/dk64_boot/os/initialize.c new file mode 100644 index 00000000..e7b3cff3 --- /dev/null +++ b/src/dk64_boot/os/initialize.c @@ -0,0 +1,68 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/os/initialize/osInitialize.s") + +/* +typedef struct +{ + unsigned int inst1; // 0x0 + unsigned int inst2; // 0x4 + unsigned int inst3; // 0x8 + unsigned int inst4; // 0xC +} __osExceptionVector; +extern __osExceptionVector __osExceptionPreamble; + +extern OSTime osClockRate;// = OS_CLOCK_RATE; +extern s32 osViClock;// = VI_NTSC_CLOCK; +extern u32 __osShutdown;// = 0; +extern u32 __OSGlobalIntMask;// = OS_IM_ALL; +extern u32 __osFinalrom; + +void osInitialize() +{ + u32 pifdata; + u32 clock = 0; + __osFinalrom = TRUE; + __osSetSR(__osGetSR() | SR_CU1); //enable fpu + __osSetFpcCsr(FPCSR_FS | FPCSR_EV); //flush denorm to zero, enable invalid operation + + while (__osSiRawReadIo(PIF_RAM_END - 3, &pifdata)) //last byte of joychannel ram + { + ; + } + while (__osSiRawWriteIo(PIF_RAM_END - 3, pifdata | 8)) + { + ; //todo: magic contant + } + *(__osExceptionVector *)UT_VEC = __osExceptionPreamble; + *(__osExceptionVector *)XUT_VEC = __osExceptionPreamble; + *(__osExceptionVector *)ECC_VEC = __osExceptionPreamble; + *(__osExceptionVector *)E_VEC = __osExceptionPreamble; + osWritebackDCache((void *)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector)); + osInvalICache((void *)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector)); + osMapTLBRdb(); + //osUnmapTLBAll(); // TODO: Which function is actually called here + //osUnmapTLBAll(); // TODO: Which function is actually called here + osPiRawReadIo(4, &clock); //TODO: remove magic constant; + clock &= ~0xf; //clear lower 4 bits + if (clock != 0) + { + osClockRate = clock; + } + //osClockRate = osClockRate * 3 / 4; // TODO: How do we do division/multiplication on a u64? + if (osResetType == 0) // cold reset + { + bzero(osAppNMIBuffer, OS_APP_NMI_BUFSIZE); + } + if (osTvType == OS_TV_PAL) { + osViClock = VI_PAL_CLOCK; + } else if (osTvType == OS_TV_MPAL) { + osViClock = VI_MPAL_CLOCK; + } else { + osViClock = VI_NTSC_CLOCK; + } +} +*/ diff --git a/src/dk64_boot/os/jammesg.c b/src/dk64_boot/os/jammesg.c new file mode 100644 index 00000000..3c427517 --- /dev/null +++ b/src/dk64_boot/os/jammesg.c @@ -0,0 +1,30 @@ +#include +#include "osint.h" + +s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) +{ + register u32 saveMask = __osDisableInt(); + while (mq->validCount >= mq->msgCount) + { + if (flag == OS_MESG_BLOCK) + { + __osRunningThread->state = OS_STATE_WAITING; + __osEnqueueAndYield(&mq->fullqueue); + } + else + { + __osRestoreInt(saveMask); + return -1; + } + } + + mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount; + mq->msg[mq->first] = msg; + mq->validCount++; + if (mq->mtqueue->next != NULL) + { + osStartThread(__osPopThread(&mq->mtqueue)); + } + __osRestoreInt(saveMask); + return 0; +} diff --git a/src/dk64_boot/os/pidma.c b/src/dk64_boot/os/pidma.c new file mode 100644 index 00000000..c2fa377f --- /dev/null +++ b/src/dk64_boot/os/pidma.c @@ -0,0 +1,32 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern OSDevMgr __osPiDevMgr; + +s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) +{ + register s32 ret; + if (!__osPiDevMgr.active) + return -1; + if (direction == OS_READ) + mb->hdr.type = OS_MESG_TYPE_DMAREAD; + else + mb->hdr.type = OS_MESG_TYPE_DMAWRITE; + mb->hdr.pri = priority; + mb->hdr.retQueue = mq; + mb->dramAddr = dramAddr; + mb->devAddr = devAddr; + mb->size = size; + mb->piHandle = NULL; + if (priority == OS_MESG_PRI_HIGH) + { + ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); + } + else + { + ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); + } + return ret; +} diff --git a/src/dk64_boot/os/recvmesg.c b/src/dk64_boot/os/recvmesg.c new file mode 100644 index 00000000..26509ad3 --- /dev/null +++ b/src/dk64_boot/os/recvmesg.c @@ -0,0 +1,32 @@ +#include +#include "osint.h" + +s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) +{ + register u32 saveMask; + saveMask = __osDisableInt(); + + while (MQ_IS_EMPTY(mq)) + { + if (flags == OS_MESG_NOBLOCK) + { + __osRestoreInt(saveMask); + return -1; + } + __osRunningThread->state = OS_STATE_WAITING; + __osEnqueueAndYield(&mq->mtqueue); + } + + if (msg != NULL) + { + *msg = mq->msg[mq->first]; + } + mq->first = (mq->first + 1) % mq->msgCount; + mq->validCount--; + if (mq->fullqueue->next != NULL) + { + osStartThread(__osPopThread(&mq->fullqueue)); + } + __osRestoreInt(saveMask); + return 0; +} diff --git a/src/dk64_boot/os/resetglobalintmask.c b/src/dk64_boot/os/resetglobalintmask.c new file mode 100644 index 00000000..181dbf83 --- /dev/null +++ b/src/dk64_boot/os/resetglobalintmask.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/os/resetglobalintmask/__osResetGlobalIntMask.s") diff --git a/src/dk64_boot/os/sendmesg.c b/src/dk64_boot/os/sendmesg.c new file mode 100644 index 00000000..b0588ce4 --- /dev/null +++ b/src/dk64_boot/os/sendmesg.c @@ -0,0 +1,31 @@ +#include +#include "osint.h" + +s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) +{ + register u32 saveMask; + register s32 last; + saveMask = __osDisableInt(); + while (MQ_IS_FULL(mq)) + { + if (flags == OS_MESG_BLOCK) + { + __osRunningThread->state = OS_STATE_WAITING; + __osEnqueueAndYield(&mq->fullqueue); + } + else + { + __osRestoreInt(saveMask); + return -1; + } + } + last = (mq->first + mq->validCount) % mq->msgCount; + mq->msg[last] = msg; + mq->validCount++; + if (mq->mtqueue->next != NULL) + { + osStartThread(__osPopThread(&mq->mtqueue)); + } + __osRestoreInt(saveMask); + return 0; +} diff --git a/src/dk64_boot/os/setIntMask.c b/src/dk64_boot/os/setIntMask.c new file mode 100644 index 00000000..9d9c0cff --- /dev/null +++ b/src/dk64_boot/os/setIntMask.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/os/setIntMask/osSetIntMask.s") diff --git a/src/dk64_boot/os/seteventmesg.c b/src/dk64_boot/os/seteventmesg.c new file mode 100644 index 00000000..a95b6158 --- /dev/null +++ b/src/dk64_boot/os/seteventmesg.c @@ -0,0 +1,14 @@ +#include +#include "osint.h" + +__OSEventState __osEventStateTab[OS_NUM_EVENTS]; +void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) +{ + register u32 saveMask = __osDisableInt(); + __OSEventState *es; + + es = &__osEventStateTab[event]; + es->messageQueue = mq; + es->message = msg; + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/os/setglobalintmask.c b/src/dk64_boot/os/setglobalintmask.c new file mode 100644 index 00000000..3fda389a --- /dev/null +++ b/src/dk64_boot/os/setglobalintmask.c @@ -0,0 +1,9 @@ +#include +#include + +void __osSetGlobalIntMask(OSHWIntr mask) +{ + register u32 saveMask = __osDisableInt(); + __OSGlobalIntMask |= mask; + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/os/setthreadpri.c b/src/dk64_boot/os/setthreadpri.c new file mode 100644 index 00000000..fe1e9be8 --- /dev/null +++ b/src/dk64_boot/os/setthreadpri.c @@ -0,0 +1,24 @@ +#include +#include "osint.h" + +void osSetThreadPri(OSThread *t, OSPri pri) +{ + register u32 saveMask = __osDisableInt(); + if (t == NULL) + t = __osRunningThread; + if (t->priority != pri) + { + t->priority = pri; + if (t != __osRunningThread && t->state != OS_STATE_STOPPED) + { + __osDequeueThread(t->queue, t); + __osEnqueueThread(t->queue, t); + } + if (__osRunningThread->priority < __osRunQueue->priority) + { + __osRunningThread->state = OS_STATE_RUNNABLE; + __osEnqueueAndYield(&__osRunQueue); + } + } + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/os/settime.c b/src/dk64_boot/os/settime.c new file mode 100644 index 00000000..4238dc11 --- /dev/null +++ b/src/dk64_boot/os/settime.c @@ -0,0 +1,6 @@ +#include +#include "osint.h" + +void osSetTime(OSTime time) { + __osCurrentTime = time; +} diff --git a/src/dk64_boot/os/settimer.c b/src/dk64_boot/os/settimer.c new file mode 100644 index 00000000..5d168790 --- /dev/null +++ b/src/dk64_boot/os/settimer.c @@ -0,0 +1,19 @@ +#include +#include "osint.h" + +int osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMesg msg) +{ + OSTime time; + t->next = NULL; + t->prev = NULL; + t->interval = interval; + if (value != 0) t->value = value; + else t->value = interval; + t->mq = mq; + t->msg = msg; + time = __osInsertTimer(t); + if (__osTimerList->next == t) { + __osSetTimerIntr(time); + } + return 0; +} diff --git a/src/dk64_boot/os/startthread.c b/src/dk64_boot/os/startthread.c new file mode 100644 index 00000000..8103a989 --- /dev/null +++ b/src/dk64_boot/os/startthread.c @@ -0,0 +1,40 @@ +#include +#include "osint.h" + +void osStartThread(OSThread *t) +{ + register u32 saveMask = __osDisableInt(); + switch (t->state) + { + case OS_STATE_WAITING: + t->state = OS_STATE_RUNNABLE; + __osEnqueueThread(&__osRunQueue, t); + break; + case OS_STATE_STOPPED: + if (t->queue == NULL || t->queue == &__osRunQueue) + { + t->state = OS_STATE_RUNNABLE; + __osEnqueueThread(&__osRunQueue, t); + } + else + { + t->state = OS_STATE_WAITING; + __osEnqueueThread(t->queue, t); + __osEnqueueThread(&__osRunQueue, __osPopThread(t->queue)); + } + break; + } + if (__osRunningThread == NULL) + { + __osDispatchThread(); + } + else + { + if (__osRunningThread->priority < __osRunQueue->priority) + { + __osRunningThread->state = OS_STATE_RUNNABLE; + __osEnqueueAndYield(&__osRunQueue); + } + } + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/os/stopthread.c b/src/dk64_boot/os/stopthread.c new file mode 100644 index 00000000..8095f486 --- /dev/null +++ b/src/dk64_boot/os/stopthread.c @@ -0,0 +1,30 @@ + +#include +#include "osint.h" + +void osStopThread(OSThread *t) +{ + register u32 saveMask = __osDisableInt(); + register u16 state; + if (t == NULL) + { + state = OS_STATE_RUNNING; + } + else + { + state = t->state; + } + switch (state) + { + case OS_STATE_RUNNING: + __osRunningThread->state = OS_STATE_STOPPED; + __osEnqueueAndYield(NULL); + break; + case OS_STATE_RUNNABLE: + case OS_STATE_WAITING: + t->state = OS_STATE_STOPPED; + __osDequeueThread(t->queue, t); + break; + } + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/os/thread.c b/src/dk64_boot/os/thread.c new file mode 100644 index 00000000..660b4495 --- /dev/null +++ b/src/dk64_boot/os/thread.c @@ -0,0 +1,21 @@ +#include +#include "functions.h" +#include "variables.h" + +void __osDequeueThread(OSThread **queue, OSThread *t) +{ + register OSThread *pred; + register OSThread *succ; + pred = (OSThread *)queue; // This is actually legit.. + succ = pred->next; + + while (succ != NULL) { + if (succ == t) { + pred->next = t->next; + return; + } + + pred = succ; + succ = pred->next; + } +} diff --git a/src/dk64_boot/os/timerintr.c b/src/dk64_boot/os/timerintr.c new file mode 100644 index 00000000..d1b293e9 --- /dev/null +++ b/src/dk64_boot/os/timerintr.c @@ -0,0 +1,105 @@ +#include +#include "functions.h" +#include "variables.h" + +extern OSTime __osCurrentTime; +extern u32 __osBaseCounter; +extern u32 __osViIntrCount; +extern u32 __osTimerCounter; +extern OSTimer* __osTimerList; + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/os/timerintr/__osTimerServicesInit.s") + +/* +// TODO: Very close, just issues with temp variables +void __osTimerServicesInit(void) { + __osCurrentTime = 0; + __osBaseCounter = 0; + __osViIntrCount = 0; + __osTimerList->prev = __osTimerList; + __osTimerList->next = __osTimerList->prev; + __osTimerList->value = 0; + __osTimerList->interval = __osTimerList->value; + __osTimerList->mq = NULL; + __osTimerList->msg = NULL; +} +*/ + +// TODO: Are these signatures correct? +void __osSetCompare(u32 t); +void __osSetTimerIntr(OSTime tim); +OSTime __osInsertTimer(OSTimer* t); + +void __osTimerInterrupt(void) { + OSTimer* t; + u32 count; + u32 elapsed_cycles; + if (__osTimerList->next == __osTimerList) { + return; + } + while (1) { + t = __osTimerList->next; + if (t == __osTimerList) { + __osSetCompare(0); + __osTimerCounter = 0; + break; + } + count = osGetCount(); + elapsed_cycles = count - __osTimerCounter; + __osTimerCounter = count; + if (elapsed_cycles < t->value) { + t->value -= elapsed_cycles; + __osSetTimerIntr(t->value); + return; + } else { + t->prev->next = t->next; + t->next->prev = t->prev; + t->next = NULL; + t->prev = NULL; + if (t->mq != NULL) { + osSendMesg(t->mq, t->msg, 0); + } + if (t->interval != 0) { + t->value = t->interval; + __osInsertTimer(t); + } + } + } +} + +void __osSetTimerIntr(OSTime tim) { + OSTime NewTime; + u32 savedMask; + + savedMask = __osDisableInt(); + + __osTimerCounter = osGetCount(); + NewTime = __osTimerCounter + tim; + __osSetCompare(NewTime); + __osRestoreInt(savedMask); +} + +OSTime __osInsertTimer(OSTimer* t) { + OSTimer* timep; + OSTime tim; + u32 savedMask; + + savedMask = __osDisableInt(); + + for (timep = __osTimerList->next, tim = t->value; timep != __osTimerList && tim > timep->value; + tim -= timep->value, timep = timep->next) { + ; + } + t->value = tim; + if (timep != __osTimerList) { + timep->value -= tim; + } + t->next = timep; + t->prev = timep->prev; + timep->prev->next = t; + timep->prev = t; + + __osRestoreInt(savedMask); + + return tim; +} diff --git a/src/dk64_boot/os/virtualtophysical.c b/src/dk64_boot/os/virtualtophysical.c new file mode 100644 index 00000000..824c46e3 --- /dev/null +++ b/src/dk64_boot/os/virtualtophysical.c @@ -0,0 +1,18 @@ +#include + + +u32 osVirtualToPhysical(void *addr) +{ + if (IS_KSEG0(addr)) + { + return K0_TO_PHYS(addr); + } + else if (IS_KSEG1(addr)) + { + return K1_TO_PHYS(addr); + } + else + { + return __osProbeTLB(addr); + } +} \ No newline at end of file diff --git a/src/dk64_boot/os/yieldthread.c b/src/dk64_boot/os/yieldthread.c new file mode 100644 index 00000000..9e1aff6f --- /dev/null +++ b/src/dk64_boot/os/yieldthread.c @@ -0,0 +1,9 @@ +#include +#include "osint.h" + +void osYieldThread(void) { + register u32 saveMask = __osDisableInt(); + __osRunningThread->state = OS_STATE_RUNNABLE; + __osEnqueueAndYield(&__osRunQueue); + __osRestoreInt(saveMask); +} diff --git a/src/dk64_boot/sinf.c b/src/dk64_boot/sinf.c new file mode 100644 index 00000000..a7619610 --- /dev/null +++ b/src/dk64_boot/sinf.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/sinf/sinf.s") diff --git a/src/global_asm/audio/event.c b/src/global_asm/audio/event.c new file mode 100644 index 00000000..98fc2692 --- /dev/null +++ b/src/global_asm/audio/event.c @@ -0,0 +1,132 @@ +#include +#include "functions.h" +#include "variables.h" + +void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount) + +{ + s32 i; + + evtq->eventCount = 0; + evtq->allocList.next = 0; + evtq->allocList.prev = 0; + evtq->freeList.next = 0; + evtq->freeList.prev = 0; + + for (i = 0; i < itemCount; i++) { + alLink((ALLink *)&items[i], &evtq->freeList); + } +} + +ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt) +{ + ALEventListItem *item; + ALMicroTime delta; + OSIntMask mask; + + mask = osSetIntMask(OS_IM_NONE); + + item = (ALEventListItem *)evtq->allocList.next; + + if (item) + { + alUnlink((ALLink *)item); + bcopy(&item->evt, evt, sizeof(*evt)); + alLink((ALLink *)item, &evtq->freeList); + delta = item->delta; + } + else + { + /* sct 11/28/95 - If we get here, most like we overflowed the event queue */ + /* with non-self-perpetuating events. Eg. if we filled the evtq with volume */ + /* events, then when the seqp is told to play it will handle all the events */ + /* at once completely emptying out the queue. At this point this problem */ + /* must be treated as an out of resource error and the evtq should be increased. */ + evt->type = -1; + delta = 0; + } + + osSetIntMask(mask); + + return delta; +} + +void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta) +{ + ALEventListItem *item; + ALEventListItem *nextItem; + ALLink *node; + s32 postAtEnd=0; + OSIntMask mask; + + mask = osSetIntMask(OS_IM_NONE); + + item = (ALEventListItem *)evtq->freeList.next; + if (!item) { + osSetIntMask(mask); + #ifdef _DEBUG + __osError(ERR_ALEVENTNOFREE, 0); + #endif + return; + } + + alUnlink((ALLink *)item); + bcopy(evt, &item->evt, sizeof(*evt)); + + if (delta == AL_EVTQ_END) + postAtEnd = -1; + + for (node = &evtq->allocList; node != 0; node = node->next) { + if (!node->next) { /* end of the list */ + if (postAtEnd) + item->delta = 0; + else + item->delta = delta; + alLink((ALLink *)item, node); + break; + } else { + nextItem = (ALEventListItem *)node->next; + + if (delta < nextItem->delta) { + item->delta = delta; + nextItem->delta -= delta; + + alLink((ALLink *)item, node); + break; + } + + delta -= nextItem->delta; + + } + } + + osSetIntMask(mask); +} + +void alEvtqFlushType(ALEventQueue *evtq, s16 type) +{ + ALLink *thisNode; + ALLink *nextNode; + ALEventListItem *thisItem, *nextItem; + OSIntMask mask; + + mask = osSetIntMask(OS_IM_NONE); + + thisNode = evtq->allocList.next; + while( thisNode != 0 ) + { + nextNode = thisNode->next; + thisItem = (ALEventListItem *)thisNode; + nextItem = (ALEventListItem *)nextNode; + if (thisItem->evt.type == type) + { + if (nextItem) + nextItem->delta += thisItem->delta; + alUnlink(thisNode); + alLink(thisNode, &evtq->freeList); + } + thisNode = nextNode; + } + + osSetIntMask(mask); +} diff --git a/src/global_asm/audio/link.c b/src/global_asm/audio/link.c new file mode 100644 index 00000000..a9251569 --- /dev/null +++ b/src/global_asm/audio/link.c @@ -0,0 +1,21 @@ +#include +#include "functions.h" +#include "variables.h" + +/* might want to make these macros */ +void alLink(ALLink *ln, ALLink *to) +{ + ln->next = to->next; + ln->prev = to; + if (to->next) + to->next->prev = ln; + to->next = ln; +} + +void alUnlink(ALLink *ln) +{ + if (ln->next) + ln->next->prev = ln->prev; + if (ln->prev) + ln->prev->next = ln->next; +} diff --git a/src/global_asm/audio/n_sl.c b/src/global_asm/audio/n_sl.c new file mode 100644 index 00000000..1c855e1d --- /dev/null +++ b/src/global_asm/audio/n_sl.c @@ -0,0 +1,26 @@ +#include +#include "functions.h" +#include "variables.h" + +extern N_ALGlobals *n_alGlobals=0; +extern N_ALSynth *n_syn; + +void n_alInit(N_ALGlobals *g, ALSynConfig *c) +{ + if (!n_alGlobals) { /* already initialized? */ + n_alGlobals = g; + if (!n_syn) { + n_syn = &n_alGlobals->drvr; + n_alSynNew(c); //n_alSynNew(c); + } + } +} + +void n_alClose(N_ALGlobals *glob) +{ + if (n_alGlobals) { + n_alSynDelete();//n_alSynDelete(); + n_alGlobals = 0; + n_syn = 0; + } +} diff --git a/src/global_asm/audio/n_syndelete.c b/src/global_asm/audio/n_syndelete.c new file mode 100644 index 00000000..608a2e77 --- /dev/null +++ b/src/global_asm/audio/n_syndelete.c @@ -0,0 +1,9 @@ +#include +#include "functions.h" +#include "variables.h" + +extern N_ALSynth *n_syn; + +void n_alSynDelete(void) { + n_syn->head = NULL; +} diff --git a/src/global_asm/audio/seqpsetseq.c b/src/global_asm/audio/seqpsetseq.c new file mode 100644 index 00000000..bd8d88ef --- /dev/null +++ b/src/global_asm/audio/seqpsetseq.c @@ -0,0 +1,13 @@ +#include +#include "functions.h" +#include "variables.h" + +void alSeqpSetSeq(ALSeqPlayer *seqp, ALSeq *seq) +{ + ALEvent evt; + + evt.type = AL_SEQP_SEQ_EVT; + evt.msg.spseq.seq = seq; + + alEvtqPostEvent(&seqp->evtq, &evt, 0); +} diff --git a/src/global_asm/audio/seqpsetvol.c b/src/global_asm/audio/seqpsetvol.c new file mode 100644 index 00000000..c8bdb5a9 --- /dev/null +++ b/src/global_asm/audio/seqpsetvol.c @@ -0,0 +1,13 @@ +#include +#include "functions.h" +#include "variables.h" + +void alSepqSetVol(ALSeqPlayer *seqp, s16 vol) +{ + ALEvent evt; + + evt.type = AL_SEQP_VOL_EVT; + evt.msg.spvol.vol = vol; + + alEvtqPostEvent(&seqp->evtq, &evt, 0); +} diff --git a/src/global_asm/audio/seqpstop.c b/src/global_asm/audio/seqpstop.c new file mode 100644 index 00000000..62fbfc0b --- /dev/null +++ b/src/global_asm/audio/seqpstop.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + +void alSeqpStop(ALSeqPlayer *seqp) { + ALEvent evt; + + evt.type = AL_SEQP_STOPPING_EVT; + alEvtqPostEvent(&seqp->evtq, &evt, 0); +} diff --git a/src/global_asm/audio/synthesizer.c b/src/global_asm/audio/synthesizer.c new file mode 100644 index 00000000..ac6a9ac2 --- /dev/null +++ b/src/global_asm/audio/synthesizer.c @@ -0,0 +1,92 @@ +#include +#include "functions.h" +#include "variables.h" +#include "synthinternal.h" + +//n_alSynNew +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/audio/synthesizer/n_alSynNew.s") + +//n_alAudioFrame +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/audio/synthesizer/n_alAudioFrame.s") + +ALParam *__n_allocParam(void) { + ALParam *update = 0; + + if (n_syn->paramList) { + update = n_syn->paramList; + n_syn->paramList = n_syn->paramList->next; + update->next = 0; + } + return update; +} + +void __n_freeParam(ALParam *param) +{ + param->next = n_syn->paramList; + n_syn->paramList = param; +} + +void _n_collectPVoices() +{ + ALLink *dl; + PVoice *pv; + + while ((dl = n_syn->pLameList.next) != 0) { + pv = (PVoice *)dl; + + /* ### remove from mixer */ + + alUnlink(dl); + alLink(dl, &n_syn->pFreeList); + } +} + +void _n_freePVoice(PVoice *pvoice) +{ + /* + * move the voice from the allocated list to the lame list + */ + alUnlink((ALLink *)pvoice); + alLink((ALLink *)pvoice, &n_syn->pLameList); +} + +/* + Add 0.5 to adjust the average affect of + the truncation error produced by casting + a float to an int. +*/ +s32 _n_timeToSamplesNoRound(s32 micros) +{ + + f32 tmp = ((f32)micros) * n_syn->outputRate / 1000000.0f + 0.5f; + + return (s32)tmp; +} + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/audio/synthesizer/func_80739E24.s") +#else +// s32 _timeToSamples(ALSynth *synth, s32 micros) +s32 func_80739E24(s32 micros) +{ return _n_timeToSamplesNoRound(micros) & ~0xf; +} +#endif + +static s32 __n_nextSampleTime(ALPlayer **client) +{ + s32 pad; + ALMicroTime delta = 0x7fffffff; /* max delta for s32 */ + ALPlayer *cl; + + //assert(n_syn->head); + *client = 0; + + for (cl = n_syn->head; cl != 0; cl = cl->next) { + if ((cl->samplesLeft - n_syn->curSamples) < delta) { + *client = cl; + delta = cl->samplesLeft - n_syn->curSamples; + } + } + + return (*client)->samplesLeft; +} diff --git a/src/global_asm/code_0.c b/src/global_asm/code_0.c new file mode 100644 index 00000000..f0d938fb --- /dev/null +++ b/src/global_asm/code_0.c @@ -0,0 +1,693 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 *D_8076A080; +extern s32 D_807FF100; +extern s32 D_8000DDE4; +extern s32 D_8076A084; +extern u8 D_807467CC; +extern u8 D_8076A0B2; +extern s32 D_80769018; +extern u16 D_8076A09C; +extern f32 D_807444B8; +extern f32 D_807444BC; +extern f32 D_807444C4; +extern f32 D_807444C8; +extern u8 D_8076A0B1; // map_state +extern u8 D_8076A0B3; // cutscene_bar_state + +extern u8 D_80746830; +extern s32 D_8076A090; +extern s32 D_8076A094; +extern s32 D_8076A098; +extern u16 D_80750AC4; +extern u8 D_8076A0A4; +extern u8 D_807444FC; +extern s32 D_8076A068; +extern u16 *D_807ECDF4; +extern s32 D_8076A06C; +extern u8 D_80744500; +extern u8 D_80750AC0; // number_of_players? +extern s32 D_807F6010; +extern s32 *D_8076A0A0; +extern s16 D_8076A0AA; +extern s32 next_exit; +extern s32 D_806025AC; +extern u8 D_807F6008; +extern u8 D_80745BDC[]; // Might be a struct array +extern f32 D_807565D8; +extern f32 D_807FD888; // loading_zone_fadeout_progress +extern f32 loading_zone_transition_speed; +extern u8 D_807444F8; +extern u8 loading_zone_transition_type; + +extern s32 D_80767E68; +extern Mtx D_80767CE8; +extern Mtx D_80768E98; + +f32 func_8062A850(void); +void func_8060B140(s32, s32*, s32*, s32, s32, s32, s32); +void func_8060AA04(); +void func_80631B80(); +void func_806C9AE0(); +void func_80731030(); +void func_805FF118(); +void func_8063DB0C(); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FB300.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FB5C4.s") + +extern s32 D_8000DDCC; +extern OSIoMesg D_807ECE00; +extern OSMesgQueue D_807655F0; +extern OSMesg D_80765608; + +extern OSMesgQueue D_807656D0; +extern OSMesg D_807656E8; + +extern OSMesgQueue D_807659E8; +extern OSMesg D_80765A00; + +extern OSMesg D_8076A128; +extern OSMesg D_8076A108; + +extern OSTimer D_8076A130; + +void func_805FB750(s32 arg0, s32 arg1, s32 arg2) { + s32 sp2C; + + sp2C = D_8000DDCC; + osWritebackDCache(arg2, arg1); + osPiStartDma(&D_807ECE00, 0, 0, sp2C + arg0, arg2, arg1, &D_807655F0); + osRecvMesg(&D_807655F0, 0, 1); + osInvalDCache(arg2, arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FB7E4.s") + +void func_805FB944(s32 arg0); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FB944.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FBC5C.s") + +extern s32 D_8076A07C; +extern OSMesgQueue D_8076A110; +extern s32 D_8000DDE8; +extern s32 D_8000DDE4; + +extern s32 D_80767A40; +extern s32 D_80767CD8; + +/* +// TODO: Pretty close +void func_805FBC5C(void) { + // This might be a static struct field access + D_8076A084 = D_8000DDE8 - D_8000DDE4; + osCreateMesgQueue(&D_807655F0, &D_80765608, 0x32); + osCreateMesgQueue(&D_807656D0, &D_807656E8, 0xC0); + func_8060EC80(&D_80767A40, &D_80767A40, 0x19, osTvType, 1); + osCreateMesgQueue(&D_807659E8, &D_80765A00, 0x10); + func_8060ED6C(&D_80767A40, &D_80767CD8, &D_807659E8, 1, 1); + current_map = next_map; + func_805FB944(0); + D_8076A07C = 5; + func_8060FFF0(); + func_8060A900(); + func_80600D50(); + setIntroStoryPlaying(0); + func_8073239C(); + osWriteBackDCacheAll(); + osCreateMesgQueue(&D_8076A110, &D_8076A108, 2); + osSetTimer(&D_8076A130, 0, 0xD693A4, &D_8076A110, D_8076A128); + playSound(0x23C, 0x7FFF, 63.0f, 1.0f, 0, 0); +} +*/ + +void func_805FBE04(void) { + s32 stackpad1; + f32 FOV; + + osWriteBackDCacheAll(); + osInvalDCache(0x80000000, 0x800000); + D_8076A080 = &D_807FF100; + func_8060B140(D_8000DDE4, D_8076A080, &D_8076A084, 0, 0, 0, 0); + D_8076A0A4 = 0; + func_8060AA04(); + object_timer = 0; + D_8076A068 = 0; + D_807467CC = 0; + current_exit = 4; + global_properties_bitfield = 0x30030; + D_8076A0B1 |= 1; + D_8076A0B2 = 0; + D_807FD888 = 31.0f; // loading_zone_fadeout_progress + D_8076A0B1 |= 4; + func_80631B80(); + func_806C9AE0(); + func_80731030(); + func_805FF118(); + func_8063DB0C(); + FOV = func_8062A850(); // getFieldOfView() + guTranslate(&D_80767E68, 0.0f, 0.0f, 0.0f); + guTranslate(&D_80769018, 0.0f, 0.0f, 0.0f); + guPerspective(&D_80767CE8, &D_8076A09C, D_807444B8, D_807444BC * FOV, D_807444C8, D_807444C4, 1.0f); + guPerspective(&D_80768E98, &D_8076A09C, D_807444B8, D_807444BC * FOV, D_807444C8, D_807444C4, 1.0f); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FBFF4.s") + +extern s32 D_8076A070; +extern s32 osTvType; +extern s8 D_80744460; +extern u16 D_8074682C; +extern u8 D_80744504; +extern u8 D_807F059C; +extern u64 D_80761680; +extern s32 D_807655E0; +extern u8 D_807444F0; +extern s32 D_80767CC0; + +void func_80732354(u8, s32, s32, s32); + +/* +// TODO: Remarkably close, just missing some NOPs +void func_805FBFF4(s32 arg0) { + s32 phi_s4; + OSMesg* sp38; + + phi_s4 = 1; + if (osTvType == OS_TV_PAL) { + D_807444BC = 1.25f; + } + func_805FBC5C(); + osViSetSpecialFeatures(0x42); + func_805FBE04(); + D_8076A070 = D_80767CC0 - 2; + osRecvMesg(&D_8076A110, &sp38, 1); + while (TRUE) { + D_8074682C = 0xC8; + + while (D_80744460) {} + + if (D_8076A0B1 & 1 && !D_8076A0B2) { + func_805FE7FC(); + if (D_807444F8 == 2) { + global_properties_bitfield |= 0x200; + D_80744504 = 8; + } + } + + switch (is_cutscene_active) { + case 6: + func_8070A934(next_map, next_exit); + break; + case 3: + func_80024000(); + break; + case 4: + func_80024000(); + break; + case 5: + break; + default: + func_805FC2B0(); + break; + } + + func_80600B10(); + func_8066AF40(); + func_80610268(0x4D2); + if (D_807F059C) { + func_80610268(0x929); + } + func_80600674(); // calculateLagBoost() + if ((is_cutscene_active == 0) || (is_cutscene_active == 1) || (is_cutscene_active == 7)) { + func_80658CCC(); + func_80700BF4(); + } + func_80611730(); + if (D_80761680 != 0x12345678) { + func_80732354(2, 0, 0, 0); + } + if (phi_s4) { + osSendMesg(D_807655E0, 0x309, 1); + phi_s4 = 0; + } + if (D_8076A0B1 & 1 && D_807FD888 == 31.0f) { + D_8076A0B2--; + } + D_807444F0 = is_cutscene_active; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FC2B0.s") + +extern s32 *D_8076A048; +extern s32 D_8076A050[]; +extern s32 D_8076A150; +extern s32 D_8076A088; +extern s32 D_8076A08C; +void func_8068C2EC(); + +/* +void func_805FC2B0(void) { + s32 sp2C; + s32 sp28; + s32 temp_v0; + s32 phi_v0; + + func_8060A9BC(); + if (D_8076A0A4 != 0) { + phi_v0 = 0; + } else { + phi_v0 = 1; + } + //func_80610044(((*0x807444FC * 4) + 0x80770000)->unk-5FB0, D_8076A088, 3, phi_v0 & 0xFF, 0x4D2, 1); + if (D_8076A0A4 != 0) { + //func_80610044((D_807444FC * 0x11B0) + 0xDB0 + &D_80767CE8, D_8076A08C, 0, 1, 0x929, 1); + } + D_807444FC ^= 1; + object_timer++; + if ((global_properties_bitfield & 2) == 0) { + D_8076A068++; + } + *D_8076A048 = (D_807444FC * 0x11B0) + &D_80767CE8; + func_8060AC7C(); + if (func_805FC668() != 0) { + func_8065D1AC(); + func_806789E4(); + func_80715270(1); + func_80603450(); + func_806057F8(); + func_806025D4(); + func_805FCA94(D_8076A048); + } else { + func_8065A648(); + func_806787CC(); + func_805FCA94(D_8076A048); + func_8065D1AC(); + func_8068A508(); + func_8066CDD0(); + func_8066CCD8(); + func_80661054(); + func_80678824(); + func_80663A80(); + func_80715270(0); + func_80603450(); + func_806025D4(); + func_806057F8(); + func_806F6F28(); + } + func_8070DD44(); + temp_v0 = *(&D_8076A050 + (D_807444FC * 4)); + //temp_v0 = D_8076A050[D_807444FC * 4]; + D_8076A150 = temp_v0; + if (((D_8076A0B1 & 1) != 0) && (D_807FD888 == 31.0f)) { + sp2C = temp_v0; + sp28 = D_8076A048 + 0xDB0; + func_8068C2EC(); + } else { + func_805FD088(D_8076A048, &sp2C, &sp28); + } + if ((global_properties_bitfield & 0x100) != 0) { + global_properties_bitfield &= ~0x100; + func_807094D0(2, &global_properties_bitfield); + } else if ((global_properties_bitfield & 0x200) != 0) { + D_80744504--; + if (D_80744504 == 0) { + global_properties_bitfield &= ~0x200; + func_807094D0(3, &global_properties_bitfield); + } + } else { + sp2C = func_80704484(sp2C, loading_zone_transition_type); + } + if ((D_8076A0A4 != 0) && (is_cutscene_active != 6)) { + func_805FE71C(sp2C, D_807444FC, &D_8076A088, 0); + func_805FE7B4(sp28, D_8076A048, &D_8076A08C, 1); + return; + } + func_805FE71C(sp2C, D_807444FC, &D_8076A088, 1); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FC668.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FC98C.s") + +u64 func_80005818(u64, f32, u32); +u64 func_80005918(s32, u32, f32, u32); +extern s32 D_807445B8; // OSTime? +extern u32 D_807445BC; +extern s32 D_807445C0; // OSTime? +extern u32 D_807445C4; +extern s32 D_80750AB0; + +/* +// TODO: 64 bit nonsense +s32 func_805FC98C(void) { + u32 sp1C; + s32 sp18; + s32 temp_t8; + u32 temp_t7; + u32 temp_t9; + OSTime currentTime; + + currentTime = osGetTime(); + temp_t8 = (currentTime - D_807445B8) - (currentTime < D_807445BC); + temp_t9 = currentTime - D_807445BC; + sp1C = temp_t9; + sp18 = temp_t8; + if (global_properties_bitfield & 2) { + temp_t9 = (temp_t9 - currentTime) + D_807445C4; + sp18 = (temp_t9 < D_807445C4) + ((temp_t8 - currentTime) - (temp_t9 < currentTime)) + D_807445C0; + sp1C = temp_t9; + } + return func_80005818(func_80005818(func_80005918(sp18, sp1C, 0, 0x40), 0, 3000), 0, 1000000) + D_80750AB0; +} +*/ + +u8 func_805FCA64(void) { // getCutsceneBarState() + return !(D_8076A0B1 & 0x10) && !D_8076A0B3; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FCA94.s") + +extern u8 D_8074450C; + +/* rom */ +extern Gfx **D_1000020; +extern Gfx **D_1000030; +extern Gfx **D_1000068; +extern Gfx **D_1000040; + +void *func_805FCFD8(Gfx *arg0) { + if (D_8074450C == 2) { + gSPDisplayList(arg0++, &D_1000068); + } else { + gSPDisplayList(arg0++, &D_1000040); + } + return arg0++; +} + +void *func_805FD030(Gfx *arg0) { + if (D_8074450C == 2) { + gSPDisplayList(arg0++, &D_1000030); + } else { + gSPDisplayList(arg0++, &D_1000020); + } + return arg0++; +} + +// display list something +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FD088.s") + +// display list something? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FE398.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FE4D4.s") + +extern s32 D_8076A058; + +void func_805FE544(u8 arg0) { + if (D_807FBB64 & 1) { + D_8076A058 = 6000; + } else { + D_8076A058 = arg0 * 3000; + } + D_8076A050[0] = malloc(D_8076A058 * 8); + D_8076A050[1] = malloc(D_8076A058 * 8); + func_805FE71C(func_805FE634(D_8076A050[0], 0), 0, &D_8076A088, 1); + func_805FE71C(func_805FE634(D_8076A050[1], 1), 1, &D_8076A088, 1); +} + +// display list something? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FE634.s") + +// display list something? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FE71C.s") + +// display list something? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FE7B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_0/func_805FE7FC.s") + +void func_80712A40(void); +void func_80605510(void); +void func_8068C080(void); +void func_8070F570(void); +void func_80600950(void); + +void func_8060A4D0(s32 arg0, f32 arg1); + +void func_8066ADA0(void); +void func_806FBB58(void); +void func_806FD9A0(void); + +void func_807040E0(u8 arg0, u8 arg1, u8 arg2); +void func_80704108(u8 arg0, u8 arg1, u8 arg2); + +void func_80705B30(); +void func_807215EC(); +void func_806F3760(s16 map); +void func_8072ED90(); +void func_80658BD0(); +void func_80722E00(s32 map); + +void func_80630300(); +void func_80650E20(s32 arg0); +void func_8062F050(s32 arg0); +void func_8065D170(); +void func_806588E0(s32 arg0); +void func_80688940(); +void func_80631C3C(); +void func_8063643C(); + +void func_806C7C10(void); +void func_806D0430(f32 arg0); +void func_805FE544(u8 arg0); + +void func_80631FAC(Maps arg0, s32 arg1); +void func_806886E0(s32 arg0, s32 arg1, s32 arg2); +void func_80663DA0(); +void func_8065A570(); +void func_80677D80(); +void func_8068A7B0(); +void func_8072E740(s32 arg0); + +void func_80626264(s32); +void func_8066B434(void*, s32, s32); +void func_80712B80(); +void func_806C7D40(s32 arg0); +void func_80714670(); + +void func_80724C78(s32 arg0); +void func_8061EA78(); +void func_806F4778(); +void func_8070E8C8(); +void func_8060098C(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); + +void func_80026FD0(s32 arg0); +void func_8002EC08(s32 arg0); + +void func_8066BDE0(void); + +void func_80701C90(void); +void func_80629190(void); +void func_80664CB0(s32 arg0); +void func_80600590(s32 arg0); + +void func_806641A0(); + +void func_80712BD4(); +void func_805FF670(); + +/* +// TODO: Regalloc, oof +void func_805FE7FC(void) { + s32 *mapGeometry; + s32 *sp28; + s32 *mapSetup; + f32 phi_f0; + + D_80746830 = 1; + D_8076A090 = 0; + D_8076A094 = 0; + D_8076A098 = 0; + global_properties_bitfield &= 0xFFEB3FFC; + func_80712A40(); + D_80750AC4 = 0; + D_8076A0A4 = 0; + D_807444FC = 0; + object_timer = 0; + D_8076A068 = 0; + func_80605510(); + enemies_killed = 0; + *D_807ECDF4 = 0; + func_8068C080(); + D_8076A0B1 &= 0xFFCF; + func_8070F570(); + if (is_cutscene_active == 1) { + is_cutscene_active = 0; + } + D_8076A06C = object_timer; + D_80744500 = 0; + func_80600950(); + current_map = next_map; + + if (current_map != MAP_MAIN_MENU) { + if (current_map != MAP_TITLE_SCREEN_NOT_FOR_RESALE_VERSION) { + global_properties_bitfield |= 0x30030; + } else { + global_properties_bitfield &= 0xFFFCFFCF; + } + } else { + global_properties_bitfield &= 0xFFFEFFCF; + } + + if (current_map == MAP_DK_ARCADE) { + is_cutscene_active = 3; + } else if (current_map == MAP_JETPAC) { + is_cutscene_active = 4; + } else { + is_cutscene_active = 0; + } + + func_805FB944(1); + // TODO: Proper bitfield syntax for D_807FBB64 + if (D_80750AC0 >= 2 && D_807FBB64 << 5 >= 0) { + D_80750AC0 = 1; + } + func_806C7C10(); + func_806D0430(0.0f); + func_805FE544(D_80750AC0); + + if (current_map != MAP_ENGUARDE_ARENA) { + if (current_map == MAP_RAMBI_ARENA) { + current_character_index[0] = 6; + } + } else { + current_character_index[0] = 7; + } + + D_807F6010 = 0; + func_8066ADA0(); + func_806FBB58(); + func_806FD9A0(); + func_807040E0(0xFF, 0xFF, 0xFF); + func_80704108(0xFF, 0xFF, 0xFF); + if (!is_cutscene_active) { + D_8076A0A0 = getPointerTableFile(0x13, MAP_TEST_MAP, 1, 1); + func_80705B30(); + func_807215EC(); + func_806F3760(current_map); // Load autowalk file + func_8072ED90(); + func_80658BD0(); + func_80722E00(current_map); // Load path file + mapGeometry = getPointerTableFile(1, current_map, 1, 1); + func_80630300(); + func_80650E20(mapGeometry); + func_8062F050(mapGeometry); + loadExits(current_map); + func_8065D170(); + func_806588E0(current_map); // Load per map file, pointer table 20 + func_80688940(); + func_80631C3C(); + func_8063643C(); + mapSetup = getPointerTableFile(9, current_map, 1, 1); + func_80631FAC(current_map, 1); + func_806886E0(mapSetup, 0, 0); + func_80663DA0(); + func_8065A570(); + func_80677D80(); + func_8068A7B0(); // spawnPersistentActors() + func_8072E740(current_map); + func_80626264(sp28 = getPointerTableFile(8, current_map, 1, 1)); + if (sp28) { + func_8066B434(sp28, 0x8D0, 2); + } + func_80712B80(); + func_806C7D40(next_exit); + func_80714670(); + sp28 = getPointerTableFile(0x10, current_map, 1, 1); + func_80724C78(sp28); + if (sp28) { + func_8066B434(sp28, 0x8DD, 2); + } + func_8061EA78(); + func_8068C2EC(); + func_806F4778(); + func_8070E8C8(); + func_8060098C(&D_806025AC, 2, 0, 0, 0); + if (D_807FBB64 & 0x1000) { + sp28 = getPointerTableFile(0x16, current_map, 1, 1); + func_80026FD0(sp28); + if (sp28) { + func_8066B434(sp28, 0x8ED, 2); + } + } + if (D_807FBB64 & 0x2000) { + func_8002EC08(current_map); + } + func_8066BDE0(); + D_807F6008 = 0; + if (!isIntroStoryPlaying() && is_cutscene_active != 2) { + if (current_map == MAP_HELM && isFlagSet(0x302, FLAG_TYPE_PERMANENT)) { + playSong(0x74, 1.0f); + } else { + phi_f0 = 1.0f; + if (D_80745BDC[current_map * 4] == 6 || D_80745BDC[current_map * 4] == 0x1F) { + phi_f0 = D_807565D8; + } + playSong(D_80745BDC[current_map * 4], phi_f0); + } + } + if (current_map == MAP_DK_ISLES_OVERWORLD || current_map == MAP_ENGUARDE_ARENA) { + playSong(0x60, 1.0f); + } + func_8060A4D0(0, 1.0f); + func_8060A4D0(1, 1.0f); + func_8060A4D0(2, 1.0f); + func_805FFEF8(current_map); + func_806641A0(); + } + func_80712BD4(); + func_805FF670(); + D_8076A0B1 ^= 1; + D_807FD888 = 31.0f; + D_8076A0B1 |= 4; + loading_zone_transition_speed = -1.0f; + if (D_807444F8 != 2 && loading_zone_transition_type == 1) { + playSong(0x2B, 1.0f); + } + func_80701C90(); + func_80629190(); + func_80664CB0(D_8076A0AA); + func_80600590(current_map); + D_80746830 = 0; +} +*/ + +extern u8 D_8074447C; +extern u8 D_80744480; +extern u8 D_80744484; +extern u8 D_80744488; + +void func_805FEE84(u8 arg0, u8 arg1, u8 arg2, u8 arg3) { + D_8074447C = arg0; + D_80744480 = arg1; + D_80744484 = arg2; + D_80744488 = arg3; +} + +void func_805FEEB8(s32 *arg0, s32 arg1) { + s32 temp_hi; + + temp_hi = *arg0 % arg1; + if (temp_hi) { + *arg0 += arg1 - temp_hi; + } +} diff --git a/src/global_asm/code_100180.c b/src/global_asm/code_100180.c new file mode 100644 index 00000000..8b673229 --- /dev/null +++ b/src/global_asm/code_100180.c @@ -0,0 +1,71 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806FB480(void) { + +} + +void func_806FB488(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FB490.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FB714.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FB8B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FB914.s") + +extern s32 *D_807FD7F0; // Array of 43 texture pointers +extern u8 *D_807FD7F4; // Array of 43 u8's + +void func_806FBB58() { + D_807FD7F0 = malloc(sizeof(s32) * 43); + func_80611690(D_807FD7F4 = malloc(sizeof(u8) * 43)); +} + +s32 func_806FBB9C(s16 textureIndex) { + if (!D_807FD7F4[textureIndex]) { + // Texture + D_807FD7F0[textureIndex] = getPointerTableFile(0xE, textureIndex, 1, 1); + D_807FD7F4[textureIndex] = 3; + } else { + D_807FD7F4[textureIndex] = 3; + } + return D_807FD7F0[textureIndex]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FBC34.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FBD5C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FBEAC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FBEF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FC530.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FCC88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FD094.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FD490.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FD7A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_100180/func_806FD894.s") + +/* +extern s32 D_80754A36; +u8 func_806FD894(s16 arg0) { + s16 temp; + + temp = arg0; + if (arg0 & 0x80) { + temp = (s16) (arg0 ^ 0x80); + } + return *(&D_80754A36 + (((temp * 4) - temp) * 2)); +} +*/ diff --git a/src/global_asm/code_10130.c b/src/global_asm/code_10130.c new file mode 100644 index 00000000..07bf43eb --- /dev/null +++ b/src/global_asm/code_10130.c @@ -0,0 +1,148 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s16 D_807463A0; +extern void *D_807463A8; // DKTV Inputs - Camera + Stick +extern s16 D_807463AC; +extern s16 D_807463B0; +extern s16 D_807463B4; + +extern u8 D_807ECE30; +extern void *D_807ECE90; // DKTV Inputs - Buttons +extern void *D_807ECE94; +extern s16 *D_807ECE98; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10130/func_8060B430.s") + +/* +// Very doable, datatype nonsense +void func_8060B430(void *arg0, void *arg1) { + void *temp_a1; + + arg0->unk7C = arg1->unk0; + temp_a1 = arg1 + 0x12; + arg0->unk80 = arg1->unk4; + arg0->unk84 = temp_a1->unk-A; + arg0->unkE6 = temp_a1->unk-6; + memcpy(&D_807FC950->character_progress[temp_a1->unk-2], temp_a1, 0x5E); +} +*/ + +s16 func_8060B49C(s32 arg0, s32 arg1) { + is_autowalking = 2; + func_8060B430(arg0, &D_807ECE20); + return D_807463B0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10130/func_8060B4D4.s") + +/* +// Very doable, datatype nonsense +void func_8060B4D4(void *arg0) { + if (D_807463AC < (D_807463B0 - 1)) { + arg0->unk2 = D_807ECE98->unk2; + arg0->unk3 = D_807ECE98->unk3; + if (D_807ECE98->unk0 & 0x8000) { + D_807463B4 = *D_807ECE94; + D_807ECE94 += 2; + } + arg0->unk0 = D_807463B4 & 0xEFFF; + } +} +*/ + +void func_8060B55C(s16 *arg0) { + if (D_807463AC < (D_807463B0 - 1)) { + *arg0 = *D_807ECE98 & 0x7FFF; + D_807ECE98 += 2; + D_807463AC++; + return; + } + is_autowalking = 0; +} + +void func_8060B5C0(u8 *file) { + s32 size; + + // Allocate buffer for camera + stick inputs + if (!D_807463A8) { + D_807463A8 = malloc(1800 * sizeof(u32)); + } + D_807ECE98 = D_807463A8; + + // Allocate buffer for button inputs + if (!D_807ECE90) { + D_807ECE90 = malloc(1800 * sizeof(u16)); + } + D_807ECE94 = D_807ECE90; + + // Read the number of camera + stick inputs + memcpy(&D_807463B0, file, sizeof(u16)); + file += sizeof(u16); + size = D_807463B0 * sizeof(u32); + + // Read the camera + stick inputs + memcpy(D_807463A8, file, size); + file += size; + + // Read the number of button inputs + memcpy(&D_807463A0, file, sizeof(u16)); + file += sizeof(u16); + size = D_807463A0 * sizeof(u16); + + // Read the button inputs + memcpy(D_807ECE90, file, size); + file += size; + + // Read the extra data + memcpy(&D_807ECE20, file, 0x70); + + // TODO: This is dumb, fix it + //[3:01 PM] I***: They wouldn't have written that right? + //[3:01 PM] M***: no, but they may have set size to that 0x70 in someway + //[3:02 PM] M***: or may have used a macro to advance the buffer pointer that would have referenced size and then never used it + if (size); +} + +void func_8060B6CC(void) { + D_807463A8 = NULL; + D_807ECE90 = NULL; + D_807463AC = 0; + D_807463B0 = 0; + D_807463A0 = 0; + is_autowalking = 0; +} + +void func_8060B700(void) { + if (D_807463A8) { + func_8061130C(D_807463A8); + } + if (D_807ECE90) { + func_8061130C(D_807ECE90); + } + func_8060B6CC(); +} + +void func_8060B750(s32 fileIndex) { + void* file; + + // DK TV Inputs + file = getPointerTableFile(0x11, fileIndex, 1, 1); + func_8060B5C0(file); + func_8066B434(file, 0xF8, 0x33); + D_807ECE98 = D_807463A8; + D_807ECE94 = D_807ECE90; + D_807463AC = 0; + D_807463B4 = 0; +} + +// This is assigned to current_character_index +u8 func_8060B7C4(void) { + return D_807ECE30; +} + +void func_8060B7D0(s32 *mapPointer, s32 *exitPointer) { + *mapPointer = D_807ECE20.map; + *exitPointer = D_807ECE20.exit; +} diff --git a/src/global_asm/code_1025E0.c b/src/global_asm/code_1025E0.c new file mode 100644 index 00000000..a5e833ad --- /dev/null +++ b/src/global_asm/code_1025E0.c @@ -0,0 +1,269 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FD8E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FD950.s") + +extern s16 D_80744490; +extern s16 D_80744494; + +extern s32 D_80754AD0; // TODO: Might be an pointer to/array of structs of type GlobalASMStruct2 +extern u16 D_80754AD4; + +extern f32 D_8075DFB0; +extern f32 D_8075DFB4; + +extern u8 D_807FD890; +extern u16 D_807FD892; +extern u8 D_807FD894; +extern u8 D_807FD895; +extern u8 D_807FD896; +extern u8 D_807FD897; +extern u8 D_807FD898; +extern u8 D_807FD899; +extern s32 D_807FD8A0; +extern Mtx D_807FD928; +extern f32 D_807FD968; +extern s32 D_807FD978; + +void func_806FD9A0(void) { + D_80754AD0 = 0; + D_80754AD4 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FD9B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FD9FC.s") + +// TODO: Any overlap with existing/known structs? +typedef struct { + s32 unk0; + s32 unk4; + u8 pad8[0x18 - 0x08]; + f32 unk18; +} GlobalASMStruct2; + +GlobalASMStruct2 *func_806FD9B4(s16); + +f32 func_806FDA8C(s16 arg0) { + return func_806FD9B4(arg0)->unk18; +} + +void func_806FDAB8(s16 arg0, f32 arg1) { + func_806FD9B4(arg0)->unk18 = arg1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FDAEC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FDB8C.s") + +void func_806FDF1C(s16 arg0, s32 arg1) { + func_80002A30(func_806FD9B4(arg0)->unk4, arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FDF54.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FE078.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FEDB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FEF7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FF01C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FF144.s") + +void func_806FF32C(s32 arg0, Actor *arg1) { + func_806FF144(func_806FEDB0(arg0, arg1->PaaD->unk1A4)); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FF358.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FF628.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FF75C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FFB2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FFC04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FFEAC.s") + +void func_806FFF5C(void) { + // Texture, maybe pulling it into cache? + getPointerTableFile(0x19, 0x138B, 1, 1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_806FFF88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80700088.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807002AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_8070033C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_8070068C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807007B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807009F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80700AE4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80700BF4.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80701098.s") + +void func_80701C90(void) { + D_807FD890 = 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80701CA0.s") + +// Yikes, lots of params. Perhaps it's passing a struct by value on the stack? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807023E8.s") + +// Yikes, lots of params. Perhaps it's passing a struct by value on the stack? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80702464.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807024E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80703374.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807035C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80703850.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80703AB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80703CF8.s") + +void func_807040D0(u16 arg0) { + D_807FD892 = arg0; +} + +void func_807040E0(u8 arg0, u8 arg1, u8 arg2) { + D_807FD894 = arg0; + D_807FD895 = arg1; + D_807FD896 = arg2; +} + +void func_80704108(u8 arg0, u8 arg1, u8 arg2) { + D_807FD897 = arg0; + D_807FD898 = arg1; + D_807FD899 = arg2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80704130.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80704298.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80704444.s") + +/* +// TODO: REGALLOC'D +typedef struct { + u16 unk0; + u16 unk2; + u16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; +} GlobalASMStruct3; + +void func_80704444(GlobalASMStruct3 *arg0, u16 arg1, u16 arg2, s16 arg3, s16 arg4, u8 arg5) { + arg0->unk0 = arg1; + arg0->unk2 = arg2; + arg0->unk4 = 1000; + arg0->unk8 = arg3 << arg5; + arg0->unkA = arg4 << arg5; +}*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80704484.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80704960.s") + +extern f32 D_807FD968; +extern f32 D_807FD96C; +extern f32 D_807FD970; + +void func_80704AFC(f32 arg0, f32 arg1, f32 arg2) { + D_807FD968 = arg0; + D_807FD96C = arg1; + D_807FD970 = arg2; +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80704B20.s") + +typedef struct global_asm_struct_1 { + u8 unk0[0x0C]; + u8 unkC; + u8 unkD; + u8 unkE; +} GlobalASMStruct1; + +void func_80705B14(GlobalASMStruct1 *arg0, u8 arg1, u8 arg2, u8 arg3) { + arg0->unkC = arg1; + arg0->unkD = arg2; + arg0->unkE = arg3; +} + +void func_80705B30(void) { + D_807FD8A0 = 0; + guOrtho(&D_807FD928, + 0.0f, + (D_80744490 * 16.0f) - 1.0, + (D_80744494 * 16.0f) - 1.0, + 0.0f, + D_8075DFB0, + D_8075DFB4, + 1.0f + ); + D_807FD968 = -1.0f; + D_807FD978 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80705C00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80705F5C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807063B8.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807065F8.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_807069A4.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80706F90.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_8070770C.s") + +// Jumptable, 2524 bytes +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_80707980.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1025E0/func_8070835C.s") + +extern f32 D_80754CE8; + +void func_80708574(f32 arg0) { + // TODO: Clamp macro? + if (arg0 < 0.0) { + arg0 = 0.0f; + } + if (arg0 > 1.0) { + arg0 = 1.0f; + } + D_80754CE8 = arg0; +} diff --git a/src/global_asm/code_104F0.c b/src/global_asm/code_104F0.c new file mode 100644 index 00000000..2a76efeb --- /dev/null +++ b/src/global_asm/code_104F0.c @@ -0,0 +1,419 @@ +#include +#include "functions.h" +#include "variables.h" + +u8 func_8060BBE0(u16, s32); +s32 func_8060C6B8(s32 arg0, u8 arg1, u8 arg2, u8 fileIndex); +void func_8060C758(u8, s32); +void func_8060BCA0(s32, u8, u8, s16 *, s32); +void func_8060BEA8(s32, u8, s16 *, s32); +void func_8060BF84(s32, u8, s16 *, s32); +u16 func_80631C20(u8); +u32 func_806F8EDC(s32, s32); // getMaxItemCapacity(HUDItemIndex, playerIndex) + +extern s32 D_807EDEAC; +extern s32 D_807ECCF0; +extern u8 D_807467E0; +extern OSMesg D_807EE0B0; +extern OSMesgQueue D_807EE0D0; +extern s32 D_807EE0E8; +extern s32 D_807F0298; + +extern s8 D_80744460; +extern void (*D_807467D0[])(); +extern s16 D_807ECEA0; +extern u8 D_807EDEA8[4]; // EEPROM file mapping +extern u8 D_807EDEB0[]; +extern u8 D_807ECEA8[]; +extern OSMesgQueue D_807F02B8; +extern u8 D_807FC952; + +#define FILE_SIZE (((D_807ECEA0 + 0x6B7 & -64) + 0x27) & -8) +#define FILE_SIZE_BYTES FILE_SIZE / 8 + +void func_8060B7F0(void) { + s32 i; + + D_807ECEA0 = 0; + for (i = 0; i < 8; i++) { + D_807ECEA0 += func_80631C20(i); + } +} + +// Libultra 64 bit stuff, timer +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060B84C.s") + +void func_8060B8F8(s32 arg0) { + if (osGetThreadId(0) == 9) { + D_807467D0[arg0](); + return; + } + if (D_80744460 == 0) { + osSendMesg(&D_807F02B8, arg0, 0); + } +} + +// Hmm, checksum? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060B968.s") + +u8 getEEPROMSaveSlot(s32 fileIndex) { + u8 i; + for (i = 0; i < 4; i++) { + if (fileIndex == D_807EDEA8[i]) { + return i; + } + } + return 0; +} + +// 2015 MMM Implications... +void func_8060BA14(void) { + u8 currentFileSaveSlot = getEEPROMSaveSlot(current_file); + u8 temporaryFileSaveSlot = getEEPROMSaveSlot(3); + + if ((gameIsInAdventureMode() || gameIsInQuitGameMode()) && (currentFileSaveSlot != temporaryFileSaveSlot)) { + void *src = &D_807ECEA8[FILE_SIZE_BYTES * currentFileSaveSlot]; + void *dest = &D_807ECEA8[FILE_SIZE_BYTES * temporaryFileSaveSlot]; + memcpy(dest, src, FILE_SIZE_BYTES); + + // Switch the two file indexes in the file mapping array using the XOR trick + // It avoids using a temporary variable + D_807EDEA8[temporaryFileSaveSlot] = D_807EDEA8[currentFileSaveSlot] ^ D_807EDEA8[temporaryFileSaveSlot]; + D_807EDEA8[currentFileSaveSlot] ^= D_807EDEA8[temporaryFileSaveSlot]; + D_807EDEA8[temporaryFileSaveSlot] = D_807EDEA8[currentFileSaveSlot] ^ D_807EDEA8[temporaryFileSaveSlot]; + } +} + +// TODO: Double check signature +u8 func_8060BB18(u32, u16, u8); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060BB18.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060BBE0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060BCA0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060BEA8.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060BF84.s") + +void func_8060C2C4(s32 arg0, s32 arg1, u8 arg2, u16 *arg3, s8 *arg4) { + s32 i; + *arg3 += 800; + for (i = 0; i < arg2; i++) { + *arg3 += func_80631C20(i); + } + *arg4 = 1; +} + +void func_8060C340(s16 *arg0, s32 arg1, s32 arg2, u8 arg3, u8 arg4, u8 arg5) { + *arg0 = arg5 * FILE_SIZE; + if (arg2 >= 0x11) { + func_8060BF84(arg2, arg4, arg0, arg1); + return; + } + if (arg2 >= 0xC) { + func_8060BEA8(arg2, arg4, arg0, arg1); + return; + } + if (arg2 > 0) { + func_8060BCA0(arg2, arg3, arg4, arg0, arg1); + return; + } + func_8060C2C4(arg2, arg3, arg4, arg0, arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060C430.s") + +void func_8060C648(s32 arg0, u8 arg1, u8 arg2, u8 fileIndex, s32 arg4) { + u16 sp26; + u8 sp25; + + func_8060C340(&sp26, &sp25, arg0, arg1, arg2, getEEPROMSaveSlot(fileIndex)); + func_8060BB18(func_8060C430(arg0, arg4, 1), sp26, sp25); +} + +s32 func_8060C6B8(s32 arg0, u8 arg1, u8 arg2, u8 fileIndex) { + s32 temp; // Pad + u16 sp22; + u8 sp21; + + func_8060C340(&sp22, &sp21, arg0, arg1, arg2, getEEPROMSaveSlot(fileIndex)); + return func_8060C430(arg0, func_8060BBE0(sp22, sp21), 0); +} + +s32 func_8060C724(u8 fileIndex) { + return func_8060C6B8(0x10, 0, 0, fileIndex) + 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060C758.s") + +/* +void func_8060C758(u8 fileIndex, s32 arg1) { + s32 temp_lo = getEEPROMSaveSlot(fileIndex) * FILE_SIZE_BYTES; + current_file = fileIndex; + bzero(&D_807ECEA8[temp_lo], FILE_SIZE_BYTES); + func_8060C648(0xC, 0, 0, fileIndex, 1); + func_8060C648(0xF, 0, 0, fileIndex, fileIndex); + if (arg1 != 0) { + func_8060B8F8(1); + } +} +*/ + +void func_8060C830(u8 fileIndex, s32 arg1) { + current_file = fileIndex; + func_8060C758(fileIndex, 0); + if (func_8060C6B8(0xF, 0, 0, 3) == fileIndex) { + func_8060C758(3, 0); + } + if (arg1) { + func_8060B8F8(1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060C8AC.s") + +void func_8060CB74() { + clearGlobalFlags(); + func_8060C8AC(0xFF); +} + +void func_8060CB9C() { + func_8060B8F8(3); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060CBBC.s") + +void func_8060D0A8(void) { + s32 fileIndex; + s32 currentFileBackup; + + currentFileBackup = current_file; + // Setup EEPROM file mapping in normal order: 0, 1, 2, 3 + for (fileIndex = 0; fileIndex < 4; fileIndex++) { + D_807EDEA8[fileIndex] = fileIndex; + } + bzero(&D_807ECEA8, 0x800); // Clear the EEPROM copy + func_8060CB74(); + for (fileIndex = 0; fileIndex < 4; fileIndex++) { + func_8060C758(fileIndex, fileIndex == 3); + } + current_file = currentFileBackup; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060D14C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060D2C8.s") + +void func_8060D768() { + func_8060D2C8(0); +} + +void func_8060D788() { + func_8060D2C8(1); +} + +void func_8060D7A8(void) { + s32 kongIndex; + + if (func_806F6EDC()) { + D_807FC950[0].crystals = 0.5 * func_806F8EDC(5, 0); + } + // Training Grounds: Orange Barrel Completed + if (isFlagSet(0x184, FLAG_TYPE_PERMANENT)) { + D_807FC950[0].oranges = 0.5 * func_806F8EDC(4, 0); + } + // Camera/Shockwave Unlocked + if (isFlagSet(0x179, FLAG_TYPE_PERMANENT)) { + D_807FC950[0].film = 0.5 * func_806F8EDC(6, 0); + } + if (D_807FC952 != 0) { + D_807FC950[0].standardAmmo = 0.5 * func_806F8EDC(2, 0); + } + for (kongIndex = 0; kongIndex < 5; kongIndex++) { + current_character_index[0] = kongIndex; + if (D_807FC950[0].character_progress[kongIndex].instrument != 0) { + D_807FC950[0].character_progress[kongIndex].instrument_ammo = 0.5 * func_806F8EDC(7, 0); + } + } + current_character_index[0] = 0; // DK +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060DC3C.s") + +extern s8 D_80750AC0; +extern u8 D_807ED6A8[]; +extern s32 D_80750AB0; + +/* +// TODO: Very close +// loadTheGame() +void func_8060DC3C(u8 fileIndex, s32 arg1) { + CharacterProgress *phi_fp; + s32 levelIndex; + s32 kongIndex; + s32 byteIndex; + + phi_fp = D_807FC950[0].character_progress; + D_80750AC0 = 1; + func_806C9AE0(); + memcpy(&D_807ECEA8, &D_807ED6A8, 0x800); + current_file = fileIndex; + current_character_index[0] = 0; // DK + if (func_8060C6B8(0xD, 0, 0, fileIndex) == 0) { + func_8060C758(fileIndex, 0); + } + if (arg1 != 0) { + func_8060BA14(); + } + cc_number_of_players = 0; + D_807FC950->melons = func_8060C6B8(0xC, 0, 0, fileIndex); + func_80709464(0); + func_806C7B00(); + D_80750AB0 = func_8060C6B8(0xE, 0, 0, fileIndex); + for (kongIndex = 0; kongIndex < 5; kongIndex++) { + for (byteIndex = 0; byteIndex < 5; byteIndex++) { + ((u8*)phi_fp)[byteIndex] = func_8060C6B8(byteIndex + 4, kongIndex, 0, fileIndex); + } + phi_fp->coins = func_8060C6B8(9, kongIndex, 0, fileIndex); + phi_fp->unk5 = func_8060C6B8(0xA, kongIndex, 0, fileIndex); + if (func_8060C6B8(0xB, kongIndex, 0, fileIndex)) { + phi_fp->unk5 |= 0x80; + } + for (levelIndex = 0; levelIndex < 8; levelIndex++) { + phi_fp->coloured_bananas[levelIndex] = func_8060C6B8(1, kongIndex, levelIndex, fileIndex); + phi_fp->coloured_bananas_fed_to_tns[levelIndex] = func_8060C6B8(2, kongIndex, levelIndex, fileIndex); + phi_fp->golden_bananas[levelIndex] = func_8060C6B8(3, kongIndex, levelIndex, fileIndex); + } + phi_fp++; + } + if (arg1 != 0) { + func_8060D7A8(); + } + current_character_index[0] = 0; +} +*/ + +void func_8060DEA8(void) { + func_8060B8F8(2); +} + +// saveTheGame() +void func_8060DEC8(void) { + s32 kongIndex; + u32 temp_s1; + u32 phi_s0; + s32 byteIndex; + CharacterProgress *phi_s7; + s32 levelIndex; + + if ((cc_number_of_players == 1) && (gameIsInQuitGameMode() || gameIsInAdventureMode())) { + phi_s7 = D_807FC950[0].character_progress; + phi_s0 = func_805FC98C(); + temp_s1 = func_8060C724(current_file); + if (phi_s0 >= 0x400000) { + phi_s0 = -1; + } + func_8060C648(0xD, 0, 0, current_file, 1); + func_8060C648(0xE, 0, 0, current_file, phi_s0); + func_8060C648(0xC, 0, 0, current_file, D_807FC950[0].melons); + func_8060C648(0xF, 0, 0, current_file, current_file); + func_8060C648(0x10, 0, 0, current_file, temp_s1); + for (kongIndex = 0; kongIndex < 5; kongIndex++) { + for (byteIndex = 0; byteIndex < 5; byteIndex++) { + // TODO: Better way to match this? + func_8060C648(byteIndex + 4, kongIndex, 0, current_file, ((u8*)phi_s7)[byteIndex]); + } + func_8060C648(9, kongIndex, 0, current_file, phi_s7->coins); + func_8060C648(0xA, kongIndex, 0, current_file, phi_s7->unk5 & 0x7F); + func_8060C648(0xB, kongIndex, 0, current_file, (phi_s7->unk5 >> 7) & 1); + for (levelIndex = 0; levelIndex < 8; levelIndex++) { + func_8060C648(1, kongIndex, levelIndex, current_file, phi_s7->coloured_bananas[levelIndex]); + func_8060C648(2, kongIndex, levelIndex, current_file, phi_s7->coloured_bananas_fed_to_tns[levelIndex]); + func_8060C648(3, kongIndex, levelIndex, current_file, phi_s7->golden_bananas[levelIndex]); + } + phi_s7++; + } + func_8060B8F8(1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/func_8060E128.s") + +/* +void func_8060E128(s32 arg0) { + s32 sp2C; + + while (TRUE) { + osRecvMesg(&D_807F02B8, &sp2C, 1); + D_807467D0[sp2C](); + } +} +*/ + +void func_8060E128(void); // forward declaration for function pointer + +void func_8060E1A8(void) { + func_8060B7F0(); + D_807EDEAC = osEepromProbe(&D_807ECCF0); + osCreateMesgQueue(&D_807EE0D0, &D_807EE0B0, 8); + osCreateMesgQueue(&D_807F02B8, &D_807F0298, 8); + osCreateThread(&D_807EE0E8, 9, &func_8060E128, 0, &D_807F0298, 0xC); + osStartThread(&D_807EE0E8); + D_807467E0 = 1; + func_8060B8F8(0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_104F0/getFlagBlockAddress.s") + +// TODO: Close +/* +// ./diff.sh 0x12F5C +u8 *getFlagBlockAddress(u8 flagType) { + s32 temp_t6; + u8 *phi_v1; + phi_v1 = NULL; + switch (flagType) { + case FLAG_TYPE_PERMANENT: + if ((gameIsInDKTVMode()) || (cc_number_of_players >= 2)) { + func_80731030(); + bzero(&D_807EDEB0, FILE_SIZE_BYTES); + phi_v1 = &D_807EDEB0; + } else { + phi_v1 = &D_807ECEA8[getEEPROMSaveSlot(current_file) * FILE_SIZE_BYTES]; + } + break; + case FLAG_TYPE_GLOBAL: + phi_v1 = &D_807ECEA8[((((FILE_SIZE * 4) + 0x3F) & ~0x3F) / 8)]; + break; + } + return phi_v1; +} +*/ + +u8 func_8060E3B0(u16 arg0, u8 arg1) { + u8 phi_v1; + u16 sp24; + u8 sp23; + + phi_v1 = 0; + if (gameIsInAdventureMode()) { + func_8060C340(&sp24, &sp23, 0, 0, arg1, getEEPROMSaveSlot(current_file)); + phi_v1 = func_8060BBE0(sp24 + arg0, 1); + } + return phi_v1; +} + +void func_8060E430(u16 arg0, u8 arg1, u8 arg2) { + u16 sp26; + u8 sp25; + + if (gameIsInAdventureMode()) { + func_8060C340(&sp26, &sp25, 0, 0, arg2, getEEPROMSaveSlot(current_file)); + func_8060BB18(arg1, sp26 + arg0, 1); + } +} diff --git a/src/global_asm/code_10D2D0.c b/src/global_asm/code_10D2D0.c new file mode 100644 index 00000000..b4719c00 --- /dev/null +++ b/src/global_asm/code_10D2D0.c @@ -0,0 +1,112 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10D2D0/func_807085D0.s") + +typedef struct global_asm_struct_21 { + f32 unk0; + u16 unk4; + u16 unk6; + u8 unk8; + u8 unk9; + u8 unkA; +} GlobalASMStruct21; + +void func_80708BB8(GlobalASMStruct21 *arg0) { + if ((D_807FBB64 & 0x800)) { + arg0->unk6 = 0x20; + } else { + arg0->unk6 = 1; + } + if (gameIsInDKTVMode()) { + arg0->unk6 = 0x20; + } + arg0->unkA = 0; + arg0->unk8 = 0; + arg0->unk4 = 0; + arg0->unk0 = 4.0f; +} + +// TODO: arg1 might also be PlayerProgress*, needs some padding split apart though +// Other than that this function looks doable +void func_80708C24(s32 arg0, CharacterChange *arg1, PlayerProgress *arg2, s32 arg3); +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10D2D0/func_80708C24.s") + +void func_80026B0C(s32); +s32 func_8070943C(); + +/* +// Regalloc :( +void func_80708C24(s32 arg0, CharacterChange *arg1, PlayerProgress *arg2, s32 arg3) { + s32 temp_v1_2; + s32 temp_lo; + s32 pad; + u32 sp28; + + sp28 = (u8)arg1->unk2E2; + if ((arg1->unk2E2 & 0x10)) { + arg1->unk2E2 ^= 0x10; + if (arg2->unk2FD > 0) { + temp_lo = arg2->melons * func_8070943C(); + temp_v1_2 = arg2->health + arg2->unk2FD; + arg2->health = MIN(temp_v1_2, temp_lo); + } else if (arg2->unk2FD < 0) { + if (gameIsInAdventureMode() || gameIsInMysteryMenuMinigameMode()) { + arg2->health += arg2->unk2FD; + } + if (arg2->health <= 0) { + arg2->health = 0; + arg1->unk2E6 = 0xC; + if (cc_number_of_players >= 2) { + func_80026B0C(arg0); + } + } else { + playSound(0x24B, 0x7FFF, 63.0f, 1.0f, 0, 0); + } + } + arg2->unk2FD = 0; + } + if ((!(global_properties_bitfield & 2) && func_805FCA64()) || (sp28 & 0x80)) { + arg1->unk2E5--; + if (arg1->unk2E5 == 0) { + arg1->unk2E5 = 0x11; + arg1->unk2E4 = 3; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10D2D0/func_80708DA4.s") + +extern s8 D_80744504; + +s16 func_80708DA4(s32, s16, CharacterChange*); + +s32 func_80709344(s32 arg0) { + s16 i; + for (i = 0; i < cc_number_of_players; i++) { + if (character_change_array[i].does_player_exist) { + if (!(character_change_array[i].unk2E2 & 0x20) + && (((character_change_array[i].unk2E4 + || character_change_array[i].unk2E2) + && (D_80744504 == 0)) + || (character_change_array[i].unk2E2 & 0x10))) { + arg0 = func_80708DA4(arg0, i, &character_change_array[i]); + } + } + } + return arg0; +} + +// Segments per melon +s32 func_8070943C(void) { + return cc_number_of_players > 1 ? 10 : 4; +} + +void func_80709464(u8 playerIndex) { + PlayerProgress *temp = &D_807FC950[playerIndex]; + temp->health = temp->melons * func_8070943C(); + temp->unk2FD = 0; +} diff --git a/src/global_asm/code_10E1D0.c b/src/global_asm/code_10E1D0.c new file mode 100644 index 00000000..50ce1aba --- /dev/null +++ b/src/global_asm/code_10E1D0.c @@ -0,0 +1,168 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_807094D0.s") + +/* +extern u8 D_807444F4; +extern f32 D_807FD9C4; +extern s8 D_807FD9BC; +extern s8 D_807444F8; +extern u8 D_807FD9BD; +extern s32 D_8076D1F8; +extern s32 D_807FD9C8; + +void func_80737638(s32, s32, s32, s32, f32, s32, s32); + +// TODO: Regalloc, and last function call is sus +void func_807094D0(u8 arg0) { + D_807444F4 = is_cutscene_active; + switch (arg0) { + case 2: + D_807FD9C4 = 1.0f; + D_807FD9BC = 0; + D_807444F8 = 1; + is_cutscene_active = 6; + break; + case 3: + D_807FD9C4 = 0.5f; + D_807FD9BC = 0; + D_807444F8 = 2; + is_cutscene_active = 2; + D_807FD9BD = 6; + if ((D_807444F4 == 1) && (D_807FBB64 & 1)) { + func_80600BBC(0); + } + break; + } + func_80737638(D_8076D1F8, 0x1BC, 0x7FFF, 0x3F, 1.0f, 0, &D_807FD9C8); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_807095E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_80709890.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_80709ACC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_80709BC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070A220.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070A848.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070A934.s") + +/* +s32 func_805FE71C(s32, u8, s32 *, ?); +s32 func_805FE7B4(s32 *, s32 *, s32 *, ?); +s32 func_80610044(s32, s32, ?, ?, s32, s32); +s32 func_8061134C(s32); +s32 func_8061CBCC(); +s32 func_8070AC74(s32, s32 *, u8 *); +s32 func_8070AF24(s32 *, u8 *); +s32 func_8070B7EC(s32 *, s32, s32); +extern u8 D_807444F4; +extern void *D_807FD9A8; +extern s32 D_807FD9B0; +extern s32 D_807FD9B4; +extern s32 D_807FD9B8; +extern u8 D_807FD9BC; +extern u8 D_807FD9BD; + +// TODO: Made decent progress, cleaning up mips_to_c output, still needs some TLC though +// Those array/struct lookups, oof +// Also idk what's going on with the first switch case +void func_8070A934(s32 nextMap, s32 nextExit) { + s32 sp34; + s32 *sp30; + s32 *temp_t7; + s32 temp_t5; + u8 temp_t1; + u8 temp_t1_2; + u8 temp_t5_2; + + func_80610044(((D_807444FC * 4) + 0x80770000)->unk-5FB0, D_8076A088, 3, 1, 0x4D2, 1); + temp_t1 = D_807444FC ^ 1; + temp_t5 = (temp_t1 & 0xFF) * 0x11B0; + D_807444FC = temp_t1; + object_timer++; + temp_t7 = temp_t5 + &D_80767CE8; + D_8076A048 = temp_t7; + sp30 = temp_t7 + 0xDB0; + switch (D_807FD9BC) { + case 0: + D_807FD9BC = 1; + func_8070AF24(&object_timer, &D_807FD9BC); + break; + } + case 1: + if ((D_8076A0B1 & 1) && (D_807FD888 == 31.0f)) { + sp34 = ((D_807444FC * 4) + 0x80770000)->unk-5FB0; + if (D_8076A0B2 == 1) { + is_cutscene_active = D_807444F4; + } + } else { + func_8070AC74(*0x8076A048, &sp34, &D_8076A0B1); + if (func_8070B7EC(&sp34, D_807FD9B8, D_807FD9B0)) { + switch (D_807444F8) { + case 1: + osViBlack(1); + func_805FF378(nextMap, nextExit); + D_807FD888 = 31.0f; + D_807444F8 = 2; + break; + case 2: + func_8061134C(D_807FD9B0); + func_8061134C(D_807FD9A8->unk8); + func_8061134C(D_807FD9B4); + func_8061134C(D_807FD9A8->unk10); + func_8061134C(D_807FD9A8->unk14); + func_8066B434(D_807FD9B8, 0x24B, 0x4A); + is_cutscene_active = D_807444F4; + if ((is_cutscene_active == 1) && D_807FBB64 & 1) { + func_8061CBCC(); + } + D_807444F8 = 3; + D_807FD888 = 0.0f; + break; + } + } + } + if (D_807FD9BD != 0) { + temp_t5_2 = D_807FD9BD - 1; + D_807FD9BD = temp_t5_2; + if ((temp_t5_2 & 0xFF) == 0) { + D_8076A0B1 |= 2; + } + } + if (D_8076A0A4 && (is_cutscene_active != 6)) { + func_805FE71C(sp34, D_807444FC, &D_8076A088, 0); + func_805FE7B4(sp30, D_8076A048, &D_8076A08C, 1); + return; + } + func_805FE71C(sp34, D_807444FC, &D_8076A088, 1); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070AC74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070AF24.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070B05C.s") + +extern u8 D_80755070; // intro_story_is_playing + +void setIntroStoryPlaying(u8 arg0) { + D_80755070 = arg0; +} + +u8 isIntroStoryPlaying(void) { + return D_80755070; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070B324.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_10E1D0/func_8070B7EC.s") diff --git a/src/global_asm/code_110F00.c b/src/global_asm/code_110F00.c new file mode 100644 index 00000000..109c106c --- /dev/null +++ b/src/global_asm/code_110F00.c @@ -0,0 +1,349 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_8070C89C(float (*mf)[4], f32, f32, f32); +void func_8070C8F4(float (*mf)[4], f32, f32, f32); +void func_8070C990(float (*mf)[4], f32, f32, f32); +void func_8070CAB4(float (*mf)[4], f32); +void func_8070CB2C(float (*mf)[4], f32); +void func_8070CBA4(float (*mf)[4], f32); +void func_8070CCC4(float (*mf)[4]); +void func_8070CD44(float (*mf)[4], f32, f32, f32); +void func_8070CDD0(f32 (*arg0)[4], f32 (*arg1)[4], f32 arg2, f32 arg3, f32 arg4); +void func_8070D07C(Mtx*, Mtx*, f32, f32, f32, f32, f32, f32); + +extern f64 D_8075E470; +extern f64 D_8075E478; +extern f64 D_8075E480; + +f32 func_80612D1C(f32, f32); +f32 func_80612D10(f32); + +// tiny, round float, can't auto decompile +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070C200.s") + +void func_8070C210(float (*mf)[4], f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6) { + func_8070CCC4(mf); + mf[0][0] = arg1; + mf[1][1] = arg2; + mf[2][2] = arg3; + mf[3][3] = 1.0f; + mf[3][0] = arg4; + mf[3][1] = arg5; + mf[3][2] = arg6; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070C27C.s") + +/* +void func_8070C210(Mtx*, f32, f32, f32, f32, f32, f32); + +// TODO: Something off here with stack/params +void func_8070C27C(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { + Mtx sp28; + + func_8070C210(&sp28, arg1, arg2, arg4, arg5, arg6, arg7); + guMtxF2L(&sp28, arg0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070C2D8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070C590.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070C808.s") + +/* +// TODO: Order of operations nonsense +void func_8070C808(float (*mf)[4], f32 *arg1, f32 *arg2, f32 *arg3) { + *arg1 = (*arg1 * mf[0][0]) + (*arg2 * mf[1][0]) + (*arg3 * mf[2][0]) + mf[3][0]; + *arg2 = (*arg1 * mf[0][1]) + (*arg2 * mf[1][1]) + (*arg3 * mf[2][1]) + mf[3][1]; + *arg3 = (*arg1 * mf[0][2]) + (*arg2 * mf[1][2]) + (*arg3 * mf[2][2]) + mf[3][2]; +} +*/ + +void func_8070C89C(float (*mf)[4], f32 arg1, f32 arg2, f32 arg3) { + f32 temp_f0; + f32 temp_f2; + + func_8070CCC4(mf); + temp_f0 = arg2 / arg3; + temp_f2 = arg1 / arg3; + mf[1][1] = temp_f2; + mf[1][2] = temp_f0; + mf[2][1] = -temp_f0; + mf[2][2] = temp_f2; +} + +void func_8070C8F4(float (*mf)[4], f32 arg1, f32 arg2, f32 arg3) { + f32 phi_f0; + f32 phi_f2; + + phi_f0 = arg2 / arg3; + phi_f2 = arg1 / arg3; + if (arg2 == 0.0) { + phi_f0 = 0.0f; + } + if (arg1 == 0.0) { + phi_f2 = 0.0f; + } + func_8070CCC4(mf); + mf[2][0] = phi_f0; + mf[0][2] = -phi_f0; + mf[0][0] = phi_f2; + mf[2][2] = phi_f2; +} + +void func_8070C990(float (*mf)[4], f32 arg1, f32 arg2, f32 arg3) { + f32 temp_f0; + f32 temp_f2; + + func_8070CCC4(mf); + temp_f0 = arg2 / arg3; + temp_f2 = arg1 / arg3; + mf[0][0] = temp_f2; + mf[0][1] = temp_f0; + mf[1][1] = temp_f2; + mf[1][0] = -temp_f0; +} + +void func_8070C9E8(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3) { + Mtx sp18; + + func_8070C89C(&sp18, arg1, arg2, arg3); + guMtxF2L(&sp18, arg0); +} + +void func_8070CA2C(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3) { + Mtx sp18; + + func_8070C8F4(&sp18, arg1, arg2, arg3); + guMtxF2L(&sp18, arg0); +} + +void func_8070CA70(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3) { + Mtx sp18; + + func_8070C990(&sp18, arg1, arg2, arg3); + guMtxF2L(&sp18, arg0); +} + +void func_8070CAB4(float (*mf)[4], f32 arg1) { + f32 pad; // TODO: Get rid of this if possible + f32 temp_f0; + f32 sp24; + f32 temp_f12; + + temp_f12 = arg1 * D_8075E470; + temp_f0 = func_80612D1C(temp_f12, arg1); + sp24 = func_80612D10(temp_f12); + func_8070CCC4(mf); + mf[1][2] = temp_f0; + mf[2][1] = -temp_f0; + mf[1][1] = sp24; + mf[2][2] = sp24; +} + +void func_8070CB2C(float (*mf)[4], f32 arg1) { + f32 pad; // TODO: Get rid of this if possible + f32 temp_f0; + f32 sp24; + f32 temp_f12; + + temp_f12 = arg1 * D_8075E478; + temp_f0 = func_80612D1C(temp_f12, arg1); + sp24 = func_80612D10(temp_f12); + func_8070CCC4(mf); + mf[2][0] = temp_f0; + mf[0][2] = -temp_f0; + mf[0][0] = sp24; + mf[2][2] = sp24; +} + +void func_8070CBA4(float (*mf)[4], f32 arg1) { + f32 pad; // TODO: Get rid of this if possible + f32 temp_f0; + f32 sp24; + f32 temp_f12; + + temp_f12 = arg1 * D_8075E480; + temp_f0 = func_80612D1C(temp_f12, arg1); + sp24 = func_80612D10(temp_f12); + func_8070CCC4(mf); + mf[0][1] = temp_f0; + mf[1][0] = -temp_f0; + mf[0][0] = sp24; + mf[1][1] = sp24; +} + +void func_8070CC1C(Mtx *arg0, f32 arg1) { + Mtx sp18; + + func_8070CAB4(&sp18, arg1); + guMtxF2L(&sp18, arg0); +} + +void func_8070CC54(Mtx *arg0, f32 arg1) { + Mtx sp18; + + func_8070CB2C(&sp18, arg1); + guMtxF2L(&sp18, arg0); +} + +void func_8070CC8C(Mtx *arg0, f32 arg1) { + Mtx sp18; + + func_8070CBA4(&sp18, arg1); + guMtxF2L(&sp18, arg0); +} + +void func_8070CCC4(float (*mf)[4]) { + mf[0][0] = 1.0f; + mf[1][0] = 0.0f; + mf[2][0] = 0.0f; + mf[3][0] = 0.0f; + mf[0][1] = 0.0f; + mf[1][1] = 1.0f; + mf[2][1] = 0.0f; + mf[3][1] = 0.0f; + mf[0][2] = 0.0f; + mf[1][2] = 0.0f; + mf[2][2] = 1.0f; + mf[3][2] = 0.0f; + mf[0][3] = 0.0f; + mf[1][3] = 0.0f; + mf[2][3] = 0.0f; + mf[3][3] = 1.0f; +} + +void func_8070CD14(Mtx *arg0) { + Mtx sp18; + + func_8070CCC4(&sp18); + guMtxF2L(&sp18, arg0); +} + +void func_8070CD44(float (*mf)[4], f32 arg1, f32 arg2, f32 arg3) { + func_8070CCC4(mf); + mf[3][0] = arg1; + mf[3][1] = arg2; + mf[3][2] = arg3; +} + +void func_8070CD8C(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3) { + float sp18[4][4]; + + func_8070CD44(&sp18, arg1, arg2, arg3); + guMtxF2L(&sp18, arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070CDD0.s") + +/* +// TODO: Surprisingly close but very fiddly +void func_8070CDD0(f32 (*arg0)[4], f32 (*arg1)[4], f32 arg2, f32 arg3, f32 arg4) { + f32 sp30; + f32 sp2C; + f32 sp24; + f32 temp_f0; + f32 temp_f16; + f32 temp_f16_2; + f32 temp_f20; + f32 temp_f8; + f32 phi_f12; + f32 phi_f14; + f32 phi_f16; + f32 phi_f18; + f32 phi_f20; + + if ((arg2 == 0.0f) && (arg4 == 0.0f)) { + if (arg3 == 0.0f) { + func_8070CCC4(arg0); + func_8070CCC4(arg1); + return; + } + sp24 = 0.0f; + sp2C = 0.0f; + sp30 = 1.0f; + phi_f12 = 1.0f; + phi_f14 = 0.0f; + phi_f16 = 0.0f; + phi_f18 = 0.0f; + phi_f20 = -1.0f; + } else { + temp_f16 = 1.0 / sqrtf(arg2 * arg2 + (arg3 * arg3) + (arg4 * arg4)); + temp_f20 = arg3 * temp_f16; + arg2 *= temp_f16; + arg4 *= temp_f16; + temp_f0 = sqrtf((arg2 * arg2) + (arg4 * arg4)); + temp_f16_2 = 1.0 / temp_f0; + temp_f8 = -arg4 * temp_f16_2; + sp24 = -arg2 * temp_f16_2; + sp2C = -arg4; + sp30 = temp_f20 * temp_f8; + phi_f12 = temp_f8; + phi_f14 = temp_f20 * sp24; + phi_f16 = -arg2; + phi_f18 = temp_f0; + phi_f20 = -temp_f20; + } + + // Setup matrix 1 + arg0[0][0] = phi_f12; + arg0[1][0] = phi_f14; + arg0[2][0] = phi_f16; + arg0[3][0] = 0.0f; + arg0[0][1] = 0.0f; + arg0[1][1] = phi_f18; + arg0[2][1] = phi_f20; + arg0[3][1] = 0.0f; + arg0[0][2] = -sp24; + arg0[1][2] = sp30; + arg0[3][2] = 0.0f; + arg0[0][3] = 0.0f; + arg0[1][3] = 0.0f; + arg0[2][3] = 0.0f; + arg0[3][3] = 1.0f; + arg0[2][2] = sp2C; + + // Setup matrix 2 + arg1[0][0] = phi_f12; + arg1[1][0] = 0.0f; + arg1[3][0] = 0.0f; + arg1[0][1] = phi_f14; + arg1[1][1] = phi_f18; + arg1[2][0] = -sp24; + arg1[3][1] = 0.0f; + arg1[0][2] = phi_f16; + arg1[1][2] = phi_f20; + arg1[2][1] = sp30; + arg1[3][2] = 0.0f; + arg1[0][3] = 0.0f; + arg1[1][3] = 0.0f; + arg1[2][3] = 0.0f; + arg1[3][3] = 1.0f; + arg1[2][2] = sp2C; +} +*/ + +void func_8070D020(Mtx *arg0, Mtx *arg1, f32 arg2, f32 arg3, f32 arg4) { + Mtx sp60; + Mtx sp20; + + func_8070CDD0(&sp60, &sp20, arg2, arg3, arg4); + guMtxF2L(&sp60, arg0); + guMtxF2L(&sp20, arg1); +} + +// TODO: It's going to be very similar to func_8070CDD0, better match that one first to get familiar with what it's doing +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_110F00/func_8070D07C.s") + +void func_8070D300(Mtx *arg0, Mtx *arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { + Mtx sp68; + Mtx sp28; + + func_8070D07C(&sp68, &sp28, arg2, arg3, arg4, arg5, arg6, arg7); + guMtxF2L(&sp68, arg0); + guMtxF2L(&sp28, arg1); +} diff --git a/src/global_asm/code_112080.c b/src/global_asm/code_112080.c new file mode 100644 index 00000000..f2a4a5a6 --- /dev/null +++ b/src/global_asm/code_112080.c @@ -0,0 +1,197 @@ +#include +#include "functions.h" +#include "variables.h" + +typedef struct Temp8070D6D8 { + s32 unk0; + s32 unk4; + u16 unk8; // Size + u16 unkA; + void *unkC; // Next? +} Temp8070D6D8; + +// TODO: What the +void func_8070D380(u32 arg0, Temp8070D6D8 *arg1, u8 **arg2) { + memcpy(arg1, *arg2, arg0); + *arg2 += arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D3CC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D464.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D568.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D654.s") + +Temp8070D6D8 *func_8070D6D8(void *arg0) { + Temp8070D6D8 *temp_s0; + s32 size; + + temp_s0 = malloc(0x10); + func_8070D380(1, temp_s0, &arg0); + func_8070D654(temp_s0, &arg0); + func_8070D380(2, &temp_s0->unk8, &arg0); + size = temp_s0->unk8; + temp_s0->unkC = malloc(size); + memcpy(temp_s0->unkC, arg0, size); + return temp_s0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D754.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D82C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D8C0.s") + +extern u8 D_807550CC; + +/* +// TODO: What type does func_8070D754 return? +void func_8070D8C0(Actor *arg0, u16 arg1, u8 arg2) { + void *temp_a0; + void *temp_v0; + + temp_v0 = func_8070D754(); + temp_a0 = temp_v0; + temp_v0->unk4->unk174->unk54 = D_807550CC; + D_807550CC = 0; + func_8070D82C(temp_a0, arg1, arg2, &D_807550CC); + arg0->object_properties_bitfield |= 0x02000000; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D928.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D970.s") + +/* +// TODO: Which struct is this? +void func_8070D970(s32 arg0) { + void *temp_v0; + + temp_v0 = func_8070D928(arg0 & 0xFFFF); + if (temp_v0 != 0) { + temp_v0->unk2--; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070D9AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DA28.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DA74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DB7C.s") + +/* +// TODO: Which struct is this? +void func_8070DB7C(void *arg0) { + func_8061134C(arg0->unk4); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DB9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DC40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DCA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DD18.s") + +/* +// TODO: Which struct is this? +void func_8070DD18(void *arg0) { + func_8070DCA4(arg0->unk4); + func_8061134C(arg0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DD44.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DDDC.s") + +/* +s32 func_8070D6D8(void *); +void *func_8070D928(u16); +extern void *D_807550C0; + +// TODO: Nice little puzzle to solve... +s32 func_8070DDDC(u16 arg0, s32 arg1) { + s32 sp20; + u8 temp_v1_2; + void **temp_v1; + void *temp_a0; + void *temp_v0; + void *temp_v0_2; + void *temp_v0_3; + void *phi_v0; + void **phi_v1; + void *phi_v0_2; + void *phi_a0; + + temp_v0 = func_8070D928(arg0); + phi_v0_2 = temp_v0; + phi_a0 = temp_v0; + if (temp_v0 == 0) { + // TEXT!!! + temp_a0 = getPointerTableFile(0xC, arg0, 1, 1); + phi_v1 = &D_807550C0; + if (D_807550C0 != 0) { + phi_v0 = D_807550C0; + do { + temp_v1 = phi_v0 + 0xC; + temp_v0_2 = *temp_v1; + phi_v0 = temp_v0_2; + phi_v1 = temp_v1; + } while (temp_v0_2 != 0); + } + sp20 = func_8070D6D8(temp_a0); + func_8066B434(temp_a0, 0x1F1, 0x50); + temp_v0_3 = malloc(0x10); + *phi_v1 = temp_v0_3; + temp_v0_3->unk4 = sp20; + temp_v0_3->unk0 = arg0; + temp_v0_3->unk2 = 0; + temp_v0_3->unkC = 0; + temp_v0_3->unk8 = arg1; + phi_v0_2 = temp_v0_3; + phi_a0 = temp_v0_3; + } + temp_v1_2 = phi_v0_2->unk8; + if (temp_v1_2 != 0) { + if (temp_v1_2 == 1) { + phi_v0_2->unk2 = 2; + } + } else { + phi_v0_2->unk2++; + } + return phi_a0->unk4; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DED4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070E2AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070E34C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070E548.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070E750.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070E808.s") + +extern s32 D_807550C0; +extern s32 D_807550C4; +extern u8 D_807550CC; + +void func_8070E8C8(void) { + D_807550C0 = 0; + D_807550C4 = 0; +} + +void func_8070E8DC(u8 arg0) { + D_807550CC = arg0; +} diff --git a/src/global_asm/code_1135F0.c b/src/global_asm/code_1135F0.c new file mode 100644 index 00000000..3bc0eacc --- /dev/null +++ b/src/global_asm/code_1135F0.c @@ -0,0 +1,73 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern uSprite *D_807550D0; + +extern s16 D_807FD9D0; //sx +extern s16 D_807FD9D2; //sy +extern u8 D_807FD9D4; //fx +extern u8 D_807FD9D5; //fy + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1135F0/func_8070E8F0.s") +#else +void func_8070E8F0(Gfx **arg0, uSprite *arg1) { + D_807550D0 = arg1; + D_807FD9D0 = 0x400; + D_807FD9D2 = 0x400; + D_807FD9D4 = 0; + D_807FD9D5 = 0; + switch(D_807550D0->s.SourceImageBitSize) { + case G_IM_SIZ_8b: //L8070E96C + if ((D_807550D0->s.Stride & 7) == 0) { + gDPLoadTextureBlock((*arg0)++,D_807550D0->s.SourceImagePointer, D_807550D0->s.SourceImageType, G_IM_SIZ_8b, + D_807550D0->s.SubImageWidth, D_807550D0->s.SubImageHeight, + D_807550D0->s.TlutPointer, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + } else {//L8070EB34 + gDPLoadTextureBlock((*arg0)++,D_807550D0->s.SourceImagePointer, D_807550D0->s.SourceImageType, G_IM_SIZ_8b, + D_807550D0->s.SubImageWidth, D_807550D0->s.SubImageHeight, + D_807550D0->s.TlutPointer, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + } + break; + case G_IM_SIZ_16b: //L8070EC7C + if ((D_807550D0->s.Stride & 3) == 0) { + gDPLoadTextureBlock((*arg0)++,D_807550D0->s.SourceImagePointer, D_807550D0->s.SourceImageType, G_IM_SIZ_16b, + D_807550D0->s.SubImageWidth, D_807550D0->s.SubImageHeight, + D_807550D0->s.TlutPointer, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + } else {//L8070EB34 + gDPLoadTextureBlock((*arg0)++,D_807550D0->s.SourceImagePointer, D_807550D0->s.SourceImageType, G_IM_SIZ_8b, + D_807550D0->s.SubImageWidth, D_807550D0->s.SubImageHeight, + D_807550D0->s.TlutPointer, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + } + break; + case G_IM_SIZ_32b: //L8070EF94 + if ((D_807550D0->s.Stride & 3) == 0) { + gDPLoadTextureBlock((*arg0)++,D_807550D0->s.SourceImagePointer, D_807550D0->s.SourceImageType, G_IM_SIZ_32b, + D_807550D0->s.SubImageWidth, D_807550D0->s.SubImageHeight, + D_807550D0->s.TlutPointer, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + } else { + gDPLoadTextureBlock((*arg0)++,D_807550D0->s.SourceImagePointer, D_807550D0->s.SourceImageType, G_IM_SIZ_8b, + D_807550D0->s.SubImageWidth, D_807550D0->s.SubImageHeight, + D_807550D0->s.TlutPointer, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD + ); + } + break; + } +} +#endif + +void func_8070F2C8(s16 arg0, s16 arg1, u8 arg2, u8 arg3) { + D_807FD9D0 = arg0; + D_807FD9D2 = arg1; + D_807FD9D4 = arg2; + D_807FD9D5 = arg3; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1135F0/func_8070F2FC.s") diff --git a/src/global_asm/code_114270.c b/src/global_asm/code_114270.c new file mode 100644 index 00000000..63d4bce5 --- /dev/null +++ b/src/global_asm/code_114270.c @@ -0,0 +1,566 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s16 D_80744490; +extern OSTime D_807445B8; +extern u32 D_807445BC; + +extern s8 D_80750754; +extern s8 D_80750AB8; +extern u8 D_80750AC0; + +extern u16 *D_807550E0; +extern s32 D_807552EC; +extern u16 D_80755308; // buttons_enabled +extern u8 D_8075530C; // joystick_x_bits_enabled +extern u8 D_80755310; // joystick_y_bits_enabled +extern u16 D_8075531C; +extern u8 D_80755324; +extern u8 D_80755328; // index into D_8075E5C0[] +extern u8 D_8075532C; +extern s8 D_80755330; // prevent_transition +extern s32 D_80755334; +extern s32 D_80755338; // cutscene_will_play_next_map +extern s32 D_8075533C; // cutscene_to_play_next_map +extern f32 D_80755348; // helm_timer +extern u8 D_80755350; +extern s8 D_8075536C; // Exit +extern s32 D_80755384[]; + +extern u8 D_8075E5C0[]; + +extern s32 D_807FBB68; + +extern u8 D_807FDA1A; +extern u8 D_807FDA1C; + +extern u8 D_807FDA28; +extern s8 D_807FDA30[]; + +void func_80026D40(Actor *arg0, s32 arg1); +void func_80709464(u8); +void func_8060AC34(GlobalASMStruct12*); + +void func_8070F570(void) { + s16 i; + + *D_807550E0 = 0; + D_807FDA1C = 6; + for (i = 0; i < 0x80; i++) { + D_807FDA30[i] = i; + } + D_807FDA1A = 0x7F; + D_807FDA28 = 0; +} + +// Doable, needs some structs defined though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_8070F5CC.s") + +// Doable, needs some structs defined though (arg0) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_8070FA58.s") + +// Doable, needs some structs defined though (arg0) +// % 320 on a float? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_8070FC40.s") + +// Big, need structs +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_8070FCCC.s") + +// Need arg0 struct +// f32 unkC; +// f32 unk10; +// u8 unkB0; +// u8 unkB1; +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_8071006C.s") + +// Need arg0 struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80710174.s") + +// Need arg0 struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807102AC.s") + +// Need arg0 struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807103E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807105D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80710CA0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80711410.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80711950.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80711BD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80711F90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807122B4.s") + +void func_80712490(Maps newMap, s32 newExit, u8 newGameMode) { + func_805FF378(newMap, newExit); + game_mode = newGameMode; +} + +void func_807124B8(Maps newMap, s32 cutsceneIndex, u8 newGameMode) { + if (!func_80712798()) { + func_805FF158(0); + func_80712490(newMap, D_8075536C, newGameMode); + D_80755338 = 1; + D_8075533C = cutsceneIndex; + D_8075536C = 0; + } +} + +void func_80712524(Maps newMap, s32 cutsceneIndex) { + func_807124B8(newMap, cutsceneIndex, game_mode); +} + +// getHelmTimerStartTime() +s32 func_80712548(void) { + // Count blueprints turned + 10 + return func_80731AA8(0x1FD, 40, FLAG_TYPE_PERMANENT) + 10; +} + +// loopy libultra stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80712574.s") + +void func_8071261C(void) { + D_80755350 = 0; +} + +u8 func_80712628(void) { + return D_80755350; +} + +void func_80712634(Maps newMap, s32 arg1) { + func_807124B8(newMap, arg1, GAME_MODE_DK_THEATRE); + D_80755330 = 0; +} + +// TODO: Why can't this return s32? +int gameIsInDKTheatreMode(void) { + return game_mode_copy == GAME_MODE_DK_THEATRE || game_mode == GAME_MODE_DK_THEATRE; +} + +void func_8071268C(void) { + if (game_mode_copy == GAME_MODE_DK_THEATRE) { + D_80755330 = 1; + } +} + +void func_807126B0(Maps newMap, s32 newExit, s32 characterIndex, s8 moves, s8 simianSlam, s8 instrument, s8 melons) { + s32 kongIndex; + + current_character_index[0] = characterIndex; + D_807FC950[0].melons = melons; + D_807FC950[0].health = melons * 4; + + for (kongIndex = 0; kongIndex < 5; kongIndex++) { + D_807FC950[0].character_progress[kongIndex].moves = moves; + D_807FC950[0].character_progress[kongIndex].simian_slam = simianSlam; + D_807FC950[0].character_progress[kongIndex].instrument = instrument; + } + + func_80712490(newMap, newExit, GAME_MODE_MYSTERY_MENU_MINIGAME); +} + +void func_80712774(Maps newMap) { + func_80712490(newMap, 0, GAME_MODE_SNIDES_BONUS_GAME); +} + +s32 func_80712798(void) { + return game_mode_copy != game_mode; +} + +void func_807127B4(void) { + func_805FFFC8(); + // Unknown flag block right after Aztec Caption Seen + setFlag(0x314, TRUE, FLAG_TYPE_PERMANENT); + func_807124B8(MAP_HELM_LEVEL_INTROS_GAME_OVER, 0x17, GAME_MODE_QUIT_GAME); // initMapFade() +} + +void func_807127F4(s32 isDKTheatre) { + u8 newGameMode; + + if (!isDKTheatre) { + newGameMode = GAME_MODE_END_SEQUENCE; + } else { + newGameMode = GAME_MODE_END_SEQUENCE_DK_THEATRE; + } + func_807124B8(MAP_DK_ISLES_DK_THEATRE, 0xB, newGameMode); // initMapFade() + D_80750754 = -2; +} + +void func_80712830(Actor *arg0, s32 exit) { + Actor *temp_a2; // TODO: This is just padding too... hmm + Maps map; + s32 stackpad; + Maps sp20; + s32 sp1C; + + func_80709464(exit); + if (D_807FBB64 & 1) { + arg0->control_state_progress++; + if (D_807FBB68 & 2) { + // K. Rool: Reset Tiny Phase Progress Flags and Round Counter + setFlag(0x5C, TRUE, FLAG_TYPE_TEMPORARY); + map = MAP_DK_ISLES_OVERWORLD; + exit = 0xC; + } else { + map = MAP_TROFF_N_SCOFF; + if (current_map == MAP_FUNGI_SPIDER) { + map = MAP_FUNGI_REAR_PART_OF_MILL; + exit = 1; + } else { + exit = 2; + } + } + func_805FF378(map, exit); + return; + } + if (D_807FBB64 & 0x400) { + arg0->control_state_progress++; + func_805FF800(&sp20, &sp1C); + func_805FF378(sp20, sp1C); + return; + } + if (cc_number_of_players >= 2) { + func_80026D40(arg0, exit); + return; + } + func_805FF1B0(exit); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80712944.s") + +/* +// TODO: Regalloc +void func_80712944(GlobalASMStruct12 *arg0) { + func_8060AC34(arg0); // wrapper for subdragHookFunction() + arg0->unk2 &= D_8075530C; + arg0->unk3 &= D_80755310; + arg0->unk0 &= D_80755308; + arg0->unk8 &= D_8075530C; + arg0->unk9 &= D_80755310; + arg0->unk6 &= D_80755308; + arg0->unkE &= D_8075530C; + arg0->unkF &= D_80755310; + arg0->unkC &= D_80755308; + arg0->unk14 &= D_8075530C; + arg0->unk15 &= D_80755310; + arg0->unk12 &= D_80755308; +} +*/ + +// osGetTime stuff, probably timestamp maths +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80712A40.s") + +void func_80712B80(void) { + if (game_mode == GAME_MODE_DK_TV) { + func_8060B750(D_8075E5C0[D_80755328 * 4]); + current_character_index[0] = func_8060B7C4(); + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80712BD4.s") + +void func_80712EDC(void) { + D_80750AC0 = 1; + func_80712490(MAP_MAIN_MENU, 0, GAME_MODE_MAIN_MENU); +} + +void func_80712F10(Maps *arg0, s32 *arg1) { + if ((game_mode_copy == GAME_MODE_MYSTERY_MENU_MINIGAME) + && (((D_807FBB68 & 2) == 0) + || (current_map == MAP_KROOL_FIGHT_CHUNKY_PHASE) + || (*arg0 == MAP_DK_ISLES_OVERWORLD))) { + *arg0 = MAP_MAIN_MENU; + *arg1 = 0; + game_mode = GAME_MODE_MAIN_MENU; + return; + } + if ((game_mode_copy == GAME_MODE_SNIDES_BONUS_GAME) && (current_map != *arg0)) { + *arg0 = MAP_SNIDES_HQ; + *arg1 = 0; + game_mode = GAME_MODE_ADVENTURE; + return; + } + if (D_80755330 != 0) { + *arg0 = -1; + } +} + +void func_80712FC8(void) { + Maps map; + s32 exit; + + if ((D_80755334 >= 0x5A) && (newly_pressed_input & START_BUTTON)) { + func_80712EDC(); + return; + } + if (D_8075531C == 0) { + if (D_8075532C >= 3) { + func_807124B8(MAP_NINTENDO_LOGO, 0, GAME_MODE_OPENING_CUTSCENE); + return; + } + func_8060B750(D_8075E5C0[D_80755328 * 4]); + func_8060B7D0(&map, &exit); + func_805FF158(1); + func_805FF378(map, exit); + } +} + +void func_80713088(void) { + D_8075531C = 0x1E; + if (newly_pressed_input_copy & A_BUTTON) { + setIntroStoryPlaying(0); + func_80712490(MAP_MAIN_MENU, 0, GAME_MODE_MAIN_MENU); + } +} + +void func_807130D4(void) { + if (func_8061CB50()) { + D_8075531C = 0x1E; + } + if ((D_80755330 == 1) || (D_8075531C == 0) || (newly_pressed_input_copy & A_BUTTON)) { + setIntroStoryPlaying(0); + D_80755330 = 0; + func_80712490(MAP_MAIN_MENU, 0, GAME_MODE_MAIN_MENU); + D_80755330 = 2; + } +} + +void func_80713168(void) { + if ((D_80755334 < 0x1E) || ((newly_pressed_input_copy & (A_BUTTON | START_BUTTON)) == 0)) { + if (D_8075531C == 0) { + block_3: + func_807124B8(MAP_NINTENDO_LOGO, 0, GAME_MODE_OPENING_CUTSCENE); + } + } else { + goto block_3; // TODO: Yikes, this matches, but we should remove this goto + } +} + +void func_807131BC(void) { + Maps map; + s32 exit; + + D_8075532C = 0; + func_8060B750(D_8075E5C0[D_80755328 * 4]); + func_8060B7D0(&map, &exit); + func_805FF158(1); + func_80712490(map, exit, GAME_MODE_DK_TV); +} + +void func_8071321C(void) { + if ((D_8075531C == 0) || ((D_80755334 >= 0xA) && (newly_pressed_input & START_BUTTON))) { + func_807131BC(); + } +} + +void func_80713270(void) { + if ((D_80755324 != 0) || ((game_mode_copy == GAME_MODE_OPENING_CUTSCENE) && (D_80755334 >= 0x5A) && newly_pressed_input & START_BUTTON)) { + func_807124B8(MAP_DK_RAP, 0, GAME_MODE_DK_RAP); + } +} + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807132DC.s") + +s32 *func_805FD030(s32 *arg0); +s32 *func_807132DC(s32 *arg0); // get displaylist? + +/* +s32 *func_807132DC(s32 *arg0) { + s32 *temp_v0; + + temp_v0 = func_805FD030(arg0); // displayList.start() + temp_v0[0] = 0x01000118; + temp_v0[1] = 0xDA380007; + temp_v0[2] = 0xDE000000; + temp_v0[3] = 0x020000C0; + temp_v0[4] = 0xDA380003; + temp_v0[5] = 0x02000180; + temp_v0[6] = 0xE7000000; + temp_v0[7] = 0x00000000; + temp_v0[8] = 0xFFFFF7FB; + temp_v0[9] = 0xFC11FE23; + temp_v0[0xA] = 0xFA000000; + temp_v0[0xB] = 0xFFFFFFFF; + temp_v0[0xC] = 0x004D4394; + temp_v0[0xD] = 0xED028028; + return &temp_v0[0xE]; +} +*/ + +// display list something? probably doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_8071338C.s") + +// display list something? probably doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80713438.s") + +// display list something? probably doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807135B4.s") + +s32 func_8071375C(s32 arg0) { + return arg0; +} + +// display list something? probably doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80713764.s") + +// TODO: This might return a displaylist +void func_807138A4(s32 *arg0) { + func_807135B4(func_807132DC(arg0)); +} + +// display list something? float +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_807138CC.s") + +// display list something? probably doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80713AA8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80713B40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80713C8C.s") + +s32 func_8068E7B4(Gfx* arg0, f32, f32, f32); + +// TODO: Gfx* passed in? +s32 func_80713DFC(s32 arg0) { // displayHelmTimer() + s32 stackPad0; + s32 stackPad1; + s32 stackPad2; + s32 stackPad3; + s32 stackPad4; + s32 stackPad5; + s32 stackPad6; + s32 stackPad7; + f32 sp1C; + Gfx* dl; + + if (func_80712628()) { + if (!(global_properties_bitfield & 3)) { + sp1C = D_80744490 * 0.5f; + dl = func_807132DC(arg0); + gDPSetCombineMode(dl++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(dl++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); + arg0 = func_8068E7B4(dl++, sp1C, 214.0f, D_80755348); // drawHelmTimer() + } + } + return arg0; +} + +s32 func_80713EA8(s32 arg0) { + return arg0; +} + +// GAME_MODE_END_SEQUENCE_DK_THEATRE, structs +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80713EB0.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_114270/func_80714060.s") + +// extern s32 (*D_8075E628[])(void); +// extern s32 (*D_8075E664[])(void); + +// TODO: Why can't these return s32? +int gameIsInDKTVMode(void) { + return game_mode == GAME_MODE_DK_TV + || game_mode == GAME_MODE_UNKNOWN_4 + || game_mode_copy == GAME_MODE_DK_TV + || game_mode_copy == GAME_MODE_UNKNOWN_4; +} + +int gameIsInAdventureMode(void) { + return game_mode_copy == GAME_MODE_ADVENTURE || game_mode == GAME_MODE_ADVENTURE; +} + +int func_80714360(void) { + return game_mode_copy == GAME_MODE_UNKNOWN_8 || game_mode == GAME_MODE_UNKNOWN_8; +} + +int gameIsInQuitGameMode(void) { + return (game_mode_copy == GAME_MODE_QUIT_GAME || game_mode == GAME_MODE_QUIT_GAME) || (game_mode_copy == GAME_MODE_GAME_OVER || game_mode == GAME_MODE_GAME_OVER); +} + +int gameIsInSnidesBonusGameMode(void) { + return game_mode_copy == GAME_MODE_SNIDES_BONUS_GAME || game_mode == GAME_MODE_SNIDES_BONUS_GAME; +} + +int gameIsInMysteryMenuMinigameMode(void) { + return game_mode_copy == GAME_MODE_MYSTERY_MENU_MINIGAME || game_mode == GAME_MODE_MYSTERY_MENU_MINIGAME; +} + +int gameIsInMainMenuMode(void) { + return game_mode_copy == GAME_MODE_MAIN_MENU; +} + +int func_80714464(void) { + return game_mode_copy == GAME_MODE_END_SEQUENCE + || game_mode_copy == GAME_MODE_END_SEQUENCE_DK_THEATRE + || game_mode == GAME_MODE_END_SEQUENCE + || game_mode == GAME_MODE_END_SEQUENCE_DK_THEATRE; +} + +void func_807144B8(u8 arg0) { + Maps map; + s32 exit; + + D_807445B8 = osGetTime(); + D_80755350 = 0; + func_806C9AE0(); + func_80731030(); + func_8060DC3C(arg0, 1); + current_character_index[0] = 0; // DK + if (func_8060C6B8(0xD, 0, 0, current_file) || story_skip) { + // Flag: Isles: Escape Cutscene + if (isFlagSet(0x186, FLAG_TYPE_PERMANENT)) { + map = MAP_DK_ISLES_OVERWORLD; + exit = 0; + } else { + map = MAP_TRAINING_GROUNDS; + exit = 1; + } + } else { + D_80755338 = 1; + map = MAP_DK_ISLES_DK_THEATRE; + D_8075533C = 0; + exit = 0; + } + func_805FF4D8(map, exit); // initMapChange() + game_mode = GAME_MODE_ADVENTURE; +} + +void func_8071458C(void) { + s32 map; + + func_806C9AE0(); + D_80750AB8 = 0; + if (D_807552E4.unk0 == 0) { + D_80750AB8 = 1; + map = MAP_KONG_BATTLE_BATTLE_ARENA; + } else { + map = D_80755384[D_807552E4.unk20]; + } + func_80712490(map, 0, GAME_MODE_ADVENTURE); +} + +void func_807145F8(void) { + D_80755324 = 1; +} + +int func_80714608(s32 arg0) { + return (cc_number_of_players >= 2) && arg0 == D_807552E4.unk0; +} + +void func_80714638(void) { + func_80712EDC(); + D_807552EC = 3; +} + +void func_80714660(void) { + +} diff --git a/src/global_asm/code_119370.c b/src/global_asm/code_119370.c new file mode 100644 index 00000000..db6b7796 --- /dev/null +++ b/src/global_asm/code_119370.c @@ -0,0 +1,433 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_8074450C; + +// TODO: Is this a huge static struct? +// If so, we can match this whole file pre much +extern s32 D_807FDB00; +extern s32 D_807FDB04; +extern s32 D_807FDB08; +extern u8 D_807FDB0C; +extern u8 D_807FDB0D; +extern u8 D_807FDB0E; +extern u8 D_807FDB0F; +extern s32 D_807FDB10; +extern s32 D_807FDB14; +extern u8 D_807FDB18; +extern u16 D_807FDB1A; +extern u8 D_807FDB1C; +extern u8 D_807FDB1D; +extern f32 D_807FDB20; +extern f32 D_807FDB24; +extern u8 D_807FDB28; +extern s32 D_807FDB2C; +extern s32 D_807FDB30; +extern u16 D_807FDB34; +extern u16 D_807FDB36; +extern s16 D_807FDB38; +extern u16 D_807FDB3A; +extern s16 D_807FDB3C; +extern s16 D_807FDB3E; +extern s16 D_807FDB40; +extern s16 D_807FDB42; + +void func_80714A9C(void); + +void func_80714670(void) { + D_807FDB00 = 0; + D_807FDB04 = 0; + D_807FDB08 = 0; + func_80714A9C(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807146A4.s") + +// TODO: Struct? +void func_807146E0(u8 *arg0, u8 *arg1, u8 *arg2) { + *arg1 = arg0[4]; + *arg2 = arg0[5]; +} + +// TODO: Struct? +void func_807146F4(s16 *arg0, s16 *arg1, s16 *arg2) { + *arg1 = arg0[7]; + *arg2 = arg0[8]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80714708.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80714778.s") + +void func_80714944(s32 arg0) { + D_807FDB30 = arg0; +} + +void func_80714950(s32 arg0) { + D_807FDB2C = arg0; +} + +void func_8071495C(void) { + D_807FDB1D = 1; +} + +void func_8071496C(u16 arg0) { + D_807FDB1A = arg0; +} + +void func_8071497C(u16 arg0) { + D_807FDB34 = arg0; +} + +void func_8071498C(s32 arg0) { + D_807FDB14 = arg0; +} + +void func_80714998(u8 arg0) { + D_807FDB1C = arg0; +} + +void func_807149A8(u16 arg0) { + D_807FDB3A = arg0; +} + +void func_807149B8(u8 arg0) { + D_807FDB18 = arg0; +} + +void func_807149C8(u8 arg0, u8 arg1, u8 arg2, u8 arg3) { + D_807FDB0C = arg0; + D_807FDB0D = arg1; + D_807FDB0E = arg2; + D_807FDB0F = arg3; +} + +void func_807149FC(s32 arg0) { + D_807FDB10 = arg0; +} + +void func_80714A08(f32 arg0, f32 arg1) { + D_807FDB20 = arg0; + D_807FDB24 = arg1; + D_807FDB28 = 1; +} + +void func_80714A28(u16 arg0) { + D_807FDB36 = arg0; +} + +void func_80714A38(u8 arg0) { + D_807FDB36 |= arg0; +} + +void func_80714A58(u16 arg0) { + D_807FDB38 = arg0; +} + +void func_80714A68(s16 arg0, s16 arg1, s16 arg2, s16 arg3) { + D_807FDB3C = arg0; + D_807FDB3E = arg1; + D_807FDB40 = arg2; + D_807FDB42 = arg3; +} + +void func_80714A9C(void) { + D_807FDB0F = 0; + D_807FDB10 = 1; + D_807FDB14 = 0; + D_807FDB18 = 0; + D_807FDB1C = 1; + D_807FDB1A = 0; + D_807FDB1D = 0; + D_807FDB28 = 0; + D_807FDB2C = 0; + D_807FDB30 = 0; + D_807FDB36 = 0; + D_807FDB38 = -1; + D_807FDB3C = D_8074450C * 0xA; + D_807FDB3E = D_8074450C * 0xA; + D_807FDB40 = D_8074450C * 0x135; + D_807FDB42 = D_8074450C * 0xE5; + D_807FDB3A = 0x258; +} + +s32 func_80714D08(void*, f32, f32, f32, f32, s32, s32, s32, s32); + +void func_80714B84(s32 arg0, f32 arg1, s32 arg2, s32 arg3, u8 arg4) { + f32 sp3C; + f32 sp38; + f32 sp34; + + func_806335B0(arg2, 1, arg3, &sp3C, &sp38, &sp34); + func_80714D08(arg0, arg1, sp3C, sp38, sp34, 0, arg2, arg3, arg4); +} + +s32 func_80714C08(s32 arg0, f32 arg1, Actor *arg2, s32 arg3, u8 arg4) { + f32 sp3C; + f32 sp38; + f32 sp34; + + func_80671C0C(arg2, arg3, &sp3C, &sp38, &sp34); + if (!(arg2->object_properties_bitfield & 0x200) && (arg2->animation_state != NULL) && (D_807FDB36 & 0x80)) { + func_80714A38(0x40); + } + return func_80714D08(arg0, arg1, sp3C, sp38, sp34, arg2, 0, arg3, arg4); +} + +s32 func_80714CC0(void* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + return func_80714D08(arg0, arg1, arg2, arg3, arg4, 0, 0, 0, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80714D08.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071509C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80715270.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071586C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807158C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80715908.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80715A3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80715B30.s") + +void func_80715E38(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5) { + f32 temp_f0; + f32 temp_f16; + f32 temp_f2; + + temp_f0 = arg0 - arg3; + temp_f2 = arg1 - arg4; + temp_f16 = arg2 - arg5; + sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2) + (temp_f16 * temp_f16)); +} + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80715E94.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80716F10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80716FB4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717100.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071720C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717404.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717760.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717814.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717B64.s") + +// Very doable, possibly same struct as func_8071C818 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717CE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717D4C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717D84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717DB4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80717F1C.s") + +// Doable, large struct, that sprite thing? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80718080.s") + +void func_807180F4(s32 arg0, s32 arg1) { + func_80717D4C(); + func_80716FB4(arg0, arg1); +} + +extern s32 D_80718380; // Function pointer? +extern s32 D_8071FEF4; + +void func_80718124(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + func_807149B8(1); + func_80714998(3); + func_8071498C(&D_80718380); + func_80714CC0(&D_8071FEF4, arg0, arg1, arg2, arg3); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80718188.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071827C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80718380.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807184F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807186C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807189BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80718BF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071910C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807195D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_807197B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80719A0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80719B88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80719C00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_80719EF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071A038.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071A1E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071A440.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071A674.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071A8B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071AADC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071ABDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071AF30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B1AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B24C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B2EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B44C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B520.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B758.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B89C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071B8EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071BB14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071BC80.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071BE04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C004.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C24C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C48C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C620.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C818.s") + +/* +// TODO: Is this a different struct? +// 0x35C is alpha in this function +extern u8 D_807444FC; +extern f64 D_8075E9C8; + +void func_8071C818(otherSpriteControl *arg0, s8 *arg1) { + float sp70[4][4]; + float sp30[4][4]; + f64 temp_f2; + + temp_f2 = D_8075E9C8; + arg0->xScale -= temp_f2; + arg0->yScale -= temp_f2; + if (arg0->xScale <= 0.0f) { + *arg1 = 1; + } + arg0->unk35C += 5; + guScaleF(&sp70, arg0->xScale, arg0->yScale, 0.0f); + guRotateF(&sp30, arg0->unk35C, 0.0f, 0.0f, 1.0f); + guMtxCatF(&sp70, &sp30, &sp70); + guMtxF2L(&sp70, arg0 + (D_807444FC << 6) + 0x128); + arg0->unk32C = 2; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C914.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071C9E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071CDE0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071D0F0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071D260.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071D28C.s") + +// More sprite stuff? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071D5BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071D784.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071D94C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071DB74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071DC90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071E028.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071E110.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071E1C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071E3EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071E864.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071EA24.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071EB70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071EDEC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071EEA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071EEE0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071EFDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F034.s") + +/* +// TODO: Which struct is this.. otherSpriteControl? +void func_8071F034(void *arg0, s32 arg1) { + if (arg0->unk34E == 0) { + arg0->unk340 = player_pointer->x_position; + arg0->unk344 = player_pointer->y_position; + arg0->unk348 = player_pointer->z_position; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F078.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F1D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F2F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F3C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F444.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F660.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F758.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_119370/func_8071F8E4.s") diff --git a/src/global_asm/code_127B00.c b/src/global_asm/code_127B00.c new file mode 100644 index 00000000..1f94d802 --- /dev/null +++ b/src/global_asm/code_127B00.c @@ -0,0 +1,119 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80722E00(s32 map) { + void *paths; + + paths = getPointerTableFile(0xF, map, 1, 1); + func_80722E48(paths); + func_8066B434(paths, 0x47, 0x27); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80722E48.s") + +// Used in func_80722FEC as well as func_807245D8. +typedef struct global_asm_struct_3 { + s32 unk0; // Pointer + s16 unk4; // Unknown, seen value of 2 +} GlobalASMStruct3; + +extern GlobalASMStruct3 *D_807FDB90[]; + +s32 func_80722FEC(u8 arg0) { + if (D_807FDB90[arg0]) { + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80723020.s") + +typedef struct { + u8 pad0[0x14]; + s8 unk14; + s8 unk15; + s8 unk16; + s8 unk17; + s32 unk18; + s32 unk1C; + s8 unk20; + s8 unk21; +} GlobalASMStruct00; + +extern GlobalASMStruct00* D_807FDBF8[]; + +void func_80723284(s32 arg0, u8 arg1) { + if (arg0 != -1 && D_807FDBF8[arg0]) { + D_807FDBF8[arg0]->unk20 = arg1; + } +} + +void func_807232B8(s32 arg0, u8 arg1) { + if (arg0 != -1 && D_807FDBF8[arg0]) { + D_807FDBF8[arg0]->unk16 = arg1; + } +} + +void func_807232EC(s32 arg0, u8 arg1) { + if (arg0 != -1 && D_807FDBF8[arg0]) { + D_807FDBF8[arg0]->unk15 = arg1; + } +} + +void func_80723320(s32 arg0, s32 arg1) { + if (arg0 != -1 && D_807FDBF8[arg0]) { + D_807FDBF8[arg0]->unk18 = arg1; + } +} + +void func_8072334C(s32 arg0, u8 arg1) { + if (arg0 != -1 && D_807FDBF8[arg0]) { + D_807FDBF8[arg0]->unk21 = arg1; + } +} + +void func_80723380(s32 arg0, u8 arg1) { + if (arg0 != -1 && D_807FDBF8[arg0]) { + D_807FDBF8[arg0]->unk14 = arg1; + } +} + +// TODO: Very doable, loop thingy, might need a pointer defined +// Actor* arg0 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_807233B4.s") + +void func_80723428(s32 arg0) { + if (arg0 == -1 || D_807FDBF8[arg0]) { + func_8061130C(D_807FDBF8[arg0]); + D_807FDBF8[arg0] = NULL; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80723484.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_807238D4.s") + +u8 func_80723C98(s32 arg0) { + if (arg0 == -1 || !D_807FDBF8[arg0]) { + return 0; + } + return D_807FDBF8[arg0]->unk21; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80723CCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80723F88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80724154.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80724308.s") + +s16 func_807245D8(s32 arg0) { + return D_807FDB90[arg0]->unk4; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_807245F0.s") + +// Unknown struct arg0, only function that calls it is a jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_127B00/func_80724874.s") diff --git a/src/global_asm/code_1295B0.c b/src/global_asm/code_1295B0.c new file mode 100644 index 00000000..e3a0866b --- /dev/null +++ b/src/global_asm/code_1295B0.c @@ -0,0 +1,254 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807248B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724994.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724A20.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724A9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724B5C.s") + +void func_80724C2C(s16 arg0) { + current_actor_pointer->y_rotation = \ + current_actor_pointer->unkEE = D_807FBD6C->unkEE + 0x800 & 0xFFF; + current_actor_pointer->unkB8 = arg0; +} + +extern s32 D_80755690; + +typedef struct { + s16 count; + s16 unk2; + EnemySpawner *firstSpawner; +} EnemySpawnerLocator; + +extern EnemySpawnerLocator *D_80755694; + +void func_80724C78(s32 arg0) { + func_80728300(arg0, D_80755690, D_80755694); +} + +// TODO: Very doable, just need to define ActorAnimationState->unk1C as an array of 0x8 big structs +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724CA4.s") + +// TODO: Doable, more struct definitions needed +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724D28.s") + +// TODO: ActorAnimationState->unk20 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724DB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80724E48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807255A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80725B38.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80725BA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80725DC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80725ED4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80726164.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807264B0.s") + +typedef struct global_asm_struct_8 { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s16 unk8; +} GlobalASMStruct8; + +void func_807266E8(Actor *arg0, GlobalASMStruct8 *arg1) { + arg0->x_position = arg1->unk4; + arg0->y_position = arg1->unk6; + arg0->unk8C = arg1->unk6; + arg0->z_position = arg1->unk8; + arg0->y_rotation = arg1->unk2; +} + +// Jumptable, references the cutscene model mapping table at D_8075570C +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80726744.s") + +u8 func_80726DEC(u8, s32); + +u8 func_80726D7C(u8 arg0) { + return func_80726DEC(arg0, 5) || func_80726DEC(arg0, 6); +} + +u8 func_80726DC0(u8 arg0) { + return func_80726DEC(arg0, 7); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80726DEC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80726E60.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80726EE0.s") + +Actor *func_807270C0(s16, u16); // getSpawnerTiedActor() +void func_80678428(Actor*); + +void func_8072707C(s16 arg0, u8 arg1, u16 arg2) { + Actor *actor = func_807270C0(arg0, arg2); + if (actor) { + actor->control_state = arg1; + actor->control_state_progress = 0; + } +} + +// getSpawnerTiedActor() +Actor *func_807270C0(s16 spawn_trigger, u16 arg1) { + s16 i; + EnemySpawner *var_v1; + + var_v1 = D_80755694->firstSpawner; + i = 0; + while (i < D_80755694->count) { + if (spawn_trigger == var_v1->spawn_trigger) { + if (var_v1->spawn_state == 5) { + var_v1->properties_bitfield |= arg1; + return var_v1->tied_actor; + } + if ((var_v1->spawn_state == 6) && (arg1 & 0x400)) { + func_80678428(var_v1->tied_actor); + var_v1->spawn_state = 5; + return var_v1->tied_actor; + } + } + i++; + var_v1++; + } + return NULL; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80727194.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807271F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807273A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_8072752C.s") + +/* +s16 func_80665DE0(f32, f32, f32, f32); +s32 func_807271F4(s16, s16, s16, s16, s32, s32, s32); + +// TODO: Everything matches apart from stack offset +void func_8072752C(s16 arg0, s16 x1, s16 y1, s16 z1, s16 x2, s16 y2, s16 z2, s16 arg7, s16 arg8) { + s16 sp46; + f32 sp40; + s32 dx, dy, dz; + // s32 temp; + + dx = (x2 - x1) * (x2 - x1); + dy = (y2 - y1) * (y2 - y1); + dz = (z2 - z1) * (z2 - z1); + sp46 = func_80665DE0(x2, z2, x1, z1); + sp40 = sqrtf(dx + dy + dz); + if (func_807271F4(arg0, x1, y1, z1, sp46, sqrtf(dx + dz) / (sp40 / arg7), arg8)) { + D_807FBB44->control_state = 0x17; + D_807FBB44->control_state_progress = 0; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80727678.s") + +// Unknown struct arg0 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807278C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80727958.s") + +// TODO: Regalloc v1 a3 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80727F20.s") + +extern u8 D_80755698[]; + +u8 func_80652F24(s16, s16); + +/* +// TODO: Regalloc v1 a3 +u8 func_80727F20(EnemyInfo *arg0, s32 arg1) { + f32 dz, dy, dx; + + dz = character_change_array[0].look_at_eye_z - arg0->z_position; + dx = character_change_array[0].look_at_eye_x - arg0->x_position; + dy = character_change_array[0].look_at_eye_y - arg0->y_position; + + return ((dz * dz) + ((dx * dx) + (dy * dy)) < arg1) + && ((D_80755698[arg0->unk44] == 6) || (arg0->unk46 & 0x20) || func_80652F24(0, arg0->unk40)); +} +*/ + +// Very doable, dx,dy,dz and a large conditional check at the end that will need to be simplified +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80728004.s") + +// Very doable, dx,dy,dz and a large conditional check at the end that will need to be simplified +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807280C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_8072818C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_8072827C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_80728300.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_8072881C.s") + +void func_806883F4(Actor *arg0, s32 arg1, s32 arg2, f32 arg3); +void func_8068842C(Actor *arg0, s32 arg1, s32 arg2); +void func_80688460(Actor *arg0, s32 arg1, s32 arg2); +void func_80688370(Actor*, u8, f32); + +//s32 func_80688540(Actor*, u8); + +/* +// TODO: Pretty close, might be missing a temp variable? +// Datatypes could also differ for the & 0x7F function calls +u8 func_8072881C(s32 arg0, u32 *arg1) { + u8 phi_v1 = FALSE; + if ((arg0 & 0x80) + || (*arg1 + 50 < object_timer + && (((rand() >> 0xF) % 1000) < 0x3C1) == 0 + && !func_80688540(current_actor_pointer, arg0))) { + func_80688370(current_actor_pointer, arg0 & 0x7F, 1.0f); + func_806883C8(current_actor_pointer, arg0 & 0x7F, 1); + func_8068839C(current_actor_pointer, arg0 & 0x7F, 0); + func_806884B8(current_actor_pointer, arg0 & 0x7F, 3); + func_80688514(current_actor_pointer, arg0 & 0x7F); + func_806883F4(current_actor_pointer, arg0 & 0x7F, 0, 0); + func_8068842C(current_actor_pointer, arg0 & 0x7F, 2); + *arg1 = object_timer; + phi_v1 = TRUE; + } + return phi_v1; +} +*/ + +void func_80728950(u8 arg0) { + func_8068842C(current_actor_pointer, arg0, 1); + func_80688460(current_actor_pointer, arg0, 1); + func_806883F4(current_actor_pointer, arg0, 2, 0); +} + +void func_807289B0(u8 arg0, u8 arg1) { + func_806883F4(current_actor_pointer, arg0, arg1, 0); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1295B0/func_807289E8.s") + +void func_80729AA4(u8 arg0) { + Actor *actor = func_807270C0(arg0, 0); // getSpawnerTiedActor() + if (!actor) { + actor = player_pointer; + } + actor->unk6A |= 0x100; +} diff --git a/src/global_asm/code_12E800.c b/src/global_asm/code_12E800.c new file mode 100644 index 00000000..39e1834c --- /dev/null +++ b/src/global_asm/code_12E800.c @@ -0,0 +1,327 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80614D00(Actor *, f32, f32); +extern s32 D_8071FB34; +extern s32 D_80717D4C; +extern s32 D_8071FF18; +extern f64 D_8075FF20; +void func_806A5DF0(s32, f32, f32, f32, s32, s32, s32, s32); +void func_806F8BC4(s32, s32, s32); +void func_806F91B4(u8, u8, s16); +s16 func_806CC190(s16, s16, f32); +s32 func_80665DE0(f32, f32, f32, f32); +s16 func_806CC190(s16, s16, f32); + +extern f64 D_8075FF38; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_80729B00.s") + +void func_80729E6C(void) { + current_actor_pointer->y_velocity += current_actor_pointer->y_acceleration; + if (current_actor_pointer->y_velocity < current_actor_pointer->terminal_velocity) { + current_actor_pointer->y_velocity = current_actor_pointer->terminal_velocity; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_80729EB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072A450.s") + +extern f64 D_8075FD28; +extern s32 D_80720120; // TODO: Datatype + +// killEnemy +void func_8072A714(void) { + if ((current_actor_pointer->interactable & 2) && (func_80666A94() || func_80666AA0())) { + if (func_80666AA0()) { + func_80714CC0( + &D_80720120, + current_actor_pointer->animation_state->scale_y * D_8075FD28, + current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position + ); + } + current_actor_pointer->control_state = 0x40; + enemies_killed++; + } +} + +void func_8072A7DC(void) { + if ((D_807FDC90->unk1A & 0x40) == 0) { + if ((current_actor_pointer->x_position == current_actor_pointer->unk88) && (current_actor_pointer->z_position == current_actor_pointer->unk90)) { + D_807FDC90->unk38++; + if (D_807FDC90->unk38 >= 0x1F) { + D_807FDC90->unk1A |= 0x40; + } + } else { + D_807FDC90->unk38 = 0; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072A86C.s") + +f32 func_80612794(s16); +void func_8072AB74(u8, f32, f32, u16, f32); + +/* +// TODO: t8 a3 regalloc? Odd one +void func_8072A86C(u8 arg0, f32 arg1, f32 arg2, f32 arg3, u16 arg4) { + current_actor_pointer->y_velocity = func_80612794(current_actor_pointer->unkF0) * -arg3; + func_8072AB74(arg0, arg1, arg2, (arg4 | 0x1080) & 0xFFFF, current_actor_pointer->unk15E * 0.5); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072A920.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072AA80.s") + +/* +// TODO: Surprisingly close, might have type conflicts with D_807FDC9C[0].unkA +void func_8072AA80(void) { + s16 phi_a0; + + if (D_807FDC9C[0].unkA) { + phi_a0 = D_807FDC9C[0].unk6 + current_actor_pointer->unk15E + D_807FDC9C[0].unkA; + } else { + phi_a0 = (s16)current_actor_pointer->unkAC - current_actor_pointer->unk15E; + } + D_807FDC90->unkC = (((rand(phi_a0) >> 0xF) % 32767) + % ((phi_a0 - D_807FDC9C[0].unk6 + current_actor_pointer->unk15E) + 1)) + + D_807FDC9C[0].unk6 + current_actor_pointer->unk15E; +} +*/ + +// TODO: Huge, and actually seems super doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072AB74.s") + +void func_8072B324(Actor *arg0, s32 arg1) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + PaaD->unk26 = arg1; +} + +void func_8072B330(u16 arg0) { + f32 phi_f2 = MIN(3.0, current_actor_pointer->unkB8 * D_807FDC98->unk38); + + if (current_actor_pointer->unk6A & 4) { + phi_f2 *= 0.5; + } + if (!(D_807FDC98->unk3C < phi_f2)) { + phi_f2 = D_807FDC98->unk3C; + } + if ((!(arg0 & 0x400) || !(phi_f2 < 1.0)) && !(arg0 & 0x200) && (phi_f2 != current_actor_pointer->animation_state->unk48)) { + func_80614D00(current_actor_pointer, phi_f2, 0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072B438.s") + +void func_8072B59C(u8 arg0, s16 arg1, s32 arg2) { + current_actor_pointer->control_state = arg0; + current_actor_pointer->control_state_progress = 0; + if (arg2 != current_actor_pointer->animation_state->unk64) { + func_80614EBC(current_actor_pointer, arg2); + } + func_8072B324(current_actor_pointer, arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072B608.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072B79C.s") + +/* +// Regalloc +void func_8072B79C(s16 arg0, u16 arg1, s16 arg2) { + D_807FDC98->unk26 = arg0; + D_807FDC98->unk28 = arg1; + D_807FDC98->unk2A = arg2; +} +*/ + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072B7CC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072C670.s") + +void func_8072C870(u8 arg0, u8 arg1, s32 arg2) { + if (arg0 == 7) { + if (func_80725ED4(1, current_actor_pointer, D_807FDCA0, &D_807FDC90->unkA, &D_807FDC90->unkC, &D_807FDC90->unkE) == 0) { + arg0 = 0x10; + func_8072B324(current_actor_pointer, D_807FDC9C[0].unkD); + } + } + D_807FDC90->unk36 = arg0; + func_8072B59C(arg0, arg1, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072C918.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072CFE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072D08C.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072D13C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072D714.s") + +void func_8072D99C(void) { + current_actor_pointer->noclip_byte = 1; + current_actor_pointer->control_state = 0x40; + enemies_killed++; +} + +void func_8072D9D4(void) { + func_80714CC0(&D_8071FB34, 0.55f, current_actor_pointer->x_position, current_actor_pointer->y_position + (current_actor_pointer->unk15E * 0.5), current_actor_pointer->z_position); +} + +void func_8072DA60(void) { + func_80714CC0(&D_8071FB34, + 0.55f, + D_807FBD6C->x_position, + D_807FBD6C->y_position, + D_807FBD6C->z_position); +} + +void func_8072DAA4(void) { + func_80714998(2); + func_807149B8(1); + func_8071498C(&D_80717D4C); + func_80714950(-0x28 - ((rand() >> 0xF) % 15)); + func_80714CC0(&D_8071FF18, + (((rand() >> 0xF) % 1000) / D_8075FF20) + 0.5, + current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position); +} + +void func_8072DB68(s32 arg0) { + u8 phi_v1; + s16 phi_s0; + + if (func_806F8AD4(0xB, cc_player_index) >= 4) { + phi_v1 = 3; + } else { + phi_v1 = func_806F8AD4(0xB, cc_player_index); + } + func_806F91B4(0xB, cc_player_index, -phi_v1); + func_806F8BC4(0xB, 0, 0); + playSong(0x41, 1.0f); + for (phi_s0 = 0; phi_s0 < phi_v1; phi_s0++) { + func_806A5DF0(0x36, player_pointer->x_position, player_pointer->y_position, player_pointer->z_position, (player_pointer->y_rotation + (phi_s0 * 0xC8)) - 0xC8, 1, -1, 0); + } +} + +void func_8072DC7C(u8 arg0) { + func_8072AB74(0x37, 0.0f, 0.0f, 0x32, 0.0f); + current_actor_pointer->shadow_opacity -= arg0; + if (current_actor_pointer->shadow_opacity < 0) { + current_actor_pointer->control_state_progress++; + current_actor_pointer->shadow_opacity = 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072DCF4.s") + +/* +s32 func_8061CB50(f64, s32); // TODO: This signature is sus +f32 func_80665AE4(s32, s32, s32, s32); +extern f64 D_8075FF28; +extern f64 D_8075FF30; + +s32 func_8072DCF4(Actor *arg0, Actor *arg1, u16 arg2) { + s16 temp_f6; + s16 temp_f8; + s32 phi_a0; + + temp_f8 = ((D_8075FF28 - func_80665AE4(arg1->x_position, arg1->z_position, arg0->x_position, arg0->z_position)) / D_8075FF28) * 65536.0; + temp_f6 = (arg0->y_rotation / D_8075FF30) * 65536.0; + if (temp_f6 < temp_f8) { + phi_a0 = temp_f8 - temp_f6; + } else { + phi_a0 = temp_f6 - temp_f8; + } + if ((phi_a0 < arg2) && !func_8061CB50(D_8075FF28, phi_a0)) { + return TRUE; + } + return FALSE; +} +*/ + +void func_8072DE10(u16 arg0) { + func_8072DCF4(current_actor_pointer, D_807FDC94, arg0); +} + +void func_8072DE44(s32 arg0) { + current_actor_pointer->control_state = D_807FDC9C[0].unk10; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, arg0); + func_8072B324(current_actor_pointer, D_807FDC9C[0].unkC); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072DEA8.s") + +void func_8072E02C(void) { + current_actor_pointer->z_rotation = func_806CC190(current_actor_pointer->z_rotation, 0, 5.0f); + current_actor_pointer->x_rotation += (-current_actor_pointer->x_rotation * D_8075FF38); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072E0A8.s") + +/* +// Quite close, float regalloc and stack/datatype issues +u8 func_8072E0A8(s32 arg0, s16 arg1) { + u8 sp1F; + f32 dx; + f32 dz; + s32 temp_v0_2; + s16 phi_v1; + + dz = D_807FDC94->z_position - current_actor_pointer->z_position; + dx = D_807FDC94->x_position - current_actor_pointer->x_position; + sp1F = FALSE; + if (((dx * dx) + (dz * dz)) < (arg0 * arg0)) { + sp1F = TRUE; + } + temp_v0_2 = func_80665DE0(D_807FDC94->x_position, D_807FDC94->z_position, current_actor_pointer->x_position, current_actor_pointer->z_position); + if (temp_v0_2 < current_actor_pointer->y_rotation) { + phi_v1 = current_actor_pointer->y_rotation - temp_v0_2; + } else { + phi_v1 = temp_v0_2 - current_actor_pointer->y_rotation; + } + if (phi_v1 > 0x800) { + phi_v1 = 0x1000 - phi_v1; + } + return phi_v1 < arg1 + && sp1F + && D_807FDC94->control_state != 0x42; +} +*/ + +void func_8072E1A4(u8 arg0, Actor *arg1) { + current_actor_pointer->y_rotation = func_806CC190(current_actor_pointer->y_rotation, func_80665DE0(arg1->x_position, arg1->z_position, current_actor_pointer->x_position, current_actor_pointer->z_position), arg0); +} + +u8 func_8072E22C(u16 arg0) { + f32 dx = current_actor_pointer->x_position - D_807FDC94->x_position; + f32 dy = current_actor_pointer->y_position - D_807FDC94->y_position; + f32 dz = current_actor_pointer->z_position - D_807FDC94->z_position; + return ((dx * dx) + (dy * dy) + (dz * dz)) < (arg0 * arg0); +} + +void func_8072E2B0(Actor *arg0, f32 *arg1, f32 *arg2, f32 *arg3) { + if (arg0->unkCC) { + func_80671C0C(arg0, arg0->unkCC, arg1, arg2, arg3); + } else { + *arg1 = arg0->x_position; + *arg2 = arg0->y_position; + *arg3 = arg0->z_position; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072E320.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_8072E54C.s") diff --git a/src/global_asm/code_131B0.c b/src/global_asm/code_131B0.c new file mode 100644 index 00000000..229541d4 --- /dev/null +++ b/src/global_asm/code_131B0.c @@ -0,0 +1,313 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_8060EC54(s32); +void func_8060E6E8(s32); +u8 func_8060AC28(); +void func_8060E4D0(u8); +void func_8060E664(u8); +void func_8060EC54(s32); +void func_8060E8CC(Struct807F0470*); +u8 func_8060AB38(s32); + +extern s32 D_80746810; +extern u8 D_80746818; +extern u8 D_8076A0B1; +extern u8 D_807ECD09; +extern OSMesgQueue D_807ECCF0; + +void func_8060E4B0(Struct807F0470 *arg0) { + bzero(arg0, sizeof(Struct807F0470)); +} + +void func_8060E4D0(u8 arg0) { + Struct807F0470 *temp = &D_807F0470[arg0]; + + if (osMotorStartStop(&D_807F02D0[arg0], 1) == 4) { + func_8060E4B0(temp); + temp->unk0 = 3; + } else { + temp->unk4 = 1; + } +} + +void func_8060E574(u8 arg0) { + OSPfs *temp_a1; + + switch (osMotorInit(&D_807ECCF0, &D_807F02D0[arg0], arg0)) { + case 0: + D_807F0470[arg0].unk0 = 1; + return; + case 1: + D_807F0470[arg0].unk0 = 0; + return; + case 11: + D_807F0470[arg0].unk0 = 2; + return; + case 4: + D_807F0470[arg0].unk0 = 3; + return; + } +} + +void func_8060E664(u8 arg0) { + func_8060E574(arg0); + osMotorStartStop(&D_807F02D0[arg0], 0); + osMotorStartStop(&D_807F02D0[arg0], 0); + osMotorStartStop(&D_807F02D0[arg0], 0); + D_807F0470[arg0].unk4 = 0; +} + +void func_8060E6E8(s32 arg0) { + s32 phi_s0; + s32 phi_s3; + + for (phi_s3 = 0; phi_s3 < 4; phi_s3++) { + func_8060E4B0(&D_807F0470[phi_s3]); + D_807F0470[phi_s3].unk0 = 0; + if (D_807ECD09 & (1 << phi_s3)) { + for (phi_s0 = 0; phi_s0 < 2; phi_s0++) { + func_8060E664(phi_s3); + } + } + } +} + +s32 func_8060E79C(u8 arg0) { + if (arg0 >= 4) { + return 0; + } + return D_807F0470[func_8060AB38(arg0)].unk0; +} + +// TODO: Cleanup, get rid of the block label +void func_8060E7EC(u8 arg0, u8 arg1, s32 arg2) { + Struct807F0470 *temp_a0 = &D_807F0470[func_8060AB38(arg0)]; + + if ((D_80746810 != 1) + && (temp_a0->unk0 == 1) + && (character_change_array[arg0].unk2EB == 0) + && (gameIsInAdventureMode() || gameIsInMysteryMenuMinigameMode()) + ) { + if (temp_a0->unk12 != 0) { + if (temp_a0->unk10 < 0x1F) { + temp_a0->unk12 = 0; + temp_a0->unk10 = 0; + goto block_8; + } + } else { +block_8: + temp_a0->unkC = arg2; + temp_a0->unk5 = arg1; + } + } +} + +void func_8060E8CC(Struct807F0470 *arg0) { + if (arg0->unk0 == 1) { + arg0->unk5 = 0; + arg0->unkC = 0; + } +} + +void func_8060E8EC(u8 arg0) { + func_8060E8CC(&D_807F0470[func_8060AB38(arg0)]); +} + +void func_8060E930() { + func_8060E6E8(1); + func_8060EC54(1); +} + +void func_8060E958() { + func_8060E6E8(0); + func_8060EC54(1); +} + +// TODO: Why can't this be s32 and still match? +int func_8060E980(void) { + return (global_properties_bitfield & 0x4002) + || (D_8076A0B1 & 1) + || func_8062919C() + || func_8061CB50() + || (!gameIsInAdventureMode() && !gameIsInMysteryMenuMinigameMode() && !gameIsInSnidesBonusGameMode()); +} + +void func_8060EA28(void) { + Struct807F0470 *phi_s0; + s32 temp; + s32 phi_s1; + u8 sp23; + + phi_s0 = &D_807F0470[0]; + if (D_80746810 == 1) { + if (!func_8060E980()) { + func_8060EC54(0); + } + } else if (func_8060E980()) { + func_8060EC54(1); + } + if (D_80746818) { + func_8060E6E8(0); + } + D_80746818 = 0; + if (D_80746810 != 1) { + sp23 = func_8060AC28(); + for (phi_s1 = 0; phi_s1 < 4; phi_s1++) { + if (phi_s0->unk0 != 1) { + if (((D_807ECD09 & (1 << phi_s1))) && ((sp23 & (1 << phi_s1))) && ((object_timer % 15U) == 0)) { + func_8060E664(phi_s1); + } + } else { + if (phi_s0->unk12 == 0) { + phi_s0->unk12 = (phi_s0->unk10 >= 0x33); + } + if ((phi_s0->unkC == 0) && (phi_s0->unk5 == 0)) { + if (phi_s0->unk10 != 0) { + phi_s0->unk10--; + } + } + if (phi_s0->unk5 == 0) { + if (phi_s0->unk4) { + func_8060E664(phi_s1); + } + } else { + if (phi_s0->unkC) { + phi_s0->unkC--; + phi_s0->unk10++; + } + if ((phi_s0->unkC == 0) || phi_s0->unk12) { + func_8060E8CC(phi_s0); + } else { + if (phi_s0->unk8 >= 0x100U) { + if (phi_s0->unk4 == 0) { + func_8060E4D0(phi_s1); + } + phi_s0->unk8 -= 0x100; + } else { + temp = phi_s0->unk5; + phi_s0->unk8 += temp * 4; + if (phi_s0->unk4) { + func_8060E664(phi_s1); + } + } + } + } + } + phi_s0++; + } + } +} + +void func_8060EC54(s32 arg0) { + if (arg0 != D_80746810) { + D_80746810 = arg0; + D_80746818 = 1; + } +} + +// osCreateThread, osStartThread, function pointer, neat +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060EC80.s") + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; +} GlobalASMStruct6; + +typedef struct { + u8 pad0[0x260 - 0x0]; + s32 unk260; + s32 unk264; + s32 unk268; + GlobalASMStruct6 *unk26C; + s32 unk270; + s32 unk274; +} GlobalASMStruct87; + +void func_8060ED6C(GlobalASMStruct87 *arg0, GlobalASMStruct6 *arg1, s32 arg2, s32 arg3, s32 arg4) { + OSIntMask oldInterruptMask = osSetIntMask(OS_IM_NONE); + arg1->unk4 = arg2; + arg1->unk0 = arg0->unk260; + arg0->unk260 = arg1; + arg1->unk8 = arg3; + arg1->unkC = arg4; + osSetIntMask(oldInterruptMask); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060EDD0.s") + +s32 func_8060EE58(s32 arg0) { + return arg0 + 0x58; +} + +// Jumptable, appears to be the main function of a thread +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060EE60.s") + +s32 func_8060F928(GlobalASMStruct87*, GlobalASMStruct6*); + +void func_8060F1D0(GlobalASMStruct87 *arg0, GlobalASMStruct6 *arg1) { + func_8060F928(arg0, arg1); + if (arg0->unk274 == 0) { + func_8060F960(arg0, 1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F208.s") + +/* +// TODO: Which types are these? +void func_8060F208(void *arg0) { + if (arg0->unk274 != 0) { + func_8060FA5C(); + return; + } + D_807F04D0.unk0 = 0; + D_807F04D0.unk4D4 = 0; + func_8060F960(0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F254.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F54C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F730.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F854.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F928.s") + +/* +s32 func_8060F928(GlobalASMStruct87 *arg0, GlobalASMStruct6 *arg1) { + s32 temp_v0; + + temp_v0 = arg1->unk10; + if (temp_v0 == 2) { + //*arg0->unk26C = arg1; + arg0->unk26C = arg1; + } else { + //*arg0->unk270 = arg1; + arg0->unk270 = arg1; + } + arg1->unk0 = 0; + arg1->unk4 = 2; + return temp_v0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060F960.s") + +// D_807F04C0.unk4C4 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060FA5C.s") + +void func_8060FAA4(OSMesgQueue *arg0, OSMesg arg1, s32 arg2) { + osGetTime(); + osGetTime(); + osSendMesg(arg0, arg1, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_131B0/func_8060FAE4.s") diff --git a/src/global_asm/code_1332B0.c b/src/global_asm/code_1332B0.c new file mode 100644 index 00000000..85d37140 --- /dev/null +++ b/src/global_asm/code_1332B0.c @@ -0,0 +1,52 @@ +#include +#include "functions.h" +#include "variables.h" + +u8 func_8072E5B0(void) { + return !(player_pointer->unk6A & 1) + && !(player_pointer->locked_to_pad == 1) + && !(player_pointer->control_state == 0x63); // Rocketbarrel +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1332B0/func_8072E5FC.s") + +typedef struct { + s16 unk0; + s16 unk2; + s32 unk4; + s32 unk8; + s32 unkC; +} GlobalASMStruct67; + +extern GlobalASMStruct67 D_807557A0[]; + +// TODO: This stack is super sus, fake match? +void func_8072E740(Maps map) { + s32 i; + void *loadingZones; + s32 temp; + s32 temp2 = 0x27; + s32 temp3; + s32 sp30; + + // Loading zones + loadingZones = getPointerTableFile(0x12, map, 1, 0); + func_8072E5FC(loadingZones); + if (loadingZones) { + func_8066B434(loadingZones, 0xC1, 0x3D); + } + for (i = 0; i < temp2; i++) { + func_8072E7DC(D_807557A0[i].unk2, &sp30); + D_807557A0[i].unk8 = sp30; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1332B0/func_8072E7DC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1332B0/func_8072E868.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1332B0/func_8072EA90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1332B0/func_8072EC94.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1332B0/func_8072ECFC.s") diff --git a/src/global_asm/code_133A90.c b/src/global_asm/code_133A90.c new file mode 100644 index 00000000..734dd894 --- /dev/null +++ b/src/global_asm/code_133A90.c @@ -0,0 +1,139 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_8061134C(s32); +s32 func_8063367C(s32, s32, s32); +s32 func_80671D64(s32, s32); +s32 func_806725E4(s16, s16, s16, s32); + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s16 unk10; + s16 unk12; + s16 unk14; + s16 unk16; + s32 unk18; +} Unk34; + +typedef struct { + s32 unk0; // Used + u8 unk4; // Used + u8 unk5; + u16 unk6; + s32 unk8; + s32 unkC; + s32 unk10[4]; + s32 unk20[4]; + s32 unk30; + Unk34 *unk34; +} GlobalASMStruct82; // TODO: Might be D_807FDCC0 + +extern s32 D_807FDCC0; + +void func_8072ED90(void) { + D_807FDCC0 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072ED9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072EE0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072EE7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072EF7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072F09C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072F120.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072F230.s") + +u8 func_8072F4A8(Actor *arg0, u8 arg1, f32 *arg2, f32 *arg3, f32 *arg4) { + s16 model2ArrayIndex; + u8 phi_t0; + + phi_t0 = FALSE; + switch (arg1) { + case 0: + *arg2 = arg0->x_position; + *arg3 = arg0->y_position; + *arg4 = arg0->z_position; + break; + case 1: + case 2: + model2ArrayIndex = func_80659470(arg0); + *arg2 = D_807F6000[model2ArrayIndex].x_position; + *arg3 = D_807F6000[model2ArrayIndex].y_position; + *arg4 = D_807F6000[model2ArrayIndex].z_position; + // TODO: Better way to match this once proper type is known + // It'll probably be D_807F6000[model2ArrayIndex].unk24->unk0 + if (*((s32*)D_807F6000[model2ArrayIndex].unk24) & 1) { + phi_t0 = TRUE; + } + break; + } + return phi_t0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072F59C.s") + +s32 func_8072F8D4(GlobalASMStruct82 *arg0, s32 arg1, s16 arg2) { + s16 model2ArrayIndex; + s32 angle; + + if (!arg0->unk4) { + return TRUE; + } + model2ArrayIndex = func_80659470(arg0->unk0); + switch (D_807F6000[model2ArrayIndex].object_type) { + case 0xC9: // Ladder + case 0xCA: // Ladder + case 0x1CB: // Ladder (Fungi) + case 0x1F7: // Ladder (Fungi) + case 0x1F8: // Ladder (Fungi) + break; + default: + return TRUE; + } + angle = D_807F6000[model2ArrayIndex].y_rotation * 4096.0f / 360.0f; + if (func_806725E4((arg0->unk34[arg1].unk10 + angle) & 0xFFF, (arg0->unk34[arg1].unk14 + angle) & 0xFFF, arg2, 0)) { + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072FA14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072FCC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072FDD4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_8072FE60.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_807300BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_80730408.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_80730AEC.s") + +void func_80730D60(s32 arg0, u8 arg1, u8 arg2, u8 arg3, s32 *arg4, s32 *arg5) { + switch (arg1) { + case 0: + *arg4 = func_80671D64(arg0, arg2); + *arg5 = func_80671D64(arg0, arg3); + break; + case 1: + case 2: + *arg4 = func_8063367C(arg0, 1, arg2); + func_8061134C(*arg4); + *arg5 = func_8063367C(arg0, 1, arg3); + func_8061134C(*arg5); + break; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_133A90/func_80730E18.s") diff --git a/src/global_asm/code_135D30.c b/src/global_asm/code_135D30.c new file mode 100644 index 00000000..cc8afcbf --- /dev/null +++ b/src/global_asm/code_135D30.c @@ -0,0 +1,297 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 temporary_flag_block[]; +u8* getFlagBlockAddress(u8 flagType); // TODO: Can we use the FlagTypes enum? Needs to be a u8 to match + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_80731030.s") + +/* +// TODO: Not sure why this doesn't match, maybe turn it into a while loop? +void func_80731030(void) { // clearTemporaryFlags() + s32 flagIndex; + for (flagIndex = 0; flagIndex != 0xE; flagIndex++) { + temporary_flag_block[flagIndex] = 0; + } +} +*/ + +void clearPermanentFlags(void) { + s32 flagIndex; + for (flagIndex = 0; flagIndex < 0x316; flagIndex++) { + setFlag(flagIndex, FALSE, FLAG_TYPE_PERMANENT); + } +} + +void clearGlobalFlags(void) { + s32 flagIndex; + for (flagIndex = 0; flagIndex < 0x2C; flagIndex++) { + setFlag(flagIndex, FALSE, FLAG_TYPE_GLOBAL); + } +} + +u8 isFlagSet(s16 flagIndex, u8 flagType) { // TODO: Can we use the FlagTypes enum? Needs to be a u8 to match + u8 *flagBlock; + s16 flagByte; + + if (flagIndex == -1) { + return 0; + } + switch (flagType) { + case FLAG_TYPE_PERMANENT: + case FLAG_TYPE_GLOBAL: + flagBlock = getFlagBlockAddress(flagType); + break; + case FLAG_TYPE_TEMPORARY: + flagBlock = &temporary_flag_block; + } + flagByte = flagIndex >> 3; + return flagBlock[flagByte] >> (s16)(flagIndex - flagByte * 8) & 1; +} + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_807311C4.s") + +typedef struct { + s16 unk0; // Start Permanent Flag Index + s16 unk2; // End Permanent Flag Index + s16 unk4; // Flag Count Required + s16 unk6; // Global Flag To Set +} Struct80756024; +extern Struct80756024 D_80756024[]; + +void func_807311C4(s16, s32); + +/* +void func_807311C4(s16 arg0, s32 arg1) { + u32 i; + s32 chosenFlag; + + chosenFlag = -1; + i = 0; + do { + if (arg0 >= D_80756024[i].unk0 && D_80756024[i].unk2 >= arg0) { + if (func_80731AA8(D_80756024[i].unk0, (D_80756024[i].unk2 - D_80756024[i].unk0) + 1, FLAG_TYPE_PERMANENT) == D_80756024[i].unk4) { + chosenFlag = D_80756024[i].unk6; + } + } + i++; + } while (i < 0x21 && chosenFlag == -1); + + if (chosenFlag >= 0) { + setFlag(chosenFlag, TRUE, FLAG_TYPE_GLOBAL); + } +} +*/ + +void setFlag(s16 flagIndex, u8 newValue, u8 flagType) { + u8 *flagBlock; + s16 flagByte; + s32 sp2C; // This is load bearing, cannot remove + + if (flagIndex != -1) { + switch (flagType) { + case FLAG_TYPE_PERMANENT: + case FLAG_TYPE_GLOBAL: + flagBlock = getFlagBlockAddress(flagType); + break; + case FLAG_TYPE_TEMPORARY: + flagBlock = &temporary_flag_block; + break; + } + flagByte = flagIndex >> 3; + if (newValue) { + flagBlock[flagByte] |= 1 << (s16)(flagIndex - (flagByte * 8)); + } else { + flagBlock[flagByte] &= ~(1 << (s16)(flagIndex - (flagByte * 8))); + } + if (newValue && (flagType == FLAG_TYPE_PERMANENT)) { + func_807311C4(flagIndex, flagType); + } + } +} + +typedef struct { + u8 unk0; + u8 unk1; + s16 unk2; + s16 unk4; // Used, permanent flag index + s16 unk6; +} Struct80755A20; + +extern Struct80755A20 D_80755A20[]; + +typedef struct { + u8 unk0; // Used, likely map + u8 unk1; + s16 unk2; // Used + u16 unk4; // Used + u8 unk6; // Used + u8 unk7; // Used +} Struct807FDCD0; + +extern Struct807FDCD0 D_807FDCD0[]; + +void func_807313BC(void) { + s32 i; + + for (i = 0; i < 24; i++) { + if (!func_805FF938(D_807FDCD0[i].unk0)) { + D_807FDCD0[i].unk7 = 0; + } + } +} + +void func_80731410(s16 arg0, s16 arg1, s16 arg2, u8 arg3) { + s32 i; + + for (i = 0; i < 24; i++) { + if (D_807FDCD0[i].unk7 == 0) { + D_807FDCD0[i].unk0 = arg0; + D_807FDCD0[i].unk2 = arg1; + D_807FDCD0[i].unk4 = arg2; + D_807FDCD0[i].unk6 = arg3; + D_807FDCD0[i].unk7 = 1; + return; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_807314F4.s") + +/* +// Not sure why this doesn't match +void func_807314F4(s16 arg0, s16 arg1) { + s32 i; + s32 j; + + for (i = 0; i < 0x71; i++) { + if ((arg0 == D_80755A20[i].unk0) && (arg1 == D_80755A20[i].unk2)) { + setFlag(D_80755A20[i].unk4, TRUE, FLAG_TYPE_PERMANENT); + return; + } + } + + for (j = 0; j < 24; j++) { + if (D_807FDCD0[j].unk7 && arg0 == D_807FDCD0[j].unk0 && arg1 == D_807FDCD0[j].unk2) { + setFlag(D_807FDCD0[j].unk4, TRUE, FLAG_TYPE_PERMANENT); + D_807FDCD0[j].unk7 = 0; + return; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_807315D4.s") + +/* +// Not sure why this doesn't work +u8 func_807315D4(s16 arg0, s16 arg1) { + s32 i; + for (i = 0; i < 0x71; i++) { + if ((arg0 == D_80755A20[i].unk0) && (arg1 == D_80755A20[i].unk2)) { + return isFlagSet(D_80755A20[i].unk4, FLAG_TYPE_PERMANENT); + } + } + return FALSE; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_80731654.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_80731784.s") + +typedef struct { + u8 map; + s8 unk1; + s16 spawnerID; + s16 flagIndex; + s8 unk6; + s8 unk7; +} Struct80755DA8; + +extern Struct80755DA8 D_80755DA8[]; // 0x1F + +/* +// TODO: Close +s16 func_80731784(s16 map, s16 spawnerID, s32 *arg2) { + s16 i; + + *arg2 = 0; + i = 0; + while (i < 0x1F) { + if (map == D_80755DA8[i].map) { + if (spawnerID == D_80755DA8[i].spawnerID) { + *arg2 = i; + return D_80755DA8[i].flagIndex; + } + } + i++; + } + return -1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_807317FC.s") + +// Seems doable, but stack/datatype/address issues, hmm +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_807318AC.s") + +typedef struct { + s16 unk0; + s16 unk2; +} Struct80755F4C; + +extern Struct80755F4C D_80755F4C[]; + +// TODO: This might not be right, the struct array is not used anywhere else +s16 func_8073195C(s16 arg0) { + if (arg0 == 0) { + return -1; + } + return D_80755F4C[arg0].unk0; +} + +// Doable, unrolled loop, struct array +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_135D30/func_8073198C.s") + +// Returns a permanent flag index +s32 func_807319D8(s32 arg0, s32 arg1, s32 arg2) { + s32 tmp = -1; + if (arg1 < 8) { + if (arg2 < 5) { + tmp = (arg1 * 5) + arg0 + arg2; + } + } + return tmp; +} + +s32 func_80731A04(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + s32 flagIndex; + s32 i; + s32 count; + + count = 0; + if (arg3 >= 5) { + return 0; + } + + for (i = arg1; i <= arg2; i++) { + flagIndex = func_807319D8(arg0, i, arg3); + if (flagIndex >= 0) { + count += isFlagSet(flagIndex, FLAG_TYPE_PERMANENT); + } + } + return count; +} + +// countSetFlags(startIndex, length, flagType); +s32 func_80731AA8(s32 startIndex, s32 length, u8 flagType) { + s32 flagIndex; + s32 count = 0; + for (flagIndex = startIndex; flagIndex < startIndex + length; flagIndex++) { + count += isFlagSet(flagIndex, flagType); + } + return count; +} diff --git a/src/global_asm/code_136820.c b/src/global_asm/code_136820.c new file mode 100644 index 00000000..959e3fb1 --- /dev/null +++ b/src/global_asm/code_136820.c @@ -0,0 +1,144 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_80744470[]; + +extern s8 D_807563B0; +extern u8 D_807563B4; + +extern OSThread D_807FDDA0; + +extern OSMesgQueue D_807FEF58; +extern s32 D_807FEF70; +extern s32 D_807FEF74; +extern s32 D_807FEF78; +extern s32 D_807FEF80; +extern u16 D_807FEF84; +extern s16 D_807FEF86; + +extern OSMesgQueue D_807FEF58; +extern s32 D_807FEF80; + +extern u8 D_807FF01C; +extern s32 D_807FF020; +extern s32 D_807FF024; +extern s32 D_807FF028; + +void func_80732280(void *); +extern void *D_807FEF50; + +void func_80731B20(s32 arg0, s32 arg1, s32 arg2) { + D_807FEF80 = arg0; + D_807FEF78 = 2; + D_807FEF84 = 0xFFFF; + D_807FEF86 = 1; + D_807FEF70 = arg1; + D_807FEF74 = arg2; +} + +void func_80731B60(s32 arg0) { + if (!arg0) { + D_807FEF84 = 0xFFFF; + } else { + D_807FEF84 = 0xF801; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80731B88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80731D20.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80731E68.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_8073202C.s") + +/* +s32 func_8073202C(s32 arg0, s32 *arg1, s32 *arg2) { + if ((arg0 & 0xFFFF0000) == 0x8FBF0000) { + *arg2 = arg1[(s16)arg0]; + return TRUE; + } + return FALSE; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80732064.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_8073209C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80732158.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80732280.s") + +/* +// TODO: Matches except for some extra NOPs being inserted in this version +// No idea why +void func_80732280(void* arg0) { + OSMesg *sp3C; + s32 *temp_s0; + s32 temp_s1; + s32 temp; + + osSetEventMesg(0xC, &D_807FEF58, 0x10); + do { + do { + osRecvMesg(&D_807FEF58, &sp3C, 1); + } while (!D_807563B4); + temp_s1 = func_80005A70(); + } while (!temp_s1); + + while (TRUE) { + for (temp = 0; temp < 2; temp++) { + osViBlack(0); + D_807FEF80 = D_80744470[temp]; + func_80731E68(temp_s1); + func_80731E68(temp_s1); + } + } +} +*/ + +void func_80732354(u8 arg0, s32 arg1, s32 arg2, s32 arg3) { + D_807FF01C = arg0; + D_807FF020 = arg1; + D_807FF024 = arg2; + D_807FF028 = arg3; + func_8061D4E4(0); +} + +void func_8073239C(void) { + __osSetFpcCsr(__osGetFpcCsr() | FPCSR_EZ); + osCreateMesgQueue(&D_807FEF58, &D_807FEF50, 1); + osCreateThread(&D_807FDDA0, 8, func_80732280, NULL, &D_807FEF50, 0x32); + osStartThread(&D_807FDDA0); + D_807563B0 = 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80732420.s") + +/* +typedef struct global_asm_struct_2 { + u32 unk0; + u32 unk4; + u32 unk8; + u32 unkC; +} GlobalASMStruct2; + +void func_80732420(u32 *arg0, u32 arg1, u32 arg2) { + arg0[0] = arg1; + arg0[2] = arg2; + arg0[1] = arg0[0]; + arg0[3] = 0; + //arg0->unk0 = arg1; + //arg0->unk8 = arg2; + //arg0->unkC = 0; + //arg0->unk4 = arg0->unk0; +} +*/ + +void func_8073243C(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_136820/func_80732444.s") diff --git a/src/global_asm/code_1371D0.c b/src/global_asm/code_1371D0.c new file mode 100644 index 00000000..c6bc59ac --- /dev/null +++ b/src/global_asm/code_1371D0.c @@ -0,0 +1,54 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1371D0/func_807324D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1371D0/func_80732534.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1371D0/func_80732618.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1371D0/func_80732730.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1371D0/func_807327F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1371D0/func_80732894.s") + +typedef struct { + s32 unk0; + s32 unk4; + u8 unk8; + u8 unk9; + s16 unkA; + s32 unkC; + s32 unk10; +} GlobalASMStruct69; + +/* +// Not sure what's wrong here, some compiler flag maybe? +void func_80732894(GlobalASMStruct69 *arg0, s32 arg1, s32 arg2) { + if (arg0->unk9 != 0) { + return; + } + arg0->unk9 = 1; + arg0->unk0 += arg2; + switch (arg0->unk8) { + case 0: + arg0->unk10 += arg1; + if (arg0->unkC != 0) { + arg0->unkC += arg1; + } + break; + case 1: + if (arg0->unkC != 0) { + arg0->unkC += arg1; + } + break; + } +} +*/ + +void func_80732924(void) { + +} diff --git a/src/global_asm/code_137630.c b/src/global_asm/code_137630.c new file mode 100644 index 00000000..129714e9 --- /dev/null +++ b/src/global_asm/code_137630.c @@ -0,0 +1,48 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137630/func_80732930.s") + +/* +extern f32 D_80760190; + +// No idea why this doesn't match, compiler flag? +f32 func_80732930(u8 arg0) { + f32 sp4; + f32 sp0; + + sp4 = D_80760190; + sp0 = 1.0f; + while (arg0) { + if (arg0 & 1) { + sp0 *= sp4; + } + sp4 *= sp4; + arg0 = (arg0 >> 1); + } + return sp0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137630/func_807329AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137630/func_80732B3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137630/func_80732D80.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137630/func_80732DAC.s") + +/* +extern f32 D_8076019C; + +void func_80612D1C(f32); + +// TODO: No idea why this doesn't match +void func_80732DAC(f32 arg0) { + func_80612D1C(arg0 / D_8076019C); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137630/func_80732DEC.s") diff --git a/src/global_asm/code_137C10.c b/src/global_asm/code_137C10.c new file mode 100644 index 00000000..eabd4097 --- /dev/null +++ b/src/global_asm/code_137C10.c @@ -0,0 +1,32 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80732F10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80733180.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80733A88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80733B88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80733C34.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80733D8C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80735624.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80735864.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80735958.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_807359A0.s") + +// struct 0x88 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_137C10/func_80735A34.s") + +void func_80735A44(void) { + +} diff --git a/src/global_asm/code_13A750.c b/src/global_asm/code_13A750.c new file mode 100644 index 00000000..c527228b --- /dev/null +++ b/src/global_asm/code_13A750.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A750/func_80735A50.s") diff --git a/src/global_asm/code_13A7A0.c b/src/global_asm/code_13A7A0.c new file mode 100644 index 00000000..092fe3a9 --- /dev/null +++ b/src/global_asm/code_13A7A0.c @@ -0,0 +1,86 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80735AA0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80735CF4.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80735DBC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80736FB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737028.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_807370A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737198.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_8073726C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_8073749C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_807375E0.s") + +/* +// TODO: Which struct is passed in? +void func_807375E0(void *arg0, s32 arg1) { + if (arg0 != 0) { + arg0->unk40 = arg1 & 0xFF; + } +} +*/ + +void func_80737600(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737608.s") + +void func_80737630(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737638.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737924.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737990.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737A4C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737A74.s") + +/* +// TODO: Wtf +void func_80737A74(void) { + func_80737990(0x11); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737A9C.s") + +// Audio stuff, ALEvent struct on the stack? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737AC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737B2C.s") + +/* +extern u16 D_807FF0E4[]; + +u16 func_80737B2C(s32 arg0) { + return D_807FF0E4[arg0 & 0xFF]; +} +*/ + +void func_80737B48(void) { + +} + +void func_80737B50(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13A7A0/func_80737B58.s") diff --git a/src/global_asm/code_13C920.c b/src/global_asm/code_13C920.c new file mode 100644 index 00000000..23054947 --- /dev/null +++ b/src/global_asm/code_13C920.c @@ -0,0 +1,41 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13C920/func_80737C20.s") + +/* +extern s8 D_807FF0F0; +extern s8 D_807FF0F1; +extern s8 D_807FF0F2; + +// TODO: Sus, maybe mips3? +void func_80737C20(u8 arg0) { + s32 sp24; + s32 temp_t0; + + D_807FF0F0 = 0; + D_807FF0F1 = 0; + D_807FF0F2 = 0; + switch (arg0) { + case 1: + D_807FF0F1 = 1; + break; + case 3: + D_807FF0F2 = 1; + break; + case 4: + D_807FF0F0 = 1; + break; + } + sp24 = 0; + do { + func_80737CF4(sp24, 0); + temp_t0 = sp24 + 1; + sp24 = temp_t0; + } while (temp_t0 < 2); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13C920/func_80737CF4.s") diff --git a/src/global_asm/code_13CB30.c b/src/global_asm/code_13CB30.c new file mode 100644 index 00000000..e30b17da --- /dev/null +++ b/src/global_asm/code_13CB30.c @@ -0,0 +1,15 @@ +#include +#include "functions.h" +#include "variables.h" + +s32 func_80737E30(s32 *arg0) { + return arg0[0xB]; +} + +void func_80737E38(void) { + +} + +void func_80737E40(void) { + +} diff --git a/src/global_asm/code_13CB50.c b/src/global_asm/code_13CB50.c new file mode 100644 index 00000000..850ae590 --- /dev/null +++ b/src/global_asm/code_13CB50.c @@ -0,0 +1,43 @@ +#include +#include "functions.h" +#include "variables.h" + + +// Audio stuff, weird stack things going on +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80737E50.s") + +// struct s32 into 0x84 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80737E90.s") + +void func_80737E9C(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80737EA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80737F0C.s") + +void func_80737F38(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80737F40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80737FD8.s") + +/* +void func_807382A0(s32, s32, u8, u8); + +// TODO: Wtf +void func_80737FD8(s32 arg0, s32 arg1, s32 arg2) { + func_807382A0(arg0, 0, arg1 | 0xB0, 0xFF); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_8073801C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80738080.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_807380CC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CB50/func_80738118.s") diff --git a/src/global_asm/code_13CE70.c b/src/global_asm/code_13CE70.c new file mode 100644 index 00000000..71c8bfe5 --- /dev/null +++ b/src/global_asm/code_13CE70.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CE70/func_80738170.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CE70/func_807381D8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CE70/func_80738230.s") diff --git a/src/global_asm/code_13CFA0.c b/src/global_asm/code_13CFA0.c new file mode 100644 index 00000000..e49efeb5 --- /dev/null +++ b/src/global_asm/code_13CFA0.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13CFA0/func_807382A0.s") diff --git a/src/global_asm/code_13D020.c b/src/global_asm/code_13D020.c new file mode 100644 index 00000000..c9ac5ca1 --- /dev/null +++ b/src/global_asm/code_13D020.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D020/func_80738320.s") diff --git a/src/global_asm/code_13D0B0.c b/src/global_asm/code_13D0B0.c new file mode 100644 index 00000000..870de8a0 --- /dev/null +++ b/src/global_asm/code_13D0B0.c @@ -0,0 +1,24 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D0B0/func_807383B0.s") + +/* +// TODO ??? +s32 func_807383B0(GlobalASMStruct20 *arg0) { + if (!arg0->unk18) { + return 0; + } + return arg0->unk24 / arg0->unk18->unk8; +} +*/ + +void func_807383EC(void) { + +} + +void func_807383F4(void) { + +} diff --git a/src/global_asm/code_13D100.c b/src/global_asm/code_13D100.c new file mode 100644 index 00000000..48dc248d --- /dev/null +++ b/src/global_asm/code_13D100.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D100/func_80738400.s") diff --git a/src/global_asm/code_13D170.c b/src/global_asm/code_13D170.c new file mode 100644 index 00000000..d98af2f9 --- /dev/null +++ b/src/global_asm/code_13D170.c @@ -0,0 +1,35 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_80738470.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_807385F0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_8073876C.s") + +s32 func_80738BA0(s32 *arg0) { + return arg0[3]; +} + +void func_80738BA8(void) { + +} + +void func_80738BB0(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_80738BB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_80738C6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_80738D20.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_80738E58.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_80739098.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13D170/func_8073928C.s") + diff --git a/src/global_asm/code_13ECE0.c b/src/global_asm/code_13ECE0.c new file mode 100644 index 00000000..fbecd371 --- /dev/null +++ b/src/global_asm/code_13ECE0.c @@ -0,0 +1,40 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_80739FE0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A070.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A130.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A2A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A3C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A488.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A518.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A690.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A7B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A8BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A900.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073A98C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073AA74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073AB00.s") + +void func_8073AD48(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073AD50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_13ECE0/func_8073B08C.s") diff --git a/src/global_asm/code_140260.c b/src/global_asm/code_140260.c new file mode 100644 index 00000000..2c599ec6 --- /dev/null +++ b/src/global_asm/code_140260.c @@ -0,0 +1,38 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140260/func_8073B560.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140260/func_8073B5D0.s") + +/* +void func_8073B5D0(ALPlayer *arg0) { + OSIntMask sp1C; + + sp1C = osSetIntMask(1); + arg0->samplesLeft = n_syn->curSamples; + arg0->next = n_syn->head; + n_syn->head = arg0; + osSetIntMask(sp1C); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140260/func_8073B640.s") + +/* +void func_8073B640(ALPlayer *arg0) { + OSIntMask sp1C; + + sp1C = osSetIntMask(1); + arg0->samplesLeft = n_syn->curSamples; + arg0->next = n_syn->head; + n_syn->head = arg0; + osSetIntMask(sp1C); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140260/func_8073B6B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140260/func_8073B750.s") diff --git a/src/global_asm/code_140530.c b/src/global_asm/code_140530.c new file mode 100644 index 00000000..b6da95c5 --- /dev/null +++ b/src/global_asm/code_140530.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140530/func_8073B830.s") diff --git a/src/global_asm/code_140600.c b/src/global_asm/code_140600.c new file mode 100644 index 00000000..197e4e1c --- /dev/null +++ b/src/global_asm/code_140600.c @@ -0,0 +1,22 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073B900.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073B9B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073BA60.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073BB10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073BC74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073BDC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073BE54.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073C040.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_140600/func_8073C604.s") diff --git a/src/global_asm/code_141520.c b/src/global_asm/code_141520.c new file mode 100644 index 00000000..e80222bb --- /dev/null +++ b/src/global_asm/code_141520.c @@ -0,0 +1,14 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141520/func_8073C820.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141520/func_8073C8D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141520/func_8073C948.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141520/func_8073C9C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141520/func_8073CA04.s") diff --git a/src/global_asm/code_1417C0.c b/src/global_asm/code_1417C0.c new file mode 100644 index 00000000..7393ef68 --- /dev/null +++ b/src/global_asm/code_1417C0.c @@ -0,0 +1,8 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1417C0/func_8073CAC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1417C0/func_8073CC94.s") diff --git a/src/global_asm/code_141AD0.c b/src/global_asm/code_141AD0.c new file mode 100644 index 00000000..5534d8b2 --- /dev/null +++ b/src/global_asm/code_141AD0.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141AD0/func_8073CDD0.s") diff --git a/src/global_asm/code_141C00.c b/src/global_asm/code_141C00.c new file mode 100644 index 00000000..8aab8c55 --- /dev/null +++ b/src/global_asm/code_141C00.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141C00/func_8073CF00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141C00/func_8073CFB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141C00/func_8073D060.s") diff --git a/src/global_asm/code_141E60.c b/src/global_asm/code_141E60.c new file mode 100644 index 00000000..d4573c21 --- /dev/null +++ b/src/global_asm/code_141E60.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141E60/func_8073D160.s") diff --git a/src/global_asm/code_141EF0.c b/src/global_asm/code_141EF0.c new file mode 100644 index 00000000..e07c2df2 --- /dev/null +++ b/src/global_asm/code_141EF0.c @@ -0,0 +1,21 @@ +#include +#include "functions.h" +#include "variables.h" +#include "synthinternal.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073D1F0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073DA30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073DF50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073E268.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073E460.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073E63C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073E73C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_141EF0/func_8073E800.s") diff --git a/src/global_asm/code_1435A0.c b/src/global_asm/code_1435A0.c new file mode 100644 index 00000000..836091b0 --- /dev/null +++ b/src/global_asm/code_1435A0.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + +// tiny, struct 0x16 s16 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435A0/func_8073E8A0.s") + +void func_8073E8B4(void) { + +} diff --git a/src/global_asm/code_1435C0.c b/src/global_asm/code_1435C0.c new file mode 100644 index 00000000..dfbd65a5 --- /dev/null +++ b/src/global_asm/code_1435C0.c @@ -0,0 +1,33 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435C0/func_8073E8C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435C0/func_8073F1E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435C0/func_8073F328.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435C0/func_8073F60C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435C0/func_8073F81C.s") + +/* +// TODO: Should be trivial, and yet +s16 func_8073F81C(s16 arg0, s32 arg1, s16 arg2, s32 arg3) { + s32 sp4; + s32 temp_a1; + + temp_a1 = arg1 >> 3; + if (temp_a1 == 0) { + return arg0; + } + sp4 = (arg3 & 0xFFFF) * temp_a1; + sp4 = sp4 >> 0x10; + sp4 += arg2 * temp_a1; + return arg0 + sp4; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_1435C0/func_8073F8A0.s") diff --git a/src/global_asm/code_144A90.c b/src/global_asm/code_144A90.c new file mode 100644 index 00000000..645d7a71 --- /dev/null +++ b/src/global_asm/code_144A90.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_144A90/func_8073FD90.s") diff --git a/src/global_asm/code_144E00.c b/src/global_asm/code_144E00.c new file mode 100644 index 00000000..f9c9b0d7 --- /dev/null +++ b/src/global_asm/code_144E00.c @@ -0,0 +1,10 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_144E00/func_80740100.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_144E00/func_807407A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_144E00/func_80740A90.s") diff --git a/src/global_asm/code_145950.c b/src/global_asm/code_145950.c new file mode 100644 index 00000000..4ceb6193 --- /dev/null +++ b/src/global_asm/code_145950.c @@ -0,0 +1,8 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_145950/func_80740C50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_145950/func_80740F48.s") diff --git a/src/global_asm/code_14CF0.c b/src/global_asm/code_14CF0.c new file mode 100644 index 00000000..381b722a --- /dev/null +++ b/src/global_asm/code_14CF0.c @@ -0,0 +1,49 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_14CF0/func_8060FFF0.s") + +/* +extern ? D_80741F40; +extern ? D_807432D0; +extern ? D_80760840; +extern ? D_80760C60; +extern ? D_807F0570; +extern ? D_807F0588; + +void func_8060FFF0(void) { + D_807F0570.unk0 = &D_807432D0; + D_807F0588.unk0 = &D_80760C60; + D_807F0570.unk4 = &D_80741F40; + D_807F0588.unk4 = &D_80760840; + D_807F0570.unk8 = &D_80741F40; + D_807F0588.unk8 = &D_80760840; + D_807F0570.unkC = &D_80741F40; + D_807F0588.unkC = &D_80760840; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_14CF0/func_80610044.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_14CF0/func_80610268.s") + +/* +extern OSMesgQueue D_807659E8; +extern s8 D_80746834; +extern s8 D_807F059C; + +// TODO: Everything matches except for a bne where s1 and t8 are swapped, no idea why +void func_80610268(s32 arg0) { + u32 sp34; + + do { + D_80746834 = 8; + osRecvMesg(&D_807659E8, &sp34, 1); + D_80746834 = 0; + (&D_807F059C)[sp34 >> 0x10] = 0; + sp34 = (u16)sp34; + } while (sp34 != arg0); +} +*/ \ No newline at end of file diff --git a/src/global_asm/code_15010.c b/src/global_asm/code_15010.c new file mode 100644 index 00000000..07366128 --- /dev/null +++ b/src/global_asm/code_15010.c @@ -0,0 +1,8 @@ +#include +#include "functions.h" +#include "variables.h" + +// TODO: Can't auto decompile, unknown instruction +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15010/func_80610310.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15010/func_8061032C.s") diff --git a/src/global_asm/code_15050.c b/src/global_asm/code_15050.c new file mode 100644 index 00000000..066d8ebe --- /dev/null +++ b/src/global_asm/code_15050.c @@ -0,0 +1,128 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610350.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_806109EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610A88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610B84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610BD8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610C74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610DCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80610E84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/malloc.s") + +extern s32 D_80746A30; +extern u8 D_80746A37; + +u8 func_80611154(void) { + return D_80746A37; +} + +void func_80611160(void) { + D_80746A30 = 0; +} + +void func_8061116C(void) { + func_8065EA44(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_8061118C.s") + +s32 func_806111BC(s32 arg0, s32 arg1) { + s32 temp_v0 = func_806111F8(arg0, (arg1 + 0xF) & ~0xF); + if (temp_v0) { + temp_v0 += 0x10; + return temp_v0; + } + return 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_806111F8.s") + +// Used in resolveActorCollisions(), param 1 appears to be the a pointer to the struct ActorCollision +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_8061130C.s") + +// Negative struct offset, odd +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_8061134C.s") + +typedef struct { + s32 unk0; // Used + s8 unk4; // Used + s8 unk5; + s8 unk6; + s8 unk7; +} Struct807F0A58; + +// Also used in func_80611730 +extern Struct807F0A58 D_807F0A58[]; +extern s32 D_807F5A58; +extern s32 D_807F5A5C; + +void func_8061138C(s32 arg0) { + while (D_807F5A58 >= 0xA00) { + func_80611730(); + } + D_807F0A58[D_807F5A58].unk0 = arg0; + D_807F0A58[D_807F5A58].unk4 = D_807F5A5C; + D_807F5A58++; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80611408.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80611534.s") + +// TODO: idk if this is the best way to do this +void func_80611594(u8 *arg0) { + arg0[-5] = 0; +} + +// TODO: idk if this is the best way to do this +void func_8061159C(u8 *arg0) { + arg0[-5] = 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_806115A8.s") + +/* +extern s32 D_807F5A68; +extern void* D_807F5A70[]; + +void func_806115A8(u8 *arg0) { + arg0[-5] = 2; + D_807F5A70[D_807F5A68++] = arg0; + if (D_807F5A68 == 0x20) { + func_80732354(0xD, 0, 0, 0); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80611614.s") + +// TODO: idk if this is the best way to do this +s32 func_80611688(s32 *arg0) { + return arg0[-3]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80611690.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_806116E0.s") + +void func_80611724(s32 arg0, s32 arg1) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_15050/func_80611730.s") + +void func_80611844(void) { + +} diff --git a/src/global_asm/code_16550.c b/src/global_asm/code_16550.c new file mode 100644 index 00000000..9c7a7a57 --- /dev/null +++ b/src/global_asm/code_16550.c @@ -0,0 +1,42 @@ +#include +#include "functions.h" +#include "variables.h" + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_16550/func_80611850.s") + +s32 func_80611DA0(s16); +extern f32 D_807572D0; +extern f32 D_807572D4; +extern f32 D_807572D8; +extern f32 D_807572DC; +extern f32 D_807572E0; +extern f32 D_807572E4; + +/* +// TODO: Close, some float nonsense +f32 func_80611850(f32 arg0) { + s16 phi_a0; + + if (arg0 >= 1.0f) { + phi_a0 = 0x7FFF; + } else if (arg0 <= -1.0f) { + phi_a0 = -0x7FFF; + } else { + phi_a0 = arg0 * D_807572D0; + } + return (func_80611DA0(phi_a0) * D_807572D4) / D_807572D8; +} +*/ + +f32 func_806118FC(f32 arg0) { + s16 phi_a0; + + if (arg0 >= 1.0f) { + phi_a0 = 0x7FFF; + } else if (arg0 <= -1.0f) { + phi_a0 = -0x7FFF; + } else { + phi_a0 = arg0 * D_807572DC; + } + return (func_80611DF4(phi_a0) * D_807572E0) / D_807572E4; +} diff --git a/src/global_asm/code_2C700.c b/src/global_asm/code_2C700.c new file mode 100644 index 00000000..cf565da1 --- /dev/null +++ b/src/global_asm/code_2C700.c @@ -0,0 +1,27 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2C700/func_80627A00.s") + +extern float D_807F5D30[4][4]; + +void func_80627B58(f32 arg0) { + D_807F5D30[0][0] = -arg0; + D_807F5D30[0][1] = 2.0 * arg0; + D_807F5D30[0][2] = -arg0; + D_807F5D30[0][3] = 0.0f; + D_807F5D30[1][0] = 2.0 - arg0; + D_807F5D30[1][1] = arg0 - 3.0; + D_807F5D30[1][2] = 0.0f; + D_807F5D30[1][3] = 1.0f; + D_807F5D30[2][0] = arg0 - 2.0; + D_807F5D30[2][1] = 3.0 - (2.0 * arg0); + D_807F5D30[2][2] = arg0; + D_807F5D30[2][3] = 0.0f; + D_807F5D30[3][0] = arg0; + D_807F5D30[3][1] = -arg0; + D_807F5D30[3][2] = 0.0f; + D_807F5D30[3][3] = 0.0f; +} diff --git a/src/global_asm/code_2C910.c b/src/global_asm/code_2C910.c new file mode 100644 index 00000000..1a81cd1c --- /dev/null +++ b/src/global_asm/code_2C910.c @@ -0,0 +1,43 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_80757F70[]; +Actor *func_807270C0(s16 arg0, s32 arg1); + +void func_80627C10(u8 arg0) { + s32 index = arg0 * 3; + D_807FBB44->unk16A = D_80757F70[index + 0]; + D_807FBB44->unk16B = D_80757F70[index + 1]; + D_807FBB44->unk16C = D_80757F70[index + 2]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2C910/func_80627C5C.s") + +Actor *func_80627EA8(s16 arg0) { + Actor *actor; + + if (arg0) { + actor = func_807270C0(arg0, 0); // getSpawnerTiedActor() + } + if (!arg0 || !actor) { + actor = player_pointer; + } + return actor; +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2C910/func_80627F04.s") + +s32 func_80629148(void) { + s32 phi_v1 = FALSE; + if (current_actor_pointer->unk6A & 0x100) { + current_actor_pointer->unk6A &= ~0x100; + phi_v1 = TRUE; + } + return phi_v1; +} + +void func_80629174(void) { + current_actor_pointer->unk6A &= ~0x100; +} diff --git a/src/global_asm/code_2DE90.c b/src/global_asm/code_2DE90.c new file mode 100644 index 00000000..150d8ea9 --- /dev/null +++ b/src/global_asm/code_2DE90.c @@ -0,0 +1,136 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_807F5D84; +extern u8 D_80747B20; + +extern f32 D_807F5D94; +extern f64 D_80758150; +extern f32 D_807F5D8C; +extern f32 D_807F5D90; + +extern u8 D_80747B40; +extern void *D_807F5DD8; + +extern s32 D_80747B28; +extern u8 *D_80747B2C; +extern s32 D_80747B38; + +extern f32 D_80747B44; +extern f32 D_80747B48; +extern f32 D_80747B4C; +extern f32 D_80747B50; + +f32 func_80665AE4(s32, s32, s32,s32); +void func_80704130(s32, s32, s32, s32, s32, s32); +void func_8062A274(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void func_80002E98(void *arg0, s32 arg1, s32 arg2); + +void func_80629190(void) { + D_807F5D84 = 0; +} + +u8 func_8062919C(void) { + return D_807F5D84; +} + +u8 func_806291A8(void) { + return D_80747B20; +} + +// big, can't auto decompile right now +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2DE90/func_806291B4.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2DE90/func_80629300.s") + +void func_8062A130(s32 arg0, s32 arg1, s32 arg2) { + f32 temp_f0; + s32 phi_v0; + + temp_f0 = func_80665AE4(0xA0, 0x78, arg0, arg1); + if (D_807F5D94 < 20.0) { + func_80704130(arg2, 0xFF, 0xFF, 0xFF, 0xFF, 0); + return; + } + phi_v0 = 0; + if (D_807F5D94 < temp_f0) { + if ((temp_f0 - D_807F5D94) < 25.0) { + phi_v0 = (s16) (((temp_f0 - D_807F5D94) / 25.0) * D_80758150); + } else { + phi_v0 = 0xFF; + } + } else { + phi_v0 = 0; + } + func_80704130(arg2, 0xFF, 0xFF, 0xFF, phi_v0, 0); +} + +void func_8062A228(s32 arg0, s32 arg1, s32 arg2) { + func_8062A274(arg0, arg1, arg2, 0, 0); +} + +void func_8062A24C(s32 arg0, s32 arg1, s32 arg2) { + func_8062A274(arg0, arg1, arg2, 0xA0, 0x78); +} + +void func_8062A274(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + f32 temp_f0; + s32 temp_v0; + s32 temp_v1; + s16 phi_v0; + + temp_v0 = arg0 - arg3; + temp_v1 = arg1 - arg4; + temp_f0 = sqrtf((temp_v0 * temp_v0) + (temp_v1 * temp_v1)); + if (temp_f0 < D_807F5D8C) { + phi_v0 = 0; + } else if (D_807F5D90 < temp_f0) { + phi_v0 = 0xFF; + } else { + phi_v0 = ((temp_f0 - D_807F5D8C) / (D_807F5D90 - D_807F5D8C)) * 255.0f; + } + func_80704130(arg2, 0xFF, 0xFF, 0xFF, phi_v0, 0); +} + +void func_8062A348(void) { + s32 phi_v1; + + D_80747B2C = malloc((D_80747B28 << 5) + 1); + phi_v1 = 0; + while (D_80747B28 << 5 >= phi_v1) { + // TODO: Might be better as array notation + *(D_80747B2C + phi_v1) = phi_v1 / D_80747B28; + phi_v1++; + } + D_80747B38 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2DE90/func_8062A3F0.s") + +void func_8062A774(void) { + if (!D_80747B40) { + D_807F5DD8 = malloc(0x25800); + func_80002E98(D_807F5DD8, 0, 0x25800); + D_80747B40 = 1; + } +} + +void func_8062A7D0(void) { + if (D_80747B40) { + func_8061134C(D_807F5DD8); + D_80747B40 = 0; + } +} + +void func_8062A808(s32 arg0, s32 arg1) { + D_80747B4C = 2.0f; + D_80747B50 = 2.0f; + D_80747B44 = arg0; + D_80747B48 = arg1; +} + +s32 func_8062A844(s32 arg0) { + return arg0; +} diff --git a/src/global_asm/code_2F550.c b/src/global_asm/code_2F550.c new file mode 100644 index 00000000..d5b7f8df --- /dev/null +++ b/src/global_asm/code_2F550.c @@ -0,0 +1,621 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_807444F0; +extern f32 D_80747CD0; +extern f32 D_80758160; +extern f32 D_80758164; +extern f64 D_80758168; + +extern s32 D_807F5DE4; +extern s32 D_807F5E60; +extern s8 D_807F5FEC; +extern s32 D_807F5FF4; +extern s32 D_807F6C28; + +extern s32 D_807F5DE4; +extern s32 D_807F5E60; + +void func_8062D0CC(s32, s32, s32, u8); +void func_8062D3E4(s32 arg0); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062A850.s") + +/* +// TODO: Pretty close :) +// getFieldOfView() +f32 func_8062A850(void) { + s32 phi_v1; + f32 phi_f0; + f32 phi_f2; + f32 phi_f12; + + phi_f0 = 1.0f; + if (D_807444F0 != 1 && is_cutscene_active == 1) { + phi_f2 = D_80758160; + } else { + phi_f2 = D_80758164; + } + + phi_v1 = is_cutscene_active == 1 && current_map != MAP_MAIN_MENU; + if (widescreen_enabled && !phi_v1) { + phi_f0 = 1.0f * D_80758168; + } + + if (D_80747CD0 < phi_f0) { + phi_f12 = D_80747CD0 + phi_f2; + if (phi_f0 < phi_f12) { + phi_f12 = phi_f0; + } + } else { + phi_f12 = D_80747CD0 - phi_f2; + if (phi_f12 < phi_f0) { + phi_f12 = phi_f0; + } + } + + D_80747CD0 = phi_f12; + return phi_f12; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062A944.s") + +// Matrix, loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062AC68.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062AD28.s") + +typedef struct { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; + s16 unk10; + s16 unk12; + s16 unk14; + s16 unk16; + u8 unk18; + u8 unk19; + u16 unk1A; + u32 unk1C; + f64 unk20; + f64 unk28; + f64 unk30; + f64 unk38; +} GlobalASMStruct64; + +void func_8062B194(GlobalASMStruct64 *arg0) { + s16 temp1; + s16 temp2; + s16 temp3; + + switch ((u8)arg0->unk18) { + case 3: + temp1 = arg0->unk0; + temp2 = arg0->unk2; + temp3 = arg0->unk4; + arg0->unk0 = arg0->unk6; + arg0->unk2 = arg0->unk8; + arg0->unk4 = arg0->unkA; + arg0->unk6 = temp1; + arg0->unk8 = temp2; + arg0->unkA = temp3; + return; + case 4: + temp1 = arg0->unk0; + temp2 = arg0->unk2; + temp3 = arg0->unk4; + arg0->unk0 = arg0->unkC; + arg0->unk2 = arg0->unkE; + arg0->unk4 = arg0->unk10; + arg0->unkC = temp1; + arg0->unkE = temp2; + arg0->unk10 = temp3; + return; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062B220.s") + +/* +// D'oh, temp variables I guess? +void func_8062B220(GlobalASMStruct64 *arg0) { + arg0->unk20 = ((arg0->unk4 - arg0->unkA) * arg0->unkE) + ((arg0->unk2 * (arg0->unkA - arg0->unk10)) + (arg0->unk8 * (arg0->unk10 - arg0->unk4))); + arg0->unk28 = ((arg0->unk0 - arg0->unk6) * arg0->unk10) + ((arg0->unk4 * (arg0->unk6 - arg0->unkC)) + (arg0->unkA * (arg0->unkC - arg0->unk0))); + arg0->unk30 = ((arg0->unk2 - arg0->unk8) * arg0->unkC) + ((arg0->unk0 * (arg0->unk8 - arg0->unkE)) + (arg0->unk6 * (arg0->unkE - arg0->unk2))); + arg0->unk38 = -((((arg0->unk2 * arg0->unkA) - (arg0->unk4 * arg0->unk8)) * arg0->unkC) + ((arg0->unk0 * ((arg0->unk8 * arg0->unk10) - (arg0->unkE * arg0->unkA))) + (arg0->unk6 * ((arg0->unkE * arg0->unk4) - (arg0->unk2 * arg0->unk10))))); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062B3C4.s") + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s32 unk48; + s32 unk4C; + s32 unk50; + s32 unk54; + s32 unk58; + s32 unk5C; + s32 unk60; + s32 unk64; + s32 unk68; + s32 unk6C; + s32 unk70; + s32 unk74; + s32 unk78; + s32 unk7C; + f32 unk80; // Used + f32 unk84; // Used + f32 unk88; // Used + s8 unk8C; // Used + s8 unk8D; + s16 unk8E; +} GlobalASMStruct73; + +extern GlobalASMStruct73 *D_807F5FB8; +extern s32 D_807F5FBC; +extern s8 D_807F5FC0; + +void func_8062B478(s32 arg0) { + s32 i; + + if (arg0 == 0) { + D_807F5FB8 = NULL; + D_807F5FBC = 0; + return; + } + D_807F5FB8 = malloc(arg0 * sizeof(GlobalASMStruct73)); + D_807F5FBC = arg0; + for (i = 0; i < arg0; i++) { + D_807F5FB8[i].unk80 = 0.0f; + D_807F5FB8[i].unk84 = 0.0f; + D_807F5FB8[i].unk88 = 0.0f; + D_807F5FB8[i].unk8C = 1; + } + D_807F5FC0 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062B630.s") + +/* +// TODO: Regalloc, hmm +// Eliminating the temp variable doesn't fix it +// Datatypes are correct for the params I believe +void func_8062B630(s16 arg0, s8 arg1) { + GlobalASMStruct73 *temp = &D_807F5FB8[arg0]; + temp->unk8C = arg1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062B660.s") + +f32 func_8062B840(s8 arg0) { + return D_807F5FB8[arg0].unk80; +} + +void func_8062B86C(s32 arg0, f32 arg1, f32 arg2) { + D_807F5FB8[arg0].unk84 = arg1; + D_807F5FB8[arg0].unk88 = arg2; +} + +void func_8062B8A4(s32 arg0, f32 arg1, f32 arg2) { + D_807F5FB8[arg0].unk84 += arg1; + D_807F5FB8[arg0].unk88 = arg2; +} + +// Doable, unrolled loop using above struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062B8E4.s") + +void func_8062BA0C(f32 *arg0) { + s32 i; + + for (i = 0; i < D_807F5FBC; i++) { + D_807F5FB8[i].unk84 = arg0[i]; + D_807F5FB8[i].unk80 = arg0[i]; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062BA74.s") + +void func_8062BAE4(void) { + func_8063B4A4(); + func_8062BB2C(D_807F5DE4, D_807F5E60, 1); + func_8063B758(); + func_80641A78(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062BB2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062BCC8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062BDB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062BF24.s") + +void func_8062C1C0(s32 arg0) { + func_8065EFF0(); + func_8062D3E4(D_807F5FF4); + func_8063039C(); + if (D_807F6C28 == 0) { + func_8062EE48(0xFF); + } + func_8065214C(); + func_8065A884(); + func_8065F614(); + D_807F5FEC = 1; +} + +void func_8062C22C(void) { + if (D_807F6C28 != 0) { + func_80655BF0(); + func_8062EFA0(); + func_80655AD0(); + func_80653FA4(); + func_80653B70(0); + } + func_8063C450(); + func_8062B660(); + func_80636C00(); + func_806364C4(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062C29C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062C99C.s") + +// TODO: What is the actual signature? +void func_80630B70(s32, s32, f32, f32, f32, s32, s32, s32); + +extern s32 D_807F5FF8; +extern u8 D_807F6009; + +// TODO: Might be a fake match? +void func_8062CA0C(s32 arg0, f32 arg1, f32 arg2, f32 arg3) { + D_807F6009 = 0xFF; + func_80630B70(arg0, D_807F5FF8, arg1, arg2, arg3, 0x30030, -1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062CA70.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062CEA8.s") + +void func_8062D094(s32 arg0, u8 arg1) { + func_8062D0CC(D_807F5DE4, D_807F5E60, arg0, arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062D0CC.s") + +void func_8062D1A8() { + if (!gameIsInDKTVMode()) { + func_8062D1E0(D_807F5DE4, D_807F5E60); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062D1E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062D26C.s") + +/* +void func_8062D2AC(s32 arg0, s32 arg1, u8 arg2); + +// TODO: Something weird going on with stack +void func_8062D26C(Actor *arg0) { + s32 sp1F; + s32 sp1C; + + func_80630588(0, arg0, 1, &sp1F); + func_8062D2AC(arg0, &sp1C, 1); +} +*/ + +void func_8062D2AC(s32 arg0, s32 arg1, u8 arg2) { + func_8062D2F0(D_807F5DE4, D_807F5E60, arg0, arg1, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062D2F0.s") + +void func_8062D3E4(s32 arg0) { + func_8062D414(D_807F5DE4, D_807F5E60, arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062D414.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062D620.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062DAF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062DB70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062DBDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062E040.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062E1F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062E3B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062E548.s") + +/* +s32 func_8062E548(s16 *arg0, u8 arg1, f64 arg2, f64 arg3, u8 arg4) { + f64 phi_f0; + + switch (arg1) { + default: + phi_f0 = phi_f0; // ?? + break; + case 0: + phi_f0 = arg0[0]; + break; + case 1: + phi_f0 = arg0[1]; + break; + case 2: + phi_f0 = arg0[2]; + break; + } + switch (arg4) { + case 0: + if (arg3 <= phi_f0) { + return 1; + } + break; + case 1: + if (phi_f0 <= arg3) { + return 1; + } + break; + } + return 0; +} +*/ + +void func_8062E608(void *arg0, s32 *arg1, s32 arg2) { + // TODO: sizeof()? + memcpy((*arg1 * 6) + arg2, arg0, 6); + *arg1 += 1; + if (*arg1 >= 0xD) { + func_80732354(1, 0, 0, 0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062E67C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062E898.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062EBB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062EDA8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062EE48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062EFA0.s") + +// Appears to parse the map geometry format! +// Surprisingly doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F050.s") + +f32 func_80612D10(f32); +void func_80659DB0(f32, f32, s32 *, s32 *, f32, s32); +/* +? func_8062B3C4(void *, s32 *); +? func_8062B478(s32); +s32 func_8062BA74(void *); +? func_8062F318(); +? func_8062F328(void *); +? func_8062F3A0(void *, void *); +? func_8062F420(void *, void *, void *); +? func_8063C390(); +? func_80650ECC(void *); +? func_80659110(s32); +? func_8065996C(?); +? func_8065CDA0(s32); +? func_8065E040(s32); +? func_8065F1C0(void *); +? func_80662B90(void *); +? func_806637C0(void *); +? func_80666090(void *); +? func_8066C958(void *); +*/ + +typedef struct { + s32 unk0; + s32 unk4; + u8 unk8; + u8 unk9; + s16 unkA; + s16 unkC; + s16 unkE; + s16 unk10; + s16 unk12; + s16 unk14; + s16 unk16; + s16 unk18; + s16 unk1A; + s16 unk1C; + s16 unk1E; + s16 unk20; + s16 unk22; + s16 unk24; + s16 unk26; + s16 unk28; + s16 unk2A; + s16 unk2C; + s16 unk2E; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s32 unk48; +} MapGeometryHeader; + +extern f32 D_80758190; +extern MapGeometryHeader *D_807F5DE0; +// extern void *D_807F5DE4; +extern void *D_807F5DE8; +extern void *D_807F5DEC; +extern s32 D_807F5E60; +extern s8 D_807F5FC1; +extern void *D_807F5FC4; +extern s32 D_807F5FC8; +extern void *D_807F5FCC; +extern s32 D_807F5FD0; +extern void *D_807F5FD4; +extern f32 D_807F5FDC; +extern s16 D_807F5FE4; +extern s16 D_807F5FE6; +extern s16 D_807F5FE8; +extern s16 D_807F5FEA; +extern s16 D_807F9450; +extern s16 D_807F9452; +extern s16 D_807F9454; +extern s16 D_807F9456; +extern s32 D_807FB5E0; +extern s32 D_807FB5E4; +extern s16 D_807FB5E8; +extern s16 D_807FB5EA; +extern s16 D_807FD574; +extern s16 D_807FD576; +extern s16 D_807FD578; +extern f32 D_807444C4; + +void func_8062F318(void); + +void func_80659110(u8); +void func_8065CDA0(u8); + +/* +void func_8062F050(MapGeometryHeader *arg0) { + s32 sp50; + s32 *temp_a0; + s32 *temp_a1; + s32 *temp_v1; + void *temp_a1_2; + s32 sp28; + + D_807F5DE0 = arg0; + sp28 = 0; + D_807F5FDC = func_80612D10(D_80758190); + func_80659110(arg0->unk8 & 1); + func_8065CDA0((arg0->unk8 >> 1) & 1); + D_807444C4 = arg0->unkA; + D_807FB5E0 = arg0->unk14 * 8; + D_807FB5E4 = arg0->unk16 * 8; + D_807FB5E8 = arg0->unk10; + D_807FB5EA = arg0->unk12; + D_807F9450 = arg0->unk1C; + D_807F9452 = arg0->unk1E; + D_807F9454 = arg0->unk18; + D_807F9456 = arg0->unk1A; + D_807FD574 = arg0->unk20; + D_807FD576 = arg0->unk22; + D_807FD578 = arg0->unk24; + D_807F5FE4 = arg0->unk26; + D_807F5FE6 = arg0->unk28; + D_807F5FE8 = arg0->unk2A; + D_807F5FEA = arg0->unk2C; + temp_v1 = &D_807F5DE0->unk0 + arg0->unk40; + D_807F5FD0 = *temp_v1 + 1; + D_807F5FD4 = temp_v1 + 4; + temp_a0 = &D_807F5DE0->unk0 + arg0->unk44; + D_807F5FC8 = *temp_a0; + D_807F5FCC = temp_a0 + 4; + temp_a1 = &D_807F5DE0->unk0 + arg0->unk48; + D_807F5FC1 = *temp_a1; + D_807F5FC4 = temp_a1 + 4; + D_807F5DE4 = &D_807F5DE0->unk0 + arg0->unk30; + D_807F5DE8 = &D_807F5DE0->unk0 + arg0->unk38; + D_807F5DEC = &D_807F5DE0->unk0 + arg0->unk34; + func_80659DB0(1.0f, 1.0f, temp_a0, temp_a1, 1.0f, -1); + func_8065996C(-1); + func_8065E040(arg0->unkE << 0xA); + temp_a1_2 = &D_807F5DE0->unk0 + arg0->unk30; + func_8062F420(temp_a1_2, temp_a1_2, &D_807F5DE0->unk0 + arg0->unk34); + func_8062F3A0(&D_807F5DE0->unk0 + arg0->unk34, &D_807F5DE0->unk0 + arg0->unk38); + func_8062F328(&D_807F5DE0->unk0 + arg0->unk40); + func_8063C390(); + func_8062B3C4(D_807F5DE4, &sp28); + func_8062B478(sp28); + D_807F5E60 = func_8062BA74(D_807F5DE4); + func_80650ECC(arg0); + func_8066C958(arg0); + func_80666090(arg0); + func_8065F1C0(arg0); + func_80662B90(arg0); + func_806637C0(arg0); + func_8062F318(); +} +*/ + +extern s32 D_807F5FC8; +// extern s32 D_807F5FCC; +extern u8 D_807F5FED; + +void func_8062F318(void) { + D_807F5FED = 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F328.s") + +// extern s32 D_807F5FD0; +// extern s32 *D_807F5FD4; + +/* +// Regalloc +void func_8062F328(s32 arg0) { + s32 temp_a1; + s32 i; + + if (D_807F5FD0 != 0) { + for (i = 0; i <= D_807F5FD0; i++) { + D_807F5FD4[i] += arg0; + } + } +} +*/ + +s32 func_8062F388(s32 *arg0) { + *arg0 = D_807F5FCC; + return D_807F5FC8; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F3A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F420.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F538.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F640.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062F998.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062FBC8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_2F550/func_8062FF10.s") diff --git a/src/global_asm/code_35000.c b/src/global_asm/code_35000.c new file mode 100644 index 00000000..08ab77ef --- /dev/null +++ b/src/global_asm/code_35000.c @@ -0,0 +1,436 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806306D0(Chunk14 *current); +void func_8061130C(Chunk14*); + +extern Chunk14 *D_807F5FF0; +extern Chunk14 *D_807F5FF4; +extern Chunk14 *D_807F5FF8; +extern Chunk14 *D_807F5FFC; + +void func_80630300(void) { + D_807F5FF0 = NULL; + D_807F5FF4 = NULL; + D_807F5FF8 = NULL; + D_807F5FFC = NULL; +} + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s32 unk48; + s16 unk4C; + u8 unk4E; // Used + u8 unk4F; +} GlobalASMStruct59; + +s32 func_80630324(u8 arg0, GlobalASMStruct59 *arg1) { + if (arg0 == 2) { + arg0 = arg1->unk4E; + if (arg0 & 2) { + return FALSE; + } + if (arg0 & 1) { + return TRUE; + } + return FALSE; + } + switch (arg0) { + case 0: + case 1: + return FALSE; + case 5: + return TRUE; + default: + return FALSE; + } +} + +void func_8063039C(void) { + func_806306D0(D_807F5FF4); + D_807F5FF4 = NULL; +} + +Chunk14 *func_806303C4(Chunk14 *arg0, u8 arg1, s32 arg2, f32 arg3, f32 arg4, f32 arg5, s16 arg6, s16 arg7, u8 arg8, s16 arg9, u8 argA) { + Chunk14 *temp_v0; + Chunk14 *phi_v1; + s32 phi_v0; + Chunk14 *phi_a1; + + phi_v0 = FALSE; + phi_v1 = NULL; + if (argA == 1) { + arg0 = D_807F5FF0; + } + if (argA == 2) { + arg0 = D_807F5FF4; + } + if (argA == 3) { + arg0 = D_807F5FF8; + } + if (argA == 4) { + arg0 = D_807F5FFC; + } + phi_a1 = arg0; + while (arg0 && !phi_v0) { + if (arg2 == arg0->unk0) { + phi_v0 = TRUE; + } else { + phi_v1 = arg0; + arg0 = arg0->next; + } + } + if (phi_v0) { + arg0->unk4 = arg3; + arg0->unk8 = arg4; + arg0->unkC = arg5; + arg0->unk1C = arg6; + if (arg9 != -1) { + arg0->unk20 = arg9; + } + arg0->unk23 = 1; + } else { + temp_v0 = malloc(sizeof(Chunk14)); + temp_v0->unk24 = arg1; + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + temp_v0->unkC = arg5; + temp_v0->unk1C = arg6; + temp_v0->unk1E = arg7; + temp_v0->unk22 = arg8; + temp_v0->unk23 = 1; + temp_v0->unk10 = 0.0f; + temp_v0->unk20 = 0; + temp_v0->next = NULL; + if (phi_v1) { + phi_v1->next = temp_v0; + temp_v0->next2 = phi_v1; + } else { + phi_a1 = temp_v0; + temp_v0->next2 = NULL; + } + } + if (argA == 1) { + D_807F5FF0 = phi_a1; + } + if (argA == 2) { + D_807F5FF4 = phi_a1; + } + if (argA == 3) { + D_807F5FF8 = phi_a1; + } + if (argA == 4) { + D_807F5FFC = phi_a1; + } + return phi_a1; +} + +Chunk14 *func_80630588(Chunk14 *arg0, s32 arg1, u8 arg2, u8 *arg3) { + u8 phi_v0; + Chunk14 *phi_t0; + Chunk14 *phi_a2; + + phi_v0 = FALSE; + phi_t0 = NULL; + if (arg2 == 1) { + arg0 = D_807F5FF0; + } + if (arg2 == 2) { + arg0 = D_807F5FF4; + } + if (arg2 == 3) { + arg0 = D_807F5FF8; + } + if (arg2 == 4) { + arg0 = D_807F5FFC; + } + phi_a2 = arg0; + while (arg0 && !phi_v0) { + if (arg1 == arg0->unk0) { + phi_v0 = TRUE; + } else { + phi_t0 = arg0; + arg0 = arg0->next; + } + } + if (phi_v0) { + if (phi_t0) { + phi_t0->next = arg0->next; + } else { + phi_a2 = arg0->next; + } + if (arg0->next) { + arg0->next->next2 = phi_t0; + } + func_8061130C(arg0); + } + *arg3 = phi_v0; + if (arg2 == 1) { + D_807F5FF0 = phi_a2; + } + if (arg2 == 2) { + D_807F5FF4 = phi_a2; + } + if (arg2 == 3) { + D_807F5FF8 = phi_a2; + } + if (arg2 == 4) { + D_807F5FFC = phi_a2; + } + return phi_a2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_806306D0.s") + +/* +// TODO: Very close, adding a temp variable for next doesn't work +void func_806306D0(Chunk14 *current) { + while (current) { + func_8061130C(current); + current = current->next; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_8063070C.s") + +/* +// TODO: Pretty close, not sure exactly what it's doing +Chunk14 *func_8063070C(Chunk14 *arg0) { + while (arg0) { + if ((arg0->unk22 == 1) && (arg0->unk23 == 0)) { + if (arg0->next2) { + arg0->next2->next = arg0->next; + } else { + arg0 = arg0->next; + } + if (arg0->next) { + arg0->next->next2 = arg0->next2; + } + func_8061130C(arg0); + } + arg0 = arg0->next; + } + return arg0; +} +*/ + +void func_806307AC(Chunk14 *current) { + while (current) { + current->unk23 = 0; + current = current->next; + } +} + +void func_806307CC(Chunk14 *arg0, s32 arg1, u8 arg2, u8 arg3, s8 *arg4) { + s8 found = FALSE; + + if (arg2 == 1) { + arg0 = D_807F5FF0; + } + if (arg2 == 2) { + arg0 = D_807F5FF4; + } + if (arg2 == 3) { + arg0 = D_807F5FF8; + } + if (arg2 == 4) { + arg0 = D_807F5FFC; + } + while (arg0 && !found) { + if (arg1 == arg0->unk0) { + found = TRUE; + } else { + arg0 = arg0->next; + } + } + if (found) { + if (arg3) { + arg0->unk10 = -1.0f; + } else { + arg0->unk1C = -2; + } + } + *arg4 = found; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_80630890.s") + +extern f32 D_807581D0; +extern f32 D_807581D4; +extern f64 D_807581D8; + +/* +// TODO: Pretty close +Chunk14 *func_80630890(Chunk14 *arg0, f32 arg1, f32 arg2, f32 arg3, Chunk14 **arg4) { + Chunk14 *phi_a1; + Chunk14 *phi_v0; + Chunk14 *phi_v1; + Chunk14 *temp_v0_4; + f32 dz; + f64 phi_f16; + f64 temp_f12; + f32 phi_f14; + f32 phi_f18; + f32 phi_f2; + f32 dx; + s32 found; + f32 dy; + Chunk14 *phi_t0_2; + + phi_v0 = arg0; + phi_f18 = 0.0f; + phi_f16 = 0.0; + *arg4 = NULL; + while (phi_v0) { + dx = phi_v0->unk4 - arg1; + dy = phi_v0->unk8 - arg2; + dz = phi_v0->unkC - arg3; + if (phi_f16 != phi_v0->unk10) { + phi_v0->unk10 = sqrtf((dx * dx) + (dy * dy) + (dz * dz)); + } + phi_v0 = phi_v0->next; + } + phi_t0_2 = arg0; + phi_a1 = arg0; + if (arg0) { + if ((arg0->unk10 < arg0->unk1C) || (arg0->unk1C == -2)) { + *arg4 = arg0; + if (arg0->unk1C == -2) { + phi_f18 = D_807581D0; + } else { + phi_f18 = arg0->unk10; + } + } + phi_a1 = arg0->next; + if (phi_a1) { + temp_f12 = D_807581D8; + do { + found = FALSE; + phi_a1 = phi_t0_2; + if (((phi_f18 < phi_a1->unk10) && (phi_a1->unk10 < phi_a1->unk1C)) || (phi_a1->unk1C == -2)) { + *arg4 = phi_a1; + if (phi_a1->unk1C == -2) { + phi_f18 = D_807581D4; + } else { + phi_f18 = phi_a1->unk10; + } + } + if (phi_a1->unk1C < phi_a1->unk10) { + phi_f14 = temp_f12; + } else { + phi_f14 = phi_a1->unk10; + } + phi_v1 = phi_a1->next2; + while (phi_v1 && !found) { + if (phi_v1->unk1C < phi_v1->unk10) { + phi_f2 = temp_f12; + } else { + phi_f2 = phi_v1->unk10; + } + if ((phi_f14 <= phi_f2) || (phi_a1->unk1C == -2)) { + found = TRUE; + if (phi_v1 != phi_a1->next2) { + phi_a1->next2->next = phi_a1->next; + if (phi_a1->next) { + phi_a1->next->next2 = phi_a1->next2; + } + temp_v0_4 = phi_v1->next; + phi_v1->next = phi_a1; + phi_a1->next = temp_v0_4; + if (temp_v0_4) { + temp_v0_4->next2 = phi_a1; + } + phi_a1->next2 = phi_v1; + } + } + phi_v1 = phi_v1->next2; + } + if (!found) { + phi_a1->next2->next = phi_a1->next; + if (phi_a1->next) { + phi_a1->next->next2 = phi_a1->next2; + } + phi_a1->next2 = NULL; + phi_a1->next = phi_t0_2; + phi_t0_2->next2 = phi_a1; + } + phi_a1 = phi_a1->next; + phi_t0_2 = phi_a1; + } while (phi_a1); + } + } + return phi_a1; +} +*/ + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_80630B70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_80630DCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_8063162C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_806317D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_35000/func_806319C4.s") + +/* +f32 func_80612794(s16); +s32 func_8063162C(Actor *, s16 *); +s32 func_806317D4(Actor *, s16 *, f32, f32, f32); + +// TODO: Pretty close :) +void func_806319C4(Actor *arg0, u8 arg1) { + f32 sp78[4][4]; + s16 phi_a0; + s16 temp_f2; + s16 sp32; + s16 temp_t7; + s16 temp_yrot; + + if ((arg0->object_properties_bitfield & 1)) { + f32 sppad[4][4]; // TODO: How to incorperate this into the code? It was clearly there originally because the stack lines up + phi_a0 = (arg0->y_rotation - arg0->unkDC) & 0xFFF; + if (phi_a0 >= 0x801) { + phi_a0 = phi_a0 - 0x1000; + } + temp_f2 = (0x400 - arg0->unkDE) & 0xFFF; + sp32 = (s16)(arg0->z_rotation + (func_80612790(phi_a0) * temp_f2)) & 0xFFF; + temp_t7 = ((s16)(func_80612794(phi_a0) * temp_f2) + arg0->x_rotation) & 0xFFF; + temp_yrot = arg0->y_rotation; + if (arg1 != 0) { + func_806317D4(arg0, &sp78, temp_t7, sp32, temp_yrot); + guMtxCatF(&arg0->unkC, &sp78, &arg0->unkC); + return; + } + func_806317D4(arg0, &arg0->unkC, temp_t7, sp32, temp_yrot); + return; + } + if (arg1 != 0) { + func_8063162C(arg0, &sp78); + guMtxCatF(&arg0->unkC, &sp78, &arg0->unkC); + return; + } + func_8063162C(arg0, &arg0->unkC); +} +*/ diff --git a/src/global_asm/code_36880.c b/src/global_asm/code_36880.c new file mode 100644 index 00000000..c053d8fe --- /dev/null +++ b/src/global_asm/code_36880.c @@ -0,0 +1,760 @@ +#include +#include "functions.h" +#include "variables.h" + +extern f32 D_80747E00; +extern f32 D_80747E04; + +extern f64 D_807584F0; +extern f64 D_80758540; +extern f64 D_80758548; +extern f64 D_80758550; + +extern u16 D_807F6028; +extern u16 D_807F60A8; + +extern u8 D_807F6148; +extern s16 D_807F6140[]; +extern s16 D_807F6150[]; +extern f32 D_807F6170; +extern f32 D_807F6174; +extern f32 D_807F6178; +extern void* D_807F617C; // Texture +extern f32 D_807F6180; +extern f32 D_807F6184; +extern void* D_807F6188; // Texture +extern void* D_807F618C; // Texture +extern void* D_807F6190; // Texture +extern u8 D_807F6194; +extern f32 D_807F6198; +extern void* D_807F619C; // Texture +extern f32 D_807F61A0; +extern u8 D_807F6938; + +void func_80631B80(void) { + D_807F6148 = 0; +} + +void func_80631B8C(s16 arg0) { + if (D_807F6148 != 4) { + D_807F6140[D_807F6148] = arg0; + D_807F6148++; + } +} + +s32 func_80631BCC(s16 arg0) { + s32 i; + + for (i = 0; i < D_807F6148; i++) { + if (arg0 == D_807F6140[i]) { + return TRUE; + } + } + return FALSE; +} + +s16 func_80631C20(u8 arg0) { + return D_807F6150[arg0]; +} + +// Doable, little struct definition work needed, couple of loops +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80631C3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80631D8C.s") + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + u16 unk28; // Used + u16 unk2A; + s32 unk2C; + s32 unk30; + s32 unk34; +} GlobalASMStruct88; + +/* +// TODO: Very close, just stack nonsense +s32 func_80631D8C(u8 arg0) { + s32 j; + s32 temp_s2; + s32 *sp5C; + s32 sp58; + s32 i; + u8 temp_s6; + u16 phi_s3; + GlobalASMStruct88 *phi_s0; + + temp_s6 = getLevelIndex(arg0, 1); + phi_s3 = 0; + for (i = 0; i < arg0; i++) { + if (temp_s6 == getLevelIndex(i, 1)) { + // Load setup for map + void *temp_v0 = getPointerTableFile(9, i, 1, 1); + if (temp_v0) { + func_80631F58(temp_v0, &sp5C, &sp58); + temp_s2 = *sp5C; + phi_s0 = sp5C + 1; + for (j = 0; j < temp_s2; j++) { + if (func_80631EB8(phi_s0->unk28) != 0) { + phi_s3++; + } + phi_s0++; + } + func_8066B424(); + func_8066B434(temp_v0, 0x13A, 7); + } + } + } + return phi_s3; +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80631EB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80631F58.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80631FAC.s") + +// Load Model 2 Setup? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632084.s") + +// Jumptable, chunk14* arg0 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806323C0.s") + +s32 func_8063253C(s32 arg0, s32 arg1) { + return 1; +} + +// Doable, object model 2 loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063254C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632630.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632860.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632E10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632E74.s") + +// Weird struct in arg1 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632F20.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632F74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80632FCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806330C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806333F8.s") + +// Loop, struct arg1, doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80633570.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806335B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063367C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063373C.s") + +// Loop, struct arg1, doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806338B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806338F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063393C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80633A1C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80633D30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80633DC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80634768.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806348B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80634908.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063495C.s") + +// Init for Model2Model50_B8 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806349FC.s") + +void func_80634E10(Model2Model50_B8*, s16, s16, s16, s16*, s16*, u8); +void func_80634FA0(Model2Model50_B8*, s16, u8, u8*, u8); +void func_80635098(Model2Model50_B8*, s16, s32, s32); +void func_80634F14(s32, s16, u8, u8*, u8); +void func_80634F14(s32, s16, u8, u8*, u8); +void func_80634D64(s32 arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, u8 arg6); + +void func_80634CC8(s32 arg0, s16 arg1, s16 arg2, s16 arg3) { + func_80634D64(arg0, arg1, arg2, arg3, &arg2, &arg3, 0); +} + +void func_80634D14(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + s16 temp2; + s16 temp; + func_80634D64(arg0, arg1, temp2, temp, arg2, arg3, 1); +} + +void func_80634D64(s32 arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, u8 arg6) { + s32 model2ArrayIndex = func_80659470(arg0); + Model2Model *model = D_807F6000[model2ArrayIndex].model_pointer; + + switch (D_807F6000[model2ArrayIndex].unk86) { + case 2: + func_80634E10(model->unk50, arg1, arg2, arg3, arg4, arg5, arg6); + break; + case 1: + func_80634E10(model->unkB8, arg1, arg2, arg3, arg4, arg5, arg6); + break; + } +} + +void func_80634E10(Model2Model50_B8 *arg0, s16 arg1, s16 arg2, s16 arg3, s16 *arg4, s16 *arg5, u8 arg6) { + // TODO: Better match for arg1--, this syntax is weird + arg1--; + while (arg0 && arg1) { + arg1--; + arg0 = arg0->next; + } + if (arg0) { + if (arg6) { + *arg4 = arg0->unk38; + *arg5 = arg0->unk3A; + } else { + arg0->unk38 = arg2; + arg0->unk3A = arg3; + } + } +} + +void func_80634EA4(s32 arg0, s16 arg1, u8 arg2) { + func_80634F14(arg0, arg1, arg2, &arg2, 0); +} + +void func_80634EDC(s32 arg0, s16 arg1, u8 *arg2) { + u8 temp; + func_80634F14(arg0, arg1, temp, arg2, 1); +} + +void func_80634F14(s32 arg0, s16 arg1, u8 arg2, u8 *arg3, u8 arg4) { + s32 model2ArrayIndex = func_80659470(arg0); + Model2Model *model = D_807F6000[model2ArrayIndex].model_pointer; + + switch (D_807F6000[model2ArrayIndex].unk86) { + case 2: + func_80634FA0(model->unk50, arg1, arg2, arg3, arg4); + break; + case 1: + func_80634FA0(model->unkB8, arg1, arg2, arg3, arg4); + break; + } +} + +void func_80634FA0(Model2Model50_B8 *arg0, s16 arg1, u8 arg2, u8 *arg3, u8 arg4) { + // TODO: Better match for arg1--, this syntax is weird + arg1--; + while (arg0 && arg1) { + arg1--; + arg0 = arg0->next; + } + if (arg0) { + if (arg4) { + *arg3 = arg0->unk48; + } else { + arg0->unk48 = arg2; + } + } +} + +void func_80635018(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + s32 model2ArrayIndex = func_80659470(arg0); + Model2Model *model = D_807F6000[model2ArrayIndex].model_pointer; + + switch (D_807F6000[model2ArrayIndex].unk86) { + case 2: + func_80635098(model->unk50, arg1, arg2, arg3); + break; + case 1: + func_80635098(model->unkB8, arg1, arg2, arg3); + break; + } +} + +void func_80635098(Model2Model50_B8 *arg0, s16 arg1, s32 arg2, s32 arg3) { + // TODO: Better match for arg1--, this syntax is weird + arg1--; + while (arg0 && arg1) { + arg1--; + arg0 = arg0->next; + } + if (arg0) { + if (arg2 != arg0->unk54 || arg3 != arg0->unk50) { + arg0->unk49 = 1; + } + arg0->unk54 = arg2; + arg0->unk50 = arg3; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80635114.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80635214.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063524C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80635468.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80635548.s") + +extern s32 D_80747D70; + +void func_80635588(void) { + s32 temp_s1; + s32 i; + + temp_s1 = D_80747D70; + for (i = 0; i < temp_s1; i++) { + func_806355DC(0, 0); + } + func_80659350(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806355DC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806357F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806358E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80635EF0.s") + +void func_80636014(s32 arg0, u8 arg1, u8 arg2) { + if (arg1 == 1) { + arg0 = func_80659470(arg0); + } + func_8062D094(D_807F6000[arg0].model_pointer, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636074.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636164.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636210.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806362C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636380.s") + +/* +// TODO: Which struct is this? +void func_80636380(s32 arg0, void *arg1) { + s32 temp_a0; + s32 temp_a0_2; + s32 temp_s1; + void *phi_s0; + s32 phi_s1; + + phi_s0 = arg1; + phi_s1 = 0; + if (arg1->unk20 > 0) { + do { + temp_a0 = phi_s0->unk24; + if (temp_a0 != 0) { + func_8066B434(temp_a0, 0xA69, 7); + } + temp_a0_2 = phi_s0->unk34; + if (temp_a0_2 != 0) { + func_8066B434(temp_a0_2, 0xA6A, 7); + } + temp_s1 = phi_s1 + 1; + phi_s0 += 4; + phi_s1 = temp_s1; + } while (temp_s1 < arg1->unk20); + } + func_8066B434(arg0, 0xA6E, 7); + func_8061134C(arg1->unk1C); + func_8061134C(arg1); + func_8061134C(arg1->unk14); + func_8061134C(arg1->unk18); +} +*/ + +typedef struct struct_807F6160 Struct807F6160; + +struct struct_807F6160 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + void *unk10; // Pointer to something at least 0x3C big, see func_806364C4 + s32 unk14; + Struct807F6160 *unk18; // Linked list +}; + +extern Struct807F6160 *D_807F6160; +extern s32 D_8076A064; + +void func_8063643C(void) { + D_807F6160 = NULL; +} + +void func_80636448(s32 arg0, s32 arg1, s32 arg2, s32 arg3, void *arg4) { + Struct807F6160 *new; + Struct807F6160 *old; + + new = malloc(sizeof(Struct807F6160)); + old = D_807F6160; + D_807F6160 = new; + new->unk18 = old; + new->unk0 = arg0; + new->unk4 = arg1; + new->unk8 = arg2; + new->unkC = arg3; + new->unk14 = D_8076A064 + 2; + new->unk10 = arg4; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806364C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806365D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636784.s") + +// Object Model 2 Geometry +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806368F0.s") + +f32 func_80636A44(s32 arg0) { + s32 pad2; // TODO: Why is this needed? + s32 pad; // TODO: Why is this needed? + f32 sp1C; + f32 *model2Geometry; + + // Object Model 2 Geometry + model2Geometry = getPointerTableFile(4, arg0, 1, 0); + sp1C = model2Geometry[1]; + func_8066B434(model2Geometry, 0xB87, 7); + return sp1C; +} + +u8 func_80636A8C(s32 arg0) { + s32 pad; // TODO: Why is this needed? + s32 pad2; // TODO: Why is this needed? + s32 phi_v1; + s32 *model2Geometry; + + // Object Model 2 Geometry + model2Geometry = getPointerTableFile(4, arg0, 1, 0); + if (*model2Geometry & 8) { + phi_v1 = TRUE; + } else { + phi_v1 = FALSE; + } + func_8066B434(model2Geometry, 0xBA3, 7); + return phi_v1; +} + +// Annoying struct stuff, doable otherwise, maybe object model 2? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636AE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636B50.s") + +// object model 2, model pointer, behaviour_pointer +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636C00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636D38.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636EFC.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80636FFC.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80637B6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806392BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_806398E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80639968.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80639C04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80639CD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80639F1C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_80639FC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063A38C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063A848.s") + +// object model 2 -> model_pointer -> 0x54, 0xBC -> unk4 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063A8C4.s") + +/* +void func_8063A8C4(s16 arg0, u8 arg1, f32 arg2) { + ObjectModel2 *temp_v0; + s16 temp_a1; + Model2Model *temp_v1; + s16 phi_a0; + void *phi_v0; + + phi_a0 = arg0; + if (arg1 == 1) { + phi_a0 = func_80659470(arg0); + } + temp_v0 = &D_807F6000[phi_a0]; + temp_a1 = temp_v0->unk86; + temp_v1 = temp_v0->model_pointer; + if (temp_a1 != 1) { + if (temp_a1 != 2) { + phi_v0 = sp18; + } else { + phi_v0 = temp_v1->unk54; + } + } else { + phi_v0 = temp_v1->unkBC; + } + if (phi_v0 != 0) { + phi_v0->unk4 = arg2; + } +} +*/ + +// display list something +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063A968.s") + +void func_8063B4A4(void) { + D_807F6028 = 0; + D_807F60A8 = 0; + D_807F6938 = 0; +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063B4C0.s") + +// big, object model 2 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063B758.s") + +// big, object model 2 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063B8D8.s") + +// big, object model 2 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063BBB0.s") + +// big +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063BEC0.s") + +// object model 2 -> 0x48, 0x49, 0x4E, 0x7C -> 0x10, 0x12, 0x38, 0x94, 0x9A +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063BF34.s") + +void func_8063C1EC(s32 arg0, u8 arg1) { + D_807F6000[func_80659470(D_807F6240[arg0])].model_pointer->unk4E |= arg1; +} + +void func_8063C248(s32 arg0, u8 arg1) { + D_807F6000[func_80659470(D_807F6240[arg0])].model_pointer->unk4E &= ~arg1; +} + +// object model 2 -> unk7C -> 0x60, 0x64 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063C2A8.s") + +s16 func_8063C328(s16 arg0) { + s16 model2ArrayIndex = func_80659470(arg0); + if (model2ArrayIndex == -1) { + return -1; + } + return D_807F6000[model2ArrayIndex].object_type; +} + +typedef struct { + void (*unk0)(void); // Function pointer, used + void (*unk4)(s32); // Function pointer, used + void (*unk8)(void); // Function pointer, used + u8 unkC; // Used + s8 unkD; + s8 unkE; + s8 unkF; +} Struct80747D80; + +extern Struct80747D80 D_80747D80[]; + +void func_8063C390(void) { + s32 i = 0; + + for (i = 0; i < 8; i++) { + D_80747D80[i].unkC = FALSE; + } +} + +void func_8063C3C0(s16 arg0) { + if (!D_80747D80[arg0].unkC) { + D_80747D80[arg0].unk0(); + D_80747D80[arg0].unkC = TRUE; + } +} + +void func_8063C418(s32 arg0, s16 arg1) { + D_80747D80[arg1].unk4(arg0); +} + +void func_8063C450(void) { + s32 i = 0; + + for (i = 0; i < 8; i++) { + if (D_80747D80[i].unkC) { + D_80747D80[i].unk8(); + } + } +} + +void func_8063C4A8(void) { + D_807F6170 = 255.0f; + D_807F6174 = 255.0f; +} + +// display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063C4C4.s") + +void func_8063C6D8(void) { + D_807F6170 -= 1.0; + if (D_807F6170 < 0.0) { + D_807F6170 = 255.0f; + } + D_807F6174 -= D_807584F0; + if (D_807F6174 < 0.0) { + D_807F6174 = 255.0f; + } +} + +void func_8063C784(void) { + D_807F6178 = 255.0f; + D_807F617C = getPointerTableFile(0x19, 0x565, 1, 0); // Texture +} + +// display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063C7C4.s") + +void func_8063CA7C(void) { + D_807F6178 -= 1.0; + if (D_807F6178 < 0.0) { + D_807F6178 = 255.0f; + } +} + +void func_8063CADC(void) { + D_807F6180 = 255.0f; + D_807F6184 = 255.0f; + D_807F6188 = getPointerTableFile(7, 0x3B7, 0, 0); // Texture + D_807F618C = getPointerTableFile(7, 0x3B8, 0, 0); // Texture +} + +// jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063CB40.s") + +void func_8063CE64(void) { + D_807F6180 -= D_80758540; + if (D_807F6180 < 0.0) { + D_807F6180 = 255.0f; + } + D_807F6184 -= D_80758548; + if (D_807F6184 < 0.0) { + D_807F6184 = 255.0f; + } +} + +void func_8063CF0C(void) { + D_807F6190 = getPointerTableFile(7, 0x3E0, 1, 0); // Texture +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063CF3C.s") + +void func_8063D1D8(void) { + D_80747E00 -= 5.0; + if (D_80747E00 < 0.0) { + D_80747E00 = 255.0f; + } + D_80747E04 -= 2.0; + if (D_80747E04 < 0.0) { + D_80747E04 = 255.0f; + } +} + +typedef struct { + s16 unk0; // Texture index + s16 unk2; + void *unk4; // Pointer to an uncompressed texture +} GlobalASMStruct77; + +extern GlobalASMStruct77 D_80747E0C[]; + +void func_8063D288(void) { + s32 i; + + D_807F6194 = 0; + for (i = 0; i < 11; i++) { + // Texture (Uncompressed) + D_80747E0C[i].unk4 = getPointerTableFile(7, D_80747E0C[i].unk0, 1, 0); + } +} + +// display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063D2E4.s") + +void func_8063D468(void) { + D_807F6194++; + if (D_807F6194 == 11) { + D_807F6194 = 0; + } +} + +void func_8063D494(void) { + D_807F6198 = 0.0f; +} + +// display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063D4A4.s") + +void func_8063D5AC(void) { + D_807F6198 -= D_80758550; + if (D_807F6198 < 0.0) { + D_807F6198 = 255.0f; + } +} + +void func_8063D608(void) { + D_807F619C = getPointerTableFile(0x19, 0x1765, 1, 0); // Texture +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_36880/func_8063D638.s") + +void func_8063D854(void) { + switch (current_map) { + case MAP_CASTLE_BARREL_BLAST: + D_807F61A0 -= 2.0; + break; + case MAP_FUNGI_BARREL_BLAST: + D_807F61A0 -= 1.0; + break; + default: + D_807F61A0 -= 1.0; + break; + } + if (D_807F61A0 < 0.0) { + D_807F61A0 = 255.0f; + } +} diff --git a/src/global_asm/code_3C10.c b/src/global_asm/code_3C10.c new file mode 100644 index 00000000..e540d2df --- /dev/null +++ b/src/global_asm/code_3C10.c @@ -0,0 +1,547 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_8002920C(void); + +void func_805FF168(void); +void func_805FF898(void); + +void func_807313BC(void); +void func_805FFFC8(void); + +extern u8 D_807445E0[]; // level_index_mapping +extern s32 D_80744720[] = { + 0x181, // Kong Unlocked: DK + 0x6, // Kong Unlocked: Diddy + 0x46, // Kong Unlocked: Lanky + 0x42, // Kong Unlocked: Tiny + 0x75, // Kong Unlocked: Chunky +}; // kong_unlocked_flag_mapping + +extern u16 D_80744734[] = { // lobby_array + MAP_JAPES_LOBBY, + MAP_AZTEC_LOBBY, + MAP_FACTORY_LOBBY, + MAP_GALLEON_LOBBY, + MAP_FUNGI_LOBBY, + MAP_CAVES_LOBBY, + MAP_CASTLE_LOBBY, + MAP_HELM_LOBBY, + MAP_HELM_LOBBY, // TODO: Why is this here twice? +}; // lobby_array + +typedef struct { + s32 unk0; + s32 unk4; // Permanent Flag Index +} GlobalASMStruct41; +extern GlobalASMStruct41 D_80744800[]; +extern u8 D_80744820; +extern u8 D_80744824; +extern u8 D_80744828; +extern u8 D_807444F8; +extern u8 D_807565E0[]; +extern u8 D_80756630[]; +extern u16 D_807446C0[]; +extern s16 D_8076AEF2; +extern u8 D_8076A0B1; +extern u8 D_8076A0B2; +extern u8 loading_zone_transition_type; +extern f32 loading_zone_transition_speed; +extern u16 D_8076AEF4; +extern u8 D_8076AEF6; + +typedef struct global_asm_struct_1 { + u8 unk0; // inSubmap? + u8 unk1; + s16 unk2; + f32 unk4; // X Position + f32 unk8; // Y Position + f32 unkC; // Z Position + s16 unk10; // Angle? + s16 unk12; // Map + u8 unk14; // Used + u8 unk15; + s16 unk16; + s32 unk18; + s32 unk1C; + s32 unk20; // Used + u8 pad24[0x9C]; +} GlobalASMStruct1; // Size 0xC0 + +extern GlobalASMStruct1 D_8076A160[]; +extern s16 D_8076AEE2; +extern f32 D_8076AEE4; // X Position +extern f32 D_8076AEE8; // Y Position +extern f32 D_8076AEEC; // Z Position +extern s16 D_8076AEF0; // Angle? + +extern s32 D_807F6010; +extern s32 D_807FBB68; +extern u16 D_807FC930[]; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_805FEF10.s") + +/* +// TODO: Pretty close +// arg0 appears to be a pointer to a flag index +s32 func_805FEF10(s32 *arg0) { + s32 found; + s32 i; + + found = FALSE; + i = 0; + while (!found && i < 4) { + found = player_pointer->unk58 == D_80744800[i].unk0; + if (found) { + *arg0 = D_80744800[i].unk4; + } + i++; + } + + return found; +} +*/ + +s32 func_805FEF74(Maps map) { + s32 lobbyIndex; + + for (lobbyIndex = 0; lobbyIndex < 9; lobbyIndex++) { + if (map == D_80744734[lobbyIndex]) { + return TRUE; + } + } + + return FALSE; +} + +// level_index_mapping lookup +u8 func_805FF000(u8 map) { + return D_807445E0[map]; +} + +// TODO: Yuk, get rid of temp variable if possible +// getKongUnlockedFlagIndex(s32 actorBehaviour, s32 kongIndex); +s32 func_805FF018(s32 actorBehaviour, s32 kongIndex) { + s32 temp; + temp = D_80744720[kongIndex]; + return temp; +} + +// Returns a level index for a given map +u8 getLevelIndex(u8 map, u8 arg1) { + u8 levelIndex; + Maps _map; + s32 sp24; + s32 temp; + + _map = map; + levelIndex = D_807445E0[_map]; + if ((levelIndex == 0xD) || (levelIndex == 9)) { + if (func_805FF800(&_map, &sp24)) { + levelIndex = D_807445E0[_map]; + } + } + if (arg1) { + if (func_805FEF74(_map)) { + levelIndex = 7; + } + } + return levelIndex; +} + +u8 func_805FF0C8(void) { + s32 levelIndex = getLevelIndex(D_8076A0AB, FALSE); + return D_807FC930[levelIndex] >= D_807446C0[levelIndex]; +} + +void func_805FF118(void) { + s32 i; + for (i = 0; i < 18; i++) { + D_8076A160[i].unk0 = FALSE; + } +} + +void func_805FF158(u8 arg0) { + D_80744824 = arg0; +} + +void func_805FF168(void) { + loading_zone_transition_type = D_80744824; + D_80744824 = 1; +} + +void func_805FF188(s16 arg0, u8 arg1) { + D_80744828 = 1; + D_8076AEF4 = arg0; + D_8076AEF6 = arg1; +} + +// Weird, accessing current_map as a struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_805FF1B0.s") + +void func_805FF2F4(void) { + Maps map; + s32 exit; + + if (current_map != MAP_DK_ISLES_OVERWORLD) { + func_805FFFC8(); + map = D_80744734[getLevelIndex(D_8076A0AB, FALSE)]; + exit = 1; + } else { + map = current_map; + exit = 0; + } + setFlag(0x6E, TRUE, FLAG_TYPE_TEMPORARY); + func_805FF378(map, exit); +} + +void func_805FF378(Maps nextMap, s32 nextExit) { + func_806F5378(); + if (is_cutscene_active == 6 || !func_80712798()) { + func_80712F10(&nextMap, &nextExit); + if (nextMap != -1) { + if (current_character_index[0] >= 6) { + current_character_index[0] = func_806C8DE0(0); + } + D_8076A0B1 |= 1; + D_8076AEF2 = current_map; + next_map = nextMap; + next_exit = nextExit; + D_8076A0B2 = 3; + func_805FF168(); + loading_zone_transition_speed = 1.0f; + if (D_807444F8 != 1 && loading_zone_transition_type == 1 && !(D_807FBB68 & 2) && current_map != MAP_DK_RAP) { + playSong(0x2C, 1.0f); + } + func_807313BC(); + func_805FF5A0(nextMap); + if (D_807FBB64 & 1) { + func_8002920C(); + } + } + } +} + +void func_805FF4D8(Maps map, s32 exit) { + func_806F5378(); + global_properties_bitfield |= 0x100; + next_map = map; + next_exit = exit; + D_8076AEF2 = current_map; + func_807313BC(); + func_805FF5A0(map); +} + +typedef struct { + s32 unk0; // Map + s32 unk4; // Map + s32 unk8; // Exit +} GlobalASMStruct42; + +extern GlobalASMStruct42 D_807447A0[]; + +void func_805FF544(void) { + s32 i; + for (i = 0; i < 8; i++) { + if (current_map == D_807447A0[i].unk0) { + func_805FF378(D_807447A0[i].unk4, D_807447A0[i].unk8); + return; + } + } +} + +void func_805FF5A0(Maps map) { + s32 index = func_80600080(map); + + if (index != -1) { + D_8076AEE2 = D_8076A160[index].unk2; + D_8076AEE4 = D_8076A160[index].unk4; // X Position (exit) + D_8076AEE8 = D_8076A160[index].unk8; // Y Position (exit) + D_8076AEEC = D_8076A160[index].unkC; // Z Position (exit) + D_8076AEF0 = D_8076A160[index].unk10; // Angle? (exit) + } else { + D_8076AEE2 = 0; + } +} + +void func_805FF628(Maps map, s32 exit) { + func_805FFEF8(current_map); + func_805FF378(map, exit); +} + +void func_805FF660(u8 arg0) { + D_80744820 = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_805FF670.s") + +f32 func_80612794(s16); +void func_806A5DF0(s32, f32, f32, f32, s32, s32, s32, s32); +void func_806F8BC4(s32, s32, s32); + +/* +// TODO: Pretty close, something up with that big function call +void func_805FF670(void) { + f32 temp_f20; + s16 temp_s2; + s16 phi_s1; + + if (D_80744820 != 0) { + playCutscene(player_pointer, 2, 5); + func_806F8BC4(1, 0, 0); + for (phi_s1 = 0; phi_s1 < D_80744820; phi_s1++) { + temp_f20 = (phi_s1 * 2) + 0x1E; + temp_s2 = player_pointer->x_position - (func_80612794(player_pointer->y_rotation) * temp_f20); + func_806A5DF0( + 0x35, + temp_s2, + player_pointer->y_position + 20.0f + (phi_s1 * 5), + player_pointer->z_position - (func_80612790(player_pointer->y_rotation) * temp_f20), + player_pointer->y_rotation, + 1, + -1, + 0 + ); + } + D_80744820 = 0; + } +} +*/ + +s32 func_805FF800(Maps *arg0, s32 *arg1) { + s32 phi_v1 = FALSE; + s32 i = 0; + + while (i < 18 && !phi_v1) { + if (D_8076A160[i].unk0 && (D_8076A160[i].unk2 & 2)) { + phi_v1 = TRUE; + } else { + i++; + } + } + if (phi_v1) { + *arg0 = D_8076A160[i].unk12; // Map + *arg1 = D_8076A160[i].unk14; + } + return phi_v1; +} + +void func_805FF898(void) { + Maps map; + s32 exit; + + if (func_805FF800(&map, &exit)) { + func_805FFEF8(current_map); + func_805FF378(map, exit); + return; + } + if (gameIsInSnidesBonusGameMode()) { + func_805FF378(MAP_SNIDES_HQ, 0); + } +} + +void func_805FF8F8(void) { + if (gameIsInMysteryMenuMinigameMode()) { + func_805FF378(MAP_MAIN_MENU, 0); + } else { + func_805FF898(); + } +} + +// arg0 likely map +s32 func_805FF938(s16 arg0) { + s32 phi_v1 = FALSE; + s32 i = 0; + + while (i < 18 && !phi_v1) { + if (D_8076A160[i].unk0 && (arg0 == D_8076A160[i].unk12)) { + phi_v1 = TRUE; + } else { + i++; + } + } + return phi_v1; +} + +// Hmm, looks doable, big job though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_805FF9AC.s") + +// arg0 likely map +s32 func_805FFE50(s32 arg0, s16 arg1, s16 arg2) { + s32 i = 0; + s32 phi_a3 = FALSE; + + while (!phi_a3 && i < 18) { + if (arg0 == D_8076A160[i].unk12) { + phi_a3 = TRUE; + } else { + i++; + } + } + if (!phi_a3) { + return FALSE; + } + func_8063BEC0(D_8076A160[i].unk20, D_8076A160[i].unk1C, arg1, arg2); + return TRUE; +} + +void func_805FFEF8(Maps map) { + s32 phi_v1 = FALSE; + s32 i = 0; + + while (i < 18 && !phi_v1) { + if (D_8076A160[i].unk0 && (map == D_8076A160[i].unk12)) { + phi_v1 = TRUE; + } else { + i++; + } + } + if (phi_v1) { + func_80611614(&D_8076A160[i].unk18); + func_8061130C(D_8076A160[i].unk18); + if (D_8076A160[i].unk1C != 0) { + func_80611614(&D_8076A160[i].unk20); + func_8061130C(D_8076A160[i].unk20); + } + D_8076A160[i].unk0 = FALSE; + D_807F6010 = 0; + } +} + +void func_805FFFC8(void) { + s32 i; + for (i = 0; i < 18; i++) { + if (D_8076A160[i].unk0) { + func_80611614(&D_8076A160[i].unk18); + func_8061130C(D_8076A160[i].unk18); + if (D_8076A160[i].unk1C != 0) { + func_80611614(&D_8076A160[i].unk20); + func_8061130C(D_8076A160[i].unk20); + } + D_8076A160[i].unk0 = FALSE; + } + } +} + +void func_80600044(s32 arg0) { + func_805FFFC8(); + func_805FF378(D_80744734[arg0], 1); +} + +s32 func_80600080(Maps map) { + s32 i; + for (i = 0; i < 18; i++) { + if (D_8076A160[i].unk0 && map == D_8076A160[i].unk12) { + return i; + } + } + return -1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_80600174.s") + +/* +// TODO: Bleh, matches everything except for some extra lui instructions being generated for some reason +s16 func_80600174(f32 *arg0, f32 *arg1, f32 *arg2) { + s32 i; + for (i = 0; i < 18; i++) { + if (D_8076A160[i].unk0 && (D_8076A160[i].unk2 & 1)) { + *arg0 = D_8076A160[i].unk4; + *arg1 = D_8076A160[i].unk8; + *arg2 = D_8076A160[i].unkC; + return i; + } + } + return -1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_80600340.s") + +int func_80689C20(s32, s32, s32, s32, f32, f32); +void func_80631F58(s32, s32, s32); + +/* +// TODO: Regalloc v1 a3 +s32 func_80600340(s32 arg0, u8 arg1, s32 *arg2) { + s32 sp3C; + s32 sp38; + s32 sp34; + f32 sp30; + f32 sp2C; + u8 temp_a3 = func_80600174(&sp34, &sp30, &sp2C); + if (temp_a3 == -1) { + return -1; + } + func_80631F58(D_8076A160[temp_a3].unk18, &sp3C, &sp38); + *arg2 = D_8076A160[temp_a3].unk12; + return func_80689C20(sp38, arg0, arg1, sp34, sp30, sp2C); +} +*/ + +typedef struct global_asm_struct_2 { + s32 unk0; // Bitfield + s32 unk4; + s32 unk8; +} GlobalASMStruct2; + +extern GlobalASMStruct2 D_8074482C[]; +extern GlobalASMStruct2 D_80744834[]; + +void func_806003EC(s16 arg0) { + D_807FBB64 = D_8074482C[arg0].unk0; + D_807FBB68 = D_8074482C[arg0].unk4; +} + +s32 func_8060042C(s16 arg0) { + return D_80744834[arg0].unk0; +} + +u8 func_80600454(s16 arg0, u8 *arg1) { + u8 i = 0; + u8 hadSeenFirstTimeText = FALSE; + + while (D_807565E0[i] && arg0 != D_807565E0[i]) { + i++; + } + if (D_807565E0[i] != 0) { + *arg1 = D_80756630[i]; + if (i < 0xD) { + // Level first time caption (FTT) seen + hadSeenFirstTimeText = !isFlagSet(0x307 + i, FLAG_TYPE_PERMANENT); + setFlag(0x307 + i, TRUE, FLAG_TYPE_PERMANENT); + } else { + hadSeenFirstTimeText = TRUE; + } + } + return hadSeenFirstTimeText; +} + +// TODO: This is pretty ugly, can it be turned into a for loop while still matching? +s32 func_80600530(void) { // getLobbyIndex() + s32 foundLobby; + s32 i; + + i = 0; + foundLobby = FALSE; + + while (!foundLobby && i < 8) { + if (current_map == D_80744734[i]) { + foundLobby = TRUE; + } else { + i++; + } + } + + if (!foundLobby) { + i = 0; + } + return i; +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_80600590.s") + +// Delay slot problem +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_3C10/func_80600674.s") diff --git a/src/global_asm/code_42630.c b/src/global_asm/code_42630.c new file mode 100644 index 00000000..705e2d6b --- /dev/null +++ b/src/global_asm/code_42630.c @@ -0,0 +1,1191 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_80717D4C; +extern s32 D_8071AADC; +extern s32 D_8071FBC8; +extern s32 D_8071FF18; +extern s32 D_8071FFA0; +extern s32 D_80720A7C; +extern s32 D_80721530; + +extern u8 D_80750AB4; +extern s32 D_807552E8; +extern f64 D_80758AA8; // Z position +extern f64 D_80758AB0; // X position +extern f64 D_80758AB8; // Radius for dx/dz +extern f64 D_80758BD8; + +extern f32 D_807F621C; // X +extern f32 D_807F6220; // Y +extern f32 D_807F6224; // Z +extern f32 D_807F6228; +extern f32 D_807F622C; +extern f32 D_807F6230; +extern f32 D_807F6234; +extern f32 D_807F6238; +extern s8 D_807F6950; +extern s8 D_807F6951; + +void func_80614D00(Actor*, f32, f32); + +void func_806335B0(s16, s32, s32, f32*, f32*, f32*); + +s32 func_806418E8(s16, s16, s16); +u8 func_8064EC60(s32, s16, s16, s16); +extern void func_8064EE08(void); + +void func_8065A708(f32, f32, s32, f32, f32, f32, f32, s32, u8, u8, u8); // TODO: Is this signature correct? + +u8 func_80661300(s32); +void func_8066134C(s32, u8); + +void func_8067DF44(f32, f32, f32, f32, s32, s32); + +void func_80714950(s32); +void func_80714998(s32); +void func_807149B8(s32); +void func_80714B84(void*, f32, s32, s32, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063D930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063D990.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063D9D0.s") + +void func_8063DA40(s16 arg0, s16 arg1) { + func_8063DA78(arg0, arg1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063DA78.s") + +void func_8063DA40(s16, s16); + +typedef struct { + s16 unk0; // Used + s16 unk2; // Used + s16 unk4; // Used + u8 unk6; // Used + u8 unk7; +} Struct807F61B0; + +extern Struct807F61B0 D_807F61B0[]; + +void func_8063DB0C(void) { + s32 i; + + for (i = 0; i < 8; i++) { + D_807F61B0[i].unk6 = FALSE; + } +} + +void func_8063DB3C(s16 arg0, s16 arg1, s16 arg2) { + s16 phi_v0 = 0; + s32 phi_v1 = FALSE; + + while (!phi_v1 && phi_v0 < 8) { + if (!D_807F61B0[phi_v0].unk6) { + phi_v1 = TRUE; + } else { + phi_v0++; + } + } + + if (phi_v1) { + D_807F61B0[phi_v0].unk6 = TRUE; + D_807F61B0[phi_v0].unk0 = arg0; + D_807F61B0[phi_v0].unk2 = arg1; + D_807F61B0[phi_v0].unk4 = arg2; + } +} + +void func_8063DBD8(s16 arg0) { + s32 i; + + for (i = 0; i < 8; i++) { + if (D_807F61B0[i].unk6 && (arg0 == D_807F61B0[i].unk0)) { + func_8063DA40(D_807F61B0[i].unk2, D_807F61B0[i].unk4); + D_807F61B0[i].unk6 = FALSE; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063DC58.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063DE68.s") + +// Probably initting a struct, easy way to figure out the shape +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063DED0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063DFEC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063E078.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063E0D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063E5B4.s") + +// Object model 2 behaviour passed in? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063E6B4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063E72C.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063EA14.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8063FA48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641724.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806417BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641874.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806418E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064199C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806419F8.s") + +/* +// TODO: Likely needs to be split into switch cases +s32 func_806419F8(void) { + CharacterChange *temp_v1; + s16 temp_a1; + temp_v1 = &character_change_array[0]; + + if ( + ((player_pointer->control_state == 0x42) && ((temp_a1 = temp_v1->player_pointer->PaaD->unkBC, (temp_a1 == 0x62)) || (temp_a1 == 0x88) || (temp_a1 == 0x17))) + || (player_pointer->control_state == 0x52) + || (player_pointer->control_state == 0x67) + || ((temp_v1->action_initiated == 0x1C)) || (temp_v1->action_initiated == 0x53)) { + return 0; + } + return 1; + + // TODO: aaa + // switch (player_pointer->control_state) { + // case 0x42: + // switch (character_change_array[0].player_pointer->PaaD->unkBC) { + // case 0x62: + // case 0x88: + // case 0x17: + // return 0; + // } + // break; + // case 0x52: + // case 0x67: + // return 0; + // } + // switch (character_change_array[0].action_initiated) { + // case 0x1C: + // case 0x53: + // return 0; + // } +} +*/ + +extern u8 D_807F6938; +extern s16 D_807F6918[]; + +// TODO: This does match but the types on the externs are sus +void func_80641A78(void) { + s32 phi_s0; + + for (phi_s0 = 0; phi_s0 < D_807F6938; phi_s0++) { + func_806355DC(D_807F6240[D_807F6918[phi_s0]], 1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641B00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641BCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641C98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641DA0.s") + +typedef struct { + u8 pad0[0x94 - 0x0]; + Actor *unk94; +} GlobalASMStruct44; + +s32 func_80678014(s32); +Actor *func_807270C0(s16, s32); // getSpawnerTiedActor() +extern f32 D_807F621C; // X +extern f32 D_807F6220; // Y +extern f32 D_807F6224; // Z +extern f32 D_807F622C; // Y Rotation +extern s16 D_807F693C; +extern u8 D_807F693F; + +/* +// TODO: Pretty close, datatytpe issues? +void func_80641DA0(GlobalASMStruct44 *arg0, s16 arg1, s16 arg2, s16 arg3) { + s32 phi_v1; + + if ((arg0->unk94 == 0) && ((func_80678014(0x14)))) { + arg0->unk94 = D_807FBB44; + D_807FBB44->noclip_byte = 1; + D_807FBB44->x_position = D_807F621C; + D_807FBB44->y_position = D_807F6220; + D_807FBB44->z_position = D_807F6224; + D_807FBB44->y_rotation = (D_807F622C * 4096.0f) / 360.0f; + if (D_807F693F != 0) { + D_807FBB44->unk15E = arg3; + } + if (D_807F693F != 0) { + phi_v1 = 4; + } else { + phi_v1 = 0; + } + switch (arg2) { + case 0: + playCutscene(arg0->unk94, arg1, (phi_v1 | 1 | D_807F693C) & 0xFF); + return; + case 1: + playCutscene(NULL, arg1, (phi_v1 | 1 | D_807F693C) & 0xFF); + return; + case 2: + playCutscene(func_807270C0(arg3, 0x400), arg1, (phi_v1 | 1 | D_807F693C) & 0xFF); + break; + } + } +} +*/ + +void func_80641F68(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80641F70.s") + +u8 func_8064216C(s16 cap, f32 x, f32 y, f32 z) { + f32 dx = D_807F621C - x; + f32 dy = D_807F6220 - y; + f32 dz = D_807F6224 - z; + dx *= dx; + dy *= dy; + dz *= dz; + return sqrtf(dx + dy + dz) < cap; +} + +s32 func_80642204(s16 arg0) { + u8 playerIndex; + for (playerIndex = 0; playerIndex < D_80750AB4; playerIndex++) { + if ((character_change_array[playerIndex].does_player_exist) + && (func_8064216C(arg0, + character_change_array[playerIndex].player_pointer->x_position, + character_change_array[playerIndex].player_pointer->y_position, + character_change_array[playerIndex].player_pointer->z_position))) { + return TRUE; + } + } + return FALSE; +} + +s32 func_806422D8(s16 arg0) { + u8 playerIndex; + for (playerIndex = 0; playerIndex < D_80750AB4; playerIndex++) { + if ((character_change_array[playerIndex].does_player_exist) + && (func_8064216C(arg0, + character_change_array[playerIndex].look_at_eye_x, + character_change_array[playerIndex].look_at_eye_y, + character_change_array[playerIndex].look_at_eye_z))) { + return TRUE; + } + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806423A8.s") + +s32 func_80667110(f32, f32, f32 *); +extern f32 D_807F621C; +extern f32 D_807F6220; +extern f32 D_807F6224; +extern f32 D_807F6238; + +void func_80642480(s16 arg0, s32 arg1) { + s32 temp; // TODO: Why is this needed? + f32 sp20; + + switch (arg0) { + case 0: + sp20 = D_807F6220; + if (func_80667110(D_807F621C, D_807F6224, &sp20)) { + D_807F6220 = sp20 + D_807F6238; + } + case 1: + return; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642500.s") + +extern f64 D_80758918; + +/* +// TODO: Pretty close +s32 func_80642500(f32 *arg0, u8 arg1, s16 arg2) { + f32 temp_f0; + f32 temp_f2; + s32 temp_t5; + f32 phi_f12; + s32 phi_v1; + + phi_v1 = 0; + temp_f0 = arg0[arg1]; + switch (arg1) { + default: + return 0; + case 0: + temp_f2 = arg2 / 10.0f; + if (temp_f2 < temp_f0) { + phi_f12 = temp_f0 - temp_f2; + } else { + phi_f12 = temp_f2 - temp_f0; + } + if (phi_f12 < D_80758918) { + return 1; + } + break; + case 1: + if ((arg2 / 10.0f) < temp_f0) { + return 1; + } + break; + case 2: + if (temp_f0 < (arg2 / 10.0f)) { + phi_v1 = 1; + } + break; + } + return phi_v1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806425FC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642748.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642844.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642940.s") + +void func_80642BF0(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + func_80714B84(&D_8071FF18, 0.3f, arg1, 1, 0); + func_80714B84(&D_8071FF18, 0.3f, arg1, 2, 0); + func_80714B84(&D_8071FF18, 0.3f, arg1, 3, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642C78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642E34.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80642FC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80643274.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80643354.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80643440.s") + +void func_806436A4(s32 arg0, s32 arg1, s16 arg2, s16 arg3) { + func_80643354(0, arg2, arg3); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806436E0.s") + +void func_8064384C(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + ObjectModel2 *temp_v1 = &D_807F6000[func_80659470(arg1)]; + + func_8067DF44(temp_v1->x_position, temp_v1->y_position, temp_v1->z_position, temp_v1->hitbox_scale, 0, 1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806438B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80643B24.s") + +void func_80714950(s32); +void func_8071498C(void*); +void func_80714998(s32); +void func_807149B8(s32); +void func_807149C8(s32, s32, s32, s32); +extern s32 D_80717D4C; + +/* +// TODO: Close, minor stack issue +void func_80643B24(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + s32 temp = &D_80717D4C; + if ((object_timer % 5U) == 0) { + func_80714950(-0x78); + func_8071498C(temp); + func_807149B8(1); + func_80714998(3); + func_807149C8(0xFF, 0xFF, 0xFF, 0x96); + func_80714B84(&D_8071FFA0, 1.0f, arg1, 1, 0); + func_80714950(-0x78); + func_8071498C(temp); + func_807149B8(1); + func_80714998(3); + func_807149C8(0xFF, 0xFF, 0xFF, 0x96); + func_80714B84(&D_8071FFA0, 1.0f, arg1, 2, 0); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80643C0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80643F38.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064409C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064431C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806443E4.s") + +void func_806449C0(s32 arg0, s16 arg1, s16 arg2, s32 arg3) { + func_80714998(2); + func_807149B8(1); + func_80714B84(&D_8071FBC8, 1.5f, arg1, arg2, 1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80644A18.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80644CC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80644D50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80644E2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80644EC8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806450C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80645238.s") + +void func_80645614(s32 arg0, s16 arg1, s16 arg2, s16 arg3) { + u32 sp24; + + if (((func_806119A0() / 10000U) % arg2) == 0) { + sp24 = (func_806119A0() / 10000U) % arg3; + func_80714998(2); + func_80714950(0x10064); + func_8071498C(&D_8071AADC); + func_807149C8(0xFF, 0xFF, 0xFF, 0xFF); + func_807149B8(1); + func_80714B84(&D_80720A7C, 0.5f, arg1, sp24 + 1, 0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80645700.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806458C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80645A64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80645B9C.s") + +void func_80645C04(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + f32 sp4C; + f32 sp48; + s32 sp44; + + func_806335B0(arg1, 1, 1, &sp4C, &sp48, &sp44); + func_80659610(2500); + func_80659600(9); + func_806595F0(2); + func_8065A708(sp4C, sp48, sp44, 0.0f, 0.0f, 0.0f, 600.0f, 0, 0xFF, 0xFF, 0xFF); + func_80659610(2500); + func_80659600(0xA); + func_806595F0(2); + func_8065A708(sp4C, sp48, sp44, 0.0f, 0.0f, 0.0f, 600.0f, 0, 0xFF, 0xFF, 0xFF); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80645D14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80645F40.s") + +/* +extern s32 D_8071EB70; +extern f64 D_807589E8; +extern f64 D_807589F0; +extern s32 D_80720B00; + +// TODO: Very close, doable +void func_80645F40(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + s32 i; + f32 phi_f22 = 0.0f; + + if ((object_timer & 0xF) == 0) { + f64 temp_f26 = D_807589E8; + f64 temp_f24 = D_807589F0; + f64 temp; + void* test = &D_80720B00; + for (i = 1; i < 0xB; i++) { + func_807149B8(1); + func_80714998(2); + func_8071498C(&D_8071EB70); + func_80714950(700); + func_807149A8(700); + func_80714B84(test, phi_f22 + temp_f24, arg1, i, 1); + phi_f22 += temp_f26; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80646058.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80646770.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80646978.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80646DC4.s") + +void func_80647108(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + func_80714950(-0x78); + func_8071498C(&D_80717D4C); + func_807149B8(1); + func_80714998(3); + func_80714B84(&D_8071FFA0, 1.5f, arg1, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647170.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647218.s") + +void func_80647508(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + s32 sp34; + f32 sp30, sp2C, sp28; + + sp34 = ((func_806119A0() / 1000U) % 10) + 1; + func_80714950(-0x28A - ((func_806119A0() / 1000U) % 200)); + func_8071498C(&D_80717D4C); + func_807149B8(1); + func_80714998(9); + func_807149C8(0xFF, 0xFF, 0xFF, 0x64); + func_80714944(5); + func_806335B0(arg1, 1, sp34, &sp30, &sp2C, &sp28); + func_80714CC0(&D_8071FFA0, 1.5f, sp30, sp2C - 70, sp28); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647610.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064774C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647834.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647A14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647B74.s") + +void func_80647CF4(s32 arg0, s16 arg1, s16 arg2, s32 arg3) { + func_80714998(2); + if (arg2 != 0) { + func_80714CC0(&D_8071FBC8, 3.0, D_807F621C, D_807F6220, D_807F6224); + return; + } + func_80714B84(&D_8071FBC8, 3.0, arg1, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80647D7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80648000.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064826C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806485A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806487C4.s") + +int func_80648C50() { + s16 chunk = character_change_array[0].chunk; + switch(chunk) { + case 4: + case 0xC: + return 1; + default: + return 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80648C84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064911C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806491F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806493C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064954C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_806496B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80649BF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80649D74.s") + +typedef struct { + u8 pad0[0x14]; + f32 unk14; + u8 pad1[0x31]; + u8 unk49; +} GlobalASMStruct49; + +void func_80649E00(GlobalASMStruct49 *arg0, s32 arg1, s32 arg2, s32 arg3) { + arg0->unk14 = arg0->unk49; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80649E34.s") + +void func_80649F64(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + // TODO: Might actually use unk88 which gets read as unk8A because of the explicit s16 in the function signature + // We'll see what looks more logical when the fields shake out down the line + func_806418E8(0x5F, D_807F6000[func_80659470(arg1)].unk8A, 1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_80649FC0.s") + +void func_8064A180(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064A194.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064A258.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064A804.s") + +// Something to do with caves ice tomato board +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064AAC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064AB1C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064AC28.s") + +void func_8002D6F8(s16); + +void func_8064B118(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + func_8002D6F8(arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B150.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B190.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B204.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B260.s") + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + f32 unk14; + f32 unk18; + f32 unk1C; +} GlobalASMStruct54; + +/* +// TODO: Wrong register order t8 a0 +void func_8064B260(s32 arg0, s32 arg1, s16 arg2, s32 arg3) { + GlobalASMStruct54 *temp_v0; + + temp_v0 = arg0 + (arg2 * 4); + temp_v0->unk14 = player_pointer->unk100; + temp_v0->unk18 = player_pointer->unk104; + temp_v0->unk1C = player_pointer->unk108; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B2AC.s") + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + f32 unk10; + f32 unk14; + f32 unk18; + f32 unk1C; + f32 unk20; + f32 unk24; +} GlobalASMStruct86; + +void func_8064B370(GlobalASMStruct86 **arg0, s32 arg1, s32 arg2, s32 arg3) { + GlobalASMStruct86* temp_v0 = *arg0; + D_807F621C = temp_v0->unk0; + D_807F6220 = temp_v0->unk4; + D_807F6224 = temp_v0->unk8; + D_807F6228 = temp_v0->unkC; + D_807F622C = temp_v0->unk10; + D_807F6230 = temp_v0->unk14; + D_807F6234 = temp_v0->unk18; + D_807F6234 = temp_v0->unk1C; + D_807F6234 = temp_v0->unk20; + D_807F6238 = temp_v0->unk24; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B3F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B4AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B514.s") + +/* +void func_806FAC64(u8); +void func_806F8D58(s32, s32); +void func_806F8BC4(s32, u8, s32); + +// TODO: Regalloc, using t6 instead of t8 +void func_8064B514(u8 arg0, u8 arg1, u8 arg2, s16 arg3) { + func_806FAC64(arg2); + if (arg3) { + func_806F8D58(0xD, 0); + } else { + func_806F8BC4(0xD, 1, 0); + } +} +*/ + +void func_8064B574(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + func_80726EE0(3); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B5A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B798.s") + +/* +// TODO: Regalloc (t7 t8 t9) +void func_8064B798(s32 arg0, s32 arg1, u8 arg2, s32 arg3) { + PlayerAdditionalActorData *temp_v0 = character_change_array[0].player_pointer->PaaD; + temp_v0->unk1FC = arg2; +} +*/ + +void func_8064B7C0(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + +} + +void func_8064B7D4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + +} + +void func_8064B7E8(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + func_806612B4(5, 1); + func_806612B4(6, 1); +} + +void func_8064B828(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + func_8066134C(5, 0xFF); + func_8066134C(6, 0xFF); +} + +void func_8064B868(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + u8 temp_a2 = func_80661300(5); + func_8066134C(5, temp_a2 < 0xFC ? temp_a2 + 3 : 0xFF); + func_8066134C(6, temp_a2 < 0xFC ? temp_a2 + 3 : 0xFF); + func_806612B4(5, 0); + func_806612B4(6, 0); +} + +void func_8064B900(s32 arg0, s32 arg1, s16 arg2, s32 arg3) { + Actor *temp_v0; + Actor *temp_v0_2; + + if (arg2 != 0) { + if (arg2 != 1) { + if (arg2 == 2) { + func_807271F4(8, 0, 0, 0, 0, 0, 0); + D_807FBB44->object_properties_bitfield &= -5; + } + } else { + temp_v0 = func_807270C0(8, 0); + if (temp_v0) { + temp_v0->object_properties_bitfield |= 4; + func_80614EBC(temp_v0, 0x35C); + func_80614D00(temp_v0, 0.9f, 0); + } + } + } else { + temp_v0_2 = func_807270C0(8, 0); + if (temp_v0_2) { + temp_v0_2->control_state = 0x3C; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064B9E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064BAF4.s") + +void func_8064BB4C(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + func_805FF0C8(); +} + +// This function checks whether the key has been turned in for the map stored at D_8076A0AB +s32 func_8064BB78(s32 arg0, s32 arg1, s32 levelIndex, s32 arg3) { + levelIndex = getLevelIndex(D_8076A0AB, FALSE); + if (levelIndex >= 8) { + levelIndex = 0; + } + return isFlagSet(D_80744710[levelIndex], FLAG_TYPE_PERMANENT); +} + +// Seems doable, but very odd float/s16 nonsense in params +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064BBD8.s") + +s32 func_8064BCB0(s32 arg0, s32 arg1) { + Actor *player; + s32 playerIndex; + + for (playerIndex = 0; playerIndex < cc_number_of_players; playerIndex++) { + if (character_change_array[playerIndex].does_player_exist) { + player = character_change_array[playerIndex].player_pointer; + if ((player->locked_to_pad == 1) && (arg0 == player->unk10C) && (arg1 == player->unk10E)) { + return playerIndex; + } + } + } + return -1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064BD2C.s") + +u8 func_8064BE58(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + return D_807552E8 == 5; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064BE80.s") + +s32 func_8064BF58(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + f64 dz, dx; + + dz = character_change_array[0].look_at_eye_z - D_80758AA8; + dx = character_change_array[0].look_at_eye_x - D_80758AB0; + if (((dz * dz) + (dx * dx)) < D_80758AB8) { + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064BFD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C134.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C250.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C3E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C544.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C644.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C708.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C814.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064C9F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064CB3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064CC80.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064CD3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064D0C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064D1E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064D418.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064D880.s") + +extern u16 D_807446C0[]; +extern u16 D_807FC930[]; + +void func_80650AD8(s16, s32, s32, f32); + +/* +// TODO: Float regalloc +void func_8064D880(s32 arg0, s16 arg1, s16 arg2, s32 arg3) { + f32 phi_f0; + f32 temp; + f32 temp2; + s32 levelIndex; + + levelIndex = getLevelIndex(D_8076A0AB, FALSE); + temp = D_807FC930[levelIndex]; + temp2 = D_807446C0[levelIndex]; + phi_f0 = temp / temp2; + if (phi_f0 > 1.0) { + phi_f0 = 1.0f; + } + if (arg2 == 0) { + phi_f0 = 1.0f - phi_f0; + } + func_80650AD8(arg1, 1, 0, phi_f0); + func_80650A04(arg1, 1, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064D978.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064DB98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064DE04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064DF5C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E174.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E428.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E48C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E4F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E55C.s") + +/* +extern s32 D_807482EC; + +void func_8064E55C(s16 arg1, s16 arg2, s32 arg3) { + s32 sp2C = D_807482EC; + func_8064E174(arg1, arg2, &sp2C, 3, 7, 0x14); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E5C0.s") + +/* +// TODO: Which struct is arg0? +void func_8064E5C0(void *arg0, ? arg1, ? arg2, ? arg3) { + s16 sp26; + + sp26 = arg0->unk62; + arg0->unk66 = 0xFF; + arg0->unk60 = 1; + if (((rand() >> 0xF) % 100) >= 0x29) { + arg0->unk62 = 0; + } else { + arg0->unk62 = 0xFF; + } + if (sp26 != arg0->unk62) { + playSound(0x8A, 0xBB8, 63.0f, 1.0f, 0x1E, 0); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064E65C.s") + +void func_8064EA48(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + if (func_806F8AD4(1, 0) >= 2) { + func_806F8BC4(1, 0, 0); + func_806F91B4(1, 0, -2); + // DK Arcade Level 3? + setFlag(0x83, TRUE, FLAG_TYPE_PERMANENT); + } +} + +typedef struct global_asm_struct_7 { + u8 unk0[0x4B]; + s8 unk4B; +} GlobalASMStruct7; + +void func_8064EAB4(GlobalASMStruct7 *arg0, s32 arg1, s32 arg2, s32 arg3) { + s32 numberOfGunSwitchesPressed; + + // Fungi Mushroom Gun Switches Pressed + // Odd that they didn't use func_80731AA8() countSetFlags() for this + numberOfGunSwitchesPressed = isFlagSet(0xE6, FLAG_TYPE_PERMANENT); + numberOfGunSwitchesPressed += isFlagSet(0xE8, FLAG_TYPE_PERMANENT); + numberOfGunSwitchesPressed += isFlagSet(0xE9, FLAG_TYPE_PERMANENT); + numberOfGunSwitchesPressed += isFlagSet(0xE7, FLAG_TYPE_PERMANENT); + numberOfGunSwitchesPressed += isFlagSet(0xEA, FLAG_TYPE_PERMANENT); + + arg0->unk4B = numberOfGunSwitchesPressed; +} + +s32 func_8064EB3C(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + // DK Arcade GB Collected + if (!isFlagSet(0x82, FLAG_TYPE_PERMANENT)) { + return 1; + } + // DK Arcade Level 3? + if (isFlagSet(0x83, FLAG_TYPE_PERMANENT)) { + return 1; + } + return 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064EB9C.s") + +extern u8 D_807446F0[]; + +/* +// TODO: Regalloc +u8 func_8064EB9C(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + s32 levelIndex = getLevelIndex(D_8076A0AB, FALSE); + if (levelIndex >= 8) { + levelIndex = 0; + } + return D_807446F0[levelIndex] == current_character_index[0]; +} +*/ + +// Doable, but tricky, maybe array lookup +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064EC04.s") + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064EC60.s") + +/* +// TODO: Pretty close +u8 func_8064EC60(s32 arg0, s16 arg1, s16 arg2, s16 arg3) { + u8 sp1B; + s32 temp_v0; + s32 kongIndex; + u8 phi_t0; + + phi_t0 = 0; + switch (arg2) { + default: + kongIndex = 4; + if (arg2 != 6) { + kongIndex = 0; + } + break; + case 3: + kongIndex = 1; + break; + case 4: + kongIndex = 2; + break; + case 5: + kongIndex = 3; + break; + } + temp_v0 = func_80600530(); + if ((D_807FC950->character_progress[kongIndex].unk5 & 0x7F) == temp_v0) { + phi_t0 = TRUE; + if (arg3 == 0) { + phi_t0 = TRUE; + if ((D_807FC950->character_progress[kongIndex].unk5 & 0x80)) { + phi_t0 = FALSE; + } + } + } else if (temp_v0 < (D_807FC950->character_progress[kongIndex].unk5 & 0x7F)) { + phi_t0 = TRUE; + } + if (phi_t0 == TRUE) { + if (arg3 == 2) { + D_807FC950->character_progress[kongIndex].unk5 = (D_807FC950->character_progress[kongIndex].unk5 & 0x7F); + } + } + return phi_t0; +} +*/ + +s32 func_8064ED68(s32 arg0, s16 arg1, s32 arg2, s32 arg3) { + u8 phi_s0; + s32 phi_s3; + + phi_s3 = FALSE; + for (phi_s0 = 2; phi_s0 < 7; phi_s0++) { + if (!func_8064EC60(arg0, arg1, phi_s0, 1)) { + phi_s3 = TRUE; + } + } + return phi_s3; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064EE08.s") + +void func_8064F028(s32 arg0, s32 arg1, s16 arg2, s32 arg3) { + func_807149C8(0xFF, 0xFF, 0xFF, 0x80); + func_8071498C(&func_8064EE08); + func_807149FC(-1); + func_807149B8(1); + func_80714998(2); + func_80714CC0(&D_80721530, 0, D_807F621C, D_807F6220 + D_80758BD8, D_807F6224); + func_80677FA8(0x9C, 0x53); // Spawn actor: Wrinkly + D_807FBB44->x_position = D_807F621C; + D_807FBB44->y_position = D_807F6220; + D_807FBB44->z_position = D_807F6224; + D_807FBB44->y_rotation = (D_807F622C * 4096.0f) / 360.0f; + if ((current_map == MAP_FUNGI_LOBBY) || ((current_map == MAP_AZTEC_LOBBY) && (arg2 == 4))) { + // BUG(?): This angle addition does not truncate to 4096 + D_807FBB44->y_rotation += 0x800; + } + playCutscene(D_807FBB44, 0x22, 5); + playSong(0xAB, 1.0f); + playSound(0x2EA, 0x7FFF, 63.0f, 1.0f, 0, 0); + D_807F6951 = arg2; + D_807F6950 = 0; +} + +extern s8 D_807F6950; +extern s8 D_807FC8D0; + +u8 func_8064F1C4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + if (D_807F6950) { + func_80602B60(0xAB, 0); + } + return D_807F6950; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064F210.s") + +/* +f32 func_80612794(s16); +extern f32 D_807F621C; +extern f32 D_807F6224; +extern f32 D_807F622C; + +s32 func_8064F210(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + f32 sp2C; + f32 temp_f0; + s32 temp_f18; + u8 phi_v0; + + temp_f18 = (D_807F622C * 4096.0f) / 360.0f; + sp2C = func_80612794(temp_f18); + temp_f0 = func_80612790(temp_f18); + phi_v0 = FALSE; + if (((player_pointer->x_position * sp2C) + (temp_f0 * player_pointer->z_position) + -((D_807F621C * sp2C) + (D_807F6224 * temp_f0))) > 6.0) { + phi_v0 = TRUE; + } + return phi_v0; +} +*/ + +s32 func_8064F2F0(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + return 1; +} + +void func_8064F308(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + s16 flagIndex; + + if (D_807FC8D0 == 5) { + flagIndex = 0x1C1; // Key 6 turned + } else { + flagIndex = 0x1C2; // Key 7 turned + } + setFlag(flagIndex, TRUE, FLAG_TYPE_PERMANENT); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_42630/func_8064F358.s") + +u8 func_8064F404(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + // Has the player collected 4 or more Battle Crowns? + return func_80731AA8(0x261, 10, FLAG_TYPE_PERMANENT) >= 4; +} diff --git a/src/global_asm/code_54150.c b/src/global_asm/code_54150.c new file mode 100644 index 00000000..00ad115f --- /dev/null +++ b/src/global_asm/code_54150.c @@ -0,0 +1,141 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064F450.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064F6C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064F6F8.s") + +typedef struct { + s32 unk0; + s32 unk4; +} GlobalASMStruct9; + +void func_80650684(GlobalASMStruct9*); +//display list struct ? idk +void func_8064F804(GlobalASMStruct9 *arg0) { + if (arg0) { + func_8061134C(arg0->unk0); + func_8061134C(arg0->unk4); + func_80650684(arg0); + func_8061130C(arg0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064F84C.s") + +void func_8064F954(s32 arg0) { + func_806500E0(); + func_8064F97C(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064F97C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064FA7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8064FB64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_806500E0.s") + +typedef struct { + GlobalASMStruct9* unk0; // Used + void *unk4; // TODO: Which struct? + void *unk8; // TODO: Which struct? + u8 unkC; // Used + s8 unkD; + s8 unkE; + s8 unkF; +} GlobalASMStruct10; + +extern GlobalASMStruct10 D_807F6960[]; +extern u8 D_807444FC; +extern s8 D_807F6BEC; + +void func_8065051C(void) { + s32 i; + for (i = 0; i < 0x28; i++) { + D_807F6960[i].unk0 = NULL; + } +} + +void func_8065054C(GlobalASMStruct9 *arg0, void *arg1, void *arg2) { + s32 found = FALSE; + s32 i = 0; + + while (!found && i < 0x28) { + if (!D_807F6960[i].unk0) { + found = TRUE; + } else { + i++; + } + } + if (found) { + D_807F6960[i].unk0 = arg0; + D_807F6960[i].unk4 = arg1; + D_807F6960[i].unk8 = arg2; + D_807F6960[i].unkC = D_807444FC ^ 1; + } else { + func_80732354(0xB, 0, 0, 0); + } +} + +void func_806505F0(GlobalASMStruct9 *arg0) { + s32 i; + for (i = 0; i < 0x28; i++) { + if (D_807F6960[i].unk0 && arg0 == D_807F6960[i].unk8) { + D_807F6960[i].unk0 = NULL; + } + } +} + +void func_80650684(GlobalASMStruct9 *arg0) { + s32 i; + for (i = 0; i < 0x28; i++) { + if (arg0 == D_807F6960[i].unk0) { + D_807F6960[i].unk0 = NULL; + } + } +} + +void func_806506E8(GlobalASMStruct9 *arg0) { + s32 i; + for (i = 0; i < 0x28; i++) { + if (arg0 == D_807F6960[i].unk0 && D_807F6960[i].unkC == D_807444FC) { + // TODO: Sizeof which struct? + memcpy(D_807F6960[i].unk8, D_807F6960[i].unk4, 0x40); + D_807F6960[i].unk0 = NULL; + D_807F6BEC = 1; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650794.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_806508B4.s") + +// Doable, needs ObjectModel2 -> 0x78 defined +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_8065092C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650998.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650A04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650A70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650AD8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650B50.s") + +// Doable, needs ObjectModel2 -> 0x78 defined +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650BBC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650C28.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650C98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650D04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_54150/func_80650D8C.s") diff --git a/src/global_asm/code_55B20.c b/src/global_asm/code_55B20.c new file mode 100644 index 00000000..e63cfafa --- /dev/null +++ b/src/global_asm/code_55B20.c @@ -0,0 +1,681 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s16 D_807F6BF0[]; +extern u8 D_807F6C08; +extern s32 D_807F6C28; // Number of chunks? +extern s16 D_807F6C58[]; +extern s32 D_807F6C80; + +extern u8 D_807F7078[]; +extern u8 D_807F70AA; +extern u8 D_807F70AB; +extern u8 D_807F7140; + +extern u16 D_807F7358; +extern u16 D_807F735A; +extern u16 D_807F735C; +extern u16 D_807F735E; + +void func_806307CC(s32, s32, s32, u8, u8 *); +void func_80636164(s32, u8); +void func_80636210(s32, u8); +void func_8063B4C0(Chunk14*, u8); +s32 func_8063A38C(Chunk14*, Chunk14*, f32, f32, f32); + +void func_80652FDC(f32, f32, f32, s16, s16, s16*); +Chunk14* func_80630890(Chunk14*, f32, f32, f32, void*); +u8 func_80668E9C(s32, s16, f32, f32, f32, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80650E20.s") + +/* +s32 malloc(s32); +extern s32 D_8076A0B4; +extern s32 D_8076A0B8; +extern s32 D_8076A0BC; +extern s32 D_8076A0C0; +extern s32 D_8076A0C4; +extern s32 D_8076A0C8; + +typedef struct global_asm_struct_18 { + s32 unk0; + u8 pad4[0x64 - 0x4]; + s32 *unk64; +} GlobalASMStruct18; + +// TODO: Single instruction off, I probably should be using the struct, idk +void func_80650E20(s32 *arg0) { + s32 size; + u8 phi_v1; + + D_807F6C28 = arg0[arg0[25]]; + if (D_807F6C28 >= 2) { + phi_v1 = D_807F6C28; + } else { + phi_v1 = 1; + } + size = phi_v1 * 4; + D_8076A0B4 = malloc(size); + D_8076A0B8 = malloc(size); + D_8076A0BC = malloc(size); + D_8076A0C0 = malloc(size); + D_8076A0C4 = malloc(size); + D_8076A0C8 = malloc(size); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80650ECC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80651708.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80651904.s") + +// TODO: Any more cleanup possible? +u8 func_80651B64(s16 arg0) { + s32 phi_v1; + s32 phi_v0; + + phi_v1 = (arg0 + 1) != 0; + if (phi_v1) { + phi_v0 = chunk_array_pointer[arg0].unk3 ? TRUE : FALSE; + phi_v1 = phi_v0 != 0; + } + return phi_v1; +} + +void func_80651BC0(s16 arg0, u8 arg1) { + D_807F7078[arg0] = arg1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80651BE0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80651C2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_8065214C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806521F8.s") + +s32 func_806522CC(s16 arg0, s16 arg1, s16 arg2) { + if (chunk_array_pointer[arg2].unk1 == 0) { + return FALSE; + } + if ((arg0 >= chunk_array_pointer[arg2].deload1) + && (arg1 >= chunk_array_pointer[arg2].deload2) + && (chunk_array_pointer[arg2].deload3 >= arg0) + && (chunk_array_pointer[arg2].deload4 >= arg1)) { + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80652374.s") + +void func_806524A0(s32 arg0, u8 arg1) { + u8 sp4F; + s32 i; + + sp4F = 0; + // TODO: While loop better for this? Multi condition in for loop is odd + for (i = 0; i < D_807F6C28 && !sp4F; i++) { + func_806307CC(chunk_array_pointer[i].unk14, arg0, 0, arg1, &sp4F); + if (sp4F == 0) { + func_806307CC(chunk_array_pointer[i].unk1C, arg0, 0, arg1, &sp4F); + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80652594.s") + +Chunk14 *func_80630588(Chunk14*, s32, s32, u8*); + +/* +// TODO: Quite close +// Something to do with arg2? Loop condition? Break? +u8 func_80652594(s32 arg0, s16 *arg1, u8 arg2) { + u8 sp4F; + s16 i; + s32 pad; + + sp4F = 0; + i = 0; + while (i < D_807F6C28 && !sp4F && arg2) { + chunk_array_pointer[i].unk14 = func_80630588(chunk_array_pointer[i].unk14, arg0, 0, &sp4F); + if (sp4F) { + *arg1 = i; + } + if (!sp4F || arg2) { + chunk_array_pointer[i].unk1C = func_80630588(chunk_array_pointer[i].unk1C, arg0, 0, &sp4F); + if (sp4F) { + *arg1 = i; + } + } + i++; + } + return sp4F; +} +*/ + +void func_806526E0(u8 arg0) { + s32 i; + + for (i = 0; i < D_807F6C28; i++) { + if ((chunk_array_pointer[i].loaded == 1) || (arg0 != 0)) { + func_806307AC(chunk_array_pointer[i].unk14); + func_806307AC(chunk_array_pointer[i].unk1C); + } + } +} + +void func_80652790(u8 arg0) { + s32 i; + + for (i = 0; i < D_807F6C28; i++) { + if (chunk_array_pointer[i].loaded == 1 || (arg0 != 0)) { + chunk_array_pointer[i].unk14 = func_8063070C(chunk_array_pointer[i].unk14); + chunk_array_pointer[i].unk1C = func_8063070C(chunk_array_pointer[i].unk1C); + } + } +} + +void func_80652858(f32 arg0, f32 arg1, f32 arg2, u8 arg3) { + s32 i; + + for (i = 0; i < D_807F6C28; i++) { + if (chunk_array_pointer[i].loaded == 1 || (arg3 != 0)) { + chunk_array_pointer[i].unk14 = func_80630890(chunk_array_pointer[i].unk14, arg0, arg1, arg2, &chunk_array_pointer[i].unk18); + chunk_array_pointer[i].unk1C = func_80630890(chunk_array_pointer[i].unk1C, arg0, arg1, arg2, &chunk_array_pointer[i].unk20); + } + } +} + +void func_8065297C(void) { + s32 i; + + for (i = 0; i < D_807F6C28; i++) { + func_806323C0(chunk_array_pointer[i].unk14); + func_806323C0(chunk_array_pointer[i].unk1C); + } +} + +void func_80652A08(f32 arg0, f32 arg1, f32 arg2, u8 arg3) { + s32 i; + + for (i = 0; i < D_807F6C28; i++) { + if (chunk_array_pointer[i].loaded == 1 || (arg3 != 0)) { + if (chunk_array_pointer[i].unk6 != 0) { + chunk_array_pointer[i].unk24 = 0; + } else { + chunk_array_pointer[i].unk24 = func_8063A38C(chunk_array_pointer[i].unk14, chunk_array_pointer[i].unk1C, arg0, arg1, arg2); + } + } + } +} + +void func_80652B04(void) { + s32 i; + u8 phi_s2; + Chunk14 *current; + Chunk14 *next; + + D_807F7140 = 0; + for (i = 0; i < D_807F6C28; i++) { + phi_s2 = chunk_array_pointer[i].unk1 != 0 ? TRUE : FALSE; + current = chunk_array_pointer[i].unk14; + while (current) { + next = current->next; + func_8063B4C0(current, phi_s2); + current = next; + } + } +} + +u8 func_80652BC8(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4) { + Chunk14 *phi_s0; + s16 temp_f8; + s16 temp_f16; + u8 phi_s1; + u8 sp6E; + s32 i; + + phi_s1 = 0; + sp6E = func_80630324(1, 0); + temp_f8 = arg1 * 6.0f; + temp_f16 = arg2 * 6.0f; + for (i = 0; i < D_807F6C28; i++) { + if (temp_f8 >= (chunk_array_pointer[i].unk80 - 50)) { + if ((temp_f16 >= (chunk_array_pointer[i].unk82 - 50)) && ((chunk_array_pointer[i].unk84 + 50) >= temp_f8) && ((chunk_array_pointer[i].unk86 + 50) >= temp_f16)) { + switch (sp6E) { + case 0: + phi_s0 = chunk_array_pointer[i].unk14; + break; + case 1: + phi_s0 = chunk_array_pointer[i].unk1C; + break; + } + while (phi_s0) { + if (phi_s0->unk24 == 1) { + phi_s1 |= func_80668E9C(arg0, phi_s0->unk1E, arg1, arg2, arg3, arg4); + } + phi_s0 = phi_s0->next; + } + } + } + } + return phi_s1; +} + +// Doable, but surprisingly fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80652DB4.s") + +u8 func_80652E58(s16 arg0) { + if (D_807F6C28 == 0) { + return 0xFF; + } + return chunk_array_pointer[arg0].unk1 ? TRUE : FALSE; +} + +u8 func_80652EBC(s16 arg0) { + if (D_807F6C28 == 0) { + return 0xFF; + } + return chunk_array_pointer[arg0].loaded == 1 ? TRUE : FALSE; +} + +u8 func_80652F24(s16 arg0, s16 arg1) { + if (D_807F6C28 == 0) { + return TRUE; + } + return (chunk_array_pointer[arg1].unk1 & (1 << arg0)) ? TRUE : FALSE; +} + +s16 func_80652F9C(f32 arg0, f32 arg1, f32 arg2, s16 arg3) { + s16 sp26; + func_80652FDC(arg0, arg1, arg2, arg3, -1, &sp26); + return sp26; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80652FDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806531B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806533C4.s") + +/* +// TODO: Stupidly close, v0/v1 mixup in the final return +s32 func_806533C4(f32 arg0, f32 arg1, f32 arg2) { + s32 phi_v0; + s32 phi_v1; + f32 phi_f0; + f32 phi_f2; + + if (arg0 <= arg2) { + phi_v0 = TRUE; + } else { + phi_v0 = (arg0 - arg2) < 60.0f ? TRUE : FALSE; + } + if (arg1 <= arg2) { + phi_v1 = TRUE; + } else { + phi_v1 = (arg1 - arg2) < 60.0f ? TRUE : FALSE; + } + if (!phi_v0 && !phi_v1) { + return FALSE; + } + if (!phi_v1) { + return FALSE; + } + if (!phi_v0) { + return TRUE; + } + phi_f0 = (arg2 < arg0) ? arg0 - arg2 : arg2 - arg0; + phi_f2 = (arg2 < arg1) ? arg1 - arg2 : arg2 - arg1; + return phi_f0 < phi_f2 ? FALSE : TRUE; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806534E0.s") + +s32 func_80653684(Chunk78_7C*, f32, f32); +s32 func_80653804(Chunk78_7C*, f32, f32); + +/* +// TODO: Very close +s32 func_806534E0(f32 arg0, f32 arg1, f32 arg2, s16 chunkIndex, s8 *arg4, f32 *arg5) { + Chunk* chunk = &chunk_array_pointer[chunkIndex]; + Chunk78_7C *phi_s0; + + if (arg0 < chunk->unk80) { + return FALSE; + } + if (arg2 < chunk->unk82) { + return FALSE; + } + if (chunk->unk84 < arg0) { + return FALSE; + } + if (chunk->unk86 < arg2) { + return FALSE; + } + phi_s0 = chunk->unk78; + while (phi_s0 != chunk->unk7C) { + if (func_80653684(phi_s0, arg0, arg2) && func_80653804(phi_s0, arg0, arg2)) { + if (phi_s0->unk12 & 1) { + *arg4 = 0; + } else { + *arg4 = 1; + *arg5 = phi_s0->unk6; + } + return TRUE; + } + phi_s0++; + } + return FALSE; +} +*/ + +// TODO: Can this be cleaned up any more? +s32 func_80653684(Chunk78_7C *arg0, f32 arg1, f32 arg2) { + f32 phi_f0; + + phi_f0 = MIN(arg0->unk0, arg0->unk2); + if (!(phi_f0 < arg0->unk4)) { + phi_f0 = arg0->unk4; + } + if (arg1 < phi_f0) { + return FALSE; + } + phi_f0 = MIN(arg0->unkC, arg0->unkE); + if (!(phi_f0 < arg0->unk10)) { + phi_f0 = arg0->unk10; + } + if (arg2 < phi_f0) { + return FALSE; + } + phi_f0 = MAX(arg0->unk0, arg0->unk2); + if (!(arg0->unk4 < phi_f0)) { + phi_f0 = arg0->unk4; + } + if (phi_f0 < arg1) { + return FALSE; + } + phi_f0 = MAX(arg0->unkC, arg0->unkE); + if (!(arg0->unk10 < phi_f0)) { + phi_f0 = arg0->unk10; + } + if (phi_f0 < arg2) { + return FALSE; + } + return TRUE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80653804.s") + +/* +// TODO: WIP, needs a lot of TLC +s32 func_80653804(Chunk78_7C *arg0, f32 arg1, f32 arg2) { + f64 spA0; + f64 sp98; + f64 sp90; + f64 sp88; + f64 temp_f12; + f64 temp_f14; + f64 temp_f22; + f64 temp_f24; + s32 temp_t2; + s32 phi_t2; + f64 phi_f2; + f64 phi_f0; + f64 phi_f20; + s32 phi_a0; + s32 phi_t3; + f64 phi_f18; + f64 phi_f16; + f64 phi_f14; + f64 phi_f12; + s32 phi_v1; + + temp_f22 = (arg0->unk0 + ((arg0->unk4 + arg0->unk2) * 0.5)) * 0.5; + temp_f24 = (arg0->unkC + ((arg0->unk10 + arg0->unkE) * 0.5)) * 0.5; + phi_t2 = 0; + phi_v1 = 0; + do { + switch (phi_t2) { + default: + phi_f2 = (arg2 - phi_f18) * phi_f12; + phi_f0 = (arg1 - phi_f16) * phi_f14; + phi_f20 = ((temp_f22 - phi_f16) * phi_f14) - ((temp_f24 - phi_f18) * phi_f12); + break; + case 0: + temp_f14 = arg0->unkE - arg0->unkC; + temp_f12 = arg0->unk2 - arg0->unk0; + phi_f2 = (arg2 - arg0->unkC) * temp_f12; + phi_f0 = (arg1 - arg0->unk0) * temp_f14; + phi_f20 = ((temp_f22 - arg0->unk0) * temp_f14) - ((temp_f24 - arg0->unkC) * temp_f12); + phi_f18 = arg0->unkC; + phi_f16 = arg0->unk0; + phi_f14 = temp_f14; + phi_f12 = temp_f12; + break; + case 1: + temp_f14 = arg0->unk10 - arg0->unkC; + temp_f12 = arg0->unk4 - arg0->unk0; + phi_f2 = (arg2 - arg0->unkC) * temp_f12; + phi_f0 = (arg1 - arg0->unk0) * temp_f14; + phi_f20 = ((temp_f22 - arg0->unk0) * temp_f14) - ((temp_f24 - arg0->unkC) * temp_f12); + phi_f18 = arg0->unkC; + phi_f16 = arg0->unk0; + phi_f14 = temp_f14; + phi_f12 = temp_f12; + break; + case 2: + temp_f12 = arg0->unk4 - arg0->unk2; + temp_f14 = arg0->unk10 - arg0->unkE; + phi_f2 = (arg2 - arg0->unkE) * temp_f12; + phi_f0 = (arg1 - arg0->unk2) * temp_f14; + phi_f20 = ((temp_f22 - arg0->unk2) * temp_f14) - ((temp_f24 - arg0->unkE) * temp_f12); + phi_f18 = arg0->unkE; + phi_f16 = arg0->unk2; + phi_f14 = temp_f14; + phi_f12 = temp_f12; + break; + } + temp_t2 = phi_t2 + 1; + phi_t2 = temp_t2; + phi_t3 = -1; + if (phi_f2 <= phi_f0) { + phi_t3 = 1; + } + phi_a0 = -1; + if (phi_f20 >= 0.0) { + phi_a0 = 1; + } + if (phi_a0 != phi_t3) { + phi_v1 = 1; + } + } while (temp_t2 != 3); + return (phi_v1 == 0) & 0xFF; +} +*/ + +void func_80653A70(s16 chunkIndex) { + chunk_array_pointer[chunkIndex].loaded = 1; + chunk_array_pointer[chunkIndex].unk1 |= 1 << cc_player_index; + chunk_array_pointer[chunkIndex].deload1 = character_change_array[cc_player_index].unk270; + chunk_array_pointer[chunkIndex].deload2 = character_change_array[cc_player_index].unk272; + chunk_array_pointer[chunkIndex].deload3 = character_change_array[cc_player_index].unk274; + chunk_array_pointer[chunkIndex].deload4 = character_change_array[cc_player_index].unk276; +} + +void func_80653B70(u8 arg0) { + D_807F70AB = arg0; +} + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80653B80.s") + +// Loops over a DL and replaces texture indices with RDRAM pointers for G_SETTIMG commands +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80653DF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80653EA8.s") + +void func_80653F68(s16 index) { + chunk_array_pointer[index].unk7 |= 8; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80653FA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654380.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654418.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806545D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806547A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654A2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654BC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654CCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654E84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80654FEC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80655258.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80655410.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80655AD0.s") + +void func_80655BF0(void) { + Chunk14 *current; + + if (func_80652E58(D_807F70AA) == 0) { + current = chunk_array_pointer[D_807F70AA].unk14; + while (current) { + func_80636164(current->unk0, current->unk24); + func_80636210(current->unk0, current->unk24); + current = current->next; + } + current = chunk_array_pointer[D_807F70AA].unk1C; + while (current) { + func_80636164(current->unk0, current->unk24); + func_80636210(current->unk0, current->unk24); + current = current->next; + } + } + D_807F70AA++; + if (D_807F6C28 == (D_807F70AA)) { + D_807F70AA = 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80655CF8.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80655DD0.s") + +// Displaylist stuff, chunks +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80656B98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80656E58.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80656F14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806574B8.s") + +extern u8 D_807F7060[]; +extern u8 D_807F7070; + +// TODO: Close +/* +s32 func_806574B8(s32 arg0) { + s32 i; + + for (i = 0; i < D_807F7070; i++) { + if (D_807F7060[i] == arg0) { + return 0; + } + } + return 1; +} +*/ + +void func_80657508(s32 arg0) { + s32 i; + + for (i = 0; i < D_807F6C08; i++) { + if (D_807F6BF0[i] == arg0) { + return; + } + } + if (i != 0xC) { + D_807F6BF0[D_807F6C08] = arg0; + D_807F6C08++; + } +} + +void func_8065756C(s16 arg0) { + s32 i; + + for (i = 0; i < D_807F6C80; i++) { + if (D_807F6C58[i] == arg0) { + return; + } + } + D_807F6C58[D_807F6C80++] = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806575D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_8065776C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80657974.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80657CB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80657E24.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80657F14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658000.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658134.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_806582F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_8065850C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658624.s") + +void func_806588E0(s32 fileIndex) { + void *file = getPointerTableFile(0x14, fileIndex, 1, 1); + func_80658930(file); + if (file) { + func_8066B434(file, 0xBED, 0x22); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658B08.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658BD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658C10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658CCC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658DAC.s") + +void func_80658E58(u16 arg0, u16 arg1, u16 arg2, u16 arg3) { + D_807F7358 = arg0; + D_807F735A = arg1; + D_807F735C = arg2; + D_807F735E = arg3; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_55B20/func_80658E8C.s") diff --git a/src/global_asm/code_5650.c b/src/global_asm/code_5650.c new file mode 100644 index 00000000..3a643a34 --- /dev/null +++ b/src/global_asm/code_5650.c @@ -0,0 +1,27 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_807452A0; + +void func_80600950(void) { + D_807452A0 = 0; +} + +s32 func_8060095C(s32 arg0, s32 *arg1, s32 *arg2) { + *arg1 += 0x50505050; + *arg2 += 0x50505050; + return arg0 + 0x3FFF00FF; +} + +// malloc, small struct? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5650/func_8060098C.s") + +// small struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5650/func_80600B10.s") + +// similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5650/func_80600BBC.s") + +// similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5650/func_80600C68.s") diff --git a/src/global_asm/code_5A50.c b/src/global_asm/code_5A50.c new file mode 100644 index 00000000..eff3f5b9 --- /dev/null +++ b/src/global_asm/code_5A50.c @@ -0,0 +1,170 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_8000DDCC; +extern s32 D_8076D200; + +s32 func_80737E30(GlobalASMStruct20*, u8); +void func_80737E50(GlobalASMStruct20*); +void func_80737F0C(s32, s32, u8); +void func_80738080(s32, u8, u8); +void func_807380CC(GlobalASMStruct20*, s32, u8); +void func_80738118(s32, s32, u8); +void func_807382A0(s32, u8, u8, u8, u8); +void func_80738400(s32, u8, u8, u8, s32); +void func_807381D8(s32, f32, f32); +void func_8060B140(s32, s32*, s32*, s32, s32, s32, s32); + +// Struct on the stack? Big malloc +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5A50/func_80600D50.s") + +void func_806010A0(void) { + s32 sp34, sp30, sp2C; + + sp34 = 0x80; + func_8060B140(D_8000DDCC, &D_8076D200, &sp34, 0, 0, 0, 0); + sp30 = 0x2C0; + sp2C = D_8076D200; + func_8060B140(D_8000DDCC + sp2C, &D_8076D200, &sp30, 0, 0, 0, 0); +} + +void func_80601120(u8 arg0) { + if (func_80737E30(D_8076BF20[arg0], arg0) == 0) { + func_80737E50(D_8076BF20[arg0]); + } +} + +void func_8060116C(u8 arg0) { + func_80737E30(D_8076BF20[arg0], arg0); +} + +void func_806011A0(u8 arg0, s32 arg1) { + func_80737E90(D_8076BF20[arg0], arg1, arg0); +} + +void func_806011D4(s32 arg0, s32 arg1, s32 arg2) { + +} + +void func_806011E4(u8 arg0, s32 arg1, u8 arg2) { + func_80737F0C(D_8076BF20[arg0], arg1, arg2); +} + +void func_80601224(u8 arg0, s32 arg1) { + func_80737FD8(D_8076BF20[arg0], arg1, arg0); +} + +void func_80601258(u8 arg0, s32 arg1) { + func_8073801C(D_8076BF20[arg0], arg1, arg0); +} + +void func_8060128C(u8 arg0, s32 arg1, u8 arg2) { + func_80738080(D_8076BF20[arg0], arg1, arg2); +} + +void func_806012D4(u8 arg0, u8 arg1, u8 arg2) { + func_807380CC(D_8076BF20[arg0], arg1, arg2); +} + +void func_8060131C(u8 arg0, s32 arg1, u8 arg2) { + s32 i; + for (i = 0; i < 0x10; i++) { + if ((1 << i) & arg1) { + func_8060128C(arg0, i & 0xFF, arg2); + } + } +} + +void func_806013A0(u8 arg0, u8 arg1, u8 arg2) { + func_80738118(D_8076BF20[arg0], arg1, arg2); +} + +void func_806013E8(u8 arg0, s32 arg1, u8 arg2) { + s32 i; + for (i = 0; i < 0x10; i++) { + if ((1 << i) & arg1) { + func_80738118(D_8076BF20[arg0], i, arg2); + } + } +} + +void func_80601484(u8 arg0, s32 arg1, s32 arg2) { + s32 i; + for (i = 0; i < 0x10; i++) { + if ((1 << i) & arg1) { + if (arg2 != 0) { + func_80601258(arg0, i); + } else { + func_80601224(arg0, i); + } + } + } +} + +void func_8060151C(u8 arg0, s32 arg1, s32 arg2) { + s32 i; + for (i = 0; i < 0x10; i++) { + if ((1 << i) & arg1) { + if (arg2 != 0) { + D_8076BF20[arg0]->unk30 |= arg1; + } else { + D_8076BF20[arg0]->unk30 &= (arg1 ^ 0xFFFF); + } + } + } +} + +// TODO: Double check datatypes, it's fine for now though +void func_806015E0(u8 arg0, s32 arg1, s32 arg2) { + s32 i; + for (i = 0; i < 0x10; i++) { + if ((1 << i) & arg1) { + func_80738230(D_8076BF20[arg0], i & 0xFF, arg2 & 0xFF); + } + } +} + +void func_80601678(u8 arg0, u8 arg1, u8 arg2) { + func_807382A0(D_8076BF20[arg0], 0, arg1 | 0xB0, 0x21, arg2); +} + +void func_806016D0(u8 arg0, u8 arg1, u8 arg2) { + func_807382A0(D_8076BF20[arg0], 0, arg1 | 0xB0, 0x22, arg2); +} + +void func_80601728(u8 arg0, u8 arg1, u8 arg2) { + func_807382A0(D_8076BF20[arg0], 0, arg1 | 0xB0, 0x23, arg2); +} + +void func_80601780(u8 arg0, s32 arg1) { + func_80738320(D_8076BF20[arg0], arg1, arg0); +} + +void func_806017B4(u8 arg0) { + func_807383B0(D_8076BF20[arg0], arg0); +} + +void func_806017E8(u8 arg0, u8 arg1, u8 arg2, u8 arg3, s32 arg4) { + func_80738400(D_8076BF20[arg0], arg1, arg2, arg3, arg4); +} + +void func_80601848(u8 arg0, f32 arg1, f32 arg2) { + func_807381D8(D_8076BF20[arg0], arg1, arg2); +} + +void func_8060188C(u8 arg0, s32 arg1) { + D_8076BF20[arg0]->unk28 += arg1; +} + +s32 func_806018B4(u8 arg0) { + return D_8076BF20[arg0]->unk1C; +} + +// Struct size 0xF8, 0x3B0 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5A50/func_806018D4.s") + +// Struct size 0xF8, 0x3B0, 0xEC +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5A50/func_8060193C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5A50/func_806019B8.s") diff --git a/src/global_asm/code_5DE10.c b/src/global_asm/code_5DE10.c new file mode 100644 index 00000000..7ea25fec --- /dev/null +++ b/src/global_asm/code_5DE10.c @@ -0,0 +1,37 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_807F7360; +extern u8 D_807F7361; +extern u8 D_807F7362; +extern u8 D_807F7363; +extern u8 D_807F7364; +extern u16 D_807F7366; +extern u16 D_807F7368; + +void func_80659110(u8 arg0) { + D_807F7360 = arg0; + if (current_map == MAP_AZTEC) { + D_807F7361 = 0x8A; + D_807F7362 = 0x52; + D_807F7363 = 0x16; + } else { + D_807F7361 = 0; + D_807F7362 = 0; + D_807F7363 = 0; + } + D_807F7364 = 0; + D_807F7366 = 990; + D_807F7368 = 999; +} + +u8 func_80659190(void) { + return D_807F7360; +} + +//display list stuff? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5DE10/func_8065919C.s") + +//display list stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5DE10/func_806592B4.s") diff --git a/src/global_asm/code_5E020.c b/src/global_asm/code_5E020.c new file mode 100644 index 00000000..eaf42394 --- /dev/null +++ b/src/global_asm/code_5E020.c @@ -0,0 +1,111 @@ +#include +#include "functions.h" +#include "variables.h" + +typedef struct global_asm_struct_78 GlobalASMStruct78; + +struct global_asm_struct_78 { + s32 unk0; + s32 unk4; + GlobalASMStruct78 *unk8; // Linked list? +}; + +extern GlobalASMStruct78 *D_807F7370[]; + +void func_80659320(void) { + s32 i; + + for (i = 0; i < 100; i++) { + D_807F7370[i] = NULL; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E020/func_80659350.s") + +/* +// TODO: Pretty close +void func_80659350(void) { + s32 i; + GlobalASMStruct78 *temp; + + for (i = 0; i < 100; i++) { + temp = D_807F7370[i]; + while (temp->unk8) { + func_8061130C(temp->unk8); + // temp = temp->unk8; + } + } + func_80659320(); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E020/func_806593C8.s") + +/* +// TODO: Quite close +void func_806593C8(s32 arg0, s32 arg1) { + GlobalASMStruct78 *temp_v0; + GlobalASMStruct78 *temp_v1; + + temp_v1 = D_807F7370[func_80659544(arg0)]; + while (temp_v1 && arg0 != temp_v1->unk0) { + temp_v1 = temp_v1->unk8; + } + + if (!temp_v1) { + temp_v0 = malloc(0xC); + temp_v1->unk8 = temp_v0; + temp_v0->unk0 = arg0; + temp_v0->unk4 = arg1; + temp_v0->unk8 = NULL; + } else { + temp_v1->unk4 = arg1; + } +} +*/ + +// Returns an index into object model2 array +s32 func_80659470(s32 arg0) { + GlobalASMStruct78 *phi_v1; + + phi_v1 = D_807F7370[func_80659544(arg0)]; + while (phi_v1) { + if (arg0 == phi_v1->unk0) { + return phi_v1->unk4; + } + phi_v1 = phi_v1->unk8; + } + return -1; +} + +void func_806594C8(s32 arg0) { + // TODO: Clean up these temp variables + // Probably don't need so much indirection + GlobalASMStruct78 **temp_v1; + GlobalASMStruct78 *phi_a0; + GlobalASMStruct78 **phi_v1; + + temp_v1 = &D_807F7370[func_80659544(arg0)]; + phi_a0 = *temp_v1; + phi_v1 = temp_v1; + while (phi_a0 && arg0 != phi_a0->unk0) { + phi_v1 = &phi_a0->unk8; + phi_a0 = phi_a0->unk8; + } + if (phi_a0) { + *phi_v1 = phi_a0->unk8; + func_8061130C(phi_a0, arg0); + } +} + +s32 func_80659544(s32 arg0) { + // Yes the ternary is required + // ABS macro doesn't match + return (arg0 > 0 ? arg0 : -arg0) % 100; +} + +// Doable, for loop i < 100, weird indirection though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E020/func_80659574.s") + +// Similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E020/func_806595B0.s") diff --git a/src/global_asm/code_5E2F0.c b/src/global_asm/code_5E2F0.c new file mode 100644 index 00000000..7a9270c2 --- /dev/null +++ b/src/global_asm/code_5E2F0.c @@ -0,0 +1,165 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u16 D_80748300; + +extern f32 D_80758CA0; +extern f32 D_80758CA4; +extern f32 D_80758CA8; +extern f32 D_80758CAC; + +extern f32 *D_8076A0B4; +extern f32 *D_8076A0B8; +extern f32 *D_8076A0BC; + +extern u16 D_807F7EC8; + +extern u8 D_807F7EF8; +extern f32 D_807F7ECC; +extern f32 D_807F7ED0; +extern f32 D_807F7ED4; +extern f32 D_807F7ED8; +extern f32 D_807F7EDC; +extern f32 D_807F7EE0; +extern f32 D_807F7EE4; +extern f32 D_807F7EE8; +extern s16 D_807F7EFA; +extern u16 D_807F7EFC; +extern u16 D_807F7EFE; + +f32 func_80612D10(f32); + +void func_806595F0(u8 arg0) { + D_807F7EF8 = arg0; +} + +void func_80659600(u16 arg0) { + D_807F7EFA = arg0; +} + +void func_80659610(u16 arg0) { + D_807F7EFC = arg0; +} + +void func_80659620(f32 *arg0, f32 *arg1, f32 *arg2, s16 arg3) { + *arg0 = D_8076A0B4[arg3]; + *arg1 = D_8076A0B8[arg3]; + *arg2 = D_8076A0BC[arg3]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_80659670.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065996C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_80659DB0.s") + +/* +extern f32 *D_8076A0C0; // pointer to an array of floats +extern f32 *D_8076A0C4; +extern f32 *D_8076A0C8; +extern s32 D_807F6C28; + +// TODO: MIN/MAX macros? +void func_80659DB0(f32 arg0, f32 arg1, f32 arg2, s16 arg3) { + u8 phi_v1; + s32 iChunk; + + if (D_807F6C28 <= 0) { + phi_v1 = 1; + } else { + phi_v1 = D_807F6C28; + } + iChunk = 0; + if (arg3 == -1) { + if (phi_v1 != 0) { + do { + if (arg0 <= 1.0f) { + D_8076A0C0[iChunk] = arg0; + } else { + D_8076A0C0[iChunk] = 1.0f; + } + iChunk++; + if (arg1 <= 1.0f) { + D_8076A0C4[iChunk] = arg1; + } else { + D_8076A0C4[iChunk] = 1.0f; + } + if (arg2 <= 1.0f) { + D_8076A0C8[iChunk] = arg2; + } else { + D_8076A0C8[iChunk] = 1.0f; + } + } while (iChunk < phi_v1); + } + } else { + if (arg0 <= 1.0f) { + D_8076A0C0[arg3] = arg0; + } else { + D_8076A0C0[arg3] = 1.0f; + } + if (arg1 <= 1.0f) { + D_8076A0C4[arg3] = arg1; + } else { + D_8076A0C4[arg3] = 1.0f; + } + if (arg2 <= 1.0f) { + D_8076A0C8[arg3] = arg2; + } else { + D_8076A0C8[arg3] = 1.0f; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_80659F7C.s") + +void func_8065A570(void) { + D_807F7ECC = func_80612D10(D_80758CA0); + D_807F7ED0 = func_80612D10(D_80758CA4); + D_807F7ED4 = 1.0f / (D_807F7ECC - D_807F7ED0); + D_807F7ED8 = D_807F7ECC; + D_807F7EDC = D_807F7ED0; + D_807F7EE0 = D_807F7ED4; + D_807F7EE4 = 25.0f; + D_807F7EE8 = 65.0f; + D_80748300 = 0; + D_807F7EF8 = 0; + D_807F7EFA = -1; + D_807F7EFC = 700; + D_807F7EFE = 600; +} + +void func_8065A648(void) { + D_80748300 = 0; +} + +void func_8065A654(void) { + D_807F7EC8 = 0; +} + +void func_8065A660(f32 arg0, f32 arg1) { + D_807F7EE4 = arg0; + D_807F7EE8 = arg1; + D_807F7ED8 = func_80612D10(arg0 * D_80758CA8); + D_807F7EDC = func_80612D10(arg1 * D_80758CAC); + D_807F7EE0 = 1.0f / (D_807F7ED8 - D_807F7EDC); +} + +void func_8065A6F8(u16 arg0) { + D_807F7EFE = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065A708.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065A884.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065BAA0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065BE74.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065BF18.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065C240.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_5E2F0/func_8065C334.s") diff --git a/src/global_asm/code_61690.c b/src/global_asm/code_61690.c new file mode 100644 index 00000000..740cd27e --- /dev/null +++ b/src/global_asm/code_61690.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61690/func_8065C990.s") diff --git a/src/global_asm/code_61AA0.c b/src/global_asm/code_61AA0.c new file mode 100644 index 00000000..caeadd2b --- /dev/null +++ b/src/global_asm/code_61AA0.c @@ -0,0 +1,193 @@ +#include +#include "functions.h" +#include "variables.h" + +extern f32 D_807F5FDC; +extern f32 D_807F5FE0; + +extern f32 D_807F6940; + +extern u8 D_807F7F00; + +extern f64 D_80758D60; +extern f64 D_80758D68; +extern u16 D_807F8E8A; +extern s32 D_807F8E90; +extern s32 D_807F8E9C; +extern s32 D_807F8EA8; +extern s32 D_807F8EB4; +extern s32 D_807F8EC0[]; // size 100 +extern s32 D_807F9050; +extern s32 D_807F9054; +extern u16 D_807F9058; +extern u16 D_807F905A; +extern s32 D_807F905C; +extern s16 D_807F9060; +extern u32 D_807F9064; +extern s32 D_807F9068; + +s32 func_8065E0CC(void); +s32 func_8065E81C(s32, s32); + +void func_8065CDA0(u8 arg0) { + D_807F7F00 = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065CDB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065CE4C.s") + +f32 func_8065CFB8(s16, f32); +f32 func_8065D0FC(f32); + +/* +// TODO: Quite close, annoying float nonsense +void func_8065CE4C(f32 arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s16 *arg5) { + f32 dx, dy, dz; + f32 phi_f14; + + dx = arg0 - character_change_array[cc_player_index].unk21C; + dy = arg1 - character_change_array[cc_player_index].unk220; + dz = arg2 - character_change_array[cc_player_index].unk224; + phi_f14 = sqrtf((dx * dx) + (dy * dy) + (dz * dz)); + if (current_map == MAP_AZTEC) { + arg3 = func_8065CFB8(arg4, arg3); + if (arg3 < phi_f14) { + *arg5 = 0; + return; + } + } + dy = func_8065D0FC(arg3); + dx = (dy * 3.0f) / 4; + if (phi_f14 < dx) { + *arg5 = 0xFF; + return; + } + *arg5 = ((phi_f14 - dx) / (dy - dx)) * 255.0f; + if (*arg5 >= 0x100) { + *arg5 = 0xFF; + } + *arg5 = 0xFF - *arg5; +} +*/ + +f32 func_8065CFB8(s16 arg0, f32 arg1) { + if (arg0 == 0xB2 || arg0 == 0x253) { + arg1 += (D_80758D60 - arg1) * D_807F6940; + } + return arg1; +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065D008.s") + +f32 func_8065D0FC(f32 arg0) { + if (D_80758D68 == character_change_array[cc_player_index].fov_y) { + return arg0; + } + return (arg0 / D_807F5FDC) * D_807F5FE0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065D170.s") + +/* +// TODO: No idea why this doesn't match, possibly a struct or array using temp registers? +void func_8065D170(void) { + D_807F8E90 = -1; + D_807F8E9C = -1; + D_807F8EA8 = -1; + D_807F8EB4 = -1; + D_807F8E8A = 0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065D1AC.s") + +void func_8065D244(u16 arg0) { + D_807F8E8A = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065D254.s") + +typedef struct { + s16 unk0; + u16 unk2; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; +} GlobalASMStruct66; + +void func_8065D964(GlobalASMStruct66 *arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { + arg0->unk0 = arg1; + arg0->unk2 = 0; + arg0->unk4 = arg2; + arg0->unk8 = arg3 << 5; + arg0->unkA = arg4 << 5; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065D994.s") + +void func_8065E040(s32 arg0) { + s32 i; + for (i = 0; i < 100; i++) { + D_807F8EC0[i] = 0; + } + D_807F9050 = 0; + D_807F9054 = 0; + D_807F905C = 0; + D_807F9060 = 0; + if (func_8065E0CC()) { + D_807F9064 = arg0 + 0x70000; + } else { + D_807F9064 = arg0; + } +} + +s32 func_8065E0CC(void) { + switch (current_map) { + case MAP_JAPES_MINECART: + case MAP_JAPES_ARMY_DILLO: + case MAP_FUNGI_MINECART: + case MAP_FUNGI_DOGADON: + case MAP_CASTLE_MINECART: + case MAP_CAVES_ARMY_DILLO: + case MAP_AZTEC_DOGADON: + return FALSE; + } + return TRUE; +} + +void func_8065E124(void) { + D_807F9058 = 0; + D_807F905A = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065E138.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065E634.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_61AA0/func_8065E81C.s") + +s32 func_8065EA44(void) { + D_807F9064 = (D_807F9064 * 3) >> 2; + if (D_807F9064 < 0x10000) { + return 0; + } + return func_8065E81C(1, 0); +} + +s32 func_8065EA98(s32 arg0, s16 arg1, u8 arg2) { + return ((arg1 * 0x10) + (arg0 * 4) + arg2) % 100; +} + +void func_8065EACC() { + if (D_807F9064 != 40000) { + D_807F9068 = D_807F9064; + } + D_807F9064 = 40000; +} + +void func_8065EAF4() { + D_807F9064 = D_807F9068; +} \ No newline at end of file diff --git a/src/global_asm/code_63810.c b/src/global_asm/code_63810.c new file mode 100644 index 00000000..5aa2fd5a --- /dev/null +++ b/src/global_asm/code_63810.c @@ -0,0 +1,65 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63810/func_8065EB10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63810/func_8065EFF0.s") + +typedef struct { + s32 unk0; + f32 unk4; + f32 unk8; + s32 unkC; + s16 unk10; + s16 unk12; + s16 unk14; + u8 unk16; + u8 unk17; + u8 unk18; + u8 unk19; + s16 unk1A; +} GlobalASMStruct51; + +void func_80659600(s16); +void func_80659610(s16); +void func_8065A708(f32, f32, s32, f32, f32, f32, f32, s32, s32, s32, s32); +extern s32 D_807FBB68; +extern s16 D_80748A84; +extern GlobalASMStruct51 D_807F9070[]; + +/* +void func_8065EFF0(void) { + s32 i; + + // TODO: Proper bitfield syntax + if ((current_map == MAP_FUNGI) && ((player_pointer->PaaD->unk1F0 << 0xB) >= 0)) { + + } else if (!(global_properties_bitfield & 2)) { + for (i = 0; i < D_80748A84; i++) { + if (!(D_807FBB68 & 4)) { + func_806595F0(2); + } + func_80659600(D_807F9070[i].unk12); + func_80659610(D_807F9070[i].unk14); + func_8065A708( + D_807F9070[i].unk4, + D_807F9070[i].unk8, + D_807F9070[i].unkC, + 0.0f, + 0.0f, + 0.0f, + D_807F9070[i].unk10, + 0, + D_807F9070[i].unk16, + D_807F9070[i].unk17, + D_807F9070[i].unk18 + ); + } + } + D_80748A84 = 0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63810/func_8065F134.s") diff --git a/src/global_asm/code_63EC0.c b/src/global_asm/code_63EC0.c new file mode 100644 index 00000000..887dbcc1 --- /dev/null +++ b/src/global_asm/code_63EC0.c @@ -0,0 +1,338 @@ +#include +#include "functions.h" +#include "variables.h" + + +typedef struct global_asm_struct_18 { + void* unk0; // Texture pointer usually + void* unk4; + void* unk8; + void* unkC; // Texture pointer usually + void* unk10; // Texture pointer usually + u8 pad8[0x18 - 0x14]; +} GlobalASMStruct18; + +// TODO: Could this just be an array of void*? +// The offsets overlap in weird ways +extern GlobalASMStruct18 D_80748A9C[]; +extern GlobalASMStruct18 D_80748A90[]; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065F1C0.s") + +void func_8065F49C(s32 arg0, f32 arg1, f32 arg2, f32 arg3) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + phi_v0->unk10 = arg1; + phi_v0->unk14 = arg2; + phi_v0->unk18 = arg3; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065F4F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065F5F0.s") + +s32 func_8065F5F0(GlobalASMStruct58 *); +void func_806615BC(void); + +void func_8065F614(void) { + GlobalASMStruct58 *phi_s0 = D_807F93C0; + + while (phi_s0) { + phi_s0->unk4C = 0; + func_8065F4F4(phi_s0); + phi_s0 = phi_s0->next; + } + if (!(global_properties_bitfield & 2)) { + func_806615BC(); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065F678.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065F964.s") + +typedef struct { + s32 unk0[4]; + s32 unk10[4]; + s32 unk20[4]; + s32 unk30[4]; + s32 unk40[4]; + s16 unk50[8]; // Used, not sure if count is correct + s32 unk60; + s16 unk64; + s8 unk66; + u8 unk67; // Used +} GlobalASMStruct81; + +s32 func_8065FB04(GlobalASMStruct81 *arg0) { + s32 i; + + for (i = 0; i < arg0->unk67; i++) { + if (chunk_array_pointer[arg0->unk50[i]].loaded == 1) { + return TRUE; + } + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065FB64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065FD88.s") + +// Displaylist stuff (chunk) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8065FEB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80660070.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80660520.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80660830.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_806608FC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80660D38.s") + +s32 func_8066104C(s32 arg0) { + return ~arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661054.s") + +// Needs definition for D_807F93C0->unk0->unk64 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661264.s") + +void func_806612B4(s32 arg0, u8 arg1) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + phi_v0->unk4A = arg1; + } +} + +u8 func_80661300(s32 arg0) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + return phi_v0->unk4B; + } + return 0; +} + +void func_8066134C(s32 arg0, u8 arg1) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + phi_v0->unk4B = arg1; + } +} + +void func_80661398(s32 arg0, f32 arg1, f32 arg2) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + phi_v0->unk8 = arg1; + phi_v0->unkC = arg2; + } +} + +void func_806613E8(s32 arg0, f32 arg1, f32 arg2) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + phi_v0->unk8 += arg1; + phi_v0->unkC = arg2; + } +} + +void func_80661440(f32 *arg0) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + s32 phi_a1 = 0; + + while (phi_v0 && phi_a1 < 32) { + arg0[phi_a1++] = phi_v0->unk8; + phi_v0 = phi_v0->next; + } +} + +void func_80661484(f32 *arg0) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + s32 phi_a1 = 0; + + while (phi_v0 && phi_a1 < 32) { + phi_v0->unk8 = arg0[phi_a1++]; + phi_v0->unk4 = phi_v0->unk8; + phi_v0 = phi_v0->next; + } +} + +f32 func_806614D0(s32 arg0) { + GlobalASMStruct58 *phi_v0 = D_807F93C0; + + while (phi_v0 && arg0) { + phi_v0 = phi_v0->next; + arg0--; + } + if (phi_v0) { + return phi_v0->unk4; + } + return 0.0f; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661520.s") + +extern u8 D_807F93C4; +extern f32 D_807F93C8; +extern f32 D_807F93CC; +extern f32 D_807F93D0; +extern f32 D_807F93D4; +extern f32 D_807F93D8; +extern f32 D_807F93DC; +extern f32 D_807F93E0; +extern f32 D_807F93E4; +extern f32 D_807F93E8; + +/* +void func_80661520(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5) { + if (D_807F93C4 == 0) { + // TODO: Something up with arg0 arg1 + D_807F93C8 = arg0; + D_807F93CC = arg1; + D_807F93D4 = 0.0f; + D_807F93D0 = arg2; + D_807F93D8 = arg3; + D_807F93DC = 0.0f; + D_807F93E0 = arg4; + D_807F93E4 = arg5; + D_807F93E8 = (arg5 * 2) / 3.0f; + D_807F93C4 = 1; + } +} +*/ + +void func_806615BC(void) { + if (D_807F93C4 != 0) { + D_807F93D4 += D_807F93D8; + if (D_807F93D0 < D_807F93D4) { + D_807F93D4 = D_807F93D0; + } + D_807F93DC += D_807F93E0; + if (D_807F93E4 < D_807F93DC) { + D_807F93C4 = 0; + } + } +} + +void func_8066164C(void) { + D_807F93C4 = 0; +} + +void func_80661658(u8 arg0) { + // Texture (Uncompressed) + D_80748A9C[arg0].unk0 = getPointerTableFile(7, 0x3C5, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_806616A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_806618A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661AB4.s") + +void func_80661B84(u8 arg0) { + // Textures + D_80748A90[arg0].unkC = getPointerTableFile(0x19, 0x2EE, 1, 0); + D_80748A90[arg0].unk10 = getPointerTableFile(0x19, 0x2EF, 1, 0); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661BF0.s") + +// Needs some fiddly struct defintions +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661E34.s") + +void func_80661EC4(u8 arg0) { + // Texture + D_80748A9C[arg0].unk0 = getPointerTableFile(0x19, 0xF0, 1, 0); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80661F0C.s") + +void func_80662108(s32 arg0) { + +} + +void func_80662110(u8 arg0) { + // Texture + D_80748A9C[arg0].unk0 = getPointerTableFile(0x19, 0xAF4, 1, 0); +} + +void func_80661F0C(s32, s32, u8); + +void func_80662158(s32 arg0, s32 arg1, u8 arg2) { + func_80661F0C(arg0, arg1, arg2); +} + +void func_80662180(s32 arg0) { + +} + +void func_80662188(u8 arg0) { + // Texture + D_80748A9C[arg0].unk0 = getPointerTableFile(0x19, 0x75C, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_806621D0.s") + +void func_806623CC(s32 arg0) { + +} + +void func_806623D4(u8 arg0) { + // Texture (Uncompressed) + D_80748A9C[arg0].unk0 = getPointerTableFile(7, 0x3B9, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_8066241C.s") + +void func_806625D0(u8 arg0) { + // Texture (Uncompressed) + D_80748A9C[arg0].unk0 = getPointerTableFile(7, 0x3D2, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80662618.s") + +void func_806627CC(u8 arg0) { + // Texture (Uncompressed) + D_80748A90[arg0].unkC = getPointerTableFile(7, 0x3BA, 1, 0); + D_80748A90[arg0].unk10 = getPointerTableFile(7, 0x3DB, 1, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80662838.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_63EC0/func_80662AB4.s") diff --git a/src/global_asm/code_6710.c b/src/global_asm/code_6710.c new file mode 100644 index 00000000..1b1071a2 --- /dev/null +++ b/src/global_asm/code_6710.c @@ -0,0 +1,252 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s8 D_807452CC; +extern u16 D_80745658[]; +extern u8 D_80745654; +extern f32 D_807457B8[]; +extern s16 D_807458DC[]; // music_track_channels +extern OSThread D_8076D4E8; +extern f32 D_80770578[]; +extern u8 D_80770598[]; + +extern u8 D_80770560[]; +extern f32 D_80770568[]; +extern s16 D_80770628[]; +extern s16 D_80770710[]; +extern f32 D_80770B68[]; +extern f32 D_80770BC0[]; +extern f32 D_80770C18[]; +extern f32 D_80770C70[]; +extern u8 D_80770CE0[]; + +extern s32 func_80737E30(s32, u8); + +u8 func_80602430(s16 arg0); +u8 func_8060245C(s16 arg0); +void func_80602B60(s16 arg0, s32 arg1); +void func_8060A60C(s32 arg0, f32 arg1); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80601A10.s") + +void func_80601CC0(void) { + D_807452CC = TRUE; + osStartThread(&D_8076D4E8); +} + +void func_80601CF0(s32 arg0) { + if (D_807452CC) { + osStopThread(&D_8076D4E8); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80601D24.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80601EE4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602104.s") + +extern s32 D_807454E8; + +/* +void func_80602104(s32 arg0) { + if (((osAiGetLength() >> 2) == 0) && (D_807454E8 == 0)) { + D_807454E8 = 0; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602144.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_806022DC.s") + +/* +void *func_806022DC(void *arg0) { + if (D_80770188.unk0 == 0) { + D_80770188.unk4 = 0; + D_80770188.unk8 = &D_8076FE68; + D_80770188.unk0 = (u8)1U; + } + *arg0 = &D_80770188; + return &func_80602144; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602314.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602430.s") + +u8 func_8060245C(s16 arg0) { + return (D_80745658[arg0] & 0x78) >> 3; +} + +void func_80602488(u8 arg0) { + D_80745654 = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602498.s") + +void func_806025AC(s32 arg0, s32 arg1, s32 arg2) { + func_80602498(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_806025D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/playSong.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602B60.s") + +void func_80602C0C(void) { + u8 i; + for (i = 0; i < 0xC; i++) { + if (D_807458DC[i] != 0) { + func_80602B60(D_807458DC[i], 1); // playMusic()? + } + } +} + +void func_80602C6C(s32 arg0, f32 arg1) { + u8 sp1F; + + sp1F = func_80602430(arg0); + if ((arg0 == D_807458DC[func_8060245C(arg0)]) && (arg0 == D_80770560[sp1F])) { + func_8060A60C(sp1F, arg1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602CE0.s") + +extern s32 D_8074593C[]; + +/* +void func_80602CE0(s32 arg0, s32 arg1, u8 arg2) { + s32 temp_v0; + + temp_v0 = func_8060245C(arg0); + if (arg0 == D_807458DC[temp_v0]) { + D_8074593C[temp_v0 + arg2 * 0xC] = arg1; + } +} +*/ + +f32 func_80602D4C(s32 arg0) { + u8 temp_v0 = func_80602430(arg0); + + if (arg0 == D_80770560[temp_v0]) { + if (func_80737E30(D_8076BF20[temp_v0], temp_v0) == 1) { + return D_80770568[temp_v0]; + } + } + return 0.0f; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602DC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80602E6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80603340.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80603450.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_806049CC.s") + +void func_80604BE8(u8 arg0, f32 arg1, f32 arg2) { + if (arg0 != -1) { + if (arg2 == 0.0f) { + D_80770C18[D_80770628[arg0]] = arg1; + D_80770C70[D_80770628[arg0]] = arg1; + } else { + D_80770B68[D_80770628[arg0]] = arg1; + } + D_80770BC0[D_80770628[arg0]] = arg2; + } +} + +void func_80604C80(u8 arg0, u8 arg1) { + if (arg0 != -1) { + D_80770CE0[D_80770628[arg0]] = arg1; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80604CBC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80604D70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80605044.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80605314.s") + +void func_80605380(s16); + +/* +// TODO: Very close +void func_80605314(Actor *arg0, u8 arg1) { + if (arg0[arg1].unk6E >= 0) { + func_80605380(arg0[arg1].unk6E); + arg0[arg1].unk6E = -1; + if (arg1 == 0) { + arg0->unk72 = 0; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80605380.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80605510.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_806057F8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80608528.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_806085DC.s") + +void func_8060956C(f32, f32, f32, s16, s32, f32, s32, s32); + +void func_8060866C(Actor *arg0, s16 arg1, u8 arg2, f32 arg3, u8 arg4, u8 arg5) { + func_8060956C(arg0->x_position, arg0->y_position, arg0->z_position, arg1, arg2, arg3, arg4, arg5); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_806086CC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80608DA8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/playSound.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_8060956C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_80609B80.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_8060A1B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_8060A398.s") + +void func_8060A4D0(s32 arg0, f32 arg1) { + D_807457B8[arg0] = arg1; + func_8060A398(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_8060A500.s") + +void func_8060A60C(s32 arg0, f32 arg1) { + D_80770578[arg0] = arg1; + D_80770598[arg0] = 1; +} + +void func_8060A634(s32 arg0, f32 arg1) { + D_80770578[arg0] = arg1; + D_80770568[arg0] = arg1; + func_8060A398(arg0); +} + +extern s32 D_80770588; // TODO: f32? + +void func_8060A1B0(s32, u8, s32); + +void func_8060A670(s32 arg0, u8 arg1) { + func_8060A1B0(arg0, arg1, D_80770588); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_6710/func_8060A6A0.s") diff --git a/src/global_asm/code_67890.c b/src/global_asm/code_67890.c new file mode 100644 index 00000000..6529edec --- /dev/null +++ b/src/global_asm/code_67890.c @@ -0,0 +1,36 @@ +#include +#include "functions.h" +#include "variables.h" + +typedef struct { + s32 unk0[4]; + s32 unk10[4]; + s32 unk20[4]; + s32 unk30; + s32 unk34; + s16 unk38; // Used + s16 unk3A; + s32 unk3C; +} GlobalASMStruct89; + +extern GlobalASMStruct89 *D_807F93F0; +extern s32 D_807F93F8; + +// Load map texture, malloc, loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_67890/func_80662B90.s") + +s32 func_80663040(s32 arg0) { + s32 i; + for (i = 0; i < D_807F93F8; i++) { + if (arg0 == D_807F93F0[i].unk38) { + return TRUE; + } + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_67890/func_8066308C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_67890/func_806634A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_67890/func_80663594.s") diff --git a/src/global_asm/code_684C0.c b/src/global_asm/code_684C0.c new file mode 100644 index 00000000..6b3f455a --- /dev/null +++ b/src/global_asm/code_684C0.c @@ -0,0 +1,108 @@ +#include +#include "functions.h" +#include "variables.h" + +typedef struct global_asm_struct_83 GlobalASMStruct83; +struct global_asm_struct_83 { + Actor* unk0; + u32 unk4; + Actor* unk8; + GlobalASMStruct83 *next; +}; + +typedef struct { + s16 min_x; // 0 + s16 min_y; // 2 + s16 min_z; // 4 + s16 max_x; // 6 + s16 max_y; // 8 + s16 max_z; // A + s16 unkC; + u8 unkE; + u8 unkF; +} GlobalASMStruct84; + +typedef struct global_asm_struct_85 GlobalASMStruct85; +struct global_asm_struct_85 { + GlobalASMStruct84* unk0; + GlobalASMStruct83* unk4; + GlobalASMStruct85* next; +}; + +extern GlobalASMStruct85 *D_807F9410; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_684C0/func_806637C0.s") + +s32 func_806639CC(Actor*, GlobalASMStruct83*); +void func_80663A0C(Actor *arg0, GlobalASMStruct84 *arg1); + +void func_80663844(Actor *arg0) { + GlobalASMStruct85 *current; + GlobalASMStruct84 *boundingBox; + GlobalASMStruct83 *current2; + GlobalASMStruct83 *temp_v0_4; + GlobalASMStruct83 **phi_s0; + + current = D_807F9410; + while (current) { + boundingBox = current->unk0; + if (boundingBox->min_x <= arg0->x_position + && boundingBox->min_y <= arg0->y_position + && boundingBox->min_z <= arg0->z_position + && arg0->x_position <= boundingBox->max_x + && arg0->y_position <= boundingBox->max_y + && arg0->z_position <= boundingBox->max_z + && !func_806639CC(arg0, current->unk4)) { + func_80663A0C(arg0, current->unk0); + phi_s0 = ¤t->unk4; + current2 = current->unk4; + while (current2) { + phi_s0 = ¤t2->next; + current2 = current2->next; + } + temp_v0_4 = malloc(sizeof(GlobalASMStruct83)); + *phi_s0 = temp_v0_4; + temp_v0_4->unk0 = arg0; + temp_v0_4->unk4 = arg0->unk54; + temp_v0_4->unk8 = D_807FBB44; + temp_v0_4->next = NULL; + } + current = current->next; + } +} + +s32 func_806639CC(Actor *arg0, GlobalASMStruct83 *arg1) { + while (arg1) { + if (arg0 == arg1->unk0 && arg1->unk4 == arg0->unk54) { + return TRUE; + } + arg1 = arg1->next; + } + return FALSE; +} + +// TODO: Add to AAD union +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s16 unkC; // Used + u8 unkE; // Used + u8 unkF; // Used +} KongMirrorAAD; + +void func_80663A0C(Actor *arg0, GlobalASMStruct84 *arg1) { + KongMirrorAAD *temp_v1; + + func_80677FA8(0x7B, func_80613448(arg0)); // Spawn actor: Kong Mirror (Creepy Castle Museum) + D_807FBB44->unk11C = arg0; + temp_v1 = D_807FBB44->additional_actor_data; + temp_v1->unkE = arg1->unkE; + temp_v1->unkC = arg1->unkC; + temp_v1->unkF = arg1->unkF; + arg0->unk156++; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_684C0/func_80663A80.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_684C0/func_80663BE8.s") diff --git a/src/global_asm/code_68960.c b/src/global_asm/code_68960.c new file mode 100644 index 00000000..ebfbe5f3 --- /dev/null +++ b/src/global_asm/code_68960.c @@ -0,0 +1,46 @@ +#include +#include "functions.h" +#include "variables.h" + +extern f32 D_80758DF0; +extern f64 D_80758DF8; +extern f64 D_80758E00; + +typedef struct { + s16 unk0; + s8 unk2; + s8 unk3; + s16 unk4; +} GlobalASMStruct70; + +extern GlobalASMStruct70 D_80748B70[]; + +void func_80663C60(f32 *arg0, s16 arg1) { + s16 sp26; + f32 temp_f0; + f32 temp_f0_2; + s16 temp_a0; + s8 temp_v1; + GlobalASMStruct70 *temp_v0; + f32 phi_f2; + s16 phi_a0; + + sp26 = 6; + if (current_map == MAP_CASTLE) { + if (func_8061CC00()) { + phi_f2 = D_80758DF0; + } else { + phi_f2 = 900.0f; + } + temp_f0 = *arg0; + *arg0 = ((phi_f2 - temp_f0) * D_80758DF8) + temp_f0; + } + for (phi_a0 = 0; phi_a0 < sp26; phi_a0++) { + temp_v0 = &D_80748B70[phi_a0]; + if (current_map == temp_v0->unk0 && (arg1 == temp_v0->unk2 || temp_v0->unk2 == -1)) { + temp_f0_2 = *arg0; + *arg0 = ((temp_v0->unk4 - temp_f0_2) * D_80758E00) + temp_f0_2; + return; + } + } +} diff --git a/src/global_asm/code_68AA0.c b/src/global_asm/code_68AA0.c new file mode 100644 index 00000000..af611830 --- /dev/null +++ b/src/global_asm/code_68AA0.c @@ -0,0 +1,22 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68AA0/func_80663DA0.s") + +s32 func_80663FCC(s16 model2ArrayIndex) { + switch (D_807F6000[model2ArrayIndex].object_type) { + case 0x1: // Thin Flame? (2D) + case 0xC: // Flames (2D) + case 0x10: // Flame (2D) + case 0xF3: // Torch + case 0x134: // Flame + case 0x135: // Flame + case 0x138: // Torch + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68AA0/func_80664044.s") diff --git a/src/global_asm/code_68EA0.c b/src/global_asm/code_68EA0.c new file mode 100644 index 00000000..f7cce701 --- /dev/null +++ b/src/global_asm/code_68EA0.c @@ -0,0 +1,56 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_806641A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_806643C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_806644B0.s") + +// Doable, loop over struct array size 0xC +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_806645B8.s") + +/* +typedef struct { + s32 unk0; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; +} Struct807F9430; + +extern Struct807F9430 D_807F9430[]; +extern s16 D_807F9434; + +void func_806645B8(s16 arg0) { + s32 i; + + for (i = 0; i < D_807F9430[0].unk4; i++) { + if (arg0 == D_807F9430[i].unkA) { + D_807F9430[i].unkA = -1; + } + } +} +*/ + +s32 func_8066461C(s16 arg0) { + switch (arg0) { + case 1: // Thin Flame? (2D) + case 0x10: // Flame (2D) + case 0x74: // Golden Banana + case 0xF3: // Torch + case 0x138: // Torch + case 0x288: // Rareware GB + return TRUE; + default: + return FALSE; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_8066466C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_80664834.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_68EA0/func_80664A38.s") diff --git a/src/global_asm/code_699B0.c b/src/global_asm/code_699B0.c new file mode 100644 index 00000000..f9e9e900 --- /dev/null +++ b/src/global_asm/code_699B0.c @@ -0,0 +1,753 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_80748E00; +extern u8 D_80748E04; +extern void *D_80748E14; // TODO: Datatype +extern u8 D_80748E18[]; +extern f64 D_80758F08; + +extern u8 D_807F951D; +extern f32 D_807F9468; +extern u8 D_807F946C; +extern u8 D_807F946E; +extern f32 D_807F9488; +extern f32 D_807F948C; +extern s16 D_807F9490; +extern s16 D_807F9498; +extern s16 D_807F94A2; +extern s16 D_807F94A4; +extern u8 D_807F94AA; +extern u8 D_807F94AE; +extern u8 D_807F94AF; +extern u8 D_807F94B0; +extern u8 D_807F94B1; +extern u8 D_807F94B3; +extern u8 D_807F94B4; +extern u8 D_807F94B5; +extern u8 D_807F94B7; +extern u8 D_807F94BC; +extern u8 D_807F9484; +extern u8 D_807F9510; +extern s32 *D_807F95A8[]; +extern s32 D_807F9678; +extern u8 D_807F967C; +extern u8 D_807F967D; + +extern s32 *D_807FB1A0[]; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80664CB0.s") + +/* +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; +} Temp20Big; + +extern Temp20Big D_80748BA0[]; +extern s8 D_807F9440[]; +extern s32 D_807F9448; + +void func_80664CB0(s16 arg0) { + s32 i; + + D_807F9448 = 0; + i = 0; + do { + if (arg0 == D_80748BA0[i].unk0) { + if (D_807F9448 != 8) { + D_807F9440[D_807F9448] = i; + D_807F9448++; + } + } + } while (i++ < 0xD); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80664D20.s") + +void func_80665ACC(Actor *arg0); +u16 func_80672134(s16, s16, s16, s16); + +void func_80665160(Actor *arg0, s16 arg1, s16 arg2) { + func_8067ACB4(); + func_80665ACC(arg0); + if (arg0->unkFC != 0) { + func_80672680(arg0->unkEE, arg1, arg0->unkF4, arg0->unkF6, &arg0->unkF2); + arg0->unkFA = func_80672134(arg0->unkF4, arg0->unkF6, arg2, arg0->unkF8); + if ((arg0->unk64 & 0x200) && (arg0->unk64 & 0x100)) { + arg0->unkFA = 0; + } + arg0->unkEE = arg0->unkF2; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806651FC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806653C0.s") + +void func_80665548(void) { + D_80748E00 = 1; +} + +u8 func_80665558(void) { + return D_80748E04; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665564.s") + +// short but kinda complicated, struct? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665AAC.s") + +void func_80665ACC(Actor *arg0) { + arg0->object_properties_bitfield |= 0x2; // block playing instrument? + arg0->object_properties_bitfield |= 0x20; // TODO: What is this used for? +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665AE4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665C18.s") + +//forward decl necessary +//looks like its taking the linear distance between 2 points (2D) +void func_80665C18(f32,f32,f32,f32,f32); +void func_80665DE0(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + f32 temp_f0; + f32 temp_f2; + + temp_f0 = arg0 - arg2; + temp_f2 = arg1 - arg3; + func_80665C18(arg0, arg1, arg2, arg3, + sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2))); +} + +// complicated float stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665E48.s") + +/* +extern f32 D_80758EB0; + +f32 func_80665E48(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + return (func_80665DE0(arg0, arg1, arg2, arg3) * D_80758EB0) * 0.00048828125; +} +*/ + +void func_80611BB4(f32, f32); + +void func_80665E94(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s16 arg6) { + f32 temp_f0; + f32 temp_f2; + f32 phi_f14; + + temp_f0 = arg0 - arg3; + temp_f2 = arg2 - arg5; + temp_f0 = sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2)); + if (temp_f0 < arg6) { + phi_f14 = arg6; + } else { + phi_f14 = temp_f0; + } + func_80611BB4(arg4 - arg1, phi_f14); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665F24.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80665FB4.s") + +/* +extern f32 D_80758EB4; + +void func_8066EB50(Actor *actor, f32 arg1, f32 arg2, f32 arg3, f32 arg4); +void func_806303C4(f32, f32, Actor*, s32, s32, s16, s32); + +void func_80665FB4(Actor *arg0) { + f32 phi_f0; + + f32 xPos = arg0->x_position; + f32 yPos = arg0->y_position; + f32 zPos = arg0->z_position; + + if (arg0->animation_state) { + func_806303C4(yPos, zPos, arg0->draw_distance, 0, 1, -1, 1); + } + if (arg0->ledge_info_pointer) { + if (arg0->animation_state) { + phi_f0 = arg0->animation_state->scale_y; + } else { + phi_f0 = D_80758EB4; + } + func_8066EB50(arg0, xPos, yPos, zPos, phi_f0); + arg0->ledge_info_pointer->unk80 = object_timer; + } + //return phi_f0; +} +*/ + +// Loads floors from pointer table 3 for the current map +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80666090.s") + +void func_80666280(u8 arg0) { + D_807F94B4 = arg0; +} + +void func_80666428(Actor*, f32, f32, f32, s32, s32, s32, s32, u8); + +void func_80666290(Actor *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u8 arg5) { + f32 sp3C; + f32 sp38; + f32 sp34; + + D_807F94BC = 0; + D_807F94B3 = 0; + if (arg0->unkCC && !arg0->locked_to_pad && arg0->object_properties_bitfield & 0x10) { + func_80671C0C(arg0, arg0->unkCC, &sp3C, &sp38, &sp34); + } else { + sp3C = arg0->x_position; + sp38 = arg0->unk8C; + sp34 = arg0->z_position; + } + func_80666428(arg0, sp3C, sp38, sp34, arg1, arg2, arg3, arg4, arg5); +} + +void func_8066635C(Actor *arg0, f32 arg1, f32 arg2, f32 arg3, f32 *arg4) { + u8 sp3F; + u8 sp3E; + s32 sp38; + s32 sp34; + + // Actor->behaviour == Camera + if (arg0->unk58 == 0xBC) { + D_807F94B3 = 1; + } else { + D_807F94B3 = 0; + } + D_807F94BC = 1; + func_80666428(0, arg1, arg2, arg3, &sp3F, &sp38, &sp3E, &sp34, 0); + *arg4 = D_807F948C; +} + +void func_806663F8(void) { + D_807F94AE = 0; + D_807F94AF = 0; + D_807F94B0 = 0; + D_807F94B7 = 0; +} + +u8 func_8066641C(void) { + return D_807F951D; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80666428.s") + +u8 func_80666A88(void) { + return D_807F946E; +} + +u8 func_80666A94(void) { + return D_807F94AE; +} + +u8 func_80666AA0(void) { + return D_807F94AF; +} + +u8 func_80666AAC(void) { + return D_807F94B0; +} + +u8 func_80666AB8(void) { + return D_807F94B7; +} + +void func_80666AC4(s16 *arg0, s16 *arg1) { + *arg0 = D_807F94A2; + *arg1 = D_807F94A4; +} + +u8 func_80666AE0(void) { + return D_807F94B1; +} + +u8 func_80666AEC(void) { + return D_807F94AA; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80666AF8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80666D88.s") + +s32 func_80666F04(f32 arg0, f32 arg1, u8 arg2, u8 arg3) { + f32 phi_f0; + s32 phi_v1; + + phi_v1 = 0; + if (arg3 == 0xFF && arg0 < arg1) { + phi_f0 = arg2 == 1 ? D_80758F08 : 25; + if ((arg1 - arg0) < phi_f0) { + D_807F946C = 1; + D_807F9468 = arg1 - phi_f0; + phi_v1 = 1; + if (arg2) { + D_807F9468 /= 6.0f; + } + D_807F9468 += 6.0; + } + } + return phi_v1; +} + +s32 func_80666FC8(f32 arg0, f32 arg1, f32 arg2, u8 arg3) { + f32 phi_f0; + s32 phi_v0; + s32 phi_v1; + f32 phi_f2; + + phi_f0 = arg3 == 1 ? 60.0 : 10.0; + + if (arg0 <= arg2) + phi_v0 = TRUE; + else if ((arg0 - arg2) < phi_f0) + phi_v0 = TRUE; + else + phi_v0 = FALSE; + + if (arg1 <= arg2) + phi_v1 = TRUE; + else if ((arg1 - arg2) < phi_f0) + phi_v1 = TRUE; + else + phi_v1 = FALSE; + + if (!(phi_v0 || phi_v1)) { + return FALSE; + } + if (!phi_v1) { + return FALSE; + } + if (!phi_v0) { + return TRUE; + } + + if (arg2 < arg0) { + phi_f0 = arg0 - arg2; + } else { + phi_f0 = arg2 - arg0; + } + if (arg2 < arg1) { + phi_f2 = arg1 - arg2; + } else { + phi_f2 = arg2 - arg1; + } + + if (phi_f0 < phi_f2) { + return FALSE; + } + return TRUE; +} + +void func_80667110(s32 arg0, s32 arg1, s32 arg2) { + D_807F9484 = 0; + D_807F9510 = 0; + func_80667180(arg0, arg1, arg2, 0); + D_807F94A4 = D_807F9498; + D_807F94A2 = D_807F9490; +} + +u8 func_8066715C(f32 *arg0) { + *arg0 = D_807F9488; + return D_807F9484; +} + +u8 func_80667174(void) { + return D_807F94B5; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80667180.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806672B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066785C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806679BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80668520.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806685E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806686F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806687E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806688B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066893C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806689F0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80668B28.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80668C30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80668E9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669588.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669650.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806696A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669830.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_806699C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669A6C.s") + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + f32 unk10; + f32 unk14; +} GlobalASMStruct80; + +int func_80669BE8(GlobalASMStruct80 *arg0, f32 arg1, f32 arg2) { + if (arg1 < arg0->unk0) { + return FALSE; + } + if (arg2 < arg0->unk8) { + return FALSE; + } + if (arg0->unkC < arg1) { + return FALSE; + } + if (arg0->unk14 < arg2) { + return FALSE; + } + return TRUE; +} + +int func_80669C6C(GlobalASMStruct80 *arg0, f32 arg1) { + if (arg1 < arg0->unk4) { + return FALSE; + } + if (arg0->unk10 < arg1) { + return FALSE; + } + return TRUE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669CB4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_80669E04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066A08C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066A584.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066A64C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066A75C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066A834.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066A988.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066AC10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066ACA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066ADA0.s") + +void func_8066AEE4(s32 arg0, s32 arg1) { + s32 sp24; + s32 sp20; + + sp24 = arg0; + sp20 = arg1; + if (!D_80748E14) { + D_80748E14 = malloc(0x2400); + } + func_800024E0(&sp24, &sp20, D_80748E14); + func_8061130C(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066AF40.s") + +s32 func_8066B020(s32 arg0, s32 arg1) { + s32 sp1C; + s32 sp18; + + func_8066B5F4(); + func_8066B4D4(arg0, arg1, &sp1C, &sp18); + if (sp18 == 0) { + return 0; + } + return sp1C; +} + +s32 func_8066B06C(s32 arg0, s32 arg1) { + s32 sp1C; + s32 sp18; + + if (D_80748E18[arg0] != 0) { + sp18 = *(D_807FB1A0[arg0] + arg1); + } else { + func_8066B5F4(); + func_8066B4D4(arg0, arg1, &sp1C, &sp18); + } + return sp18; +} + +void func_8066B0DC(void) { + D_807F967C = 1; +} + +void func_8066B0EC(s32 arg0) { + D_807F9678 = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/getPointerTableFile.s") + +void func_8066B424(void) { + D_807F967D = 1; +} + +//forward decl needed +void func_8066B4AC(s32,s32,s32); +s32 func_8066B9F4(void*); + +// It's usually a file from a pointer table in arg0 +void func_8066B434(void *arg0, s32 arg1, s32 arg2) { + s32 sp1C; + s32 sp18; + + if (func_8066B9F4(arg0) == 0) { + func_8066BC00(arg0, &sp1C, &sp18); + func_8066B4AC(sp1C, sp18, 0); + if (D_807F967D == 0) { + func_8061134C(arg0); + } else { + func_8061130C(arg0); + } + } + D_807F967D = 0; +} + +void func_8066B4AC(s32 arg0, s32 arg1, s32 arg2) { + s32 *temp_v0 = D_807F95A8[arg0]; + if (temp_v0) { + *(temp_v0 + arg1) = arg2; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066B4D4.s") + +s32 func_8066B5C8(s32 arg0, s32 arg1) { + s32 *temp_v0; + s32 phi_v1; + + temp_v0 = D_807F95A8[arg0]; + phi_v1 = 0; + if (temp_v0) { + phi_v1 = *(temp_v0 + arg1); + } + return phi_v1; +} + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066B5F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066B75C.s") + +//forward declaration needed here +u32 func_8066C2B4(u32); +extern s32 D_807F9628[]; +void func_8066B7AC(s32 arg0, s32 arg1, s32 arg2) { + func_8066B7F4(D_807F9628[func_8066C2B4(arg0)], arg0, arg1, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066B7F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066B8C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066B924.s") + +s32 func_8066B9F4(void *arg0) { + return func_8066BB44(D_807F9628[func_8066C2B4(arg0)], arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BA2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BAB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BB44.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BC00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BC5C.s") + +typedef struct global_asm_struct_40 GlobalASMStruct40; + +struct global_asm_struct_40 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + u8 unk10; + s8 unk11; + s8 unk12; + s8 unk13; + GlobalASMStruct40 *unk14; // Doubly linked list? + GlobalASMStruct40 *unk18; // Doubly linked list? +}; + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + u8 unk10; + s8 unk11; + s8 unk12; + s8 unk13; +} GlobalASMStruct65; + +/* +// TODO: Quite close, similar issue as below +GlobalASMStruct40 *func_8066BC5C(GlobalASMStruct40 *arg0, u32 arg1, s32 *arg2, s32 *arg3) { + GlobalASMStruct40 *phi_s0; + + // phi_s0 = arg0; + if (arg0) { + if (arg1 == arg0->unk0) { + *arg2 = arg0->unk4; + *arg3 = arg0->unk8; + if (!arg0->unk14 && !arg0->unk18) { + func_8061130C(arg0); + arg0 = NULL; + } else { + if (!arg0->unk14) { + arg0 = arg0->unk18; + func_8061130C(arg0); + } else if (!arg0->unk18) { + arg0 = arg0->unk14; + func_8061130C(arg0); + } else { + arg0->unk18 = func_8066BD54(arg0->unk18, arg0, &arg0->unk4, &arg0->unk8, &arg0->unkC, &arg0->unk10); + } + } + } else if (arg0->unk0 < arg1) { + arg0->unk18 = func_8066BC5C(arg0->unk18, arg1, arg2, arg3); + } else { + arg0->unk14 = func_8066BC5C(arg0->unk14, arg1, arg2, arg3); + } + } + return arg0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BD54.s") + +/* +// TODO: a0/s0 mixup in one spot... Not sure how to fix +GlobalASMStruct40 *func_8066BD54(GlobalASMStruct40 *arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4, s8 *arg5) { + GlobalASMStruct40 *pad; + + if (!arg0->unk14) { + *arg1 = arg0->unk0; + *arg2 = arg0->unk4; + *arg3 = arg0->unk8; + *arg4 = arg0->unkC; + *arg5 = arg0->unk10; + arg0 = arg0->unk18; + func_8061130C(arg0); + } else { + arg0->unk14 = func_8066BD54(arg0->unk14, arg1, arg2, arg3, arg4, arg5); + } + return arg0; +} +*/ + +void func_8066BE20(s32); +void func_8066BECC(GlobalASMStruct40 *arg0); +GlobalASMStruct40 *func_8066BF0C(GlobalASMStruct65 *arg0, s32 arg1, s32 arg2); + +void func_8066BDE0() { + int i; + for (i = 0; i < 0x14; i++) { + func_8066BE20(i); + } +} + +void func_8066BE20(s32 arg0) { + s32 temp_v0; + s32 *sp30; + s32 sp2C; + s32 sp28; + + sp28 = 0; + temp_v0 = func_8066B75C(D_807F9628[arg0]); + if (temp_v0 != 0) { + sp30 = malloc(temp_v0 * sizeof(GlobalASMStruct65)); + func_8066BFF0(D_807F9628[arg0], sp30, &sp28); + func_8066C0DC(sp30, 0, temp_v0 - 1); + sp2C = func_8066BF0C(sp30, 0, temp_v0 - 1); + func_8066BECC(D_807F9628[arg0]); + D_807F9628[arg0] = sp2C; + func_8061130C(sp30); + } +} + +// Recursion :O +void func_8066BECC(GlobalASMStruct40 *arg0) { + if (arg0) { + func_8066BECC(arg0->unk14); + func_8066BECC(arg0->unk18); + func_8061130C(arg0); + } +} + +GlobalASMStruct40 *func_8066BF0C(GlobalASMStruct65 *arg0, s32 arg1, s32 arg2) { + GlobalASMStruct40 *temp_v0; + s32 temp_t7; + + temp_v0 = malloc(sizeof(GlobalASMStruct40)); + temp_t7 = (arg1 + arg2) / 2; + temp_v0->unk0 = arg0[temp_t7].unk0; + temp_v0->unk4 = arg0[temp_t7].unk4; + temp_v0->unk8 = arg0[temp_t7].unk8; + temp_v0->unkC = arg0[temp_t7].unkC; + temp_v0->unk10 = arg0[temp_t7].unk10; + if (arg1 != temp_t7) { + temp_v0->unk14 = func_8066BF0C(arg0, arg1, temp_t7 - 1); + } else { + temp_v0->unk14 = NULL; + } + if (arg2 != temp_t7) { + temp_v0->unk18 = func_8066BF0C(arg0, temp_t7 + 1, arg2); + } else { + temp_v0->unk18 = NULL; + } + return temp_v0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066BFF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_699B0/func_8066C0DC.s") + +u32 func_8066C2B4(u32 arg0) { + return (u32) (arg0 >> 0xC) % 0x14U; +} \ No newline at end of file diff --git a/src/global_asm/code_70FD0.c b/src/global_asm/code_70FD0.c new file mode 100644 index 00000000..367a10e6 --- /dev/null +++ b/src/global_asm/code_70FD0.c @@ -0,0 +1,673 @@ +#include +#include "functions.h" +#include "variables.h" + + +void func_8066EC6C(LedgeInfo *); +void func_8066F06C(LedgeInfo *); +void func_80679290(Actor *arg0, s32 arg1, s32 arg2, u8 arg3, s32 arg4, s32 arg5, s32 arg6); +void func_8066C2D0(s32, s32, f32, f32, f32, f32, f32, f32, f32); + +s32 func_80672328(Actor*, f32, f32); +s32 func_80672680(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16* arg4); +s32 func_806726DC(s32 arg0, s16 arg1, s16 arg2, s16 arg3, s16 *arg4, s16 arg5); +s32 func_806728F0(s16, s16, s16); +s16 func_80672A70(s16, s16); + +extern s32 D_807FB53C; +extern s32 D_807FB540; +extern s16 D_807FB544; +extern u8 D_807FB546; +extern s16 D_807FB5EC; +extern s16 D_807FB5EE; +extern s16 D_807FB5F0; +extern s16 D_807FB5F2; +extern s16 D_807FB5F8; +extern s16 D_807FB5FA; +extern u8 D_807FB602; +extern u8 D_807FB604; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066C2D0.s") + +// Doable, model2 matrix stuff, might need some more structs/arrays defined though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066C610.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066C7F4.s") + +void func_8066C8B0(s32 arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, f32 arg8) { + func_8066C2D0(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066C904.s") + +// Loads walls for the current map from pointer table 2 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066C958.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066CB88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066CCD8.s") + +void func_8066CDD0() { + func_8066CDF8(); + func_806687E0(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066CDF8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066CEE4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066D250.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066D2F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066D4DC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066DB40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066DD34.s") + +void func_8066E21C(LedgeInfo *ledgeInfo) { + LedgeInfo8C *current; + LedgeInfo8C *next; + LedgeInfo90 *current2; + LedgeInfo90 *next2; + + if (ledgeInfo) { + current = ledgeInfo->unk8C; + while (current) { + next = current->next; + func_8061130C(current); + current = next; + } + current2 = ledgeInfo->unk90; + while (current2) { + next2 = current2->next; + func_8061130C(current2); + current2 = next2; + } + if (ledgeInfo->unkA0) { + func_8061130C(ledgeInfo->unkA0); + } + if (ledgeInfo->unk98) { + func_8061130C(ledgeInfo->unk98); + } + func_8061130C(ledgeInfo); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066E2C0.s") + +typedef struct { + u8 pad0[0x24]; + u16 unk24; + u8 unk26; + u8 unk27; +} GlobalASMStruct0; + +GlobalASMStruct0 *func_8066EAEC(s32, s32); + +void func_8066E5CC(s32 arg0, s32 arg1, u16 arg2) { + GlobalASMStruct0 *temp_v0 = func_8066EAEC(arg0, arg1); + if (temp_v0) { + temp_v0->unk24 = arg2; + } +} + +void func_8066E5F8(s32 arg0, s32 arg1, u8 arg2) { + GlobalASMStruct0 *temp_v0 = func_8066EAEC(arg0, arg1); + if (temp_v0) { + temp_v0->unk27 |= arg2; + } +} + +void func_8066E62C(s32 arg0, s32 arg1, u8 arg2) { + GlobalASMStruct0 *temp_v0 = func_8066EAEC(arg0, arg1); + if (temp_v0) { + temp_v0->unk27 &= ~arg2; + } +} + +void func_8066E664(Actor *arg0, s32 arg1, u8 arg2) { + LedgeInfo *ledgeInfo; + LedgeInfoA0 *phi_a2; + s32 i; + + ledgeInfo = arg0->ledge_info_pointer; + if (arg0->ledge_info_pointer) { + phi_a2 = ledgeInfo->unkA0; + for (i = 0; i < ledgeInfo->unk9C; i++) { + if (arg1 == phi_a2[i].unk28) { + phi_a2[i].unk2A = arg2; + } + } + } +} + +void func_8066E6C8(Actor *arg0, s32 arg1, u8 arg2) { + LedgeInfo *ledgeInfo; + LedgeInfo98 *phi_a2; + s32 i; + + ledgeInfo = arg0->ledge_info_pointer; + if (arg0->ledge_info_pointer) { + phi_a2 = ledgeInfo->unk98; + for (i = 0; i < ledgeInfo->unk94; i++) { + if (arg1 == phi_a2[i].unk54) { + phi_a2[i].unk56 = arg2; + } + } + } +} + +void func_8066E72C(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7, s32 arg8) { + LedgeInfo *ledgeInfo = malloc(0xC4); // TODO: sizeof(LedgeInfo) + something? + + ledgeInfo->unk0 = arg0 * 8.0f; + ledgeInfo->unk4 = arg1 * 8.0f; + ledgeInfo->unk8 = arg2 * 8.0f; + ledgeInfo->unkC = arg4 * arg3 * 8.0f; + ledgeInfo->unk10 = arg5 * arg3 * 8.0f; + ledgeInfo->unk14 = arg4; + ledgeInfo->unk18 = arg5; + ledgeInfo->unk70 = arg6; + ledgeInfo->unk74 = arg7; + ledgeInfo->unk78 = arg8; + ledgeInfo->unk7C = -1; + ledgeInfo->unk80 = -2; + ledgeInfo->unk84 = -1; + ledgeInfo->unk88 = -1; + ledgeInfo->unk60 = 0; + ledgeInfo->unk6C = 0; + ledgeInfo->unk24 = 0; + ledgeInfo->unk8C = NULL; + ledgeInfo->unk90 = NULL; + ledgeInfo->unk94 = 0; + ledgeInfo->unk98 = NULL; + ledgeInfo->unk9C = 0; + ledgeInfo->unkA0 = NULL; + ledgeInfo->unkA4 = 0; + ledgeInfo->unkA8 = 0; + ledgeInfo->unkAC = 0; +} + +void func_8066E854(Actor *arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4) { + s32 pad[3]; + LedgeInfo *temp_a1; + LedgeInfo90 *temp_v0; + LedgeInfo90 *temp_v1; + void **phi_a0; + + temp_a1 = arg0->ledge_info_pointer; + temp_v0 = malloc(sizeof(LedgeInfo90)); + temp_v0->next = NULL; + temp_v0->unk0 = arg1; + temp_v0->unk4 = arg2; + temp_v0->unk8 = arg3; + temp_v0->unk18 = arg4; + temp_v0->unkC = 0; + temp_v0->unk10 = 0; + temp_v0->unk14 = 0; + temp_v1 = temp_a1->unk90; + phi_a0 = &temp_a1->unk90; + while (temp_v1) { + phi_a0 = &temp_v1->next; + temp_v1 = temp_v1->next; + } + *phi_a0 = temp_v0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066E8E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066E990.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066E9EC.s") + +/* +// TODO: Pretty close, surprisingly fiddly +f32 func_8066E9EC(Actor *arg0, s32 arg1, f32 arg2) { + LedgeInfo8C *phi_v1; + + arg1--; + phi_v1 = arg0->ledge_info_pointer->unk8C; + while (phi_v1) { + if (phi_v1->next) { + if (arg1) { + arg1--; + } else { + break; + } + phi_v1 = phi_v1->next; + } else { + break; + } + } + + if (phi_v1) { + if (arg2 != -1.0f) { + phi_v1->unkC = arg2; + } + return phi_v1->unkC; + } + return -1.0f; +} +*/ + +void func_8066EA64(s32 arg0, s32 arg1) { + GlobalASMStruct0 *temp_v0 = func_8066EAEC(arg0, arg1); + if (temp_v0) { + temp_v0->unk26 = 1; + } +} + +void func_8066EA90(s32 arg0, s32 arg1) { + GlobalASMStruct0 *temp_v0 = func_8066EAEC(arg0, arg1); + if (temp_v0) { + temp_v0->unk26 = 0; + } +} + +//related to the struct used above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066EABC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066EAEC.s") + +void func_8066EB40(Actor *arg0, f32 arg1) { + LedgeInfo *ledgeInfo = arg0->ledge_info_pointer; + ledgeInfo->unk14 = arg1; +} + +void func_8066EB50(Actor *actor, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + LedgeInfo *ledgeInfo = actor->ledge_info_pointer; + if (actor->unk64 & 0x800) { + arg4 = actor->unk120; + } + ledgeInfo->unk0 = arg1 * 8.0f; + ledgeInfo->unk4 = arg2 * 8.0f; + ledgeInfo->unk8 = arg3 * 8.0f; + ledgeInfo->unkC = ledgeInfo->unk14 * arg4 * 8.0f; + ledgeInfo->unk10 = ledgeInfo->unk18 * arg4 * 8.0f; +} + +void func_8066EBF4(Actor *arg0) { + if (arg0->ledge_info_pointer) { + if (!(arg0->object_properties_bitfield & 0x80000000) || ((arg0->object_properties_bitfield & 0x10) == 0)) { + func_8066EC6C(arg0->ledge_info_pointer); + } + if (!(arg0->unk64 & 8) || !(arg0->object_properties_bitfield & 0x10)) { + func_8066F06C(arg0->ledge_info_pointer); + } + } +} + +// Loop, memcpy, matrix +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066EC6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066EE50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066F06C.s") + +u8 func_8066F1F8(s32 arg0, s16 arg1) { + s16 sp1E; + s16 sp1C; + s8 sp1B; + + D_807FB544 = arg1; + D_807FB540 = arg0; + D_807FB546 = 1; + D_807FB604 = 1; + func_8066F274(arg0, &sp1E, &sp1C, &sp1B); + return D_807FB546; +} + +void func_8066F250() { + D_807FB604 = 0; + func_8066F274(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066F274.s") + +void func_8066F400(Actor *arg0) { + if (D_807FB602) { + if (arg0->interactable & 1) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + if (PaaD->unkD4 == 0) { + if (D_807FB602 & 1) { + func_80679290(arg0, 0, 8, 0, 0, 0, 1); + } + if (D_807FB602 & 2) { + func_80679290(arg0, 0, 8, 0, 0, 0, 1); + } + } + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066F4AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066F84C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066FC0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066FD6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_8066FE08.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80670548.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80670C5C.s") + +void func_80670F04(LedgeInfo *arg0) { + s16 temp_v0 = arg0->unk48; + + D_807FB5EC = temp_v0 - 0x32; + if (D_807FB5EC < 0) { + D_807FB5EC = D_807FB5EC + 0xFFF; + } + D_807FB5EE = temp_v0 + 0x32; + if (D_807FB5EC >= 0x1000) { + D_807FB5EE += -0xFFF; + } + D_807FB5F0 = D_807FB5EC + 0x800; + if (D_807FB5F0 >= 0x1000) { + D_807FB5F0 = D_807FB5F0 - 0xFFF; + } + D_807FB5F2 = D_807FB5EE + 0x800; + if (D_807FB5F2 >= 0x1000) { + D_807FB5F2 = D_807FB5F2 - 0xFFF; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80670FA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_806710E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671260.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_806713E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671528.s") + +s32 func_806717FC(Actor *arg0) { + PlayerAdditionalActorData *PaaD; + switch (arg0->unk58) { + case ACTOR_TINY: + PaaD = arg0->PaaD; + if (character_change_array[PaaD->unk1A4].unk2C0 != 1) { + return 20; + } + return 50; + case ACTOR_DIDDY: + return 50; + case ACTOR_DK: + return 50; + default: + return 50; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671880.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671A6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671C0C.s") + +void func_80671D10(Actor *arg0, s32 arg1, f32 *arg2, f32 *arg3, f32 *arg4) { + s32 phi_v0 = arg1 - 1; + LedgeInfo90 *phi_v1 = arg0->ledge_info_pointer->unk90; + + while (phi_v1 && phi_v0) { + phi_v1 = phi_v1->next; + phi_v0--; + } + + *arg2 = phi_v1->unk0; + *arg3 = phi_v1->unk4; + *arg4 = phi_v1->unk8; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671D64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671E00.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80671F54.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80672134.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80672328.s") + +extern f64 D_80759158; +extern f64 D_80759160; +extern f64 D_80759168; +extern f64 D_80759170; + +s32 func_806725A0(Actor *arg0, s16 arg1); +s32 func_80611E60(s32, s32); + +/* +// TODO: Pretty close +// Float, s16 and stack nonsense +s32 func_80672328(Actor *arg0, f32 arg1, f32 arg2) { + s32 temp_f6; + s32 temp_v1; + s32 temp_f16; + s32 temp_a1; + s32 temp_f8; + s32 temp_f18; + s32 phi_a2; + s32 phi_v1; + f32 temp_f0; + + temp_f8 = arg0->unk88 * 8.0f; + temp_f6 = arg1 * 8.0f; + temp_f18 = arg0->unk90 * 8.0f; + temp_v1 = temp_f6 - temp_f8; + temp_f16 = arg2 * 8.0f; + temp_a1 = temp_f16 - temp_f18; + temp_f0 = sqrtf((temp_v1 * temp_v1) + (temp_a1 * temp_a1)); + if (temp_f0 == 0.0) { + return TRUE; + } + if ((temp_v1 >= 0) && (temp_a1 >= 0)) { + phi_a2 = func_80611E60((temp_v1 * D_80759158) / temp_f0, temp_a1) >> 4; + } + if (((temp_f6 - temp_f8) >= 0) && ((temp_f16 - temp_f18) < 0)) { + phi_a2 = (func_80611E60(((temp_f18 - temp_f16) * D_80759160) / temp_f0, temp_f16 - temp_f18) >> 4) + 0x400; + } + if (((temp_f6 - temp_f8) < 0) && ((temp_f16 - temp_f18) < 0)) { + phi_a2 = (func_80611E60(((temp_f8 - temp_f6) * D_80759168) / temp_f0, temp_f16 - temp_f18) >> 4) + 0x800; + } + if (((temp_f6 - temp_f8) < 0) && ((temp_f16 - temp_f18) >= 0)) { + phi_a2 = (func_80611E60(((temp_f16 - temp_f18) * D_80759170) / temp_f0, temp_f16 - temp_f18) >> 4) + 0xC00; + } + return func_806725A0(arg0, phi_a2) ? TRUE : FALSE; +} +*/ + +s32 func_806725A0(Actor *arg0, s16 arg1) { + s16 sp26, sp24; + + return func_80672680(sp24, arg1, arg0->unkF4, arg0->unkF6, &sp26); +} + +s32 func_806725E4(s16 arg0, s16 arg1, s16 arg2, s16 arg3) { + s16 sp26, sp24; + + return func_806726DC(sp24, arg2, arg0, arg1, &sp26, arg3); +} + +s32 func_80672630(Actor *arg0, s16 arg1, s16 arg2) { + s16 sp26, sp24; + + return func_806726DC(sp24, arg1, arg0->unkF4, arg0->unkF6, &sp26, arg2); +} + +s32 func_80672680(s16 arg0, s16 arg1, s16 arg2, s16 arg3, s16* arg4) { + return func_806726DC(arg0, arg1, arg2, arg3, arg4, 0xA); +} + +s32 func_806726DC(s32 arg0, s16 arg1, s16 arg2, s16 arg3, s16 *arg4, s16 arg5) { + u8 phi_a0; + s16 phi_t2 = arg2 + arg5; + s16 phi_t3 = arg3 - arg5; + + if (arg3 >= arg2) { + if ((phi_t2 < phi_t3) && (arg1 >= phi_t2) && (phi_t3 >= arg1)) { + *arg4 = arg1; + return TRUE; + } + *arg4 = func_806728F0(arg2, arg3, arg1); + } else { + phi_a0 = 0; + if (phi_t2 >= 0x1000) { + phi_t2 -= 0x1000; + phi_a0 = 1; + } + if (phi_t3 < 0) { + phi_t3 += 0x1000; + phi_a0 += 2; + } + switch (phi_a0) { + case 0: + if ((arg1 >= phi_t2) || (phi_t3 >= arg1)) { + *arg4 = arg1; + return TRUE; + } + *arg4 = func_806728F0(arg2, arg3, arg1); + break; + case 1: + case 2: + if ((phi_t2 < phi_t3) && (arg1 >= phi_t2) && (phi_t3 >= arg1)) { + *arg4 = arg1; + return TRUE; + } + *arg4 = func_806728F0(arg2, arg3, arg1); + break; + case 3: + *arg4 = func_806728F0(arg2, arg3, arg1); + break; + } + } + return FALSE; +} + +s32 func_806728F0(s16 arg0, s16 arg1, s16 arg2) { + s16 phi_a3; + s16 phi_t0; + s16 phi_v0; + s16 phi_a0; + s16 phi_v1; + + phi_a3 = arg0 + 0xA; + phi_t0 = arg1 - 0xA; + phi_a0 = ABS(arg0 - arg2); + if (phi_a0 >= 0x801) { + phi_a0 = 0xFFF - phi_a0; + } + phi_v0 = ABS(arg1 - arg2); + if (phi_v0 >= 0x801) { + phi_v0 = 0xFFF - phi_v0; + } + if (phi_v0 >= phi_a0) { + if (phi_a3 >= 0x1000) { + phi_a3 -= 0xFFF; + } + phi_v1 = phi_a3; + } else { + if (phi_t0 < 0) { + phi_t0 += 0xFFF; + } + phi_v1 = phi_t0; + } + if (arg1 >= arg0) { + if ((phi_v1 < arg0) || (arg1 < phi_v1)) { + phi_v1 = func_80672A70(arg0, arg1); + } + } else if ((phi_v1 < arg0) && (arg1 < phi_v1)) { + phi_v1 = func_80672A70(arg0, arg1); + } + return phi_v1; +} + +s16 func_80672A70(s16 arg0, s16 arg1) { + s16 temp_v0; + + if (arg1 >= arg0) { + return (arg0 + arg1) >> 1; + } + temp_v0 = (((arg1 - arg0) + 0xFFF) / 2) + arg0; + if (temp_v0 >= 0x1000) { + temp_v0 -= 0xFFF; + } + return temp_v0; +} + +void func_80672AFC(Actor *actor) { + LedgeInfo *ledgeInfo = actor->ledge_info_pointer; + if (ledgeInfo) { + ledgeInfo->unk88 = object_timer; + } +} + +void func_80672B1C(Actor *actor) { + if (actor->noclip_byte & 8) { + if (actor->ledge_info_pointer->unk6C) { + actor->unkFC |= func_80670548(); + } else { + actor->ledge_info_pointer->unk60 = 0; + } + if (actor->object_properties_bitfield & 0x20) { + if (actor->ledge_info_pointer->unk24) { + if (func_80672328(actor, actor->ledge_info_pointer->unk1C, actor->ledge_info_pointer->unk20) != 0) { + actor->x_position = actor->ledge_info_pointer->unk1C; + actor->z_position = actor->ledge_info_pointer->unk20; + } + } + } + } else { + if (actor->ledge_info_pointer) { + actor->ledge_info_pointer->unk6C = 0; + } + } +} + +u8 func_80672BD4(Actor *arg0) { + return arg0->locked_to_pad + || arg0->ledge_info_pointer->unk6C + || arg0->ledge_info_pointer->unk24 + || (arg0->unk6A & 8) + || (arg0->unk6A & 0x400); +} + +void func_80672C30(Actor *arg0) { + arg0->locked_to_pad = 0; + if (arg0->ledge_info_pointer) { + arg0->ledge_info_pointer->unk6C = 0; + arg0->ledge_info_pointer->unk24 = 0; + } + arg0->unk6A &= ~0x8; + arg0->unk6A &= ~0x400; + arg0->unk64 |= 0x2000; +} + +void func_80672C70(s32 arg0) { + D_807FB53C = arg0; + if ((arg0 != 0) && (arg0 != 0xBC)) { + D_807FB5F8 = 2; + D_807FB5FA = 0xA; + } else { + D_807FB5F8 = 0x64; + D_807FB5FA = 0x64; + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_70FD0/func_80672CBC.s") + +void func_80672E64(void) { + +} + +void func_80672E6C() { + func_806119A0(); +} \ No newline at end of file diff --git a/src/global_asm/code_77B90.c b/src/global_asm/code_77B90.c new file mode 100644 index 00000000..de14097a --- /dev/null +++ b/src/global_asm/code_77B90.c @@ -0,0 +1,62 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80672E90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80672EBC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80672F94.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806730A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673240.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806732A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673324.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806734E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673708.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806738D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806739D8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673A40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673A94.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673B78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673C34.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673D48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80673FDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674080.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674150.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806742C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674330.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_8067443C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_806744A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_8067457C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674688.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_8067470C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674884.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674A5C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_77B90/func_80674ADC.s") diff --git a/src/global_asm/code_79890.c b/src/global_asm/code_79890.c new file mode 100644 index 00000000..6308852a --- /dev/null +++ b/src/global_asm/code_79890.c @@ -0,0 +1,20 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_80674B90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_80674E14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_80675180.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_80675234.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_806752D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_80675380.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_80675478.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_79890/func_806755A8.s") diff --git a/src/global_asm/code_7A510.c b/src/global_asm/code_7A510.c new file mode 100644 index 00000000..a17a7032 --- /dev/null +++ b/src/global_asm/code_7A510.c @@ -0,0 +1,126 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675810.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675AFC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675C70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675D70.s") + +/* +// TODO: Pretty close +void func_80675D70(Actor *arg0) { + if (D_807FBB70[0].unk200 < 2) { + D_807FBB70[0].unk1FC = arg0; + D_807FBB70[0].unk200 = 1; + } + if (D_807FBB70[0].unk201 < 0xF) { + D_807FBB70[D_807FBB70[0].unk201].unk204 = arg0; + D_807FBB70[D_807FBB70[0].unk201].unk244 = 2; + D_807FBB70[0].unk201++; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675DD0.s") + +/* +void func_80675DD0(void *arg0, void *arg1) { + u8 temp_v0; + u8 phi_v0; + + arg0->unk134 -= arg1->unk136; + if (arg0->unk134 <= 0) { + D_807FBB70[0].unk200 = 9; + return; + } + temp_v0 = D_807FBB70[0].unk200; + phi_v0 = temp_v0; + if (temp_v0 == 6) { + D_807FBB70[0].unk200 = 4; + phi_v0 = 4 & 0xFF; + } + if (phi_v0 == 7) { + D_807FBB70[0].unk200 = 5; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675E3C.s") + +s32 func_80675C70(s16, s16, s16); + +typedef struct { + s16 unk0; + s16 unk2; + s32 unk4; +} GlobalASMStruct57; + +/* +// TODO: Astonishingly close, extra NOP +s32 func_80675E3C(GlobalASMStruct57 *arg0, s16 arg1, s16 arg2) { + s16 temp_s1; + s32 temp_s2; + + do { + temp_s1 = arg0->unk0; + temp_s2 = arg0->unk4; + if (!func_80675C70(arg1, arg2, temp_s1)) { + arg0++; + } + } while (temp_s1); + + return temp_s2; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_80675EE0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7A510/func_8067605C.s") + +void func_8067618C(Actor *arg0, u8 *arg1) { + if ((current_map == MAP_FUNGI_DOGADON) && (arg0->unk58 == ACTOR_CHUNKY) && (arg0->control_state == 0x1E)) { + *arg1 = 0x15; + } +} + +typedef struct { + s16 unk0; + s16 unk2; +} GlobalASMStruct55; + +extern GlobalASMStruct55 D_8074D0C4[]; + +void func_806761D0(Actor *arg0) { + arg0->health = D_8074D0C4[arg0->unk58].unk0; +} + +void func_806761EC(Actor *arg0) { + arg0->unk136 = D_8074D0C4[arg0->unk58].unk2; +} + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + void* unk4; +} GlobalASMStruct56; + +extern GlobalASMStruct56 D_8074C608[]; + +u8 func_80676208(Actor *arg0) { + return D_8074C608[arg0->unk58].unk0; +} + +s32 func_80676220(s16 arg0) { + // Actor behaviour: Klump, Robo-Kremling, Kosha + if ((arg0 == 0xBB) || (arg0 == 0xEB) || (arg0 == 0x123)) { + return FALSE; + } + return TRUE; +} diff --git a/src/global_asm/code_7AF60.c b/src/global_asm/code_7AF60.c new file mode 100644 index 00000000..b6e078ce --- /dev/null +++ b/src/global_asm/code_7AF60.c @@ -0,0 +1,192 @@ +#include +#include "functions.h" +#include "variables.h" + + +s32 func_806D0DE4(Actor *arg0, Actor *arg1); +u8 func_806767E0(s32, s32, s32); +u8 func_80676CB0(s32, s32); +f32 func_80665E94(f32, f32, f32, f32, f32, f32, s32); + +extern u8 D_807F6902; +extern f64 D_807591E0; + +void func_80676260(Actor *arg0, Actor *arg1, s32 arg2) { + func_806D0DE4(arg0, arg1); +} + +u8 func_80676280(Actor *arg0, s32 arg1, s32 arg2) { + return func_806D10D0(arg1) && D_807F6902 == 0; +} + +u8 func_806762C0(s32 arg0, s32 arg1, s32 arg2) { + return func_806767E0(arg0, arg1, arg2) && func_80676280(arg0, arg1, arg2); +} + +u8 func_80676308(Actor *arg0, Actor *arg1, s32 arg2) { + s16 diff = arg0->health - arg1->unk136; + if (diff <= 0) { + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676338.s") + +// TODO: Not exactly sure what's wrong here +// Tricky floating point typecasty stuff I suspect +/* +s32 func_80665DE0(s32, s32, s32, s32); +s32 func_806CC14C(s16, s16); + +s32 func_8067641C(s32, s32, s32); + +s32 func_80676338(Actor *arg0, Actor *arg1, s32 arg2) { + u8 temp = func_806CC14C(func_80665DE0(arg0->x_position, arg0->z_position, arg1->x_position, arg1->z_position), arg0->y_rotation) < 0x200; + return temp + && func_8067641C(arg0, arg1, arg2); +} +*/ + +// TODO: Similar layout as above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_8067641C.s") + +u8 func_806764D8(Actor *arg0, Actor *arg1, s32 arg2) { + return D_807591E0 < func_80665E94(arg0->x_position, arg0->y_position, arg0->z_position, arg1->x_position, arg1->y_position, arg1->z_position, 0); +} + +u8 func_80676540(s32 arg0, Actor *arg1, Actor *arg2) { + return func_806764D8(arg0, arg1, arg2) && arg1->y_velocity < -100.0f; +} + +u8 func_80676590(Actor *arg0, Actor *arg1, s32 arg2) { + return arg0->distance_from_floor < 10.0f && arg0->y_position < arg1->y_position; +} + +u8 func_806765E8(Actor *arg0, Actor *arg1, s32 arg2) { + f32 position[3]; + + if (arg0->unkCC) { + func_80671C0C(arg0, arg0->unkCC, &position[2], &position[1], &position[0]); + } else { + position[2] = arg0->x_position; + position[1] = arg0->y_position; + position[0] = arg0->z_position; + } + + return arg1->distance_from_floor < 10.f && arg1->y_position < position[1]; +} + +u8 func_80676690(s32 arg0, s32 arg1, s32 arg2) { + return func_80676CB0(arg2, 1) && func_8067641C(arg0, arg1, arg2); +} + +u8 func_806766E0(s32 arg0, s32 arg1, s32 arg2) { + return func_80676CB0(arg2, 2) && func_8067641C(arg0, arg1, arg2); +} + +void func_80676730(s32 arg0, s32 arg1, s32 arg2) { + func_80676CB0(arg2, 1); +} + +void func_8067675C(s32 arg0, s32 arg1, s32 arg2) { + func_80676CB0(arg2, 3); +} + +void func_80676788(s32 arg0, s32 arg1, s32 arg2) { + func_80676CB0(arg2, 5); +} + +void func_806767B4(s32 arg0, s32 arg1, s32 arg2) { + func_80676CB0(arg2, 4); +} + +u8 func_806767E0(s32 arg0, s32 arg1, s32 arg2) { + return func_80676CB0(arg2, 2); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_8067680C.s") + +// CharacterChange and ActorAdditionalData struct usages +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_806769A8.s") + +/* +// TODO: beql and bnel instead of bne and beq +// Returning the conditional doesn't work +int func_806769A8(s32 arg0, Actor *arg1, s32 arg2) { + if ((arg1->unk58 == ACTOR_CHUNKY) && (character_change_array[arg1->PaaD->unk1A4].unk2C0 != 1)) { + return TRUE; + } + return FALSE; +} +*/ + +// CharacterChange and ActorAdditionalData struct usages +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676A0C.s") + +/* +// TODO: beql and bnel instead of bne and beq +// Returning the conditional doesn't work +int func_80676A0C(s32 arg0, Actor *arg1, s32 arg2) { + if ((arg1->unk58 == 5) && (character_change_array[arg1->PaaD->unk1A4].unk2C0 != 1)) { + return TRUE; + } + return FALSE; +} +*/ + +u8 func_80676A70(s32 arg0, s32 arg1, s32 arg2) { + return func_806769A8(arg0, arg1, arg2) && func_8067680C(arg0, arg1, arg2); +} + +// CharacterChange and ActorAdditionalData struct usages +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676AB8.s") + +u8 func_80676B38(Actor *arg0, void *arg1, s32 arg2) { + // Actor->isGrounded? + return func_80676AB8(arg0, arg1, arg2) && arg0->unk6A & 1; +} + +u8 func_80676B70(Actor *arg0, void *arg1, s32 arg2) { + return func_80676AB8(arg0, arg1, arg2) + && (func_80676540(arg1, arg0, arg2) + || func_80714608(0)); +} + +// CharacterChange and ActorAdditionalData struct usages +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676BCC.s") + +/* +// TODO: Regalloc +u8 func_80676BCC(s32 arg0, Actor *arg1, s32 arg2) { + PlayerAdditionalActorData *PaaD = arg1->PaaD; + u8 temp = PaaD->unk1A4; + return (character_change_array[PaaD->unk1A4].unk2C0 == 2); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676C10.s") + +/* +// TODO: Issue with func_806769A8 signature? +// TODO: Regalloc? +u8 func_80676C10(s32 arg0, Actor *arg1, s32 arg2) { + s32 phi_v1 = arg1->PaaD->unkD4 != 0 ? 1 : 0; + return phi_v1 || func_806769A8(arg0, arg1, arg2); +} +*/ + +u8 func_80676C64(s32 arg0, Actor *arg1, s32 arg2) { + if (func_80676CB0(arg2, 1) && arg1->control_state == 0x1C) { + return TRUE; + } + return FALSE; +} + +// Small struct and a loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676CB0.s") + +// CharacterChange, Player, ActorAdditionalData struct usages +// Seems doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7AF60/func_80676D00.s") diff --git a/src/global_asm/code_7BBD0.c b/src/global_asm/code_7BBD0.c new file mode 100644 index 00000000..f184f8ca --- /dev/null +++ b/src/global_asm/code_7BBD0.c @@ -0,0 +1,67 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7BBD0/func_80676ED0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7BBD0/func_80677148.s") + +// guMtxL2F, memcpy, object_timer, struct->unk88 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7BBD0/func_8067760C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7BBD0/func_806776A0.s") + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s16 unk48; // Used + s16 unk4A; + u8 unk4C; // Used +} Struct807FB5D8; + +extern Struct807FB5D8 *D_807FB5D8; + +s32 func_80677CAC(s16 arg0, s16 arg1) { + s16 phi_v0; + s16 phi_v1; + + phi_v0 = D_807FB5D8->unk48; + if (D_807FB5D8->unk4C != 0) { + phi_v0 -= 0x800; + } + if (phi_v0 < 0) { + phi_v0 += 0x1000; + } + phi_v1 = phi_v0 - arg0; + if (phi_v1 < 0) { + phi_v1 = -phi_v1; + } + if (phi_v1 >= 0x801) { + phi_v1 = 0xFFF - phi_v1; + } + if (phi_v1 < arg1) { + return TRUE; + } + return FALSE; +} + +void func_80677D58(Actor *arg0) { + func_80677CAC(arg0->y_rotation, 0x190); +} diff --git a/src/global_asm/code_7CA80.c b/src/global_asm/code_7CA80.c new file mode 100644 index 00000000..7286f51d --- /dev/null +++ b/src/global_asm/code_7CA80.c @@ -0,0 +1,1137 @@ +#include +#include "functions.h" +#include "variables.h" + +extern f64 D_80759380; +extern u8 D_807F94B4; + +extern u16 D_807FBB34; +extern u8 D_807FBC55; +extern u8 D_807FBE08; +extern u8 D_807FBE09; +extern Actor *D_807FBE10; +extern s16 D_807FBF10; + +extern u16 D_8074D624[]; +Actor *actor_list[256]; +s16 actor_count; + +s32 func_8067B2C0(s32); +void func_80678F64(Actor*); +u8 func_8066F250(Actor*, s16*, s16*, u8*); +LedgeInfo *func_80665F24(Actor*); +void func_8067B01C(void); +void func_8067B100(Actor *player); +s16 func_8067AF74(Actor*); +s32 func_806782E8(Actor *arg0); + +void func_806785D4(Actor*); +void func_80732354(s32, s32, s32, s32); +void func_80605314(Actor*, u8); +void func_8062D26C(Actor*); +void func_806783BC(); +void func_8061130C(void *); +void func_806136B4(); +void func_8066E21C(LedgeInfo*); +// void func_80679200(s32, Actor *, s32, s32, s32, s32); +// Note: The pointer can be to any one of the above 10 structs, maybe more +void func_80679200(s32, s32, s32, s32, s32, void*); +void func_8067AEFC(Actor*); +void func_8068C2F8(void *); +void func_8070DA74(void *); +void func_8071586C(Actor*); +void func_807233B4(Actor*); +void func_8072F09C(void *); + +// Pointer table 0xD (13) access, doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80677D80.s") + +void func_80677EC8(s32 arg0) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80677ED0.s") + +extern s32 (*D_8074DA30[])(void*); +extern u8 D_8074D8D4[]; + +/* +// Doable, not sure what type arg0 is +s32 func_80677ED0(void *arg0) { + s32 temp_a2; + + if (func_80678050(arg0->unk2, arg0) != 0 && ((D_8074DA30[*(&D_8074D8D4[arg0->unk0])](arg0 + 4, arg0) != 0))) { + D_807FBB44->x_position = arg0->unkC; + D_807FBB44->y_position = arg0->unk10; + D_807FBB44->z_position = arg0->unk14; + D_807FBB44->unk124 = arg0->unk1C; + D_807FBB44->y_rotation = arg0->unk18; + D_807FBB44->unk15C = arg0->unk1A; + temp_a2 = arg0->unk8; + if (temp_a2 != 0) { + func_80614EBC(D_807FBB44, temp_a2); + } + return TRUE; + } + return FALSE; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80677FA8.s") + +extern s32 func_80678050(u16); + +/* +// TODO: Regalloc +// Spawn actor and call constructor? +s32 func_80677FA8(s32 arg0, void *arg1) { + if (func_80678050(arg0) && D_8074DA30[D_8074D8D4[arg0]](&arg1)) { + return TRUE; + } + return FALSE; +} +*/ + +s32 func_80678014(s32 arg0) { + if (func_80678050(arg0)) { + func_8067B2C0(0); + return TRUE; + } + return FALSE; +} + +// Doable, initializeActor(behaviour) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80678050.s") + +void func_806782C0(Actor *arg0) { + func_806897F0(); + func_806782E8(arg0); +} + +s32 func_806782E8(Actor *arg0) { + s32 i; + + if (D_807FBE09 != 0) { + if (D_807FBF10 == 0x40) { + func_80732354(0xC, 0, 0, 0); + } + if (arg0 == current_actor_pointer) { + D_807FBE08 = 1; + } + for (i = 0; i < D_807FBF10; i++) { + if (arg0 == (&D_807FBE10)[i]) { + return FALSE; + } + } + (&D_807FBE10)[D_807FBF10] = arg0; + D_807FBF10++; + } else { + func_806785D4(arg0); + } + return TRUE; +} + +// TODO: Cleanup +void func_806783BC(void) { + s32 *var_s1; + s32 var_s0; + + var_s0 = 0; + if (D_807FBF10 > 0) { + var_s1 = &D_807FBE10; + do { + func_806785D4(*var_s1); + var_s0++; + var_s1++; + } while (var_s0 < D_807FBF10); + } + D_807FBF10 = 0; +} + +void func_80678428(Actor *arg0) { + D_807FB930[D_807FBB34].unk0 = arg0; + D_807FB930[D_807FBB34].unk4 = 0; + D_807FBB34++; +} + +void func_80678458(Actor *arg0) { + s16 i; + + func_80605314(arg0, 0); + func_80605314(arg0, 1); + // Absolutely baffling way to write this + i = 0; + while ((arg0 != D_807FB930[i].unk0) && (i < D_807FBB34)) { + i++; + } + D_807FBB34--; + if (D_807FBB34 != 0) { + D_807FB930[i].unk0 = D_807FB930[D_807FBB34].unk0; + D_807FB930[i].unk4 = D_807FB930[D_807FBB34].unk4; + } + func_8062D26C(arg0); + arg0->unk150 = NULL; +} + +void func_80678530(Actor *arg0) { + Actor *actor; + s32 i; + + D_807FBE09 = 1; + D_807FBF10 = 0; + for (i = 0; i < D_807FBB34; i++) { + actor = D_807FB930[i].unk0; + if (arg0 == actor->unk11C) { + func_806782C0(actor); + actor->unk11C = NULL; + } + } + D_807FBE09 = 0; + func_806783BC(); +} + +void func_806785D4(Actor *arg0) { + s16 i; + Actor *temp_v0; + void *temp_a0_3; + void *temp_a0_4; + void *temp_a0_5; + void *temp_a0_6; + + if (arg0->unk0 != 0) { + func_806136B4(); + } + temp_a0_6 = arg0->unk11C; + if (temp_a0_6 != 0) { + func_80679200(temp_a0_6, arg0, 0x80000, 0, 0, 0); + } + for (i = 0; i < D_807FBB34; i++) { + temp_v0 = D_807FB930[i].unk0; + if (arg0 == temp_v0->unk11C) { + temp_v0->unk11C = NULL; + } + } + func_8071586C(arg0); + func_807233B4(arg0); + func_80605314(arg0, 0); + func_80605314(arg0, 1); + // Absolutely baffling way to write this + i = 0; + while (arg0 != D_807FB930[i].unk0 && i < D_807FBB34) { + i++; + } + if (i != D_807FBB34) { + D_807FBB34--; + if (D_807FBB34 != 0) { + D_807FB930[i].unk0 = D_807FB930[D_807FBB34].unk0; + D_807FB930[i].unk4 = D_807FB930[D_807FBB34].unk4; + } + } + func_8066E21C(arg0->ledge_info_pointer); + func_8072F09C(arg0); + temp_a0_3 = arg0->unk118; + if (temp_a0_3 != NULL) { + func_8061130C(temp_a0_3); + } + temp_a0_4 = arg0->unk148; + if (temp_a0_4 != NULL) { + func_8061130C(temp_a0_4); + } + temp_a0_5 = arg0->unk14C; + if (temp_a0_5 != NULL) { + func_8061130C(temp_a0_5); + } + func_8062D26C(arg0); + if (arg0->unk58 != 0x12B) { // TODO: ACTOR_TEXTBOX, enum I guess? + func_8070DA74(arg0); + } + func_8068C2F8(arg0); + func_8067AEFC(arg0); + func_8061130C(arg0); +} + +void func_806787CC(void) { + func_80689418(); +} + +void func_806787EC(void) { + +} + +void func_806787F4(void) { + +} + +void func_806787FC(void) { + +} + +void func_80678804(void) { + +} + +void func_8067880C(void) { + +} + +void func_80678814(void) { + +} + +void func_8067881C(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80678824.s") + +/* +// TODO: This is sus +extern s8 D_807FBE09; +extern s16 D_807FBF10; +extern s32 D_807FBFE4; +extern s32 D_807FBFE0; +extern s32 D_807FBFE4; +extern s32 D_807FBFE8; +extern s32 D_807FBFEC; + +void func_80678824(void) { + D_807FBE09 = 1; + D_807FBF10 = 0; + //D_807FBFE4 = 0; + D_807FBFE0 = 0; + D_807FBFE8 = 0; + D_807FBFEC = 0; + func_8067889C(1); // updateLoadedActors()? + func_8067889C(2); // updateLoadedActors()? + func_806790F4(1); + func_80678B04(); + D_807FBE09 = 0; + func_806783BC(); + func_80679334(); +} +*/ + +// Jumptable, can auto decompile for some reason... +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_8067889C.s") + +// Jumptable, can auto decompile for some reason... +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_806789E4.s") + +void func_80678B04(void) { + Actor *temp_s0; + s32 i; + + for (i = 0; i < D_807FBB34; i++) { + temp_s0 = D_807FB930[i].unk0; + if (!(temp_s0->object_properties_bitfield & 0x08000000) && (temp_s0->object_properties_bitfield & 0x500) && (temp_s0->object_properties_bitfield & 0x4000)) { + func_80614A64(temp_s0); + } + temp_s0->object_properties_bitfield &= ~0x100; + } +} + +void func_80678BBC(Actor *arg0) { + func_806663F8(); + if (arg0->interactable & 1) { + func_8067B100(arg0); + } + arg0->unk88 = arg0->x_position; + arg0->unk8C = arg0->y_position; + arg0->unk90 = arg0->z_position; + arg0->unkBC = arg0->unkB8; + D_807F94B4 = 0; + if (arg0->ledge_info_pointer) { + arg0->ledge_info_pointer->unk68 = 0; + } + func_80678F64(arg0); + if (arg0 == D_807FBB48) { + func_80675EE0(arg0); + } else { + func_806761EC(arg0); + } + func_806794EC(arg0); + if (arg0 == D_807FBB48) { + func_806EB194(); + } + if (arg0->noclip_byte & 4) { + func_80672B1C(arg0); + } else { + if (arg0->ledge_info_pointer) { + arg0->ledge_info_pointer->unk6C = 0; + } + } + if (arg0->locked_to_pad) { + func_80669A6C(arg0); + } +} + +// TODO: Very doable, just some arrays to sort out +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80678CC8.s") + +/* +void func_80678CC8(Actor *arg0) { + u32 temp_v0; + u32 temp_v0_2; + + if (&func_8067B3F4 == ((*(&D_8074D8D4 + arg0->unk58) * 4) + 0x80750000)->unk-25D0) { + guTranslateF(&arg0->unkC, arg0->x_position, arg0->y_position, arg0->z_position); + } + func_80665FB4(arg0); + func_80678E6C(arg0); + if ((arg0->object_properties_bitfield * 0x10) >= 0) { + arg0->object_properties_bitfield &= ~0x200; + if (arg0->animation_state && ((func_8061421C(arg0), temp_v0_2 = arg0->object_properties_bitfield, ((temp_v0_2 & 0x500) != 0)) || (arg0->unk156 != 0)) && ((temp_v0_2 & 0x4000) == 0)) { + func_80614A64(arg0); + } + } + func_80678E14(arg0); + func_8066EBF4(arg0); + func_806790F4(0); + func_8067A1DC(arg0); + func_80679178(arg0); + func_80685D84(arg0); + func_80687F7C(arg0); + arg0->object_properties_bitfield |= 0x10; +} +*/ + +void func_80678DD8(Actor *arg0) { + func_8061421C(); + if (arg0->object_properties_bitfield & 0x500) { + func_80614A64(arg0); + } +} + +void func_80678E14(Actor *arg0) { + if (arg0->unk8C < arg0->y_position) { + arg0->unk9C = arg0->y_position; + return; + } + if (arg0->unk6A & 5) { + if (arg0->unk6C & 5) { + arg0->unk9C = arg0->y_position; + return; + } + arg0->unkA0 = arg0->unk9C; + } +} + +void func_80678E6C(Actor *arg0) { + u8 sp27; + + if ((arg0->noclip_byte & 4) && (D_807FBE08 == 0)) { + if (arg0->object_properties_bitfield & 0x10000) { + arg0->unkFC = 0; + arg0->unkFD = 0; + } + arg0->unkFC |= func_8066F250(arg0, &arg0->unkF4, &arg0->unkF6, &sp27); + sp27 |= D_807FBC55; + if (sp27 != 0) { + if (!(arg0->unk6A & 0x10)) { + arg0->unk6A |= 0x10; + if (arg0 == D_807FBB48) { + func_806EB0C0(4, NULL, cc_player_index); + } + } + } + if (sp27 == 0) { + arg0->unk6A &= ~0x10; + return; + } + } else { + arg0->unkFC = 0; + arg0->unkFD = 0; + arg0->unk6A &= ~0x10; + } +} + +// This matched without a temp before, now it needs one +// This compiler owns +void func_80678F64(Actor *arg0) { + Actor* temp = arg0->unk114; + if (temp) { + func_8061130C(temp); + arg0->unk114 = NULL; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80678F9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80679010.s") + +extern void* D_807FBFE0[]; + +// Several different types of structs are passed into this function +void func_80679064(void *arg0) { + s32 i = 0; + s32 found = FALSE; + + while (i < 4 && !found) { + if (!D_807FBFE0[i]) { + found = TRUE; + } else { + i++; + } + } + if (!found) { + func_80732354(0xE, 0, 0, 0); + } else { + D_807FBFE0[i] = arg0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_806790F4.s") + +// This matched without a temp before, now it needs one +// This compiler owns +// resolveActorCollisions()? +void func_80679178(Actor *arg0) { + ActorCollision *nextCollision; // TODO: Can we get rid of this somehow? + ActorCollision *currentCollision; + ActorCollision *temp; + + currentCollision = arg0->collision_queue_pointer; + if (currentCollision) { + arg0->collision_queue_pointer = NULL; + } + while (currentCollision) { + nextCollision = currentCollision->next; + temp = currentCollision->unk10; + if (temp) { + func_8061130C(temp); + } + func_8061130C(currentCollision); + currentCollision = nextCollision; + } +} + +void func_806791DC(Actor *arg0, s32 arg1) { + arg0->unk138 |= arg1; +} + +void func_806791EC(Actor *arg0, s32 arg1) { + arg0->unk138 &= ~arg1; +} + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80679200.s") + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80679290.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80679334.s") + +// TODO: What type is this actually? +typedef struct { + s32 unk0; + u8 unk4; + u8 unk5; + s16 unk6; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; +} GlobalASMStruct39; + +GlobalASMStruct39 *func_80679490(s32 arg0, s32 arg1, u8 arg2, s32 arg3, s32 arg4) { + GlobalASMStruct39 *temp_v0 = malloc(0x1C); + temp_v0->unk0 = arg1; + temp_v0->unk4 = arg2; + temp_v0->unk8 = arg0; + temp_v0->unkC = arg3; + temp_v0->unk10 = arg4; + temp_v0->unk14 = 0; + return temp_v0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_806794EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_80679DC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_8067A09C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_8067A170.s") + +/* +// TODO: Pretty close, something odd going on with the byte reads though +void func_8067A170(Actor *arg0, u8 arg1) { + s32 i; + + i = 0; + if (D_807FBB70[i].unk201 > 0) { + do { + if ((arg1 == D_807FBB70[i].unk244) && (arg0 == (D_807FBB70[i].unk204))) { + D_807FBB70[i].unk244 = 0; + } + i++; + } while (i < D_807FBB70->unk201); + } +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_8067A1DC.s") + +// TODO: What type is this actually? +typedef struct { + f32 unk0; + f32 unk4; + u8 unk8; + u8 unk9; + s16 unkA; +} GlobalASMStruct38; + +// TODO: What type is this actually? +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + u8 unkC; + u8 unkD; +} GlobalASMStruct26; + +// TODO: What type is this actually? +typedef struct { + s16 unk0; + s16 unk2; + f32 unk4; + s16 unk8; + s16 unkA; +} GlobalASMStruct27; + +// TODO: What type is this actually? +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + s32 unkC; + u8 unk10; + u8 unk11; + u8 unk12; + u8 unk13; +} GlobalASMStruct28; + +// TODO: What type is this actually? +typedef struct { + s16 unk0; + s16 unk2; + u8 pad4[0xC - 0x4]; + s32 unkC; + s32 unk10; + u8 pad14[0x30 - 0x14]; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; +} GlobalASMStruct29; + +// TODO: What type is this actually? +typedef struct { + s32 unk0; +} GlobalASMStruct30; + +// TODO: Position? +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; +} GlobalASMStruct31; + +// TODO: What type is this actually? +typedef struct { + f32 unk0; + f32 unk4; +} GlobalASMStruct32; + +// TODO: What type is this actually? +typedef struct { + s16 unk0; + s16 unk2; + f32 unk4; + s16 unk8; +} GlobalASMStruct33; + +// TODO: What type is this actually? +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + s16 unkC; + s16 unkE; +} GlobalASMStruct34; + +void func_8067A69C(s32 arg0, s32 arg1, f32 arg2, f32 arg3, u8 arg4, u8 arg5) { + GlobalASMStruct38 *temp_v0 = malloc(0xC); + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + temp_v0->unk9 = arg5; + func_80679200(arg1, arg0, 0x10, 0, 1, temp_v0); +} + +void func_8067A70C(s32 arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4, u8 arg5, u8 arg6) { + GlobalASMStruct26 *temp_v0 = malloc(0x10); + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + temp_v0->unkC = arg5; + temp_v0->unkD = arg6; + func_80679200(arg1, arg0, 0x20, 0, 1, temp_v0); +} + +void func_8067A784(s32 arg0, s32 arg1, s16 arg2, f32 arg3, s16 arg4) { + GlobalASMStruct27 *temp_v0; + + temp_v0 = malloc(0xC); + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + func_80679200(arg1, arg0, 0x4000, 0, 1, temp_v0); +} + +void func_8067A7EC(s32 arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5, u8 arg6) { + GlobalASMStruct28 *temp_v0; + + temp_v0 = malloc(0x14); + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + temp_v0->unkC = arg5; + temp_v0->unk10 = arg6; + func_80679200(arg1, arg0, 1, 0, 1, temp_v0); +} + +void func_8067A864(s32 arg0, s32 arg1, s16 arg2, s16 arg3, void *arg4, void *arg5, s32 arg6, s32 arg7, s32 arg8) { + GlobalASMStruct29 *temp_v0; + + temp_v0 = malloc(0x40); + temp_v0->unk0 = arg2; + temp_v0->unk2 = arg3; + memcpy(&temp_v0->pad4, arg4, 0xC); + memcpy(&temp_v0->unk10, arg5, 0x24); + temp_v0->unk34 = arg6; + temp_v0->unk38 = arg7; + temp_v0->unk3C = arg8; + func_80679200(arg1, arg0, 0x10000, 0, 1, temp_v0); +} + +void func_8067A908(s32 arg0, s32 arg1, void *arg2, void *arg3, s32 arg4, s32 arg5, s32 arg6) { + GlobalASMStruct29 *temp_v0; // TODO: What type is this actually? It's probably not the same struct as above since there's 0x40 vs 0x3C in the malloc call + + temp_v0 = malloc(0x3C); + memcpy(&temp_v0->unk0, arg2, 0xC); + memcpy(&temp_v0->unkC, arg3, 0x24); + temp_v0->unk30 = arg4; + temp_v0->unk34 = arg5; + temp_v0->unk38 = arg6; + func_80679200(arg1, arg0, 0x20000, 0, 1, temp_v0); +} + +void func_8067A99C(s32 arg0, s32 arg1, s32 arg2) { + GlobalASMStruct30 *temp_v0; // TODO: What type is this actually? + + temp_v0 = malloc(4); + temp_v0->unk0 = arg2; + func_80679200(arg1, arg0, 0x40000, 0, 1, temp_v0); +} + +void func_8067A9F0(s32 arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4) { + GlobalASMStruct31 *temp_v0; + + temp_v0 = malloc(0xC); + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + func_80679200(arg1, arg0, 0x100000, 0, 1, temp_v0); +} + +void func_8067AA58(s32 arg0, s32 arg1, f32 arg2, f32 arg3) { + GlobalASMStruct32 *temp_v0; + + temp_v0 = malloc(8); + temp_v0->unk0 = arg2; + temp_v0->unk4 = arg3; + func_80679200(arg1, arg0, 0x200000, 0, 1, temp_v0); +} + +void func_8067AAB8(Actor* arg0, s32 arg1, s16 arg2, f32 arg3, s16 arg4) { + GlobalASMStruct33 *temp_v0; + + temp_v0 = malloc(0xC); + temp_v0->unk4 = arg3; + temp_v0->unk8 = arg4; + temp_v0->unk0 = arg2; + func_80679200(arg1, arg0, 0x400, 0, 1, temp_v0); +} + +void func_8067AB20(s32 arg0, s32 arg1, s32 arg2, u8 arg3, void *arg4, u8 arg5) { + void *sp2C; + + sp2C = malloc(8); + memcpy(sp2C, arg4, 8); + if (arg5 == 0) { + func_80679200(arg1, arg0, arg2, arg3, 1, sp2C); + return; + } + func_80679290(arg1, arg0, arg2, arg3, 1, sp2C, 1); +} + +void func_8067ABC0(s32 arg0, s32 arg1, u8 arg2, s16 arg3, s16 arg4, f32 arg5, f32 arg6, f32 arg7) { + GlobalASMStruct34 *temp_v0; + + temp_v0 = malloc(0x10); + temp_v0->unk0 = arg5; + temp_v0->unk4 = arg6; + temp_v0->unk8 = arg7; + temp_v0->unkC = arg3; + temp_v0->unkE = arg4; + func_80679200(arg1, arg0, 0x800000, arg2, 1, temp_v0); +} + +void func_8067AC38(void) { + D_807FBB70[0].unkE5 = 0; + D_807FBB70[0].unk15 = 0; + D_807FBB70[0].unk16 = 0; + D_807FBB70[0].unk17 = 0; + D_807FBB70[0].unk18 = 0; + D_807FBB70[0].unk19 = 0; + D_807FBB70[0].unk1B = 0; + D_807FBB70[0].unk1A = 0; + D_807FBB70[0].unk1C = 0; + D_807FBB70[0].unk24 = 0; + D_807FBB70[0].unk25 = 0; + D_807FBB70[0].unk2C = 0; + D_807FBB70[0].unk38 = 0; + D_807FBB70[0].unkE4 = 0; + D_807FBB70[0].unk90 = 0; + D_807FBB70[0].unk39 = 0; + D_807FBB70[0].unk91 = 0; + D_807FBB70[0].unk1F8 = 0; + D_807FBB70[0].unk1FC = 0; + D_807FBB70[0].unk200 = 0; + D_807FBB70[0].unk201 = 0; + D_807FBB70[0].unk254 = 0; + D_807FBB70[0].unk2 = 0; + D_807FBB70[0].unk0 = 0; + D_807FBB70[0].unkE8 = 0.0f; + D_807FBB70[0].unkF0 = 0.0f; + D_807FBB70[0].unkF4 = 0.0f; +} + +void func_8067ACB4(Actor *arg0) { + arg0->unk6C = arg0->unk6A; +} + +u16 func_8067ACC0(u16 index) { + return D_8074D624[index]; +} + +s32 func_8067ACDC(Actor *arg0, u16 arg1, s32 (*arg2)(Actor *)) { + Actor *temp_a0; + s32 i; + u16 count = 0; + for (i = 0; i < D_807FBB34; i++) { + temp_a0 = D_807FB930[i].unk0; + if ((arg0 == temp_a0->unk11C) && (temp_a0->interactable == arg1) && ((arg2 == NULL) || (arg2(temp_a0) != 0))) { + count++; + } + } + return count; +} + +Actor *func_8067ADB4(u16 arg0) { + s32 i; + Actor *temp; + for (i = 0; i < D_807FBB34; i++) { + temp = D_807FB930[i].unk0; + if (temp->unk58 == arg0) { + return temp; + } + } + return NULL; +} + +s32 func_8067AE0C(Actor *arg0) { + s32 i; + Actor *temp; + + i = 0; + while (i < D_807FBB34) { + temp = D_807FB930[i].unk0; + if (arg0 == temp) { + return TRUE; + } + i++; + } + return FALSE; +} + +void func_8067AE58(void) { // clearActorList() + s32 i; + for (i = 0; i < 256; i++) { + actor_list[i] = -1; + } + actor_count = 0; +} + +void func_8067AE90(Actor *arg0) { // addActorToList() + if (actor_count < 256) { + actor_list[actor_count] = arg0; + actor_count++; + } else { + func_80732354(0x13, arg0->unk58, 0, 0); + } + func_8067B01C(); +} + +void func_8067AEFC(Actor *arg0) { + s16 temp_v0; + + temp_v0 = func_8067AF74(arg0); + if (temp_v0 != -1) { + actor_list[temp_v0] = -1; + func_8067B01C(); + } +} + +s32 func_8067AF44(Actor *arg0) { + if (func_8067AF74(arg0) != -1) { + return TRUE; + } + return FALSE; +} + +s16 func_8067AF74(Actor *arg0) { + s16 earlyIndex; + s16 lateIndex; + s16 combinedIndex; + + earlyIndex = 0; + lateIndex = actor_count - 1; + if (actor_count == 0) { + return -1; + } + combinedIndex = lateIndex; + if (-1 < lateIndex) { + while (TRUE) { + combinedIndex = earlyIndex + lateIndex >> 1; + if (arg0 == actor_list[combinedIndex]) { + return combinedIndex; + } + if (arg0 < actor_list[combinedIndex]) { + lateIndex = combinedIndex - 1; + } else { + earlyIndex = combinedIndex + 1; + } + if (lateIndex < earlyIndex) { + break; + } + } + } + return -1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_8067B01C.s") + +/* +// TODO: WIP, seems to be removing gaps in the actor list? +// Original output is below this implementation +void func_8067B01C(void) { + Actor *temp_a1; + s32 temp_a0_2; + s32 temp_a3; + s32 phi_v1; + u32 phi_t0; + s32 phi_a3; + s32 phi_a3_2; + s32 phi_v0; + + phi_v0 = FALSE; + phi_v1 = 1; + + if (actor_count >= 2) { + do { + temp_a1 = actor_list[phi_v1]; + phi_a3 = phi_v1; + if ((s32)actor_list[phi_v1] < (s32)actor_list[phi_v1 - 1]) { + phi_t0 = actor_list[phi_v1 - 1]; + do { + phi_t0 = actor_list[phi_a3 - 1]; + phi_a3--; + } while ((s32)actor_list[phi_a3] < (s32)actor_list[phi_a3 - 1]); + } + actor_list[phi_a3] = actor_list[phi_v1]; + phi_v1++; + } while (phi_v1 < actor_count); + } + + // This part looks fine :) + actor_count = 0; + do { + if ((s32)actor_list[actor_count] == -1) { + phi_v0 = TRUE; + } else { + actor_count++; + } + } while (!phi_v0); +} +*/ + +/* +void func_8067B01C(void) { + Actor **temp_a2; + Actor **temp_a2_2; + Actor **temp_a2_3; + Actor *temp_a1; + s16 temp_a0; + s16 temp_a0_2; + s16 temp_a3; + s16 temp_v1; + u32 temp_t0; + s16 phi_v1; + u32 phi_t0; + Actor **phi_a2; + s16 phi_a3; + s16 phi_a3_2; + s32 phi_v0; + + temp_a0 = actor_count; + phi_v1 = 1; + phi_v0 = 0; + if (temp_a0 >= 2) { + do { + temp_a2 = &actor_list[phi_v1]; + temp_a1 = temp_a2->unk0; + phi_a3 = phi_v1; + phi_a3_2 = phi_v1; + if (temp_a1 < temp_a2->unk-4) { + temp_a2_2 = &actor_list[phi_v1]; + phi_t0 = temp_a2_2->unk-4; + phi_a2 = temp_a2_2; + do { + temp_a3 = phi_a3 - 1; + *phi_a2 = phi_t0; + temp_a2_3 = &actor_list[temp_a3]; + temp_t0 = temp_a2_3->unk-4; + phi_t0 = temp_t0; + phi_a2 = temp_a2_3; + phi_a3 = temp_a3; + phi_a3_2 = temp_a3; + } while (temp_a1 < temp_t0); + } + temp_v1 = phi_v1 + 1; + actor_list[phi_a3_2] = temp_a1; + phi_v1 = temp_v1; + } while (temp_v1 < temp_a0); + } + actor_count = 0; + do { + temp_a0_2 = actor_count; + if (actor_list[temp_a0_2] == -1) { + phi_v0 = 1; + } else { + actor_count = temp_a0_2 + 1; + } + } while (phi_v0 == 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_7CA80/func_8067B100.s") + +extern s32 D_807ECDEC; +extern u16 D_807ECDF0; +extern CharacterProgress *D_807FD568; +extern s16 D_807FD584; + +/* +// TODO: Very close +void func_8067B100(Actor *player) { + extra_player_info_pointer = player->PaaD; + cc_player_index = extra_player_info_pointer->unk1A4; + D_807FBB48 = character_change_array[cc_player_index].player_pointer; + D_807FD568 = &D_807FC950[cc_player_index].character_progress[current_character_index[cc_player_index]]; + D_807ECDEC = character_change_array[cc_player_index].unk294; + D_807ECDF0 = character_change_array[cc_player_index].new_controller_inputs; + D_807FD584 = D_8075C410[current_character_index[cc_player_index]].unk4; + character_change_array[cc_player_index].unk2C1 = 0; +} +*/ + +u8 func_8067B1E0(Actor *arg0) { + s32 i; + for (i = 0; i < cc_number_of_players; i++) { + if (character_change_array[i].does_player_exist && (arg0 == character_change_array[i].player_pointer)) { + return i; + } + } + return 0; +} + +void func_8067B238(Actor *destination, Actor *source, f32 scale) { + destination->x_position = source->x_position; + destination->y_position = source->y_position; + destination->z_position = source->z_position; + destination->y_rotation = source->y_rotation; + if (destination->animation_state) { + destination->animation_state->scale_x = scale; + destination->animation_state->scale_y = scale; + destination->animation_state->scale_z = scale; + } +} + +void func_8067B280(void) { + +} + +void func_8067B288(void) { + +} + +void func_8067B290(void) { + +} + +void func_8067B298(void) { + +} + +void func_8067B2A0(void) { + +} + +void func_8067B2A8(void) { + +} + +void func_8067B2B0(s32 arg0) { + +} + +void func_8067B2B8(s32 arg0) { + +} + +s32 func_8067B2C0(s32 arg0) { + D_807FBB44->noclip_byte = 1; + return 1; +} + +// TODO: arg0 is probably not an actor spawner, it just so happened to have a u16 at unk2 for the match +s32 func_8067B2DC(ActorSpawner *arg0) { + if (func_806134B4(D_807FBB44, arg0->unk2, arg0)) { + D_807FBB44->ledge_info_pointer = func_80665F24(D_807FBB44); + D_807FBB44->unk15E = D_807FBB44->ledge_info_pointer->unkC * D_80759380 * 0.5; + return TRUE; + } + return FALSE; +} + +s32 func_8067B3F4(s32 arg0) { + D_807FBB44->ledge_info_pointer = func_80665F24(D_807FBB44); + return 1; +} + +s32 func_8067B42C(s32 arg0) { + D_807FBB44->object_properties_bitfield |= 0x2000; + return 1; +} diff --git a/src/global_asm/code_80150.c b/src/global_asm/code_80150.c new file mode 100644 index 00000000..a45f33b1 --- /dev/null +++ b/src/global_asm/code_80150.c @@ -0,0 +1,584 @@ +#include +#include "functions.h" +#include "variables.h" + +f32 func_80612794(s32); +void func_8065D254(Actor*, s32, s32, s32, s32, s32, s32, s32, s32, s32, f32); +void func_80665564(Actor*, f32); +void func_8067AAB8(Actor* arg0, s32 arg1, s16 arg2, f32 arg3, s16 arg4); +void func_8067ACB4(Actor*); +void func_8067DF44(f32, f32, f32, f32, u8, u8); +void func_80683AD8(); + +extern f64 D_80759560; +extern s32 D_8071FC8C; + +typedef struct { + u16 unk0; + u8 unk2; // Actor Spawner ID + u8 unk3; + s16 unk4; // Permanent Flag Index +} GlobalASMStruct47; + +extern GlobalASMStruct47 D_8074E7A0[]; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067B450.s") + +/* +// Don't know what this needs, our stack is too big though +u8 func_8067B450(void) { + s32 i; + for (i = 0; i < 4; i++) { + if ((current_map == D_8074E7A0[i].unk0) && (func_80688E68(4) == D_8074E7A0[i].unk2)) { + return isFlagSet(D_8074E7A0[i].unk4, FLAG_TYPE_PERMANENT); + } + } + return 0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067B4C8.s") + +void func_8067BA3C() { + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->draw_distance = 2000; + } + func_8067B4C8(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067BA7C.s") + +void func_8067BC68(void) { + func_8067BA7C(0x13); +} + +void func_8067BC88(void) { + func_8067BA7C(0x13); +} + +void func_8067BCA8(void) { + func_8067BA7C(0x13); +} + +void func_8067BCC8(void) { + func_8067BA7C(0x13); +} + +void func_8067BCE8(void) { + func_8067BA7C(0x13); +} + +void func_8067BD08(void) { + func_8067BA7C(0x13); +} + +void func_80689114(s32, f32, f32, f32, s32, f32, Actor *); +extern u8 D_807FBBA8; + +void func_8067BD28(void) { + s32 phi_v1; + PlayerAdditionalActorData *PaaD = player_pointer->PaaD; + + phi_v1 = FALSE; + if (D_807FBBA8 && (PaaD->unk1F0 & 0x200000)) { + phi_v1 = TRUE; + } + if (((current_actor_pointer->object_properties_bitfield & 0x10) == 0) || (phi_v1 != 0)) { + func_80689114(0x55, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0, 1.0f, current_actor_pointer); + } +} + +void func_80665564(Actor*, f32); + +void func_8067BDB8() { + func_8067BA7C(0x95); + func_80665564(current_actor_pointer, 0.0f); + current_actor_pointer->y_position = current_actor_pointer->floor; +} + +void func_8067BDF8() { + s8 sp1F; + s32 temp_a1; + + sp1F = 0; + // TODO: Which aaD type are they actually expecting here? + temp_a1 = current_actor_pointer->PaaD; + func_8067BF84(0x13, temp_a1, temp_a1 + 1, &sp1F); +} + +// Doable, needs some solid aaD knowledge though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067BE30.s") + +void func_8067BF4C() { + s32 temp_v0; + + // TODO: Which aaD type are they actually expecting here? + temp_v0 = current_actor_pointer->PaaD; + func_8067BF84(0x1A, temp_v0 + 2, temp_v0 + 3, temp_v0 + 4); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067BF84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067C2B8.s") + +void func_8067C67C(void) { + func_8067C71C(); +} + +void func_8067C69C(void) { + func_8067C71C(); +} + +void func_8067C6BC(void) { + func_8067C71C(); +} + +void func_8067C6DC(void) { + func_8069B908(); +} + +void func_8067C6FC(void) { + func_8067C71C(); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067C71C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067DCC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067DF44.s") + +void func_8067E278(u8 arg0, u8 arg1) { + func_8067DF44(current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position, + current_actor_pointer->animation_state->scale_y / D_80759560, + arg0, + arg1); +} + +void func_8067E2E4(s32 arg0, u8 arg1, f32 arg2) { + f32 sp2C, sp28, sp24; + + func_80671C0C(current_actor_pointer, arg1, &sp2C, &sp28, &sp24); + func_8067DF44(sp2C, sp28, sp24, arg2, 0, 1); +} + +void func_8067E348(void) { + OtherAdditionalActorData *temp_v0; + + temp_v0 = current_actor_pointer->OaaD; + current_actor_pointer->animation_state->scale_x = temp_v0->unkC; + current_actor_pointer->animation_state->scale_y = temp_v0->unkC; + current_actor_pointer->animation_state->scale_z = temp_v0->unkC; + current_actor_pointer->y_position = temp_v0->unk14; + temp_v0->unk8 = 0; + temp_v0->unk18 = 0; + temp_v0->unk10 = temp_v0->unkC; + current_actor_pointer->control_state = 0; + current_actor_pointer->noclip_byte = 2; + current_actor_pointer->object_properties_bitfield &= ~0x200000; +} + +void func_8067E3D0(void) { + func_8067E348(); + current_actor_pointer->control_state = 0x14; + current_actor_pointer->noclip_byte = 1; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->shadow_opacity = 0; + func_806F8D58(5, 0); +} + +// Might use CharacterChange ptr +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067E43C.s") + +void func_8067E4D4() { + func_8067E784(); + if (current_actor_pointer->control_state == 0) { + func_8067E43C(); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067E510.s") + +void func_8067E69C() { + func_8067E784(); + func_8067E43C(); +} + +void func_8067E6C4() { + func_8067E784(); +} + +void func_8067E6E4() { + func_8067E784(); +} + +void func_8067E704() { + func_8067E784(); +} + +void func_8067E724() { + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + current_actor_pointer->draw_distance = 800; + } + func_8067E784(); +} + +void func_8067E764(void) { + func_8067E784(); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067E784.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067FAC8.s") + +/* +// TODO: Doable, but fiddly, good clues on D_807FBB70 shape +void func_8067FAC8(void) { + s16 phi_s0; + + for (phi_s0 = 0; phi_s0 < D_807FBB70[0].unk254; phi_s0++) { + if ((D_807FBB70[phi_s0].unk258 == 1) && (D_807FBB70[phi_s0].unk278 == 1)) { + func_8067DCC0(); + func_806782C0(current_actor_pointer); + } + } +} +*/ + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8067FB6C.s") + +void func_80680774(void) { + if ((character_change_array->unk2C0 != 1) || (((extra_player_info_pointer->unk1F4 & 0x40) != 0)) || (((current_character_index[0] >= 5)))) { + current_actor_pointer->unk132 = 4; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->shadow_opacity = 0x7F; + } else if ((character_change_array->unk2C0 == 1) && ((extra_player_info_pointer->unk1F0 & 0x40) == 0) && (current_character_index[0] < 5)) { + current_actor_pointer->object_properties_bitfield |= 0x8000; + current_actor_pointer->unk132 = 1; + } + if (extra_player_info_pointer->unkCA != 0) { + current_actor_pointer->unk132 = 4; + } +} + +void func_8068086C() { + if (current_character_index[0] >= 5) { + current_actor_pointer->unk132 = 4; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->shadow_opacity = 0x7F; + } else { + current_actor_pointer->object_properties_bitfield |= 0x8000; + current_actor_pointer->unk132 = 1; + } + if (extra_player_info_pointer->unkCA != 0) { + current_actor_pointer->unk132 = 4; + } +} + +u8 func_80680908(void) { + u8 phi_v1 = 0x64; + switch (current_map) { + case MAP_FACTORY: + if (func_80688E68(current_actor_pointer) == 0xD + || func_80688E68(current_actor_pointer) == 0xF) { + phi_v1 = 2; + } + break; + case MAP_FUNGI_DK_BARN: + if (func_80688E68(current_actor_pointer) == 3) { + phi_v1 = 2; + } + break; + case MAP_FUNGI: + if (func_80688E68(current_actor_pointer) == 0x12) { + phi_v1 = 2; + } + break; + case MAP_AZTEC_LOBBY: + case MAP_DK_ISLES_SNIDES_ROOM: + phi_v1 = 2; + break; + } + return phi_v1; +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_806809F0.s") + +// Doable and interesting, reading which flag to set from an array +// Just needs some patience, energy, and a defintion for unkD in an aaD +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80681B14.s") + +// Similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80681BD8.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80681E18.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_806822FC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80682AB4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80682DF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80682E38.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_8068304C.s") + +/* +extern ? D_8074E834; + +void func_8068304C(void) { + ? sp2C; + void *sp28; + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + sp2C.unk0 = D_8074E834.unk0; + sp2C.unk4 = D_8074E834.unk4; + sp2C.unk8 = D_8074E834.unk8; + sp2C.unkC = D_8074E834.unkC; + sp2C.unk10 = D_8074E834.unk10; + sp28 = current_actor_pointer->additional_actor_data; + current_actor_pointer->object_properties_bitfield |= 0x1000; + func_8068842C(current_actor_pointer, 0, 1); + func_80688460(current_actor_pointer, 0, 1); + func_806883F4(current_actor_pointer, 0, (sp + (*sp28 * 4))->unk2E, 0); + func_80614EBC(current_actor_pointer, 0x329); + } + current_actor_pointer->unk16D = current_actor_pointer->unk15F; + current_actor_pointer->y_rotation += 0x32; + current_actor_pointer->y_rotation &= 0xFFF; + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Function pointer in a local variable, needs some PaaD untangling +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80683158.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_806832F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_806833DC.s") + +/* +// Needs some PaaD untangling I think +// Switch case for control_state_progress? +void func_806833DC(YetAnotherAdditionalActorData *arg0) { + void *sp34; + void *sp30; + s32 sp28; + s32 sp20; + s16 temp_v0_3; + s16 temp_v0_4; + u16 temp_v0_2; + u8 temp_v0; + Actor *temp_a0; + void *temp_a1; + Actor *temp_t1; + void *temp_v0_5; + s32 phi_v0; + s32 phi_a1; + + temp_v0 = current_actor_pointer->control_state_progress; + if (temp_v0 != 0) { + if (temp_v0 != 1) { + if (temp_v0 != 0xA) { + if ((temp_v0 == 0xB) && (func_8061CB50(¤t_actor_pointer) == 0)) { + current_actor_pointer->noclip_byte = 2; + current_actor_pointer->control_state_progress = 0; + } + } else { + goto block_6; + } + } else { + temp_v0_2 = arg0->unk4; + if (temp_v0_2 != 0) { + arg0->unk4 = temp_v0_2 - 1; + return; + } + temp_a0 = arg0->unk0; + temp_v0_3 = temp_a0->unk12C; + temp_a1 = temp_a0->unk174; + phi_v0 = temp_v0_3; + if (temp_v0_3 == -1) { + phi_v0 = 0; + } + sp28 = phi_v0; + sp34 = temp_a0; + sp30 = temp_a1; + func_806C93E4(temp_a0, temp_a1, ¤t_actor_pointer); + func_806C9304(arg0->unk0, temp_a1); + sp20 = phi_v0; + func_80659620(&arg0->unk2C, &arg0->unk30, &arg0->unk34, phi_v0); + func_80659670(1.0f, 1.0f, 1.0f, sp20); + current_actor_pointer->y_rotation = arg0->unk22; + current_actor_pointer->noclip_byte = 1; + temp_v0_4 = sp34->unk5A; + global_properties_bitfield &= 0xFFFCFFCF; + arg0->unk6 = 0; + if (temp_v0_4 != (&D_8074E814 + (arg0->unk6 * 6))->unk2) { + do { + arg0->unk6 = arg0->unk6 + 1; + } while (temp_v0_4 != (&D_8074E814 + (arg0->unk6 * 6))->unk2); + } + arg0->unk7 = arg0->unk6; + phi_a1 = arg0->unk6; + if (current_map != MAP_HELM) { + playSong(0x65, 1.0f); + func_80602CE0(0x65, 0x7E - *(&D_8074E848 + (arg0->unk6 * 4)), 1); + phi_a1 = arg0->unk6; + } + setFlag(func_805FF018(current_actor_pointer->unk58, phi_a1), TRUE, FLAG_TYPE_PERMANENT); + func_80682E38(arg0); + func_80627878(sp30->unk104); + arg0->unk38 = sp34->unkE6; + sp34->unkE6 = current_actor_pointer->y_rotation; + func_8060DEC8(); // saveTheGame() + playCutscene(current_actor_pointer, 0xE, 0xC); + func_8061B650(sp30->unk104); + func_806FB218(); + current_actor_pointer->control_state = 1; + current_actor_pointer->control_state_progress = 0; + } + } else { +block_6: + if (D_807FBB70->unk200 == 4) { + temp_t1 = D_807FBB70->unk1FC; + arg0->unk0 = temp_t1; + temp_t1->unk144 = 1; + temp_v0_5 = arg0->unk0->unk174; + temp_v0_5->unk1F0 |= 0x20000000; + current_actor_pointer->control_state_progress = 1; + arg0->unk4 = 2; + arg0->unk3C = 0; + } + } +} +*/ + +// Doable, might need some structs? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_806836D0.s") + +// Doable, needs some structs +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80683A80.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_80150/func_80683AD8.s") + +typedef struct { + s16 unk0; + s16 unk2; + u8 unk4; // Used + u8 unk5; +} GlobalASMStruct45; + +extern GlobalASMStruct45 D_8074E814[]; + +void func_8068408C(Actor *arg0) { + s32 kongIndex; + + for (kongIndex = 0; kongIndex < 5; kongIndex++) { + if (isFlagSet(func_805FF018(arg0->unk58, kongIndex), FLAG_TYPE_PERMANENT)) { + func_8068A764(arg0, D_8074E814[kongIndex].unk4); + } + } +} + +void func_8068412C(void) { + YetAnotherAdditionalActorData *YaaD; + + YaaD = current_actor_pointer->YaaD; + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + YaaD->unk22 = current_actor_pointer->y_rotation; + YaaD->unk24 = current_actor_pointer->y_position; + current_actor_pointer->unk146 = 0; + current_actor_pointer->unk15E = 0; + func_80714998(2); + func_807149FC(-1); + func_807149B8(1); + func_807149A8(1000); + func_80714A28(4); + func_80714CC0(&D_8071FC8C, + 1.3f, + current_actor_pointer->x_position, + current_actor_pointer->y_position + 13.0, + current_actor_pointer->z_position); + if (func_80689F2C()) { + current_actor_pointer->draw_distance = 2000; + } else { + current_actor_pointer->draw_distance = 350; + } + current_actor_pointer->floor = current_actor_pointer->y_position; + func_80665564(current_actor_pointer, 0.0f); + current_actor_pointer->locked_to_pad = 0; + current_actor_pointer->object_properties_bitfield |= 2; + } + func_8068408C(current_actor_pointer); + func_80680774(); + func_8067ACB4(current_actor_pointer); + + switch (current_actor_pointer->control_state) { + case 0: + if (YaaD->unk4) { + YaaD->unk4--; + if (!YaaD->unk4) { + current_actor_pointer->noclip_byte = 2; + } + } else { + func_806833DC(YaaD); + } + if (current_actor_pointer->control_state_progress == 0xA) { + if ((player_pointer->unk6A & 4) || func_806C9D7C()) { + current_actor_pointer->control_state_progress = 0; + } else { + if ((player_pointer->locked_to_pad != 1) && (player_pointer->unk6A & player_pointer->unk6C & 1)) { + func_806832F4(player_pointer->unk58, 1); + } + } + } + break; + case 1: + func_806836D0(YaaD); + func_8068C350(&func_80683AD8, current_actor_pointer, 3); + break; + case 2: + if (YaaD->unk4) { + YaaD->unk4--; + } else { + func_8067AAB8(current_actor_pointer, YaaD->unk0, YaaD->unk38, 180.0f, 0x46); + func_80679200(YaaD->unk0, current_actor_pointer, 0x40, 1, 0, 0); + func_806FB2B8(); + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + if (func_806832F4(player_pointer->unk58, 0)) { + current_actor_pointer->control_state_progress = 0xA; + } + YaaD->unk4 = 0x1E; + } + break; + } + func_8065D254(current_actor_pointer, 0x3C8, 0x40, 0x40, 0x1E, 0x1E, 1, 0x64, 0x78, 0, 1.0f); + if (current_actor_pointer->control_state != 1) { + current_actor_pointer->y_rotation += 0x32; + current_actor_pointer->y_rotation &= 0xFFF; + current_actor_pointer->y_position = func_80612794(YaaD->unk28) * 5.0f + YaaD->unk24; + YaaD->unk28 += 0x32; + YaaD->unk28 &= 0xFFF; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806844EC() { + func_8068412C(); +} + +void func_8068450C() { + func_8068412C(); +} + +void func_8068452C() { + func_8068412C(); +} \ No newline at end of file diff --git a/src/global_asm/code_89250.c b/src/global_asm/code_89250.c new file mode 100644 index 00000000..a93e1f0f --- /dev/null +++ b/src/global_asm/code_89250.c @@ -0,0 +1,575 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_80717D4C; +extern s32 D_80717930; +extern s32 D_80718BF4; +extern s32 D_807197B4; +extern s32 D_8071827C; +extern s32 D_80719B88; +extern s32 D_80719C00[]; +extern s32 D_8071AF30; +extern s32 D_8071EFDC; +extern s32 D_8071FC40; +extern s32 D_8071FF18; +extern s32 D_8071FF40; +extern s32 D_8071FF58; +extern s32 D_8071FFA0; +extern s32 *D_8072006C; +extern s32 D_80720120; +extern s32 D_80720558; +extern s32 D_807210EC; +extern s32 D_80721158; +extern s32 D_8072139C; + +extern s32 D_8074E880[]; +extern u8 D_80750AD0; +extern f64 D_80759AB8; +extern f64 D_80759AC0; +extern f64 D_80759AB0; +extern f64 D_80759A90; +extern f64 D_80759A98; +extern f64 D_80759AA0; +extern f64 D_80759AA8; +extern f64 D_80759B60; // y +extern f64 D_80759B70; +extern f64 D_80759B68; + +void func_80677FA8(s32, s32); // spawnActorWrapper() +void func_80719A0C(void); // Function pointer +void func_8068588C(Actor *arg0, s16 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6); +void func_806858E8(Actor*, s16, f32, f32, f32, f32, s32); +void func_80686390(Actor*, f32, f32, f32, f32); +void func_80685F60(Actor *actor); +void func_80714C08(s32*, f32, Actor*, s32, s32); +void func_8068588C(Actor*, s16, f32, f32, f32, f32, s32); +void func_80714998(s32); + +void func_80684550(s32 arg0, u8 arg1, f32 arg2) { + func_807149B8(1); + func_8071498C(&D_8071AF30); + func_80714950(arg0); + func_80714A28(4); + func_80714C08(&D_80720120, arg2, current_actor_pointer, arg1, 0); +} + +void func_806845B8(u8 arg0, u8 arg1) { + f32 sp2C; + u8 sp2B; + + if ((object_timer & 3) == 0) { + sp2C = current_actor_pointer->animation_state->scale_y / D_80759A90; + sp2B = (((rand() >> 0xF) % 0x7FFF) % ((arg1 - arg0) + 1)) + arg0; + func_80714998(3); + func_807149C8(0xE6, 0xE6, 0xE6, 0xE6); + func_8068588C(current_actor_pointer, sp2B, sp2C, 0.0f, 0.0f, 0.0f, -0x78); + } +} + +// spawnShockwave(xPosition, yPosition, zPosition, xzScale, yScale, parentActor, arg6) +void func_806846B4(f32 xPosition, f32 yPosition, f32 zPosition, f32 xzScale, f32 yScale, Actor *arg5, u8 arg6) { + s32 phi_a1; + + phi_a1 = 0xAD; + if (arg5) { + switch (arg5->unk58) { + case ACTOR_TINY: + case 0xF4: // TODO: ACTOR_KASPLAT_TINY + phi_a1 = 0xD1; + break; + case ACTOR_LANKY: + case 0xF3: // TODO: ACTOR_KASPLAT_LANKY + phi_a1 = 0xD0; + break; + case ACTOR_CHUNKY: + case 0xF5: // TODO: ACTOR_KASPLAT_CHUNKY + phi_a1 = 0xCF; + break; + case ACTOR_DIDDY: + case 0xF2: // TODO: ACTOR_KASPLAT_DIDDY + phi_a1 = 0xAE; + break; + } + } + func_80677FA8(0xFF, phi_a1); // Spawn actor: Shockwave + D_807FBB44->unk11C = arg5; + D_807FBB44->animation_state->scale_x = xzScale; + D_807FBB44->animation_state->scale_z = xzScale; + D_807FBB44->animation_state->scale_y = yScale; + D_807FBB44->x_position = xPosition; + D_807FBB44->y_position = yPosition; + D_807FBB44->z_position = zPosition; + if (arg5 && (arg5->interactable & 1)) { + if (arg6) { + D_807FBB44->unk168 = 0xF; + D_807FBB44->unk160 = D_80759A98; + D_807FBB44->unk15F = 1; + } else { + D_807FBB44->unk168 = 0x19; + D_807FBB44->unk160 = D_80759AA0; + } + } else { + D_807FBB44->unk168 = 0x20; + D_807FBB44->unk160 = D_80759AA8; + D_807FBB44->unk15F = 0; + } +} + +void func_80684850(u8 arg0) { + if ((object_timer & 0x1F) == 0) { + func_80714998(2); + func_807149B8(1); + func_807149FC(0x3C); + func_8071498C(&D_807197B4); + if (arg0) { + func_80714C08(&D_8071FF58, 0.05f, current_actor_pointer, arg0, 0); + return; + } + func_80714CC0(&D_8071FF58, 0.05f, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position); + } +} + +void func_80684900(u8 arg0) { + if (arg0 != 0) { + func_80714950(((rand() >> 0xF) % 10) + 0x8008); + } else { + func_80714950(((rand() >> 0xF) % 8) + 6); + } + func_807149FC(2); + func_8071498C(&D_80717930); + func_807149B8(1); + func_80714A28(4); + func_80714C08(&D_8072139C, (((rand() >> 0xF) % 50) / 80.0) + D_80759AB0, current_actor_pointer, 8, 0); +} + +void func_80684A00(s16 arg0, s8 arg1) { + f32 sp3C, sp38, sp34, sp30; + + sp30 = current_actor_pointer->animation_state->scale_y / D_80759AB8; + func_80671C0C(current_actor_pointer, arg0, &sp3C, &sp38, &sp34); + func_80714950((((rand() >> 0xF) % 100) + 400) * arg1); + func_8071498C(&D_80717D4C); + func_807149B8(1); + func_80714CC0(D_8074E880[((rand() >> 0xF) % 1000) % 3], + sp30 * D_80759AC0, + ((rand() >> 0xF) % 20) + (sp3C - 10.0f), + sp38, + ((rand() >> 0xF) % 20) + (sp34 - 10.0f) + ); +} + +// Similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80684BB0.s") + +extern f64 D_80759AC8; +extern f64 D_80759AD0; +extern f64 D_80759AD8; +extern s32 D_8071F2F8; + +/* +void func_80684BB0(s16 arg0, s16 arg1, s16 arg2) { + f32 sp54; + f32 sp50; + f32 sp4C; + f32 sp48; + s32 temp; // Padding, TODO: Can we get rid of this? + f64 temp_f0; + f64 phi_f2; + + sp48 = current_actor_pointer->animation_state->scale_y / D_80759AC8; + func_80671C0C(current_actor_pointer, arg0, &sp54, &sp50, &sp4C); + func_80714950(arg1 + (arg2 << 0x10)); + func_8071498C(&D_8071F2F8); + func_807149B8(1); + temp_f0 = arg2 * D_80759AD0; + if (temp_f0 < 2.0) { + phi_f2 = 2.0; + } else { + phi_f2 = temp_f0; + } + func_807149FC(0, phi_f2); // TODO: This might be wrong + func_80714CC0( + D_8074E880[((rand() >> 0xF) % 1000) % 3], + sp48 * D_80759AD8, + ((rand() >> 0xF) % 60) + (sp54 - 30.0f), + sp50, + ((rand() >> 0xF) % 60) + (sp4C - 30.0f) + ); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80684D98.s") + +void func_80685020(u8 arg0, u8 arg1) { + if ((arg0 & object_timer) == 0) { + func_8071498C(&D_80718BF4); + func_807149B8(1); + func_807149FC(-1); + func_80714A28(4); + if (arg1) { + func_80714C08(&D_8071FC40, 0, current_actor_pointer, arg1, 0); + return; + } + func_80714CC0(&D_8071FC40, 0, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_806850D0.s") + +/* +extern s32 D_8071FE08; +extern f64 D_80759AE8; +extern f64 D_80759AE0; +extern s32 D_8071910C; +extern s32 D_8072073C; + +void func_806850D0(void) { + f32 temp_f20; + s32 temp_s0; + + temp_f20 = current_actor_pointer->animation_state->scale_y / D_80759AE0; + func_807149B8(0); + func_807149FC(1); + func_80714CC0(&D_8071FE08, + temp_f20 * 0.75, + current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position + ); + for (temp_s0 = 0; temp_s0 < 7; temp_s0++) { + func_807149B8(1); + func_807149FC(0xA); + func_8071498C(&D_8071910C); + func_80714998(2); + func_80714950(0); + func_80714CC0(&D_8072073C, + temp_f20 * D_80759AE8, + current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position + ); + } +} +*/ + +void func_80685210(f32 arg0, s16 arg1, s16 arg2) { + if ((((u32) object_timer % 3) == 0) && (arg1 < current_actor_pointer->unkB8)) { + func_80714998(2); + func_807149B8(1); + func_8071498C(&D_80717D4C); + func_80714950(-0x32); + func_80714A28(4); + func_80714C08(&D_8071FF18, arg0, current_actor_pointer, arg2, 0); + } +} + +void func_806852C4(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + s16 phi_s0; + + for (phi_s0 = 0; phi_s0 < 8; phi_s0++) { + func_8071498C(&func_80719A0C); + func_80714950(phi_s0); + func_807149B8(1); + func_807149C8(0xFF, 0xFF, 0xFF, 0xC8); + func_80714CC0(&D_8071FFA0, arg0, arg1, arg2, arg3); + } +} + +// Doable, just gotta figure out a struct/array on the stack +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80685390.s") + +void func_80685520(f32 arg0, u8 arg1, f32 arg2, f32 arg3, f32 arg4) { + s32 temp_s0; + s32 phi_s0; + + if (D_80750AD0 == 0) { + if (arg1 > 0) { + func_806852C4(arg0, arg2, arg3, arg4); + } + if (arg1 >= 2) { + temp_s0 = &D_80719B88; + for (phi_s0 = 0; phi_s0 < 8; phi_s0++) { + func_8071498C(temp_s0); + func_80714950(phi_s0); + func_807149B8(1); + func_807149FC(-1); + func_807149C8(0xFF, 0xFF, 0xFF, 0xFF); + func_80714CC0(&D_8071FF40, arg0 * 0.5, arg2, arg3, arg4); + } + } + if (arg1 >= 3) { + temp_s0 = &D_80719C00; + for (phi_s0 = 0; phi_s0 < 9; phi_s0++) { + func_8071498C(temp_s0); + func_80714950(phi_s0); + func_807149B8(1); + func_807149FC(-1); + func_807149C8(0xFF, 0xFF, 0xFF, 0xFF); + func_80714CC0(D_8074E880[phi_s0 % 3], arg0, arg2, arg3, arg4); + } + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80685708.s") + +void func_8068581C(s32 arg0, s16 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6) { + func_80714998(2); + func_807149C8(0xFF, 0xFF, 0xFF, 0xC8); + func_8068588C(arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +void func_8068588C(Actor *arg0, s16 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6) { + func_807149B8(1); + func_806858E8(arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +// Returns struct from function call in a weird way... Doable once we figure out which struct is returned. +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_806858E8.s") + +// Surprisingly doable, just a huge function call that will be interesting to decipher +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80685984.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80685B44.s") + +extern s32 D_807180F4; // TODO: Datatype, just for pointer + +void func_8071496C(u16); + +/* +// TODO: Pretty close +void func_80685B44(void *arg0, s32 arg1, f32 arg2, u8 arg3, u8 arg4, s16 arg5, s16 arg6, s16 arg7, s16 arg8) { + s8 temp_s0; + s8 temp_s4; + s16 i; + + for (i = 0; i < arg3; i++) { + temp_s4 = (((rand() >> 0xF) % 32767) % (arg4 * 2)) + -arg4; + temp_s0 = (((rand() >> 0xF) % 32767) % (arg4 * 2)) + -arg4; + func_80714950(-arg5 - ((rand() >> 0xF) % 80)); + func_8071498C(&D_807180F4); + func_807149B8(1); + func_80714998(2); + if (arg1 != 0) { + func_8071496C(arg1); + } + func_80714CC0(arg0, arg2, arg6 + temp_s4, arg7, arg8 + temp_s0); + } +} +*/ + +void func_80685D84(Actor *arg0) { + if (!(arg0->unk64 & 4)) { + if ((arg0->object_properties_bitfield & 0x10) && ((arg0->unk6A ^ arg0->unk6C) & 4)) { + func_80686390(arg0, 0, arg0->x_position, arg0->unkAC, arg0->z_position); + } + if (arg0->unk6A & 4) { + func_80685F60(arg0); + } + } + if ((arg0->unk68 & 0x40) && func_80665AAC(arg0) && (!(arg0->unk6A & 0x800)) && arg0->floor <= arg0->y_position) { + func_806A081C(arg0); + } + if (arg0->unk68 & 0x80) { + func_80663844(arg0); + } +} + +// Returns struct from function call in a weird way... Doable once we figure out which struct is returned. +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80685E78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80685F60.s") + +/* +extern f32 D_80753A08[]; +extern f32 D_80753A18[]; + +// TODO: Doable, just need to figure out what actor118 points to +void func_80685F60(Actor *actor) { + u8 sp1B; + Actor *temp_a1; + f32 temp_f0; + u32 temp_a0; + u32 temp_v0; + u8 temp_t9; + f32 phi_f0; + u8 phi_v1; + u8 phi_v1_2; + Actor *phi_a1; + u8 phi_v1_3; + + temp_a1 = actor; + phi_v1 = 0; + phi_a1 = temp_a1; + phi_v1_3 = 0; + if ((actor->unk0 != 0) && (actor->animation_state != 0)) { + if (actor->interactable == 1) { + if (character_change_array[cc_player_index].unk2C0 == 1) { // TODO: This is marked f32 in the struct, which is correct? + phi_f0 = D_80753A08[actor->unk58 * 2]; + } else { + phi_f0 = D_80753A18[actor->unk58 * 2]; + } + } else { + phi_f0 = temp_a1->unk15E; + } + if ((temp_a1->unkAC - phi_f0) <= temp_a1->y_position) { + temp_a0 = object_timer; + if ((object_timer & 3) == 0) { + if (temp_a1->unkB8 != 0.0) { + phi_v1_3 = 1; + } + temp_v0 = temp_a1->unk118; + phi_v1 = phi_v1_3 & 0xFF; + if ((temp_v0) && (temp_v0->unk10 != 0)) { + phi_v1 = 1; + } + } + phi_v1_2 = phi_v1; + if (phi_v1 != 0) { + sp1B = phi_v1; + actor = temp_a1; + func_80714950(1, temp_a1); + phi_v1_2 = phi_v1; + phi_a1 = actor; + } else if ((temp_a1->unkB8 == 0.0) && (((object_timer % 24) == 0) || (temp_a1->unkBC != 0.0))) { + phi_v1_2 = 1; + } + if (phi_v1_2 != 0) { + func_80685E78(phi_a1, phi_a1); + } + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_8068613C.s") + +void func_80686340(void) { + func_807149B8(1); + func_807149FC(0x14); + func_8071498C(&D_8071827C); + func_807149C8(0xFF, 0xFF, 0xFF, 0xC8); + func_80714A28(4); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80686390.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_8068696C.s") + +extern f32 D_80759B50; + +extern void func_8071DC90(void); // Function pointer + +/* +// TODO: Weird regalloc again, at s2, s3 +void func_8068696C(Actor *arg0) { + s32 phi_s0; + f32 temp_f20 = D_80759B50; + for (phi_s0 = 0; phi_s0 < 0x10; phi_s0++) { + func_807149B8(1); + func_807149FC(-1); + func_80714950(arg0); + func_8071498C(&func_8071DC90); + func_80714CC0(D_8074E880[phi_s0 % 3], temp_f20, arg0->x_position, arg0->y_position, arg0->z_position); + } +} +*/ + +// Probably will have the same regalloc as above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80686A5C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80686CF8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80686E40.s") + +void func_80686F90(u8 arg0, s16 arg1, s16 arg2) { + func_80677FA8(0x109, 0xC0); // Spawn actor: Light beam (boss fights) + if (arg0) { + func_80671C0C(current_actor_pointer, arg0, &D_807FBB44->x_position, &D_807FBB44->y_position, &D_807FBB44->z_position); + } else { + D_807FBB44->x_position = current_actor_pointer->x_position; + D_807FBB44->y_position = current_actor_pointer->y_position; + D_807FBB44->z_position = current_actor_pointer->z_position; + } + D_807FBB44->y_rotation = arg1; + D_807FBB44->z_rotation = arg2; + D_807FBB44->animation_state->scale_y *= D_80759B60; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_80687080.s") + +/* +void func_806782C0(Actor*); +void func_806319C4(Actor*, s32); + +void func_80687080(void) { + f64 scaleMult; + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->object_properties_bitfield |= 0x800000; + current_actor_pointer->unk16A = 0xFF; + current_actor_pointer->unk16B = ((rand() >> 0xF) % 75) + 180; + current_actor_pointer->unk16C = 0x28; + current_actor_pointer->shadow_opacity = 0xFF; + } + if (current_actor_pointer->animation_state->scale_y > 1.0) { + current_actor_pointer->shadow_opacity -= 0x28; + if (current_actor_pointer->shadow_opacity < 0) { + func_806782C0(current_actor_pointer); + } + } else { + // TODO: Needs .rodata defined + scaleMult = 0.3333; // D_80759B68 + current_actor_pointer->animation_state->scale_y *= D_80759B70; + current_actor_pointer->animation_state->scale_x *= scaleMult; + current_actor_pointer->animation_state->scale_z *= scaleMult; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_806871DC.s") + +void func_80687400(void) { + playSound(0x2D4, 0x7FFF, 63.0f, 1.0f, 0, 0); + func_807149FC(0xC8); + func_8071495C(); + func_8071498C(&D_8071EFDC); + func_80714CC0(&D_80721158, 1.0f, 160.0f, 120.0f, -10.0f); +} + +void func_80687474(Actor *arg0, f32 arg1) { + func_80677FA8(0xB3, 0x5D); // Spawn actor: Shockwave (Mad Jack) + D_807FBB44->object_properties_bitfield |= 0x400; + func_80614EBC(D_807FBB44, 0x334); + func_8067B238(D_807FBB44, arg0, arg0->animation_state->scale_y * arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_806874EC.s") + +void func_806877C8(u8 arg0) { + func_807149B8(1); + func_80714C08(&D_8072006C, 1.0f, current_actor_pointer, arg0, 0); +} + +// Surprisingly doable, just need the energy +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_89250/func_8068780C.s") + +void func_80687C48(void) { + playSound(0xF2, 0x7FFF, 63.0f, 1.0f, 0, 0); + playSong(0x97, 1.0f); + func_807149FC(0xC8); + func_8071495C(); + func_8071498C(&D_8071EFDC); + func_80714CC0(&D_80720558, 1.0f, 160.0f, 120.0f, -10.0f); +} + +void func_80687CC8(void) { + playSound(0xF2, 0x7FFF, 63.0f, 1.0f, 0, 0); + playSong(0x97, 1.0f); + func_807149FC(0xC8); + func_8071495C(); + func_8071498C(&D_8071EFDC); + func_80714CC0(&D_807210EC, 1.0f, 160.0f, 120.0f, -10.0f); +} diff --git a/src/global_asm/code_8CA50.c b/src/global_asm/code_8CA50.c new file mode 100644 index 00000000..dbd68730 --- /dev/null +++ b/src/global_asm/code_8CA50.c @@ -0,0 +1,275 @@ +#include +#include "functions.h" +#include "variables.h" + +/* +// See func_8072881C() for details +void func_80688370(Actor *, s32, f32, s32); +void func_8068839C(Actor *, s32, s32); +void func_806883C8(Actor *, s32, s32); +void func_806883F4(Actor *, s32, s16, s32); +void func_8068842C(Actor *, s32, s32); +void func_806884B8(Actor *, s32, s32); +void func_80688514(Actor *, s32); +s32 func_80688540(Actor *, s32); +*/ + +GlobalASMStruct60 *func_80688584(Actor*, s32); +void func_80687FC8(GlobalASMStruct60 *arg0); + +// malloc and initialization for GlobalASMStruct60 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8CA50/func_80687D50.s") + +// Displaylist stuff? Actor arg1 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8CA50/func_80687EE0.s") + +void func_80687F7C(Actor *arg0) { + GlobalASMStruct60 *phi_s0; + + phi_s0 = arg0->unk158; + while (phi_s0) { + if (phi_s0->unk22 == 0) { + func_80687FC8(phi_s0); + } + phi_s0 = phi_s0->next; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8CA50/func_80687FC8.s") + +/* +// TODO: Close, doable, just some fiddly last steps with order of operations +// Maybe need to eliminate the last of the temporary variables +void func_80687FC8(GlobalASMStruct60 *arg0) { + s32 temp_f10; + s32 temp_lo; + s32 temp_lo_2; + s32 temp_v0_5; + + switch ((u8)arg0->unk20) { + case 0: + arg0->unk14 += arg0->unk10; + temp_f10 = arg0->unk14; + arg0->unkC += temp_f10; + arg0->unk14 -= temp_f10; + if (arg0->unkC >= arg0->unk1E) { + temp_lo = arg0->unkC / arg0->unk1E; + arg0->unk1A += temp_lo; + if ((arg0->unk1A >= arg0->unk18) && (arg0->unk18 != -1)) { + arg0->unkC = arg0->unk1E - 1; + arg0->unk22 = 1; + arg0->unk14 = 1.0f; + if ((u8)arg0->unk21 == 1) { + arg0->unk20 = 1; + } + } else { + switch ((u8)arg0->unk21) { + case 0: + arg0->unkC %= arg0->unk1E; + if (arg0->unkC < arg0->unk1C) { + arg0->unkC = arg0->unk1C; + } + break; + case 1: + if (temp_lo != 0) { + arg0->unk20 = 1; + arg0->unkC = arg0->unk1E - 1; + arg0->unk14 = 1.0f; + } + break; + } + } + } + break; + case 1: + arg0->unk14 -= arg0->unk10; + if (arg0->unk14 < 0.0) { + temp_v0_5 = (s32)arg0->unk14 - 1; + arg0->unkC += temp_v0_5; + arg0->unk14 -= temp_v0_5; + } + if (arg0->unkC < 0) { + temp_lo_2 = -arg0->unkC / arg0->unk1E; + arg0->unk1A += temp_lo_2 + 1; + if ((arg0->unk1A >= arg0->unk18) && (arg0->unk18 != -1)) { + arg0->unkC = 0; + arg0->unk22 = 1; + arg0->unk14 = 0.0f; + if ((u8)arg0->unk21 == 1) { + arg0->unk20 = 0; + } + } else { + switch ((u8)arg0->unk21) { + case 0: + arg0->unkC = -arg0->unkC % (arg0->unk1E - 1); + if (arg0->unkC != 0) { + arg0->unkC = (arg0->unk1E - arg0->unkC) - 1; + } + break; + case 1: + if ((temp_lo_2 + 1) != 0) { + arg0->unkC = 0; + arg0->unk20 = 0; + if (arg0->unkC < arg0->unk1C) { + arg0->unkC = arg0->unk1C; + } + arg0->unk14 = 0.0f; + } + break; + } + } + } + break; + } +} +*/ + +s32 func_806882DC(Actor *actor, s32 arg1, s16 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (!temp_v0) { + return 0; + } + return temp_v0->unk0[arg2]; +} + +void func_80688320(Actor *actor, s32 arg1, s16 arg2, s32 arg3) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if ((temp_v0) && (arg2 < temp_v0->unkA)) { + temp_v0->unk0[arg2] = arg3; + } +} + +void func_80688370(Actor* actor, s32 arg1, f32 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk10 = arg2; + } +} + +void func_8068839C(Actor *actor, s32 arg1, u8 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk20 = arg2; + } +} + +void func_806883C8(Actor* actor, s32 arg1, u8 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk21 = arg2; + } +} + +void func_806883F4(Actor* actor, s32 arg1, s16 arg2, f32 arg3) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unkC = arg2; + temp_v0->unk14 = arg3; + } +} + +void func_8068842C(Actor* actor, s32 arg1, s16 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk18 = arg2; + temp_v0->unk1A = 0; + temp_v0->unk22 = 0; + } +} + +void func_80688460(Actor* actor, s32 arg1, u8 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk22 = arg2; + } +} + +void func_8068848C(Actor* actor, s32 arg1, s16 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk1C = arg2; + } +} + +void func_806884B8(Actor* actor, s32 arg1, s16 arg2) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk1E = arg2; + } +} + +void func_806884E4(Actor* actor, s32 arg1) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk1E = temp_v0->unkA; + } +} + +void func_80688514(Actor* actor, s32 arg1) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (temp_v0) { + temp_v0->unk1C = 0; + } +} + +s32 func_80688540(Actor* actor, s32 arg1) { + GlobalASMStruct60 *temp_v0 = func_80688584(actor, arg1); + + if (!temp_v0) { + return FALSE; + } + // Absolutely baffling why they wrote it like this + return temp_v0->unk22 == 0 ? TRUE : FALSE; +} + +GlobalASMStruct60 *func_80688584(Actor *arg0, s32 arg1) { + GlobalASMStruct60 *current = arg0->unk158; + while (arg1) { + if (current) { + arg1--; + current = current->next; + } else { + return NULL; + } + } + return current; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8CA50/func_80688638.s") + +/* +// TODO: Close +void func_80688638(GlobalASMStruct60 **arg0) { + GlobalASMStruct60 *temp_s0; + GlobalASMStruct60 *temp_s2; + GlobalASMStruct60 *phi_s2; + s32 phi_s0; + + phi_s2 = *arg0; + while (phi_s2) { + temp_s2 = phi_s2->unk4; + for (phi_s0 = 0; phi_s0 < phi_s2->unkA; phi_s0++) { + func_8066B434(temp_s2->unk0, 0x1E6, 0x2C); + temp_s2++; + } + func_8061130C(phi_s2->unk0); + func_8061130C(phi_s2->unk4); + temp_s0 = phi_s2->next; + func_8061130C(phi_s2); + phi_s2 = temp_s0; + } + *arg0 = NULL; +} +*/ diff --git a/src/global_asm/code_8D3E0.c b/src/global_asm/code_8D3E0.c new file mode 100644 index 00000000..78a542bf --- /dev/null +++ b/src/global_asm/code_8D3E0.c @@ -0,0 +1,581 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80631F58(s32, void *, void **); +s16 func_806531B8(f32, f32, f32, s16); +void func_8066B424(void); +s32 func_8066B434(s32, s32, s32); +u16 func_80688C84(u16); +void func_80689250(s16, s32, s32, s32, s32, f32, s32, s32, s32, s32); +void func_80689710(ActorSpawner *arg0, u8 arg1); +f32 func_80689DD4(f32, f32, f32); +u8 func_80689F80(ActorSpawner*); +u8 func_80689FEC(ActorSpawner *spawner); + +extern u8 D_807500B0; +extern u16 D_807FC408[]; +extern s16 D_807FC5D0[]; +extern s16 D_807FC5F0[]; +extern u8 D_807FC610; +extern u8 D_807FC611; + +// TODO: Use proper actor spawner struct +typedef struct global_asm_struct_18 { + u8 pad0[0x32 - 0x0]; + s16 unk32; + s32 unk34; +} GlobalASMStruct18; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_806886E0.s") + +void func_80688940(void) { + s32 actorIndex; + s32 numActors; + s32 mapIndex; + s32 sp60; + s32 *sp5C; + s32 setup; + u16 phi_s3; + GlobalASMStruct18 *phi_s1; + + phi_s3 = 0; + if (!D_807500B0) { + D_807500B0 = 1; + for (mapIndex = 0; mapIndex < 0xDD; mapIndex++) { + D_807FC408[mapIndex] = phi_s3; + setup = getPointerTableFile(9, mapIndex, 1, 1); + if (setup) { + func_80631F58(setup, &sp60, &sp5C); + numActors = *sp5C; + phi_s1 = &sp5C[1]; + for (actorIndex = 0; actorIndex < numActors; actorIndex++) { + phi_s3 += func_80688C84(phi_s1[actorIndex].unk32 + 0x10); + } + func_8066B424(); + func_8066B434(setup, 0x168, 0x34); + } + } + } +} + +typedef struct { + u8 unk0; + u8 unk1; + s16 unk2; +} GlobalASMStruct79; + +extern GlobalASMStruct79 *D_807FC5C4; +extern u8 D_807FC5C8; + +// Loads the map setup from pointer table 9 for the current map +// Also uses the above struct +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80688A6C.s") + +s16 func_80688C30(u16 arg0) { + s32 i; + + for (i = 0; i < D_807FC5C8; i++) { + if (arg0 == D_807FC5C4[i].unk0) { + return D_807FC5C4[i].unk2; + } + } + return -1; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80688C84.s") + +// Something unk124 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80688CC4.s") + +// Something unk124 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80688CF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80688D20.s") + +// TODO: Any way to clean this up? +s32 func_80688E08(void) { + s32 found; + s16 search = 0; + ActorSpawner *spawner; + + do { + found = FALSE; + spawner = actor_spawner_pointer; + while (spawner && !found) { + if (search == spawner->id) { + found = TRUE; + } + spawner = spawner->next_spawner; + } + if (found) { + search++; + } + } while (found); + + return search; +} + +// getSpawnerID(Actor*) +s16 func_80688E68(Actor *arg0) { + ActorSpawner *spawner = actor_spawner_pointer; + while (spawner) { + if (arg0 == spawner->tied_actor) { + return spawner->id; + } + spawner = spawner->next_spawner; + } + return 0; +} + +// getActor(spawnerID) +Actor *func_80688EA4(s16 id) { + ActorSpawner *spawner = actor_spawner_pointer; + while (spawner) { + if (id == spawner->id) { + return spawner->tied_actor; + } + spawner = spawner->next_spawner; + } +} + +void func_80688EE4(s16 id, f32 x, f32 y, f32 z) { + ActorSpawner *spawner = actor_spawner_pointer; + while (spawner) { + if (id == spawner->id) { + spawner->x_position = x; + spawner->y_position = y; + spawner->z_position = z; + spawner->unk10 = x; + spawner->unk14 = y; + spawner->unk18 = z; + spawner->unk4A = func_806531B8(x, y, z, 0); + return; + } + spawner = spawner->next_spawner; + } +} + +void func_80688F74(Actor *arg0, f32 x, f32 y, f32 z) { + ActorSpawner *spawner = actor_spawner_pointer; + while (spawner) { + if (arg0 == spawner->tied_actor) { + spawner->x_position = x; + spawner->y_position = y; + spawner->z_position = z; + return; + } + spawner = spawner->next_spawner; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80688FC0.s") + +// TODO: Doable, another struct on the stack +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689064.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689114.s") + +void func_806891D8(s16 arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4, f32 arg5, s32 arg6, s32 arg7) { + func_80689250(arg0 - 0x10, arg1, arg2, arg3, arg4, arg5, arg7, 1, arg6, func_80688E08()); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689250.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689418.s") + +typedef struct { + s16 unk0; + s16 unk2; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; +} GlobalASMStruct_8074E8B0; + +extern f64 D_80759C80; +extern GlobalASMStruct_8074E8B0 D_8074E8B0[]; + +void func_8068A1B8(void); +void func_80613794(Actor*, u8); + +typedef struct { + s32 sp5C; + s32 sp60; + s32 sp64; + f32 sp68; + f32 sp6C; + f32 sp70; + s16 sp74; + s16 sp76; + u8* sp78; +} StackStructThing_80689418; + +/* +// TODO: Made good progress +void func_80689418(void) { + StackStructThing_80689418 tempStruct; + ActorSpawner *currentSpawner; + f64 temp_f20; + s16 *var_v0; + s16 temp_a1; + s32 var_a0; + s32 var_v1; + GlobalASMStruct_8074E8B0 *temp_v0; + + currentSpawner = actor_spawner_pointer; + temp_f20 = D_80759C80; + while (currentSpawner != NULL) { + if (currentSpawner->unk48 != 0) { + if (currentSpawner->drawing_code(currentSpawner) != 0) { + if (!(currentSpawner->tied_actor->object_properties_bitfield & 0x200000)) { + func_80678458(currentSpawner->tied_actor); + currentSpawner->unk48 = 0; + currentSpawner->unk10 = currentSpawner->tied_actor->x_position; + currentSpawner->unk14 = currentSpawner->tied_actor->y_position; + currentSpawner->unk18 = currentSpawner->tied_actor->z_position; + currentSpawner->unk4A = currentSpawner->tied_actor->unk12C; + func_80613794(currentSpawner->tied_actor, 0); + func_80613794(currentSpawner->tied_actor, 1); + func_80613794(currentSpawner->tied_actor, 2); + } + } + } else if (currentSpawner->unk5C(currentSpawner) != 0) { + var_v1 = 0; + var_a0 = FALSE; + if (currentSpawner->tied_actor == NULL) { + temp_a1 = currentSpawner->actor_type + 0x10; + var_v0 = &D_8074E8B0[0]; +loop_9: + if (temp_a1 == *var_v0) { + var_a0 = TRUE; + } else { + var_v1++; + var_v0++; + } + if ((var_a0 == 0) && (var_v1 < 0x80)) { + goto loop_9; + } + tempStruct.sp5C = temp_a1; + tempStruct.sp64 = D_8074E8B0[var_v1].unk4; + tempStruct.sp60 = D_8074E8B0[var_v1].unk2; + tempStruct.sp68 = currentSpawner->x_position; + tempStruct.sp6C = currentSpawner->y_position; + tempStruct.sp70 = currentSpawner->z_position; + tempStruct.sp74 = currentSpawner->y_rotation; + tempStruct.sp76 = 0; + tempStruct.sp78 = ¤tSpawner->pad22[6]; + if (func_80677ED0(&tempStruct) != 0) { + currentSpawner->tied_actor = D_807FBB44; + currentSpawner->unk48 = 1; + D_807FBB44->unk11C = currentSpawner->unk50; + if (D_807FBB44->animation_state != NULL) { + D_807FBB44->animation_state->scale_x = currentSpawner->unk20 * temp_f20; + D_807FBB44->animation_state->scale_y = currentSpawner->unk20 * temp_f20; + D_807FBB44->animation_state->scale_z = currentSpawner->unk20 * temp_f20; + } + } + } else if (currentSpawner->unk48 == 0) { + if (currentSpawner->unk58 != 0) { + currentSpawner->tied_actor->unk0 = func_80612E90(currentSpawner->tied_actor, currentSpawner->unk58, 0); + } + func_80678428(currentSpawner->tied_actor); + currentSpawner->unk48 = 1; + } + } + currentSpawner = currentSpawner->next_spawner; + } + func_8068A1B8(); +} +*/ + +void func_806896D0(s32 arg0) { + func_80689710(arg0, 1); +} + +void func_806896F0(s32 arg0) { + func_80689710(arg0, 0); +} + +void func_80689710(ActorSpawner *arg0, u8 arg1) { + ActorSpawner *phi_s0 = actor_spawner_pointer; + s32 found = FALSE; + ActorSpawner *phi_s1 = NULL; + + while (!found && phi_s0) { + if (phi_s0 == arg0) { + found = TRUE; + if (arg1 != 0) { + if (phi_s0->tied_actor) { + func_806782C0(phi_s0->tied_actor); + } + } + if (phi_s1) { + phi_s1->next_spawner = phi_s0->next_spawner; + } else { + actor_spawner_pointer = phi_s0->next_spawner; + } + if (phi_s0->next_spawner) { + phi_s0->next_spawner->previous_spawner = phi_s1; + } + func_8061130C(phi_s0); + } else { + phi_s1 = phi_s0; + phi_s0 = phi_s0->next_spawner; + } + } +} + +void func_806897F0(Actor *arg0) { + ActorSpawner *phi_s0 = actor_spawner_pointer; + s32 found = FALSE; + ActorSpawner *phi_s1 = NULL; + + while (!found && phi_s0) { + if (arg0 == phi_s0->tied_actor) { + found = TRUE; + if (phi_s1) { + phi_s1->next_spawner = phi_s0->next_spawner; + } else { + actor_spawner_pointer = phi_s0->next_spawner; + } + if (phi_s0->next_spawner) { + phi_s0->next_spawner->previous_spawner = phi_s1; + } + func_8061130C(phi_s0); + } else { + phi_s1 = phi_s0; + phi_s0 = phi_s0->next_spawner; + } + } +} + +void func_806898A8(void) { + ActorSpawner *next; + ActorSpawner *spawner = actor_spawner_pointer; + + while (spawner) { + next = spawner->next_spawner; + func_8061130C(spawner); + spawner = next; + } + actor_spawner_pointer = NULL; +} + +s32 func_806898F8(void) { + Actor *tiedActor; + ActorSpawner *spawner = actor_spawner_pointer; + s32 count = 0; + + while (spawner) { + if (spawner->unk4C == 0 || ((tiedActor = spawner->tied_actor, (tiedActor != 0)) && (tiedActor->unk64 & 0x400))) { + count++; + } + spawner = spawner->next_spawner; + } + // TODO: What is this? Some sizeof()? + return (count * 0x38) + 4; +} + +// 0x20 struct on the stack? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689958.s") + +void func_80689A80(s16 arg0, s32 arg1) { + s32 found = FALSE; + ActorSpawner *spawner = actor_spawner_pointer; + + while (spawner && !found) { + if (arg0 == spawner->id) { + found = TRUE; + } else { + spawner = spawner->next_spawner; + } + } + if (found) { + if (spawner->tied_actor) { + func_8067AB20(current_actor_pointer, spawner->tied_actor, 0x01000000, 1, arg1, 0); + } + } +} + +u8 func_80689B10(s16 arg0, u8 arg1, u8 arg2) { + s32 found = FALSE; + ActorSpawner *spawner = actor_spawner_pointer; + + while (spawner && !found) { + if (arg0 == spawner->id) { + found = TRUE; + } else { + spawner = spawner->next_spawner; + } + } + if (!found) { + return 0; + } + if (!spawner->tied_actor) { + return 0; + } + if (arg2) { + spawner->tied_actor->control_state = arg1; + } + return spawner->tied_actor->control_state; +} + +s32 func_80689BAC(s16 arg0) { + s32 found = FALSE; + ActorSpawner *spawner = actor_spawner_pointer; + + while (spawner && !found) { + if (arg0 == spawner->id) { + found = TRUE; + } else { + spawner = spawner->next_spawner; + } + } + if (!found) { + return FALSE; + } + if (spawner->unk48) { + return TRUE; + } + return FALSE; +} + +// Probably doable, looks like dxyz calculations in nested loops? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689C20.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689DD4.s") + +/* +extern f32 D_80759C8C; + +// TODO: Close, weird float regalloc +f32 func_80689DD4(f32 x, f32 y, f32 z) { + f32 dx, dy, dz; + f32 phi_f2; + f32 temp_f0; + s32 i; + + phi_f2 = D_80759C8C; + for (i = 0; i < cc_number_of_players; i++) { + if (character_change_array[i].does_player_exist) { + dz = z - character_change_array[i].look_at_eye_z; + dx = x - character_change_array[i].look_at_eye_x; + dy = y - character_change_array[i].look_at_eye_y; + temp_f0 = (dx * dx) + (dy * dy) + (dz * dz); + phi_f2 = MIN(temp_f0, phi_f2); + } + } + return phi_f2; +} +*/ + +s32 func_80689E98(s32 arg0) { + return 1; +} + +void func_80689EA4(ActorSpawner *spawner) { + if (func_80689F2C()) { + func_80652E58(spawner->unk4A, spawner); + return; + } + func_80689F80(spawner); +} + +u8 func_80689EE4(ActorSpawner *spawner) { + if (func_80689F2C()) { + return !func_80652E58(spawner->tied_actor->unk12C, spawner); + } + return func_80689FEC(spawner); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8D3E0/func_80689F2C.s") + +u8 func_80689F80(ActorSpawner *spawner) { + return func_80652E58(spawner->unk4A, spawner) + && func_80689DD4(spawner->unk10, spawner->unk14, spawner->unk18) < spawner->unk54; +} + +u8 func_80689FEC(ActorSpawner *spawner) { + return (!func_80652E58(spawner->tied_actor->unk12C, spawner) + || !(func_80689DD4(spawner->unk10, spawner->unk14, spawner->unk18) < spawner->unk54)) + && spawner->tied_actor->unk114 == 0; +} + +u8 func_8068A074(ActorSpawner *spawner) { + return (!func_80652E58(spawner->tied_actor->unk12C, spawner) + || !(func_80689DD4(spawner->unk10, spawner->unk14, spawner->unk18) < spawner->unk54)) + && (spawner->tied_actor->unk114 == 0 + && spawner->tied_actor->control_state == 0); +} + +s32 func_8068A10C(s32 arg0) { + return 0; +} + +u8 func_8068A118(ActorSpawner *arg0) { + // TODO: idk why this temporary variable is needed but... yeah + u8 temp = func_80689DD4(arg0->unk10, arg0->unk14, arg0->unk18) < arg0->unk54; + return temp; +} + +u8 func_8068A164(ActorSpawner *spawner) { + return !(func_80689DD4(spawner->tied_actor->x_position, spawner->tied_actor->y_position, spawner->tied_actor->z_position) < spawner->unk54); +} + +void func_8068A1B8(void) { + D_807FC610 = 0; + D_807FC611 = 0; +} + +void func_8068A1CC(s16 arg0) { + if (D_807FC610 != 0x10) { + D_807FC5D0[D_807FC610] = arg0; + D_807FC610++; + } +} + +void func_8068A20C(s16 arg0) { + if (D_807FC611 != 0x10) { + D_807FC5F0[D_807FC611] = arg0; + D_807FC611++; + } +} + +s32 func_8068A24C(ActorSpawner *spawner) { + s32 i; + for (i = 0; i < D_807FC610; i++) { + if ((spawner->id == D_807FC5D0[i]) && (spawner->unk48 == 0)) { + return TRUE; + } + } + return FALSE; +} + +s32 func_8068A2AC(ActorSpawner *spawner) { + s32 i; + for (i = 0; i < D_807FC611; i++) { + if ((spawner->id == D_807FC5F0[i]) && (spawner->unk48 != 0)) { + return TRUE; + } + } + return FALSE; +} + +void func_8068A2FC(Actor *actor) { + actor->shadow_opacity = 0; + actor->object_properties_bitfield &= ~0x8000; + actor->noclip_byte = 1; + actor->unk138 = 0; + actor->control_state = 0x63; + func_8066E6C8(actor, 0, 0); +} diff --git a/src/global_asm/code_8F050.c b/src/global_asm/code_8F050.c new file mode 100644 index 00000000..93833028 --- /dev/null +++ b/src/global_asm/code_8F050.c @@ -0,0 +1,63 @@ +#include +#include "functions.h" +#include "variables.h" + +// TODO: What are the actual datatypes? +s32 func_8068A3A0(s32, u32 *); +s32 func_8068A404(s32, s32, s32); +void func_806883F4(Actor*, s32, s16, f32); + +void func_8068A350(Actor *arg0, s32 arg1, s16 arg2) { + func_8068842C(arg0, arg1, -1); + func_80688460(arg0, arg1, 1); + func_806883F4(arg0, arg1, arg2, 0.0f); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F050/func_8068A3A0.s") + +/* +typedef struct { + s16 unk0; + s16 unk2; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; +} GlobalASMStruct76; + +extern GlobalASMStruct76 D_80750100[]; + +// TODO: Fiddly, might want another look at the mips_to_c output +s32 func_8068A3A0(s32 arg0, u32 *arg1) { + u32 phi_v0; + s32 phi_v1; + + phi_v1 = FALSE; + *arg1 = 0; + for (phi_v0 = 0; phi_v0 < 7; phi_v0++) { + if (arg0 == D_80750100[phi_v0].unk0) { + phi_v1 = TRUE; + break; + } else { + *arg1 = phi_v0; + } + } + return phi_v1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F050/func_8068A404.s") + +void func_8068A4C8(s32 arg0, s32 arg1, s32 arg2) { + s32 sp1C; + + if (func_8068A3A0(arg1, &sp1C)) { + func_8068A404(arg0, sp1C, arg2); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F050/func_8068A508.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F050/func_8068A764.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F050/func_8068A784.s") diff --git a/src/global_asm/code_8F4B0.c b/src/global_asm/code_8F4B0.c new file mode 100644 index 00000000..0bb66017 --- /dev/null +++ b/src/global_asm/code_8F4B0.c @@ -0,0 +1,229 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_807501E0; +extern u8 D_807FC620; +extern u8 D_807FC621; +extern u8 D_807FC622; + +// spawnPersistantActors +void func_8068A7B0(void) { + func_80677FA8(ACTOR_UNKNOWN_10, 0); + func_80677FA8(ACTOR_UNKNOWN_11, 0); + func_80677FA8(ACTOR_LOADING_ZONE_CONTROLLER, 0); + func_80677FA8(ACTOR_OBJECT_MODEL_2_CONTROLLER, 0); + func_80677FA8(ACTOR_UNKNOWN_14, 0); + func_80677FA8(ACTOR_UNKNOWN_15, 0); +} + +void func_8068A810(void) { + func_8072E868(); +} + +void func_8068A830(void) { + func_80727678(); + func_80727958(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068A858.s") + +// Jumptable, really interesting though, flag checks/sets and story skip +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068ABE0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068AD7C.s") + +void func_8068B80C(void) { + D_807FC620 = 1; +} + +void func_8068B81C(void) { + D_807FC621 = 0; + D_807FC622 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068B830.s") + +/* +// TODO: Which aaD is this? +void func_8068B830(s16 arg0, s16 arg1, s16 arg2) { + Actor *sp1C; + RaceAdditionalActorData *temp_v0; + + func_8072E7DC(0xC, &sp1C); + temp_v0 = sp1C->RaaD; + temp_v0->unk0 = arg0; + temp_v0->unk4 = arg1 / 100.0; + temp_v0->unk8 = arg2; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068B8A4.s") + +/* +// TODO: Which aaD is this? +void func_8068B8A4(f32 arg0) { + void *sp1C; + void *temp_v0; + + func_8072E7DC(0xC, &sp1C); + temp_v0 = sp1C->unk174; + temp_v0->unkC = arg0; + temp_v0->unk10 = arg0; + temp_v0->unk14 = arg0; + if (temp_v0->unk18 == 0) { + temp_v0->unk1C = 1; + temp_v0->unk1E = temp_v0->unk1C; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068B8FC.s") + +/* +// TODO: Which aaD is this? +void func_8068B8FC(void) { + Actor *sp1C; + + func_8072E7DC(0xC, &sp1C); + sp1C->TaaD->unk0 = 0xFF; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068B930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068B9B4.s") + +extern u8 D_807FBDC4; + +/* +// TODO: Something up with 807FBB70 definition +void func_8068B9B4(void) { + void *temp_a1; + s32 i; + + for (i = 0; i < D_807FBDC4; i++) { + temp_a1 = D_807FBB70[i].unk278; + if (D_807FBB70[i].unk258 == 1) { + // TODO: Better match for this + func_80689A80(((s16*)temp_a1)[1], temp_a1); + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068BA2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068BBF8.s") + +typedef struct { + void *texturePointer; // Texture Pointer (from table 0xE) + u16 textureIndex; // Texture Index + u8 unk6; + u8 unk7; +} Struct807FC690; + +extern Struct807FC690 D_807FC690[]; + +void func_8068C080(void) { + s16 i; + + for (i = 0; i < 0x20; i++) { + D_807FC690[i].unk6 = 0; + } +} + +void func_8068C0B4(void) { + s16 i; + + for (i = 0; i < 0x20; i++) { + if (D_807FC690[i].unk6 != 0) { + D_807FC690[i].unk6--; + if (D_807FC690[i].unk6 == 0) { + func_8066B434(D_807FC690[i].texturePointer, 0x6A, 0x46); + } + } + } +} + +// Returns a texture pointer for a given texture index +void *func_8068C12C(u16 textureIndex) { + s16 i; + + for (i = 0; i < 0x20; i++) { + if ((textureIndex == D_807FC690[i].textureIndex) && (D_807FC690[i].unk6 != 0)) { + D_807FC690[i].unk6 = 2; + return D_807FC690[i].texturePointer; + } + } + + for (i = 0; i < 0x20; i++) { + if (D_807FC690[i].unk6 == 0) { + D_807FC690[i].texturePointer = getPointerTableFile(0xE, textureIndex, 0, 0); + D_807FC690[i].unk6 = 2; + D_807FC690[i].textureIndex = textureIndex; + return D_807FC690[i].texturePointer; + } + } + + D_807FC690[0].unk6 = 2; + return D_807FC690[0].texturePointer; +} + +typedef struct { + s32 unk0; + s32 unk4; // Used + s8 unk8; // Used + s8 unk9; + s8 unkA; + s8 unkB; +} TempCBig; + +extern u8 D_807501E0; +extern TempCBig D_807FC630[]; + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068C20C.s") + +void func_8068C2EC(void) { + D_807501E0 = 0; +} + +void func_8068C2F8(s32 arg0) { + u8 i; + for (i = 0; i < D_807501E0; i++) { + if (arg0 == D_807FC630[i].unk4) { + D_807FC630[i].unk8 = 8; + } + } +} + +void func_8068C350(s32 arg0, s32 arg1, u8 arg2) { + if (D_807501E0 < 8) { + D_807FC630[D_807501E0].unk0 = arg0; + D_807FC630[D_807501E0].unk4 = arg1; + D_807FC630[D_807501E0].unk8 = arg2; + D_807501E0++; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068C3A0.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068C5A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068D264.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068D8C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068D9DC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068DAF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068DBA4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068DC54.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068E474.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_8F4B0/func_8068E7B4.s") diff --git a/src/global_asm/code_936B0.c b/src/global_asm/code_936B0.c new file mode 100644 index 00000000..dc5fe1bd --- /dev/null +++ b/src/global_asm/code_936B0.c @@ -0,0 +1,393 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_80750270; +extern s16 D_807502D0; +extern f32 D_807502E4; +extern f32 D_8075A0B8; // 16.0627460479736328125 + +extern f32 D_807FC7B0; +extern f32 D_807FC7B4; +extern f32 D_807FC7B8; + +void func_80688370(s32, s32, f32); +void func_80604CBC(s32, s32, u8, s32, s32, s32, f32, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068E9B0.s") + +/* +void func_8068E9B0(Actor *arg0) { + f32 sp2C; + Actor *vehicle; + + vehicle = arg0->PaaD->vehicle_actor_pointer; + func_80671C0C(vehicle, 9, arg0->x_position, &sp2C, arg0->z_position); + if (arg0->y_position < sp2C) { + arg0->y_position = sp2C; + } + arg0->y_rotation = vehicle->y_rotation; + func_806319C4(arg0, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068EA38.s") + +/* +// TODO: Regalloc +void func_8068EA38(Actor **arg0) { + PlayerAdditionalActorData *PaaD; + Actor *vehicle; + + PaaD = (*arg0)->PaaD; + vehicle = (*arg0)->PaaD->vehicle_actor_pointer; + if (vehicle) { + if (vehicle->RaaD->unk34 < 5) { + (*arg0)->x_position = vehicle->x_position; + (*arg0)->y_position = PaaD->vehicle_actor_pointer->y_position; + (*arg0)->z_position = PaaD->vehicle_actor_pointer->z_position; + (*arg0)->y_rotation = PaaD->vehicle_actor_pointer->y_rotation; + (*arg0)->z_rotation = PaaD->vehicle_actor_pointer->z_rotation; + (*arg0)->x_rotation = PaaD->vehicle_actor_pointer->x_rotation; + (*arg0)->unkAC = PaaD->vehicle_actor_pointer->unkAC; + if (PaaD->vehicle_actor_pointer->unk58 == 0x12E) { + (*arg0)->unkB8 = vehicle->unkB8 * 10.0f; + } else { + (*arg0)->unkB8 = vehicle->unkB8; + } + } else { + (*arg0)->unkB8 = 0.0f; + } + } + func_806319C4(*arg0, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068EB3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068ECF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068EF54.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068F72C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8068FF40.s") + +void func_80690058(Actor *arg0, s32 arg1) { + arg0->animation_state->unk1C = malloc(arg1 * 8); + func_80611690(arg0->animation_state->unk1C); +} + +void func_80690094(Actor *arg0, Actor *arg1) { + u8 sp37 = 0; + PlayerAdditionalActorData *PaaD = arg1->PaaD; + + func_806EB0C0(0x4C, arg0, PaaD->unk1A4); + if (current_map == MAP_GALLEON_PUFFTOSS) { + sp37 = 0x3C; + } + func_80604CBC(arg0, 0x115, sp37, 1, 0, 0xFF, 1.0f, 0); + func_80604CBC(arg0, 0x116, sp37, 1, 1, 0xFF, 1.0f, 0); + func_80688370(arg0, 0, 1.0f); + func_8068842C(arg0, 0, -1); + func_80690058(arg0, 2); + func_8067B238(arg0, arg1, 0.15f); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690190.s") + +void func_806903BC(Actor *actor, RaceAdditionalActorData *arg1) { + ExitData *exit; + s16 angle; + + exit = getExitData(arg1->unk36); + actor->x_position = exit->x_pos; + actor->y_position = exit->y_pos; + actor->z_position = exit->z_pos; + angle = exit->angle * D_8075A0B8; // 16.0627460479736328125 + actor->y_rotation = angle; + actor->unkEE = angle; + arg1->unk0 = angle; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690470.s") + +/* +// TODO: Not sure what I'm missing here... hmm +void func_80690470(Actor *arg0) { + Actor *sp18; + RaceAdditionalActorData *RaaD; + PlayerAdditionalActorData *PaaD; + + PaaD = arg0->PaaD; + func_80677FA8(0x13F, 0xDA); // Spawn actor 319, propeller (boat) + RaaD = D_807FBB44->RaaD; + RaaD->unk28 = PaaD->unk1A4; + func_80690094(D_807FBB44, arg0); + RaaD->unk35 = 0; + RaaD->unk27 = 0; + RaaD->unk0 = arg0->y_rotation; + PaaD->vehicle_actor_pointer = D_807FBB44; + D_807FBB44->object_properties_bitfield &= 0xFFFDFFFF; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690500.s") + +void func_806907B8(void) { + func_806319C4(current_actor_pointer, 0); +} + +void func_806907E0(void) { + D_80750270 = 1; +} + +void func_806907F0(f32 arg0, f32 arg1, f32 arg2) { + D_807FC7B0 = arg0; + D_807FC7B4 = arg1; + D_807FC7B8 = arg2; +} + +void func_80690814(s32 arg0, s32 arg1) { + func_80671C0C(arg0, arg1, &D_807FC7B0, &D_807FC7B4, &D_807FC7B8); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8069084C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690A28.s") + +/* +extern f32 D_807FC7B0; +extern f32 D_807FC7B8; + +f32 func_80665DE0(f32, f32, f32, f32); +void func_80690930(s32, s16, s16, s32, f32, f32, f32, f32, f32); + +void func_80690A28(s16 arg0, s16 arg1, s32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, s32 arg7) { + func_80690930(func_80665DE0(arg3, arg5, D_807FC7B0, D_807FC7B8), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690AB0.s") + +//typematching this accurately might be a nightmare +void func_80690A28(s16,s16,s32,s32,f32,f32,f32,s32); +void func_80690BE8(s16 arg0, s16 arg1, s32 arg2, s32 arg3, s32 arg4, f32 arg5, s32 arg6) { + s32 sp34; + f32 sp30; + f32 sp2C; + + func_80671C0C(arg3, arg4, &sp34, &sp30, &sp2C); + func_80690A28(arg0, arg1, arg2, sp34, sp30, sp2C, arg5, arg6); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690C60.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80690F30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806915B0.s") + +extern s32 D_807F5D10; + +void func_80661520(f32, f32, f32, f32, f32, f32); + +void func_80691830(s16 arg0, f32 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5, f32 arg6, f32 arg7, f32 arg8, f32 arg9) { + func_80677FA8(0x102, arg0); // Spawn actor: Shockwave (boss) + func_8067B238(D_807FBB44, current_actor_pointer, arg1); + D_807FBB44->unkF0 = arg0; + D_807FBB44->unk16A = arg2; + D_807FBB44->unk16B = arg3; + D_807FBB44->unk16C = arg4; + D_807FBB44->unk15F = arg5; + D_807FBB44->unk168 = 1; + D_807FBB44->unk160 = arg6; + if (arg7 != 0.0f) { + func_80661520(current_actor_pointer->x_position, current_actor_pointer->z_position, arg7, 2.0f, arg8, arg9); + } + func_8061F0B0(D_807F5D10, 0x50, 0x14); +} + +// TODO: Add to AAD union +typedef struct { + s16 unk0; + s16 unk2; + f32 unk4; + f32 unk8; + f32 unkC; + s8 unk10; + s8 unk11; +} TempAAD2; + +void func_80691930(u8 arg0, u8 arg1, f32 arg2, f32 arg3, u8 arg4, u8 arg5) { + TempAAD2 *temp_v0; + + func_80677FA8(0x107, 0); + func_8067B238(D_807FBB44, current_actor_pointer, 0.15f); + temp_v0 = D_807FBB44->additional_actor_data; + temp_v0->unk11 = arg0; + temp_v0->unk8 = arg2; + temp_v0->unkC = arg3; + temp_v0->unk0 = arg1; + D_807FBB44->y_position = current_actor_pointer->unkA8; + D_807FBB44->unk15F = arg4; + D_807FBB44->unk168 = arg5; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806919E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806921DC.s") + +void func_80692500(void) { + func_806921DC(0); +} + +void func_80692520(void) { + func_806921DC(1); +} + +// TODO: What datatype is this? +extern s32 D_807201D4; + +void func_80692540(void) { + func_806919E0(&D_807201D4); +} + +void func_80692564(void) { + func_806919E0(&D_807201D4); +} + +void func_80692588(void) { + func_806919E0(&D_807201D4); +} + +void func_806925AC(void) { + AnotherAdditionalActorData *sp1C; + + sp1C = current_actor_pointer->AaaD; + func_806919E0(&D_807201D4); + if (sp1C->unk13 == 1) { + current_actor_pointer->y_velocity += D_807502E4; + if (current_actor_pointer->y_velocity < D_807502D0) { + current_actor_pointer->y_velocity = D_807502D0; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80692640.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80692940.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80692E50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8069329C.s") + +void func_8061EF4C(Actor*, s32, s32, f32, f32, f32, f32, f32); + +extern s32 D_8071A8B0; // TODO: Datatype +extern s32 D_8071ABDC; // TODO: Datatype +extern s32 D_807200EC; // TODO: Datatype +extern s32 D_80720120; // TODO: Datatype +extern u8 D_80750AD0; +extern f32 D_8075A14C; + +/* +// TODO: Close, regalloc and something going wrong in the bottom loop +void func_8069329C(void) { + f32 temp_f20; + s32 phi_s0; + + func_807149B8(1); + func_80714950(0x1006E); + func_8071498C(&D_8071A8B0); + func_80714CC0(&D_80720120, 2.0f, current_actor_pointer->x_position, current_actor_pointer->y_position + 22.0f, current_actor_pointer->z_position); + for (phi_s0 = 0; phi_s0 < cc_number_of_players; phi_s0++) { + func_8061EF4C(character_change_array[phi_s0].player_pointer->PaaD->unk104, 7, 0x16, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 200.0f, 400.0f); + } + func_806915B0(); + if (D_80750AD0 == 0) { + temp_f20 = D_8075A14C; + for (phi_s0 = 0; phi_s0 < 0xC; phi_s0++) { + func_807149B8(1); + func_80714950(phi_s0 + 0x0B010000); + func_8071498C(&D_8071ABDC); + func_80714CC0(&D_807200EC, temp_f20, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position); + } + } + func_80608528(current_actor_pointer, 0xF6, 0xFF, 0x7F, 0x1E); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_8069346C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80693EC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806944BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80694948.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80694D20.s") + +s32 func_806951B0(Actor *arg0) { + if (arg0->unk58 != ACTOR_PROJECTILE_FEATHER) { + return TRUE; + } + if (arg0->control_state == 0) { + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806951E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80695724.s") + +void func_80695724(f32, s32); +void func_80695B50() { + AnotherAdditionalActorData *sp1C = current_actor_pointer->AaaD; + func_80695724(0, 1); + func_80612BC0(¤t_actor_pointer->unkC, sp1C->unk8); + func_806319C4(current_actor_pointer, 1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80695BAC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806960A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80696574.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_80696A6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_936B0/func_806970CC.s") + +/* +// TODO: Regalloc at the end :( +void func_806970CC(void) { + s32 temp_v0; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->unkFA = 9000; + } + func_80696A6C(); + if ((current_actor_pointer->unkFC != 0) && (func_806725A0(current_actor_pointer, current_actor_pointer->unkEE) == 0)) { + func_80608528(current_actor_pointer, 0xF5, 0xFF, 0x7F, 0x1E); + temp_v0 = func_80672A70(current_actor_pointer->unkF4, current_actor_pointer->unkF6, current_actor_pointer); + current_actor_pointer->unkEE = temp_v0 + (temp_v0 - ((current_actor_pointer->unkEE + 0x800) & 0xFFF)); + } +} +*/ + +extern u16 D_807FBB34; + +void func_80697184(void) { + Actor *temp_a0; + s16 i; + + for (i = 0; i < D_807FBB34; i++) { + temp_a0 = D_807FB930[i].unk0; + if (temp_a0->interactable & 4) { + func_80679200(temp_a0, current_actor_pointer, 8, 0, 0, 0); + } + } +} diff --git a/src/global_asm/code_9BF30.c b/src/global_asm/code_9BF30.c new file mode 100644 index 00000000..d170da28 --- /dev/null +++ b/src/global_asm/code_9BF30.c @@ -0,0 +1,26 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9BF30/func_80697230.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9BF30/func_806978FC.s") + +/* +// TODO: Missing another temp variable, hmm +extern s32 *D_807FC7C0; + +void func_806978FC(void) { + s16 phi_s0; + + D_807FC7C0 = malloc(0xC0); + for (phi_s0 = 0; phi_s0 < 0x30; phi_s0++) { + D_807FC7C0[phi_s0] = getPointerTableFile(0x19, phi_s0 + 0x1654, 1, 1); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9BF30/func_80697988.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9BF30/func_80697CEC.s") diff --git a/src/global_asm/code_9CE20.c b/src/global_asm/code_9CE20.c new file mode 100644 index 00000000..d2cca8ea --- /dev/null +++ b/src/global_asm/code_9CE20.c @@ -0,0 +1,22 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9CE20/func_80698120.s") + +void func_80698FEC(void) { + func_80698120(0xE); +} + +void func_8069900C(void) { + func_80698120(0xB); +} + +void func_8069902C(void) { + func_80698120(0xB); +} + +void func_8069904C(void) { + func_80698120(0xE); +} diff --git a/src/global_asm/code_9DD70.c b/src/global_asm/code_9DD70.c new file mode 100644 index 00000000..2060fa28 --- /dev/null +++ b/src/global_asm/code_9DD70.c @@ -0,0 +1,314 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s8 D_807F6951; +extern s8 D_807F6950; + +void func_80613C48(Actor*, s16, f32, f32); +void func_8070D8C0(Actor*, s32, u8); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_80699070.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_80699128.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_80699284.s") + +void func_806998C8(void) { + func_80699284(); +} + +void func_806998E8(void) { + +} + +void func_806998F0(void) { + func_80699958(8, 0); +} + +void func_80699914(void) { + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->draw_distance = 1000; + } + func_80699958(0x1C, 1); +} + +// Huge, lots of ActorAnimationState stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_80699958.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069A614.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069A750.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069A7C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069AB74.s") + +void func_8069AFF0(void) { + func_8069AB74(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069B010.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069B3FC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069B85C.s") + +extern s32 D_8076A068; + +/* +// TODO: Regalloc :( +s32 func_8069B85C(void) { + Actor *temp_v1; + ActorCollision *collision = current_actor_pointer->collision_queue_pointer; + + while (collision) { + if ((collision->unk0 == 0x8000) && (func_8067AF44(collision->collisionSource))) { + temp_v1 = collision->collisionSource; + if ((temp_v1->interactable & 1) && ((D_8076A068 - temp_v1->PaaD->unk120) < 2U)) { + return TRUE; + } + } + collision = collision->next; + } + return FALSE; +} +*/ + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069B908.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069CD9C.s") + +void func_8069B908(); +extern f64 D_8075A3F8; +extern f64 D_8075A400; + +/* +// TODO: Just some float nonsense to sort out +void func_8069CD9C(void) { + f32 dx, dy, dz; + f32 phi_f0; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + phi_f0 = (current_actor_pointer->animation_state->scale_x / D_8075A3F8) - 1.0; + if (phi_f0 < 0.0) { + phi_f0 = 0.0f; + } + current_actor_pointer->unk130 = phi_f0 * 80; + current_actor_pointer->unk131 = phi_f0 * 80; + current_actor_pointer->draw_distance = 700; + } + dz = current_actor_pointer->z_position - character_change_array->look_at_eye_z; + dx = current_actor_pointer->x_position - character_change_array->look_at_eye_x; + dy = current_actor_pointer->y_position - character_change_array->look_at_eye_y; + if (((dx * dx) + (dy * dy) + (dz * dz)) < D_8075A400) { + current_actor_pointer->object_properties_bitfield |= 0x400; + } else { + current_actor_pointer->object_properties_bitfield &= ~0x400; + } + func_8069B908(); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069CF54.s") + +/* +// TODO: Actor->unk124, not sure how it works... +void func_8069CF54(void) { + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->unk130 = 0x3C; + current_actor_pointer->unk131 = 0x3C; + func_80689114(0x83, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0, 1.0f, current_actor_pointer); + } + func_8069B908(); + if ((!(current_actor_pointer->object_properties_bitfield & 0x10)) && (current_actor_pointer->unk124->unk8 == 1) && isFlagSet(0xFD, FLAG_TYPE_PERMANENT)) { + current_actor_pointer->unk132 = 4; + } +} +*/ + +void func_8069D018(void) { + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->draw_distance = 700; + } + func_8069B908(); +} + +void func_8069D058(void) { + func_8069D018(); +} + +void func_8069D078(void) { + func_8069D018(); +} + +void func_8069D098(void) { + func_8069D018(); +} + +void func_8069D0B8(void) { + func_8069D018(); +} + +void func_8069D0D8(void) { + func_8069B908(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069D0F8.s") + +// TODO: Are these signatures correct? Maybe it's passing a struct? +void func_8069D0F8(u8, s16, s16, s32, s32, s32, s32, s32); + +void func_8069D2AC(u8 arg0, s16 arg1, s16 arg2, s32 arg3, u16 arg4, u16 arg5, u8 arg6, u8 arg7) { + if ((cc_number_of_players < 2) + && !gameIsInMainMenuMode() + && !gameIsInDKTVMode() + && (gameIsInAdventureMode() || gameIsInDKTheatreMode())) { + func_8069D0F8(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069D358.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069D424.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069D930.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069DA54.s") + +// Negative struct offset in loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069DC10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069DC80.s") + +void func_8068842C(Actor*, s32, s16); +void func_80688370(Actor*, s32, f32); +void func_80688320(Actor*, s32, s32, void*); +void func_8069DC10(s32, void*, u8); +s32 func_806FBB9C(s16 textureIndex); + +/* +// TODO: Bleh, stack nonsense, beqzl vs beqz +void *func_8069DC80(u8 arg0, s32 arg1, u8 arg2, u8 arg3, u8 arg4) { + s32 sp24; + void *temp_v0; + + sp24 = func_806FBB9C(arg0 + arg3); + if (arg1) { + func_8061134C(arg1); + } + temp_v0 = malloc(arg4 << 7); + func_8069DC10(temp_v0, sp24, arg4); + func_8068842C(current_actor_pointer, arg2, -1); + func_80688370(current_actor_pointer, arg2, 0); + func_80688320(current_actor_pointer, arg2, 0, temp_v0); + return temp_v0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069DD40.s") + +/* +extern u16 D_807446C0[]; +extern s16 D_807FC930[]; + +// TODO: Surprisingly close, just need to figure out which aaD type it is +// Will possibly be the same as the function below this one +void func_8069DD40(void) { + PlayerAdditionalActorData *temp_s1; + s32 temp_v0; + u16 temp_s0; + s32 phi_t0; + + temp_s1 = current_actor_pointer->additional_actor_data; + if (((current_actor_pointer->object_properties_bitfield & 0x10) == 0) || (extra_player_info_pointer->unk1F0 & 0x20000)) { + phi_t0 = getLevelIndex(D_8076A0AB, FALSE); + if (phi_t0 >= 8) { + phi_t0 = 0; + } + temp_s0 = D_807FC930[phi_t0]; + temp_s1->unk0 = func_8069DC80(0x21, temp_s1->unk0, 0, (temp_s0 / 100) & 0xFF, 0x20); + temp_s1->unk4 = func_8069DC80(0x21, temp_s1->unk4, 1, ((temp_s0 % 100) / 10) & 0xFF, 0x20); + temp_s1->unk8 = func_8069DC80(0x21, temp_s1->unk8, 2, (temp_s0 % 10) & 0xFF, 0x20); + current_actor_pointer->unk16A = 0xFF; + current_actor_pointer->unk16B = 0xFF; + current_actor_pointer->unk16C = 0xFF; + current_actor_pointer->object_properties_bitfield |= 0x800000; + extra_player_info_pointer->unk1F0 &= 0xFFFDFFFF; + if (temp_s0 >= D_807446C0[phi_t0]) { + current_actor_pointer->object_properties_bitfield &= 0xFFFF7FFF; + current_actor_pointer->shadow_opacity = 0; + current_actor_pointer->noclip_byte = 1; + func_8063DA40(8, 2); + func_8063DA40(9, 0xA); + func_8063DA40(0xA, 0xA); + func_8063DA40(0xB, 0xA); + func_8063DA40(0xD, 0xA); + func_8063DA40(0xC, 0xA); + } + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_9DD70/func_8069DF58.s") + +/* +// TODO: Which aaD type is this? +void func_8069DF58(void) { + void *temp_v1; + + temp_v1 = current_actor_pointer->additional_actor_data; + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + temp_v1->unk0 = func_8069DC80(0x14, temp_v1->unk0, 0, (current_actor_pointer->control_state_progress / 10) & 0xFF, 0x10); + temp_v1->unk4 = func_8069DC80(0x14, temp_v1->unk4, 1, (current_actor_pointer->control_state_progress % 10) & 0xFF, 0x10); + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_8069E018(void) { + func_806319C4(current_actor_pointer, 0); +} + +void func_8069E040() { + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_80614EBC(current_actor_pointer, 0x299); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_8069E088(void) { + s16 phi_s0_2; + + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_80613C48(current_actor_pointer, 0x5ED, 0, 0); + } + current_actor_pointer->unk15E = 0x14; + if (current_actor_pointer->control_state < 0x1E) { + current_actor_pointer->control_state++; + } + if (current_actor_pointer->control_state == 0x1E) { + phi_s0_2 = 0; + current_actor_pointer->control_state = 0x64; + func_8070E8DC(1); + if (!isFlagSet(0x178, FLAG_TYPE_PERMANENT)) { // Wrinkly FTT + setFlag(0x178, TRUE, FLAG_TYPE_PERMANENT); + } else { + phi_s0_2 = (func_80600530() * 5) + D_807F6951 + 1; + } + func_8070D8C0(current_actor_pointer, 0x29, phi_s0_2); + } + if (D_807F6950 != 0) { + func_806782C0(current_actor_pointer); + } + current_actor_pointer->animation_state->scale_x = 0.0f; + current_actor_pointer->animation_state->scale_y = 0.0f; + current_actor_pointer->animation_state->scale_z = 0.0f; + func_806319C4(current_actor_pointer, 0); +} diff --git a/src/global_asm/code_A2F10.c b/src/global_asm/code_A2F10.c new file mode 100644 index 00000000..8ed5646b --- /dev/null +++ b/src/global_asm/code_A2F10.c @@ -0,0 +1,120 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069E210.s") + +void func_806A5DF0(s16 arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s16 arg5, s16 arg6, Actor *arg7); + +void func_8069E490(u16 arg0, s16 arg1) { + func_806A5DF0(arg0, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0, 0, arg1, current_actor_pointer); +} + +void func_8067A70C(Actor *, void *, f32, f32, f32, s32, s32); +extern u16 D_807FBB34; + +void func_8069E4E0(s16 arg0) { + Actor *temp_a1; + s16 i; + + for (i = 0; i < D_807FBB34; i++) { + temp_a1 = D_807FB930[i].unk0; + if (current_actor_pointer == temp_a1->unk11C) { + func_8067A70C(current_actor_pointer, temp_a1, current_actor_pointer->x_position, current_actor_pointer->y_position + arg0, current_actor_pointer->z_position, 2, 1); + } + } +} + +void func_8069E5B8(void) { + Actor *temp_a0; + s16 phi_s0; + + for (phi_s0 = 0; phi_s0 < D_807FBB34; phi_s0++) { + temp_a0 = D_807FB930[phi_s0].unk0; + if (current_actor_pointer == temp_a0->unk11C) { + func_80679200(temp_a0, current_actor_pointer, 0x02000000, 1, 0, 0); + } + } +} + +// TODO: Yikes, needs a dx dz macro or something... +int func_8069E660(Actor *arg0, f32 arg1, f32 arg2) { + return (arg0->y_position - 8.0f) <= current_actor_pointer->y_position + && current_actor_pointer->y_position < (arg0->y_position + arg1) + && ((((arg0->x_position - current_actor_pointer->x_position) * (arg0->x_position - current_actor_pointer->x_position)) + ((arg0->z_position - current_actor_pointer->z_position) * (arg0->z_position - current_actor_pointer->z_position))) < arg2) + && (arg0->noclip_byte != 1); +} + +// Jumptable, a fun one though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069E724.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069E774.s") + +s32 func_8069EF50(s16 arg0, s16 arg1, s16 arg2, s16 arg3, f32 arg4) { + f32 dx = player_pointer->x_position - arg0; + f32 dz = player_pointer->z_position - arg2; + + if (((dx * dx) + (dz * dz)) < (arg4 * arg4)) { + if ((arg1 <= player_pointer->y_position) && (player_pointer->y_position < (arg1 + arg3))) { + return TRUE; + } + } + return FALSE; +} + +// Huge, surprisingly doable though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069F020.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069F904.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069FA40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_8069FDA0.s") + +// Doable, actor->unk124 pointer stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A018C.s") + +void func_806A02F0(void) { + func_806A018C(); +} + +void func_806A0310(void) { + func_806A018C(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A0330.s") + +void func_806A05D4(void) { + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A05FC.s") + +void func_806A081C(Actor *arg0) { + func_80677FA8(ACTOR_KONG_REFLECTION, func_80613448(arg0)); + D_807FBB44->unk11C = arg0; + arg0->unk6A |= 0x800; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A0864.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A0B74.s") + +void func_806883F4(Actor *arg0, s32 arg1, u8 arg2, f32 arg3); + +void func_806A0F78(Actor *arg0, u8 arg1, u8 arg2) { + func_8068842C(arg0, 0, 1); + func_80688460(arg0, 0, 1); + func_806883F4(arg0, 0, arg1, 0.0f); + func_8068842C(arg0, 1, 1); + func_80688460(arg0, 1, 1); + func_806883F4(arg0, 1, arg2, 0.0f); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A1008.s") + +// AnimationState->unk24 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A10BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A2F10/func_806A112C.s") diff --git a/src/global_asm/code_A6280.c b/src/global_asm/code_A6280.c new file mode 100644 index 00000000..75da464d --- /dev/null +++ b/src/global_asm/code_A6280.c @@ -0,0 +1,129 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806319C4(Actor *, s32); +void func_80613C48(Actor*,s16,f32,f32); +void func_80699070(s16 *, s16 *, f32, f32, f32, f32, f32, f32); +extern f64 D_8075A588; +extern f64 D_8075A590; +extern f64 D_8075A598; +extern f64 D_8075A5A0; + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A6280/func_806A1580.s") + +extern f32 D_8075A550; +extern u8 D_807FBD70; +extern u8 D_807506C0[]; + +f32 func_80665AE4(s32, s32, s32, s32); +void func_80688370(Actor*, s32, f32); +void func_806883F4(Actor*, s32, s32, f32); +void func_80679200(Actor*, Actor*, s32, u8, s32, s32); + +/* +// TODO: Everything matches, but the stack is too big +// Perhaps a dxz macro? +void func_806A1580(void) { + f32 dx, dz; + s16 sp36; + Actor *sp30; + + sp36 = func_80688E68(current_actor_pointer); + sp30 = func_807270C0(2, 0); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->unk130 = 0x46; + current_actor_pointer->unk131 = 0x32; + current_actor_pointer->unk6A &= 0xFFFE; + current_actor_pointer->noclip_byte = 2; + current_actor_pointer->object_properties_bitfield |= 0x80000000; + current_actor_pointer->unk64 |= 0x28; + func_8068848C(current_actor_pointer, 0, 1); + } + dx = player_pointer->x_position - current_actor_pointer->x_position; + dz = player_pointer->z_position - current_actor_pointer->z_position; + if (((dx * dx) + (dz * dz)) < D_8075A550) { + current_actor_pointer->object_properties_bitfield |= 0x400; + } else { + current_actor_pointer->object_properties_bitfield &= ~0x400; + } + if (sp30) { + if (sp36 == D_807506C0[sp30->unk15F]) { + dx = current_actor_pointer->x_position - player_pointer->x_position; + dz = current_actor_pointer->z_position - player_pointer->z_position; + if (((dx * dx) + (dz * dz)) > 900.0f) { + sp30->unkEC = func_80665AE4(current_actor_pointer->x_position, current_actor_pointer->z_position, player_pointer->x_position, player_pointer->z_position) - func_80665AE4(character_change_array->look_at_at_x, character_change_array->look_at_at_z, character_change_array->look_at_eye_x, character_change_array->look_at_eye_z); + } + if (func_80688540(current_actor_pointer, 0) == 0) { + func_80688370(current_actor_pointer, 0, 1.0f); + func_8068842C(current_actor_pointer, 0, -1); + } + } else if (func_80688540(current_actor_pointer, 0) != 0) { + func_80688460(current_actor_pointer, 0, 1); + func_806883F4(current_actor_pointer, 0, 0, 0.0f); + } + if (D_807FBD70 == 4) { + if (current_actor_pointer->unk132 == 4) { + current_actor_pointer->unk132 = 8; + playSong(0x43, 1.0f); + func_80679200(sp30, current_actor_pointer, 0x02000000, sp36, 0, 0); + } else { + current_actor_pointer->unk132 *= 2; + } + } + if ((player_pointer->unk6A & 1) && !player_pointer->locked_to_pad) { + current_actor_pointer->unk132 = 1; + } + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A6280/func_806A18A8.s") + +void func_806A1ABC(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A6280/func_806A1AC4.s") + +void func_806A1F28() { + current_actor_pointer->object_properties_bitfield |= 0x400; + func_806319C4(current_actor_pointer, 0); +} + +void func_806A1F64() { + if (func_8061CB50()) { + func_80613C48(current_actor_pointer, 0x640, 0, 8.0f); + } else { + func_80613C48(current_actor_pointer, 0x63F, 0, 8.0f); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806A1FD0(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A6280/func_806A1FD8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A6280/func_806A2328.s") + +void func_806A285C(void) { + s16 spBE; + s16 spBC; + f32 sp7C[4][4]; + f32 sp3C[4][4]; + + func_80699070(&spBE, &spBC, character_change_array[0].look_at_eye_x, character_change_array[0].look_at_eye_y, character_change_array[0].look_at_eye_z, character_change_array[0].look_at_at_x, character_change_array[0].look_at_at_y, character_change_array[0].look_at_at_z); + current_actor_pointer->y_rotation = spBC; + current_actor_pointer->z_rotation = spBE; + guRotateF(&sp7C, (spBE / D_8075A588) * D_8075A590, 1.0f, 0.0f, 0.0f); + guRotateF(&sp3C, (spBC / D_8075A598) * D_8075A5A0, 0.0f, 1.0f, 0.0f); + guMtxCatF(&sp7C, &sp3C, &sp7C); + guTranslateF(&sp3C, character_change_array[0].look_at_eye_x, character_change_array[0].look_at_eye_y, character_change_array[0].look_at_eye_z); + guMtxCatF(&sp7C, &sp3C, &sp7C); + guMtxXFMF(&sp7C, 0.0f, 0.0f, -11.0f, ¤t_actor_pointer->x_position, ¤t_actor_pointer->y_position, ¤t_actor_pointer->z_position); + guTranslateF(¤t_actor_pointer->unkC, 0.0f, -20.0f, 0.0f); + func_806319C4(current_actor_pointer, 1); +} diff --git a/src/global_asm/code_A7710.c b/src/global_asm/code_A7710.c new file mode 100644 index 00000000..5910a16d --- /dev/null +++ b/src/global_asm/code_A7710.c @@ -0,0 +1,57 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A7710/func_806A2A10.s") + +/* +// TODO: Quite close, our stack's too big, and datatype on the temporary variable +void func_806A2A10(s16 arg0, s16 arg1, u8 arg2) { + s8 temp = arg2; + func_80677FA8(0xB0, 0); // spawnActorWrapper(ACTOR_TIMER_CONTROLLER) + if ((arg0 & 0x8000) != 0) { + D_807FBB44->unk15F = 0xB; + temp--; + } else { + D_807FBB44->unk15F = 6; + } + current_actor_pointer->unk11C = D_807FBB44; + extra_player_info_pointer->unk1A8 = D_807FBB44; + D_807FBB44->additional_data_pointer[3] = temp & 0xFF; + D_807FBB44->x_position = (s16) (arg0 & 0x7FFF); + D_807FBB44->y_position = arg1; + D_807FBB44->control_state = 1; + D_807FBB44->shadow_opacity = 0; +} +*/ + +void func_806A2B08(Actor *arg0) { + arg0->control_state = 2; + arg0->control_state_progress = 0; + arg0->shadow_opacity = 0xFF; +} + +void func_806A2B20(Actor *arg0) { + if (arg0 != 0) { + arg0->control_state = 1; + arg0->control_state_progress = 0; + } +} + +// actor + libultra + weird struct offset, doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A7710/func_806A2B38.s") + +void func_806A2B80(Actor *arg0) { + arg0->control_state = 3; + arg0->control_state_progress = 0; +} + +// actor + displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A7710/func_806A2B90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A7710/func_806A2E30.s") + +void func_806A36F4(void) { + +} diff --git a/src/global_asm/code_A8400.c b/src/global_asm/code_A8400.c new file mode 100644 index 00000000..8d4ee992 --- /dev/null +++ b/src/global_asm/code_A8400.c @@ -0,0 +1,307 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_80720A10; +extern s32 D_807209EC; +extern s32 D_807207E0; +extern s32 D_80720A34; +extern s32 D_80720A58; + +extern s32 D_807204BC; +extern s32 D_80720508; +extern s32 D_807205C4; +extern s32 D_807205E8; +extern s32 D_80720768; +extern s32 *D_807207BC; +extern s32 D_807211D0; +extern s32 D_80721378; +extern f32 D_8075A9B0; +extern f32 D_8075A9B4; + +extern s32 D_80720710; + +extern s32 D_80720FE0; +extern s32 D_80720F98; +extern s32 D_80720FBC; +extern s32 D_80721028; +extern s32 D_80721004; +extern f32 D_8075AA70; +extern f32 D_8075AA74; + +void func_80686A5C(Actor *arg0, f32 arg1, f32 arg2, s32 arg3); +void func_80665564(Actor *arg0, f32 arg1); +void func_806A6DB4(s32 arg0); +void func_806086CC(f32 arg0, f32 arg1, f32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, f32 arg8, s32 arg9); +void func_8065D254(Actor *actor, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, f32 arg10); +void func_80686CF8(Actor *actor); +void func_806319C4(Actor *arg0, s32 arg1); + +void func_806A664C(f32 arg0); +void func_80714A08(f32 arg0, f32 arg1); +void func_806A5EAC(s32 *arg0, s32 *arg1, f32 arg2); + +void func_806A3700(s32 arg0, s32 arg1) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A370C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A3B78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A3C6C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A3DA0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A3E9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A4284.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A495C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A4B84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A4DDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A5174.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A57C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A5868.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A5C60.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A5DF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A5EAC.s") + +/* +// TODO: Which aaD is arg0? +void func_806A5EAC(void *arg0, s32 arg1, f32 arg2) { + f32 phi_f12; + + phi_f12 = arg2; + if (D_807FBB68 & 0x10) { + phi_f12 = 2.0f * arg2; + } + arg2 = phi_f12; + func_807149FC(phi_f12, -1); + func_807149B8(1); + func_80714998(2); + arg0->unk4 = func_80714C08(arg2, arg1, arg2 * D_8075A9A8, current_actor_pointer, 1, 2); +} +*/ + +void func_806A5F44(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_806A5EAC(sp1C, &D_80720710, 1.0f); + } +} + +void func_806A5FA4(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_806A5EAC(sp1C, &D_80720508, 1.0f); + } +} + +void func_806A6004(void *arg0, s32 arg1) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + if (arg1 != player_pointer->unk58) { + func_807149C8(0xFF, 0xFF, 0xFF, 0x64); + } + func_806A5EAC(sp1C, arg0, 1.0f); + } +} + +void func_806A6094(void) { + func_806A6004(&D_807209EC, 3); +} + +void func_806A60BC(void) { + func_806A6004(&D_80720A10, 6); +} + +void func_806A60E4(void) { + func_806A6004(&D_807207E0, 4); +} + +void func_806A610C(void) { + func_806A6004(&D_80720A34, 2); +} + +void func_806A6134(void) { + func_806A6004(&D_80720A58, 5); +} + +void func_806A615C(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_80714A08(D_8075A9B0, D_8075A9B4); + func_806A5EAC(sp1C, &D_80720768, 1.0f); + } +} + +void func_806A61D0(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_806A5EAC(sp1C, &D_807204BC, 1.0f); + } +} + +void func_806A6230(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + s32 temp_v1; + + func_806A664C(4.5f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + temp_v1 = D_807FBB64; // shadow_display_bitfield, shockwave_bitfield, long_distance_actor_spawn + if (((temp_v1 << 0xC) < 0) || (temp_v1 & 0x2000)) { + current_actor_pointer->unk15F = 1; + } + func_806A5EAC(sp1C, &D_807207BC, 1.0f); + } +} + +void func_806A62B4(void) { + func_806A6230(); +} + +void func_806A62D4(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_807149C8(0xFF, 0xFF, 0, 0xFF); + func_806A5EAC(sp1C, &D_807211D0, 1.5f); + } +} + +void func_806A6348(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_806A5EAC(sp1C, &D_807205C4, 1.0f); + } +} + +void func_806A63A8(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(4.5f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_806A5EAC(sp1C, &D_807205E8, 1.0f); + } +} + +void func_806A6408(void) { + // TODO: Which aaD type are they actually expecting here? + void *sp1C = current_actor_pointer->additional_actor_data; + func_806A664C(12.0f); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_806A5EAC(sp1C, &D_80721378, 2.0f); + } +} + +// jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A6468.s") + +// jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A6574.s") + +// jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A664C.s") + +// jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A6DB4.s") + +void func_806A734C(void) { + func_806A6DB4(1); +} + +void func_806A736C(void) { + PlayerAdditionalActorData *PaaD = current_actor_pointer->PaaD; + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + current_actor_pointer->unk64 |= 4; + current_actor_pointer->object_properties_bitfield |= 0x400; + func_80686CF8(current_actor_pointer); + } + // TODO: Get rid of typecasts + if ((u16)PaaD->unk8 == 1) { + func_806086CC(current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0x73, 0xFF, 0x7F, 1, 0, 0.0f, 0); + playSong(0x3B, 0.7f); + } else if ((u16)PaaD->unk8 == 0xA) { + func_806086CC(current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0x19C, 0xB4, 0x7F, 1, 0, 0.0f, 0); + } + func_806A6DB4(0); + if (current_actor_pointer->y_position < current_actor_pointer->unkAC) { + current_actor_pointer->unkB8 = 0.0f; + current_actor_pointer->y_position = current_actor_pointer->unkAC; + current_actor_pointer->y_velocity = current_actor_pointer->y_acceleration; + } + func_8065D254(current_actor_pointer, 0x3C8, 0x40, 0x40, 0x1E, 0x1E, 1, 0x96, 0x78, 0, 1.0f); +} + +void func_806A7518(void) { + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + current_actor_pointer->object_properties_bitfield |= 0x400; + func_80686A5C(current_actor_pointer, 20.0f, 40.0f, 0x1E); + current_actor_pointer->floor = D_8075AA70; + func_80665564(current_actor_pointer, 0.0f); + } + func_806A6DB4(0); + if (D_8075AA74 != current_actor_pointer->floor) { + func_8065D254(current_actor_pointer, 0x3C8, 0x40, 0x40, 0x19, 0x19, 1, 0x96, 0x78, 0, 1.0f); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A7600.s") + +void func_806A7B04(void) { + func_806A7600(&D_80720FBC); +} + +void func_806A7B28(void) { + func_806A7600(&D_80720F98); +} + +void func_806A7B4C(void) { + func_806A7600(&D_80721028); +} + +void func_806A7B70(void) { + func_806A7600(&D_80721004); +} + +void func_806A7B94(void) { + func_806A7600(&D_80720FE0); +} + +void func_806A7BB8(void) { + func_806A7600(&D_80721004); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A7BDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_A8400/func_806A7EF0.s") + +void func_806A8070(void) { + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->object_properties_bitfield |= 0x40000000; + } + func_806319C4(current_actor_pointer, 0); +} diff --git a/src/global_asm/code_ACDC0.c b/src/global_asm/code_ACDC0.c new file mode 100644 index 00000000..2afba2c5 --- /dev/null +++ b/src/global_asm/code_ACDC0.c @@ -0,0 +1,238 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 *D_807FC7E0; +extern u16 D_807ECD58; +extern s8 D_80750560[]; + +extern void func_806ACA88(void); + +s32 func_806A80C0(s8 arg0) { + s32 i; + + for (i = 0; i < 9; i++) { + if (arg0 == D_80750560[i]) { + return i; + } + } + return 0; +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806A8158.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806A9124.s") + +void func_8061130C(s32); +void func_8061134C(s32); +extern s32 *D_807FC7E8; + +typedef struct TempStruct807FC7F0 { + s32 unk0; + s32 unk4; +} TempStruct807FC7F0; + +typedef struct TempStruct807FC7F8 { +s8 unk0; + s8 unk1; + s8 unk2; + s8 unk3; + s8 unk4; +} TempStruct807FC7F8; + +extern TempStruct807FC7F0 D_807FC7F0; +extern TempStruct807FC7F8 D_807FC7F8; + +/* +// TODO: Close, doable +// TODO: Regalloc, something iffy with global_properties_bitfield set +void func_806A9124(void) { + s32 temp_t8; + s32 var_s0; + s32 var_s0_2; + + temp_t8 = global_properties_bitfield | 0x40; + global_properties_bitfield = temp_t8; + if (!(player_pointer->PaaD->unk1F0 & 0x20000000)) { + global_properties_bitfield |= 0x10030; + } + func_8061130C(D_807FC7F0.unk0); + D_807FC7F0.unk0 = 0; + D_807FC7F0.unk4 = 0; + D_807FC7F8.unk0 = 0; + D_807FC7F8.unk1 = 0; + for (var_s0 = 0; var_s0 < 27; var_s0++) { + func_8061134C(D_807FC7E0[var_s0]); + } + func_8061134C(D_807FC7E0); + for (var_s0 = 0; var_s0 < 9; var_s0++) { + func_8061134C(D_807FC7E8[var_s0]); + } + func_8061134C(D_807FC7E8); +} +*/ + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806A921C.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806A92B4.s") + +// displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806AA09C.s") + +// TODO: Surprisingly doable, good target +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806AA304.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806AB4EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806AB808.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ABA6C.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ABB98.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ABC94.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ABE3C.s") + +void func_806AC048(s32 arg0, s32 arg1) { + func_80703374(arg0, 0, 0, 0, 0x46); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806AC07C.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ACA88.s") + +void func_806ACC00(u8 arg0) { + func_80677FA8(0x156, 0); // Spawn actor: Try Again Dialog + D_807FBB44->unk15F = arg0; + D_807FBB44->unk64 |= 2; + global_properties_bitfield |= 0x40001; +} + +void func_806ACC64() { + s16 i; + + global_properties_bitfield |= 0x40; + for (i = 0; i < 3; i++) { + func_8061134C(D_807FC7E0[i]); + } + func_8061134C(D_807FC7E0); + func_806782C0(current_actor_pointer); +} + +void func_806ACCE8(void) { + s32 i; + + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + current_actor_pointer->unk168 = 0x1E; + current_actor_pointer->shadow_opacity = 0; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + D_807FC7E0 = malloc(0xC); + for (i = 0; i < 3; i++) { + D_807FC7E0[i] = func_8070E750(0x24, i + 0xF, 0); + } + } + if (current_actor_pointer->unk168 != 0) { + current_actor_pointer->unk168--; + } else if (current_actor_pointer->control_state == 0) { + if (D_807ECD58 & 0x8000) { + switch (current_actor_pointer->unk15F) { + case 2: + playCutscene(NULL, 0x20, 1); + func_806ACC64(); + break; + case 3: + case 4: + func_80724994(3, 7, 0x30, 0, 0); + func_806ACC64(); + break; + default: + func_805FF378(current_map, 0); + break; + } + current_actor_pointer->control_state = 1; + } else if (D_807ECD58 & 0x4000) { + switch (current_actor_pointer->unk15F) { + case 3: + case 4: + func_80724994(3, 7, 0x3C, 0, 0); + case 2: + func_806ACC64(); + break; + case 1: + func_805FF544(); + break; + default: + func_805FF898(); + break; + } + current_actor_pointer->control_state = 1; + } + } + func_8068C350(&func_806ACA88, current_actor_pointer, 5); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ACF10.s") + +// TODO: Good target, doable, as long as NOPs don't screw us at end of function +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_ACDC0/func_806ACFFC.s") + +/* +extern s8 D_8076A105; +extern s8 D_807FC80E; +extern s8 D_807FC8B9; + +void func_806ACF10(void); + +// TODO: Very close, something wrong with the do while loops? +void func_806ACFFC(void) { + s32 var_s1; + s8 temp_v0_2; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FC7E0 = malloc(0x10); + var_s1 = 0; + do { + D_807FC7E0[var_s1] = func_8070E750(0x24, var_s1, 0); + var_s1++; + } while (var_s1 != 4); + global_properties_bitfield &= 0xFFFEFFCF; + func_806291B4(7); + D_807FC80E = 0; + current_actor_pointer->control_state_progress = 0; + } + temp_v0_2 = character_change_array[D_807FC8B9].unk294->unk3; + if ((temp_v0_2 >= 0x33) || (temp_v0_2 < -0x32)) { + if (!(D_807FC80E & 1)) { + current_actor_pointer->control_state_progress = 1 - current_actor_pointer->control_state_progress; + D_807FC80E |= 1; + playSound(0x2A0, 0x7FFF, 63.0f, 1.0f, 0, 0); + } + } else { + D_807FC80E &= 0xFFFE; + } + if (character_change_array[D_807FC8B9].new_controller_inputs & A_BUTTON) { + if (current_actor_pointer->control_state_progress == 0) { + global_properties_bitfield |= 0x10070; + var_s1 = 0; + do { + func_8061134C(D_807FC7E0[var_s1]); + var_s1++; + } while (var_s1 != 0x10); + func_8061134C(D_807FC7E0); + } else if (current_actor_pointer->control_state_progress == 1) { + D_8076A105 = -1; + func_80714638(); + current_actor_pointer->control_state_progress = 2; + } + } + func_8068C350(&func_806AC048, current_actor_pointer, 1); + func_8068C350(&func_806ACF10, current_actor_pointer, 5); +} +*/ diff --git a/src/global_asm/code_B1F60.c b/src/global_asm/code_B1F60.c new file mode 100644 index 00000000..cebf620a --- /dev/null +++ b/src/global_asm/code_B1F60.c @@ -0,0 +1,247 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80724E48(u8); +void func_806319C4(Actor *, s32); +void func_80729B00(void); +void func_8072B79C(s32, s32, s32); +void func_806782C0(Actor *); +s32 func_8072881C(s32, s32); +s32 func_8072AB74(u8, f32, f32, s32, f32); +s32 func_8072B324(Actor *, s32); +s32 func_8072D714(s32, s32); +s32 func_8072DE44(s32); +s32 func_8072DEA8(s32, s32, s32); + +extern f32 D_8075AE18; + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B1F60/func_806AD260.s") + +extern f64 D_8075AE10; + +void func_806AD54C(void) { + f32 dx, dz; + Actor *klaptrap; + s32 angleSign; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_80724CA4(2, 1); + func_8072B79C(0x1F8, 0x1F8, 0x1F9); + if (current_map == MAP_BEAVER_BOTHER_EASY || current_map == MAP_BEAVER_BOTHER_NORMAL || current_map == MAP_BEAVER_BOTHER_HARD) { + current_actor_pointer->unk132 = 2; + } + } + if ((current_actor_pointer->unk132 == 2) && (current_actor_pointer->control_state != 0x36)) { + klaptrap = func_8067ADB4(0x11A); + if (klaptrap) { + if (klaptrap->control_state != 0) { + if (!(D_807FDC90->unk1A & 0x8000)) { + dx = klaptrap->x_position - current_actor_pointer->x_position; + dz = klaptrap->z_position - current_actor_pointer->z_position; + if (((dx * dx) + (dz * dz)) < 1600.0f) { + angleSign = ((klaptrap->y_rotation - current_actor_pointer->y_rotation) & 0xFFF) >= 0x801 ? 1 : -1; + current_actor_pointer->unkB8 = D_807FDC9C[0].unkD * D_8075AE10; + current_actor_pointer->y_rotation += angleSign * 400; + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + D_807FDC90->unk1A |= 0x8000; + current_actor_pointer->control_state = 0x10; + current_actor_pointer->control_state_progress = 0; + } + } + } else { + // Not Snapping + D_807FDC90->unk1A &= ~0x8000; + } + } + } + func_806AD260(0x1FA, 0, 0); + func_80724E48(current_actor_pointer->control_state == 0x23 ? 0 : 2); + func_806319C4(current_actor_pointer, 0); +} + +void func_806AD7AC(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_80724CA4(2, 1); + func_8072B79C(0x1F8, 0x1F8, 0x1F9); + } + func_806AD260(0x1FA, 0, 0); + func_80724E48(current_actor_pointer->control_state == 0x23 ? 0 : 2); + func_806319C4(current_actor_pointer, 0); +} + +void func_806AD84C(void) { + f32 temp_f0; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + temp_f0 = D_8075AE18; + current_actor_pointer->animation_state->scale_x = temp_f0; + current_actor_pointer->animation_state->scale_z = temp_f0; + current_actor_pointer->animation_state->scale_y = 2.0f; + current_actor_pointer->object_properties_bitfield |= 0x400; + } + switch (current_actor_pointer->control_state) { + case 0: + if ((current_actor_pointer->unk11C == 0) || ((current_actor_pointer->unk11C->unk6A & 1))) { + current_actor_pointer->control_state = 1; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + } else { + func_80671C0C(current_actor_pointer->unk11C, 2, ¤t_actor_pointer->x_position, ¤t_actor_pointer->y_position, ¤t_actor_pointer->z_position); + current_actor_pointer->z_rotation = current_actor_pointer->unk11C->z_rotation; + } + break; + case 1: + if (current_actor_pointer->shadow_opacity >= 0xB) { + current_actor_pointer->shadow_opacity -= 0xA; + } else { + func_806782C0(current_actor_pointer); + } + break; + } + current_actor_pointer->y_rotation = character_change_array[0].unk2C8 & 0xFFF; + func_806319C4(current_actor_pointer, 0); +} + +void func_806AD9AC(void) { + func_80677FA8(0x118, 0xC0); // Spawn actor: Spider Silk String (miniboss) + D_807FBB44->unk11C = current_actor_pointer; + D_807FBB44->draw_distance = 2000; +} + +void func_806AD9F4(void) { + s32 tmp_t0; + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FDC98->unk46 |= 0x200; + func_8072B79C(0x2F4, 0x2F4, 0x2F4); + if (current_actor_pointer->y_position != current_actor_pointer->floor) { + current_actor_pointer->control_state = 0x1E; + func_80614EBC(current_actor_pointer, 0x2F8); + func_806AD9AC(); + } + } + if (((D_807FBB70[0].unk200 == 9) || D_807FBB70[0].unk15) && (current_actor_pointer->control_state != 0x37)) { + func_8072D714(D_807FBB70[0].unk1FC, 0x2F7); + func_8072B324(current_actor_pointer, 0); + current_actor_pointer->unkB8 = -200.0f; + } else if (D_807FBB70[0].unk200 == 4) { + current_actor_pointer->unk132 = 2; + func_8072DEA8(0x2F6, 0x27, D_807FBB70[0].unk1FC); + current_actor_pointer->unkB8 *= 2; + D_807FDC90[0].unk2C = 0x1F4; + } + switch (current_actor_pointer->control_state) { + case 30: + func_8072AB74(0, D_807FDC94->x_position, D_807FDC94->z_position, 0x4202, 0.0f); + if (current_actor_pointer->control_state_progress != 0) { + func_8072DE44(0x2F4); + } + break; + case 39: + tmp_t0 = 1; + func_8072AB74(0, D_807FDC94->x_position, D_807FDC94->z_position, 0x4300, 0.0f); + current_actor_pointer->y_rotation += D_807FDC90[0].unk2C; + if (D_807FDC90[0].unk2C >= 0x15) { + D_807FDC90[0].unk2C -= 0x14; + } else { + D_807FDC90[0].unk2C = 0; + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + } + if ((current_actor_pointer->control_state_progress) && (D_807FDC90[0].unk2C == 0)) { + current_actor_pointer->unk132 = tmp_t0; + func_8072DE44(0x2F4); + } + break; + case 40: + switch (current_actor_pointer->control_state_progress) { + case 0: + func_8072B324(current_actor_pointer, 0); + func_80614EBC(current_actor_pointer, 0x2F5); + current_actor_pointer->control_state_progress++; + case 1: + func_8072AB74(0, D_807FDC94->x_position, D_807FDC94->z_position, 0x4200, 0.0f); + if (current_actor_pointer->unkB8 < 1.0f) { + current_actor_pointer->control_state_progress++; + } + break; + case 3: + func_8072DE44(0x2F4); + break; + } + break; + case 1: + if (((rand() >> 0xF) % 1000) >= 996) { + if ((current_actor_pointer->unk6A & 1)) { + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + } + } + default: + func_806AD260(0, 1, 0); + break; + } + func_8072881C(0, &D_807FDC90[0].unk28); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B1F60/func_806ADDD8.s") + +void func_8072B7CC(s32); + +/* +// TODO: Bleh, everything matches except for stack size +void func_806ADDD8(void) { + s32 temp = 0x31A; + // Might not need this + u8 pad = current_actor_pointer->control_state; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FDC98->unk46 |= 0x40; + D_807FDC98->unk28 = temp; + } + switch (current_actor_pointer->control_state) { + case 0: + case 1: + if (func_8072E22C(300)) { + func_80614EBC(current_actor_pointer, 0x31A); + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + } + break; + case 4: + if (current_actor_pointer->animation_state->unk64 != 0x319) { + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + } else if (func_8072E22C(100)) { + func_80614EBC(current_actor_pointer, 0x31B); + current_actor_pointer->control_state = 0x1E; + current_actor_pointer->control_state_progress = 0; + } + break; + case 30: + if (current_actor_pointer->animation_state->unk64 == 0x31A) { + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + } + break; + case 35: + if ((current_actor_pointer->animation_state->unk64 == 0x31A) && (current_actor_pointer->animation_state->unk0->unk4 > 4.0f)) { + func_8072AB74(current_actor_pointer->control_state, D_807FDC94->x_position, D_807FDC94->z_position, 0, 0.0f); + } + if (!func_8072E22C(300)) { + func_80614EBC(current_actor_pointer, 0x31C); + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + } + break; + default: + func_8072B7CC(temp); + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ diff --git a/src/global_asm/code_B2CE0.c b/src/global_asm/code_B2CE0.c new file mode 100644 index 00000000..0c8dd418 --- /dev/null +++ b/src/global_asm/code_B2CE0.c @@ -0,0 +1,126 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806ADFE0.s") + +void func_807248B0(Actor*, f32); + +void func_806AE2B0(s32 arg0, s16 arg1, s16 arg2, s16 arg3) { + f32 sp2C; + f32 sp28; + f32 sp24; + + if (func_80677FA8(0xED, arg0)) { // Spawn actor: Unknown 237 + func_80671C0C(current_actor_pointer, arg2, &sp2C, &sp28, &sp24); + D_807FBB44->floor = current_actor_pointer->floor; + D_807FBB44->y_rotation = current_actor_pointer->y_rotation + arg1; + D_807FBB44->unkEE = D_807FBB44->y_rotation; + D_807FBB44->unk168 = arg3; + D_807FBB44->x_position = sp2C; + D_807FBB44->y_position = sp28; + D_807FBB44->z_position = sp24; + func_807248B0(D_807FBB44, current_actor_pointer->animation_state->scale_y); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806AE394.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806AE588.s") + +void func_806AEE08(void) { + if ((((rand() >> 0xF) % 1000) >= 981) + && func_8072DE10(4000) + && !(D_807FDC90->unk1A & 0x80)) { + current_actor_pointer->control_state = 0x25; + current_actor_pointer->control_state_progress = 0; + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806AEE84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806AF688.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806AFA60.s") + +/* +extern f64 D_8075B098; + +extern s32 D_8072073C; // TODO: Proper datatype +extern s32 D_8071910C; // TODO: Proper datatype + +void func_80714C08(s32*, f32, Actor*, s32, s32); +void func_8071498C(s32*); + +// TODO: May need .data defined? s3 s2 regalloc +void func_806AFA60(u8 arg0) { + f32 temp_f22; + f64 temp_f20; + s16 i; + + temp_f20 = D_8075B098; + for (i = 0; i < 7; i++) { + temp_f22 = current_actor_pointer->animation_state->scale_y / temp_f20; + func_807149B8(1); + func_807149FC(0xA); + func_8071498C(&D_8071910C); + func_80714998(2); + func_80714950(0); + func_80714C08(&D_8072073C, temp_f22 * temp_f20, current_actor_pointer, arg0, 0); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806AFB58.s") + +void func_806B02EC(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_8072B79C(0, 0x31E, 0x31F); + } + func_806AD260(800, 0, 0); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806B0354.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806B0770.s") + +extern f32 D_8075B1AC; +extern u16 D_807FBB34; + +/* +// TODO: Might need .rodata for D_8075B1AC? +s32 func_806B0770(void) { + f32 dx, dy, dz; + Actor *temp_a0; + s16 phi_v0; + s32 phi_v1; + f32 temp; + + phi_v1 = FALSE; + phi_v0 = 0; + if (D_807FBB34 > 0) { + temp = D_8075B1AC; + do { + temp_a0 = D_807FB930[phi_v0].unk0; + if (temp_a0->unk58 == 0x29) { + dx = temp_a0->x_position - current_actor_pointer->x_position; + dy = temp_a0->y_position - current_actor_pointer->y_position; + dz = temp_a0->z_position - current_actor_pointer->z_position; + if (((dx * dx) + (dy * dy) + (dz * dz)) < temp) { + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + phi_v1 = TRUE; + } + } + phi_v0++; + } while (!phi_v1 && phi_v0 < D_807FBB34); + } + return phi_v1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B2CE0/func_806B0848.s") diff --git a/src/global_asm/code_B5EC0.c b/src/global_asm/code_B5EC0.c new file mode 100644 index 00000000..57c3a12e --- /dev/null +++ b/src/global_asm/code_B5EC0.c @@ -0,0 +1,86 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806883F4(Actor*, s32, u8, f32); +extern u8 D_807FBD70; +extern s32 D_80750600[]; + +// TODO: Are these 4 correct? +extern s32 D_8071FFA0; +extern f32 D_8075B2A0; +void func_806846B4(f32, f32, f32, f32, f32, Actor*, s32); +void func_80685B44(void*, s32, f32, s32, s32, s32, s32, s32, s32); + +void func_806B11C0(u8 arg0) { + f32 sp3C, sp38, sp34; + + func_80671C0C(current_actor_pointer, arg0, &sp3C, &sp38, &sp34); + func_80685B44(&D_8071FFA0, 0, 1.0f, 3, 5, 0x28, sp3C, current_actor_pointer->floor, sp34); + // spawnShockwave + func_806846B4(sp3C, current_actor_pointer->floor, sp34, 0.05f, D_8075B2A0, current_actor_pointer, 0); +} + +void func_806B1290(void) { + // TODO: Hahahaha clean this up + if (D_807FDC90[0].unk18 >= 0x65 + && ((D_807FDC90[0].unk1A & 0x80) && (rand() >> 0xF) % 1000 >= 981 + || !((rand() >> 0xF) % 1000 < 991) + && current_actor_pointer->object_properties_bitfield & 0x100)) { + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + } +} + +void func_806B1348(void) { + if ((D_807FDC90->unk18 >= 0x65) && (D_807FBD70 == 2) && (func_8072DE10(0x2710) != 0)) { + current_actor_pointer->control_state = 0x27; + current_actor_pointer->control_state_progress = 0; + } +} + +// Huge, jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B5EC0/func_806B13B4.s") + +void func_806B1D78(u8 arg0) { + func_8068842C(current_actor_pointer, 0, 1); + func_80688460(current_actor_pointer, 0, 1); + func_806883F4(current_actor_pointer, 0, arg0, 0); +} + +void func_806B1DD4(u8 arg0) { + u8 phi_v1; + s32 levelIndex; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + phi_v1 = 0; + levelIndex = func_805FF000(D_8076A0AB); + if ((levelIndex != 9) && (levelIndex != 0xA)) { + levelIndex = getLevelIndex(D_8076A0AB, TRUE); + phi_v1 = !func_80731A04(0x1D5, levelIndex, levelIndex, D_80750600[arg0]); + } + func_806B1D78(phi_v1 != 0 ? arg0 : 5); + current_actor_pointer->unk15F = phi_v1; + } + func_806B13B4(current_actor_pointer->unk15F); +} + +void func_806B1EA8(void) { + func_806B1DD4(4); +} + +void func_806B1EC8(void) { + func_806B1DD4(2); +} + +void func_806B1EE8(void) { + func_806B1DD4(3); +} + +void func_806B1F08(void) { + func_806B1DD4(0); +} + +void func_806B1F28(void) { + func_806B1DD4(1); +} diff --git a/src/global_asm/code_B6C50.c b/src/global_asm/code_B6C50.c new file mode 100644 index 00000000..6faf2a25 --- /dev/null +++ b/src/global_asm/code_B6C50.c @@ -0,0 +1,8 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B6C50/func_806B1F50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B6C50/func_806B24B8.s") diff --git a/src/global_asm/code_B7490.c b/src/global_asm/code_B7490.c new file mode 100644 index 00000000..dc033aa7 --- /dev/null +++ b/src/global_asm/code_B7490.c @@ -0,0 +1,417 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s16 D_80750340; +extern f32 D_8075B5C0; +extern f64 D_8075B708; +extern f64 D_8075B710; + +extern s32 D_8076A064; + +extern u8 D_807FBD70; + +void func_80614D00(Actor*, f32, f32); +void func_8069084C(u8, s32, f32, s16, f32, f32, Actor*); +void func_806907F0(f32, f32, f32); +void func_80690A28(u8, s32, f32, f32, f32, f32, f32, Actor*); +s32 func_80726164(Actor*, s16, s16, s16, void*); +void func_806B3E7C(); +void func_8068588C(Actor *, s32, f32, f32, f32, f32, s32); +void func_80714998(s32); +void func_807149C8(u8, u8, u8, u8); +void func_806653C0(Actor*, f32, f32); +void func_80665564(Actor*, f32); +void func_806086CC(f32, f32, f32, s32, s32, s32, s32, s32, f32, s32); +void func_807248B0(Actor*, f32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B2790.s") + +void func_806B2D5C(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B2D64.s") + +void func_806B3420(void) { + f32 dx, dy, dz; + s32 temp; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->unk64 |= 0x24; + current_actor_pointer->object_properties_bitfield |= 0x400; + D_807FDC90[0].unk2C = 0x5A; + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + func_8067ACB4(current_actor_pointer); + func_8066EA90(current_actor_pointer, 1); + } + dx = current_actor_pointer->x_position - D_807FDC94->x_position; + dy = current_actor_pointer->y_position - D_807FDC94->y_position; + dz = current_actor_pointer->z_position - D_807FDC94->z_position; + if (D_8075B5C0 < ((dx * dx) + (dy * dy) + (dz * dz))) { + current_actor_pointer->object_properties_bitfield |= 0x80000000; + } else { + current_actor_pointer->object_properties_bitfield &= ~0x80000000; + } + switch (current_actor_pointer->control_state) { + case 0: + if (D_807FDC90[0].unk2C) { + D_807FDC90[0].unk2C--; + } else { + func_80614EBC(current_actor_pointer, 0x35D); + func_80614D00(current_actor_pointer, 0.5f, 0.0f); + current_actor_pointer->control_state = 1; + current_actor_pointer->control_state_progress = 0; + } + break; + case 1: + if (current_actor_pointer->control_state_progress) { + current_actor_pointer->control_state = 2; + current_actor_pointer->control_state_progress = 0; + D_807FDC90[0].unk2C = 0x5A; + } + break; + case 2: + temp = 2; + if (D_807FDC90[0].unk2C) { + D_807FDC90[0].unk2C--; + } else { + current_actor_pointer->unk132 = temp; + func_80614D00(current_actor_pointer, 0.5f, 0.0f); + current_actor_pointer->control_state = 3; + current_actor_pointer->control_state_progress = 0; + } + break; + case 3: + temp = 1; + if (current_actor_pointer->control_state_progress) { + current_actor_pointer->unk132 = temp; + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + D_807FDC90[0].unk2C = 0x5A; + } + break; + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B3680.s") + +void func_806B3C30(u8 arg0) { + func_80690814(current_actor_pointer, arg0); + func_8069084C(0x32, 1, 0.3f, current_actor_pointer->unkEE, 80.0f, 0.0f, current_actor_pointer); +} + +void func_806B3C94(void) { + func_806907F0(current_actor_pointer->x_position, current_actor_pointer->y_position - 5.0f, current_actor_pointer->z_position); + func_80690A28(0x51, 1, 0.3f, D_807FDC94->x_position, D_807FDC94->y_position, D_807FDC94->z_position, 80.0f, current_actor_pointer); +} + +void func_806B3D18(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + if (func_8072E0A8(0x96, 0x96)) { + func_80614EBC(current_actor_pointer, 0x253); + current_actor_pointer->control_state_progress = 1; + } + break; + case 2: + func_806B3C30(2); + current_actor_pointer->control_state_progress = 3; + break; + } +} + +void func_806B3DA4(void) { + if (D_807FDC90[0].unk2C) { + D_807FDC90[0].unk2C--; + return; + } + if (func_8072E0A8(0x96, 0x96)) { + func_806B3C30(1); + D_807FDC90[0].unk2C = D_80750340; + } +} + +void func_806B3E08(void) { + if (D_807FDC90[0].unk2C) { + D_807FDC90[0].unk2C--; + if ((object_timer & 1)) { + func_806B3C94(); + } + } else if (func_8072E0A8(0x96, 0x96)) { + D_807FDC90->unk2C = 0x14; + } +} + +void func_806B3E7C(void) { + if (D_807FDC90->unk2C != 0) { + D_807FDC90->unk2C--; + return; + } + if ((func_80726164(current_actor_pointer, D_807FDC94->x_position, D_807FDC94->y_position, D_807FDC94->z_position, D_807FDCA0)) && (func_8072E0A8(0x96, 0x96))) { + current_actor_pointer->control_state = 0x26; + current_actor_pointer->control_state_progress = 0; + } +} + +void func_806B3F3C(void) { + if (((rand() >> 0xF) % 1000) >= 996) { + current_actor_pointer->control_state = 0x1C; + current_actor_pointer->control_state_progress = 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B3F90.s") + +f32 func_80665E94(f32, f32, f32, f32, f32, f32, s32); +s16 func_806CC190(s16, s16, f32); +s32 func_8072AB74(u8, f32, f32, s32, f32); +extern f64 D_8075B5E0; +extern f64 D_8075B5E8; + +typedef struct GlobalASMStruct91 { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; // Used, X? + s16 unkC; // Used, Y? + s16 unkE; // Used, Z? +} GlobalASMStruct91; + +/* +// TODO: Very doable, float regalloc, I might have got the MIN/MAX macros mixed up? +void func_806B3F90(GlobalASMStruct91 *arg0, u8 arg1) { + f32 dz; + f32 dx; + f32 var_f16; + f32 var_f18; + f64 temp_f16; + + dz = arg0->unkE - current_actor_pointer->z_position; + dx = arg0->unkA - current_actor_pointer->x_position; + temp_f16 = sqrtf((dz * dz) + (dx * dx)); + if ((temp_f16 / MAX(current_actor_pointer->unkB8, D_8075B5E0)) < D_8075B5E0) { + var_f18 = D_8075B5E0; + } else { + var_f18 = temp_f16 / MIN(current_actor_pointer->unkB8, D_8075B5E0); + } + current_actor_pointer->y_velocity = 0.0f; + if (current_actor_pointer->y_position < arg0->unkC) { + var_f16 = 0.0f; + } else { + var_f16 = current_actor_pointer->y_position - arg0->unkC; + } + current_actor_pointer->y_acceleration = -(var_f16 / var_f18); + current_actor_pointer->z_rotation = func_806CC190(current_actor_pointer->z_rotation, (func_80665E94(arg0->unkA, arg0->unkC, arg0->unkE, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0x46) * 2048.0) / D_8075B5E8, 3.3f); + func_8072AB74(arg1, arg0->unkA, arg0->unkE, 0x2E0, 0.0f); +} +*/ + +void func_806B4194(void) { + u8 temp; + u8 sp2E; + f32 sp28; + u32 phi_v0; + + switch (current_actor_pointer->health) { + case 2: + sp2E = 200; + sp28 = 0.5f; + phi_v0 = 0x20; + break; + case 1: + sp2E = 100; + sp28 = 1.0f; + phi_v0 = 0x18; + break; + case 0: + sp2E = 50; + sp28 = 1.5f; + phi_v0 = 8; + break; + default: + phi_v0 = 0; + } + if (phi_v0 && ((D_8076A064 % phi_v0) == 0)) { + func_80714998(3); + func_807149C8(sp2E, sp2E, sp2E, current_actor_pointer->shadow_opacity); + func_8068588C(current_actor_pointer, 1, sp28, 0.0f, 0.0f, 0.0f, -0x50); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B42A8.s") + +void func_806B486C() { + func_80729B00(); + func_806B42A8(&func_806B3E7C, 0x251, 0x250, 0x10E); + func_8072881C(0, &D_807FDC90[0].unk28); +} + +void func_806B48B8() { + func_80729B00(); + func_806B42A8(&func_806B3DA4, 0x251, 0x250, 0x10E); + func_8072881C(0, &D_807FDC90[0].unk28); +} + +void func_806B4904() { + func_80729B00(); + func_806B42A8(&func_806B3D18, 0x254, 0x252, 0x108); + func_806B4194(); + func_8072881C(0, &D_807FDC90[0].unk28); +} + +void func_806B4958() { + func_80729B00(); + func_806B42A8(&func_806B3E7C, 0x251, 0x250, 0x10E); + if (current_actor_pointer->control_state != 0x37) { + func_806B3E08(); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B49B0.s") + +void func_806B4DCC(void) { + s32 tmp; + s32 tmp2; + Actor178 *sp3C; + + sp3C = current_actor_pointer->unk178; + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->object_properties_bitfield |= 0x400; + D_807FDC98->unk46 |= 0x40; + current_actor_pointer->unk16A = 0xFA; + current_actor_pointer->unk16B = 0xFA; + current_actor_pointer->unk16C = 0xFA; + func_8069E490(0x2D, 0x44); + func_806086CC(current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position, 0x2C1, 0xFF, 0x7F, 0, 0x14, 0.0f, 0); + } + sp3C->unk0 = MAX(0, D_807FDC90[0].unkC - D_807FDC9C[0].unk6); + if (D_807FBD70 == 9) { + if (current_actor_pointer->control_state != 0x37) { + current_actor_pointer->control_state = 0x37; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0x248); + func_8069E5B8(); + playSong(0x14, 1.0f); + func_8063DA40(0x7F, 0xA); + } + } + if ((current_actor_pointer->control_state != 0x37) && (current_actor_pointer->control_state != 0x40)) { + func_8069E4E0(-0x1E); + } + func_807248B0(current_actor_pointer, ((D_807FDC90[0].unk30 - current_actor_pointer->animation_state->scale_x) * D_8075B708) + current_actor_pointer->animation_state->scale_x); + if (D_807FDC90[0].unk2C != 0) { + D_807FDC90[0].unk2C--; + if ((object_timer & 4) != 0) { + current_actor_pointer->object_properties_bitfield |= 0x800000; + } else { + current_actor_pointer->object_properties_bitfield &= ~0x800000; + } + } else { + current_actor_pointer->unk132 = 1; + current_actor_pointer->object_properties_bitfield &= ~0x800000; + if (D_807FBD70 == 4) { + current_actor_pointer->unk132 = 2; + D_807FDC90[0].unk2C = 0x1E; + D_807FDC90[0].unk30 *= D_8075B710; + func_8072D9D4(); + playCutscene(current_actor_pointer, 3, 5); + if ((current_actor_pointer->health & 1) != 0) { + func_80614EBC(current_actor_pointer, 0x24A); + } else { + func_80614EBC(current_actor_pointer, 0x249); + } + } + } + func_806B49B0(current_actor_pointer->control_state, 0x247, 0x246); + func_8072881C(0, &D_807FDC90->unk28); + func_806319C4(current_actor_pointer, 0); +} + +void func_806B50F4() { + func_80729B00(); + func_806B49B0(current_actor_pointer->control_state, 0x23D, 0x23E); + func_806319C4(current_actor_pointer, 0); +} + +void func_806B513C(void) { + s32 temp_t3; + void *phi_a0; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_8072B79C(0x30C, 0x30B, 0x30D); + current_actor_pointer->object_properties_bitfield &= ~0x8000; + } + if (current_map == MAP_CASTLE_CHUNKY_TOOLSHED) { + temp_t3 = extra_player_info_pointer->unk1F0 & 0x40; + if ((temp_t3 != 0) && (current_actor_pointer->shadow_opacity == 0)) { + D_807FDC90->unk2C = 0xA; + current_actor_pointer->noclip_byte = 0x24; + } else if ((temp_t3 == 0) && (current_actor_pointer->shadow_opacity == 0xFF)) { + D_807FDC90->unk2C = -0xA; + current_actor_pointer->noclip_byte = 1; + } + if (D_807FDC90->unk2C != 0) { + current_actor_pointer->shadow_opacity += D_807FDC90->unk2C; + if (current_actor_pointer->shadow_opacity >= 0x100) { + current_actor_pointer->shadow_opacity = 0xFF; + D_807FDC90->unk2C = 0; + } else if (current_actor_pointer->shadow_opacity < 0) { + current_actor_pointer->shadow_opacity = 0; + D_807FDC90->unk2C = 0; + } + } + } + if ((object_timer & 1)) { + phi_a0 = &func_806B3E7C; + } else { + phi_a0 = &func_806B3F3C; + } + func_806B42A8(phi_a0, 0x30E, 0x30B, 0); +} + +void func_806B52DC(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FDC98->unk46 |= 0x60; + D_807FDC98->unk46 &= ~0x08; + current_actor_pointer->unkB8 = ((rand() >> 0xF) % 100) + 0x12C; + current_actor_pointer->y_position += (rand() >> 0xF) % 30; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->shadow_opacity = 0; + current_actor_pointer->unkEC = ((rand() >> 0xF) % 7) + 0xF; + } + func_8067ACB4(current_actor_pointer); + func_806653C0(current_actor_pointer, current_actor_pointer->unkB8, 0); + func_80665564(current_actor_pointer, 0); + switch (current_actor_pointer->control_state) { + case 0x6: + current_actor_pointer->shadow_opacity += current_actor_pointer->unkEC; + if (current_actor_pointer->shadow_opacity >= 0xFF) { + current_actor_pointer->shadow_opacity = 0xFF; + current_actor_pointer->control_state = 0x37; + } + break; + case 0x37: + current_actor_pointer->shadow_opacity -= current_actor_pointer->unkEC; + if (current_actor_pointer->shadow_opacity < 0) { + current_actor_pointer->control_state = 0x3C; + current_actor_pointer->shadow_opacity = 0; + } + break; + default: + func_8072B7CC(0x333); + break; + } + func_8072881C(0, &D_807FDC90->unk28); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B54BC.s") diff --git a/src/global_asm/code_BA790.c b/src/global_asm/code_BA790.c new file mode 100644 index 00000000..b63009dc --- /dev/null +++ b/src/global_asm/code_BA790.c @@ -0,0 +1,13 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BA790/func_806B5A90.s") + +void func_806B63E0() { + func_80729B00(); + func_806B5A90(10000, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BA790/func_806B640C.s") diff --git a/src/global_asm/code_BB300.c b/src/global_asm/code_BB300.c new file mode 100644 index 00000000..81faccf4 --- /dev/null +++ b/src/global_asm/code_BB300.c @@ -0,0 +1,91 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern f32 D_807502E8; +extern s16 D_807502E0; +extern u8 D_807FBD70; + +void func_8072B324(Actor*, s32); +void func_8072AB74(s32, f32, f32, s32, f32); + +// Doable, Actor178 stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BB300/func_806B6600.s") + +void func_806B6958(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FDC90->unk35 *= 2; + D_807FDC90->unk2C = 210; + D_807FDC90->unk1F *= 1.5; + D_807FDC90->unk1E *= 1.5; + } + if (D_807FDC90->unk2C != 0) { + D_807FDC90->unk2C--; + } + if ((D_807FDC90->unk2C % 30) == 0) { + D_807FDC90->unk1F--; + D_807FDC90->unk1E--; + } + if (D_807FBB70->unk200 == 4) { + func_80724C2C(-150, &D_807FDC90); + } + if ((D_807FDC90->unk2C == 0) || (D_807FBB70->unk200 == 9) || (D_807FBB70->unk15 != 0)) { + func_80608528(current_actor_pointer, 0x3B2, 0xFF, 0x7F, 0x1E); + func_80608528(current_actor_pointer, 0x3B7, 0xFF, 0x7F, 0x1E); + func_806850D0(); + func_806782C0(current_actor_pointer); + } + if (current_actor_pointer->control_state == 0x23) { + func_8072AB74(0x23, D_807FDC94->x_position, D_807FDC94->z_position, 0x200, 0.0f); + } else { + func_8072B7CC(0x237); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806B6C88(s16 arg0, s16 arg1) { + if (func_80677FA8(0xD3, 0x24)) { // Spawn actor: Klaptrap (Skeleton) + D_807FBB44->control_state = 0x23; + func_80614EBC(D_807FBB44, 0x237); + D_807FBB44->y_rotation = arg1; + D_807FBB44->unkEE = D_807FBB44->y_rotation; + func_8067B238(D_807FBB44, + current_actor_pointer, + current_actor_pointer->animation_state->scale_y); + D_807FBB44->floor = current_actor_pointer->floor; + D_807FBB44->y_acceleration = D_807502E8; + D_807FBB44->terminal_velocity = D_807502E0; + D_807FBB44->unkB8 = 0.0f; + func_8072B324(current_actor_pointer, arg0 * 1.25); + // TODO: Which aaD type are they actually expecting here? + memcpy(D_807FBB44->PaaD, + current_actor_pointer->PaaD, + 0x3C); + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BB300/func_806B6DB0.s") + +void func_806B75F4() { + func_80729B00(); + func_806B6DB0(10000); +} + +void func_806B761C() { + func_80729B00(); + if (D_807FBD70 == 4) { + func_80724C2C(-100); + } + func_806B6DB0(10000); +} + +void func_806B7660() { + func_80729B00(); + if (D_807FBD70 == 4) { + func_80724C2C(-100); + } + func_806B6DB0(10000); +} \ No newline at end of file diff --git a/src/global_asm/code_BC3B0.c b/src/global_asm/code_BC3B0.c new file mode 100644 index 00000000..7eb818ce --- /dev/null +++ b/src/global_asm/code_BC3B0.c @@ -0,0 +1,109 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B76B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B7830.s") + +extern f32 D_8075B878; + +void func_806907F0(f32, f32, f32); +void func_80690A28(s16, s32, f32, f32, f32, f32, f32, Actor*); + +void func_806B7BB8(s32 arg0) { + s32 phi_v1; + + if ((current_map != MAP_CAVES_SHACK_CHUNKY) && (current_map != MAP_CAVES_IGLOO_DIDDY)) { + phi_v1 = 30; + } else { + phi_v1 = 99; + } + func_806907F0(D_807FDC94->x_position, D_807FDC94->y_position + 100.0f, D_807FDC94->z_position); + func_80690A28(phi_v1, 1, 0.5f, D_807FDC94->x_position, D_807FDC94->y_position, D_807FDC94->z_position, D_8075B878, current_actor_pointer); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B7C74.s") + +extern f64 D_8075B880; +extern f64 D_8075B888; +extern f64 D_8075B890; + +typedef struct GlobalASMStruct90 { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} GlobalASMStruct90; + +extern s16 D_80744490; +extern s16 D_80744494; + +/* +// TODO: Doable, annoying float stuff +void func_806B7C74(GlobalASMStruct90 *arg0, f32 arg1, f32 arg2) { + f32 var_f2; + f32 var_f2_2; + f32 var_f2_3; + f32 var_f2_4; + + if (arg1 < arg0->unk0) { + // Problem here + arg0->unk8 -= D_8075B880; + if (arg0->unk8 < -5.0f) { + arg0->unk8 = -5.0f; + } + } else if (arg0->unk0 < arg1) { + // Problem here + arg0->unk8 += D_8075B888; + if (arg0->unk8 > 5.0f) { + arg0->unk8 = 5.0f; + } + } + if (arg2 < arg0->unk4) { + // Problem here + arg0->unkC -= D_8075B890; + if (arg0->unkC < -5.0f) { + arg0->unkC = -5.0f; + } + } else if (arg0->unk4 < arg2) { + // Problem here + arg0->unkC += D_8075B890; + if (arg0->unkC > 5.0f) { + arg0->unkC = 5.0f; + } + } + // Here down is all good I think + var_f2 = MAX(arg0->unk0 + arg0->unk8, 0.0f); + if (var_f2 < D_80744490) { + var_f2_2 = MAX(arg0->unk0 + arg0->unk8, 0.0f); + arg0->unk0 = var_f2_2; + } else { + arg0->unk0 = D_80744490; + } + var_f2_3 = MAX(arg0->unk4 + arg0->unkC, 0.0f); + if (var_f2_3 < D_80744494) { + var_f2_4 = MAX(arg0->unk4 + arg0->unkC, 0.0f); + arg0->unk4 = var_f2_4; + } else { + arg0->unk4 = D_80744494; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B7EA0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B83E4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B86AC.s") + +void func_806B8878(void) { + func_806B88B8(); +} + +void func_806B8898(void) { + func_806B88B8(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BC3B0/func_806B88B8.s") diff --git a/src/global_asm/code_BD820.c b/src/global_asm/code_BD820.c new file mode 100644 index 00000000..f8034cae --- /dev/null +++ b/src/global_asm/code_BD820.c @@ -0,0 +1,107 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_80717D4C; +extern s32 D_8071FFA0; +extern s32 D_8071C9E8; // TODO: Datatype +extern s32 D_8074E880[]; // TODO: Datatype + +void func_806B8B20(s16 arg0, s16 arg1, s16 arg2, s16 arg3) { + func_8071498C(&D_8071C9E8); + func_807149FC(-1); + func_807149B8(1); + func_8071496C(arg3); + func_80714CC0(D_8074E880[((rand() >> 0xF) % 1000) % 3], 1.8f, arg0, arg1, arg2); +} + +void func_806B8BDC(s16 arg0, s16 arg1, s16 arg2) { + func_80714998(2); + func_8071498C(&D_80717D4C); + func_80714950(-0x28); + func_807149B8(1); + func_807149C8(0xFF, 0xFF, 0xFF, 0xC8); + func_80714CC0(&D_8071FFA0, 2.0f, arg0, arg1, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BD820/func_806B8C78.s") + +extern f32 D_8075B8B0; +extern f32 D_8075B8B4; +extern f32 D_8075B8B8; +extern s16 D_807F6248; +extern s16 D_807F624C; + +extern void func_80659670(f32, f32, f32, s32); + +/* +// TODO: Regalloc, damn it +void func_806B8C78(void) { + switch (current_actor_pointer->control_state) { + case 1: + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->y_velocity = 0.0f; + func_80614EBC(current_actor_pointer, 0x290); + current_actor_pointer->control_state_progress++; + break; + case 2: + if (current_actor_pointer->y_position > -20.0f) { + current_actor_pointer->y_position -= current_actor_pointer->y_velocity; + } + current_actor_pointer->y_velocity = MAX(current_actor_pointer->y_velocity + 0.5, 8.0f); + break; + } + break; + case 2: + func_806B8B20(0x258, 0x64, 0x1E5, 0x64); + func_806B8B20(0x258, 0x96, 0x1E5, 0x64); + func_806B8B20(0x258, 0xC8, 0x1E5, 0x67); + func_806B8B20(0x258, 0xFA, 0x1E5, 0x68); + func_806B8B20(0x258, 0x12C, 0x1E5, 0x6C); + func_806B8B20(0x258, 0x15E, 0x1E5, 0x6E); + func_806B8B20(0x258, 0x190, 0x1E5, 0x73); + func_806B8B20(0x258, 0x1C2, 0x1E5, 0x74); + current_actor_pointer->control_state++; + D_807FDC90->unk2C = 0x46; + break; + case 3: + if (D_807FDC90->unk2C != 0) { + D_807FDC90->unk2C--; + } else { + current_actor_pointer->control_state = 0x40; + } + if (D_807FDC90->unk2C < 0x28) { + func_8063C1EC(4, 0x10, &D_807FDC90); + func_8063C1EC(6, 0x10); + func_8063C248(5, 0x10); + func_8063C248(7, 0x10); + if (((D_807FDC90->unk2C < 0x15) && (((rand() >> 0xF) % 1000) < 0x12C)) || (current_actor_pointer->control_state == 0x40)) { + if (current_actor_pointer->control_state == 0x40) { + func_8063C1EC(5, 0x10); + func_8063C1EC(7, 0x10); + playSound(0x1D0, 0x58EF, 63.0f, 1.0f, 0, 0); + playSong(0x3A, 1.0f); + func_806B8BDC(0xBD, 0xAA, 0x2FB); + func_806B8BDC(0x19A, 0xA6, 0x2F8); + } + func_8065F134(D_807F6248, 0); + func_8065F134(D_807F624C, 0); + func_80659670(D_8075B8B0, D_8075B8B0, D_8075B8B0, 0); + return; + } + if (D_807FDC90->unk2C >= 0x15) { + func_8065F134(D_807F6248, 9); + func_8065F134(D_807F624C, 9); + func_80659670(D_8075B8B4, D_8075B8B4, D_8075B8B4, 0); + return; + } + func_8065F134(D_807F6248, 8); + func_8065F134(D_807F624C, 8); + func_80659670(D_8075B8B8, D_8075B8B8, D_8075B8B8, 0); + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BD820/func_806B904C.s") diff --git a/src/global_asm/code_BDEE0.c b/src/global_asm/code_BDEE0.c new file mode 100644 index 00000000..f8faa5ce --- /dev/null +++ b/src/global_asm/code_BDEE0.c @@ -0,0 +1,233 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s32 D_8071720C; +extern s32 D_80717D4C; +extern s32 D_8074E880[]; +extern u8 D_80750628[]; +extern f32 D_8075B9E0; + +void func_80612BC0(Mtx*, f32); +void func_80612C30(Mtx*, f32); +void func_80611A70(f32, f32, f32*, f32*); +f32 func_80611BB4(f32, f32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806B91E0.s") + +void func_806B9CB0() { + func_80729B00(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806B9CE0(u8 arg0, s8 arg1) { + switch (arg0) { + case 0: + func_8071498C(&D_8071720C); + break; + case 1: + func_80714950(-0x258); + func_8071498C(&D_80717D4C); + break; + } + func_807149B8(1); + func_80714CC0( + D_8074E880[((rand() >> 0xF) % 1000) % 3], + (((rand() >> 0xF) % 256) * 0.001953125) + 0.5, + ((rand() >> 0xF) % 6) + (current_actor_pointer->x_position - 3.0f), + current_actor_pointer->y_position + arg1, + ((rand() >> 0xF) % 6) + (current_actor_pointer->z_position - 3.0f) + ); +} + +s32 func_806B9EB4(u8 arg0, u8 arg1, f32 arg2, f32 arg3, f32 arg4) { + Mtx sp80; + Mtx sp40; + f32 sp3C; + f32 sp38; + f32 sp34; + f32 temp; + f32 sp2C; + + if (D_80750628[arg0]) { + func_80671C0C(D_807FDCA0->unk1C, D_80750628[arg0], &sp3C, &sp38, &sp34); + func_80611A70(arg2, arg4, &sp3C, &sp34); + sp2C = func_80611BB4(sp3C - arg2, sp34 - arg4); + guTranslateF(&sp80, 0.0f, -arg1, 0.0f); + func_80612C30(&sp40, (current_actor_pointer->y_rotation * 360) / 4096); + guMtxCatF(&sp80, &sp40, &sp80); + func_80612BC0(&sp40, -90.0f); + guMtxCatF(&sp80, &sp40, &sp80); + guAlignF(&sp40, (sp2C * D_8075B9E0) + 180.0f, sp3C - arg2, sp38 - arg3, sp34 - arg4); + guMtxCatF(&sp80, &sp40, &sp80); + guTranslateF(&sp40, 0.0f, arg1, 0.0f); + guMtxCatF(&sp80, &sp40, &sp80); + guScaleF(&sp40, + current_actor_pointer->animation_state->scale_x, + current_actor_pointer->animation_state->scale_y, + current_actor_pointer->animation_state->scale_z); + guMtxCatF(&sp80, &sp40, &sp80); + guTranslateF(&sp40, + current_actor_pointer->x_position, + current_actor_pointer->y_position, + current_actor_pointer->z_position); + guMtxCatF(&sp80, &sp40, ¤t_actor_pointer->unkC); + return TRUE; + } + return FALSE; +} + +void func_806BA130(void) { + current_actor_pointer->interactable = 2; + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->health = 1; + current_actor_pointer->unk132 = 1; + D_807FDC90[0].unk4 = player_pointer; + func_80614EBC(current_actor_pointer, D_807FDC98->unk2A); + current_actor_pointer->y_rotation = (((rand() >> 0xF) % 1024) + player_pointer->y_rotation) - 0x200; + current_actor_pointer->unkB8 = ((rand() >> 0xF) % 100) + 50; + current_actor_pointer->y_velocity = ((rand() >> 0xF) % 150) + 100; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806BA240.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806BA76C.s") + +void func_806BA8C8(void) { + switch (current_actor_pointer->control_state) { + case 0x2: + case 0x3: + func_8072D13C(current_actor_pointer->control_state, 0); + default: + func_8072C918(10000, 0, 0); + break; + case 0x15: + case 0x37: + case 0x40: + break; + } +} + +// Huge, float matrix stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806BA93C.s") + +void func_806BB32C(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->unk16A = 0xFA; + current_actor_pointer->unk16B = 0xFA; + current_actor_pointer->unk16C = 0xFA; + } + if (current_actor_pointer->control_state == 0x17) { + func_806B9CE0(0, 0); + } + if (D_807FDC90[0].unk2E != 0) { + D_807FDC90[0].unk2E--; + current_actor_pointer->unkFC = 0; + if ((D_807FDC90[0].unk2E == 0) && (D_807FDC94 == player_pointer)) { + current_actor_pointer->noclip_byte = 0x24; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806BB400.s") + +extern f32 D_8075BAEC; +extern f32 D_8075BAF0; +void func_807248B0(Actor*, f32); +s16 func_80665DE0(f32, f32, f32, f32); +void func_8072AB74(s32, f32, f32, s32, f32); +void func_806D0430(f32); + +/* +// TODO: Very close, 1 extra instruction related to default case in the second switch +void func_806BB400(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_806D0430(D_8075BAEC); + player_pointer->object_properties_bitfield |= 0x400; + player_pointer->draw_distance = 0x7D0; + current_actor_pointer->object_properties_bitfield &= -5; + func_807248B0(current_actor_pointer, 1.0f); + current_actor_pointer->unk15F = 0; + current_actor_pointer->y_rotation = func_80665DE0(player_pointer->x_position, player_pointer->z_position, current_actor_pointer->x_position, current_actor_pointer->z_position); + func_80614EBC(current_actor_pointer, 0x21B); + D_807FDC98->unk46 |= 8; + D_807FDC98->unk28 = 0x21C; + } + switch (current_actor_pointer->control_state) { + case 0x4: + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + // fallthrough + case 0x23: + switch (current_actor_pointer->control_state_progress) { + case 0: + func_8072AB74(0x37, 0.0f, 0.0f, 0x202, 0.0f); + break; + default: + current_actor_pointer->control_state_progress = 1; + // break; + case 1: + if (current_actor_pointer->animation_state->unk64 != 0x21C) { + func_80614EBC(current_actor_pointer, 0x21C); + } + func_8072AB74(current_actor_pointer->control_state, D_807FDC94->x_position, D_807FDC94->z_position, 0, 0.0f); + break; + case 2: + break; + } + break; + case 0x37: + func_806D0430(D_8075BAF0); + current_actor_pointer->control_state = 0x40; + break; + } + D_807FDCA0->unk20 = 0; + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806BB604.s") + +//need these forward declarations to match, not sure if type is right +void func_80604CBC(Actor*,s32,s32,s32,s32,s32,f32,s32); + +void func_806BB81C() { + func_80604CBC(current_actor_pointer, 0x11F, 0, 0, 0, 0xFF, 1.0f, 0); + playSong(0x3B, 1.0f); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_BDEE0/func_806BB874.s") + +void func_806BC080() { + func_806BB32C(); + if ((D_807FDC9C[0].unkA == 0) || (func_806BA240(0, 0x446) == 0)) { + func_806AD260(0x2ED, 1, 0); + func_806319C4(current_actor_pointer, 0); + } +} + +void func_806BC0E4() { + func_806BB32C(); + if ((D_807FDC9C[0].unkA == 0) || (func_806BA240(0x32, 0x44E) == 0)) { + func_806AD260(0x2EC, 1, 0); + func_806319C4(current_actor_pointer, 0); + } +} + +void func_806BC148() { + func_806BB32C(); + if ((D_807FDC9C[0].unkA == 0) || (func_806BA240(0x14, 0x44A) == 0)) { + func_806AD260(0x2EE, 1, 0); + func_806319C4(current_actor_pointer, 0); + } +} + +void func_806BC1AC() { + func_806BB32C(); + func_806BA93C(0x24, 0x14, 0x1E); +} diff --git a/src/global_asm/code_C0EE0.c b/src/global_asm/code_C0EE0.c new file mode 100644 index 00000000..8b24bee3 --- /dev/null +++ b/src/global_asm/code_C0EE0.c @@ -0,0 +1,39 @@ +#include +#include "functions.h" +#include "variables.h" + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C0EE0/func_806BC1E0.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C0EE0/func_806BCF98.s") + +// Caves Ice Tomato Board State +extern s8 D_807FC8C0[]; + +void func_8063DA40(s16, s32); + +// Set Caves Ice Tomato Board Square +void func_806BD094(s16 arg0, s8 arg1) { + if (arg0 >= 0 && arg0 < 0x10) { + D_807FC8C0[arg0] = arg1; + } +} + +// Reset Caves Ice Tomato Board +void func_806BD0CC(void) { + s32 i; + + // Caves: Ice Tomato Board Active + setFlag(0x30, FALSE, FLAG_TYPE_TEMPORARY); + + for (i = 0; i < 16; i++) { + D_807FC8C0[i] = -1; + func_8063DA40(i, 0); + } + + D_807FC8C0[5] = 0; + D_807FC8C0[6] = 1; + D_807FC8C0[9] = 1; + D_807FC8C0[10] = 0; +} diff --git a/src/global_asm/code_C1E70.c b/src/global_asm/code_C1E70.c new file mode 100644 index 00000000..b16a3d0f --- /dev/null +++ b/src/global_asm/code_C1E70.c @@ -0,0 +1,88 @@ +#include +#include "functions.h" +#include "variables.h" + +// Doable, big, interesting +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C1E70/func_806BD170.s") + +f32 func_80612794(s16); +void func_80677FA8(s32, s32); +extern s8 D_80750660; +extern s8 D_807506A4; +extern s8 D_807FC8D0; + +// TODO: Add to aaD union +typedef struct { + s16 unk0; + s8 unk2; // keyIndex + s8 unk3; + Actor *unk4; +} PadlockAAD; + +/* +void func_806BD170(void) { + PadlockAAD *temp_v0; + s8 keyIndex; + s16 sp50; + s16 temp_s2; + + sp50 = -1; + for (keyIndex = 0; keyIndex < 8; keyIndex++) { + // Key[keyIndex] Turned Flag + if (!isFlagSet(0x1BC + keyIndex, FLAG_TYPE_PERMANENT)) { + // Spawn Padlock + func_80677FA8(0x14E, 0xCD); + temp_s2 = 260 + (keyIndex * 512); + D_807FBB44->draw_distance = 2000; + D_807FBB44->object_properties_bitfield |= 0x800400; + D_807FBB44->object_properties_bitfield &= ~0x8000; + D_807FBB44->unk16A = 0xFF; + D_807FBB44->unk16B = 0xFF; + D_807FBB44->unk16C = 0xFF; + D_807FBB44->shadow_opacity = 0xFF; + D_807FBB44->x_position = (func_80612794(temp_s2) * 270.0f) + current_actor_pointer->x_position; + D_807FBB44->z_position = (func_80612790(temp_s2) * 270.0f) + current_actor_pointer->z_position; + D_807FBB44->y_position = 100.0f; + D_807FBB44->y_rotation = temp_s2; + D_807FBB44->unk146 = 0; + D_807FBB44->control_state = 0; + temp_v0 = D_807FBB44->additional_actor_data; + temp_v0->unk0 = 0; + temp_v0->unk2 = keyIndex; + temp_v0->unk4 = current_actor_pointer; + // Key Collected Flag + if (isFlagSet(D_80744710[keyIndex], FLAG_TYPE_PERMANENT)) { + sp50 = keyIndex; + D_807FBB44->control_state = 5; + } + } + } + D_807506A4 = 0; + // Isles: Japes Boulder Smashed + if (!isFlagSet(0x1BB, FLAG_TYPE_PERMANENT)) { + sp50 = -1; + } + if ((D_80750660 == 0) && (sp50 != -1)) { + D_807FBB44->unk146 = 1; + D_807FBB44->control_state = 1; + D_80750660 = 1; + D_807FC8D0 = sp50; + } +} +*/ + +// Doable, big, interesting +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C1E70/func_806BD3E4.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C1E70/func_806BD7B0.s") + +s32 areAllKeysTurnedIn() { + s32 key; + for (key = 0; key < 8; key++) { + if (!isFlagSet(key + 0x1BC, FLAG_TYPE_PERMANENT)) { + return FALSE; + } + } + return TRUE; +} \ No newline at end of file diff --git a/src/global_asm/code_C2A90.c b/src/global_asm/code_C2A90.c new file mode 100644 index 00000000..fc8d2232 --- /dev/null +++ b/src/global_asm/code_C2A90.c @@ -0,0 +1,489 @@ +#include +#include "functions.h" +#include "variables.h" + + +extern s32 D_807F5D10; +extern f32 D_8075BEA8; +extern f64 D_8075BEB0; +extern u8 D_807506C0[]; +extern s32 D_8071FBA0; + +void func_8072B324(Actor*, s32); +void func_80729B00(void); +void func_806319C4(Actor*, s32); + +void func_80714C08(s32*, f32, Actor*, s32, s32); +void func_80724E48(u8); +void func_806F09F0(Actor*, u16); + +// TODO: Needs D_807FBB70[i].unk278->unk3, looks like a fairly easy match after that +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BDD90.s") + +extern f32 D_8075BBE4; +void func_8061C600(Actor*, Actor*, s32, s32, s32, s32, s32, s32, s32, s32, f32); + +void func_806BDEC8(void) { + PlayerAdditionalActorData *PaaD = player_pointer->PaaD; + + if (func_806BDD90() == 1) { + current_actor_pointer->control_state = 0x12; + current_actor_pointer->control_state_progress = 0; + } + if (current_actor_pointer->control_state == 0x12) { + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->y_velocity = 150.0f; + func_80614EBC(current_actor_pointer, 0x28E); + func_8061C600(PaaD->unk104, current_actor_pointer, 4, 0xE77, 0xFA, 2, 0x32, 0x20, 0x3F, 0x4A, D_8075BBE4); + D_807FDC90->unk2C = 0x32; + current_actor_pointer->control_state_progress += 1; + break; + case 2: + if (D_807FDC90->unk2C != 0) { + D_807FDC90->unk2C--; + } else { + func_80614EBC(current_actor_pointer, 0x28F); + current_actor_pointer->control_state_progress++; + D_807FDC90->unk2C = 0x78; + } + break; + case 3: + if (D_807FDC90->unk2C != 0) { + D_807FDC90->unk2C--; + } else if (!func_805FF0C8()) { + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + } + break; + } + } + func_8072881C(0, &D_807FDC90->unk28); + func_806319C4(current_actor_pointer, 0); +} + +// Doable lookin +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BE09C.s") + +void func_806BE674(u8 arg0) { + s16 i; + for (i = 0; i < 0x10U; i++) { + if (arg0) { + func_8068A1CC(D_807506C0[i]); + } else { + func_8068A20C(D_807506C0[i]); + } + } +} + +// Displaylist stuff, dl arg0, actor arg1? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BE6F0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BE8BC.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BF218.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BF920.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BFA8C.s") + +void func_806BFBB4() { + func_8061421C(current_actor_pointer); + func_806319C4(current_actor_pointer, 0); + func_80614A64(current_actor_pointer); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806BFBF4.s") + +void func_8072AB74(s32, f32, f32, s32, f32); +void func_80613C48(Actor*, s32, f32, f32); +void func_806F0C18(Actor*); + +void func_806C10A0(u8 arg0, u16 arg1, s16 arg2) { + f32 sp34; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_806F0C18(current_actor_pointer); + D_807FDC98->unk46 |= 0x200; + func_8072B324(current_actor_pointer, 0); + } + func_80724A20(); + switch (current_actor_pointer->control_state) { + case 5: + func_8072AB74(0, 0.0f, 0.0f, 2, 0.0f); + /* fallthrough */ + case 0: + if (func_80629148()) { + current_actor_pointer->control_state = 0x12; + current_actor_pointer->control_state_progress = 0; + return; + } + return; + case 2: + func_8072AB74(2, D_807FDC90->unkA, D_807FDC90->unkE, 0, 0.0f); + func_8072D13C(2, 0); + return; + case 18: + switch (current_actor_pointer->control_state_progress) { + case 0: + func_8070D8C0(current_actor_pointer, arg1, arg0); + func_80614EBC(current_actor_pointer, arg2); + current_actor_pointer->control_state_progress++; + return; + case 2: + // TODO: Proper bitfield syntax + if (((s32)(current_actor_pointer->object_properties_bitfield << 6) >= 0)) { + func_80613C48(current_actor_pointer, 0xE4, 0.0f, 2.0f); + func_80677FA8(0xE1, 0x98); + func_8067B238(D_807FBB44, current_actor_pointer, 0.21f); + func_80671C0C(current_actor_pointer, 1, &D_807FBB44->x_position, &sp34, &D_807FBB44->z_position); + func_80614EBC(D_807FBB44, 0x298); + D_807FBB44->unk11C = current_actor_pointer; + current_actor_pointer->control_state_progress++; + return; + } + break; + case 3: + current_actor_pointer->y_position += 0.5; + break; + } + break; + } +} + +void func_806C1300(void) { + switch (current_actor_pointer->control_state_progress) { + case 1: + current_actor_pointer->unk11C->object_properties_bitfield &= -5; + current_actor_pointer->control_state_progress++; + break; + case 3: + func_8061D4E4(D_807F5D10); + current_actor_pointer->unk11C->control_state = 0x40; + func_806782C0(current_actor_pointer); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C13AC.s") + +void func_806C151C(u16 arg0, u8 arg1, s16 tempFlagIndex) { + f32 dx, dy, dz; + s32 phi_a3; + + dx = player_pointer->x_position - current_actor_pointer->x_position; + dy = player_pointer->y_position - current_actor_pointer->y_position; + dz = player_pointer->z_position - current_actor_pointer->z_position; + phi_a3 = FALSE; + if (((dx * dx) + (dy * dy) + (dz * dz)) < D_8075BEA8) { + phi_a3 = TRUE; + } + if ((phi_a3 & 0xFF) && !isFlagSet(tempFlagIndex, FLAG_TYPE_TEMPORARY)) { + func_8070D8C0(current_actor_pointer, arg0, arg1); + setFlag(tempFlagIndex, TRUE, FLAG_TYPE_TEMPORARY); + } +} + +void func_806C15E8() { + D_807FDC98->unk46 |= 0x1000; + current_actor_pointer->unk146 = 0; + func_8072B324(current_actor_pointer, 0); + current_actor_pointer->unkCC = 1; +} + +void func_806C1640(void) { + f64 temp_f0; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_806C15E8(); + if (current_map == MAP_DK_RAP) { + temp_f0 = D_8075BEB0; + current_actor_pointer->animation_state->scale_x *= temp_f0; + current_actor_pointer->animation_state->scale_y *= temp_f0; + current_actor_pointer->animation_state->scale_z *= temp_f0; + } + } + func_806BF920(); + // TODO: Bitfield syntax + if (!(((s32)current_actor_pointer->object_properties_bitfield << 3) >= 0)) { + func_806BFBF4(current_actor_pointer); + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C1734.s") + +void func_806C19F4(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_806C15E8(); + current_actor_pointer->ledge_info_pointer->unk14 = 180.0f; + func_80724CA4(2, 1); + // Note: This is read as u16 at 0x5A instead of u32 at 0x58 + func_806F09F0(current_actor_pointer, current_actor_pointer->unk58); + } + + // TODO: Bitfield syntax + if (((s32)current_actor_pointer->object_properties_bitfield * 8) < 0) { + func_806BFBF4(); + if (current_actor_pointer->animation_state->unk0->unk10 == 0x1A4) { + func_807149B8(1); + func_807149C8(0x96, 0xFF, 0xFF, 0xFF); + func_80714C08(&D_8071FBA0, 0.7f, current_actor_pointer, 5, 0); + } + func_80724E48(D_807FDC94 == player_pointer ? 5 : 7); + } else { + func_806C10A0(2, 6, 0x3D9); + func_80724E48(0); + func_806C151C(6, 1, 6); // Aztec: Caged Lanky Text Cleared + } + func_806319C4(current_actor_pointer, 0); +} + +// Doable, need to untangle some switch cases/labels probably +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C1B50.s") + +extern s32 D_807035C4; // TODO: Datatype + +void func_806C1CCC(void) { + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->terminal_velocity = -2000.0f; + current_actor_pointer->y_acceleration = -200.0f; + func_806C15E8(); + func_80724CA4(2, 1); + if (current_map == MAP_DK_RAP) { + func_80613194(current_actor_pointer, 0xE); + } + func_806F09F0(current_actor_pointer, current_actor_pointer->unk58); + } + // TODO: Better way to do this + if (((s32) current_actor_pointer->object_properties_bitfield * 8) < 0) { + func_806BFBF4(); + if (current_actor_pointer->object_properties_bitfield & 4) { + if ((current_actor_pointer->animation_state->unk0->unk10 == 0x2C4) && (current_actor_pointer->animation_state->unk0->unk4 > 25.0f)) { + func_8068C350(&D_807035C4, 0, 3); + } + } + func_80724E48(D_807FDC94 == player_pointer ? 5 : 7); + } else { + func_806C10A0(2, 5, 0x3DA); + func_80724E48(0); + func_806C151C(5, 1, 0xF); // Factory: Caged Chunky Text Cleared + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C1E44.s") + +extern s32 D_80720B58; // TODO: Datatype +extern s32 D_8076A064; // TODO: Datatype (bitfield?) + +extern s32 D_807197B4; // TODO: Datatype +extern s32 D_8071FF58; // TODO: Datatype +extern s32 D_8071F078; // TODO: Datatype + +void func_806883F4(Actor*, s32, s32, f32); + +/* +// TODO: Not sure what's going on here +// It keeps messing a0 and s0 up around the function calls +// Also, our stack is 0x10 too small +void func_806C1E44(void) { + s32 phi_s0; + + func_80729B00(); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + func_8068842C(current_actor_pointer, 0, 1); + func_80688460(current_actor_pointer, 0, 1); + switch (current_map) { + case MAP_AZTEC_LLAMA_TEMPLE: + current_actor_pointer->unk130 = 0xFF; + current_actor_pointer->unk131 = 0xFF; + // Aztec: Water Cooled Down + if (!isFlagSet(0x4C, FLAG_TYPE_PERMANENT)) { + func_806883F4(current_actor_pointer, 0, 1, 0); + func_80614EBC(current_actor_pointer, 0x2BD); + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + } else { + current_actor_pointer->control_state = 0x27; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->control_state_progress = 4; + } + break; + case MAP_AZTEC: + func_806883F4(current_actor_pointer, 0, 0, 0); + current_actor_pointer->control_state = 5; + current_actor_pointer->control_state_progress = 0; + break; + } + } + switch (current_actor_pointer->control_state) { + case 0: + func_80724A20(); + switch (current_actor_pointer->control_state_progress) { + case 1: + D_807FDC90->unk2C = 3; + current_actor_pointer->control_state_progress = 2; + // Fallthrough + case 2: + if (!(D_8076A064 & 7)) { + if (D_807FDC90->unk2C != 0) { + D_807FDC90->unk2C--; + if (D_807FDC90->unk2C == 0) { + current_actor_pointer->control_state_progress = 0; + } + func_80714998(2); + func_807149B8(1); + func_807149FC(0x28); + func_8071498C(&D_807197B4); + func_80714C08(&D_8071FF58, 0.05f, current_actor_pointer, 1, 0); + } + } + break; + } + break; + case 39: + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806883F4(current_actor_pointer, 0, 0, 0); + func_80614EBC(current_actor_pointer, 0x2BE); + current_actor_pointer->control_state_progress = 1; + break; + case 3: + for (phi_s0 = 0; phi_s0 < 0xA; phi_s0++) { + func_807149B8(1); + func_807149FC(0x28); + func_8071498C(&D_8071F078); + func_80714950(current_actor_pointer->y_rotation); + func_80714C08(&D_80720B58, 0.7f, current_actor_pointer, 1, 0); + } + current_actor_pointer->control_state_progress++; + } + break; + case 5: + func_80724A20(); + func_806C151C(0xA, 1, 7); + func_806C13AC(4, 0x4F1, 0x4F7, 0x4F7, 0x4F7); + if (func_80629148()) { + current_actor_pointer->control_state = 0x12; + current_actor_pointer->control_state_progress = 0; + } + break; + case 18: + switch (current_actor_pointer->control_state_progress) { + case 0: + func_80614EBC(current_actor_pointer, 0x2BF); + func_806883F4(current_actor_pointer, 0, 2, 0); + func_8072B324(current_actor_pointer, D_807FDC9C[0].unkC); + current_actor_pointer->control_state_progress = 1; + break; + case 2: + func_8072AB74(2, D_807FDC90->unkA, D_807FDC90->unkE, 0, 0.0f); + func_8072D13C(2, 0); + break; + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Doable and quite interesting, but it's a big project and may require some struct definitions +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C226C.s") + +extern f64 D_8075BEB8; + +void func_80684550(Actor*, s32, f32); +void func_80604CBC(Actor*, s32, s32, s32, s32, s32, f32, s32); // TODO: Are the datatypes correct? + +void func_806C27DC(void) { + f32 temp_f20; + + temp_f20 = current_actor_pointer->animation_state->scale_y / D_8075BEB8; + func_80604CBC(current_actor_pointer, 0x114, 0x50, 0, 0, 0xFF, 0.5f, 0); + if (object_timer & 1) { + func_80684550(current_actor_pointer, 1, temp_f20); + func_80684550(current_actor_pointer, 3, temp_f20); + } else { + func_80684550(current_actor_pointer, 2, temp_f20); + func_80684550(current_actor_pointer, 4, temp_f20); + } +} + +// Doable, floaty loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C28B8.s") + +extern f64 D_8075BEC0; +extern f64 D_8075BEC8; +extern f64 D_8075BED0; + +void func_806852C4(f32, f32, f32, s32); + +/* +// TODO: Float and stack nonsense +void func_806C28B8(void) { + f64 temp_f20; + f32 sp78; + f64 temp_f22; + f32 sp74; + s32 sp70; + f32 phi_f2; + s16 phi_s0; + f64 phi_f0; + + phi_f2 = current_actor_pointer->animation_state->unk0->unk4; + if (phi_f2 > 83.0f) { + func_806C27DC(); + phi_f2 = current_actor_pointer->animation_state->unk0->unk4; + } + if ((phi_f2 > 2.0f) && (phi_f2 < 90.0f)) { + if ((object_timer % 6U) == 0) { + temp_f20 = MIN(1, phi_f2 / D_8075BEC0) * D_8075BEC8; + temp_f22 = D_8075BED0; + for (phi_s0 = 1; phi_s0 < 5; phi_s0++) { + func_80671C0C(current_actor_pointer, phi_s0, &sp78, &sp74, &sp70); + phi_f0 = MAX(temp_f22, temp_f20); + func_806852C4(phi_f0, sp78, sp74 + 3.0f, sp70); + } + } + } +} +*/ + +extern s32 D_80717D84; +extern f64 D_8075BED8; + +void func_806C2A64(u8 arg0, u8 arg1, u8 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6, f32 arg7) { + func_807149A8(1000); + func_80714998(0xFF); + func_80714944(((rand() >> 0xF) % 32767) % 11); + func_807149C8(arg0, arg1, arg2, 0xFF); + func_8071498C(&D_80717D84); + func_80714950(2); + func_80714CC0(arg6, arg7 * D_8075BED8, arg3, arg4, arg5); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C2B2C.s") + +extern s32 D_8071FFA0; +void func_806C2D7C() { + func_806C2B2C(1, 0xB, 6, &D_8071FFA0); + func_806C2B2C(0x20, 0x30, 6, &D_8071FFA0); + func_806C2B2C(0xC, 0x16, 2, &D_8071FFA0); + func_806C2B2C(0x17, 0x1F, 2, &D_8071FFA0); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C2DF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C2A90/func_806C3A8C.s") diff --git a/src/global_asm/code_C8C10.c b/src/global_asm/code_C8C10.c new file mode 100644 index 00000000..31524f61 --- /dev/null +++ b/src/global_asm/code_C8C10.c @@ -0,0 +1,154 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C3F10.s") + +void func_806C43A8() { + s32 song = 0; + switch(current_map) { + case MAP_JAPES_MINECART: + song = 3; + break; + case MAP_CASTLE_MINECART: + song = 0x6A; + break; + case MAP_FUNGI_MINECART: + song = 0x4A; + } + if (song != 0) { + playSong(song, 1.0f); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C4414.s") + +void func_806C4904() { + func_806C4414(0, 1, 2, 0xF, 0x10, 0x32, 0x18); +} + +void func_806C4948() { + func_806C4414(6, 7, 8, 0x10, 0xE, 0x32, 0xD7); +} + +void func_806C498C() { + func_806C4414(1, 2, 3, 4, 5, 0x19, 0x13E); +} + +void func_806C49D0() { + func_80729B00(); + switch(current_map) { + case MAP_AZTEC: + func_806C3F10(2, 6, 0); + break; + case MAP_JAPES_MINECART: + func_806C4904(); + break; + case MAP_FUNGI_MINECART: + func_806C4948(); + break; + case MAP_CASTLE_MINECART: + func_806C498C(); + break; + case MAP_FUNGI: + if (D_807FDC9C[0].unk13 == 6) { + func_806C3F10(2, 7, 0x1A); + } else { + func_806C3F10(2, 3, 0); + } + break; + } + func_806319C4(current_actor_pointer, 0); +} + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C4AC4.s") + +void func_806C4E8C(void) { + func_806FB370(5, 0, 0); +} + +void func_806C4EB4() { + func_8063DA40(0x2C, 0xB); + func_806C4E8C(); +} + +void func_806C4EE0(u8 arg0, u8 arg1) { + D_807FDC90[0].unk2E = 0; + func_8070E8DC(1); + func_8070D8C0(current_actor_pointer, 0xF, arg0); + current_actor_pointer->control_state = 0x29; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->unk168 = arg1; + current_actor_pointer->unkF0 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C4F5C.s") + +void func_806C55D8(void) { + +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C55E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C5C20.s") + +// Doable, nice size too +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C5FEC.s") + +// ? func_80602B60(?, ?); /* extern */ +// ? func_8061CB08(Actor *); /* extern */ +// ? func_806319C4(Actor *, ?); /* extern */ +void func_80659670(f32, f32, void *, s32 *, s32, s16); /* extern */ +// ? func_8070D8C0(Actor *, ?, ?); /* extern */ + +/* +// TODO: Very close! +void func_806C5FEC(void) { + PlayerAdditionalActorData *temp_a0; + YetAnotherAdditionalActorData5 *temp_v1; + + temp_v1 = current_actor_pointer->additional_actor_data; + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + temp_v1->unk1C = 0; + current_actor_pointer->object_properties_bitfield |= 0x400; + } + temp_v1->unk1C++; + switch (temp_v1->unk1E) { + case 1: + if (player_pointer->control_state_progress == 3) { + func_8070D8C0(current_actor_pointer, 0x1E, 3); + temp_v1->unk1E = 2; + } else if (temp_v1->unk10->control_state != 0x83) { + temp_v1->unk1E = 3; + } + break; + case 2: + if (!(current_actor_pointer->object_properties_bitfield & 0x02000000)) { + temp_v1->unk1E = 3; + func_8061CB08(current_actor_pointer); + } + break; + default: + if (temp_v1->unk10->control_state != 0x83) { + temp_a0 = temp_v1->unk10->PaaD; + temp_a0->unk1F4 &= ~0x10; + temp_v1->unk10->object_properties_bitfield &= 0xBFFFFFFF; + temp_v1->unk10->object_properties_bitfield |= 1; + temp_v1->unk10->z_rotation = temp_v1->unk16; + temp_v1->unk10->x_rotation = temp_v1->unk14; + global_properties_bitfield |= 0x10030; + func_80659670(temp_v1->unk0, temp_v1->unk4, temp_a0, &global_properties_bitfield, temp_v1->unk8, temp_v1->unk1A); + func_80602B60(0x3B, 0); + func_806782C0(temp_v1->unkC); + func_806782C0(current_actor_pointer); + return; + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C61C8.s") diff --git a/src/global_asm/code_CB230.c b/src/global_asm/code_CB230.c new file mode 100644 index 00000000..c817eef6 --- /dev/null +++ b/src/global_asm/code_CB230.c @@ -0,0 +1,68 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CB230/func_806C6530.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CB230/func_806C6884.s") + +extern f32 D_8075C398; +extern f32 D_8075C39C; + +void func_80604CBC(Actor*, s32, s32, s32, s32, s32, f32, s32); +void func_8072A920(s32, s16, f32, f32, f32, s32, f32, f32, u16); + +f32 func_80612794(s16); +void func_8072B324(Actor*, s32); + +/* +// TODO: Probably needs .data/.rodata defined +void func_806C6884(s16 arg0, s16 arg1, u16 arg2) { + u16 phi_t0; + f32 dx; + f32 dz; + + func_80729B00(); + dx = current_actor_pointer->x_position - D_807FDC94->x_position; + dz = current_actor_pointer->z_position - D_807FDC94->z_position; + phi_t0 = sqrtf((dx * dx) + (dz * dz)); + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + current_actor_pointer->unk64 |= 4; + current_actor_pointer->object_properties_bitfield |= 0x800000; + current_actor_pointer->unk16A = 0xFF; + current_actor_pointer->unk16B = 0xFF; + current_actor_pointer->unk16C = 0xFF; + // TODO: Might need to store actor178 in a temporary variable + // TODO: Putting u8s at actor 178 causes Boss overlay to not match + current_actor_pointer->unk178->unk2 = 0; + current_actor_pointer->unk178->unk0 = 0xFF; + D_807FDC98->unk3C = 1.0f; + if (current_actor_pointer->unk58 == 0xF0) { + func_80604CBC(current_actor_pointer, 0x132, 0, 0, 0, 0xA0, 1.0f, 0); + } + } + phi_t0 = phi_t0 - arg1; + if (phi_t0 < 0) { + phi_t0 = 0; + } + func_8072B324(current_actor_pointer, (2.0 * phi_t0)); + func_8072A920(0x23, arg0, D_807FDC94->x_position, (D_807FDC94->y_position + (arg0 * 3.0)), D_807FDC94->z_position, 0x1E, D_8075C398, 100.0f, arg2 | 0x2000); + current_actor_pointer->y_position += func_80612794(object_timer * 0x28) * 0.5; + func_806C6530(current_actor_pointer); + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806C6B50(void) { + current_actor_pointer->unkAC = D_8075C39C; + func_806C6884(0, 0xA, 0x44); + func_8072881C(0, &D_807FDC90[0].unk28); +} + +void func_806C6BA0(void) { + func_806C6884(0xA, 0x14, 0x240); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CB230/func_806C6BC8.s") diff --git a/src/global_asm/code_CBEA0.c b/src/global_asm/code_CBEA0.c new file mode 100644 index 00000000..7652a89e --- /dev/null +++ b/src/global_asm/code_CBEA0.c @@ -0,0 +1,113 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806C71A0(void) { + +} + +void func_806C71A8(void) { + +} + +void func_806C71B0(void) { + +} + +void func_806C71B8(void) { + +} + +void func_806C71C0(void) { + +} + +void func_806C71C8(void) { + +} + +void func_806C71D0(void) { + +} + +void func_806C71D8(void) { + +} + +void func_806C71E0(void) { + +} + +void func_806C71E8(void) { + +} + +void func_806C71F0(void) { + +} + +void func_806C71F8(void) { + +} + +void func_806C7200(void) { + +} + +void func_806C7208(void) { + +} + +void func_806C7210(void) { + +} + +void func_806C7218(void) { + +} + +void func_806C7220(void) { + +} + +void func_806C7228(void) { + +} + +void func_806C7230(void) { + +} + +void func_806C7238(void) { + +} + +void func_806C7240(void) { + +} + +void func_806C7248(void) { + +} + +void func_806C7250(void) { + +} + +void func_806C7258(void) { + +} + +void func_806C7260(void) { + +} + +void func_806C7268(void) { + +} + +// Doable, just some structs and arrays to define +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CBEA0/func_806C7270.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CBEA0/func_806C75A4.s") diff --git a/src/global_asm/code_CC800.c b/src/global_asm/code_CC800.c new file mode 100644 index 00000000..883af421 --- /dev/null +++ b/src/global_asm/code_CC800.c @@ -0,0 +1,522 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_80750AB4; +extern u8 D_80750AB8; +extern u8 D_80750AC0; + +f32 func_80612794(s16); +void func_80689114(s16, f32, f32, f32, s32, f32, Actor *); +void func_806C9C80(s32, s32, s32); +void func_80614D00(Actor*, f32, f32); +s32 func_8066B06C(s32, s32); +void func_806C9658(s32); + +extern f32 D_8075C788; +extern f64 D_8075C790; +extern f64 D_8075C798; +extern u8 D_80770DC9; +extern u8 number_of_exits; + +extern ExitData *exit_array; +extern ExitData D_807FC908; +extern ExitData D_807FD574; +extern ExitData D_807FC918; + +extern s16 D_8076AEE2; +extern f32 D_8076AEE4; // x +extern f32 D_8076AEE8; // y +extern f32 D_8076AEEC; // z +extern f64 D_8075C7A8; // angle? +extern s16 D_8076AEF0; +extern f64 D_8075C7A0; + +extern u16 D_807FD570; // Tranferred actor behaviour index (through loading zone) + +extern s16 D_807FC930[]; + +void func_806C7B00(void) { + s16 i; + for (i = 0; i < 0xE; i++) { + D_807FC930[i] = 0; + } +} + +s32 func_806C7B34(void) { + return D_8075C410[current_character_index[0]].unk0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C7B50.s") + +/* +// TODO: Add this to the aaD union +typedef struct { + s32 unk0; + s32 unk4; + s8 unk8; +} AppleAAD; + +// TODO: Stack nonsense, bleh +void func_806C7B50(u8 arg1, Actor *arg2) { + AppleAAD *temp_v0; + + func_80677FA8(0x82); // Spawn actor: Apple (Fungi) + func_8067B238(D_807FBB44, arg2, 0.15f); + temp_v0 = D_807FBB44->PaaD; + temp_v0->unk4 = arg2; + temp_v0->unk8 = arg1; +} +*/ + +void func_806C7BAC(s32 arg0, s32 arg1) { + // TODO: Is this aaD type actually correct? The args line up but that's all I know right now + // Maybe run it through a debugger or something + OtherAdditionalActorData *temp_v0; + + func_80677FA8(ACTOR_ROCKETBARREL_ON_KONG, 0x8C); + func_8067B238(D_807FBB44, D_807FBB48, 0.15f); + temp_v0 = D_807FBB44->additional_actor_data; + temp_v0->unk0 = arg0; + temp_v0->unk4 = arg1; +} + +void func_806C7C10(void) { + cc_number_of_players = D_80750AC0; + character_change_array = NULL; + if (cc_number_of_players >= 2) { + switch (D_80750AB8) { + case 0: + D_80750AB4 = cc_number_of_players; + return; + case 1: + D_80750AB4 = 1; + return; + } + } else { + D_80750AB4 = 1; + D_80750AB8 = 0; + } +} + +// Little loop, probably doable, some struct stuff? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C7C94.s") + +// Delay slot problem with mips_to_c +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C7D40.s") + +void func_806C80E4(void) { + PlayerAdditionalActorData *PaaD; + f32 sp30; + f32 pad; + f32 phi_f2; + + if (D_807FD570 == ACTOR_STEEL_KEG) { + phi_f2 = 20.0f; + } else { + phi_f2 = 0.0f; + } + sp30 = func_80612794(player_pointer->y_rotation) * phi_f2; + pad = func_80612790(player_pointer->y_rotation) * phi_f2; + func_80689114(D_807FD570, player_pointer->x_position + sp30, player_pointer->y_position + 7.0, player_pointer->z_position + pad, 0, 1.0f, player_pointer); + PaaD = player_pointer->PaaD; + PaaD->unk1F0 |= 0x1000000; +} + +void func_806C81DC(s16 arg0, s16 arg1) { + CharacterChange *cc = character_change_array; + cc->unk27A = arg1 - arg0; + cc->unk272 = arg0; + cc->unk276 = arg1; + // TODO: What do these typecasts do and can we get rid of them? + cc->unk280 = (f32)cc->unk278 / (f32)cc->unk27A; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C8220.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C850C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C8984.s") + +void func_806C8D20(Actor *arg0) { + arg0->noclip_byte = 0x3C; // Normal collision +} + +u8 func_806C8D2C(s16 arg0) { + s32 i; + for (i = 0; i < 10; i++) { + if (arg0 == D_8075C410[i].unk0) { + return D_8075C410[i].unk7; + } + } + return 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C8DE0.s") + +// u8 func_806C8D2C(s16, s32); + +/* +// TODO: Missing something +s32 func_806C8DE0(s32 playerIndex) { + s32 phi_v1; + + phi_v1 = current_character_index[playerIndex]; + switch (phi_v1) { + case 6: + case 7: + phi_v1 = func_806C8D2C(character_change_array[playerIndex].player_pointer->PaaD->unk1EE); + } + return phi_v1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C8E58.s") + +void func_806C8EE8(void) { + current_character_index[cc_player_index]++; + current_character_index[cc_player_index] %= 8; + extra_player_info_pointer->unk8C = 0; + func_806C8F8C(&D_8075C410[current_character_index[cc_player_index]]); + func_8060098C(&func_806C9C80, 0x14, cc_player_index, 0, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C8F8C.s") + +/* +extern s16 D_807FD584; + +// TODO: Which struct is arg0? +// TODO: Needs some animation_state structs defined +void func_806C8F8C(void *arg0) { + D_807FBB48->unk58 = arg0->unk0; + D_807FD584 = arg0->unk4; + func_806136B4(D_807FBB48, arg0); + func_8066E21C(D_807FBB48->ledge_info_pointer); + func_806134B4(D_807FBB48, arg0->unkA); + D_807FBB48->ledge_info_pointer = func_80665F24(D_807FBB48); + D_807FBB48->object_properties_bitfield &= -0x1001; + D_807FBB48->object_properties_bitfield |= arg0->unkC; + D_807FBB48->animation_state->unk1C = malloc(0x100); + D_807FBB48->animation_state->unk1C->unk0 = 0; + D_807FBB48->animation_state->unk20 = malloc(0x100); + D_807FBB48->animation_state->unk20->unk0 = 0xFF; + D_807FBB48->animation_state->unk24 = malloc(0x100); + D_807FBB48->animation_state->unk24->unk0 = 0xFF; + func_806C8220(1, D_807FBB48->unk178, D_807FBB48->unk58); + func_806F833C(0); +} +*/ + +void func_806C90C4(s32 exitIndex) { + PlayerAdditionalActorData *PaaD; + ExitData *exit; + + PaaD = D_807FBB48->PaaD; + exit = getExitData(exitIndex); + D_8076AEE2 = 0; + global_properties_bitfield &= -0x401; + switch (exit->has_autowalk) { + case 2: + D_807FBB48->control_state = 0x4F; + D_807FBB48->control_state_progress = 3; + func_80614D00(D_807FBB48, 0.5f, 0); + PaaD->unk50 = 1; + D_807FBB48->unk6A |= 4; + func_8067ACB4(D_807FBB48); + func_80614E78(D_807FBB48, 0x34); + // Fallthrough + case 0: + D_807FBB48->unkAC = D_8075C788; + D_807FBB48->x_position = exit->x_pos; + D_807FBB48->y_position = D_807FBB48->unkA0 = exit->y_pos; + D_807FBB48->z_position = exit->z_pos; + D_807FBB48->y_rotation = (exit->angle / D_8075C790) * D_8075C798; + D_807FBB48->unkEE = D_807FBB48->y_rotation; + break; + case 1: + func_806F39E8(D_807FBB48, exit, 0x32); + } + D_807FBB48->unk6A &= ~0x200; + PaaD->unk104->unk15F = exit->unk7 <= 0 ? 1 : exit->unk7; + if (exit->size & 1) { + D_80770DC9 = 1; + } +} + +void func_806C9434(s32 arg0); +void func_80709464(u8); +void func_80605314(Actor*, u8); + +void func_806C92C4(s32 arg0) { + func_80672C30(D_807FBB48); + func_806C9434(arg0); + D_807FBB48->unk9C = D_807FBB48->y_position; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C9304.s") + +/* +// TODO: Hmm. Pretty close. Loop is sus +void func_806C9304(Actor *arg0, PlayerAdditionalActorData *arg1) { + f32 var_f18; + s32 var_v0; + + if (character_change_array[arg1->unk1A4].unk2C0 != 1) { + func_806D0468(D_807FBB48, 1, arg0, arg1); + } + if (arg0->animation_state->scale_x != arg1->unk1C0) { + var_v0 = 0; + while (var_v0 < 2) { + var_f18 = arg1[var_v0].unk1C0; + arg1[var_v0].unk1CC = var_f18; + arg0[var_v0].animation_state->scale_x = var_f18; + var_v0++; + } + } +} +*/ + +void func_806C93E4(Actor *arg0, PlayerAdditionalActorData *arg1) { + func_806F12FC(arg0); + arg1->unk1F0 &= ~0x30; + arg0->object_properties_bitfield |= 0x8000; + arg0->shadow_opacity = 0xFF; +} + +void func_806C9434(s32 arg0) { + s32 temp; // PAD + s32 temp3; // PAD + Actor178 *sp34; + s32 temp2; // PAD + PlayerProgress *sp2C; + PlayerAdditionalActorData *temp_s2; + u8 phi_s0; + + temp_s2 = D_807FBB48->additional_actor_data; + sp34 = D_807FBB48->unk178; + func_806C8DE0(temp_s2->unk1A4); + sp2C = &D_807FC950[temp_s2->unk1A4]; + temp_s2->unk250 = 0x78; + for (phi_s0 = 0; phi_s0 < 2; phi_s0++) { + func_80605314(D_807FBB48, phi_s0); + } + func_806C90C4(arg0); + func_806C8220(0, sp34, D_807FBB48->unk58); + func_80709464(temp_s2->unk1A4); + D_807FBB48->unkB8 = 0.0f; + temp_s2->unk1F0 &= 0xF7FFFF5F; + temp_s2->unk200 = 0; + temp_s2->unk4 = 0.0f; + if (cc_number_of_players >= 2) { + func_800268DC(D_807FBB48, temp_s2, sp2C); + } + func_806C9304(D_807FBB48, temp_s2); + if (!func_8061CB50()) { + if (cc_number_of_players >= 2 && D_80750AB8 == 1) { + func_8061EA78(); + } else { + func_8061EB04(D_807FBB48, temp_s2->unk1A4); + } + } + func_806C8D20(D_807FBB48); + func_806CFF9C(D_807FBB48); + D_807FBB48->z_rotation = 0; + D_807FBB48->x_rotation = 0; +} + +void loadExits(s32 map) { + exit_array = getPointerTableFile(0x17, map, 1, 1); + number_of_exits = func_8066B06C(0x17, map) / sizeof(ExitData); + func_806C9658(map); // Check galleon water level + D_807FC908.x_pos = D_807FD574.x_pos; + D_807FC908.y_pos = D_807FD574.y_pos; + D_807FC908.z_pos = D_807FD574.z_pos; + D_807FC908.angle = 0; +} + +void func_806C9658(s32 map) { + if (map == MAP_GALLEON) { + // Galleon: Water Level Raised + if (isFlagSet(0xA0, FLAG_TYPE_PERMANENT)) { + exit_array[18].y_pos = 1629; + exit_array[23].y_pos = 1629; + } else { + exit_array[18].y_pos = 1574; + exit_array[23].y_pos = 1574; + } + } +} + +ExitData *getExitData(s32 exitIndex) { + if (D_8076AEE2 & 1) { + D_807FC918.x_pos = D_8076AEE4; + D_807FC918.y_pos = D_8076AEE8; + D_807FC918.z_pos = D_8076AEEC; + D_807FC918.angle = D_8075C7A8 * (D_8076AEF0 / D_8075C7A0); + return &D_807FC918; + } + if (number_of_exits == 0) { + return &D_807FC908; + } + if (exitIndex >= number_of_exits) { + return &exit_array[0]; + } + return &exit_array[exitIndex]; +} + +void func_800268C0(s8); + +// TODO: Any cleanup possible? Fiddly regalloc +s8 func_806C9830(s8 arg0, Actor *arg1) { + s8 phi_a2 = arg0; + if (cc_number_of_players >= 2) { + PlayerAdditionalActorData *PaaD = arg1->PaaD; + CharacterChange *CC = &character_change_array[PaaD->unk1A4]; + if (CC->unk2A0) { + Actor *actor = CC->unk2A0; + if (actor->interactable & 1) { + phi_a2 = -1; + if (D_807FBB64 & 0x04000000) { + func_800268C0(1); + } + } else if (actor->interactable & 4) { + // 0xAB is Orange from Krusha's gun + if ((actor->unk58 == ACTOR_PROJECTILE_ORANGE) || (actor->unk58 == 0xAB)) { + phi_a2 = -3; + if (D_807FBB64 & 0x04000000) { + func_800268C0(2); + } + } else { + phi_a2 = -2; + if (D_807FBB64 & 0x04000000) { + func_800268C0(1); + } + } + } else if (D_807FBB64 & 0x04000000) { + func_800268C0(1); + } + } + } + return phi_a2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C9974.s") + +void func_80026E20(u8, s8); +void func_8060E7EC(u8, u8, u8); + +extern s32 D_807552EC; + +/* +// TODO: Close, something going on with the stack +s32 func_806C9974(u8 arg0, s8 arg1) { + s32 phi_v0; + + character_change_array[arg0].unk2E2 |= 0x11; + if ((cc_number_of_players >= 2) && (arg1 < 0) && (D_807552EC == 1)) { + func_80026E20(arg0, arg1); // In the multiplayer overlay + } + if (arg1 < 0) { + func_8060E7EC(arg0, 0xFF, 5); + } + if (!(D_807FBB64 & 0x800)) { + D_807FC950[arg0].unk2FD += arg1; + } + phi_v0 = FALSE; + if ((D_807FC950[arg0].unk2FD + D_807FC950[arg0].health) <= 0) { + character_change_array[arg0].unk2E2 |= 0xC0; + phi_v0 = TRUE; + } + return phi_v0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CC800/func_806C9AE0.s") + +extern u8 D_80750AC0; +extern s8 D_80750ACC; +extern s32 D_807FD56C; + +void func_806C7B00(void); + +/* +// TODO: Excruciatingly close +// Something weird going on with a0 and s2 +// Stray branch, also +void func_806C9AE0(void) { + PlayerProgress *PP; + s32 playerIndex; + s32 kongIndex; + + for (playerIndex = 0; playerIndex < 4; playerIndex++) { + PP = &D_807FC950[playerIndex]; + bzero(PP, sizeof(PlayerProgress)); + if (D_80750AC0 >= 2) { + if (D_807552E4.unk0 == 1) { + for (kongIndex = 0; kongIndex < 6; kongIndex++) { + PP->character_progress[kongIndex].weapon = 7; + } + } + for (kongIndex = 0; kongIndex < 6; kongIndex++) { + PP->character_progress[kongIndex].simian_slam = 1; + } + } + PP->melons = 1; + func_80709464(playerIndex); + } + func_806C7B00(); + D_80750ACC = 0; + D_807FD56C = 0; +} +*/ + +extern s32 D_80750B34[]; + +void func_806F91B4(s32, u8, s32); + +void func_806C9C1C(s32 arg0) { + s32 i; + + for (i = 0; i < 5; i++) { + func_806F91B4(D_80750B34[i], arg0, 9999); + } + func_806F833C(0); +} + +void func_806C9C80(s32 playerIndex, s32 arg1, s32 arg2) { + CharacterProgress *characterProgress = &D_807FC950[playerIndex].character_progress[func_806C8DE0(playerIndex)]; + + characterProgress->weapon = 7; + characterProgress->instrument = 0xF; + characterProgress->simian_slam = 3; + characterProgress->moves = 3; + + // Camera/Shockwave + setFlag(0x179, TRUE, FLAG_TYPE_PERMANENT); + func_806C9C1C(playerIndex); +} + +void func_806C9D20(u8 playerIndex) { + CharacterChange *cc = &character_change_array[playerIndex]; + cc->unk21C = cc->look_at_eye_x; + cc->unk220 = cc->look_at_eye_y; + cc->unk224 = cc->look_at_eye_z; + cc->unk234 = cc->look_at_at_x; + cc->unk238 = cc->look_at_at_y; + cc->unk23C = cc->look_at_at_z; +} + +// playerHasGoldenBananaInAtleastOneLevel() +s32 func_806C9D7C(void) { + s32 levelIndex; + s32 found; + CharacterProgress *CP; + + found = FALSE; + CP = &D_807FC950[0].character_progress[current_character_index[0]]; + for (levelIndex = 0; levelIndex < 8 && !found; levelIndex++) { + found = CP->golden_bananas[levelIndex] > 0; + } + return found; +} \ No newline at end of file diff --git a/src/global_asm/code_CEAE0.c b/src/global_asm/code_CEAE0.c new file mode 100644 index 00000000..fba3e57f --- /dev/null +++ b/src/global_asm/code_CEAE0.c @@ -0,0 +1,7159 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_8062217C(Actor*, u8); +s32 func_80629148(void); +void func_806319C4(Actor*, s32); +void func_8065A708(f32, f32, f32, f32, f32, f32, f32, s32, s32, s32, s32); + +void func_806CBE90(void); +s16 func_806CC14C(s16 arg0, s16 arg1); +void func_806CFE7C(void); +void func_806D3FA0(void); +s32 func_806E4580(void); +void func_806E9964(PlayerAdditionalActorData*); +void func_806F0B34(Actor*); +void func_806F91B4(s32, s32, s16); + +void func_806D0408(void); +void func_806D06A0(void); +void func_80714C08(s32*, f32, Actor*, s32, s32); +void func_80714950(s32); + +extern s32 D_806FF358; +extern s32 D_806FF32C; +extern s32 D_806FF75C; +extern s32 D_806FF01C; + +extern s32 D_80716FB4; // TODO: Proper datatype +extern s32 D_80717930; +extern s32 D_8071B2EC; +extern s32 D_8071FB08; // TODO: Proper datatype +extern s32 D_8071FFA0; +extern s32 D_8071FF18; + +extern s8 D_8074E77C[]; + +extern s32 D_80750FDC; +extern u8 D_80750AB8; + +typedef struct { + s16 unk0; // Used + s16 unk2; + s32 unk4; +} GlobalASMStruct63; + +extern GlobalASMStruct63 D_80750B54[]; + +extern f32 D_80750FA8; +extern f32 D_80750FF8; +extern f32 D_80750FFC; +extern f32 D_80751000; + +extern f32 D_8075305C[]; +extern f32 D_80753144[]; +extern f32 D_80753170[]; +extern f32 D_807531E0[]; +extern f32 D_807531FC[]; // Kong Walking Maximum Velocity +extern f32 D_80753218[]; +extern f32 D_80753234[]; +extern f32 D_80753250[]; +extern s16 D_8075326C[]; +extern f32 D_8075327C[]; +extern s16 D_80753298[]; +extern f32 D_807532B8[]; +extern f32 D_807532D4[]; +extern f32 D_807532F0[]; +extern f32 D_8075330C[]; +extern s16 D_80753328[]; +extern f32 D_80753338[]; +extern f32 D_8075339C[]; +extern s32 D_807533B8[]; +extern f32 D_80753380[]; +extern f32 D_80753364[]; +extern f32 D_807533D4[]; +extern s32 D_807533F0[]; +extern f32 D_80753454[]; +extern f32 D_80753470[]; +extern f32 D_8075348C[]; +extern s16 D_807534A8[]; +extern f32 D_807534B8[]; +extern s16 D_807534D4[]; +extern s16 D_80753548[]; +extern f32 D_80753578[]; // yAccelArray in ghidra +extern f32 D_80753594[]; +extern f32 D_807535B0[] = {-17, -17, -17, -17, -10, -10, -17}; // Kong Jumping Y Acceleration +extern f32 D_807535CC[]; +extern f32 D_80753658[]; +extern f32 D_807536E4[]; +extern f32 D_80753700[]; +extern f32 D_80753738[]; +extern f32 D_80753754[]; +extern f32 D_807537E0[]; +extern s16 D_8075380C[]; +extern s16 D_8075381C[]; +extern s16 D_8075382C[]; +extern s16 D_8075385C[]; +extern f32 D_807539C0[]; +extern f32 D_80753A5C[]; +extern f32 D_80753AFC[]; +extern f32 D_80753B18[]; +extern f32 D_80753BA4[]; +extern f32 D_80753BC0[]; +extern f32 D_80753BDC[]; +extern f32 D_80753BF8[]; +extern f32 D_80753CB4[]; +extern f32 D_80753DC8[]; +extern f32 D_80753DE4[]; + +extern f32 D_8075C91C; +extern f32 D_8075C920; +extern f32 D_8075C924; +extern f32 D_8075CC6C; +extern f32 D_8075CCE0; +extern f64 D_8075CD08; +extern f32 D_8075CDA0; +extern f64 D_8075CDE0; +extern f64 D_8075CDE8; +extern f64 D_8075CE68; +extern f32 D_8075CE70; + +extern f32 D_8075D080; +extern f64 D_8075D0B8; +extern f32 D_8075D0D0; +extern f64 D_8075D0C8; +extern f64 D_8075D0C0; +extern f64 D_8075D0F0; +extern f32 D_8075D0F8; +extern f64 D_8075D100; +extern f64 D_8075D108; +extern f32 D_8075D110; +extern f64 D_8075D118; +extern f64 D_8075D120; +extern f64 D_8075D128; +extern f32 D_8075D130; +extern f32 D_8075D21C; +extern f32 D_8075D220; +extern f32 D_8075D224; +extern f32 D_8075D334; +extern f32 D_8075D344; +extern f64 D_8075D348; +extern f64 D_8075D358; +extern f64 D_8075D360; + +extern s32 D_80767CC0; + +extern s32 D_807FBB68; +extern u8 D_807FBB8C; + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; +} GlobalASMStruct0; + +extern GlobalASMStruct0 *D_807FD568; // TODO: Unknown struct + +extern s16 D_807FD584; // index into a ton of arrays +extern u8 D_807FD586; + +typedef struct GlobalASMStruct6 { + u16 unk0; + u8 pad0[0x32]; +} GlobalASMStruct6; +extern GlobalASMStruct6 D_807FD63C[]; + +extern u8 D_807FC8B9; +extern f32 D_807FD888; + +void func_806CC970(void); +void func_806CCB0C(void); +void func_806CC8B8(void); +f32 func_806CD898(f32 currentSpeed, f32 desiredSpeed, f32 boostAmount); // boostSpeed +void func_806CC8B8(void); +void func_806CEE64(f32); +void func_806CEED8(void); +void func_806CFD68(void); +u8 func_806CE928(Actor*, f32, f32, s32); +void func_8067A784(Actor*, Actor*, s16, s32, s32); +void func_8061C464(Actor*, Actor*, s32, s32, s32, s32, s32, s32, s32, s32, f32); +f32 func_806DFFA0(f32, s16, s16); +void func_806EAB44(Actor *arg0, u8 arg1); +void func_806CFF9C(Actor *arg0); + +s32 func_806DF6D4(s32 arg0); + +f32 func_806E0454(f32, f32); +void func_8072FE60(f32); +void func_806E1630(void); + +extern void func_8068E9B0(); // Needed for function pointer + +void func_806CC948(); +void func_806CFD68(); +void func_806CFECC(void); +void func_806D2378(); + +void func_806CC948(); + +void func_806F4D70(u8, s32, s32, s32, f32); + +void func_8068EA38(); // Needed for function pointer + +void func_806FFB2C(void); // Needed for function pointer +void func_80677FA8(s32, s32); // spawnActorWrapper() + +u8 func_806CDD24(Actor *arg0, f32 arg1, f32 arg2, s32 arg3); +u8 func_806CE174(Actor *arg0, f32 arg1, f32 arg2, s32 arg3); + +void func_806D3608(void); + +void func_80685210(f32, s32, s32); + +s16 func_806CE4E4(Actor*, f32, f32, s32); + +void func_806F142C(Actor*); +void func_80608528(Actor*, s32, s32, s32, s32); + +void func_806DF494(s16*, s16, s16); + +u32 func_806119A0(void); +void func_807248B0(Actor*, f32); +void func_80614D00(Actor *arg0, f32 arg1, f32 arg2); +void func_806DF390(Actor*, PlayerAdditionalActorData*, u8); +void func_806DF3D0(Actor*, PlayerAdditionalActorData*, u8); +f32 func_806E03C8(f32, f32); +s32 func_806E9D1C(s16 arg0, u8 arg1, u8 arg2); +void func_80604CBC(Actor *, s32, s32, s32, s32, s32, f32, s32); +void func_806EA568(void); +s16 func_8062773C(s32); +Actor *func_807270C0(s8, s32); // getSpawnerTiedActor() +void func_80605314(Actor*, s32); +s32 func_806FA7A4(s32); // TODO: Might return s16 + +void func_806C9DE0(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 0); +} + +void func_806C9E10(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 2); +} + +void func_806C9E40(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 3); +} + +void func_806C9E70(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 4); +} + +void func_806C9EA0(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 6); +} + +void func_806C9ED0(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 1); +} + +void func_806C9F00(void) { + func_8066E5F8(current_actor_pointer, 3, 8); + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 7); +} + +void func_806C9F44(void) { + func_806CA5F8(0); + func_806F3190(current_actor_pointer, 5); +} + +void func_806C9F74(Actor *arg0) { + if (D_80750B54[arg0->control_state].unk0 & 0x200) { + func_806EAB44(arg0, arg0->control_state != 2); + } else if (D_80750B54[arg0->control_state].unk0 & 0x100) { + func_806E9964(extra_player_info_pointer); + } +} + +Actor *func_806C9FD8(Actor *actor) { + Actor *originalActor = actor; + + if (!actor) { + return actor; + } + + switch (actor->interactable) { + case 4: + actor = actor->unk11C; + break; + case 8: + actor = actor->unk11C; + break; + } + + if (actor) { + if (actor->interactable == 1 || actor->interactable == 2) { + return actor; + } + } + + return originalActor; +} + +void func_806CA048(Actor *actor, PlayerAdditionalActorData *arg1) { + s32 phi_v1 = FALSE; + + if (!actor) { + phi_v1 = TRUE; + } else { + if (actor->interactable & 1) { + PlayerAdditionalActorData *PaaD = actor->PaaD; + arg1->unk248 = PaaD->unk1A4; + arg1->unk249 = 0; + } else if (actor->interactable & 2) { + arg1->unk248 = -1; + arg1->unk249 = func_80727194(); + } else { + phi_v1 = TRUE; + } + } + + if (phi_v1) { + extra_player_info_pointer->unk246 = 0; + extra_player_info_pointer->unk247 = -1; + } + arg1->unk24A = 5; +} + +void func_806CA0E8(Actor *arg0, Actor *arg1, s32 arg2) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + s32 phi_t0 = FALSE; + s32 phi_a3 = FALSE; + + if (!arg1) { + phi_a3 = TRUE; + } else { + if (arg1->interactable == 1) { + PlayerAdditionalActorData *PaaD2 = arg1->PaaD; + PaaD->unk247 = PaaD2->unk1A4; + PaaD->unk246 = 0; + phi_t0 = TRUE; + } else if (arg1->interactable == 2) { + PaaD->unk246 = func_80727194(arg1); + PaaD->unk247 = -1; + phi_t0 = TRUE; + } else { + phi_a3 = TRUE; + } + } + if (phi_a3) { + PaaD->unk246 = 0; + PaaD->unk247 = -1; + } + if (phi_t0) { + PaaD->unk24C = arg1->animation_state->unk0->unk10; + PaaD->unk24E = arg2; + } +} + +s32 func_806CA1B4(s32 arg0) { + Actor *phi_v1; + s32 phi_a2 = 1; + phi_v1 = NULL; + + if (extra_player_info_pointer->unk247 >= 0) { + phi_v1 = character_change_array[extra_player_info_pointer->unk247].player_pointer; + } else if (extra_player_info_pointer->unk246 > 0) { + phi_v1 = func_807270C0(extra_player_info_pointer->unk246, 0); + } + + if (phi_v1) { + if ((extra_player_info_pointer->unk24C == phi_v1->animation_state->unk0->unk10) && (extra_player_info_pointer->unk24E >= arg0)) { + phi_a2 = 0; + } + } + return phi_a2; +} + +void func_806CA26C(void) { + if (func_806CA1B4(-1)) { + extra_player_info_pointer->unk247 = -1; + extra_player_info_pointer->unk246 = 0; + } +} + +void func_806CA2AC(void) { + extra_player_info_pointer->unkC8 = -1; + func_80605314(current_actor_pointer, 1); +} + +void func_806CA2E4(void) { + if ((extra_player_info_pointer->unkC8 != -1) && ((!isFlagSet(0x179, FLAG_TYPE_PERMANENT)) || (current_actor_pointer->unkE0 != 0.0f) || ((D_807FBB64 << 8) < 0) || (func_806F8AD4(5, extra_player_info_pointer->unk1A4) == 0))) { + func_806CA2AC(); + extra_player_info_pointer->unkC8 = -1; + return; + } + if (extra_player_info_pointer->unkC8 != -1) { + if (D_807FD610[cc_player_index].unk2A & B_BUTTON) { + if (extra_player_info_pointer->unkC8 > 0) { + if ((extra_player_info_pointer->unkC8 < 0x1E) && ((object_timer & 3) == 0)) { + func_80684900(0); + } + extra_player_info_pointer->unkC8--; + if (extra_player_info_pointer->unkC8 == 0x1E) { + func_80604CBC(current_actor_pointer, 0x104, 0x3C, 1, 1, 0xFF, 1.0f, 0); + } + } else if ((object_timer & 1) == 0) { + func_80684900(1); + } + } else { + if (extra_player_info_pointer->unkC8 == 0) { + if ((current_actor_pointer->unk6A & 1)) { + current_actor_pointer->control_state = 0x2D; + current_actor_pointer->control_state_progress = 0; + func_806F8BC4(5, 0, 0); + func_806F91B4(5, extra_player_info_pointer->unk1A4, -1 * func_806FA7A4(5)); + func_80614E78(current_actor_pointer, 0x42); + func_80608528(current_actor_pointer, 0xF2, 0xFF, 0x7F, 0); + current_actor_pointer->unkB8 = 0.0f; + } + } + func_806CA2AC(); + } + } +} + +void func_806CA540(void) { + if ((current_actor_pointer->unk6A & 0x221) == 1) { + if (current_actor_pointer->unkE0 != 0.0f) { + if (!(current_actor_pointer->unk6C & 1) + || current_actor_pointer->unkDE < 0x226 + || ((current_actor_pointer->unk78 == 0xC) && (current_actor_pointer->unkB8 > 40.0f))) { + extra_player_info_pointer->unkC2 = 0x32; + } + extra_player_info_pointer->unkC2++; + } else { + extra_player_info_pointer->unkC2 = 0; + } + } +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CA5F8.s") + +void func_806CB53C(void) { + s32 phi_s0; + f32 phi_f0; + + if (((D_807FBB48->unk58 == 8) || (D_807FBB48->unk58 == 9)) && (extra_player_info_pointer->unk1FD != 0)) { + if ((extra_player_info_pointer->unk1F0 & 0x800) && extra_player_info_pointer->unk23E == 0) { + extra_player_info_pointer->unk23E = 0x1E; + func_80687400(); + } + if ((D_807FD610[cc_player_index].unk2C & L_CBUTTONS) && (D_807FD610[cc_player_index].unk2A & Z_TRIG) && extra_player_info_pointer->unk23E == 0) { + extra_player_info_pointer->unk23E = 0x1E; + } + if (extra_player_info_pointer->unk23E != 0) { + func_80714950(((rand() >> 0xF) % 10) + 0x8008); + func_807149FC(2); + func_8071498C(&D_80717930); + func_807149B8(1); + func_80714A28(6); + func_80714C08(&D_8071FFA0, (((rand() >> 0xF) % 50) / 80.0) + 0.5, current_actor_pointer, 2, 0); + extra_player_info_pointer->unk23E--; + } + if (extra_player_info_pointer->unk23E == 1) { + func_806EB0C0(0x3B, NULL, cc_player_index); + extra_player_info_pointer->unk1FD = 0; + } + } else { + extra_player_info_pointer->unk23E = 0; + } + extra_player_info_pointer->unk1F0 &= ~0x800; + if ((character_change_array[cc_player_index].unk2C0 != 1) || (extra_player_info_pointer->unk1F0 & 0x30)) { + if ((extra_player_info_pointer->unk1F0 & 0x80000000) && extra_player_info_pointer->unk23F == 0) { + extra_player_info_pointer->unk23F = 0x1E; + func_80687400(); + } + if (extra_player_info_pointer->unk23F) { + extra_player_info_pointer->unk23F--; + } + if (extra_player_info_pointer->unk23F == 1) { + D_807FD610[cc_player_index].unk2C |= L_CBUTTONS; + D_807FD610[cc_player_index].unk2A |= Z_TRIG; + } + if (!(D_80750B54[current_actor_pointer->control_state].unk0 & 0x300) && !(extra_player_info_pointer->unk1F0 & 0x14000) && !func_8061CB50()) { + if ((extra_player_info_pointer->unk1F4 & 0x10) == 0) { + func_806F91B4(5, extra_player_info_pointer->unk1A4, -1); + } + } + } else { + extra_player_info_pointer->unk23F = 0; + } + extra_player_info_pointer->unk1F0 &= 0x7FFFFFFF; + if (((D_807FD610[cc_player_index].unk2C & 2) && (D_807FD610[cc_player_index].unk2A & 0x2000) && (cc_number_of_players == 1)) || !func_806F8AD4(5, extra_player_info_pointer->unk1A4)) { + if (!(extra_player_info_pointer->unk1F0 & 0x2000) && current_map != MAP_KROOL_FIGHT_CHUNKY_PHASE) { + phi_s0 = FALSE; + if (character_change_array[cc_player_index].unk2C0 != 1) { + func_806D0468(D_807FBB48, 1); + phi_s0 = TRUE; + if (extra_player_info_pointer->unk1AC != 0) { + if (D_807FBB48->unk58 == 6 && D_807FBB48->control_state != 0x4A) { + D_807FBB48->control_state = 0x4A; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0x1CD); + } + } + } + if (extra_player_info_pointer->unk1F0 & 0x10) { + extra_player_info_pointer->unk1F0 &= ~0x10; + D_807FBB48->object_properties_bitfield |= 0x8000; + D_807FBB48->shadow_opacity = 0xFF; + phi_s0 = TRUE; + } + if (extra_player_info_pointer->unk1F0 & 0x20) { + extra_player_info_pointer->unk1F0 &= ~0x20; + func_806D0408(); + phi_s0 = TRUE; + } + if (phi_s0) { + func_806C9F74(current_actor_pointer); + } + } + } + if (extra_player_info_pointer->unk1F0 & 0x10) { + extra_player_info_pointer->unkD4 = 2; + } + if (extra_player_info_pointer->unk1CC != extra_player_info_pointer->unk1C0) { + current_actor_pointer->unk64 |= 0x800; + switch (current_actor_pointer->unk58) { + case 5: + current_actor_pointer->unk120 = D_8075C920; + break; + case 6: + current_actor_pointer->unk120 = D_8075C924; + break; + default: + current_actor_pointer->unk120 = D_8075C91C; + break; + } + func_806D06A0(); + } else { + current_actor_pointer->unk64 &= ~0x800; + } + if (extra_player_info_pointer->unk1F0 & 0x40) { + if (current_actor_pointer->unk58 != 6) { + current_actor_pointer->object_properties_bitfield &= 0xFFFF7FFF; + current_actor_pointer->shadow_opacity -= 4; + if (current_actor_pointer->shadow_opacity < 100) { + current_actor_pointer->shadow_opacity = 100; + } + } + if (extra_player_info_pointer->unk1FE != -1) { + extra_player_info_pointer->unk1FE -= 1; + if (!(extra_player_info_pointer->unk1FE & 7)) { + func_8071498C(&D_80716FB4); + func_807149B8(1); + func_807149FC(3); + func_80714CC0(&D_8071FB08, 1.0f, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position); + } + if (extra_player_info_pointer->unk1FE == 0) { + func_80602B60(0x6C, 0); + current_actor_pointer->object_properties_bitfield |= 0x8000; + func_806F12FC(current_actor_pointer); + } + } + } + if (extra_player_info_pointer->unk200 != 0) { + if ((extra_player_info_pointer->unk1F0 * 0x10) < 0) { + phi_f0 = 1.0f; + if (extra_player_info_pointer->unk200 >= 2) { + phi_f0 = 0.5f; + } + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584] * phi_f0; + extra_player_info_pointer->unk2C = D_80753234[D_807FD584] * phi_f0; + extra_player_info_pointer->unk48 = D_8075326C[D_807FD584] * phi_f0; + } + if ((current_actor_pointer->control_state != 0x7C) || (current_actor_pointer->control_state == 0x7C && extra_player_info_pointer->unk200 == 1)) { + extra_player_info_pointer->unk200--; + } + if (extra_player_info_pointer->unk200 == 0) { + extra_player_info_pointer->unk1F0 &= 0xF7FFFF7F; + if (current_actor_pointer->control_state == 0x7C) { + func_806CFF9C(current_actor_pointer); + } + } + } + if ((extra_player_info_pointer->unk1F0 & 0x20) || (is_autowalking == 3)) { + if (current_map == MAP_FUNGI) { + extra_player_info_pointer->unk38 = 200.0f; + } else { + extra_player_info_pointer->unk38 = D_80753218[D_807FD584]; + } + } +} + +void func_806CBE44(void) { + if ((D_807FBB70[0].unk2 != 0) && (D_807FBB70[0].unk14 == 1)) { + func_806EB0C0(0x20, NULL, cc_player_index); + } +} + +void func_806CBE90(void) { + if ((current_actor_pointer->unk6A & 0x21) == 1) { + if ((current_actor_pointer->unk6A & 0x200) != 0) { + if (current_actor_pointer->unk6E == -1) { + func_80604CBC(current_actor_pointer, 0x10D, 0, 1, 0, 0xFF, 1.0f, 0); + } + current_actor_pointer->control_state = 0xF; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->terminal_velocity = -900.0f; + extra_player_info_pointer->unk48 = D_8075326C[D_807FD584]; + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + extra_player_info_pointer->unk2C = D_80753234[D_807FD584]; + func_80614E78(current_actor_pointer, 0x5E); + current_actor_pointer->unk6A |= 0x20; + func_80614D90(current_actor_pointer); + return; + } + if ((current_actor_pointer->unkE0 != 0.0f) && (extra_player_info_pointer->unkC2 >= 0x15) && (current_actor_pointer->control_state != 0x17)) { + if (func_806CC14C(current_actor_pointer->unkD8, current_actor_pointer->y_rotation) < 0x200) { + if (D_80750B54[D_807FBB48->control_state].unk0 & 0x200) { + func_806EAB44(current_actor_pointer, 0); + } + func_806EB0C0(0x21, NULL, cc_player_index); + return; + } + if ((func_806CC14C(current_actor_pointer->unkD8, current_actor_pointer->unkEE) < 0x400) || (current_actor_pointer->unkB8 < 15.0f)) { + if (D_80750B54[D_807FBB48->control_state].unk0 & 0x200) { + func_806EAB44(current_actor_pointer, 0); + } + func_806EB0C0(0x22, NULL, cc_player_index); + } + } + } +} + +s16 func_806CC10C(s16 arg0, s16 arg1) { + s16 temp_t2 = (arg1 - arg0); + temp_t2 &= 0xFFF; + if (temp_t2 >= 0x801) { + temp_t2 -= 0x1000; + } + return temp_t2; +} + +s16 func_806CC14C(s16 arg0, s16 arg1) { + s16 phi_v1 = (arg1 - arg0); + phi_v1 &= 0xFFF; + if (phi_v1 >= 0x801) { + phi_v1 = 0x1000 - phi_v1; + } + return phi_v1; +} + +// TODO: Clean this up with the ABS macro if possible +s16 func_806CC190(s16 arg0, s16 arg1, f32 arg2) { + s16 temp_v0; + s16 phi_v1; + s16 phi_v0; + + temp_v0 = arg1 - arg0; + if (temp_v0 > 0) { + phi_v1 = temp_v0; + } else { + phi_v1 = -temp_v0; + } + if ((arg2 != 0.0f) && ((temp_v0 & 0xFFF) != 0)) { + phi_v0 = temp_v0 >= 0 ? 1 : -1; + if (phi_v1 >= 0x801) { + phi_v1 = 0x1000 - phi_v1; + phi_v0 = -phi_v0; + } + if (phi_v1 < arg2) { + arg2 = phi_v1; + } + arg0 += (phi_v0 * (s16)(phi_v1 / arg2)); + } + return arg0 & 0xFFF; +} + +// TODO: Clean this up with the ABS macro if possible +s16 func_806CC284(s16 arg0, s16 arg1, f32 arg2) { + s16 phi_v1; + s16 phi_v0; + s16 temp_v0; + + temp_v0 = arg1 - arg0; + if (temp_v0 > 0) { + phi_v1 = temp_v0; + } else { + phi_v1 = -temp_v0; + } + if ((arg2 != 0) && (temp_v0 & 0xFFF) != 0) { + phi_v0 = temp_v0 >= 0 ? 1 : -1; + if (phi_v1 >= 0x801) { + phi_v1 = 0x1000 - phi_v1; + phi_v0 = -phi_v0; + } + arg0 += (phi_v0 * (s16)(phi_v1 * arg2)); + } + return arg0 & 0xFFF; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CC364.s") + +f32 func_80612794(s16); +extern s16 D_80753A3C[]; +extern s16 D_80753A4C[]; + +/* +// TODO: Close, float & stack nonsense +void func_806CC364(u8 arg0) { + f32 temp_f14_2; + f32 phi_f12; + + if (character_change_array[cc_player_index].unk2C0 == 1) { + phi_f12 = D_80753A3C[D_807FD584]; + } else { + phi_f12 = D_80753A4C[D_807FD584]; + } + temp_f14_2 = (ABS(func_80612794(current_actor_pointer->z_rotation) * phi_f12) + 1.5f) + ABS(func_80612790(current_actor_pointer->unkDA) * phi_f12); + if (current_actor_pointer->distance_from_floor < temp_f14_2) { + if (current_actor_pointer->unkDA < 500) { + current_actor_pointer->unkB8 = MAX(current_actor_pointer->unkB8, 50); + } + if (arg0 && current_actor_pointer->y_velocity < 0) { + current_actor_pointer->y_velocity = 0; + } + if (phi_f12 < (current_actor_pointer->unkAC - current_actor_pointer->y_position)) { + current_actor_pointer->y_position = current_actor_pointer->floor + temp_f14_2; + } + } +} +*/ + +void func_806CC5DC(void) { + current_actor_pointer->unkB8 = func_806CD898(current_actor_pointer->unkB8, 0, D_807539C0[D_807FD584]); + func_806CC970(); + func_806CC364(1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CC638.s") + +extern f64 D_8075C928; +extern f32 D_8075C930; +extern s16 D_80753A2C[]; + +void func_80665160(Actor *, s16, s16); +void func_806653C0(Actor *, f32, f32); +void func_80665564(Actor*, f32); +f32 func_80612794(s16); + +/* +// TODO: WIP, might need some more temp variables or split apart float operations into separate lines +void func_806CC638(f32 arg0) { + f32 sp34; + f32 phi_f14; + f32 phi_f2; + f32 phi_f16; + + if (extra_player_info_pointer->unk10 != 0) { + extra_player_info_pointer->unk10--; + phi_f14 = extra_player_info_pointer->unk38 * -func_80612794(extra_player_info_pointer->unk12); + sp34 = extra_player_info_pointer->unk38 * func_80612790(extra_player_info_pointer->unk12); + if (extra_player_info_pointer->unk38 < current_actor_pointer->unkB8) { + phi_f2 = extra_player_info_pointer->unk2C * 8.0f; + } else { + phi_f2 = extra_player_info_pointer->unk2C; + } + } else { + phi_f14 = current_actor_pointer->unkB8 * -func_80612794(current_actor_pointer->z_rotation); + current_actor_pointer->y_velocity = func_806CD898(current_actor_pointer->y_velocity, phi_f14, 2.0f); + sp34 = 0.0f; + phi_f2 = extra_player_info_pointer->unk30; + } + phi_f16 = 0.0f; + if (phi_f14 >= 0.0f) { + if ((current_actor_pointer->unkAC - current_actor_pointer->y_position) < D_80753A2C[D_807FD584]) { + if (D_80753A5C[D_807FD584] > 0.0f) { + phi_f16 = D_80753A5C[D_807FD584]; + } else { + phi_f16 = -D_80753A5C[D_807FD584]; + } + } + } + if ((current_actor_pointer->distance_from_floor == 0.0f) && (current_actor_pointer->y_velocity < D_8075C928)) { + current_actor_pointer->y_velocity = D_8075C930; + } + current_actor_pointer->y_velocity = func_806CD898(current_actor_pointer->y_velocity, phi_f14 + phi_f16, 2.0 * phi_f2); + current_actor_pointer->unkB8 = func_806CD898(current_actor_pointer->unkB8, sp34, phi_f2); + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + func_80665160(current_actor_pointer, current_actor_pointer->unkEE, current_actor_pointer->y_rotation); + func_806653C0(current_actor_pointer, current_actor_pointer->unkB8, current_actor_pointer->y_velocity); + func_80665564(current_actor_pointer, 0); + func_806CC364(0); +} +*/ + +void func_806CC8A8(void) { + D_807FD586 = 1; +} + +void func_806CC8B8(void) { + func_806CCB0C(); + func_806CBE90(); + func_806CCC54(1); + func_806CC970(); +} + +void func_806CC8F0(void) { + func_806CBE90(); + func_806CCC54(1); + func_806CC970(); +} + +void func_806CC920(void) { + func_806CCC54(1); + func_806CC970(); +} + +void func_806CC948(void) { + func_806CCB0C(); + func_806CC970(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CC970.s") + +extern s32 D_80744478; +extern f64 D_8075C938; + +/* +void func_806CC970(void) { + f32 dx; + f32 dz; + s16 phi_a1; + f64 phi_f2; + f64 temp; + + func_806CCC54(0); + if (func_806CC14C(current_actor_pointer->y_rotation, current_actor_pointer->unkEE) < 0x400) { + phi_a1 = current_actor_pointer->y_rotation; + } else { + phi_a1 = (current_actor_pointer->y_rotation + 0x800) & 0xFFF; + } + func_80665160(current_actor_pointer, phi_a1, phi_a1); + func_806651FC(current_actor_pointer); + phi_f2 = MAX(-6, -extra_player_info_pointer->unkD6 * 0.125); + func_80665564(current_actor_pointer, phi_f2); + current_actor_pointer->object_properties_bitfield |= 1; + dx = current_actor_pointer->x_position - current_actor_pointer->unk88; + dz = current_actor_pointer->z_position - current_actor_pointer->unk90; + // TODO: Just gotta figure out this fiddly float stuff, otherwise it matches :) + extra_player_info_pointer->unk20 = ((sqrtf((dx * dx) + (dz * dz)) / D_80744478) * 80.0 * D_8075C938) / current_actor_pointer->animation_state->scale_x; +} +*/ + +void func_806CCB0C(void) { // applyActorYAccel() + if (extra_player_info_pointer->unk50 != 0) { + extra_player_info_pointer->unk50--; + return; + } + current_actor_pointer->y_velocity += current_actor_pointer->y_acceleration; + if (current_actor_pointer->y_velocity < current_actor_pointer->terminal_velocity) { + current_actor_pointer->y_velocity = current_actor_pointer->terminal_velocity; + } + if (-current_actor_pointer->terminal_velocity < current_actor_pointer->y_velocity) { + current_actor_pointer->y_velocity = -current_actor_pointer->terminal_velocity; + } +} + +void func_806CD8EC(void); +void func_806CD424(s16, f32, f32); // TODO: Is this signature correct? + +void func_806CCB94(void) { + f32 temp_f0 = func_806DFFA0(extra_player_info_pointer->unk4, extra_player_info_pointer->unkA, current_actor_pointer->y_rotation); + + if (temp_f0 > 0.0f) { + func_806CD424(current_actor_pointer->y_rotation, temp_f0, extra_player_info_pointer->unk38); + } else { + func_806CD8EC(); + } +} + +// jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CCC10.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CCC54.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CD424.s") + +// boostSpeed() +f32 func_806CD898(f32 currentSpeed, f32 desiredSpeed, f32 boostAmount) { + if (currentSpeed < desiredSpeed) { + currentSpeed += boostAmount; + currentSpeed = MIN(desiredSpeed, currentSpeed); + } else { + currentSpeed -= boostAmount; + currentSpeed = MAX(desiredSpeed, currentSpeed); + } + return currentSpeed; +} + +void func_806CD8EC(void) { + u16 temp_v1; + f32 phi_f0; + + if ((current_actor_pointer->unk6A & 1) && !(current_actor_pointer->unk6A & 0x200)) { + phi_f0 = (extra_player_info_pointer->unk30 * ((extra_player_info_pointer->unk26 * 0xF) + 0x64)) / 1600.0f; + } else { + phi_f0 = extra_player_info_pointer->unk30; + } + current_actor_pointer->unkB8 -= phi_f0; + if (current_actor_pointer->unkB8 < 0.0f) { + current_actor_pointer->unkB8 = 0.0f; + } +} + +s16 func_806CD988(Actor *arg0) { + s16 temp = D_80750B54[arg0->control_state].unk0; + return temp; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CD9A0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CDD24.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CE174.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CE4E4.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CE7A0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CE928.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CEB44.s") + +/* +// TODO: Very close +s32 func_806CEB44(f32 arg0, f32 arg1) { + s32 phi_v1; + + phi_v1 = extra_player_info_pointer->unk4C; + switch (phi_v1) { + case 0: + if (arg1 != 0.0f) { + return 1; + } + break; + case 1: + if (arg1 == 0.0f) { + if (arg0 < D_807532B8[D_807FD584]) { + return 0; + } + } + break; + default: + if (arg0 < D_807532B8[D_807FD584]) { + return 0; + } + return 1; + } + + // return phi_v1; +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CEC04.s") + +typedef struct { + void *unk0; // function pointer + s8 unk4; + s8 unk5; + s16 unk6; + f32 unk8; + Actor *unkC; + Actor *unk10; +} GlobalASMStruct61; + +void func_806CEFBC(void); // TODO: Proper signature, just for function pointer + +void func_806CEE64(f32 arg0) { + GlobalASMStruct61 *temp_v0; + + if (extra_player_info_pointer->unk1AC != 0) { + temp_v0 = malloc(0x14); + temp_v0->unk0 = &func_806CEFBC; + temp_v0->unk8 = arg0; + temp_v0->unkC = current_actor_pointer; + temp_v0->unk10 = extra_player_info_pointer->unk1AC; + temp_v0->unk4 = 0; + func_80679064(temp_v0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CEED8.s") + +extern f32 D_8075CBE0; +extern f64 D_8075CBE8; +f32 func_80611BB4(f32, f32); + +/* +// TODO: Very doable, just stack offsets to fix +void func_806CEED8(void) { + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp28; + s32 sp24; + s32 sp20; + + func_806CF2EC(&sp24, &sp20); + func_80671C0C(current_actor_pointer, sp24, &sp40, &sp38, &sp30); + func_80671C0C(current_actor_pointer, sp20, &sp44, &sp3C, &sp34); + sp28 = sp3C - sp38; + extra_player_info_pointer->unk1BC = ((0.0 - (func_80611BB4(sp28, sqrtf(((sp34 - sp30) * (sp34 - sp30)) + ((sp44 - sp40) * (sp44 - sp40)))) * D_8075CBE0)) + D_8075CBE8); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CEFBC.s") + +void func_806CF138(void); // TODO: Proper signature, just for function pointer + +typedef struct { + void *unk0; // function pointer + s8 unk4; + s8 unk5; + s16 unk6; + Actor *unk8; + Actor *unkC; + Actor *unk10; +} GlobalASMStruct62; + +void func_806CF0D0(void) { + GlobalASMStruct62 *temp_v0; + + if (extra_player_info_pointer->unk1AC != 0) { + temp_v0 = malloc(0x14); + temp_v0->unk0 = &func_806CF138; + temp_v0->unk8 = current_actor_pointer; + temp_v0->unkC = extra_player_info_pointer->unk1AC; + temp_v0->unk4 = 0; + func_80679064(temp_v0); + } +} + +// Doable, just fiddly float stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CF138.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CF2EC.s") + +extern f32 D_8075340C[]; +extern s32 D_80753428[]; + +void func_806CF398(Actor *arg0) { + PlayerAdditionalActorData *PaaD; + + if (arg0->interactable & 1) { + PaaD = arg0->PaaD; + if (PaaD->unk1AC) { + func_8067A784(current_actor_pointer, PaaD->unk1AC, D_807FBB48->y_rotation, D_80753428[D_807FD584], D_8075340C[D_807FD584]); + PaaD->unk1AC = NULL; + PaaD->unk1B0 = 0; + } + } +} + +void func_806CF42C(Actor *arg0) { + PlayerAdditionalActorData *PaaD; + + if (arg0->interactable & 1) { + PaaD = arg0->PaaD; + if (PaaD->unk1AC != 0) { + func_80679200(PaaD->unk1AC, arg0, 8, 0, 0, 0); + } else if (PaaD->unk1B0 != 0) { + func_80679200(PaaD->unk1B0, arg0, 8, 0, 0, 0); + } + PaaD->unk1AC = 0; + PaaD->unk1B0 = 0; + } +} + +// Probably doable, character_change loop with cc_number_of_players, PaaD +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CF4B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CF580.s") + +extern s32 D_8071FC40; +extern u8 D_80750AD0; +extern s32 D_80718BF4; // TODO: Datatype + +void func_806883F4(Actor*, s32, s32, f32); +void func_80688370(Actor*, s32, f32); + +/* +// TODO: Regalloc, bleh +// TODO: PaaD->unk0 may be s16 +void func_806CF580(void) { + u8 temp_v0_4; + u8 phi_v0; + + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + extra_player_info_pointer->unk84 = object_timer; + extra_player_info_pointer->unkD0 = object_timer; + } + if (current_character_index[cc_player_index] == 1) { + if ((current_actor_pointer->control_state == 0x36) && (extra_player_info_pointer->unk0 != 0x36)) { + func_806883F4(current_actor_pointer, 1, 0, 6.0f); + } + if (current_actor_pointer->control_state == 0x36) { + func_80688370(current_actor_pointer, 0, 0.5f); + func_806883C8(current_actor_pointer, 0, 0); + func_8068839C(current_actor_pointer, 0, 0); + func_806884E4(current_actor_pointer, 0); + func_8068848C(current_actor_pointer, 0, 4); + func_8068842C(current_actor_pointer, 0, 2); + func_80688370(current_actor_pointer, 1, 0.5f); + func_806883C8(current_actor_pointer, 1, 0); + func_8068839C(current_actor_pointer, 1, 0); + func_806884E4(current_actor_pointer, 1); + func_8068848C(current_actor_pointer, 1, 4); + func_8068842C(current_actor_pointer, 1, 2); + } + if (current_actor_pointer->control_state != 0x36) { + if (extra_player_info_pointer->unk0 == 0x36) { + extra_player_info_pointer->unk84 = 0; + } + } + } + if ((current_actor_pointer->control_state != 0x36) + && (func_8072881C(0, &extra_player_info_pointer->unk84) != 0) + && (((current_character_index[cc_player_index] == 1)) + || ((cc_number_of_players == 1) && (current_character_index[cc_player_index] == 3)))) { + func_8072881C(0x81, &extra_player_info_pointer->unk84); + } + temp_v0_4 = current_actor_pointer->control_state; + if (((temp_v0_4 == 0x4F) || (temp_v0_4 == 0x7F)) + && (D_80750AD0 == 0) + && ((extra_player_info_pointer->unkD0 + 9) < (u32)object_timer) + && (((func_806119A0() % 2500) / 200) == 0)) { + func_8071498C(&D_80718BF4); + func_807149B8(1); + func_807149FC(-1); + func_80714C08(&D_8071FC40, 0.0f, current_actor_pointer, 4, 0); + extra_player_info_pointer->unkD0 = object_timer; + } +} +*/ + +void func_806CF878(void) { + if ((object_timer & 3) == 0) { + if ((current_actor_pointer->control_state_progress >= 5) && (current_actor_pointer->y_velocity > 30.0f)) { + func_80714998(2); + func_807149B8(1); + func_8071498C(&D_80716FB4); + func_80714CC0(&D_8071FB08, 0.8f, current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer->z_position); + } + } +} + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CF918.s") + +extern f32 D_8075CC68; +void func_807195D4(void); +extern s32 D_8071FF40; + +/* +// TODO: Very close now, it's just setting at, s1, s2, s3 in the wrong order +void func_806CF918(void) { + s32 i; + f32 uvar = D_8075CC68; + + for (i = 0; i < 0xC8; i += 0x28) { + func_8071498C(&func_807195D4); + func_807149B8(1); + func_80714950(i); + func_807149FC(0x45); + func_80714C08(&D_8071FF40, uvar, current_actor_pointer, 6, 2); + } +} +*/ + +// Something to do with ledge grabs +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CF9CC.s") + +u8 func_8066635C(Actor *, f32, f32, f32, s32); +u8 func_80666AE0(); + +u8 func_806CFC90(Actor *arg0, s32 arg1, u8 arg2, f32 arg3) { + f32 sp34; + f32 temp_a3; + s16 phi_a3; + u8 temp_v0; + + phi_a3 = arg0->y_rotation; + if (!arg2) { + phi_a3 = (phi_a3 + 0x800) & 0xFFF; + } + sp34 = (func_80612794(phi_a3) * arg3); + temp_a3 = (func_80612790(phi_a3) * arg3); + temp_v0 = func_8066635C( + arg0, + arg0->x_position + sp34, + arg0->y_position + 30.0f, + arg0->z_position + temp_a3, + arg1 + ); + + arg0->unk78 = func_80666AE0(); + return temp_v0; +} + +void func_806CFD68() { + if (current_actor_pointer->y_velocity < 0.0f) { + func_806CFE7C(); + } +} + +void func_806CFDA8() { + if (current_actor_pointer->y_velocity < 0.0f) { + current_actor_pointer->y_acceleration = D_80753700[D_807FD584]; + } +} + +void func_806CFDEC() { + if (current_actor_pointer->y_velocity < 0.0f) { + current_actor_pointer->y_acceleration = D_80753658[D_807FD584]; + } +} + +void func_806CFE30() { + if (current_actor_pointer->y_velocity < 0.0f) { + D_807FBB48->y_acceleration = D_80753754[D_807FD584]; + } +} + +void func_806CFE7C() { + D_807FBB48->y_acceleration = D_80753578[D_807FD584]; +} + +void func_806CFEA4() { + D_807FBB48->y_acceleration = D_80753594[D_807FD584]; +} + +void func_806CFECC() { + D_807FBB48->y_acceleration = D_807535B0[D_807FD584]; +} + +void func_806CFEF4() { + D_807FBB48->y_acceleration = D_807536E4[D_807FD584]; +} + +void func_806CFF1C(Actor *arg0) { + current_actor_pointer->y_velocity = 0.0f; + func_80614E78(arg0, 0x1B); + func_80614D90(arg0); + current_actor_pointer->unk9C = current_actor_pointer->y_position; + if (extra_player_info_pointer->unk8C != 0) { + arg0->control_state = 0x1F; + arg0->control_state_progress = 0; + } else { + arg0->control_state = 0x1E; + arg0->control_state_progress = 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806CFF9C.s") + +void func_806D0150(Actor *arg0); +void func_806C8D20(Actor*); + +/* +// TODO: Frustratingly close +void func_806CFF9C(Actor *arg0) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + Actor *vehicle; + + arg0->unk6A &= 0xFFDF; + PaaD->unk4C = -1; + PaaD->unk10C = 0; + + if (arg0->noclip_byte == 1) { + func_806C8D20(arg0); + } + + if (D_807FBB64 & 0x80000) { + vehicle = PaaD->vehicle_actor_pointer; + if ((vehicle) && (vehicle->unk58 == 0x1D)) { + func_806D0150(arg0); + return; + } + } + + if (current_character_index[cc_player_index] == 7) { + arg0->control_state = 0x7E; + arg0->control_state_progress = 0; + return; + } + + if ((PaaD->unk1F0 & 0x20) && (cc_number_of_players == 1)) { + arg0->control_state = func_806CE4E4(arg0, arg0->unkB8, PaaD->unk4, 1); + arg0->control_state_progress = 0; + if (arg0->control_state == 0x3F) { + arg0->control_state_progress = 1; + } + return; + } + + // TODO: Problem appears to be below here + if (PaaD->unk1AC) { + arg0->control_state = func_806CE928(arg0, arg0->unkB8, PaaD->unk4, 1); + arg0->control_state_progress = 0; + return; + } + + if (PaaD->unk8C != 0) { + if (arg0->control_state != 2) { + arg0->control_state = func_806CE174(arg0, arg0->unkB8, PaaD->unk4, 1); + arg0->control_state_progress = 0; + } + } else if (arg0->control_state != 2) { + arg0->control_state = func_806CDD24(arg0, arg0->unkB8, PaaD->unk4, 1); + arg0->control_state_progress = 0; + } +} +*/ + +void func_806D0150(Actor *arg0) { + arg0->unk6A &= ~0x20; + extra_player_info_pointer->unk4C = -1; + extra_player_info_pointer->unk10C = 0; + func_80614E78(arg0, 0x7A); + arg0->control_state = 7; + arg0->control_state_progress = 0; +} + +void func_806D01AC(void) { + extra_player_info_pointer->unk48 = D_80753328[D_807FD584]; + extra_player_info_pointer->unk2C = D_807532F0[D_807FD584]; + extra_player_info_pointer->unk30 = D_8075330C[D_807FD584]; + extra_player_info_pointer->unk34 = D_807532B8[D_807FD584]; + extra_player_info_pointer->unk38 = D_807532D4[D_807FD584]; +} + +void func_806D024C(void) { + extra_player_info_pointer->unk48 = D_8075326C[D_807FD584]; + extra_player_info_pointer->unk2C = D_80753234[D_807FD584]; + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + extra_player_info_pointer->unk34 = D_80753170[D_807FD584]; + if (extra_player_info_pointer->unk8C != 0) { + extra_player_info_pointer->unk38 = D_80753338[D_807FD584]; + return; + } + if ((extra_player_info_pointer->unk1F0 & 0x20) || (is_autowalking == 3)) { + if (current_map == MAP_FUNGI) { + extra_player_info_pointer->unk38 = 200.0f; + } else { + extra_player_info_pointer->unk38 = D_80753218[D_807FD584]; + } + } else { + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + } +} + +void func_806D0378(void) { + D_807FBB48->y_acceleration = D_80753578[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk28 = 1; +} + +void func_806D03BC(void) { + if (extra_player_info_pointer->unk1AC != 0) { + func_806D01AC(); + } else { + func_806D024C(); + } + func_806D0378(); +} + +void func_806D0408(void) { + func_806D024C(); + func_806D0378(); +} + +void func_806D0430(f32 arg0) { + if (arg0 != 0.0f) { + D_80750FA8 = arg0; + return; + } + D_80750FA8 = D_8075CC6C; +} + +// Doable, kinda fiddly float & cc array stuff though... hmm +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D0468.s") + +f32 func_80612D1C(f32); +extern f64 D_8075CC90; +extern f64 D_8075CC98; +extern f64 D_8075CCA0; + +void func_806D06A0(void) { + if (extra_player_info_pointer->unk1CC < extra_player_info_pointer->unk1C0) { + extra_player_info_pointer->unk1CC += extra_player_info_pointer->unk1D8; + extra_player_info_pointer->unk1D0 += extra_player_info_pointer->unk1D8; + extra_player_info_pointer->unk1D4 += extra_player_info_pointer->unk1D8; + if (extra_player_info_pointer->unk1C0 < extra_player_info_pointer->unk1CC) { + extra_player_info_pointer->unk1CC = extra_player_info_pointer->unk1C0; + extra_player_info_pointer->unk1D0 = extra_player_info_pointer->unk1C4; + extra_player_info_pointer->unk1D4 = extra_player_info_pointer->unk1C8; + } + } else { + extra_player_info_pointer->unk1CC -= extra_player_info_pointer->unk1D8; + extra_player_info_pointer->unk1D0 -= extra_player_info_pointer->unk1D8; + extra_player_info_pointer->unk1D4 -= extra_player_info_pointer->unk1D8; + if (extra_player_info_pointer->unk1CC < extra_player_info_pointer->unk1C0) { + extra_player_info_pointer->unk1CC = extra_player_info_pointer->unk1C0; + extra_player_info_pointer->unk1D0 = extra_player_info_pointer->unk1C4; + extra_player_info_pointer->unk1D4 = extra_player_info_pointer->unk1C8; + } + } + if (extra_player_info_pointer->unk1C0 == extra_player_info_pointer->unk1CC) { + current_actor_pointer->animation_state->scale_x = extra_player_info_pointer->unk1CC; + current_actor_pointer->animation_state->scale_y = extra_player_info_pointer->unk1D0; + current_actor_pointer->animation_state->scale_z = extra_player_info_pointer->unk1D4; + } else { + current_actor_pointer->animation_state->scale_x = (func_80612D1C(extra_player_info_pointer->unk1E4 * D_8075CC90) * extra_player_info_pointer->unk1DC) + extra_player_info_pointer->unk1CC; + current_actor_pointer->animation_state->scale_y = (func_80612D1C(extra_player_info_pointer->unk1E4 * D_8075CC98) * extra_player_info_pointer->unk1DC) + extra_player_info_pointer->unk1D0; + current_actor_pointer->animation_state->scale_z = (func_80612D1C(extra_player_info_pointer->unk1E4 * D_8075CCA0) * extra_player_info_pointer->unk1DC) + extra_player_info_pointer->unk1D4; + extra_player_info_pointer->unk1DC -= extra_player_info_pointer->unk1E0; + if (extra_player_info_pointer->unk1DC < 0.0) { + extra_player_info_pointer->unk1DC = 0.0f; + } + extra_player_info_pointer->unk1E4++; + } +} + +s32 func_806D0964(s32 arg0, u8 playerIndex) { + s16 actorBehaviourIndex = character_change_array[playerIndex].player_pointer->unk58; + if (actorBehaviourIndex != ACTOR_CHUNKY) { + if ((actorBehaviourIndex == ACTOR_RAMBI) && (arg0 & 2)) { + return TRUE; + } + } else { + if ((arg0 & 1) && (character_change_array[playerIndex].unk2C0 != 1)) { + return TRUE; + } + } + return FALSE; +} + +void func_806D09E8(Actor *arg0) { + if ((arg0->unk58 == 4) + && (((arg0->control_state == 0x3F)) || (arg0->control_state == 0x40)) + && !(D_807FBB68 & 0x40) + && !func_80666A88()) { + arg0->unkD1 = 0x10; + } +} + +void func_806D0A54(Actor *arg0, s32 arg1, s32 arg2) { + if (arg1) { + arg0->object_properties_bitfield |= 4; + } else { + arg0->object_properties_bitfield &= ~4; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D0A84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D0DE4.s") + +/* +// TODO: Need to sus out datatypes for Actor->additional_data_pointer +// Might be better to start this one from scratch with a new ctx.c file +s32 func_806D0DE4(Actor *arg0, Actor *arg1) { + s32 phi_v0; + s32 phi_v1; + u8 phi_a0; + u8 phi_a2; + + phi_v0 = 1; + phi_a0 = 1; + phi_a2 = 1; + if (1 < cc_number_of_players && !(arg0->interactable & 4)) { + if (!(arg1->interactable & 4)) { + if (arg0->interactable & 1) { + //phi_v0 = character_change_array[arg0->additional_data_pointer[0x1A4]][0x2C0]; + phi_v0 = *(u8 *)(*(s32 *)(arg0 + 0x174) + 0x1A4); + phi_v0 = *(u8 *)(&character_change_array[0x2C0] + ((u32)phi_v0 * 0x30 - (u32)phi_v0) * 0x10); + } + if (arg1->interactable & 1) { + //phi_v1 = character_change_array[arg1->additional_data_pointer[0x1A4]][0x2C0]; + phi_v1 = *(u8 *)(*(s32 *)(arg0 + 0x174) + 0x1A4); + phi_v1 = *(u8 *)(&character_change_array[0x2C0] + ((u32)phi_v1 * 0x30 - (u32)phi_v1) * 0x10); + phi_a2 = arg1->control_state != 0x7C; + phi_a0 = phi_v0 < phi_v1; + } + + if (phi_a0) { + phi_a0 = phi_a2 != 0; + } + //return phi_a0; + } + } + return phi_a0; +} +*/ + +extern s16 D_8075387C[]; +extern s16 D_807538B8[]; +extern s16 D_8075388C[]; +extern s16 D_807538C8[]; +extern s16 D_807539EC[]; +extern s16 D_807539EC[]; +extern s16 D_807539DC[]; + +void func_806D0EBC(s32 arg0) { + f32 phi_f12; + f32 phi_f0; + + if (character_change_array[cc_player_index].unk2C0 == 1) { + phi_f12 = D_8075388C[D_807FD584]; + } else { + phi_f12 = D_807538C8[D_807FD584]; + } + if (character_change_array[cc_player_index].unk2C0 == 1) { + phi_f0 = D_8075387C[D_807FD584]; + } else { + phi_f0 = D_807538B8[D_807FD584]; + } + if ((current_actor_pointer->unkAC - current_actor_pointer->floor) < phi_f0) { + func_806EB0C0(2, NULL, cc_player_index); + return; + } + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + phi_f12)) { + func_80608528(current_actor_pointer, 0x10, 0xFF, 0x7F, 1); + current_actor_pointer->y_position = current_actor_pointer->unkAC - phi_f12; + current_actor_pointer->y_velocity = 0.0f; + func_80614E78(current_actor_pointer, 0x3D); + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + current_actor_pointer->control_state = 0x4E; + current_actor_pointer->control_state_progress = 0; + } +} + +// TODO: Can we simplify this? +s16 func_806D1080(f32 arg0, f32 arg1) { + return (s16)((s16)((func_80611BB4(arg0, arg1) * 4096.0f) / D_8075CCE0) - 0x400) & 0xFFF; +} + +// TODO: Can we simplify this? +s32 func_806D10D0(Actor *arg0) { + s32 phi_v1; + + phi_v1 = TRUE; + if ((arg0->interactable & 1) && (D_80750B54[arg0->control_state].unk0 & 0x400)) { + phi_v1 = FALSE; + } + return phi_v1; +} + +void func_806D1110(void) { + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806DF6D4(0xB); + D_807FBB48->unkB8 = extra_player_info_pointer->unk4; + D_807FBB48->unkEE = extra_player_info_pointer->unkA; + D_807FBB48->y_rotation = extra_player_info_pointer->unkA; + func_806CC8F0(); + if (!(D_807FD610[cc_player_index].unk2A & (Z_TRIG | U_CBUTTONS | D_CBUTTONS))) { + func_806CFF9C(current_actor_pointer); + func_806C8D20(current_actor_pointer); + } else { + current_actor_pointer->noclip_byte = 1; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D11FC(void) { + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + 4.5f)) { + current_actor_pointer->y_position = current_actor_pointer->unkAC - 4.5f; + } +} + +void func_806D1238(void) { + func_806DF6D4(0x66); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1270(void) { + +} + +void func_806D1278(void) { + func_806DF6D4(1); + // TODO: Proper bitfield syntax + if ((extra_player_info_pointer->unk1F0 << 0xF) >= 0) { + func_806CFF9C(current_actor_pointer); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D12CC(void) { + current_actor_pointer->y_velocity = func_806CD898(current_actor_pointer->y_velocity, 50.0f, 4.0f); + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk24 = 0; + extra_player_info_pointer->unk38 = 100.0f; + func_806DF6D4(0x67); + func_806CC8F0(); + current_actor_pointer->control_state_progress += 1; + break; + case 1: + func_806CC8F0(); + if ((current_actor_pointer->unkB8 > 10.0f) && (current_actor_pointer->animation_state->unk64 != 0x317)) { + func_80614EBC(current_actor_pointer, 0x317); + } else if ((current_actor_pointer->unkB8 == 0.0f) && (current_actor_pointer->animation_state->unk64 != 0x314)) { + func_80614EBC(current_actor_pointer, 0x314); + } + func_806DF6D4(0x67); + break; + } + func_806D11FC(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1420(void) { + extra_player_info_pointer->unk24 = 0; + if (current_actor_pointer->control_state_progress == 0) { + extra_player_info_pointer->unk48 = 0xA; + current_actor_pointer->y_acceleration = -8.0f; + current_actor_pointer->z_rotation = func_806D1080(current_actor_pointer->unkB8, current_actor_pointer->y_velocity); + func_806DF494(¤t_actor_pointer->x_rotation, 0, 0x32); + func_806DF494(¤t_actor_pointer->z_rotation, func_806D1080(current_actor_pointer->unkB8, current_actor_pointer->y_velocity), 0xA); + func_806DF6D4(0x6A); + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + func_806CC948(); + } + if (((current_actor_pointer->y_position + 4.0f) < current_actor_pointer->unkAC) + && (current_actor_pointer->y_velocity < 0.0f)) { + current_actor_pointer->control_state = 0x7F; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk1C = 2; + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D1568.s") + +void func_806CC638(f32 arg0); +extern s16 D_80753A78[]; + +/* +// TODO: Insanely close, float regalloc +void func_806D1568(void) { + f64 temp_f0; + f64 temp_f2; + f64 temp; + + extra_player_info_pointer->unk24++; + extra_player_info_pointer->unk2C = D_80753AFC[D_807FD584]; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x4C); + // TODO: Float regalloc here + temp = -current_actor_pointer->y_velocity; + current_actor_pointer->y_velocity = func_806CD898(current_actor_pointer->y_velocity, 0.0f, temp * 0.125f); + if (extra_player_info_pointer->unk24 >= 6) { + if ((current_actor_pointer->unkB8 != 0.0f) || (extra_player_info_pointer->unk10 != 0)) { + current_actor_pointer->control_state_progress = 3; + } else { + current_actor_pointer->control_state_progress = 2; + } + current_actor_pointer->animation_state->unk78 &= -0x4001; + } + func_806CC5DC(); + break; + case 1: + func_806DF494(¤t_actor_pointer->z_rotation, func_806D1080(current_actor_pointer->unkB8, current_actor_pointer->y_velocity), 0x32); + extra_player_info_pointer->unk38 = 500; + func_806DF6D4(0x57); + func_806CC638(0.0f); + if (extra_player_info_pointer->unk10 == 0) { + current_actor_pointer->control_state_progress = 3; + } + break; + case 2: + func_806DF6D4(0x55); + func_806CC638(0); + if (current_actor_pointer->control_state == 0x7F) { + if (current_actor_pointer->unkB8 != 0) { + extra_player_info_pointer->unk18 = 0; + current_actor_pointer->control_state_progress = 3; + } else { + if (extra_player_info_pointer->unk50 != 0) { + extra_player_info_pointer->unk50--; + if (extra_player_info_pointer->unk50 == 0) { + func_80614EBC(current_actor_pointer, 0x315); + } + } + } + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + 4.0f)) { + current_actor_pointer->control_state = 0x7E; + current_actor_pointer->control_state_progress = 0; + } + } + break; + case 3: + func_806DF6D4(0x56); + func_806CC638(0); + temp_f0 = current_actor_pointer->unkB8 / 200.0; + temp_f2 = current_actor_pointer->y_velocity / 200.0; + func_80614D00(current_actor_pointer, sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2)), 5); + if ((current_actor_pointer->unkB8 == 0.0f) || (extra_player_info_pointer->unk18 != 0)) { + extra_player_info_pointer->unk50 = D_80753A78[D_807FD584]; + func_80614D00(current_actor_pointer, 0.5f, extra_player_info_pointer->unk50); + current_actor_pointer->control_state_progress = 2; + } + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + 4)) { + func_80608528(current_actor_pointer, 0x10, 0xFF, 0x7F, 1); + if (current_actor_pointer->y_velocity > 150) { + current_actor_pointer->control_state = 0x82; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0); + } else { + current_actor_pointer->control_state = 0x7E; + current_actor_pointer->control_state_progress = 0; + } + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D19A8(void) { + current_actor_pointer->y_velocity = func_806CD898(current_actor_pointer->y_velocity, 50.0f, 4.0f); + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk48 = 0x50; + func_806DF6D4(0x68); + func_806CD8EC(); + func_806CC970(); + break; + case 1: + extra_player_info_pointer->unk68 = 200.0f; + extra_player_info_pointer->unk2C = 40.0f; + func_806CD424(current_actor_pointer->y_rotation, extra_player_info_pointer->unk68, extra_player_info_pointer->unk68); + func_806DF6D4(0x68); + func_806CC970(); + break; + case 2: + func_806DF6D4(0x68); + func_806CD424(current_actor_pointer->y_rotation, extra_player_info_pointer->unk4, extra_player_info_pointer->unk68); + func_806CC970(); + break; + case 3: + func_806DF6D4(0x68); + func_806CC8F0(); + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + 4.0f)) { + current_actor_pointer->control_state = 0x7E; + current_actor_pointer->control_state_progress = 0; + } else { + current_actor_pointer->control_state = 0x7F; + current_actor_pointer->control_state_progress = 0; + } + break; + } + func_806D11FC(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1B60(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x69); + func_806CD8EC(); + func_806CC970(); + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + break; + case 1: + extra_player_info_pointer->unk2C = 40.0f; + extra_player_info_pointer->unk10 = 0xA; + extra_player_info_pointer->unk38 = 200.0f; + func_806DF6D4(0x69); + func_806CC638(0); + break; + case 2: + func_806DF6D4(0x69); + func_806CD424(current_actor_pointer->y_rotation, + extra_player_info_pointer->unk4, + extra_player_info_pointer->unk68); + func_806CC970(); + break; + case 3: + func_806DF6D4(0x69); + func_806CC920(); + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + 4.0f)) { + current_actor_pointer->control_state = 0x7E; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0x317); + } else { + current_actor_pointer->control_state = 0x7F; + current_actor_pointer->control_state_progress = 3; + func_80614EBC(current_actor_pointer, 0x318); + extra_player_info_pointer->unk38 = 300.0f; + extra_player_info_pointer->unk10 = 0xF; + } + break; + } + func_806D11FC(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1D3C() { + extra_player_info_pointer->unk4 = 0.0f; + func_806DF6D4(0x65); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1D84(void) { + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unk30 = 20.0f; + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1DEC(void) { + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unk30 = 20.0f; + func_806CC8B8(); + if ((func_80629148()) || + (current_actor_pointer->control_state_progress == 1) || + (--extra_player_info_pointer->unk23C == 0) // TODO: Janky syntax + ) { + func_805FF8F8(); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1E90(void) { + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unk30 = 20.0f; + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806CC8B8(); + if (current_actor_pointer->control_state_progress != 0) { + func_805FF898(current_actor_pointer); + current_actor_pointer->control_state_progress++; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D1F28(void) { + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unk30 = 20.0f; + func_806EB0C0(0x3C, NULL, cc_player_index); + if (!(current_actor_pointer->unk6A & 4)) { + func_806CC8B8(); + } else { + func_806D850C(); + if (!(current_actor_pointer->unk6C & 4)) { + func_80614E78(player_pointer, 0x34); + } + current_actor_pointer->y_velocity *= 0.25; + func_806CC8B8(); + } + if (func_80629148() || ((--extra_player_info_pointer->unk23C == 0))) { // TODO: Janky syntax + func_806ACC00(0); + current_actor_pointer->control_state_progress++; + } + func_806319C4(current_actor_pointer, 0); +} + +// Structs on the stack? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D205C.s") + +void func_806D21E4(void) { + func_806DF6D4(0); + if (!(global_properties_bitfield & 0x4000) && !(global_properties_bitfield & 0x8000)) { + func_806CFF9C(current_actor_pointer); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D2238(void) { + func_806DF6D4(1); + if (current_actor_pointer->control_state_progress == 0) { + func_80614E78(current_actor_pointer, 0); + current_actor_pointer->control_state_progress = 1; + current_actor_pointer->object_properties_bitfield &= -5; + } +} + +void func_806D22A0() { + func_806DF6D4(1); +} + +void func_806D22C0(void) { + func_806DF6D4(0x62); + switch (current_actor_pointer->control_state_progress) { + case 0x1: + case 0x2: + current_actor_pointer->control_state_progress++; + return; + default: + current_actor_pointer->control_state_progress++; + case 0x0: + case 0x3C: + case 0x3D: + return; + } +} + +typedef struct { + s32 unk0; + u8 unk4; + s8 unk5; + s16 unk6; + Actor *unk8; +} GlobalASMStruct1; + +void func_806D2330(s32 arg0) { + GlobalASMStruct1 *temp_v0 = malloc(0x14); + temp_v0->unk0 = arg0; + temp_v0->unk8 = D_807FBB48; // player_pointer + temp_v0->unk4 = 1; + func_80679064(temp_v0); +} + +void func_806D2378(void) { + func_806D2330(&func_8068E9B0); +} + +void func_806D239C(void) { + func_806D2378(); + switch (current_map) { + case MAP_FUNGI_MINECART: + func_806DF6D4(0x5F); + func_806CC970(); + return; + case MAP_CASTLE_MINECART: + func_806DF6D4(0x60); + func_806CC970(); + return; + case MAP_MINECART_MAYHEM_EASY: + case MAP_MINECART_MAYHEM_NORMAL: + case MAP_MINECART_MAYHEM_HARD: + if ((extra_player_info_pointer->unk1F0 & 8) && func_80629148()) { + extra_player_info_pointer->vehicle_actor_pointer->control_state = 0xA; + current_actor_pointer->control_state_progress++; + } + func_806DF6D4(0x5B); + func_806CC970(); + return; + default: + func_806DF6D4(0x5C); + current_actor_pointer->y_velocity = current_actor_pointer->terminal_velocity; + func_806CC948(); + return; + } +} + +void func_806D24A8(void) { + func_806D2378(); + func_806DF6D4(0x5D); + current_actor_pointer->y_velocity = current_actor_pointer->terminal_velocity; + func_806CC948(); +} + +void func_806D24E4(void) { + func_806D2378(); + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x5E); + func_806CC948(); + return; + case 1: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x5E); + func_806CFD68(); + func_806CC948(); + return; + case 2: + func_806CC948(); + func_806DF6D4(0x5E); + func_806CFD68(); + return; + case 3: + func_806DF6D4(0x5C); + func_806CC948(); + return; + } +} + +void func_806D25CC(void) { + switch (current_map) { + case MAP_CASTLE_MINECART: + func_806DF6D4(0x60); + func_806CC970(); + break; + case MAP_FUNGI_MINECART: + func_806DF6D4(0x5F); + func_806CC970(); + break; + case MAP_MINECART_MAYHEM_EASY: + func_806DF6D4(0x5B); + func_806CC970(); + break; + default: + func_806DF6D4(0x5C); + current_actor_pointer->y_velocity = current_actor_pointer->terminal_velocity; + func_806CC948(); + } +} + +void func_806D266C(void) { + s32 sp2C, sp28, sp24; + + func_806D2378(); + func_806D25CC(); + func_80671C0C(current_actor_pointer, 3, &sp2C, &sp28, &sp24); + func_806F4D70(cc_player_index, sp2C, sp28, sp24, 25.0f); +} + +void func_806D26D8(void) { + s32 sp2C, sp28, sp24; + + func_806D2378(); + func_806D25CC(); + func_80671C0C(current_actor_pointer, 2, &sp2C, &sp28, &sp24); + func_806F4D70(cc_player_index, sp2C, sp28, sp24, 25.0f); +} + +void func_806D2744(s32 arg0) { + func_806D2330(&func_8068EA38); + func_806DF6D4(arg0); + current_actor_pointer->unk6C = current_actor_pointer->unk6A; +} + +void func_806D2784() { + func_806D2744(0x61); +} + +void func_806D27A4(void) { + func_806D2744(0x63); + if (func_8061CB98(5)) { + if (current_actor_pointer->animation_state->unk64 != 0x3B0) { + func_80614EBC(current_actor_pointer, 0x3B0); + } + if (func_80629148() || (current_actor_pointer->control_state_progress != 0)) { + func_805FF8F8(); + } + } +} + +void func_806D281C(void) { + RaceAdditionalActorData *RaaD = extra_player_info_pointer->vehicle_actor_pointer->RaaD; + if (current_actor_pointer->control_state_progress != 0) { + current_actor_pointer->control_state = 0x6D; + current_actor_pointer->control_state_progress = 0; + } else { + func_806EB0C0(0x3C, NULL, cc_player_index); + } + RaaD->unk0 += extra_player_info_pointer->unkC2; + if (extra_player_info_pointer->unkC2 >= 8) { + extra_player_info_pointer->unkC2 -= 7; + } else if (extra_player_info_pointer->unkC2 < -7) { + extra_player_info_pointer->unkC2 += 7; + } else { + extra_player_info_pointer->unkC2 = 0; + } + func_806D2744(1); +} + +void func_806D28E4(void) { + func_806D2744(0x64); +} + +void func_806D2904(void) { + func_806319C4(current_actor_pointer, 0); + if (current_actor_pointer->control_state_progress++ > 200) { + func_806CFF9C(current_actor_pointer); + } +} + +void func_806D2954(s16 arg0) { + if ((extra_player_info_pointer->unk8C != 0) && func_805FCA64()) { + if (D_807FD568->unk2 == 7) { + arg0 = 0xF; + func_8068C350(&D_806FF75C, current_actor_pointer, 5); + } else { + arg0 = 0xE; + func_8068C350(&D_806FF01C, current_actor_pointer, 5); + } + } + if (current_actor_pointer->control_state_progress != 0) { + arg0 = 5; + current_actor_pointer->control_state_progress--; + } + func_806DF6D4(arg0); +} + +void func_806D2A14(s16 arg0) { + if (current_actor_pointer->control_state_progress != 0) { + arg0 = 5; + current_actor_pointer->control_state_progress--; + } + if (func_805FCA64()) { + if (!func_806DF6D4(arg0)) { + func_8068C350(&D_806FF358, current_actor_pointer, 3); + } + func_8068C350(&D_806FF32C, current_actor_pointer, 3); + } +} + +void func_806D2AA0(s16 arg0) { + func_806DF6D4(1); + if (current_actor_pointer->control_state_progress < 6) { + func_8068C350(&func_806FFB2C, current_actor_pointer, 3); + current_actor_pointer->control_state_progress++; + } else { + current_actor_pointer->control_state = arg0; + current_actor_pointer->control_state_progress = 0; + } + if (current_actor_pointer->control_state_progress == 2) { + func_80677FA8(0xCA, 0x8D); // Spawn fairy picture actor (202) + extra_player_info_pointer->vehicle_actor_pointer = D_807FBB44; + D_807FBB44->PaaD->unk0 = extra_player_info_pointer; + extra_player_info_pointer->unk1F0 |= 0x8000; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D2B90(void) { + func_806D2AA0(4); +} + +void func_806D2BB0(void) { + func_806D2AA0(5); +} + +void func_806D2BD0(void) { + func_806D2954(0xC); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); + if (func_8061CB50()) { + if (current_actor_pointer->unk6E != -1) { + func_80605314(current_actor_pointer, 0); + } + } + if (is_autowalking == 3) { + func_806C9F74(current_actor_pointer); + } +} + +void func_806D2C54(void) { + func_806D2A14(0x10); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); + if (is_autowalking == 3) { + func_806C9F74(current_actor_pointer); + } +} + +void func_806D2CAC(void) { + extra_player_info_pointer->unk2C = D_80753AFC[D_807FD584]; + func_806D2954(0xD); + func_806CC638(D_80753A5C[D_807FD584]); + if (func_806D850C()) { + func_806EAB44(current_actor_pointer, 1); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D2D38(void) { + extra_player_info_pointer->unk2C = D_80753AFC[D_807FD584]; + func_806D2A14(0x11); + func_806CC638(D_80753A5C[D_807FD584]); + if (func_806D850C()) { + func_806EAB44(current_actor_pointer, 1); + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D2DC4.s") + +/* +// Regalloc +void func_806D2DC4(void) { + u8 newControlState; + s32 phi_a1; + + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + current_actor_pointer->unk64 |= 0x200; + phi_a1 = 0x13; + if (current_actor_pointer->control_state_progress != 0) { + current_actor_pointer->control_state_progress--; + phi_a1 = 0x14; + } + if (object_timer > 1 && !func_806DF6D4(phi_a1)) { + newControlState = func_806CDD24(current_actor_pointer, current_actor_pointer->unkB8, extra_player_info_pointer->unk4, 1); + if (newControlState != 0xC) { + // TODO: Non matching here + // TODO: It's using t2 instead of t4 + current_actor_pointer->control_state = newControlState; + // TODO: It's using t3 instead of t5 + current_actor_pointer->control_state_progress = 0; + } + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D2E9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D3224.s") + +/* +void func_806D3224(void) { + u8 newControlState; + + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + if (func_806DF6D4(0x1D) == 0) { + newControlState = func_806CE174(current_actor_pointer, current_actor_pointer->unkB8, extra_player_info_pointer->unk4, 1); + if (newControlState != 0x5D) { + // TODO: Non matching here + // TODO: It's using t8 instead of t0 + current_actor_pointer->control_state = newControlState; + // TODO: It's using t9 instead of t1 + current_actor_pointer->control_state_progress = 0; + } + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D32C0(void) { + if ((current_map == MAP_BUSY_BARREL_BARRAGE_EASY) + || (current_map == MAP_BUSY_BARREL_BARRAGE_NORMAL) + || (current_map == MAP_BUSY_BARREL_BARRAGE_HARD)) { + func_806DF6D4(0x1F); + } else { + func_806DF6D4(0x1E); + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D332C.s") + +/* +// TODO: Surprisingly close to matching this one, just need to shuffle which t registers it's using +void func_806D332C(void) { + u8 newControlState; + + if (current_actor_pointer->control_state_progress == 0) { + current_actor_pointer->control_state_progress++; + extra_player_info_pointer->unkC = -1; + extra_player_info_pointer->unkE = -1; + } + if (func_806DF6D4(0x13) == 0) { + newControlState = func_806CDD24(current_actor_pointer, current_actor_pointer->unkB8, extra_player_info_pointer->unk4, 1); + if (newControlState != 0xD) { + current_actor_pointer->control_state = newControlState; + current_actor_pointer->control_state_progress = 0; + } + } + if ((!func_8061CB50()) + && (D_807531E0[D_807FD584] < current_actor_pointer->unkB8) + && (D_807531E0[D_807FD584] < extra_player_info_pointer->unk4) + && (extra_player_info_pointer->unkC >= 0) + && (func_806CC14C(extra_player_info_pointer->unkC, extra_player_info_pointer->unkA) >= 0x401) + && (func_806CC14C(current_actor_pointer->unkEE, extra_player_info_pointer->unkA) >= 0x539)) { + current_actor_pointer->control_state = 0xE; + current_actor_pointer->control_state_progress = 0; + func_806CC948(); + } else { + func_806CC8B8(); + } + extra_player_info_pointer->unkC = extra_player_info_pointer->unkE; + extra_player_info_pointer->unkE = extra_player_info_pointer->unkA; + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D34B4.s") + +/* +void func_806D34B4(void) { + u8 newControlState; + if (func_806DF6D4(0x1C) == 0) { + newControlState = func_806CE174(current_actor_pointer, current_actor_pointer->unkB8, extra_player_info_pointer->unk4, 1); + if (newControlState != 0x5E) { + // TODO: Non matching here + // TODO: It's using t7 instead of t9 + current_actor_pointer->control_state = newControlState; + // TODO: It's using t8 instead of t0 + current_actor_pointer->control_state_progress = 0; + } + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D3530(void) { + if (((current_actor_pointer->unk9C - current_actor_pointer->y_position) > 50.0f) && (current_actor_pointer->distance_from_floor > 250.0f)) { + extra_player_info_pointer->unk42++; + } else { + extra_player_info_pointer->unk42 = 0; + } + if ((extra_player_info_pointer->unk42++ >= 0xB) || (current_actor_pointer->y_position < -10.0f)) { + func_806EB0C0(0x2D, NULL, cc_player_index); + } +} + +void func_806D3608(void) { + f32 temp_f0 = current_actor_pointer->animation_state->scale_y / D_8075CD08; + if ((D_807FBB64 << 0xD) >= 0) { + if (!func_8061CB50()) { + if (current_map == MAP_AZTEC_BEETLE_RACE) { + func_806D3530(); + return; + } + if ((290.0f * temp_f0) < (current_actor_pointer->unk9C - current_actor_pointer->y_position)) { + func_806EB0C0(0x2C, NULL, cc_player_index); + } + } + } +} + +void func_806D36CC(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x20); + func_806D3608(); + break; + case 1: + func_806DF6D4(0x31); + func_806CFE7C(); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D374C(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x20); + func_806D3608(); + break; + case 1: + func_806DF6D4(0x32); + func_806CFE7C(); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D37CC(void) { + if (current_actor_pointer->control_state_progress == 0) { + func_806DF6D4(0x20); + func_806CC8B8(); + if (current_actor_pointer->unk6A & 1) { + if (current_actor_pointer->unkE0 != 0.0f) { + func_806CFF9C(current_actor_pointer); + } else { + func_806CFE7C(); + func_806EB0C0(0x35, NULL, cc_player_index); + } + } + } else { + func_806DF6D4(0x20); + extra_player_info_pointer->unk4 = 0.0f; + current_actor_pointer->unkB8 = 0.0f; + func_806CC8B8(); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D38AC(s32 arg0) { + func_80685210(0.5f, 0x64, 5); + current_actor_pointer->unkF8 = 0x12C; + if ((current_actor_pointer->y_position - current_actor_pointer->floor) > 5.0f) { + if (current_actor_pointer->y_acceleration == -260.0f) { + func_806CFE7C(); + } else if (current_actor_pointer->y_acceleration != -30.0f) { + current_actor_pointer->unk6A |= 0x1000; + } else { + if (current_actor_pointer->y_velocity > 0.0f) { + current_actor_pointer->y_velocity = 0.0f; + } else { + current_actor_pointer->y_velocity = current_actor_pointer->y_velocity; + } + } + current_actor_pointer->control_state = 0x14; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = current_actor_pointer->y_velocity; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x67); + } + func_806DF6D4(arg0); + func_806CC8B8(); + if ((current_actor_pointer->unk6A & 0x200) == 0) { + func_806CFF9C(current_actor_pointer); + func_80605314(current_actor_pointer, 0); + func_806224CC(extra_player_info_pointer->unk104, current_actor_pointer); + } + func_806319C4(current_actor_pointer, 0); +} + +extern f32 D_8075CD10; + +void func_806D3A38(void) { + if (current_actor_pointer->control_state_progress == 0) { + func_8061C464(extra_player_info_pointer->unk104, current_actor_pointer, 4, 0x800, 0x32, 0, 5, 0x32, 0x14, 0, D_8075CD10); + current_actor_pointer->control_state_progress++; + } + func_806D38AC(0x3D); +} + +void func_806D3AC8() { + func_806D38AC(0x3D); +} + +void func_806D3AE8() { + func_806D38AC(0x3D); +} + +void func_806D3B08() { + func_806D38AC(0x3D); +} + +void func_806D3B28() { + func_806D38AC(0x3D); +} + +void func_806D3B48(void) { + extra_player_info_pointer->unk4 = 0.0f; + func_806CC8B8(); + current_actor_pointer->control_state_progress++; + if (current_actor_pointer->control_state_progress == 0x32) { + RaceAdditionalActorData *RaaD = extra_player_info_pointer->vehicle_actor_pointer->RaaD; + RaaD->unk45 = 1; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D3BC8(void) { + func_806DF6D4(0x3E); + func_806CC8B8(); + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + current_actor_pointer->control_state_progress++; + break; + case 1: + if (current_map == MAP_AZTEC_BEETLE_RACE) { + func_806D3530(); + } + break; + case 2: + if (current_actor_pointer->unk6A & 1) { + current_actor_pointer->unk6A &= ~0x1000; + func_806CFE7C(); + current_actor_pointer->control_state = 0xF; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x5E); + } else { + func_806D3530(); + } + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D3CD4(void) { + func_80685210(0.5f, 0x64, 5); + func_806DF6D4(0x3C); + func_806CC8B8(); + if (current_actor_pointer->unkB8 == 0.0f) { + if (current_actor_pointer->unkE0 == 0.0f) { + func_806CFF9C(current_actor_pointer); + } + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D3D5C(void) { + func_80685210(0.5f, 0x64, 5); + func_806DF6D4(0x3B); + func_806CC8B8(); + if (current_actor_pointer->unkB8 == 0.0f) { + if (current_actor_pointer->unkE0 == 0.0f) { + func_806CFF9C(current_actor_pointer); + } + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D3DE4(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x41); + func_80614E78(current_actor_pointer, 5); + extra_player_info_pointer->unk30 = D_8075327C[D_807FD584]; + func_806CD8EC(); + func_806CC948(); + current_actor_pointer->control_state_progress++; + break; + case 1: + func_806DF6D4(0x41); + func_806CD8EC(); + func_806CC948(); + break; + case 2: + func_806DF6D4(0x41); + func_806CD8EC(); + func_806DF5A0(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, D_80753298[D_807FD584], 0xC00); + func_806CC948(); + break; + case 3: + func_806DF6D4(0x41); + func_806DF5A0(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, D_80753298[D_807FD584], 0xC00); + if (extra_player_info_pointer->unk4 == 0.0f) { + func_806CFF9C(current_actor_pointer); + } + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D3FA0(void) { + if (D_807FD610[cc_player_index].unk8 != 0.0f) { + current_actor_pointer->unkEA = extra_player_info_pointer->unkA; + } else { + current_actor_pointer->unkEA = current_actor_pointer->y_rotation; + } +} + +extern f32 D_80753604[]; + +void func_806D4010(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x2C); + func_806CC8B8(); + break; + case 1: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + func_806D3FA0(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x21); + func_806CFD68(); + func_806CC8B8(); + break; + case 2: + func_806CC8B8(); + if (current_actor_pointer->unk58 == 5) { + func_806DF6D4(0x22); + } else { + func_806DF6D4(0x21); + } + func_806CFD68(); + break; + case 3: + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xAU) && (current_character_index[cc_player_index] == 1)) { + if (current_actor_pointer->unkE0 == 0.0f) { + current_actor_pointer->control_state = 0x1A; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_80753604[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x13); + } + } + func_806DF6D4(0x30); + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D423C(void) { + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806DF6D4(5); + func_806CC8F0(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D428C(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x2C); + if (extra_player_info_pointer->unk3C != 0) { + func_806CC948(); + extra_player_info_pointer->unk3C--; + } else { + func_806CC8B8(); + } + break; + case 1: + if (extra_player_info_pointer->unk3C != 0) { + extra_player_info_pointer->unk2C = 0.0f; + func_806CC8B8(); + extra_player_info_pointer->unk3C--; + current_actor_pointer->unkEA = current_actor_pointer->y_rotation; + } else { + func_806D3FA0(); + func_806CC8B8(); + } + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x21); + func_806CFD68(); + break; + case 2: + if (extra_player_info_pointer->unk3C != 0) { + extra_player_info_pointer->unk2C = 0.0f; + func_806CC8B8(); + extra_player_info_pointer->unk3C--; + } else { + extra_player_info_pointer->unk2C = D_80753234[D_807FD584]; + func_806CC8B8(); + } + if (current_actor_pointer->unk58 == 5) { + func_806DF6D4(0x22); + } else { + func_806DF6D4(0x21); + } + func_806D3608(); + func_806CFD68(); + break; + case 3: + extra_player_info_pointer->unk3C = 0; + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xAU) && (current_character_index[cc_player_index] == 1)) { + if (current_actor_pointer->unkE0 == 0.0f) { + current_actor_pointer->control_state = 0x1A; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_80753604[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x13); + } + } + func_806DF6D4(0x30); + func_806CC8B8(); + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D45A4(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x2C); + func_806CC8B8(); + break; + case 1: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + func_806D3FA0(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x21); + func_806CFD68(); + func_806CC8B8(); + break; + case 2: + func_806CC8B8(); + if (current_actor_pointer->unk58 == 5) { + func_806DF6D4(0x22); + } else { + func_806DF6D4(0x21); + } + func_806D3608(); + func_806CFD68(); + break; + case 3: + extra_player_info_pointer->unk4C = -1; + current_actor_pointer->control_state = func_806CE4E4(current_actor_pointer, current_actor_pointer->unkB8, extra_player_info_pointer->unk4, 1); + current_actor_pointer->control_state_progress = 0; + if (current_actor_pointer->control_state == 0x3F) { + current_actor_pointer->control_state_progress = 1; + } + func_806DF6D4(0x46); + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D4758.s") + +extern f64 D_8075CD18; +extern f64 D_8075CD20; + +/* +void func_806D4758(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + if (extra_player_info_pointer->unk3E != 0) { + func_806CC14C(current_actor_pointer->unkEE, extra_player_info_pointer->unk40); + func_806CD424(extra_player_info_pointer->unk40, 50.0f, extra_player_info_pointer->unk38); + extra_player_info_pointer->unk3E--; + } + func_806DF6D4(0x23); + switch (current_character_index[cc_player_index]) { + case 2: + extra_player_info_pointer->unk4 *= D_8075CD18; + } + func_806CC8B8(); + break; + case 1: + func_806DF6D4(0x23); + switch (current_character_index[cc_player_index]) { + case 0: + case 2: + extra_player_info_pointer->unk4 *= D_8075CD20; + } + func_806CFE7C(); + func_806D3608(); + func_806CC8B8(); + break; + case 2: + func_806CC8B8(); + if (!func_806DF6D4(0x31) && current_actor_pointer->unkB8 < extra_player_info_pointer->unk4) { + func_806CFF9C(current_actor_pointer); + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D491C(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x26); + func_806CC8B8(); + break; + case 1: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + func_806D3FA0(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x25); + func_806CFD68(); + func_806CC8B8(); + break; + case 2: + func_806CC8B8(); + func_806DF6D4(0x25); + func_806CFD68(); + func_806D3608(); + break; + case 3: + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + func_806DF6D4(0x34); + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D4A70.s") + +/* +// TODO: It's using v0 instead of v1 for PaaD +void func_806D4A70(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + if (extra_player_info_pointer->unk3E) { + func_806CC14C(current_actor_pointer->unkEE, extra_player_info_pointer->unk40); + func_806CD424(extra_player_info_pointer->unk40, 50.0f, extra_player_info_pointer->unk38); + extra_player_info_pointer->unk3E--; + } + func_806CC8B8(); + if (current_actor_pointer->y_velocity <= -15.0f) { + current_actor_pointer->y_velocity = -15.0f; + current_actor_pointer->control_state_progress++; + } + func_806DF6D4(0x24); + if (current_actor_pointer->unk6A & 1) { + func_806F142C(current_actor_pointer); + } + break; + case 1: + func_806DF6D4(0x24); + if (extra_player_info_pointer->unk3E) { + func_806CC14C(current_actor_pointer->unkEE, extra_player_info_pointer->unk40); + func_806CD424(extra_player_info_pointer->unk40, 30.0f, extra_player_info_pointer->unk38); + extra_player_info_pointer->unk3E--; + } + func_806CC8F0(); + if (current_actor_pointer->unk6A & 1) { + func_806F142C(current_actor_pointer); + func_80608528(current_actor_pointer, 1, 0xFF, 0x7F, 0x1E); + } + break; + case 2: + current_actor_pointer->y_acceleration = -4.0f; + func_806DF6D4(0x24); + func_806CC8B8(); + if ((current_actor_pointer->unk6A & 1) != 0) { + func_806F142C(current_actor_pointer); + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D4C7C.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D4DE4.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D5008.s") + +extern f64 D_8075CD78; + +void func_806D5218(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk30 = extra_player_info_pointer->unk30 / D_8075CD78; + current_actor_pointer->control_state_progress++; + case 1: + func_806DF6D4(5); + func_806CC8B8(); + func_806DF494(¤t_actor_pointer->unkEE, current_actor_pointer->y_rotation, extra_player_info_pointer->unk48 * 1.25); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +extern f32 D_8075352C[]; + +extern f32 D_80750FC0; +extern s32 D_80750FC8; +extern s32 D_80750FCC; +extern s32 D_80750FD0; +extern u8 D_80750FD4; +extern f32 D_80750FD8; +extern f64 D_8075CD80; +extern void *D_8074E880[]; +extern s32 D_80750FC4; // TODO: Datatype +void func_80717D4C(void); // TODO: Proper signature, just needed right now for function pointer + +void func_806D5300(void) { + s32 pad; + f32 sp90, sp8C, sp88; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + s32 phi_s1; + + if ((current_actor_pointer->control_state_progress < 2) || (D_80750FD8 < current_actor_pointer->unkB8)) { + temp_f20 = current_actor_pointer->animation_state->scale_y / D_8075CD80; + func_80671C0C(current_actor_pointer, 7, &sp90, &sp8C, &sp88); + for (phi_s1 = 0; phi_s1 < D_80750FD4; phi_s1++) { + temp_f24 = (((rand() >> 0xF) % 10000) % D_80750FC8) - (D_80750FC8 / 2); + temp_f26 = (((rand() >> 0xF) % 10000) % D_80750FCC) - (D_80750FCC / 2); + temp_f22 = (((rand() >> 0xF) % 10000) % D_80750FD0) - (D_80750FD0 / 2); + func_80714950(D_80750FC4); + func_8071498C(&func_80717D4C); + func_807149B8(1); + func_80714CC0(D_8074E880[((rand() % 10000) % 3)], + D_80750FC0 * temp_f20, + (temp_f24 * temp_f20) + sp90, + (temp_f26 * temp_f20) + sp8C, + (temp_f22 * temp_f20) + sp88 + ); + } + } + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(5); + extra_player_info_pointer->unk4 = 0.0f; + break; + case 1: + func_806DF6D4(5); + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + if ((extra_player_info_pointer->unk1F4 & 8) == 0) { + current_actor_pointer->unkB8 = 140.0f; + } + extra_player_info_pointer->unk30 = 6.0f; + current_actor_pointer->control_state_progress++; + break; + case 2: + if (current_actor_pointer->unkFC != 0) { + if ((D_8075352C[D_807FD584] < current_actor_pointer->unkB8) && ((extra_player_info_pointer->unk1F4 & 8) == 0)) { + current_actor_pointer->unkB8 = D_8075352C[D_807FD584]; + extra_player_info_pointer->unk68 = D_8075352C[D_807FD584]; + } + } + func_806DF6D4(5); + break; + case 3: + current_actor_pointer->unkB8 = 0.0f; + func_806DF6D4(5); + func_806F142C(current_actor_pointer); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D57F0(void) { + func_806DF6D4(1); + extra_player_info_pointer->unk4 = 0.0f; + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D5834.s") + +extern f64 D_8075CD88; +extern s32 D_80767CC0; +extern f64 D_8075CD90; +extern s32 D_80767CC0; + +/* +// TODO: Stupidly close, regalloc v0 v1, temp variable for control state? +void func_806D5834(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk30 /= D_8075CD88; + current_actor_pointer->control_state_progress++; + extra_player_info_pointer->unk5C = D_80767CC0 - 0x64; + extra_player_info_pointer->unk48 = 0x50; + case 1: + func_806DF6D4(9); + extra_player_info_pointer->unk30 = 10.0f; + func_806CD8EC(); + func_806DF494(¤t_actor_pointer->unkEE, current_actor_pointer->y_rotation, extra_player_info_pointer->unk48 * 1.25); + break; + case 2: + if ((D_80767CC0 - extra_player_info_pointer->unk5C) < 0x32U) { + if (current_character_index[cc_player_index] == 2) { + current_actor_pointer->control_state = 0x27; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x40); + } else { + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x41); + } + } + break; + } + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D59E4(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk30 /= D_8075CD90; + current_actor_pointer->control_state_progress++; + extra_player_info_pointer->unk5C = D_80767CC0 - 0x64; + /* fallthrough */ + case 1: + func_806DF6D4(9); + extra_player_info_pointer->unk30 = 10.0f; + func_806CD8EC(); + func_806DF494(¤t_actor_pointer->unkEE, current_actor_pointer->y_rotation, extra_player_info_pointer->unk48 * 1.25); + break; + case 2: + if ((D_80767CC0 - extra_player_info_pointer->unk5C) < 0x32U) { + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x41); + } + break; + } + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +extern f64 D_8075CD98; + +void func_806D5B44(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk30 /= D_8075CD98; + if (current_character_index[cc_player_index] == 3) { + current_actor_pointer->unkB8 = 50.0f; + } + current_actor_pointer->control_state_progress++; + case 1: + func_806DF6D4(0xA); + func_806DF494(¤t_actor_pointer->unkEE, current_actor_pointer->y_rotation, extra_player_info_pointer->unk48 * 1.25); + break; + case 2: + func_806DF6D4(0xA); + extra_player_info_pointer->unk30 = 50.0f; + func_806CD8EC(); + func_806DF494(¤t_actor_pointer->unkEE, current_actor_pointer->y_rotation, extra_player_info_pointer->unk48 * 1.25); + break; + } + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D5CCC(void) { + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, extra_player_info_pointer->unk48); + func_806D3608(); + switch (current_character_index[cc_player_index]) { + case 1: + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806CFECC(); + func_806DF6D4(0x17); + func_806CC948(); + break; + case 1: + func_806CFECC(); + func_806DF6D4(0x16); + func_806CC948(); + break; + } + break; + case 0: + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk30 = 7.0f; + extra_player_info_pointer->unk2C = 8.0f; + extra_player_info_pointer->unk48 = 0x12C; + func_806DF6D4(0x15); + extra_player_info_pointer->unk4 = 0.0f; + func_806CC8B8(); + break; + case 1: + current_actor_pointer->unkB8 = D_807531FC[D_807FD584]; + extra_player_info_pointer->unk2C = 20.0f; + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + func_806DF6D4(0x15); + func_806CC948(); + break; + case 2: + current_actor_pointer->y_velocity = 150.0f; + extra_player_info_pointer->unk2C = 20.0f; + extra_player_info_pointer->unk38 = 200.0f; + func_806DF6D4(0x15); + extra_player_info_pointer->unk4 = 200.0f; + func_806CC8B8(); + current_actor_pointer->control_state_progress++; + break; + case 3: + current_actor_pointer->unkB8 = 200.0f; + extra_player_info_pointer->unk38 = 200.0f; + func_806DF6D4(0x15); + func_806CC948(); + break; + } + break; + default: + case 3: + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk28 = 0; + extra_player_info_pointer->unk30 = D_8075CDA0; + extra_player_info_pointer->unk2C = 8.0f; + extra_player_info_pointer->unk48 = 0x12C; + func_806DF6D4(0x15); + func_806CC948(); + break; + case 1: + extra_player_info_pointer->unk30 = 20.0f; + extra_player_info_pointer->unk2C = 20.0f; + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + func_806DF6D4(0x15); + func_806CC948(); + break; + case 2: + extra_player_info_pointer->unk28 = 1; + if ((D_80767CC0 - extra_player_info_pointer->unk5C) < 0x14U) { + current_actor_pointer->control_state = 0x26; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x3F); + } + func_806DF6D4(0x15); + func_806CC8B8(); + break; + } + break; + case 6: + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk28 = 0; + extra_player_info_pointer->unk2C = 20.0f; + extra_player_info_pointer->unk48 = 0x12C; + func_806DF6D4(0x15); + extra_player_info_pointer->unk30 = 10.0f; + func_806CD8EC(); + func_806CC948(); + break; + case 1: + extra_player_info_pointer->unk2C = 30.0f; + extra_player_info_pointer->unk68 = D_807531FC[D_807FD584]; + func_806CD424(current_actor_pointer->y_rotation, extra_player_info_pointer->unk68, extra_player_info_pointer->unk68); + func_806DF6D4(0x15); + func_806CC948(); + break; + case 2: + extra_player_info_pointer->unk28 = 1; + func_806DF6D4(0x15); + func_806CC8B8(); + break; + } + break; + } + func_806319C4(current_actor_pointer, 0); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D61B8.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D6558.s") + +extern f32 D_8075352C[]; + +s32 func_806D69A4(void) { + if (current_actor_pointer->unkFC != 0) { + if (func_806CC14C(current_actor_pointer->y_rotation, ((((current_actor_pointer->unkF6 - current_actor_pointer->unkF4) & 0xFFF) / 2) + current_actor_pointer->unkF4 + 0x800) & 0xFFF) < 0x2BC) { + if (current_actor_pointer->unkB8 > 150.0f) { + func_80614E78(current_actor_pointer, 0x49); + current_actor_pointer->unkEE = (current_actor_pointer->y_rotation + 0x800) % 4096; + current_actor_pointer->control_state_progress = 2; + current_actor_pointer->unkB8 = D_8075352C[D_807FD584]; + extra_player_info_pointer->unk68 = D_8075352C[D_807FD584]; + } else { + func_806CFF9C(current_actor_pointer); + } + return 1; + } + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, extra_player_info_pointer->unk48); + } + return 0; +} + +void func_806D6B00(void) { + func_806D3608(); + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk28 = 0; + func_806DF6D4(0x1A); // controlStateControl() + if (extra_player_info_pointer->unk68 < current_actor_pointer->unkB8) { + extra_player_info_pointer->unk68 = current_actor_pointer->unkB8; + } + if (func_806D69A4()) { + break; + } else { + func_806CBE90(); + if (current_actor_pointer->unkE0 != 0.0f) { + extra_player_info_pointer->unk30 = 20.0f; + func_806CD8EC(); + } else { + func_806CD424(current_actor_pointer->y_rotation, + extra_player_info_pointer->unk68, + extra_player_info_pointer->unk38); + } + func_806CC948(); + break; + } + case 1: + func_806DF6D4(0x1A); // controlStateControl() + if (func_806D69A4()) { + break; + } else { + func_806DF494(¤t_actor_pointer->y_rotation, + current_actor_pointer->unkEE, + extra_player_info_pointer->unk48); + func_806CBE90(); + func_806CD8EC(); + func_806CC948(); + extra_player_info_pointer->unk30 = D_80753548[D_807FD584]; + if (current_actor_pointer->unkB8 > 20.0f) { + if ((func_806119A0() % 3) == 0) { // RNG + func_8071498C(&D_8071B2EC); + func_80714998(2); + func_807149B8(1); + func_80714C08(&D_8071FF18, 0.2f, current_actor_pointer, 2, 0); + } + if ((func_806119A0() % 3) == 0) { // RNG + func_8071498C(&D_8071B2EC); + func_80714998(2); + func_807149B8(1); + func_80714C08(&D_8071FF18, 0.2f, current_actor_pointer, 3, 0); + } + if ((func_806119A0() % 3) == 0) { // RNG + func_8071498C(&D_8071B2EC); + func_80714998(2); + func_807149B8(1); + func_80714C08(&D_8071FF18, 0.2f, current_actor_pointer, 9, 0); + } + if ((func_806119A0() % 3) == 0) { // RNG + func_8071498C(&D_8071B2EC); + func_80714998(2); + func_807149B8(1); + func_80714C08(&D_8071FF18, 0.2f, current_actor_pointer, 0xA, 0); + } + } + break; + } + case 2: + func_806DF6D4(5); // controlStateControl() + current_actor_pointer->unkEE = (current_actor_pointer->y_rotation + 0x800) % 4096; + func_806CC8A8(); + func_806CBE90(); + func_806CC948(); + break; + case 3: + func_806DF6D4(5); // controlStateControl() + current_actor_pointer->unkEE = (current_actor_pointer->y_rotation + 0x800) % 4096; + extra_player_info_pointer->unk30 = 5.0f; + func_806CD8EC(); + func_806CC8A8(); + func_806CBE90(); + func_806CC948(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D6F0C(void) { + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, extra_player_info_pointer->unk48); + func_806DF6D4(8); // controlStateControl() + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D6F64.s") + +/* +// TODO: Annoying bit shift stuff with the function call inside case 0 +void func_806D6F64(void) { + func_806EB0C0(0x3C, NULL, cc_player_index); + current_actor_pointer->unk64 |= 0x200; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(3); + extra_player_info_pointer->unk4 = D_8075305C[D_807FD584]; + extra_player_info_pointer->unkA = current_actor_pointer->unkEE; + func_806DF494(¤t_actor_pointer->y_rotation, (current_actor_pointer->unkEE + 0x800) & 0xFFF, extra_player_info_pointer->unk48 & 0xFFF); + break; + case 1: + func_806DF6D4(3); + extra_player_info_pointer->unk4 = 0.0f; + current_actor_pointer->unkB8 = 0.0f; + break; + case 2: + func_806CFF9C(current_actor_pointer); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +s16 func_806CC190(s16, s16, f32); + +void func_806D7098(void) { + func_806DF6D4(3); + current_actor_pointer->unk64 |= 0x200; + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->y_rotation = func_806CC190(current_actor_pointer->y_rotation, extra_player_info_pointer->unkDC->y_rotation + 0x800, 8.0f); + extra_player_info_pointer->unk4 = 0.0f; + current_actor_pointer->unkB8 = 0.0f; + func_806CC8B8(); + break; + case 1: + func_806CFF9C(current_actor_pointer); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D7170(void) { + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806DF6D4(3); + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk4 = 0.0f; + current_actor_pointer->unkB8 = 0.0f; + func_806CC8B8(); + break; + case 1: + func_8068780C(1, 4, 5, 8); + break; + case 2: + func_806845B8(1, 8); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D7238(void) { + func_806EB0C0(0x5C, NULL, cc_player_index); + func_806DF6D4(3); + current_actor_pointer->noclip_byte = 1; + extra_player_info_pointer->unk4 = 0.0f; + current_actor_pointer->unkB8 = 0.0f; + func_806CC8B8(); + if (extra_player_info_pointer->unk21E == 0) { + func_80712830(current_actor_pointer, cc_player_index); + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D72D4.s") + +extern f32 D_807530F0[]; + +/* +// TODO: Minor conditional logic issues around the else blocks +void func_806D72D4(void) { + f32 temp_f0; + + func_806EB0C0(0x3C, NULL, cc_player_index); + current_actor_pointer->unk64 |= 0x200; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(3); + extra_player_info_pointer->unk4 = D_807530F0[D_807FD584]; + extra_player_info_pointer->unkA = current_actor_pointer->unkEE; + current_actor_pointer->y_rotation = func_806CC190(current_actor_pointer->y_rotation, extra_player_info_pointer->unkDC->y_rotation + 0x800, 8.0f); + func_806CC8B8(); + break; + case 1: + func_806DF6D4(3); + extra_player_info_pointer->unk4 = 0.0f; + if (current_character_index[cc_player_index] == 4) { + temp_f0 = current_actor_pointer->animation_state->unk0->unk4; + if ((temp_f0 >= 29.0f) && (temp_f0 < 33.0f)) { + current_actor_pointer->unkEE = (current_actor_pointer->y_rotation + 0x800) & 0xFFF; + current_actor_pointer->unkB8 = 150.0f; + func_806CC948(); + } else if (temp_f0 >= 48.0f) { + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + current_actor_pointer->unkB8 = 60.0f; + func_806CC948(); + } else { + current_actor_pointer->unkB8 = 0.0f; + func_806CC8B8(); + } + } else { + current_actor_pointer->unkB8 = 0.0f; + func_806CC8B8(); + } + break; + case 2: + current_actor_pointer->unkB8 = 0.0f; + func_806CFF9C(current_actor_pointer); + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D7510.s") + +/* +extern s16 D_807538C8[]; + +// TODO: Annoying bit shift stuff with the function call inside case 0 +void func_806D7510(void) { + f32 temp_f0; + f32 temp_f2; + u8 temp_v1; + + current_actor_pointer->unk64 |= 0x200; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806DF6D4(4); + func_806DF494(¤t_actor_pointer->y_rotation, (current_actor_pointer->unkEE + 0x800) & 0xFFF, (extra_player_info_pointer->unk48 << 0x11) >> 0x10); + if (current_actor_pointer->unkFC != 0) { + current_actor_pointer->unkB8 = current_actor_pointer->unkB8 * 0.5; + } + break; + case 1: + func_806EB0C0(0x3C, NULL, cc_player_index); + extra_player_info_pointer->unk4 = 0.0f; + if (current_actor_pointer->unkFC != 0) { + current_actor_pointer->unkB8 = current_actor_pointer->unkB8 * 0.5; + } + break; + case 2: + current_actor_pointer->unkB8 = 0.0f; + func_806EB0C0(0x18, NULL, cc_player_index); + break; + } + temp_f0 = current_actor_pointer->unkAC; + temp_f2 = D_807538C8[D_807FD584]; + if (temp_f0 < (temp_f2 + current_actor_pointer->y_position)) { + current_actor_pointer->y_position = temp_f0 - temp_f2; + } + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unk30 = 2.0f; + func_806CC8F0(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D7704.s") + +/* +// TODO: Annoying bit shift stuff with the function call inside case 0 +void func_806D7704(void) { + func_806EB0C0(0x3C, NULL, cc_player_index); + current_actor_pointer->unk64 |= 0x200; + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->unkB8 = D_80753144[D_807FD584]; + func_806DF6D4(5); + extra_player_info_pointer->unk4 = D_80753144[D_807FD584]; + if (extra_player_info_pointer->unk1A3 != 0) { + func_80605314(current_actor_pointer, 0); + extra_player_info_pointer->unk1A3 = 0; + } + extra_player_info_pointer->unkA = current_actor_pointer->unkEE; + // TODO: Mismatch is here + func_806DF494(¤t_actor_pointer->y_rotation, + (current_actor_pointer->unkEE + 0x800) & 0xFFF, + (extra_player_info_pointer->unk48 << 0x11) >> 0x10); + break; + case 1: + func_806DF6D4(3); + current_actor_pointer->unkB8 = 0.0f; + break; + case 2: + func_806DF6D4(3); + func_806CFF9C(current_actor_pointer); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D7878(void) { + f64 temp_f0 = current_actor_pointer->animation_state->scale_y; + func_807248B0(current_actor_pointer, ((D_8075CDE0 - temp_f0) * D_8075CDE8) + temp_f0); + current_actor_pointer->shadow_opacity -= 0x14; + if (current_actor_pointer->shadow_opacity < 0) { + current_actor_pointer->shadow_opacity = 0; + } + func_806EB0C0(0x3C, NULL, cc_player_index); + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806CC8B8(); + break; + case 1: + func_806CC8B8(); + if (extra_player_info_pointer->unk11C-- == 0) { + current_actor_pointer->control_state_progress++; + } + break; + case 2: + if ((current_map != MAP_CAVES_BEETLE_RACE) && (current_map != MAP_AZTEC_BEETLE_RACE)) { + func_80712830(current_actor_pointer, cc_player_index); + } + current_actor_pointer->control_state_progress++; + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D79E4(void) { + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D7A28.s") + +extern f32 D_80753094[]; +extern f32 D_80753024[]; + +/* +// TODO: Annoying bit shift stuff with the angles +void func_806D7A28(void) { + s32 temp_v0; + + func_806EB0C0(0x3C, NULL, cc_player_index); + func_806DF6D4(1); + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->y_acceleration = D_80753024[D_807FD584]; + if (D_807FBB68 & 2) { + playSound(0x424, 0x7FFF, 63.0f, 1.0f, 0, 0); + } + if (cc_number_of_players == 1) { + func_80627948(player_pointer, 0xC, 0x25, 0x85); + } + current_actor_pointer->control_state_progress++; + case 1: + extra_player_info_pointer->unk4 = D_80753094[D_807FD584]; + extra_player_info_pointer->unkA = current_actor_pointer->unkEE; + func_806DF494(¤t_actor_pointer->y_rotation, (current_actor_pointer->unkEE + 0x800) & 0xFFF, (extra_player_info_pointer->unk48 << 0x11) >> 0x10); + func_806CC8B8(); + extra_player_info_pointer->unk11C = 0xF; + extra_player_info_pointer->unk11D = 0; + break; + case 2: + current_actor_pointer->control_state_progress++; + current_actor_pointer->unkB8 = 0.0f; + func_806CC970(); + break; + case 3: + temp_v0 = func_80714608(0); + if ((extra_player_info_pointer->unk11C == 0) && (extra_player_info_pointer->unk11D == 0)) { + if ((temp_v0) == 0) { + func_806CF918(extra_player_info_pointer->unk11C, temp_v0); + } + extra_player_info_pointer->unk11D = 1; + } else { + extra_player_info_pointer->unk11C--; + } + if (extra_player_info_pointer->unk11D != 0) { + if (extra_player_info_pointer->unk11C >= 0xBF) { + if ((temp_v0 == 0) && ((extra_player_info_pointer->unk11C % 3) == 0)) { + func_80608528(current_actor_pointer, ((extra_player_info_pointer->unk11C & 2) / 2) + 0x57, 0xFF, 0x7F, 0x1E); + } + } else if (temp_v0 != 0) { + func_80712830(current_actor_pointer, cc_player_index); + } + } + if (((extra_player_info_pointer->unk1F0 & 0x1000) != 0) && ((object_timer & 3) == 0)) { + func_807149C8(0x64, 0x64, 0x64, 0xC8); + func_80714998(2); + func_8068588C(current_actor_pointer, (((rand() >> 0xF) % 32767) % 8) + 1, 0x3ECCCCCD, 0.0f, 0.0f, 0.0f, -0x50); + } + current_actor_pointer->unkB8 = 0.0f; + func_806CC970(); + break; + default: + if (cc_number_of_players >= 2) { + func_80712830(current_actor_pointer, cc_player_index); + } + extra_player_info_pointer->unk1F0 &= -0x1001; + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D7DF8(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x45); + extra_player_info_pointer->unk4 = 0.0f; + break; + case 1: + func_806DF6D4(0x44); + extra_player_info_pointer->unk4 = 0.0f; + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D7E88(void) { + s16 temp_v0; + + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x46); + extra_player_info_pointer->unk4 = 0.0f; + break; + case 1: + if (func_806DF6D4(0x46) == 0) { + temp_v0 = func_806CE4E4(current_actor_pointer, current_actor_pointer->unkB8, extra_player_info_pointer->unk4, 1); + if (temp_v0 != 0x3F) { + current_actor_pointer->control_state = temp_v0; + current_actor_pointer->control_state_progress = 0; + } + } + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D7F48(void) { + s16 temp_v0; + + func_806CBE90(); + if (!func_806DF6D4(0x46)) { + temp_v0 = func_806CE4E4(current_actor_pointer, + current_actor_pointer->unkB8, + extra_player_info_pointer->unk4, + 1); + + if (temp_v0 != 0x40) { + current_actor_pointer->control_state = temp_v0; + current_actor_pointer->control_state_progress = 0; + if (temp_v0 == 0x3F) { + current_actor_pointer->control_state_progress = 1; + } + } + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D7FE8(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(1); + break; + case 1: + current_actor_pointer->control_state = 0x3C; + current_actor_pointer->control_state_progress = 1; + func_80614E78(current_actor_pointer, 0xB); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D8070(void) { + func_806DF6D4(1); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D80A8(void) { + switch (current_actor_pointer->control_state_progress) { + case 0: + func_80614D00(current_actor_pointer, 1.0f, 0.0f); + func_806DF6D4(0x47); + func_806CC948(); + func_806CD8EC(); + extra_player_info_pointer->unk2C = D_80753470[D_807FD584]; + extra_player_info_pointer->unk30 = D_8075348C[D_807FD584]; + extra_player_info_pointer->unk38 = D_80753454[D_807FD584]; + extra_player_info_pointer->unk48 = D_807534A8[D_807FD584]; + break; + case 1: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + current_actor_pointer->y_acceleration = D_80753738[D_807FD584]; + current_actor_pointer->unkB8 = 0.0f; + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x47); + func_806CFE30(); + func_806CC948(); + break; + case 2: + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, 0x32); + func_806CFE30(); + func_806D3608(); + func_806CC8B8(); + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, 0x32); + func_806DF6D4(0x47); + break; + case 3: + func_806DF6D4(0x35); + if (D_807FD610[cc_player_index].unk8 != 0.0f) { + func_80614D00(current_actor_pointer, 3.0f, 0.0f); + } + extra_player_info_pointer->unk4 = 0.0f; + func_806CFE7C(); + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D8308.s") + +void func_80613AF8(Actor*, s32, f32, f32); + +int func_806D850C(void) { + f32 sp2C; + f32 phi_f2; + + if (character_change_array[cc_player_index].unk2C0 == 1) { + sp2C = D_8075388C[D_807FD584]; + } else { + sp2C = D_807538C8[D_807FD584]; + } + if ((current_actor_pointer->control_state == 0x4E) && playerCanDive()) { + if ((current_actor_pointer->control_state_progress != 0) && ((current_actor_pointer->y_position + sp2C) < (current_actor_pointer->unkAC - 10.0f))) { + extra_player_info_pointer->unk12 = D_807539EC[D_807FD584]; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk10 = D_807539DC[D_807FD584] * 0.5; + current_actor_pointer->control_state = 0x4F; + current_actor_pointer->control_state_progress = 1; + if (current_actor_pointer->y_velocity > 0.0f) { + current_actor_pointer->y_velocity = 0.0f; + } + func_80614E78(current_actor_pointer, 0x36); + func_80613AF8(current_actor_pointer, 0x31, 0.0f, 8.0f); + func_80614D00(current_actor_pointer, 0.5f, 0.0f); + func_80608528(current_actor_pointer, 0x10, 0xFF, 0x7F, 1); + } + } + if (current_actor_pointer->unkAC < (current_actor_pointer->y_position + sp2C)) { + current_actor_pointer->y_position = current_actor_pointer->unkAC - sp2C; + } + phi_f2 = character_change_array[cc_player_index].unk2C0 == 1 ? D_8075387C[D_807FD584] : D_807538B8[D_807FD584]; + if ((current_actor_pointer->unkAC - current_actor_pointer->floor) < phi_f2) { + func_806EB0C0(2, NULL, cc_player_index); + return TRUE; + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D87FC.s") + +extern f32 D_807539A4[]; +extern f64 D_8075CE08; +extern f32 D_8075CE10; +extern f32 D_80753988[]; +extern s16 D_80753B34[]; + +/* +// TODO: Very close, something iffy with the order of loading floats from those arrays +void func_806D87FC(void) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp; + f32 phi_f2; + + phi_f2 = D_807539A4[D_807FD584]; + temp = D_80753988[D_807FD584]; + if (current_actor_pointer->y_velocity < 0.0f) { + if (!((-current_actor_pointer->y_velocity / 3.0f) < D_807539A4[D_807FD584])) { + phi_f2 = -current_actor_pointer->y_velocity / 3.0f; + } + } + if ((current_actor_pointer->distance_from_floor == 0.0f) && (current_actor_pointer->y_velocity < D_8075CE08)) { + current_actor_pointer->y_velocity = D_8075CE10; + } + current_actor_pointer->y_velocity = func_806CD898(current_actor_pointer->y_velocity, temp, phi_f2); + extra_player_info_pointer->unk24 = 0; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806DF6D4(0x4E); + func_806CC8F0(); + break; + case 1: + func_806DF6D4(0x4D); + func_806CC8F0(); + if (current_actor_pointer->unkB8 != 0.0f) { + func_80614E78(current_actor_pointer, 0x3A); + current_actor_pointer->control_state_progress = 2; + } + break; + default: + func_806DF6D4(0x4D); + func_806CC8F0(); + if (current_actor_pointer->unkB8 == 0.0f) { + func_80614E78(current_actor_pointer, 0x33); + current_actor_pointer->control_state_progress = 1; + } else { + temp_f0_2 = (extra_player_info_pointer->unk4 * 1.5) / 40.0; + if (current_actor_pointer->animation_state->unk48 < temp_f0_2) { + func_80614D00(current_actor_pointer, temp_f0_2, 0.0f); + } else { + func_80614D00(current_actor_pointer, temp_f0_2, 5.0f); + } + } + break; + } + func_806D850C(); + current_actor_pointer->object_properties_bitfield &= -2; + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D8A64(void) { + extra_player_info_pointer->unk24 = 0; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_80614D00(current_actor_pointer, 1.0f, 0.0f); + func_806DF6D4(0x4B); + func_806CC8B8(); + break; + case 1: + current_actor_pointer->z_rotation = 0; + current_actor_pointer->x_rotation = 0; + func_806CFF9C(current_actor_pointer); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D8B08.s") + +void func_806D8FCC(void) { + extra_player_info_pointer->unk24 = 0; + current_actor_pointer->x_rotation = 0; + current_actor_pointer->z_rotation = 0; + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806D3FA0(); + func_806DF6D4(0x21); + func_806CC8F0(); + break; + case 1: + func_806CC8B8(); + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x21); + func_806CFD68(); + break; + case 2: + func_806CC8B8(); + func_806DF6D4(0x21); + if (current_actor_pointer->unk58 == 5) { + func_806DF6D4(0x22); + } else { + func_806DF6D4(0x21); + } + func_806CFD68(); + break; + case 3: + func_806CC8B8(); + func_806DF6D4(0x30); + func_806CFE7C(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +void func_806D9134(void) { + func_806DF6D4(1); + current_actor_pointer->unkB8 = 0.0f; + current_actor_pointer->y_velocity = 0.0f; + func_806CC970(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806D9184(void) { + func_806D9134(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D91A4.s") + +/* +// TODO: Close, doable, probably needs an assist from ghidra and/or proper bitfield syntax +extern s32 D_8072014C; + +void func_807149B8(s32); +void func_807149FC(s32); +void func_806224CC(s32); + +void func_806D91A4(void) { + s32 phi_a2; + + if (current_actor_pointer->unkFC) { + current_actor_pointer->unkB8 = 0.0f; + func_806CFF1C(current_actor_pointer); + } + if ((current_actor_pointer->unkFC != 0) || (current_actor_pointer->unk6A & 1 && (current_actor_pointer->unk6C & 1) == 0)) { + func_806224CC(extra_player_info_pointer->unk104); + } + if ((current_actor_pointer->unk6A & 1) == 0) { + func_807149B8(1); + func_807149FC(1); + func_80714C08(&D_8072014C, 0.8f, current_actor_pointer, 1, 0); + } + phi_a2 = 1; + if (current_actor_pointer->unk6A & current_actor_pointer->unk6C & 1) { + phi_a2 = 2; + } + if (((current_actor_pointer->unk6C == 0) & current_actor_pointer->unk6A & 1)) { + current_actor_pointer->unkB8 *= 0.25; + } + if (current_actor_pointer->unkB8 < phi_a2) { + current_actor_pointer->unkB8 = 0.0f; + } else { + current_actor_pointer->unkB8 -= phi_a2; + } + func_806DF6D4(1); + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D9320.s") + +void func_806D97A4(void) { + func_806DF6D4(5); + if (current_actor_pointer->y_velocity < 0.0f) { + extra_player_info_pointer->unk6C = 0.0f; + } + func_806CD424(extra_player_info_pointer->unk70, + extra_player_info_pointer->unk6C, + extra_player_info_pointer->unk38); + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D9820.s") + +/* +// TODO: Close, that comparison with 1.875 is sus +void func_806D9820(void) { + f32 temp_f0; + + func_806DF6D4(0x4A); + switch (current_actor_pointer->control_state_progress) { + case 0: + if (extra_player_info_pointer->unk38 < current_actor_pointer->unkB8) { + func_806CD8EC(); + func_806CC948(); + } else { + func_806CC8B8(); + } + // TODO: Problem is here + // Missing cvt.s.d and cvt.d.s after the mul.d instruction + // Typecasts? + temp_f0 = MAX(current_actor_pointer->unkB8 * D_8075CE68, (s32)1.875); + func_80614D00(current_actor_pointer, temp_f0, 0.0f); + break; + case 1: + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806D9924(Actor *actor) { + actor->z_rotation = 0; + actor->x_rotation = 0; + actor->object_properties_bitfield &= ~1; +} + +void func_806D9940(void) { + s32 song; + f32 phi_f0; + + func_806DF6D4(1); + if ((current_actor_pointer->control_state_progress < 3) + || (func_8061CB80() + && (func_8061CB98(7) + || func_8061CB98(0) + || func_8061CB98(4) + || func_8061CB98(9) + || func_8061CB98(8)))) { + func_80653B70(1); + } + switch (current_actor_pointer->control_state_progress) { + case 0: + if ((D_807FBB68 & 2) == 0) { + current_actor_pointer->noclip_byte = 1; + } + break; + case 1: + song = 0xA; + phi_f0 = 1.0f; + switch (current_actor_pointer->unk58) { + case 2: + song = 0xB; + break; + case 5: + song = 0xD; + break; + case 4: + song = 0xC; + if (!(D_807FBB68 & 2)) { + phi_f0 = D_8075CE70; + } + break; + case 6: + song = 9; + break; + } + playSong(song, phi_f0); + current_actor_pointer->control_state_progress++; + break; + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D9AD4.s") + +extern s32 D_8071FC8C; +extern s32 D_80717100; +extern f64 D_8075CE78; + +/* +// TODO: Close, doable +void func_806D9AD4(void) { + f32 sp28; + + func_806DF6D4(1); + if ((current_actor_pointer->control_state_progress == 1) || (current_actor_pointer->control_state_progress == 2)) { + rand(); + sp28 = ((rand() >> 0xF) % 30) + current_actor_pointer->y_position; + rand(); + func_807149B8(1); + // TODO: Problem seems to be here + func_80714950((extra_player_info_pointer->unk23C << 0x10) + (15.0 * (current_actor_pointer->shadow_opacity / D_8075CE78))); + func_8071498C(&D_80717100); + func_80714CC0(&D_8071FC8C, 0.5f, current_actor_pointer->x_position, sp28, current_actor_pointer->z_position); + } + switch (current_actor_pointer->control_state_progress) { + case 0: + extra_player_info_pointer->unk23C = 0; + current_actor_pointer->control_state_progress++; + current_actor_pointer->object_properties_bitfield &= 0xFFFF7FFF; + current_actor_pointer->shadow_opacity = 0xFF; + break; + case 1: + extra_player_info_pointer->unk23C += 0x1E; + if (extra_player_info_pointer->unk23C >= 0x191) { + extra_player_info_pointer->unk23C = 0x190; + } + if (extra_player_info_pointer->unk23C == 0xD2) { + func_80608528(current_actor_pointer, 0x264, 0xFF, 0x64, 0x19); + } + if (extra_player_info_pointer->unk23C >= 0x12D) { + extra_player_info_pointer->unk1F0 &= -0x41; + current_actor_pointer->shadow_opacity += -5; + if (current_actor_pointer->shadow_opacity < 0xA) { + current_actor_pointer->control_state_progress++; + } + } + break; + case 2: + func_805FF9AC(extra_player_info_pointer->unk242, 0, 0, 3); + current_actor_pointer->control_state_progress++; + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D9D58.s") + +extern f32 D_8075CE88; +extern f64 D_8075CE80; + +/* +// TODO: Float regalloc +void func_806D9D58(void) { + f32 phi_f0; + + switch (current_actor_pointer->control_state_progress) { + case 0: + current_actor_pointer->y_velocity = 0.0f; + current_actor_pointer->unkB8 = 0.0f; + extra_player_info_pointer->unk30 = 1.0f; + extra_player_info_pointer->unk2C = 3.0f; + current_actor_pointer->y_acceleration = 2.0f; + extra_player_info_pointer->unk23C = 0; + extra_player_info_pointer->unk238 = current_actor_pointer->y_position; + current_actor_pointer->control_state_progress++; + break; + case 1: + func_806DF6D4(0x43); + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, 0x32); + current_actor_pointer->y_position = extra_player_info_pointer->unk238; + func_806CC8B8(); + if ((extra_player_info_pointer->unk238 - current_actor_pointer->unk168) > 50.0f) { + current_actor_pointer->y_position -= 1.0; + } + extra_player_info_pointer->unk238 = current_actor_pointer->y_position; + current_actor_pointer->y_position = (func_80612794(extra_player_info_pointer->unk23C) * 10.0) + extra_player_info_pointer->unk238; + extra_player_info_pointer->unk23C += 0x64; + phi_f0 = current_actor_pointer->unk168 < current_actor_pointer->y_position ? current_actor_pointer->y_position - current_actor_pointer->unk168 : -(current_actor_pointer->y_position - current_actor_pointer->unk168); + if (phi_f0 < D_8075CE80) { + current_actor_pointer->y_acceleration = 2.0 * ((current_actor_pointer->unk168 - current_actor_pointer->y_position) / D_8075CE80); + } + if (current_actor_pointer->unk168 <= current_actor_pointer->y_position) { + current_actor_pointer->y_velocity = 0.0f; + current_actor_pointer->y_acceleration = D_8075CE88; + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806D9FD0.s") + +extern f32 D_807FBC58; + +void func_806DA320(void) { + f32 phi_f2; + + if (D_807FBC58 != 0.0) { + phi_f2 = D_807FBC58; + } else { + phi_f2 = current_actor_pointer->unkB8; + } + func_80614D00(current_actor_pointer, (phi_f2 / 25.0f) + 0.25, 2.0f); + func_806DF6D4(0x49); + if ((current_actor_pointer->unk6A & 0x10) == 0) { + func_806CFF9C(current_actor_pointer); + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DA3E4.s") + +extern f64 D_8075CEB8; + +s16 func_80665DE0(f32, f32, f32, f32); + +/* +// TODO: Float regalloc +void func_806DA3E4(void) { + f64 temp_f16; + + func_806CA2AC(); + func_806DF6D4(5); + temp_f16 = D_8075CEB8; + current_actor_pointer->unkB8 = 0.0f; + current_actor_pointer->x_position = ((extra_player_info_pointer->unk22C - current_actor_pointer->x_position) * temp_f16) + current_actor_pointer->x_position; + current_actor_pointer->z_position = ((extra_player_info_pointer->unk234 - current_actor_pointer->z_position) * temp_f16) + current_actor_pointer->z_position; + func_806DF494(¤t_actor_pointer->y_rotation, func_80665DE0(extra_player_info_pointer->unk220, extra_player_info_pointer->unk228, current_actor_pointer->x_position, current_actor_pointer->z_position), 0x32); + func_806CC970(); + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DA4D8.s") + +void func_806DA7EC(void) { + func_806DF6D4(6); + if (D_807FD610[cc_player_index].unk8 != 0.0f) { + func_80614D00(current_actor_pointer, 3.0f, 0); + } + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, extra_player_info_pointer->unk48); + extra_player_info_pointer->unk4 = 0.0f; + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DA89C(void) { + func_806DF6D4(7); + if (D_807FD610[cc_player_index].unk8 != 0.0f) { + func_80614D00(current_actor_pointer, 2.0f, 0); + } + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, extra_player_info_pointer->unk48); + extra_player_info_pointer->unk4 = 0.0f; + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DA94C(void) { + extra_player_info_pointer->unk1F0 &= ~0x1000000; + func_806CEE64(1.0f); + func_806CF0D0(); + func_806CEED8(); + current_actor_pointer->control_state = func_806CE928(current_actor_pointer, + current_actor_pointer->unkB8, + extra_player_info_pointer->unk4, + 1); + current_actor_pointer->control_state_progress = 0; + func_806DF6D4(0x37); + if (!(current_actor_pointer->unk6A & 1)) { + func_806D3608(); + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DAA14(void) { + extra_player_info_pointer->unk1F0 &= ~0x1000000; + func_806CEE64(1.0f); + func_806CF0D0(); + func_806CEED8(); + current_actor_pointer->control_state = func_806CE928(current_actor_pointer, + current_actor_pointer->unkB8, + extra_player_info_pointer->unk4, + 1); + current_actor_pointer->control_state_progress = 0; + func_806DF6D4(0x37); + if ((current_actor_pointer->unk6A & 1) == 0) { + func_806D3608(); + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DAADC(void) { + extra_player_info_pointer->unk1F0 &= ~0x1000000; + func_806DF6D4(0x3A); + func_806CEED8(); + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806CEE64(0.5f); + break; + case 1: + func_806CEE64(0.5f); + if (extra_player_info_pointer->unk1AC != 0) { + func_80679200(extra_player_info_pointer->unk1AC, current_actor_pointer, 0x2000, 0, 0, 0); + } + extra_player_info_pointer->unk1AC = NULL; + extra_player_info_pointer->unk1B0 = 0; + current_actor_pointer->control_state_progress += 1; + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DABE4(void) { + extra_player_info_pointer->unk1F0 &= ~0x1000000; + func_806DF6D4(1); + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806CEE64(1.0f); + current_actor_pointer->unkB8 = 0.0f; + break; + case 1: + func_8067A784(current_actor_pointer, extra_player_info_pointer->unk1AC, D_807FBB48->y_rotation, D_807533B8[D_807FD584], D_8075339C[D_807FD584]); + extra_player_info_pointer->unk1AC = NULL; + extra_player_info_pointer->unk1B0 = 0; + current_actor_pointer->control_state_progress++; + current_actor_pointer->unkB8 = D_80753364[D_807FD584]; + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + break; + default: + if (current_actor_pointer->unkB8 != 0.0f) { + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + current_actor_pointer->unkB8 -= D_80753380[D_807FD584]; + if (current_actor_pointer->unkB8 < 0.0f) { + current_actor_pointer->unkB8 = 0.0f; + } + } + break; + } + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DADA0(void) { + extra_player_info_pointer->unk1F0 &= ~0x1000000; + func_806DF6D4(1); + switch (current_actor_pointer->control_state_progress) { + case 0: + func_806CEE64(1.0f); + current_actor_pointer->unkB8 = 0.0f; + break; + case 1: + func_8067A784(current_actor_pointer, extra_player_info_pointer->unk1AC, D_807FBB48->y_rotation, D_807533F0[D_807FD584], D_807533D4[D_807FD584]); + extra_player_info_pointer->unk1AC = NULL; + extra_player_info_pointer->unk1B0 = 0; + current_actor_pointer->control_state_progress++; + current_actor_pointer->unkB8 = D_80753364[D_807FD584]; + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + break; + default: + if (current_actor_pointer->unkB8 != 0.0f) { + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + current_actor_pointer->unkB8 -= D_80753380[D_807FD584]; + if (current_actor_pointer->unkB8 < 0.0f) { + current_actor_pointer->unkB8 = 0.0f; + } + } + break; + } + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DAF5C(void) { + extra_player_info_pointer->unk1F0 &= ~0x1000000; + func_806CEE64(1.0f); + func_806CEED8(); + switch (current_actor_pointer->control_state_progress) { + case 0: + func_80614D00(current_actor_pointer, 1.0f, 0); + func_806DF6D4(0x21); + break; + case 1: + current_actor_pointer->y_velocity = extra_player_info_pointer->unk54; + func_806CFECC(); + func_806D3FA0(); + current_actor_pointer->control_state_progress++; + func_806DF6D4(0x21); + func_806CFD68(); + break; + case 2: + func_806D3608(); + func_806DF6D4(0x39); + func_806CFD68(); + break; + case 3: + func_806DF6D4(0x38); + func_806CFE7C(); + break; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DB08C(void) { + func_806DF6D4(0x12); + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DB0C4.s") + +extern f64 D_8075CEF8; +extern f32 D_8075CF00; +extern f64 D_8075CF08; +extern f32 D_8075CF10; + +/* +// TODO: PaaD->unkAC conflicts with existing matched function datatype for it +// Maybe extra_player_info_pointer is a union? Or maybe unkAC is a union? Very sus +void func_806DB0C4(void) { + Actor *temp_v1; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f12; + f32 temp_f14; + f32 temp_f20; + f32 temp_f2; + f32 phi_f12; + + if (D_807FBB70[0].unkE4 != 0) { + extra_player_info_pointer->unkDC = D_807FBB70[0].unkEC; + extra_player_info_pointer->unk9C = current_actor_pointer->x_position; + extra_player_info_pointer->unkA0 = current_actor_pointer->z_position; + extra_player_info_pointer->unkA4 = D_807FBB70[0].unkD8; + extra_player_info_pointer->unkA8 = D_807FBB70[0].unkE0; + extra_player_info_pointer->unkAC = 0.0f; + temp_f20 = extra_player_info_pointer->unkA4 - extra_player_info_pointer->unk9C; + temp_f14 = extra_player_info_pointer->unkA8 - extra_player_info_pointer->unkA0; + extra_player_info_pointer->unk94 = sqrtf((temp_f20 * temp_f20) + (temp_f14 * temp_f14)) * D_8075CEF8; + extra_player_info_pointer->unk98 = ((func_80611BB4(temp_f20, temp_f14) * 4096.0f) / D_8075CF00); + extra_player_info_pointer->unk4C = -1; + } + extra_player_info_pointer->unkAC += D_8075CF08; + temp_f12 = extra_player_info_pointer->unkAC; + phi_f12 = temp_f12; + if (temp_f12 > 1.0) { + temp_v1 = extra_player_info_pointer->unkDC; + if (temp_v1 != 0) { + extra_player_info_pointer->unk98 = (func_80611BB4(temp_v1->x_position - extra_player_info_pointer->unk9C, temp_v1->z_position - extra_player_info_pointer->unkA0) * 4096.0f) / D_8075CF10; + if (current_actor_pointer->y_rotation == extra_player_info_pointer->unk98) { + func_806CFF9C(current_actor_pointer); + } + } + extra_player_info_pointer->unkAC = 1.0f; + phi_f12 = extra_player_info_pointer->unkAC; + } + temp_f0 = extra_player_info_pointer->unk9C; + current_actor_pointer->x_position = temp_f0 + ((extra_player_info_pointer->unkA4 - temp_f0) * phi_f12); + temp_f2 = extra_player_info_pointer->unkA0; + current_actor_pointer->z_position = temp_f2 + ((extra_player_info_pointer->unkA8 - temp_f2) * extra_player_info_pointer->unkAC); + func_806CC970(); + temp_f0_2 = extra_player_info_pointer->unk94; + func_806CDD24(current_actor_pointer, temp_f0_2, temp_f0_2, 0); + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unk98, D_8075326C[D_807FD584] / 2); + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DB3AC.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DB670.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DBB04.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DC170.s") + +void func_806DC3A4(f32 arg0) { + f32 temp_f2; + f32 phi_f0; + + phi_f0 = extra_player_info_pointer->unk94; + temp_f2 = extra_player_info_pointer->unk4; + if (phi_f0 < temp_f2) { + phi_f0 = phi_f0 + arg0; + phi_f0 = MIN(temp_f2, phi_f0); + } else if (temp_f2 < phi_f0) { + phi_f0 = phi_f0 - arg0; + phi_f0 = MAX(temp_f2, phi_f0); + } + extra_player_info_pointer->unk94 = phi_f0; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DC410.s") + +// Surprisingly doable, just need the energy +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DCA7C.s") + +// Looks doable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DCF60.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DD24C.s") + +void func_806DD874(void) { + current_actor_pointer->unkFA = 0x12C; + func_806CC8A8(); + switch (current_actor_pointer->control_state_progress) { + case 1: + current_actor_pointer->unkEE = (current_actor_pointer->y_rotation + 0x800) & 0xFFF; + current_actor_pointer->y_velocity = D_80753CB4[D_807FD584]; + current_actor_pointer->unkB8 = 100.0f; + func_806CFECC(); + current_actor_pointer->control_state_progress++; + extra_player_info_pointer->unk3C = 3; + func_806DF6D4(0x29); + extra_player_info_pointer->unk2C = 30.0f; + extra_player_info_pointer->unk48 = 0x64; + func_806CFD68(); + extra_player_info_pointer->unk30 /= 2; + func_806CC948(); + break; + case 2: + if (current_actor_pointer->unk58 == 5) { + func_806DF6D4(0x2A); + } else { + func_806DF6D4(0x29); + } + extra_player_info_pointer->unk38 = 150.0f; + func_806D3608(); + func_806CFD68(); + if (D_807FD610[cc_player_index].unk8 != 0.0f) { + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, extra_player_info_pointer->unk48); + } + if (extra_player_info_pointer->unk3C != 0) { + func_806CC948(); + extra_player_info_pointer->unk3C += -1; + } else { + func_806CC8B8(); + } + break; + case 3: + func_806DF6D4(0x30); + func_806CFE7C(); + func_806CC8B8(); + break; + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DDAB0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DE264.s") + +void func_806DE930(void) { + extra_player_info_pointer->unk4 = 0.0f; + if (!func_806DF6D4(1)) { + if (current_actor_pointer->unk6A & 1) { + func_806CDD24(current_actor_pointer, current_actor_pointer->unkB8, 0.0f, 1); + } + } + if (current_map == MAP_CAVES_BEETLE_RACE) { + extra_player_info_pointer->unk30 = D_80753250[D_807FD584] * 5.0; + } + func_806CC8B8(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DE9F4(void) { + if (current_actor_pointer->control_state_progress == 0) { + func_8061C464(extra_player_info_pointer->unk104, current_actor_pointer, 4, 0x800, 0x32, 0, 5, 0x32, 0x14, 0, D_8075D080); + current_actor_pointer->control_state_progress += 1; + } + func_806D38AC(1); + extra_player_info_pointer->unk30 = D_80750FDC; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DEAA4.s") + +void func_806DECD4(void) { + if (current_actor_pointer->control_state_progress == 1) { + func_8061CB08(); + current_actor_pointer->control_state_progress++; + func_806CFF9C(current_actor_pointer); + } + func_806319C4(current_actor_pointer, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DED44.s") + +extern s32 D_80750FE0; +extern s32 D_80750FF0; + +void func_80659670(f32, f32, f32, u16); + +typedef struct BoulderAAD { + u32 unk0; + u32 unk4; + u32 unk8; + u32 unkC; + Actor *unk10; + u16 unk14; + u16 unk16; + u16 unk18; + u16 unk1A; + u16 unk1C; + s8 unk1E; +} BoulderAAD; + +void func_806D9924(Actor*); + +/* +// TODO: Surprisingly close +void func_806DED44(void) { + u16 temp_v0_5; + s32 *temp_s0_2; + BoulderAAD *temp_s0; // TODO: Might be GrabbedObjectAdditionalActorData + BoulderAAD *temp_s0_3; // TODO: Might be GrabbedObjectAdditionalActorData + s32 *phi_s0; + u8 phi_a1; + + func_806DF6D4(1); + func_806D9924(current_actor_pointer); + switch (current_actor_pointer->control_state_progress) { + case 0: + // Have all fairies been photographed? + if (func_806F8EB4() == 20) { + phi_a1 = 0x1A; + } else { + phi_a1 = 0x11; + } + playCutscene(current_actor_pointer, phi_a1, 5); + current_actor_pointer->control_state_progress = 1; + break; + case 1: + global_properties_bitfield &= 0xFFFEFFCF; + func_80677FA8(0x141, 0x3D); // Spawn fairy (refill) actor 321 + func_8067B238(D_807FBB44, + current_actor_pointer, + current_actor_pointer->animation_state->scale_y * 2.0f); + D_807FBB44->object_properties_bitfield |= 0x40000000; + D_807FBB44->y_rotation += 0x800; + D_807FBB44->y_rotation &= 0xFFF; + D_807FBB44->unk11C = current_actor_pointer; + func_80614EBC(D_807FBB44, 0x2B7); + // TODO: I think this is wrong + // Need a new aaD type, boulderaad/grabbedaad? + temp_s0_3 = D_807FBB44->PaaD; + temp_s0_3->unk10 = current_actor_pointer; + temp_v0_5 = current_actor_pointer->unk12C; + temp_s0_3->unk18 = temp_v0_5; + temp_v0_5 = temp_v0_5; + if (temp_v0_5 == -1) { + temp_s0_3->unk18 = 0; + temp_v0_5 = 0; + } + temp_s0_3->unk16 = current_actor_pointer->z_rotation; + temp_s0_3->unk14 = current_actor_pointer->x_rotation; + func_80659620(temp_s0_3, temp_s0_3->unk4, temp_s0_3->unk8, temp_v0_5); + func_80659670(1.0f, 1.0f, 1.0f, temp_s0_3->unk1A); + func_80677FA8(0x136, 0xA8); // Spawn spotlight actor 310 + func_8067B238(D_807FBB44, + current_actor_pointer, + current_actor_pointer->animation_state->scale_x); + D_807FBB44->object_properties_bitfield |= 0x40000000; + temp_s0_3->unkC = D_807FBB44; + temp_s0_3->unk1E = func_806F8EB4() == 20; // Have all fairies been photographed? + current_actor_pointer->control_state_progress = 2; + break; + case 2: + if (func_80629148()) { + func_80629174(); + func_806874EC(); + playSong(0x3B, 1.0f); + current_actor_pointer->control_state_progress = 3; + } + // fallthrough + case 3: + if (func_80629148()) { + func_80629174(); + func_806CFF9C(current_actor_pointer); + func_80709464(current_actor_pointer->PaaD->unk1A4); + phi_s0 = &D_80750FE0; + do { + func_806F91B4(*phi_s0, 0, 9999); + func_806F8BC4(*phi_s0, 0, 0); + temp_s0_2 = phi_s0 + 4; + phi_s0 = temp_s0_2; + } while (temp_s0_2 != &D_80750FF0); + } + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +void func_806DF050(void) { + PlayerAdditionalActorData *PaaD = current_actor_pointer->PaaD; + func_806EB0C0(0x5C, NULL, cc_player_index); + if (D_80750AB8 == 0) { + character_change_array[PaaD->unk1A4].unk2EA = 1; + } + character_change_array[PaaD->unk1A4].unk2EB = 1; + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->shadow_opacity -= current_actor_pointer->shadow_opacity < 4 ? current_actor_pointer->shadow_opacity : 4; + if (current_actor_pointer->shadow_opacity == 0) { + if (D_80750AB8 == 0) { + // TODO: This is not ideal, conflicts with does_player_exist datatype + *(u8*)(&character_change_array[PaaD->unk1A4]) = 0; + } + current_actor_pointer->object_properties_bitfield &= -5; + } + func_806CC948(); + func_806319C4(current_actor_pointer, 0); +} + +void func_806DF1A0(void) { + PlayerAdditionalActorData *PaaD = current_actor_pointer->PaaD; + current_actor_pointer->animation_state->scale_x = current_actor_pointer->animation_state->scale_x * D_8075D0B8; + current_actor_pointer->animation_state->scale_y = current_actor_pointer->animation_state->scale_x; + current_actor_pointer->animation_state->scale_z = current_actor_pointer->animation_state->scale_x; + current_actor_pointer->x_position += ((PaaD->unk22C - current_actor_pointer->x_position) * 0.125f); + current_actor_pointer->y_position += ((PaaD->unk230 - current_actor_pointer->y_position) * 0.125f); + current_actor_pointer->z_position += ((PaaD->unk234 - current_actor_pointer->z_position) * 0.125f); + current_actor_pointer->x_rotation += 0xFF; + func_806319C4(current_actor_pointer, 0); +} + +void func_806DF280(void) { + PlayerAdditionalActorData *PaaD = current_actor_pointer->PaaD; + + current_actor_pointer->animation_state->scale_x *= D_8075D0C0; + if (D_8075D0C8 < current_actor_pointer->animation_state->scale_x) { + current_actor_pointer->animation_state->scale_x = D_8075D0D0; + current_actor_pointer->control_state = 0xC; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->x_rotation = -0xFF; + } + current_actor_pointer->animation_state->scale_y = current_actor_pointer->animation_state->scale_x; + current_actor_pointer->animation_state->scale_z = current_actor_pointer->animation_state->scale_x; + current_actor_pointer->x_position += PaaD->unk220; + current_actor_pointer->z_position += PaaD->unk228; + current_actor_pointer->x_rotation += 0xFF; + current_actor_pointer->x_rotation &= 0xFFF; + func_806319C4(current_actor_pointer, 0); +} + +void func_806DF390(Actor *arg0, PlayerAdditionalActorData *arg1, u8 arg2) { + s32 phi_a3; + + phi_a3 = 0x4A; + if (arg2) { + phi_a3 = 0x4C; + } + arg1->unk1A3 = 0; + func_80614E78(arg0, phi_a3); +} + +void func_806DF3D0(Actor *arg0, PlayerAdditionalActorData *arg1, u8 arg2) { + s32 sp1C = 0x4B; + s32 phi_a3 = 2; + + if (func_806F8AD4(3, arg1->unk1A4)) { + phi_a3 = 3; + } + func_806F8BC4(phi_a3, 0, 0); + if (arg2 != 0) { + sp1C = 0x4D; + } + func_80614E78(arg0, sp1C); +} + +void func_806DF44C(Actor* arg0, PlayerAdditionalActorData *arg1, u8 arg2) { + if (arg1->unk8C != 0) { + func_806DF390(arg0, arg1, arg2); + return; + } + func_806DF3D0(arg0, arg1, arg2); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DF494.s") + +/* +// TODO: Fiddly but doable +void func_806DF494(s16 *arg0, s16 arg1, s16 arg2) { + s16 temp_v0; + s16 phi_a2; + s16 phi_t0; + s16 phi_v0; + + arg1 &= 0xFFF; + temp_v0 = arg1 - *arg0; + if (temp_v0) { + phi_a2 = ABS(temp_v0); + phi_v0 = temp_v0 / phi_a2; + if (phi_a2 >= 0x801) { + phi_a2 = 0x1000 - phi_a2; + phi_v0 *= -1; + } + phi_t0 = -arg2; + if (arg2 > 0) { + phi_t0 = arg2; + } + if (phi_a2 < phi_t0) { + *arg0 = arg1; + } else { + *arg0 += (phi_v0 * arg2); + *arg0 &= 0xFFF; + } + } +} +*/ + +// Similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DF5A0.s") + +void func_806DF670(s16 *arg0, s16 arg1, s16 arg2) { + s16 temp_v0 = arg1 - *arg0; + if (temp_v0 != 0) { + // TODO: Is there a better way to express this? + if (((temp_v0 & 0xFFF) << 0x10 >> 0x10) + arg2 >= 0x1000) { + *arg0 = arg1; + } else { + *arg0 = (*arg0 + arg2) & 0xFFF; + } + } +} + +// Surprisingly doable, quite large though +// controlStateControl() +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DF6D4.s") + +// bitfield & loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806DFF34.s") + +f32 func_806DFFA0(f32 arg0, s16 arg1, s16 arg2) { + return func_80612790(arg2 - arg1) * arg0; +} + +void func_806DFFDC(s16 arg0) { + f32 temp_f0; + + temp_f0 = func_806DFFA0(extra_player_info_pointer->unk4, extra_player_info_pointer->unkA, arg0); + if (temp_f0 > 0.0f) { + extra_player_info_pointer->unk4 = temp_f0; + } else { + extra_player_info_pointer->unk4 = 0.0f; + } + extra_player_info_pointer->unkA = arg0; +} + +void func_806E0050(void) { + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unkA = current_actor_pointer->y_rotation; +} + +void func_806E007C(void) { + f32 temp_f2; + f32 phi_f0 = extra_player_info_pointer->unk38; + if (extra_player_info_pointer->unkC8 == 0) { + phi_f0 *= 0.5; + } + if (extra_player_info_pointer->unkD6 != 0) { + phi_f0 *= 0.5; + } + if ((D_807FD610[cc_player_index].unk4 != 0.0f) && ((extra_player_info_pointer->unk1F4 & 8) == 0)) { + temp_f2 = extra_player_info_pointer->unk34; + extra_player_info_pointer->unk4 = ((D_807FD610[cc_player_index].unk8 * (phi_f0 - temp_f2)) + temp_f2); + extra_player_info_pointer->unkA = D_807FD610[cc_player_index].unk28; + } else { + extra_player_info_pointer->unk4 = 0.0f; + extra_player_info_pointer->unkA = current_actor_pointer->y_rotation; + } +} + +void func_806E0178(void) { + f32 phi_f0; + f32 phi_f2; + + func_806E007C(); + phi_f2 = D_807FD610[cc_player_index].unk8; + if (phi_f2 < D_8075D0F0) { + phi_f2 = D_8075D0F8; + } + phi_f0 = ABS(current_actor_pointer->unkEE - extra_player_info_pointer->unkA); + if (phi_f0 > 2048) { + phi_f0 = 4096 - phi_f0; + } + phi_f0 = MIN(400, phi_f0); + phi_f0 *= D_8075D100; + func_806DF494(¤t_actor_pointer->unkEE, extra_player_info_pointer->unkA, phi_f0 * phi_f2); +} + +void func_806E0294(void) { + f32 phi_f0; + f32 phi_f2; + + func_806E007C(); + phi_f2 = D_807FD610[cc_player_index].unk8; + if (D_807FD610[cc_player_index].unk8 < D_8075D108) { + phi_f2 = D_8075D110; + } + phi_f0 = ABS(current_actor_pointer->unkEE - extra_player_info_pointer->unkA); + if (phi_f0 > 2048.0f) { + phi_f0 = 4096.0f - phi_f0; + } + phi_f0 = MIN(400, phi_f0); + phi_f0 *= (extra_player_info_pointer->unk48 / 400.0); + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, phi_f0 * phi_f2); +} + +f32 func_806E03C8(f32 arg0, f32 arg1) { + f32 phi_f2; + + if (D_807FD610[cc_player_index].unk30) { + phi_f2 = MIN(70, D_807FD610[cc_player_index].unk30); + phi_f2 -= 2.0f; + phi_f2 /= 68.0f; + return ((arg1 - arg0) * phi_f2) + arg0; + } + return 0.0f; +} + +f32 func_806E0454(f32 arg0, f32 arg1) { + f32 phi_f2; + + if (D_807FD610[cc_player_index].unk31) { + phi_f2 = MIN(70, D_807FD610[cc_player_index].unk31); + phi_f2 -= 2.0f; + phi_f2 /= 68.0f; + return ((arg1 - arg0) * phi_f2) + arg0; + } + return 0.0f; +} + +void func_806E04E0(void) { + f32 phi_f2; + f32 phi_f0; + f32 phi_f3; + + func_806E007C(); + if (D_807FD610[cc_player_index].unkC > 0.0f) { + phi_f2 = D_807FD610[cc_player_index].unkC; + } else { + phi_f2 = -D_807FD610[cc_player_index].unkC; + } + if (phi_f2 < 14.0f) { + phi_f3 = (D_807FD610[cc_player_index].unk8 * D_8075D118) + D_8075D120; + phi_f0 = ABS(current_actor_pointer->y_rotation - extra_player_info_pointer->unkA); + if (phi_f0 > 2048.0f) { + phi_f0 = 4096.0f - phi_f0; + } + phi_f0 = MIN(400, phi_f0); + phi_f0 *= (extra_player_info_pointer->unk48 / 400.0); + phi_f2 = phi_f0 * phi_f3; + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, phi_f2); + } +} + +void func_806E0654(void) { + func_806E007C(); + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEA, extra_player_info_pointer->unk48); +} + +void func_806E0694(void) { + func_806E007C(); + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, extra_player_info_pointer->unk48); + extra_player_info_pointer->unk4 = 0.0f; +} + +void func_806E06E8(void) { + s16 phi_a1; + + if (current_actor_pointer->unkDA < 0x3C7) { + phi_a1 = current_actor_pointer->unkD8 + 0x800; + } else { + phi_a1 = current_actor_pointer->unkEE + 0x800; + } + func_806DF494(¤t_actor_pointer->y_rotation, phi_a1, extra_player_info_pointer->unk48 / 4); + extra_player_info_pointer->unk4 = 0.0f; +} + +void func_806E077C(void) { + s16 phi_a1; + + if (current_actor_pointer->unkDA < 0x3C7) { + phi_a1 = current_actor_pointer->unkD8; + } else { + phi_a1 = current_actor_pointer->unkEE; + } + func_806DF494(¤t_actor_pointer->y_rotation, phi_a1, extra_player_info_pointer->unk48 / 4); + extra_player_info_pointer->unk4 = 0.0f; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E07F8.s") + +/* +// TODO: WIP, quite close considering the size of it +void func_806E07F8(void) { + s16 temp_a1; + s16 temp_v0_3; + s32 temp_v0; + f32 phi_f0; + f32 phi_f0_2; + Actor *phi_t9; + u8 phi_v0; + + func_806E007C(); + temp_a1 = current_actor_pointer->unkEE; + temp_v0 = current_actor_pointer->y_rotation - temp_a1; + if (temp_v0 > 0) { + phi_f0 = temp_v0; + } else { + phi_f0 = -temp_v0; + } + phi_f0_2 = phi_f0; + if (phi_f0 > 2048.0f) { + phi_f0_2 = 4096.0f - phi_f0; + } + if (phi_f0_2 > 400.0f) { + // TODO: Some float stuff missing here? + } + func_806DF494(¤t_actor_pointer->y_rotation, temp_a1, extra_player_info_pointer->unk48 / 4); + if (current_actor_pointer->control_state != 0x14) { + if ((current_actor_pointer->control_state == 0xF) && ((temp_v0_3 = ((s16*)current_actor_pointer->animation_state->unk0)[8], (temp_v0_3 == 0x1F2)) || (temp_v0_3 == 0x1B3))) { + if (D_807FD610[cc_player_index].unk2E < -0x1E) { + func_80614E78(current_actor_pointer, 0x61); + current_actor_pointer->control_state = 0x10; + current_actor_pointer->control_state_progress = 0; + } + if (D_807FD610[cc_player_index].unk2E >= 0x1F) { + func_80614E78(current_actor_pointer, 0x5F); + current_actor_pointer->control_state = 0x11; + current_actor_pointer->control_state_progress = 0; + } else { + if (D_807FD610[cc_player_index].unk2F >= 0x1F) { + func_80614E78(current_actor_pointer, 0x63); + current_actor_pointer->control_state = 0x12; + current_actor_pointer->control_state_progress = 0; + } else if (D_807FD610[cc_player_index].unk2F < -0x1E) { + func_80614E78(current_actor_pointer, 0x65); + current_actor_pointer->control_state = 0x13; +block_19: + current_actor_pointer->control_state_progress = 0; + } + } + } + // Joystick range check + if (((D_807FD610[cc_player_index].unk2E < 0x1E) && ((current_actor_pointer->control_state == 0x11))) || ((((D_807FD610[cc_player_index].unk2F < -0x1D) == 0)) && ((current_actor_pointer->control_state == 0x13))) || ((D_807FD610[cc_player_index].unk2F < 0x1E) && (current_actor_pointer->control_state == 0x12)) || ((D_807FD610[cc_player_index].unk2E >= -0x1D) && (current_actor_pointer->control_state == 0x10))) { + if ((current_character_index[cc_player_index] == 2) && (current_actor_pointer->control_state != 0x12)) { + func_80614EBC(current_actor_pointer, 0x191); + } else { + if (current_actor_pointer->control_state_progress == 1) { + switch (current_actor_pointer->control_state) { + case 17: + func_80614E78(current_actor_pointer, 0x60); + break; + case 16: + func_80614E78(current_actor_pointer, 0x62); + break; + case 18: + func_80614E78(current_actor_pointer, 0x64); + break; + case 19: + func_80614E78(current_actor_pointer, 0x66); + break; + } + } else { + func_80614E78(current_actor_pointer, 0x68); + } + } + + current_actor_pointer->control_state = 0xF; + current_actor_pointer->control_state_progress = 0; + } + } +} +*/ + +void func_806E0BEC(void) { + f32 phi_f0; + f32 phi_f2; + + func_806E007C(); + if (extra_player_info_pointer->unk4 != 0.0f) { + phi_f2 = D_807FD610[cc_player_index].unk8; + phi_f2 *= phi_f2; + if (phi_f2 < D_8075D128) { + phi_f2 = D_8075D130; + } + phi_f0 = ABS(current_actor_pointer->y_rotation - extra_player_info_pointer->unkA); + if (phi_f0 > 2048.0f) { + phi_f0 = 4096.0f - phi_f0; + } + phi_f0 = MIN(400, phi_f0); + phi_f0 *= extra_player_info_pointer->unk48 / 400.0; + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, phi_f0 * phi_f2); + } +} + +// Strange array/struct lookup at the bottom involving D_8075D138 and D_8075D140 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E0D40.s") + +// Surprisingly doable, just large and fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E0FAC.s") + +void func_806E1334(void) { + if (D_807FD610[cc_player_index].unk2F < 0) { + extra_player_info_pointer->unk4 = func_806E0454(D_80753BDC[D_807FD584], D_80753BF8[D_807FD584]); + } else { + extra_player_info_pointer->unk4 = func_806E0454(D_80753BA4[D_807FD584], D_80753BC0[D_807FD584]); + } + if (extra_player_info_pointer->unk4 != 0.0f) { + extra_player_info_pointer->unk8 = extra_player_info_pointer->unk4 > 0.0f ? 1 : -1; + } else { + extra_player_info_pointer->unk8 = 0; + } + func_8072FE60(D_807FD610[cc_player_index].unk2F / 80.0); + current_actor_pointer->y_rotation += D_807FD610[cc_player_index].unk2E; + current_actor_pointer->y_rotation &= 0xFFF; + func_806E1630(); +} + +void func_806E14DC(void) { + if (D_807FD610[cc_player_index].unk2F < 0) { + extra_player_info_pointer->unk4 = func_806E0454(D_80753BDC[D_807FD584], D_80753BF8[D_807FD584]); + } else { + extra_player_info_pointer->unk4 = func_806E0454(D_80753BA4[D_807FD584], D_80753BC0[D_807FD584]); + } + if (extra_player_info_pointer->unk4 != 0.0f) { + extra_player_info_pointer->unk8 = extra_player_info_pointer->unk4 > 0.0f ? 1 : -1; + } else { + extra_player_info_pointer->unk8 = 0; + } + func_8072FE60(D_807FD610[cc_player_index].unk2F / 80.0); +} + +void func_806E1630(void) { + s16 phi_a1 = FALSE; + if (extra_player_info_pointer->unk19C < extra_player_info_pointer->unk19E) { + if ((current_actor_pointer->y_rotation < extra_player_info_pointer->unk19C) || (extra_player_info_pointer->unk19E < current_actor_pointer->y_rotation)) { + phi_a1 = TRUE; + } + } else { + if ((extra_player_info_pointer->unk19E < current_actor_pointer->y_rotation) && (current_actor_pointer->y_rotation < extra_player_info_pointer->unk19C)) { + phi_a1 = TRUE; + } + } + if (phi_a1) { + if (func_806CC14C(current_actor_pointer->y_rotation, extra_player_info_pointer->unk19C) < func_806CC14C(current_actor_pointer->y_rotation, extra_player_info_pointer->unk19E)) { + current_actor_pointer->y_rotation = extra_player_info_pointer->unk19C; + } else { + current_actor_pointer->y_rotation = extra_player_info_pointer->unk19E; + } + } +} + +void func_806E1728(void) { + f32 temp_f0 = func_806E03C8(D_80753DC8[D_807FD584], D_80753DE4[D_807FD584]); + if (D_807FD610[cc_player_index].unk2E < 0) { + extra_player_info_pointer->unk4 = -temp_f0; + extra_player_info_pointer->unk8 = -1; + } else { + extra_player_info_pointer->unk4 = temp_f0; + if (temp_f0 != 0.0f) { + extra_player_info_pointer->unk8 = 1; + } else { + extra_player_info_pointer->unk8 = 0; + } + } +} + +void func_806E17F4(void) { + func_806E007C(); + func_806DF494(¤t_actor_pointer->unkEE, extra_player_info_pointer->unkA, extra_player_info_pointer->unk48); + func_806DF494(¤t_actor_pointer->y_rotation, current_actor_pointer->unkEE, extra_player_info_pointer->unk48); + func_806DFFDC(current_actor_pointer->y_rotation); +} + +void func_806E1864(void) { + +} + +void func_806E186C(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + current_actor_pointer->z_rotation = 0; + current_actor_pointer->x_rotation = 0; + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) && (extra_player_info_pointer->unkC8 == -1)) { + if (current_actor_pointer->unkE0 != 0.0f) { + current_actor_pointer->unkEE = current_actor_pointer->unkDC; + current_actor_pointer->unkB8 = 200.0f; + extra_player_info_pointer->unk3E = 0x1E; + extra_player_info_pointer->unk40 = current_actor_pointer->unkDC; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584] * 0.5; + } else { + extra_player_info_pointer->unk3C = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + } + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x10); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +void func_806E1A50() { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + // TODO: Get rid of this typecast if possible + if ((u32) (D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + if (((current_actor_pointer->unk6A & 1) == 0) || + (current_actor_pointer->unkE0 == 0.0f)) { + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614EBC(current_actor_pointer, 0xB0); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E1BA4.s") + +/* +// TODO: Regalloc +void func_806E1BA4(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) && (!(current_actor_pointer->unk6A & 1) || (current_actor_pointer->unkE0 == 0.0f))) { + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + current_actor_pointer->unkB8 = MIN(current_actor_pointer->unkB8, extra_player_info_pointer->unk38); + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + extra_player_info_pointer->unk2C = 20.0f; + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x10); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} +*/ + +void func_806E1D38(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) && (!(current_actor_pointer->unk6A & 1) || (current_actor_pointer->unkE0 == 0.0f))) { + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614EBC(current_actor_pointer, 0xAF); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +void func_806E1E54(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + if (current_actor_pointer->y_acceleration == -260.0f) { + current_actor_pointer->y_acceleration = -31.0f; + } else { + func_806CFE7C(); + } + current_actor_pointer->control_state = 0x14; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x67); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +void func_806E1F8C(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) && (extra_player_info_pointer->unk8D == 0)) { + current_actor_pointer->control_state = 0x41; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614EBC(current_actor_pointer, 0x156); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E208C.s") + +/* +// TODO: Struct size 0x306? +// TODO: Is this the correct start offset for the struct? Might be earlier in memory +extern void D_807FCA6A[]; + +void func_806E208C(void) { + if ((D_807FD610[cc_player_index].unk2C & A_BUTTON) && D_807FCA6A[cc_player_index]->unk0 >= 2 && current_map != MAP_AZTEC_BEETLE_RACE) { + func_806EB0C0(9, NULL, cc_player_index); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} +*/ + +void func_806E2140(void) { + if ((D_807FD610[cc_player_index].unk2C & A_BUTTON)) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (D_80767CC0 - extra_player_info_pointer->unk58 < 0xFU && (!(current_actor_pointer->unk6A & 1) || current_actor_pointer->unkE0 == 0.0f)) { + current_actor_pointer->control_state = 0x61; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x50); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +// handle gunshots, jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E225C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E2B20.s") + +extern f64 D_8075D190; + +u8 func_80671E00(f32, f32, f32, f32, s16*, s16*, f32*, f32*); + +/* +// TODO: Pretty close +u8 func_806E2B20(Actor *arg0) { + f32 sp7C; + f32 sp78; + f32 sp74; + f32 sp70; + f32 sp6C; + f32 sp68; + s16 sp66; + s16 sp64; + f64 temp_f24; + f32 phi_f20; + u8 phi_v1; + + phi_v1 = 0; + phi_f20 = 0.0f; + func_80671C0C(arg0, 4, &sp78, &sp70, &sp68); + func_80671C0C(arg0, 0xA, &sp7C, &sp74, &sp6C); + phi_f20 = 0.0f; + temp_f24 = D_8075D190; + while (!phi_v1 && phi_f20 <= 1.0) { + phi_v1 = func_80671E00(((sp7C - sp78) * phi_f20) + sp78, + ((sp74 - sp70) * phi_f20) + sp70, + ((sp6C - sp68) * phi_f20) + sp68, + 10.0f, + &sp66, + &sp64, + 0, + 0); + phi_f20 += temp_f24; + } + return phi_v1; +} +*/ + +// Jumptable lol +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E2C74.s") + +extern s16 D_80753E64[]; + +u8 playerCanThrowOrange(void) { + return !func_80714608(0) + && !(D_807FBB64 & 0x200) + && func_806F8AD4(4, cc_player_index) + && current_character_index[cc_player_index] < 6 + && func_8067ACDC(current_actor_pointer, 4, 0) < D_80753E64[D_807FD584] + && (isFlagSet(0x184, FLAG_TYPE_PERMANENT) // Is orange barrel completed? + || (D_807FBB64 & 0x10000000) + || (cc_number_of_players > 1) + || gameIsInDKTVMode() + || gameIsInMysteryMenuMinigameMode()); +} + +void func_806E2DE8(void) { + if ((D_807FD610[cc_player_index].unk2C & R_CBUTTONS) && playerCanThrowOrange()) { + func_80614E78(current_actor_pointer, 0x47); + current_actor_pointer->control_state = 0x2C; // Throwing orange + current_actor_pointer->control_state_progress = 0; + } +} + +void func_806E2E6C() { + if (D_807FD568->unk2 & 1) { + func_806E225C(0, 0); + } +} + +void func_806E2EA8() { + func_806E225C(1, 0); +} + +void func_806E2ECC(void) { + if ((D_807FD610[cc_player_index].unk2C & (A_BUTTON | B_BUTTON)) == B_BUTTON) { + func_80614E78(current_actor_pointer, 0x54); + } else { + func_806E225C(0, 0); + } +} + +extern s16 D_80753354[]; + +void func_806E2F3C(void) { + s32 phi_v1 = 1; + if (cc_number_of_players >= 2) { + phi_v1 = !func_806E56EC(); + } + if (phi_v1 != 0) { + if ((current_actor_pointer->control_state != 0x62) && (current_actor_pointer->unk6A & 1)) { + extra_player_info_pointer->unk48 = D_80753354[D_807FD584]; + current_actor_pointer->control_state = 0x62; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x52); + } + } +} + +void func_806E2FE8(void) { + if (!(D_807FD610[cc_player_index].unk2C & Z_TRIG)) { + func_806CFF9C(current_actor_pointer); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E3040.s") + +extern f32 D_8075371C[]; +extern f32 D_8075378C[]; + +/* +// TODO: Regalloc, a3 v1 +void func_806E3040(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) && (current_character_index[cc_player_index] != 6) && ((((current_actor_pointer->unk6A & 1) == 0)) || (current_actor_pointer->unkE0 == 0.0f))) { + PlayerAdditionalActorData *PaaD = extra_player_info_pointer; + if (PaaD->unk20 > 70.0f) { + current_actor_pointer->control_state = 0x1D; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_8075378C[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x1A); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } else { + current_actor_pointer->control_state = 0x3E; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_8075371C[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0xE); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } + } +} +*/ + +extern f32 D_807535CC[]; + +void func_806E31FC(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + if ((current_actor_pointer->control_state == 0x17) && (((current_actor_pointer->unk6A & 1) == 0) || (current_actor_pointer->unkE0 == 0.0f))) { + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x10); + } + } +} + +void func_806E330C(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + if ((current_actor_pointer->control_state == 0x61) && (((current_actor_pointer->unk6A & 1) == 0) || (current_actor_pointer->unkE0 == 0.0f))) { + current_actor_pointer->control_state = 0x61; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x50); + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E341C.s") + +/* +// TODO: Replace D_80767CC0 with D_80767A40.unk280 here +// I guess it's a struct access? +void func_806E341C(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + current_actor_pointer->control_state = 0x58; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk3E = 0; + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} +*/ + +void func_806E34D8(void) { + if (D_807FD610[cc_player_index].unk2C & R_TRIG) { + current_actor_pointer->unkEE = (current_actor_pointer->unkEE + 0x800) & 0xFFF; + } +} + +extern s16 D_80753C94[]; +extern f32 D_80753D08[]; + +void func_806E352C(void) { + current_actor_pointer->unk6A &= ~0x40; + extra_player_info_pointer->unk100 = D_80753C94[D_807FD584]; + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->unkB8 = 0.0f; + extra_player_info_pointer->unk54 = D_80753D08[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x10); +} + +void func_806E35D8(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + // TODO: Get rid of this typecast if possible + if ((u32) (D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + current_actor_pointer->control_state = 0x5A; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk3E = 0; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x74); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E36B4.s") + +void func_806E380C(void) { + func_806CFEA4(); +} + +void func_806E382C(void) { + func_806CFE7C(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E384C.s") + +// TODO: This signature probably is not correct +//f32 func_80612794(f32, f32, s16, s16, s16 *); +extern f32 D_8075D214; + +/* +// TODO: Very close, minor datatype/regalloc(?) issues +void func_806E384C(void) { + f32 temp_f2; + s32 temp_f18; + f32 phi_f0; + s32 temp; + + phi_f0 = extra_player_info_pointer->unk1A0 + 0x9E8; + if (phi_f0 >= 32768) { + phi_f0 -= 65536; + } + phi_f0 /= 16; + if (current_actor_pointer->unk6E == -1) { + func_80604CBC(current_actor_pointer, 0x114, 0, 0, 0, 0xFF, 1.0f, 0); + } + current_actor_pointer->y_acceleration = D_807536E4[D_807FD584] + (-2 * D_807536E4[D_807FD584] * func_80612790(phi_f0)); + if (current_actor_pointer->y_velocity < 0.0f) { + current_actor_pointer->y_acceleration = current_actor_pointer->y_acceleration - (current_actor_pointer->y_velocity / 100.0); + } + if (current_actor_pointer->unk6A & 1) { + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + } else { + temp_f2 = func_80612794(current_actor_pointer->y_velocity, 0.0f, phi_f0, phi_f0, &D_807FD584) * 8.0f; + if (temp_f2 >= 0.0f) { + phi_f0 = current_actor_pointer->y_rotation; + } else { + phi_f0 = current_actor_pointer->y_rotation + 0x800; + if (phi_f0 > 4096) { + phi_f0 -= 4096; + } + } + if (temp_f2 > 0.0f) { + extra_player_info_pointer->unk2C = temp_f2; + } else { + extra_player_info_pointer->unk2C = -temp_f2; + } + func_806CD424(phi_f0, 900, extra_player_info_pointer->unk38); + extra_player_info_pointer->unk30 = ((current_actor_pointer->unkB8 * current_actor_pointer->unkB8) / D_8075D214) + 1.0f; + } + extra_player_info_pointer->unk1A2 = 1; +} +*/ + +extern f32 D_8075D218; + +void func_806E384C(void); + +void func_806E3B00(void) { + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG)) { + if (func_806F8AD4(5, cc_player_index) && (extra_player_info_pointer->unk1A3)) { + func_806E384C(); + } else { + func_80605314(current_actor_pointer, 0); + current_actor_pointer->y_acceleration = D_807536E4[D_807FD584]; + extra_player_info_pointer->unk30 = ((current_actor_pointer->unkB8 * current_actor_pointer->unkB8) / D_8075D218) + 1.0f; + } + } else { + current_actor_pointer->y_acceleration = D_807536E4[D_807FD584]; + } + func_806CD8EC(); +} + +void func_806E3C14(void) { + func_806F142C(current_actor_pointer); +} + +void func_806E3C38(void) { + f32 temp_f0; + + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG)) { + func_80605314(current_actor_pointer, 0); + } + current_actor_pointer->y_acceleration = D_807536E4[D_807FD584]; + temp_f0 = current_actor_pointer->unkB8; + extra_player_info_pointer->unk30 = ((temp_f0 * temp_f0) / D_8075D21C) + 1.0f; + func_806CD8EC(); +} + +void func_806E3CEC(void) { + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; +} + +void func_806E3D14(f32 arg0) { + f32 phi_f0; + + if (extra_player_info_pointer->unk1A0 < 0x8000) { + phi_f0 = extra_player_info_pointer->unk1A0 + 0x10000; + } else { + phi_f0 = extra_player_info_pointer->unk1A0; + } + if (arg0 < phi_f0) { + phi_f0 -= D_8075D220; + phi_f0 = MAX(arg0, phi_f0); + } + if (phi_f0 < arg0) { + phi_f0 += D_8075D224; + phi_f0 = MIN(arg0, phi_f0); + } + extra_player_info_pointer->unk1A0 = phi_f0; +} + +// Yeah probably doable, weird pointer to 0x80800000 maybe though? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E3E40.s") + +void func_806E41B4() { + func_80614E78(current_actor_pointer, 0x15); + current_actor_pointer->control_state_progress = 7; +} + +void func_806E41EC(void) { + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + extra_player_info_pointer->unk5C = D_80767CC0; + } + // Barrel Barrel Complete Flag Check + if ((D_807FBB8C != 0) && (isFlagSet(0x185, FLAG_TYPE_PERMANENT) || ((D_807FBB64 * 8) < 0) || (cc_number_of_players >= 2) || gameIsInMysteryMenuMinigameMode())) { + func_806EB0C0(3, NULL, cc_player_index); + return; + } + if (!func_806E4580() && (D_807FD610[cc_player_index].unk2C & B_BUTTON) && (current_actor_pointer->unk6A & 1)) { + if (current_character_index[cc_player_index] == 6) { + if (D_807FD610[cc_player_index].unk2A & 0x2000) { + current_actor_pointer->control_state = 0x2F; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x48); + extra_player_info_pointer->unk68 = D_8075380C[D_807FD584]; + extra_player_info_pointer->unk38 = D_8075381C[D_807FD584]; + extra_player_info_pointer->unk30 = D_8075382C[D_807FD584]; + extra_player_info_pointer->unk48 = D_8075385C[D_807FD584]; + current_actor_pointer->unkEE = current_actor_pointer->y_rotation; + return; + } + current_actor_pointer->control_state = 0x29; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0x1DF); + extra_player_info_pointer->unk64 = 0; + extra_player_info_pointer->unk68 = D_8075380C[D_807FD584]; + return; + } + if (!func_80714608(0) && D_807531E0[D_807FD584] <= extra_player_info_pointer->unk20 && (current_actor_pointer->unkE0 == 0.0f)) { + func_80614E78(current_actor_pointer, 0x44); + current_actor_pointer->control_state = 0x29; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->unkEA = current_actor_pointer->unkEE; + current_actor_pointer->unkB8 = 150.0f; + extra_player_info_pointer->unk38 = 150.0f; + } else { + func_80614E78(current_actor_pointer, 0x3F); + current_actor_pointer->control_state = 0x26; + current_actor_pointer->control_state_progress = 0; + } + extra_player_info_pointer->unkC8 = 0x32; + extra_player_info_pointer->unk64 = 0; + } +} + +s32 func_806E4580(void) { + if ((D_807FD610[cc_player_index].unk2C & B_BUTTON) && D_807FBB70[0].unk2 && D_807FBB70[0].unk14 == 8) { + extra_player_info_pointer->unk220 = D_807FBB70[0].unk4; + extra_player_info_pointer->unk224 = D_807FBB70[0].unk8; + extra_player_info_pointer->unk228 = D_807FBB70[0].unkC; + func_806EB0C0(0x1F, NULL, cc_player_index); + return TRUE; + } + return FALSE; +} + +void func_806E4634(void) { + f32 temp_f2; + f32 phi_f0; + + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + extra_player_info_pointer->unk5C = D_80767CC0; + } + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + phi_f0 = current_actor_pointer->distance_from_floor; + if (current_actor_pointer->unk6A & 2) { + temp_f2 = current_actor_pointer->y_position - current_actor_pointer->unkAC; + if (!(phi_f0 < temp_f2)) { + phi_f0 = temp_f2; + } + } + if ((phi_f0 > 3.0f) && current_character_index[cc_player_index] != 6) { + func_806EB0C0(0xF, NULL, cc_player_index); + } + } +} + +// Doable, needs 0x306 struct array though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E4740.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E4AD8.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E4C6C.s") + +void func_806E4D14(void) { + u32 actorBehaviourIndex = extra_player_info_pointer->unk1AC->unk58; + // Steel Keg & Apple + if ((actorBehaviourIndex != 0x55) && (actorBehaviourIndex != 0x82)) { + current_actor_pointer->y_velocity = 200.0f; + current_actor_pointer->control_state = 0x4D; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x2D); + } +} + +void func_806E4D84(void) { + if (!func_806E56EC()) { + if (extra_player_info_pointer->unkC8 == -1) { + if (current_character_index[cc_player_index] != 6 || current_actor_pointer->unkB8 < D_807531E0[D_807FD584]) { + current_actor_pointer->control_state = 0x3C; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0xA); + extra_player_info_pointer->unk48 = D_807534D4[D_807FD584]; + } + extra_player_info_pointer->unk30 = D_807534B8[D_807FD584]; + } + } +} + +void func_806E4E88(void) { + if ((D_807FD610[cc_player_index].unk2C & R_CBUTTONS) && playerCanThrowOrange()) { + func_80618104(current_actor_pointer); + func_80617770(current_actor_pointer, 0x21, 0x19); + } + if (D_807FD610[cc_player_index].unk2C & L_CBUTTONS) { + if ((D_80767CC0 - extra_player_info_pointer->unk60) < 0xFU) { + if (extra_player_info_pointer->unk8C != 0) { + func_806F0B34(current_actor_pointer); + } + extra_player_info_pointer->unk8C = 0; + func_806EAB44(current_actor_pointer, 0); + } else if (!func_80714608(0) && !(D_807FBB64 & 0x80000200) && (D_807FD568->unk2 & 1)) { + if (((extra_player_info_pointer->unk1F0 & 0x30) == 0) && (character_change_array[cc_player_index].unk2C0 == 1)) { + func_806DF44C(current_actor_pointer, extra_player_info_pointer, 1); + } + } + extra_player_info_pointer->unk60 = D_80767CC0; + } +} + +void func_806E5044(void) { + if (((D_807FD610[cc_player_index].unk2C & R_CBUTTONS)) && (playerCanThrowOrange())) { + func_80618104(current_actor_pointer); + func_80617770(current_actor_pointer, 0x21, 0x19); + } + if ((D_807FD610[cc_player_index].unk2C & L_CBUTTONS)) { + if ((D_80767CC0 - extra_player_info_pointer->unk60) < 0xFU) { + if (extra_player_info_pointer->unk8C != 0) { + func_806F0B34(current_actor_pointer); + } + extra_player_info_pointer->unk8C = 0; + func_806EAB44(current_actor_pointer, 0); + } else if (!func_80714608(0) && !(D_807FBB64 & 0x200) && (D_807FD568->unk2 & 1) && (character_change_array[cc_player_index].unk2C0 == 1)) { + func_806DF44C(current_actor_pointer, extra_player_info_pointer, 1); + character_change_array[cc_player_index].fov_y = 45.0f; + } + extra_player_info_pointer->unk60 = D_80767CC0; + } +} + +void func_806E521C(void) { + if (func_80714608(0)) { + switch (current_actor_pointer->control_state) { + case 0x31: + case 0x32: + if (extra_player_info_pointer->unk8C == 0) { + func_806E4D84(); + } + } + } +} + +// Loop +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E527C.s") + +// Doable, annoying condition that will probably need to be turned into a switch case or two though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E52D0.s") + +s32 func_806E5488(Actor *arg0) { + f32 temp_f0; + f32 dx; + f32 dz; + f32 temp_f2; + f32 dy; + + if (arg0->locked_to_pad == 1) { + temp_f0 = arg0->unk94 - arg0->unk88; + temp_f2 = arg0->unk98 - arg0->unk90; + if (sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) > 1.0) { + return TRUE; + } + } + if ((arg0->unk6A & 8) != 0) { + dx = arg0->x_position - arg0->unk88; + dy = arg0->y_position - arg0->unk8C; + dz = arg0->z_position - arg0->unk90; + if (sqrtf((dx * dx) + (dy * dy) + (dz * dz)) > 1.0) { + return TRUE; + } + } + // Object Model 2 Behavior: Mushroom (0x88) + if ((arg0->locked_to_pad == 1) && (func_8063C328(arg0->unk10C) == 0x88)) { + return TRUE; + } + // Object Model 2 Behavior: Wooden Platform (Castle) (0x219) + if ((arg0->locked_to_pad == 1) && (func_8063C328(arg0->unk10C) == 0x219)) { + return TRUE; + } + // Object Model 2 Behavior: Metal Platform (0x132) + if ((arg0->locked_to_pad == 1) && (func_8063C328(arg0->unk10C) == 0x132)) { + return TRUE; + } + return FALSE; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E560C.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E56EC.s") + +void func_806E5C2C(s32 arg0, s32 arg1, s32 arg2) { + if (arg1 != 0) { + setIntroStoryPlaying(2); + func_805FF158(0); + } + func_805FF9AC(arg0, 0, 0, 0); +} + +extern f64 D_8075D310; + +int func_806E5C74(void) { + f32 temp_f2; + f32 phi_f0; + + phi_f0 = current_actor_pointer->distance_from_floor; + if (current_actor_pointer->unk6A & 2) { + temp_f2 = current_actor_pointer->y_position - current_actor_pointer->unkAC; + if (!(phi_f0 < temp_f2)) { + phi_f0 = temp_f2; + } + } + return D_807FD610[cc_player_index].unk2C & Z_TRIG + && extra_player_info_pointer->unk1CC * D_8075D310 < phi_f0 + && current_character_index[cc_player_index] != 6 + && D_807FD568->unk1 != 0; +} + +void func_806E5D60(void) { + if (func_806E5C74()) { + switch (D_807FD568->unk1) { + case 2: + func_80614E78(current_actor_pointer, 0x17); + func_80613AF8(current_actor_pointer, 0x18, 0, 3.0f); + func_80614D00(current_actor_pointer, 1.35f, 0); + break; + case 3: + func_80614E78(current_actor_pointer, 0x19); + break; + default: + func_80614E78(current_actor_pointer, 0x16); + func_80613AF8(current_actor_pointer, 0x17, 0, 3.0f); + func_80614D00(current_actor_pointer, 1.35f, 0); + break; + } + current_actor_pointer->control_state = 0x1C; + current_actor_pointer->control_state_progress = 0; + } +} + +void func_806E5E58(void) { + +} + +void func_806E5E60(void) { + +} + +void func_806E5E68(void) { + if (!(extra_player_info_pointer->unk1F0 & 0x20)) { + func_806EB0C0(0x24, NULL, cc_player_index); + } +} + +void func_806E5EA8() { + func_806EB0C0(0x24, NULL, cc_player_index); +} + +void func_806E5ED4(void) { + if ((D_807FD610[cc_player_index].unk2C & L_CBUTTONS) + && (D_807FD568->unk2 & 1) + && (character_change_array[cc_player_index].unk2C0 == 1) + && !(extra_player_info_pointer->unk1F0 & 0x30) + && !func_80714608(0)) { + func_806EB0C0(0x14, NULL, cc_player_index); + } +} + +void func_806E5FA0(void) { + if (((D_807FD610[cc_player_index].unk2C & L_CBUTTONS)) + && (D_807FD568->unk2 & 1) + && !(D_807FBB64 & 0x200) + && (character_change_array[cc_player_index].unk2C0 == 1) + && !(extra_player_info_pointer->unk1F0 & 0x30) + && !func_80714608(0)) { + func_806EB0C0(0x15, NULL, cc_player_index); + } +} + +void func_806E607C(void) { + PlayerAdditionalActorData *temp_v0; + + temp_v0 = extra_player_info_pointer->unk104->PaaD; + temp_v0->unkAC |= 4; + if (((D_807FD610[cc_player_index].unk2C & R_TRIG))) { + if ((D_807FBB64 & 1) || ((cc_number_of_players >= 2) && (D_80750AB8 == 0))) { + if (temp_v0->unkAC & 0x10000) { + func_806261CC(extra_player_info_pointer->unk104); + return; + } + func_80626110(extra_player_info_pointer->unk104, 0, 0); + return; + } + if ((temp_v0->unkAC & 0x4000) == 0) { + temp_v0->unkAC ^= 2; + if ((temp_v0->unkF1 < 3) && (temp_v0->unkF5 == 0) && (temp_v0->unkF3 != 2)) { + temp_v0->unkF1 = 0x14; + temp_v0->unkB2 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk104->distance_from_floor = temp_v0->unkB8; + temp_v0->unkF5 = 0xA; + } + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E61D0.s") + +/* +// TODO: Need new aaD type with s32 at unk4, s32 at unkAC? +void func_806E61D0(void) { + PlayerAdditionalActorData *temp_v0; + + if (((D_807FBB64 & 1) == 0) && ((cc_number_of_players < 2) || (D_80750AB8 != 0))) { + temp_v0 = extra_player_info_pointer->unk104->RaaD; + temp_v0->unk4 = 0; + temp_v0->unkAC &= ~4; + } +} +*/ + +void func_806E6234(void) { + if ((D_807FD610[cc_player_index].unk2C & START_BUTTON) + && !func_8061CB50() + && (D_807FD888 == 0.0f) + && (gameIsInAdventureMode() || gameIsInMysteryMenuMinigameMode() || gameIsInDKTVMode()) + && !func_8062919C() + && !func_806291A8()) { + D_807FC8B9 = cc_player_index; + global_properties_bitfield |= 1; + } +} + +void func_806E6318(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } +} + +void func_806E6368(void) { + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + extra_player_info_pointer->unk5C = D_80767CC0; + } +} + +void func_806E63B8(void) { + f32 temp_f0; + + if (D_807FD610[cc_player_index].unk4 != 0.0f) { + temp_f0 = extra_player_info_pointer->unk34; + extra_player_info_pointer->unk4 = (D_807FD610[cc_player_index].unk8 * (extra_player_info_pointer->unk38 - temp_f0)) + temp_f0; + } else { + extra_player_info_pointer->unk4 = 0.0f; + } + extra_player_info_pointer->unk4 /= 4; + if (D_807FD610[cc_player_index].unk4 != 0.0f) { + func_806DF494(¤t_actor_pointer->y_rotation, D_807FD610[cc_player_index].unk28, extra_player_info_pointer->unk48); + } + func_806DF494(¤t_actor_pointer->z_rotation, 0, 0x10); + func_806DF494(¤t_actor_pointer->x_rotation, 0, 0x10); +} + +void func_806E64D0(void) { + s16 phi_a1; + s32 phi_v0; + + if (D_807FD610[cc_player_index].unk30) { + phi_a1 = D_80753B34[D_807FD584] * (D_807FD610[cc_player_index].unk2E >= 0 ? 1 : -1); + phi_a1 &= 0xFFF; + } else { + phi_a1 = 0; + } + func_806DF494(¤t_actor_pointer->x_rotation, phi_a1, 0x10); + func_806DF494(¤t_actor_pointer->z_rotation, extra_player_info_pointer->unk12, 0x10); + extra_player_info_pointer->unk38 = D_80753988[D_807FD584]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E65BC.s") + +extern s16 D_80753B44[]; +extern s16 D_80753B54[]; +extern s16 D_80753B64[]; + +/* +// TODO: Surprisingly fiddly +void func_806E65BC(void) { + f64 temp_f0; + s16 phi_t1; + s16 phi_a1; + f64 phi_f2; + s32 phi_v0; + + phi_t1 = current_character_index[cc_player_index] == 7 ? 0x19 : 0x10; + if (D_807FD610[cc_player_index].unk30 != 0) { + current_actor_pointer->y_rotation = (current_actor_pointer->y_rotation - (D_807FD610[cc_player_index].unk2E / 2)) & 0xFFF; + phi_v0 = -1; + if (D_807FD610[cc_player_index].unk2E >= 0) { + phi_v0 = 1; + } + phi_a1 = (phi_v0 * D_80753B54[D_807FD584]) & 0xFFF; + } else { + phi_a1 = 0; + } + func_806DF494(¤t_actor_pointer->x_rotation, phi_a1, 0x10); + if (D_807FD610[cc_player_index].unk2F != 0) { + temp_f0 = D_807FD610[cc_player_index].unk2F * 0.125; + if (temp_f0 > 0.0) { + phi_f2 = temp_f0; + } else { + phi_f2 = -temp_f0; + } + func_806DF494(¤t_actor_pointer->z_rotation, ((D_807FD610[cc_player_index].unk2F * D_80753B44[D_807FD584]) / 70) & 0xFFF, phi_f2 + phi_t1); + return; + } + func_806DF494(¤t_actor_pointer->z_rotation, D_80753B64[D_807FD584], 0x10); +} +*/ + +extern f64 D_8075D318; +extern s16 D_8075395C[]; + +void func_806E67D8(void) { + f32 phi_f0; + f32 phi_f0_2; + + func_806E007C(); + if (extra_player_info_pointer->unk4 != 0.0f) { + phi_f0_2 = ((D_807FD610[cc_player_index].unk8 * 0.5) + 0.5); + phi_f0 = ABS(current_actor_pointer->y_rotation - extra_player_info_pointer->unkA); + if (phi_f0 > 2048.0f) { + phi_f0 = 4096.0f - phi_f0; + } + phi_f0 = MIN(400, phi_f0); + phi_f0 *= (extra_player_info_pointer->unk48 / 400.0); + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, phi_f0 * phi_f0_2); + } + func_806DF494(¤t_actor_pointer->z_rotation, 0, 0x10); + func_806DF494(¤t_actor_pointer->x_rotation, 0, 0x10); + extra_player_info_pointer->unk12 = 0; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk10 = D_8075395C[D_807FD584]; + extra_player_info_pointer->unk38 = D_80753988[D_807FD584] * D_807FD610[cc_player_index].unk8; + if ((D_807FD610[cc_player_index].unk2A & B_BUTTON)) { + extra_player_info_pointer->unk38 *= D_8075D318; + } +} + +extern f64 D_8075D320; + +void func_806E6A38(void) { + f32 phi_f0; + f32 phi_f0_2; + f32 phi_f0_3; + f32 temp; + + func_806E007C(); + if (extra_player_info_pointer->unk4 != 0.0f) { + temp = ((D_807FD610[cc_player_index].unk8 * 0.5) + 0.5); + phi_f0 = ABS(current_actor_pointer->y_rotation - extra_player_info_pointer->unkA); + if (phi_f0 > 2048.0f) { + phi_f0 = 4096.0f - phi_f0; + } + if (phi_f0 > 400.0f) { + phi_f0 = 400.0f; + } + phi_f0 *= D_8075D320; + func_806DF494(¤t_actor_pointer->y_rotation, extra_player_info_pointer->unkA, phi_f0 * temp); + } + func_806DF494(¤t_actor_pointer->z_rotation, 0, 0x10); + func_806DF494(¤t_actor_pointer->x_rotation, 0, 0x10); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E6B98.s") + +/* +extern f64 D_8075D328; + +// TODO: Pretty close +void func_806E6B98(void) { + s16 sp18; + f64 temp_f0; + s16 temp_v0; + s8 temp_v0_2; + s16 phi_v0; + s16 phi_a1; + s16 phi_a2; + s32 phi_v0_2; + f64 phi_f2; + + temp_v0 = current_actor_pointer->y_rotation; + sp18 = 0x10; + phi_a1 = 0; + if (D_807FD610[cc_player_index].unk30 != 0) { + if (current_character_index[cc_player_index] == 7) { + phi_v0 = temp_v0 - (D_807FD610[cc_player_index].unk2E * D_8075D328); + } else { + phi_v0 = temp_v0 - (D_807FD610[cc_player_index].unk2E * 0.5); + } + current_actor_pointer->y_rotation = phi_v0 & 0xFFF; + phi_v0_2 = -1; + if (D_807FD610[cc_player_index].unk2E >= 0) { + phi_v0_2 = 1; + } + phi_a1 = (phi_v0_2 * D_80753B34[D_807FD584]) & 0xFFF; + } + func_806DF494(¤t_actor_pointer->x_rotation, phi_a1, 0x10); + temp_v0_2 = D_807FD610[cc_player_index].unk2F; + phi_a2 = sp18; + if (current_character_index[cc_player_index] == 7) { + temp_f0 = temp_v0_2 * 0.5; + if (temp_f0 > 0.0) { + phi_f2 = temp_f0; + } else { + phi_f2 = -temp_f0; + } + phi_a2 = phi_f2 + 16.0; + } + func_806DF494(¤t_actor_pointer->z_rotation, ((temp_v0_2 * D_80753B44[D_807FD584]) / 70) & 0xFFF, phi_a2); +} +*/ + +void func_806E6DE8(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + func_806EB0C0(1, NULL, cc_player_index); + } +} + +extern f32 D_8075396C[]; + +void func_806E6E7C(void) { + extra_player_info_pointer->unk12 = 0; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk10 = 1; + extra_player_info_pointer->unk38 = D_8075396C[D_807FD584]; + } +} + +void func_806E6EE0(void) { + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG) && D_807FD610[cc_player_index].unk2C & A_BUTTON) { + func_80614E78(current_actor_pointer, 0x37); + current_actor_pointer->control_state_progress = 4; + extra_player_info_pointer->unk58 = D_80767CC0; + } +} + +void func_806E6F74(void) { + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG)) { + func_80614E78(current_actor_pointer, 0x37); + current_actor_pointer->control_state_progress = 4; + extra_player_info_pointer->unk58 = D_80767CC0; + } +} + +void func_806E6FF0(void) { + extra_player_info_pointer->unk58 = D_80767CC0; + func_80614D00(current_actor_pointer, 2.0f, 0); + func_80614E78(current_actor_pointer, 0x38); + current_actor_pointer->control_state_progress = 7; +} + +void func_806E7050(void) { + func_80614E78(current_actor_pointer, 0x39); + current_actor_pointer->control_state_progress = 7; +} + +void func_806E7088(void) { + current_actor_pointer->control_state_progress = 6; +} + +extern s16 D_80753A98[]; +extern f32 D_80753AA8[]; +extern f32 D_80753AC4[]; + +void func_806E709C(void) { + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG)) { + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk38 = D_80753AC4[D_807FD584]; + func_80614E78(current_actor_pointer, 0x36); + } else { + extra_player_info_pointer->unk38 = D_80753AA8[D_807FD584]; + } + extra_player_info_pointer->unk10 = D_80753A98[D_807FD584]; + extra_player_info_pointer->unk5C = D_80767CC0; + } else if (!(D_807FD610[cc_player_index].unk2C & A_BUTTON)) { + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk10 = 1; + extra_player_info_pointer->unk38 = D_80753AA8[D_807FD584]; + } + } + } +} + +void func_806E7230(void) { + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG)) { + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk38 = D_80753AC4[D_807FD584]; + func_80614E78(current_actor_pointer, 0x36); + } else { + extra_player_info_pointer->unk38 = D_80753AA8[D_807FD584]; + } + extra_player_info_pointer->unk10 = D_80753A98[D_807FD584]; + extra_player_info_pointer->unk5C = D_80767CC0; + } +} + +void func_806E7338(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + current_actor_pointer->control_state_progress = 3; + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk38 = 300.0f; + func_80614EBC(current_actor_pointer, 0x318); + } else { + extra_player_info_pointer->unk38 = 250.0f; + } + extra_player_info_pointer->unk10 = 0xF; + extra_player_info_pointer->unk5C = D_80767CC0; + } else if (!(D_807FD610[cc_player_index].unk2C & B_BUTTON)) { + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk10 = 1; + extra_player_info_pointer->unk38 = 250.0f; + } + } +} + +void func_806E7484(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + current_actor_pointer->control_state_progress = 3; + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + if (extra_player_info_pointer->unk10 == 0) { + extra_player_info_pointer->unk38 = 300.0f; + func_80614EBC(current_actor_pointer, 0x318); + } else { + extra_player_info_pointer->unk38 = 250.0f; + } + extra_player_info_pointer->unk10 = 0xF; + extra_player_info_pointer->unk5C = D_80767CC0; + } +} + +void func_806E7568(void) { + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk38 = D_80753AC4[D_807FD584]; + func_80614E78(current_actor_pointer, 0x36); + current_actor_pointer->control_state_progress = 3; + extra_player_info_pointer->unk10 = D_80753A98[D_807FD584]; + extra_player_info_pointer->unk5C = D_80767CC0; + } +} + +void func_806E9804(s16 arg0); + +void func_806E7658(void) { + if ((D_807FD610[cc_player_index].unk2C & D_CBUTTONS) && !(D_807FBB64 & 2)) { + func_806E9804(8); + } else { + extra_player_info_pointer->unk12 = current_actor_pointer->z_rotation; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk10 = 0; + extra_player_info_pointer->unk30 = 8.0f; + } +} + +u8 playerCanDive(void) { + return isFlagSet(0x182, FLAG_TYPE_PERMANENT) // Check whether dive barrel is complete + || (D_807FBB64 & 0x10000000) + || (cc_number_of_players > 1) + || gameIsInMysteryMenuMinigameMode(); +} + +extern s16 D_8075386C[]; +extern f32 D_8075389C[]; + +void func_806E7780(void) { + f32 phi_f0; + + if ((D_807FD610[cc_player_index].unk2C & D_CBUTTONS) && !(D_807FBB64 & 2)) { + func_806E9804(8); + return; + } + if (character_change_array[cc_player_index].unk2C0 == 1) { + phi_f0 = D_8075386C[D_807FD584]; + } else { + phi_f0 = D_8075389C[D_807FD584]; + } + if ((D_807FD610[cc_player_index].unk2C & Z_TRIG) && (phi_f0 < current_actor_pointer->distance_from_floor) && playerCanDive()) { + func_806EB0C0(0x3E, NULL, cc_player_index); + func_80608528(current_actor_pointer, 0x10, 0xFF, 0x7F, 1); + } +} + +void func_806E78B8() { + extra_player_info_pointer->unk30 = D_80753B18[D_807FD584]; +} + +void func_806E78E0(void) { + extra_player_info_pointer->unk30 = 1.0f; +} + +void func_806E78F8(void) { + +} + +void func_806E7900(void) { + // TODO: There might be a special aaD type for minecart + // Could also be a RaaD, not sure yet + PlayerAdditionalActorData *PaaD = extra_player_info_pointer->vehicle_actor_pointer->additional_actor_data; + if (current_actor_pointer->control_state == 7) { + if (!(D_807FD610[cc_player_index].unk2A & R_TRIG)) { + if ((D_807FD610[cc_player_index].unk2E < -0x1E) && (current_actor_pointer->animation_state->unk0->unk10 != 0xFB)) { + func_80614E78(current_actor_pointer, 0x81); + current_actor_pointer->control_state = 0xA; // Minecart (Left) + current_actor_pointer->control_state_progress = 0; + PaaD->unk42 = 1; + } else if ((D_807FD610[cc_player_index].unk2E >= 0x1F) && (current_actor_pointer->animation_state->unk0->unk10 != 0xFF)) { + func_80614E78(current_actor_pointer, 0x7D); + current_actor_pointer->control_state = 0xB; // Minecart (Right) + current_actor_pointer->control_state_progress = 0; + PaaD->unk42 = 2; + } + } + } + if (((D_807FD610[cc_player_index].unk2E < 0x1E) && (current_actor_pointer->control_state != 0xA)) || ((D_807FD610[cc_player_index].unk2E >= -0x1D) && (current_actor_pointer->control_state != 0xB))) { + PaaD->unk42 = 0; + switch (current_actor_pointer->control_state) { + case 0xB: + if (current_actor_pointer->control_state_progress == 1) { + func_80614E78(current_actor_pointer, 0x7E); + } else { + func_80614E78(current_actor_pointer, 0x80); + } + current_actor_pointer->control_state = 7; // Minecart (Idle) + current_actor_pointer->control_state_progress = 0; + break; + case 0xA: + if (current_actor_pointer->control_state_progress == 1) { + func_80614E78(current_actor_pointer, 0x82); + } else { + func_80614E78(current_actor_pointer, 0x80); + } + current_actor_pointer->control_state = 7; // Minecart (Idle) + current_actor_pointer->control_state_progress = 0; + break; + } + } +} + +void func_806E7B48(void) { + RaceAdditionalActorData *RaaD = extra_player_info_pointer->vehicle_actor_pointer->RaaD; + if (extra_player_info_pointer->unk1F0 & 8) { + RaaD->unk3E = 4; + } else { + RaaD->unk3E = (D_807FD610[cc_player_index].unk2F * 0.5) + 60.0; + } + func_806E7900(); +} + +// Similar to above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E7C70.s") + +// Huge, probably doable though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E7DF4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E8244.s") + +extern void func_8068E474(void); + +/* +// TODO: Astonishingly close +void func_806E8244(void) { + s8 temp_t4; + Struct807FD610 *phi_v0; + RaceAdditionalActorData *RaaD; + + RaaD = extra_player_info_pointer->vehicle_actor_pointer->additional_actor_data; + if (func_805FCA64()) { + func_8068C350(&func_8068E474, extra_player_info_pointer->vehicle_actor_pointer, 5, RaaD); + } + if ((current_actor_pointer->y_rotation < 0x200) || (current_actor_pointer->y_rotation >= 0xE01)) { + RaaD->unk2 = D_807FD610[cc_player_index].unk2E; + phi_v0 = &D_807FD610[cc_player_index]; + } else if ((current_actor_pointer->y_rotation >= 0x201) && (current_actor_pointer->y_rotation < 0x600)) { + RaaD->unk2 = D_807FD610[cc_player_index].unk2F; + phi_v0 = &D_807FD610[cc_player_index]; + temp_t4 = phi_v0->unk2F; + phi_v0->unk2F = phi_v0->unk2E; + phi_v0->unk2E = temp_t4; + } else if ((current_actor_pointer->y_rotation >= 0x601) && (current_actor_pointer->y_rotation < 0xA00)) { + RaaD->unk2 = -D_807FD610[cc_player_index].unk2E; + phi_v0 = &D_807FD610[cc_player_index]; + phi_v0->unk2E = -phi_v0->unk2E; + phi_v0->unk2F = -phi_v0->unk2F; + } else { + RaaD->unk2 = -D_807FD610[cc_player_index].unk2F; + phi_v0 = &D_807FD610[cc_player_index]; + temp_t4 = -phi_v0->unk2E; + phi_v0->unk2E = -phi_v0->unk2F; + phi_v0->unk2F = temp_t4; + } + if (phi_v0->unk2E < -0x1E) { + extra_player_info_pointer->unk23C = 0x28; + RaaD->unk42 = 1; + return; + } + if (phi_v0->unk2E >= 0x1F) { + extra_player_info_pointer->unk23C = 0x28; + RaaD->unk42 = 2; + return; + } + if (extra_player_info_pointer->unk23C != 0) { + extra_player_info_pointer->unk23C--; + return; + } + RaaD->unk42 = 0; +} +*/ + +void func_806E84A4(void) { + RaceAdditionalActorData *RaaD = extra_player_info_pointer->vehicle_actor_pointer->RaaD; + RaaD->unk3E = 0x14; +} + +void func_806E84C0(void) { + RaceAdditionalActorData *RaaD = extra_player_info_pointer->vehicle_actor_pointer->RaaD; + RaaD->unk3E = 0x64; + if (extra_player_info_pointer->unk23C) { + extra_player_info_pointer->unk23C--; + } +} + +void func_806E84F8(void) { + if (!(D_807FD610[cc_player_index].unk2A & (A_BUTTON | B_BUTTON | Z_TRIG))) { + RaceAdditionalActorData *RaaD = extra_player_info_pointer->vehicle_actor_pointer->RaaD; + RaaD->unk3E = 0x32; + } +} + +// ActorAnimationState->unk0, possible datatype conflicts, not sure what is passed into arg0 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E854C.s") + +void func_806E8724(Actor *arg0, RaceAdditionalActorData *arg1) { + f32 temp_f0; + s32 temp_t1; + s32 phi_a0; + + if ((arg1->unk45 == 0) && (arg1->unk34 == 2)) { + temp_t1 = D_807FD610[cc_player_index].unk2F < -0x14; + phi_a0 = D_807FD610[cc_player_index].unk2E >= 0 ? 1 : -1; + temp_f0 = D_807FD610[cc_player_index].unk30; + temp_f0 = MIN(80.0f, temp_f0) * phi_a0 * D_8075D334; + arg1->unkC = temp_f0; + arg1->unkC = temp_f0 * D_80750FFC; + if (arg1->unk20 == 0) { + arg1->unk20 = (arg0->unkB8 < D_80750FF8) & temp_t1; + return; + } else { + arg1->unk20 = temp_t1; + return; + } + } + arg1->unk20 = 0; + arg1->unkC = 0.0f; +} + +void func_806E884C(void) { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + func_806E8724(vehicle, vehicle->additional_actor_data); + } +} + +void func_806E8880() { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + PaaD0 *paad = vehicle->PaaD0; + paad->unk8 = D_80751000; + } +} + +void func_806E88AC() { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + PaaD0 *paad = vehicle->PaaD0; + paad->unk8 = 0.0f; + } +} + +// Actor->animation_state->unk0->stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E88D8.s") + +void func_806E8A8C(void) { + Actor *vehicle; + RaceAdditionalActorData *RaaD; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + RaaD = vehicle->RaaD; + if ((RaaD->unk45 == 0) && (RaaD->unk34 == 2)) { + if (RaaD->unk25 == 0) { + RaaD->unk4 = D_8075D344; + } + } else { + RaaD->unk4 = 0.0f; + } + } +} + +void func_806E8AF0(void) { + Actor *vehicle; + RaceAdditionalActorData *RaaD; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + RaaD = vehicle->RaaD; + if (RaaD->unk25 == 0) { + RaaD->unk4 = 0.0f; + } + } +} + +void func_806E8B28(void) { + Actor *vehicle; + RaceAdditionalActorData *RaaD; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + RaaD = vehicle->RaaD; + if ((RaaD->unk45 == 0) && (RaaD->unk34 == 2)) { + Actor178 *r178 = vehicle->unk178; + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + r178->unk4 = 1; + } + } + } +} + +void func_806E8BA4(void) { + Actor *vehicle; + RaceAdditionalActorData *RaaD; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + RaaD = vehicle->RaaD; + if ((RaaD->unk45 == 0) && (RaaD->unk34 == 2)) { + RaaD->unk10 = 2.0f; + } else { + RaaD->unk10 = 1.0f; + } + } +} + +void func_806E8BFC() { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + RaceAdditionalActorData* RaaD = vehicle->RaaD; + RaaD->unk10 = 1.0f; + } +} + +// TODO: Actor->animation_state->unk0->unk10 +// TODO: Pointer to something at aaD->unk30, size at least 0x154 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E8C2C.s") + +void func_806E8D54(void) { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + if (vehicle->RaaD->unk34 && (vehicle->RaaD->unk34 < 3) && !vehicle->RaaD->unk45) { + RaceActor178 *r178 = vehicle->race178; + vehicle->RaaD->unk4 = r178->unk14 + D_8075D348; + } + } +} + +void func_806E8DB4(void) { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + if ((vehicle->RaaD->unk34) && (vehicle->RaaD->unk34 < 3) && !vehicle->RaaD->unk45) { + RaceActor178 *r178 = vehicle->race178; + vehicle->RaaD->unk4 = r178->unk14; + } + } +} + +void func_806E8E00(void) { + Actor *vehicle; + RaceAdditionalActorData *RaaD; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle) { + RaaD = vehicle->additional_actor_data; + if (RaaD->unk45 == 0 && RaaD->unk34 == 2 && (D_807FD610[cc_player_index].unk2C & A_BUTTON)) { + RaaD->unk29 = 1; + } + } +} + +void func_806E8E78(void) { + if (current_actor_pointer->control_state == 7 && !(D_807FD610[cc_player_index].unk2A & R_TRIG)) { + func_80614E78(current_actor_pointer, 0x7F); + current_actor_pointer->control_state = 8; + current_actor_pointer->control_state_progress = 0; + } +} + +void func_806E8F04(void) { + if (current_actor_pointer->control_state_progress == 1) { + func_80614E78(current_actor_pointer, 0x7B); + } else { + func_80614E78(current_actor_pointer, 0x80); + } + current_actor_pointer->control_state = 7; + current_actor_pointer->control_state_progress = 0; +} + +void func_806E8F68(void) { + if ((D_807FD610[cc_player_index].unk2C & A_BUTTON) && (!(D_807FD610[cc_player_index].unk2A & R_TRIG))) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) { + current_actor_pointer->control_state = 9; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807537E0[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + func_80614E78(current_actor_pointer, 0x7C); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E9070.s") + +/* +extern s16 D_80750338; + +// TODO: D_80767CC0 might be a struct.280 access, or an array? idk +void func_806E9070(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if (((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU) && extra_player_info_pointer->vehicle_actor_pointer->RaaD->unk0 == 0) { + extra_player_info_pointer->vehicle_actor_pointer->y_velocity = D_80750338; + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + func_80614E78(current_actor_pointer, 0x7C); + if (current_actor_pointer->unk58 == 2) { + func_80614EBC(extra_player_info_pointer->vehicle_actor_pointer, 0x294); + } else { + func_80614EBC(extra_player_info_pointer->vehicle_actor_pointer, 0x293); + } + } +} +*/ + +// Fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E918C.s") + +void func_806E9388(void) { + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + current_actor_pointer->control_state = 0x80; // Enguarde Attacking (surface) + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0x316); + } +} + +void func_806E93F8(void) { + if (D_807FD610[cc_player_index].unk2C & B_BUTTON) { + current_actor_pointer->control_state = 0x81; // Enguarde Attacking + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0x316); + } +} + +void func_806E9468(void) { + if (D_807FD610[cc_player_index].unk2C & (A_BUTTON | Z_TRIG)) { + extra_player_info_pointer->unk12 = D_807539EC[D_807FD584]; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk10 = D_807539DC[D_807FD584]; + current_actor_pointer->control_state = 0x7F; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->control_state_progress = 1; + if (current_actor_pointer->y_velocity > 0.0f) { + current_actor_pointer->y_velocity = 0.0f; + } + func_80614EBC(current_actor_pointer, 0x318); + func_80608528(current_actor_pointer, 0x10, 0xFF, 0x7F, 1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E9580.s") + +void func_806E9804(s16 arg0) { + // Do we have the camera and are we pressing C-Down + if (isFlagSet(0x179, FLAG_TYPE_PERMANENT) && (D_807FD610[cc_player_index].unk2C & D_CBUTTONS)) { + func_806E9D1C(arg0, 0xB, 0); + } +} + +void func_806E9874(void) { + if (!(D_807FBB64 & 2) && current_character_index[cc_player_index] < 5) { + func_806E9804(6); + character_change_array[cc_player_index].fov_y = 45.0f; + } +} + +void func_806E98F8(void) { + // Are we pressing Z and C-Down? + if ((D_807FD610[cc_player_index].unk2A & Z_TRIG) && (D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == D_CBUTTONS) { + func_806E9874(); + } +} + +void func_806E9964(PlayerAdditionalActorData *arg0) { + s32 phi_v0 = current_actor_pointer->control_state == 5 || current_actor_pointer->control_state == 0x65; + if ((D_807FD610[cc_player_index].unk2A & Z_TRIG) && (D_807FD610[cc_player_index].unk2C & D_CBUTTONS)) { + if (phi_v0) { + func_806E9D1C(7, 3, 0); + } else { + func_806E9D1C(5, 3, 0); + } + } else { + func_806EAB44(current_actor_pointer, phi_v0); + } + func_806F8D58(6, 1); + func_806F8D58(0xC, 1); + arg0->unk1F0 &= ~0x8000; +} + +void func_806E9A5C(void) { + if (!(extra_player_info_pointer->unk1F0 & 0x8000) && (D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == U_CBUTTONS) { + func_806E9964(extra_player_info_pointer); + } +} + +void func_806E9ACC(void) { + if (!(extra_player_info_pointer->unk1F0 & 0x8000) && (D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == D_CBUTTONS) { + func_806E9964(extra_player_info_pointer); + } +} + +void func_806E9B3C(void) { + if (!(extra_player_info_pointer->unk1F0 & 0x8000) && (D_807FD610[cc_player_index].unk2C & D_CBUTTONS)) { + func_806E9964(extra_player_info_pointer); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E9BA8.s") + +/* +// TODO: Regalloc +void func_806E9BA8(s32 arg0) { + s32 temp = cc_player_index; + if ((D_807FD610[temp].unk2C & B_BUTTON) && !(extra_player_info_pointer->unk1F0 & 0x8000) && func_806F8AD4(6, temp) > 0) { + playSound(0x263, 0x7FFF, 63.0f, 1.0f, 0xA, 0); + current_actor_pointer->control_state = arg0; + current_actor_pointer->control_state_progress = 0; + func_806F91B4(6, cc_player_index, -1); + func_8065A708(character_change_array[cc_player_index].look_at_eye_x, + character_change_array[cc_player_index].look_at_eye_y, + character_change_array[cc_player_index].look_at_eye_z, + character_change_array[cc_player_index].look_at_at_x, + character_change_array[cc_player_index].look_at_at_y, + character_change_array[cc_player_index].look_at_at_z, + 0.0f, + 1, + 0xFF, + 0xFF, + 0xFF); + } +} +*/ + +void func_806E9CDC(void) { + func_806E9BA8(0x64); +} + +void func_806E9CFC(void) { + func_806E9BA8(0x65); +} + +s32 func_806E9D1C(s16 arg0, u8 arg1, u8 arg2) { + if (((cc_number_of_players < 2) || (D_80750AB8 != 1)) && (D_807FD888 == 0.0f) && (current_actor_pointer->unkE0 == 0.0f)) { + func_806EB178(cc_player_index, arg1, arg2, 0); + func_806EB0C0(arg0, NULL, cc_player_index); + current_actor_pointer->unkB8 = 0.0f; + return TRUE; + } + return FALSE; +} + +// 0x34 struct array, fiddly (switch case?) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E9DE0.s") + +// 0x34 struct array, fiddly (bitfield shenanigans? << 0 >= 0) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E9ECC.s") + +// 0x34 struct array, same as above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806E9F8C.s") + +void func_806EA04C(void) { + if (D_807FD610[cc_player_index].unk2C & U_CBUTTONS) { + func_806E9D1C(7, 3, 0); + } +} + +void func_806EA0A4(void) { + PlayerAdditionalActorData *PaaD; + u16 temp; + u8 phi_a0; + + PaaD = extra_player_info_pointer->unk104->PaaD; + if ((D_807FBB64 & 1) && !(D_807FBB68 & 2)) { + phi_a0 = 2; + } else { + phi_a0 = 3; + } + if ((PaaD->unkEF) && ((D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == D_CBUTTONS) && ((PaaD->unkEE == phi_a0) || (PaaD->unkFC == 0))) { + PaaD->unkF0 = PaaD->unkEF; + if (PaaD->unkEF < phi_a0) { + PaaD->unkEF++; + } else { + PaaD->unkEF = 1; + } + func_8062217C(extra_player_info_pointer->unk104, PaaD->unkEF); + PaaD->unkEE = PaaD->unkEF; + if ((PaaD->unkEF != PaaD->unkF0)) { + temp = PaaD->unk8; + if ((((temp == 0)) || (temp >= 0x96)) && (PaaD->unkF3 != 2)) { + playSound(0x27, 0x7FFF, 63.0f, 1.0f, 0, 0); + } + } + PaaD->unkF1 = 0xB; + PaaD->unkF6 = 0xF; + } +} + +void func_806EA200(void) { + PlayerAdditionalActorData *PaaD = extra_player_info_pointer->unk104->PaaD; + if ((D_807FD610[cc_player_index].unk2C & L_CBUTTONS) && (PaaD->unkF1 < 3)) { + PaaD->unkB0 -= 0x2D; + PaaD->unkF1 = 0xB; + } +} + +void func_806EA26C(void) { + PlayerAdditionalActorData *PaaD = extra_player_info_pointer->unk104->PaaD; + if ((D_807FD610[cc_player_index].unk2C & R_CBUTTONS) && (PaaD->unkF1 < 3)) { + PaaD->unkB0 += 0x2D; + PaaD->unkF1 = 0xB; + } +} + +f32 func_806EA2D8(void) { + return D_807FD610[cc_player_index].unk2A & Z_TRIG ? D_8075D358 : 1; +} + +void func_806EA334(void) { + f32 temp_f2; + f32 phi_f0; + + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG) && !(D_807FD610[cc_player_index].unk2A & L_CBUTTONS) && current_actor_pointer->control_state == 2) { + phi_f0 = current_map == MAP_DK_ISLES_OVERWORLD ? 15.0 : 13.0; + temp_f2 = character_change_array[cc_player_index].fov_y - 1.5f; + if (phi_f0 < temp_f2) { + character_change_array[cc_player_index].fov_y = temp_f2; + func_80604CBC(current_actor_pointer, 0x1F0, 0, 0, 0, 0xFF, 1.0f, -1); + } else { + character_change_array[cc_player_index].fov_y = phi_f0; + func_80605314(current_actor_pointer, 0); + } + } +} + +void func_806EA460(void) { + f32 temp_f0; + if (!(D_807FD610[cc_player_index].unk2A & Z_TRIG) && !(D_807FD610[cc_player_index].unk2A & R_CBUTTONS) && current_actor_pointer->control_state == 2) { + temp_f0 = character_change_array[cc_player_index].fov_y + 1.5f; + if (temp_f0 < D_8075D360) { + character_change_array[cc_player_index].fov_y = temp_f0; + func_80604CBC(current_actor_pointer, 0x1F0, 0, 0, 0, 0xFF, 1.0f, -1); + } else { + character_change_array[cc_player_index].fov_y = 45.0f; + func_80605314(current_actor_pointer, 0); + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806EA568.s") + +/* +// TODO: Regalloc +void func_806EA568(void) { + // TODO: Switch case? + // TODO: Bitfield syntax? + if (((D_807FD610[cc_player_index].unk2A & (L_CBUTTONS | R_CBUTTONS)) != L_CBUTTONS) + && ((D_807FD610[cc_player_index].unk2A & (L_CBUTTONS | R_CBUTTONS)) != R_CBUTTONS)) { + func_80605314(current_actor_pointer, 0); + } +} +*/ + +void func_806EA5CC(void) { + if (func_806E9580()) { + func_806EAB44(current_actor_pointer, 1); + } +} + +void func_806EA600(void) { + func_806EA568(); + func_806EA5CC(); +} + +// 0x34 struct, fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_CEAE0/func_806EA628.s") + +void func_806EA7E8(void) { + if ((D_807FD610[cc_player_index].unk2C & (A_BUTTON | B_BUTTON)) == A_BUTTON) { + func_806EAB44(current_actor_pointer, 0); + } +} + +void func_806EA844(void) { + if ((D_807FD610[cc_player_index].unk2C & (A_BUTTON | B_BUTTON)) == B_BUTTON) { + func_806EAB44(current_actor_pointer, 0); + } +} + +void func_806EA8A0(void) { + if ((D_807FD610[cc_player_index].unk2C & (A_BUTTON | B_BUTTON)) == A_BUTTON) { + func_806EAB44(current_actor_pointer, 1); + } +} + +void func_806EA8FC(void) { + if ((D_807FD610[cc_player_index].unk2C & (A_BUTTON | B_BUTTON)) == B_BUTTON) { + func_806EAB44(current_actor_pointer, 1); + } +} + +void func_806EA958(void) { + if ((D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == U_CBUTTONS) { + func_806EAB44(current_actor_pointer, 0); + } +} + +void func_806EA9B4(void) { + // TODO: Bitfield syntax? + if ((D_807FD610[cc_player_index].unk2A & Z_TRIG) && (D_807FD610[cc_player_index].unk2C & D_CBUTTONS)) { + func_806E9874(); + } else if ((D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == D_CBUTTONS) { + func_806EAB44(current_actor_pointer, 0); + } +} + +void func_806EAA44(void) { + if ((D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == U_CBUTTONS) { + func_806EAB44(current_actor_pointer, 1); + } +} + +void func_806EAAA0(void) { + if ((D_807FD610[cc_player_index].unk2A & Z_TRIG) && (D_807FD610[cc_player_index].unk2C & D_CBUTTONS) && !(D_807FBB64 & 2)) { + func_806E9804(8); + return; + } + if ((D_807FD610[cc_player_index].unk2C & (U_CBUTTONS | D_CBUTTONS)) == D_CBUTTONS) { + func_806EAB44(current_actor_pointer, 1); + } +} + +void func_806EAB44(Actor *arg0, u8 arg1) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + if ((PaaD->unk1F4 & 0x10) == 0) { + playSound(0x27, 0x7FFF, 63.0f, 1.0f, 0, 0); + } + if (arg1 != 0) { + if (current_character_index[cc_player_index] == 7) { + if ((arg0->unkAC - arg0->y_position) < 20.0f) { + arg0->control_state = 0x7E; + arg0->control_state_progress = 0; + } else { + arg0->control_state = 0x7F; + arg0->control_state_progress = 0; + } + } else { + arg0->control_state = 0x4F; + arg0->control_state_progress = 3; + } + } else { + arg0->control_state = 1; + arg0->control_state_progress = 0; + func_806CFF9C(arg0); + if (arg0->control_state == 0xC) { + arg0->control_state_progress = 0xA; + } + } + if (PaaD->unk8C != 0) { + func_806F0D68(arg0); + } else { + func_806F0C18(arg0); + } + arg0->unkB8 = 0.0f; + arg0->y_rotation = func_8062773C(PaaD->unk104); +} + +void func_806EAC8C() { + Actor178 *temp_v0 = extra_player_info_pointer->vehicle_actor_pointer->unk178; + if (temp_v0->unkE == 5) { + temp_v0->unkE = 0xA; + } +} + +void func_806EACBC() { + Actor178 *temp_v0 = extra_player_info_pointer->vehicle_actor_pointer->unk178; + if (temp_v0->unkE == 5) { + temp_v0->unkE = 0xF; + } +} + +void func_806EACEC(void) { + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + extra_player_info_pointer->unk58 = D_80767CC0; + } + if ((current_actor_pointer->unk6A & 1) && ((D_80767CC0 - extra_player_info_pointer->unk58) < 0xFU)) { + func_806CFECC(); + current_actor_pointer->y_velocity = D_807535CC[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk3C = 0; + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; + func_80608528(current_actor_pointer, 0x309, 0xFF, 0x7F, 0); + } +} + +void func_806EAE04(void) { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if ((vehicle->control_state == 0) && (D_807FD610[cc_player_index].unk2C & B_BUTTON)) { + vehicle->control_state = 1; + } +} + +void func_806EAE60(void) { + // Joystick range check + if ((D_807FD610[cc_player_index].unk2E >= 41) || (D_807FD610[cc_player_index].unk2F >= 41)) { + if (extra_player_info_pointer->unk108 != 0.0f) { + extra_player_info_pointer->unk108 = 0.0f; + extra_player_info_pointer->unk200 = MAX(1, extra_player_info_pointer->unk200 - 5); + return; + } + } + // Joystick range check + if (((D_807FD610[cc_player_index].unk2E < -40) || (D_807FD610[cc_player_index].unk2F < -40)) && extra_player_info_pointer->unk108 == 0.0f) { + extra_player_info_pointer->unk108 = 1.0f; + extra_player_info_pointer->unk200 = MAX(1, extra_player_info_pointer->unk200 - 5); + } +} + +void func_806EAF6C(void) { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (D_807FD610[cc_player_index].unk2C & A_BUTTON) { + switch (vehicle->control_state) { + case 2: + vehicle->control_state = 4; + vehicle->control_state_progress = 0; + break; + case 5: + vehicle->control_state_progress++; + break; + } + } +} + +void func_806EAFEC(void) { + +} + +void func_806EAFF4(void) { + if (D_807FD610[cc_player_index].unk2A & Z_TRIG) { + current_actor_pointer->y_velocity = 0.0f; + } else { + current_actor_pointer->y_velocity = 120.0f; + } +} + +void func_806EB058(void) { + if (D_807FD610[cc_player_index].unk2A & (U_CBUTTONS | D_CBUTTONS)) { + current_actor_pointer->y_velocity = 0.0f; + } else { + current_actor_pointer->y_velocity = -120.0f; + } +} diff --git a/src/global_asm/code_EFDC0.c b/src/global_asm/code_EFDC0.c new file mode 100644 index 00000000..bb30f683 --- /dev/null +++ b/src/global_asm/code_EFDC0.c @@ -0,0 +1,1373 @@ +#include +#include "functions.h" +#include "variables.h" + +u8 func_806C9974(u8, s32); +void func_80687474(Actor*, f32); +void func_80614D48(Actor*, f32, f32); +void func_806CA2AC(); +extern void func_80614D00(Actor*, f32, f32); +void func_80614E78(Actor*, s32); +extern s32 D_807FD6F0[]; +void func_806CD424(s16, f32, f32); +extern void (*action_initiation_function_list[])(void); + +void func_806F8BC4(s32, s32, s32); +void func_80605314(Actor*, u8); +void func_8062217C(Actor*, s32); +void func_80627878(Actor*); +void func_806F0D68(Actor*); +void func_80613AF8(Actor*, s32, f32, f32); +void func_80614D00(Actor*, f32, f32); +void func_8067A784(Actor*, Actor*, s16, f32, s32); +void func_806EEAF8(s16); +void func_80613C48(Actor*, s16, f32, f32); + +extern s16 D_807FD584; +extern s16 D_807539DC[]; +extern s16 D_807539EC[]; +extern f32 D_807531C4[]; +extern f32 D_80753250[]; +extern f32 D_807531FC[]; +extern f64 D_8075D408; +extern u32 D_807FBB68; +extern s16 D_8075380C[]; +extern s16 D_807530B0[]; +extern s16 D_807530B0[]; +extern s16 D_807FD6F2; +extern f32 D_8075D5D8; +extern f32 D_807535CC[]; +extern f64 D_8075D5E0; +extern s32 D_80767CC0; +extern f32 D_80753924[]; +extern f32 D_80753940[]; +extern f32 D_80753908[]; +extern s16 D_807537FC[]; +extern s16 D_8075384C[]; +extern s16 D_8075383C[]; +extern f32 D_807534E4[]; +extern f32 D_80753500[]; +extern s16 D_8075351C[]; +extern f32 D_80753D70[]; +extern f32 D_80753D8C[]; + +u8 func_806EB0C0(s16 arg0, Actor *actor, u8 playerIndex) { + if (character_change_array[playerIndex].action_initiated < arg0) { + character_change_array[playerIndex].action_initiated = arg0; + character_change_array[playerIndex].unk2A0 = actor; + character_change_array[playerIndex].unk2A8 = D_807FD6F0[0]; + character_change_array[playerIndex].unk2AC = D_807FD6F0[1]; + character_change_array[playerIndex].unk2B0 = D_807FD6F0[2]; + if (actor) { + character_change_array[playerIndex].unk2A4 = actor->unk54; + } + return TRUE; + } + return FALSE; +} + +void func_806EB178(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + D_807FD6F0[0] = arg1; + D_807FD6F0[1] = arg2; + D_807FD6F0[2] = arg3; +} + +void func_806EB194(void) { + if (character_change_array[cc_player_index].action_initiated >= 0) { + if (character_change_array[cc_player_index].unk2A0 + && (!func_8067AF44(character_change_array[cc_player_index].unk2A0, &cc_player_index) || character_change_array[cc_player_index].unk2A0->unk54 != character_change_array[cc_player_index].unk2A4)) { + character_change_array[cc_player_index].unk2A0 = NULL; + } + action_initiation_function_list[character_change_array[cc_player_index].action_initiated](); + } + character_change_array[cc_player_index].action_initiated = -1; +} + +void func_806EB2B8(void) { + func_806CFECC(); + current_actor_pointer->control_state = 0x22; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->y_velocity = 100.0f; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk2C = 100.0f; + if (extra_player_info_pointer->unk3C == 0) { + func_806CD424(extra_player_info_pointer->unkA, extra_player_info_pointer->unk4, extra_player_info_pointer->unk38); + } + extra_player_info_pointer->unk2C = 10.0f; + func_80614EBC(current_actor_pointer, 0x17B); +} + +void func_806EB364(void) { + if (current_character_index[cc_player_index] == 6) { + func_806CFF9C(D_807FBB48); + return; + } + current_actor_pointer->control_state = 0x3D; + current_actor_pointer->control_state_progress = 0; + if (extra_player_info_pointer->unk4E == 0x22) { + func_80614EBC(current_actor_pointer, 0x131); + return; + } + func_80614E78(current_actor_pointer, 0xD); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EB400.s") + +/* +// TODO: Closer now, bottom might not be a switch case, aaa +int func_806EB400(Actor *arg0) { + int phi_v1; + u8 phi_a1; + PlayerAdditionalActorData *PaaD = arg0->PaaD; + + phi_v1 = PaaD->unkD4 == 0 + || character_change_array[cc_player_index].action_initiated == 0x3F; + + if ((current_character_index[cc_player_index] == 7) || PaaD->unk1F0 & 0x8000) { + return 0; + } + switch (arg0->control_state) { + case 0x34: + case 0x36: + phi_a1 = phi_v1 & 1; + break; + default: + phi_a1 = 0; + } + return phi_a1; +} +*/ + +void func_806EB4B4(void) { + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0x3BC); +} + +void func_806EB4F8(void) { + current_actor_pointer->control_state = 0x5F; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk1A3 = 0; + func_80614E78(current_actor_pointer, 0x4A); +} + +void func_806EB544(void) { + s32 phi_a3; + + phi_a3 = 2; + if (func_806F8AD4(3, extra_player_info_pointer->unk1A4)) { + phi_a3 = 3; + } + func_806F8BC4(phi_a3, 0, 0); + current_actor_pointer->control_state = 0x60; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk1A3 = 0; + func_80614E78(current_actor_pointer, 0x4B); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EB5C8.s") + +void func_806EB6D8(void) { + extra_player_info_pointer->unk4C = -1; + extra_player_info_pointer->unk38 = 170.0f; + current_actor_pointer->control_state = 0x3F; + current_actor_pointer->control_state_progress = 0; + extra_player_info_pointer->unk4E = 0; + func_80614EBC(current_actor_pointer, 0x14F); +} + +void func_806EB744(void) { + s32 temp_t6; // TODO: Is this needed still? Padding + s16 phi_v1; + PlayerAdditionalActorData *PaaD; + + PaaD = extra_player_info_pointer->unk104->PaaD; + phi_v1 = PaaD->unkB8; + if (PaaD->unkEF != 0) { + PaaD->unkF0 = PaaD->unkEF; + phi_v1 = 0x80; + } + func_80627878(extra_player_info_pointer->unk104); + func_8062217C(extra_player_info_pointer->unk104, 0); + PaaD->unkF3 = character_change_array[cc_player_index].unk2A8; + if (PaaD->unkF3 == 3) { + func_80605314(D_807FBB48, 0); + playSound(0x26, 0x7FFF, 63.0f, 1.0f, 0, 0); + if (character_change_array[cc_player_index].unk2AC != 0) { + func_806F0D68(D_807FBB48); + } + } + PaaD->unkBC = 0x80; + extra_player_info_pointer->unk104->distance_from_floor = phi_v1; + PaaD->unkB8 = phi_v1; + PaaD->unkB2 = D_807FBB48->y_rotation + 0x800; + D_807FBB48->unkB8 = 0.0f; + D_807FBB48->unk6A |= 0x2000; +} + +void func_806EB8CC(void) { + func_806EB744(); + D_807FBB48->control_state = 2; + D_807FBB48->control_state_progress = 0; + D_807FBB48->control_state_progress = 0xA; + if (extra_player_info_pointer->unk8C != 0) { + func_80614EBC(D_807FBB48, 0x23); + } else { + func_80614EBC(D_807FBB48, 0x13); + } + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk38 = 0.0f; +} + +void func_806EB964(void) { + playSound(0x1B9, 0x7FFF, 63.0f, 1.0f, 0xA, 0); + func_806EB744(); + D_807FBB48->control_state = 4; + D_807FBB48->control_state_progress = 0; + D_807FBB48->control_state_progress = 0xA; + func_80614EBC(D_807FBB48, 0x13); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk38 = 0.0f; + func_806F8BC4(6, 1, 0); +} + +void func_806EBA04(void) { + func_806EB744(); + D_807FBB48->control_state = 3; + D_807FBB48->control_state_progress = 0; + D_807FBB48->control_state_progress = 0xA; + func_80614EBC(D_807FBB48, 0); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk38 = 0.0f; +} + +void func_806EBA74(void) { + func_806EB744(); + D_807FBB48->control_state = 5; + D_807FBB48->control_state_progress = 0; + D_807FBB48->control_state_progress = 0xA; + func_80614EBC(D_807FBB48, 0); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk38 = 0.0f; + func_806F8BC4(6, 1, 0); +} + +void func_806EBAF4(void) { + current_actor_pointer->control_state = 0x4F; + current_actor_pointer->control_state_progress = 2; + func_80614E78(current_actor_pointer, 0x34); + extra_player_info_pointer->unk50 = 0; +} + +void func_806EBB44(void) { + global_properties_bitfield |= 0x4000; + D_807FBB48->control_state = 1; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + func_80614D48(D_807FBB48, 0.0f, 0.0f); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; +} + +void func_806EBBD0(void) { + D_807FBB48->control_state = 6; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + func_80614D48(D_807FBB48, 0.0f, 0.0f); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; + D_807FBB48->object_properties_bitfield &= -5; +} + +void func_806EBC60(void) { + D_807FBB48->control_state = 0x6B; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + func_80614D48(D_807FBB48, 0.0f, 0.0f); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; + D_807FBB48->object_properties_bitfield &= -5; +} + +void func_806EBCF0(void) { + D_807FBB48->control_state = 7; + D_807FBB48->control_state_progress = 0; + func_80614E78(D_807FBB48, 0x7A); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; + extra_player_info_pointer->vehicle_actor_pointer = character_change_array[cc_player_index].unk2A0; + D_807FBB48->object_properties_bitfield &= ~0x40000; + D_807FBB48->unkB8 = 0.0f; +} + +void func_806EBDAC(void) { + extra_player_info_pointer->unk1F0 |= 8; +} + +void func_806EBDC4(void) { + D_807FBB48->control_state = 0x69; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + func_80614D48(D_807FBB48, 0, 0); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; + D_807FBB48->object_properties_bitfield &= ~0x1000000; + extra_player_info_pointer->vehicle_actor_pointer = character_change_array[cc_player_index].unk2A0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EBE8C.s") + +/* +// TODO: Incorrect order of operation for loading function params for the call after the if statement +void func_80026004(Actor178*, s32, f32); + +void func_806EBE8C(void) { + Actor *vehicle; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle->control_state < 3) { + func_80026004(vehicle->unk178, 0x1E, 1.0f); + } +} +*/ + +void func_806EBED0(void) { + extra_player_info_pointer->vehicle_actor_pointer->y_velocity += 200.0f; + if (extra_player_info_pointer->vehicle_actor_pointer->y_velocity > 200.0f) { + extra_player_info_pointer->vehicle_actor_pointer->y_velocity = 200.0f; + } + func_8072DB68(3); +} + +void func_806EBF34(void) { + Actor *vehicle = extra_player_info_pointer->vehicle_actor_pointer; + vehicle->y_velocity += 300.0f; + func_8072DB68(3); +} + +void func_806EBF74(void) { + func_806F1250(D_807FBB48); + extra_player_info_pointer->unk1FE = character_change_array[cc_player_index].unk2A8; +} + +void func_806EBFD0(void) { + func_80614EBC(D_807FBB48, 0x1A); + D_807FBB48->control_state = 0x78; + D_807FBB48->control_state_progress = 0; +} + +void func_806EC014(void) { + func_806CF42C(current_actor_pointer); + func_806CFF9C(current_actor_pointer); +} + +void func_806EC044(void) { + f32 sp24; + + sp24 = 1.0f; + func_806F0C18(current_actor_pointer); + D_807FBB48->control_state = 0x6C; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0x3B); + if (current_character_index[0] == 0) { + sp24 = 0.5f; + } + func_80614D00(D_807FBB48, sp24, 0.0f); + func_80672C30(D_807FBB48); + // Optimization: Weird that they didn't reuse the result of the func_80659470 call + D_807FBB48->x_position = D_807F6000[func_80659470(D_807FBB48->unk10C)].x_position; + D_807FBB48->y_position = D_807F6000[func_80659470(D_807FBB48->unk10C)].y_position + 5.0f; + D_807FBB48->z_position = D_807F6000[func_80659470(D_807FBB48->unk10C)].z_position; + D_807FBB48->x_rotation = 0; + D_807FBB48->z_rotation = 0; + playCutscene(D_807FBB48, 0, 1); + func_806F8BC4(0, 1, 0); +} + +void func_806EC1A8(void) { + Actor *temp_a0; + Actor *temp_a0_2; + PlayerAdditionalActorData *temp_v0; + s16 phi_v0; + + temp_v0 = extra_player_info_pointer->unk104->additional_actor_data; + temp_v0->unkAC |= 4; + D_807FBB48->control_state = 0x6D; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; + D_807FBB48->object_properties_bitfield &= -2; + if (current_map == MAP_GALLEON_SEAL_RACE) { + D_807FBB48->noclip_byte = 1; + } + extra_player_info_pointer->vehicle_actor_pointer = character_change_array[cc_player_index].unk2A0; + func_80613C48(D_807FBB48, D_807FBB48->unk58 == 2 ? 0x53 : 0x1C7, 0, 0); +} + +void func_806EC2CC(void) { + Actor *vehicle; + + D_807FBB48->control_state = 0x75; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; + D_807FBB48->object_properties_bitfield &= -2; + extra_player_info_pointer->vehicle_actor_pointer = character_change_array[cc_player_index].unk2A0; + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + func_8067B238(D_807FBB48, vehicle, vehicle->animation_state->scale_x); + D_807FBB48->noclip_byte = 1; + func_80613C48(D_807FBB48, 0x22A, 0, 0); +} + +void func_806EC3BC(void) { + extra_player_info_pointer->unk12 = D_807539EC[D_807FD584]; + extra_player_info_pointer->unk14 = current_actor_pointer->y_rotation; + extra_player_info_pointer->unk10 = D_807539DC[D_807FD584]; + current_actor_pointer->control_state = 0x4F; + current_actor_pointer->control_state_progress = 1; + if (current_actor_pointer->y_velocity > 0.0f) { + current_actor_pointer->y_velocity = 0.0f; + } + func_80614E78(current_actor_pointer, 0x36); + func_80613AF8(current_actor_pointer, 0x31, 0, 8.0f); + func_80614D00(current_actor_pointer, 0.5f, 0); +} + +// Doable, big project though +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EC4AC.s") + +void func_806EC708(void) { + D_807FBB48->control_state = 0x51; + D_807FBB48->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_80753908[D_807FD584]; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + extra_player_info_pointer->unk2C = D_80753924[D_807FD584]; + extra_player_info_pointer->unk30 = D_80753940[D_807FD584]; + func_80614E78(D_807FBB48, 0x3E); + func_80614D00(current_actor_pointer, 1.0f, 0); + extra_player_info_pointer->unk58 = D_80767CC0 - 0x1E; +} + +void func_806EC800(void) { + D_807FBB48->control_state = 0x50; + D_807FBB48->control_state_progress = 0; + current_actor_pointer->y_velocity = -10.0f; + extra_player_info_pointer->unk50 = 0; + if (current_actor_pointer->unkB8 < D_807531C4[D_807FD584]) { + current_actor_pointer->unkB8 = current_actor_pointer->unkB8; + } else { + current_actor_pointer->unkB8 = D_807531C4[D_807FD584]; + } + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + func_80614E78(D_807FBB48, 0x3C); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EC8C4.s") + +void func_806EC994(void) { + func_80614E78(D_807FBB48, 8); + func_80614D00(D_807FBB48, 1.0f, 0); + func_80613AF8(D_807FBB48, 0x2E, 0, 6.0f); + D_807FBB48->control_state = 0x46; + D_807FBB48->control_state_progress = 0; + extra_player_info_pointer->unk38 = D_807534E4[D_807FD584]; + extra_player_info_pointer->unk2C = D_80753500[D_807FD584]; + extra_player_info_pointer->unk48 = D_8075351C[D_807FD584]; + extra_player_info_pointer->unk4C = -1; +} + +void func_806ECA74(void) { + current_actor_pointer->control_state = 0x24; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0x1B2); + extra_player_info_pointer->unkC8 = 0x32; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806ECAC4.s") + +/* +// TODO: PaaD->unkF0 is float? +void func_806ECAC4(void) { + Actor *temp_v0; + PlayerAdditionalActorData *temp_v1; + f32 phi_f0; + + if (character_change_array[cc_player_index].unk2C0 == 1) { + phi_f0 = D_80753D70[D_807FD584]; + } else { + phi_f0 = D_80753D8C[D_807FD584]; + } + D_807FBB48->control_state = 0x5B; + D_807FBB48->control_state_progress = 0; + extra_player_info_pointer->unk10C = phi_f0; + D_807FBB48->y_position = extra_player_info_pointer->unkF0 - extra_player_info_pointer->unk10C; + temp_v0 = D_807FBB48; + D_807FBB48->unkEE = D_807FBB48->unkF4 + 0x14; + D_807FBB48->y_velocity = 0.0f; + func_80614E78(D_807FBB48, 0x75); + func_80614D90(D_807FBB48); +} +*/ + +void func_806ECBD4(void) { + D_807FBB48->unk6A |= 0x40; + D_807FBB48->unk64 &= -0x2001; + D_807FBB48->control_state = 0x57; + D_807FBB48->control_state_progress = 0; + func_80614E78(D_807FBB48, 0x69); + func_80614D90(D_807FBB48); +} + +void func_806ECC48(void) { + void *sp1C = extra_player_info_pointer->unk104->additional_actor_data; + D_807FBB48->unk6A |= 0x40; + D_807FBB48->unk64 &= -0x2001; + D_807FBB48->control_state = 0x59; + D_807FBB48->control_state_progress = 0; + func_80614E78(D_807FBB48, 0x70); + func_80614D90(D_807FBB48); + func_8061F164(sp1C, 0x14); +} + +void func_806ECCDC(void) { + void *temp_a2; + + temp_a2 = extra_player_info_pointer->unk104->additional_actor_data; + current_actor_pointer->control_state = 0x17; + current_actor_pointer->control_state_progress = 0; + if ((D_807FBB68 & 2) != 0) { + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584] * D_8075D408; + } else { + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584]; + } + D_807FBB48->unkB8 = extra_player_info_pointer->unk124; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk3C = 0xA; + func_80614E78(current_actor_pointer, 0x10); + func_8061F164(temp_a2, 0x14); +} + +void func_806ECDD4(void) { + if (func_806EB400(D_807FBB48)) { + func_806EEAF8(D_807FBB68 & 2 ? 0 : 1); + } +} + +void func_806ECE2C(void) { + if ((cc_number_of_players >= 2) || (D_807FBB48->unk58 != 6) || (character_change_array[cc_player_index].unk2C0 == 1)) { + D_807FBB48->y_velocity = 260.0f; + func_806CFE7C(); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk48 = 0x64; + func_80614E78(D_807FBB48, 0x1F); + func_80614D00(D_807FBB48, 1.0f, 0); + D_807FBB48->control_state = 0x30; + D_807FBB48->control_state_progress = 0; + func_806CF42C(D_807FBB48); + } +} + +void func_806ECF1C(void) { + D_807FBB48->y_velocity = 260.0f; + func_806CFE7C(); + extra_player_info_pointer->unk50 = 0; + func_80614E78(D_807FBB48, 0x20); + func_80614D00(D_807FBB48, 1.0f, 0); + D_807FBB48->control_state = 0x30; + D_807FBB48->control_state_progress = 0; + func_806CF42C(D_807FBB48); +} + +void func_806ECF9C(void) { + f32 temp_f0; + + extra_player_info_pointer->unk50 = D_807537FC[D_807FD584]; + extra_player_info_pointer->unk68 += D_8075383C[D_807FD584]; + temp_f0 = D_8075384C[D_807FD584]; + if (temp_f0 < extra_player_info_pointer->unk68) { + extra_player_info_pointer->unk68 = temp_f0; + } + D_807FBB48->y_velocity = 0.0f; + extra_player_info_pointer->unk50 = 0; +} + +void func_806ED050(void) { + if ((current_actor_pointer->control_state != 2) && (current_character_index[cc_player_index] == 6)) { + current_actor_pointer->control_state = 0x29; + current_actor_pointer->control_state_progress = 0; + func_80614E78(current_actor_pointer, 0x3F); + extra_player_info_pointer->unk64 = 0; + extra_player_info_pointer->unk68 = D_8075380C[D_807FD584]; + } +} + +void func_806ED0FC(void) { + Actor *temp_v0; + + func_806CA2AC(); + func_806CF398(D_807FBB48); + extra_player_info_pointer->unk8C = 0; + func_806F0C18(current_actor_pointer); + func_80605314(current_actor_pointer, 0); + func_80605314(current_actor_pointer, 1); + func_80614E78(D_807FBB48, 0x21); + temp_v0 = character_change_array[cc_player_index].unk2A0; + if (temp_v0) { + extra_player_info_pointer->unkBC = temp_v0->unk58; + extra_player_info_pointer->unkBE = func_80688E68(character_change_array[cc_player_index].unk2A0); + } else { + extra_player_info_pointer->unkBC = 0; + extra_player_info_pointer->unkBE = -1; + } + if (current_actor_pointer->unk6A & 4) { + D_807FBB48->control_state = 0x43; + D_807FBB48->control_state_progress = 0; + } else { + D_807FBB48->control_state = 0x42; + D_807FBB48->control_state_progress = 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806ED244.s") + +/* +// TODO: Very close, could use a spruce up with some macros/ternaries +// Also missing something with pulling vehicle actor pointer taking an extra instruction +void func_806ED244(void) { + Actor *temp_v0; + Actor *vehicle; + f32 phi_f2; + f32 phi_f2_2; + f32 phi_f2_3; + f32 phi_f8; + f32 phi_f2_4; + f32 phi_f2_5; + + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (vehicle->unkB8 >= 0.0f) { + func_8072DB68(3); + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + } + temp_v0 = character_change_array[cc_player_index].unk2A0; + if (temp_v0) { + if (temp_v0->unkB8 != 0.0f) { + if (temp_v0->unkB8 > 0.0f) { + phi_f2_4 = temp_v0->unkB8; + } else { + phi_f2_4 = -temp_v0->unkB8; + } + vehicle->unkB8 = 2.0 * phi_f2_4; + } else { + if (vehicle->unkB8 > 0.0f) { + phi_f2 = vehicle->unkB8; + } else { + phi_f2 = -vehicle->unkB8; + } + if (phi_f2 < 50.0f) { + vehicle->unkB8 = -50.0f; + } else { + if (vehicle->unkB8 > 0.0f) { + phi_f2_2 = vehicle->unkB8; + } else { + phi_f2_2 = -vehicle->unkB8; + } + vehicle->unkB8 = -phi_f2_2; + } + } + } else { + if (vehicle->unkB8 > 0.0f) { + phi_f2_3 = vehicle->unkB8; + } else { + phi_f2_3 = -vehicle->unkB8; + } + if (phi_f2_3 < 50.0f) { + vehicle->unkB8 = -50.0f; + } else { + if (vehicle->unkB8 > 0.0f) { + phi_f2_5 = vehicle->unkB8; + } else { + phi_f2_5 = -vehicle->unkB8; + } + vehicle->unkB8 = -phi_f2_5; + } + } + func_80614EBC(extra_player_info_pointer->vehicle_actor_pointer, 0x292); + if (D_807FBB48->control_state != 9) { + func_80614E78(D_807FBB48, 0x83); + } +} +*/ + +void func_806ED420(void) { + if (extra_player_info_pointer->unkD4 == 0) { + func_806CA2AC(); + func_8072DB68(3); + switch (current_character_index[cc_player_index]) { + case 3: + func_80608528(D_807FBB48, 0xB9, 0xFF, 0x7F, 0x14); + break; + case 2: + func_80608528(D_807FBB48, 0xD2, 0xFF, 0x7F, 0x14); + break; + } + extra_player_info_pointer->unkD4 = D_807530B0[D_807FD584]; + D_807FBB48->unkB8 /= 2; + } +} + +void func_806ED508(u16 actorBehaviourIndex) { + u16 flagIndex; + s16 sp24; + + switch (actorBehaviourIndex) { + case ACTOR_RAMBI_CRATE: + // Rambi First Time Text (FTT) + flagIndex = 0x16D; + sp24 = 0x23; + break; + case 0x81: // TODO: ACTOR_ENGUARDE_CRATE + // Enguarde First Time Text (FTT) + flagIndex = 0x16E; + sp24 = 0x24; + break; + } + if (!isFlagSet(flagIndex, FLAG_TYPE_PERMANENT)) { + if (actorBehaviourIndex == 0x81) { // TODO: ACTOR_ENGUARDE_CRATE + D_807FBB48->unkB8 = 0.0f; + } + playCutscene(NULL, sp24, 5); + setFlag(flagIndex, TRUE, FLAG_TYPE_PERMANENT); + } +} + +void func_806ED5C0(Actor *arg0) { + u16 flagIndex; + u16 actorBehaviourIndex; + s32 spawnerID; + + actorBehaviourIndex = arg0->unk58; + spawnerID = func_80688E68(arg0); // getSpawnerID(actor) + + switch (current_map) { + case MAP_FACTORY: + if (spawnerID == 0x11) { + return; + } + break; + case MAP_FUNGI: + if (spawnerID == 0x17) { + return; + } + } + + switch (actorBehaviourIndex) { + case ACTOR_HUNKY_CHUNKY_BARREL: + flagIndex = 0x169; // Hunky Chunky First Time Text + break; + case ACTOR_MINI_MONKEY_BARREL: + flagIndex = 0x168; // Mini Monkey First Time Text + break; + case ACTOR_STRONG_KONG_BARREL: + flagIndex = 0x16B; // Strong Kong First Time Text + break; + case ACTOR_ORANGSTAND_SPRINT_BARREL: + flagIndex = 0x16A; // Orangstand Sprint First Time Text + break; + default: + return; + } + + if (!isFlagSet(flagIndex, FLAG_TYPE_PERMANENT)) { + playCutscene(NULL, 0x16, 5); + setFlag(flagIndex, TRUE, FLAG_TYPE_PERMANENT); + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806ED6B0.s") + +void func_806EDFF8(void) { + func_806C8E58(extra_player_info_pointer->unk1EE); + func_806CFF9C(D_807FBB48); +} + +void func_806EE02C(void) { + func_806CF398(D_807FBB48); + D_807FBB48->control_state = 0x55; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE06C(void) { + func_806CF398(D_807FBB48); + D_807FBB48->control_state = 0x56; + D_807FBB48->control_state_progress = 0; + func_80614E78(D_807FBB48, 0x87); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk38 = 0.0f; + extra_player_info_pointer->vehicle_actor_pointer = character_change_array[cc_player_index].unk2A0; +} + +void func_806EE10C(void) { + if (func_806EB400(D_807FBB48)) { + func_806CA2AC(); + if (func_806C9974(cc_player_index, -1)) { + if (D_807FBB48->unk6A & 4) { + func_80614E78(D_807FBB48, 0x29); + } else { + func_80614E78(D_807FBB48, 0x27); + } + D_807FBB48->control_state = 0x36; + D_807FBB48->control_state_progress = 0; + } + extra_player_info_pointer->unkD4 = D_807530B0[D_807FD584]; + } +} + +void func_806EE1C4(void) { + if (extra_player_info_pointer->unk1AC != 0) { + func_8067A784(current_actor_pointer, + extra_player_info_pointer->unk1AC, + D_807FBB48->y_rotation, + current_actor_pointer->y_velocity, + current_actor_pointer->unkB8); + extra_player_info_pointer->unk1AC = 0; + extra_player_info_pointer->unk1B0 = 0; + } + func_806CA2AC(); + func_80614E78(current_actor_pointer, 0x1C); + D_807FBB48->control_state = 0x20; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE26C(void) { + func_806CA2AC(); + func_80614E78(current_actor_pointer, 0x1C); + D_807FBB48->control_state = 0x21; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE2B8(void) { + s32 sp24; + s8 phi_a1; + + sp24 = TRUE; + if (func_806EB400(D_807FBB48)) { + phi_a1 = -1; + func_806CA2AC(); + if (character_change_array[cc_player_index].unk2A0 && character_change_array[cc_player_index].unk2A0->unk58 == 0x123) { + phi_a1 = -2; + } + if (func_806C9974(cc_player_index, phi_a1)) { + sp24 = FALSE; + if (D_807FBB48->unk6A & 4) { + func_80614E78(D_807FBB48, 0x29); + } else { + func_80614E78(D_807FBB48, 0x27); + } + D_807FBB48->control_state = 0x36; + D_807FBB48->control_state_progress = 0; + } else { + func_80608528(current_actor_pointer, 0x16, 0xFF, 0x7F, 0); + func_80614E78(current_actor_pointer, 0x1E); + current_actor_pointer->control_state = 0x20; + current_actor_pointer->control_state_progress = 1; + } + } + if ((extra_player_info_pointer->unkD4 == 0) && (cc_number_of_players < 2)) { + extra_player_info_pointer->unkD4 = D_807530B0[D_807FD584]; + } + if (sp24) { + func_8061F0B0(extra_player_info_pointer->unk104, 0x14, 0x14); + } +} + +void func_806EE454(void) { + s32 sp24; + + sp24 = TRUE; + func_806CA2AC(); + if (func_806EB400(D_807FBB48) && func_806C9974(cc_player_index, -1)) { + sp24 = FALSE; + if ((D_807FBB48->unk6A & 4) != 0) { + func_80614E78(D_807FBB48, 0x29); + } else { + func_80614E78(D_807FBB48, 0x27); + } + D_807FBB48->control_state = 0x36; + D_807FBB48->control_state_progress = 0; + } else { + func_80608528(current_actor_pointer, 0x16, 0xFF, 0x7F, 0); + func_80614E78(current_actor_pointer, 0x1E); + current_actor_pointer->control_state = 0x20; + current_actor_pointer->control_state_progress = 1; + } + if ((extra_player_info_pointer->unkD4 == 0) && (cc_number_of_players < 2)) { + extra_player_info_pointer->unkD4 = D_807530B0[D_807FD584]; + } + if (sp24) { + func_8061F0B0(extra_player_info_pointer->unk104, 0x14, 0x14); + } +} + +void func_806EE5A4(void) { + func_806CA2AC(); + func_80602B60(0x6B, 0); + current_actor_pointer->unk168 = character_change_array[cc_player_index].unk2A8; + func_80614E78(current_actor_pointer, 0x1D); + D_807FBB48->control_state = 0x6F; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE634(void) { + func_806CFE7C(); + func_806CFF1C(current_actor_pointer); +} + +void func_806EE660(void) { + func_806CF398(D_807FBB48); + func_80614E78(D_807FBB48, 0x32); + D_807FBB48->control_state = 0x52; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE6B0(void) { + func_806CF398(D_807FBB48); + func_80614E78(D_807FBB48, 0x86); + D_807FBB48->control_state = 0x53; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE700(void) { + func_806CF398(D_807FBB48); + func_806CFF9C(D_807FBB48); + D_807FBB48->control_state = 0x54; + D_807FBB48->control_state_progress = 0; +} + +void func_806EE74C(void) { + if (func_806EB400(D_807FBB48)) { + if ((current_map != MAP_CAVES_BEETLE_RACE) && (current_map != MAP_AZTEC_BEETLE_RACE)) { + func_806EEAF8(0x40); + } else { + PlayerAdditionalActorData *PaaD = extra_player_info_pointer->vehicle_actor_pointer->PaaD; + PaaD->unk45 = 1; + } + } +} + +void func_806EE7B8(void) { + if (func_806EB400(D_807FBB48)) { + func_806EEAF8(D_807FD6F2); + func_806CFE7C(); + } +} + +void func_806EE7F4(void) { + if (D_807FBB68 & 2) { + func_806F1048(D_807FBB48); + func_80602B60(0xC, 0); + } + if ((func_806EB400(D_807FBB48)) && (((D_807FBB68 & 2) == 0) || !func_8061CB50())) { + func_806EEAF8(1); + func_806CFE7C(); + } +} + +void func_806EE878(void) { + if (func_806EB400(D_807FBB48)) { + extra_player_info_pointer->unkDC = character_change_array[cc_player_index].unk2A0; + if (!character_change_array[cc_player_index].unk2A0) { + func_80687474(D_807FBB48, 3.2f); + } + func_806EEAF8(1); + func_806CFE7C(); + func_80697184(); + } +} + +void func_806EE924(void) { + if (func_806EB400(D_807FBB48)) { + extra_player_info_pointer->unkDC = character_change_array[cc_player_index].unk2A0; + func_806EEAF8(1); + func_806CFE7C(); + } +} + +void func_806EE994(void) { + if (func_806EB400(current_actor_pointer)) { + extra_player_info_pointer->unkDC = character_change_array[cc_player_index].unk2A0; + current_actor_pointer->noclip_byte = 1; + current_actor_pointer->control_state = 0x34; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0); + func_806C9974(cc_player_index, -0x40); + func_806CFE7C(); + func_80614D00(current_actor_pointer, 0, 0); + } +} + +void func_806EEA5C(void) { + s32 phi_v0; + + if (func_806EB400(D_807FBB48)) { + extra_player_info_pointer->unkDC = character_change_array[cc_player_index].unk2A0; + phi_v0 = 1; + if (extra_player_info_pointer->unkDC && (extra_player_info_pointer->unkDC->unk58 == 0x123)) { + phi_v0 = 2; + } + func_806EEAF8(phi_v0); + } +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EEAF8.s") + +void func_806EF830(void) { + PlayerAdditionalActorData *temp_v0_4; + + switch (D_807FBB48->control_state) { + case 0x36: + case 0x39: + case 0x3A: + case 0x71: + case 0x73: + case 0x74: + break; + default: + func_806CA2AC(); + D_807FBB48->object_properties_bitfield &= ~0x8000; + func_80614E78(D_807FBB48, 0x27); + D_807FBB48->control_state = 0x39; + D_807FBB48->control_state_progress = 0; + extra_player_info_pointer->unk11C = 0x19; + func_8061B610(extra_player_info_pointer->unk104); + if ((current_map != MAP_CAVES_BEETLE_RACE) && (current_map != MAP_AZTEC_BEETLE_RACE)) { + func_806C9974(cc_player_index, -0x40); + return; + } + // TODO: Which aaD type are they actually expecting here? VaaD, RaaD? + temp_v0_4 = extra_player_info_pointer->vehicle_actor_pointer->PaaD; + temp_v0_4->unk45 = 1; + break; + } +} + +void func_806EF944(void) { + if ((func_806EB400(D_807FBB48) != 0) && (D_807FBB48->control_state != 0x3B) && !func_8061CB50()) { + func_806CA2AC(); + func_806CF42C(D_807FBB48); + D_807FBB48->noclip_byte = 1; + func_80614E78(D_807FBB48, 0x2A); + D_807FBB48->control_state = 0x3B; + D_807FBB48->control_state_progress = 0; + func_806C9974(cc_player_index, -0x40); + playCutscene(D_807FBB48, 0xB, 0x85); + D_807FBB48->unkB8 = 0.0f; + } +} + +void func_806EFA08(void) { + extra_player_info_pointer->unk1FC = 1; +} + +void func_806EFA1C(void) { + current_actor_pointer->control_state = 0x6A; // learning_gun + current_actor_pointer->control_state_progress = 0; +} + +s16 func_80665DE0(f32, f32, f32, f32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806EFA3C.s") + +/* +// TODO: How do we deal with D_8075D380, float[3]? +void func_806EFA3C(void) { + ? sp24; + f32 sp1C; + f32 temp_f0; + void *temp_a1; + void *temp_v0; + f32 phi_f0; + + sp24.unk0 = D_8075D380.unk0; + sp24.unk4 = D_8075D380.unk4; + sp24.unk8 = D_8075D380.unk8; + temp_f0 = D_807FBB48->unk4->unk34; + sp1C = temp_f0; + func_80677FA8(0x140, 0xB9); // Spawn potion actor 320 + temp_a1 = D_807FBB48; + phi_f0 = temp_f0; + if (temp_a1->unk58 == 2) { + phi_f0 = temp_f0 * 1.25; + } + func_8067B238(D_807FBB44, temp_a1, phi_f0); + func_80614EBC(D_807FBB44, (sp + ((¤t_character_index)[extra_player_info_pointer->unk1A4] * 2))->unk24); + temp_v0 = D_807FBB44; + temp_v0->unk60 |= 0x40000000; + func_80614E78(D_807FBB48, 0x88); + current_actor_pointer->unk154 = 0x79; + current_actor_pointer->unk155 = 0; +} +*/ + +void func_806EFB4C(void) { + func_80602B60(0x6B, 0); + func_806CA2AC(); + func_806C9F74(D_807FBB48); + func_806CF42C(D_807FBB48); + func_80614E78(D_807FBB48, 0x5B); + D_807FBB48->control_state = 0x70; + D_807FBB48->control_state_progress = 0; + if (D_807FBB48->unkFC) { + D_807FBB48->y_rotation = func_80672A70(D_807FBB48->unkF4, D_807FBB48->unkF6); + } else { + D_807FBB48->y_rotation = func_80665DE0(character_change_array[cc_player_index].look_at_eye_x, + character_change_array[cc_player_index].look_at_eye_z, + D_807FBB48->x_position, + D_807FBB48->z_position); + } + func_80627948(D_807FBB48, 0x15, 0x1F, 5); +} + +void func_806EFC38(void) { + func_806CA2AC(); + func_806CF42C(D_807FBB48); + func_806C9F74(D_807FBB48); + if (D_807FBB48->control_state != 0x6D) { + func_80614E78(D_807FBB48, 0x5B); + D_807FBB48->control_state = 0x71; + D_807FBB48->control_state_progress = 0; + } + D_807FBB48->y_rotation = func_80665DE0(character_change_array[cc_player_index].look_at_eye_x, + character_change_array[cc_player_index].look_at_eye_z, + D_807FBB48->x_position, + D_807FBB48->z_position); + if (current_map == MAP_JAPES_ARMY_DILLO) { + playCutscene(D_807FBB48, 2, 1); + D_807FBB48->control_state_progress = 0xFF; + extra_player_info_pointer->unk23C = 0xFFFF; + } else { + playCutscene(D_807FBB48, 5, 5); + extra_player_info_pointer->unk23C = 0x64; + } +} + +void func_806EFD50(void) { + func_806CA2AC(); + func_806CF42C(D_807FBB48); + func_80614E78(D_807FBB48, 0x5B); + D_807FBB48->control_state = 0x72; + D_807FBB48->control_state_progress = 0; + D_807FBB48->y_rotation = func_80665DE0(character_change_array[cc_player_index].look_at_eye_x, + character_change_array[cc_player_index].look_at_eye_z, + D_807FBB48->x_position, + D_807FBB48->z_position); + playCutscene(D_807FBB48, 0x15, 5); +} + +void func_806EFDFC(void) { + Actor *vehicle; + + func_806C8E58(extra_player_info_pointer->unk1EE); + func_806CF42C(D_807FBB48); + func_806CA2AC(); + D_807FBB48->noclip_byte = 1; + if (D_807FBB48->control_state != 0x7D) { + if (D_807FBB48->unk6A & 4) { + func_80614E78(D_807FBB48, 0x34); + } else if (!(D_807FBB48->unk6A & 2)) { + func_80614E78(D_807FBB48, 0x5D); + } + } + D_807FBB48->control_state = 0x73; + D_807FBB48->control_state_progress = 0; + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (!vehicle || vehicle->unk58 != 0x57) { + D_807FBB48->y_rotation = func_80665DE0(character_change_array[cc_player_index].look_at_eye_x, + character_change_array[cc_player_index].look_at_eye_z, + D_807FBB48->x_position, + D_807FBB48->z_position); + } + D_807FBB48->y_velocity = 0.0f; + extra_player_info_pointer->unk23C = 0x5A; + func_806CFE7C(); +} + +void func_806EFF34(void) { + Actor *vehicle; + + func_806C8E58(extra_player_info_pointer->unk1EE); + func_806CF42C(D_807FBB48); + func_806CA2AC(); + D_807FBB48->noclip_byte = 1; + if (D_807FBB48->control_state != 0x7D) { + if (D_807FBB48->unk6A & 4) { + func_80614E78(D_807FBB48, 0x34); + } else if (!(D_807FBB48->unk6A & 2)) { + func_80614E78(D_807FBB48, 0x5C); + } + } + D_807FBB48->control_state = 0x74; + D_807FBB48->control_state_progress = 0; + vehicle = extra_player_info_pointer->vehicle_actor_pointer; + if (!vehicle || vehicle->unk58 != 0x57) { + D_807FBB48->y_rotation = func_80665DE0(character_change_array[cc_player_index].look_at_eye_x, + character_change_array[cc_player_index].look_at_eye_z, + D_807FBB48->x_position, + D_807FBB48->z_position); + } + D_807FBB48->y_velocity = 0.0f; + extra_player_info_pointer->unk23C = 0x5A; + func_806CFE7C(); +} + +void func_806F006C(void) { + +} + +void func_806F0074(void) { + +} + +void func_806F007C(void) { + current_actor_pointer->control_state = 0x84; + current_actor_pointer->control_state_progress = 0; + func_80614EBC(current_actor_pointer, 0); +} + +void func_806F00BC(void) { + func_806CA2AC(); + extra_player_info_pointer->unk1F0 &= ~0x20; + D_807FBB48->unk132 = 2; + extra_player_info_pointer->unk4C = -1; + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + D_807FBB48->control_state = 0x7A; + D_807FBB48->control_state_progress = 0; +} + +void func_806F014C(void) { + extra_player_info_pointer->unk1F4 |= 8; + func_806CFF9C(D_807FBB48); +} + +void func_806F0184(void) { + func_806CA2AC(); + extra_player_info_pointer->unk1F0 &= ~0x20; + D_807FBB48->control_state = 0x7B; + D_807FBB48->control_state_progress = 0; +} + +void func_806F01D8(void) { + func_806CA2AC(); + func_806F00BC(); + extra_player_info_pointer->vehicle_actor_pointer = character_change_array[cc_player_index].unk2A0; +} + +void func_806F0238(void) { + func_80614E78(D_807FBB48, 9); + D_807FBB48->control_state = 0xC; + D_807FBB48->control_state_progress = 0; +} + +void func_806F027C(void) { + extra_player_info_pointer->unk4C = -1; + extra_player_info_pointer->unk30 = D_80753250[D_807FD584]; + func_806CFE7C(); + if (D_807FBB48->control_state != 0x7C) { + func_806CA2AC(); + D_807FBB48->control_state = 0x7C; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0x13); + func_80677FA8(0x117, 0xC5); // Spawn trap bubble (spider miniboss) actor 279 + D_807FBB44->unk11C = D_807FBB48; + func_806C8D20(D_807FBB48); + } +} + +void func_806F0344(void) { + func_806CFE7C(); + D_807FBB48->control_state = 0x7D; + D_807FBB48->control_state_progress = 0; + D_807FBB48->object_properties_bitfield &= ~4; + func_80677FA8(0x11A, 0x21); // Spawn actor (beaver bother?) + func_80614EBC(D_807FBB44, 0x232); + D_807FBB44->unk11C = D_807FBB48; +} + +// Character Change, Jumptable :( +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_EFDC0/func_806F03C4.s") + +void func_806F0624(void) { + extra_player_info_pointer->unk1F4 |= 0x10; + func_806E9964(extra_player_info_pointer); + D_807FBB48->control_state = 0x83; + D_807FBB48->control_state_progress = 0; + D_807FBB48->object_properties_bitfield |= 0x40000004; + D_807FBB48->object_properties_bitfield &= ~1; +} + +void func_806F06A4(void) { + D_807FBB48->control_state = 0x87; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; +} + +void func_806F0700(void) { + f32 temp_f0; + + D_807FBB48->control_state = 0x88; + D_807FBB48->control_state_progress = 0; + func_80614EBC(D_807FBB48, 0); + temp_f0 = D_8075D5D8; + D_807FBB48->x_position = extra_player_info_pointer->unk22C; + D_807FBB48->y_position = extra_player_info_pointer->unk230; + D_807FBB48->z_position = extra_player_info_pointer->unk234; + D_807FBB48->x_rotation = -0x3E6; + D_807FBB48->animation_state->scale_x = temp_f0; + D_807FBB48->animation_state->scale_y = temp_f0; + D_807FBB48->animation_state->scale_z = temp_f0; + extra_player_info_pointer->unk50 = 0; + extra_player_info_pointer->unk4C = -1; +} + +void func_806F07CC(void) { + func_80608528(D_807FBB48, 0xF3, 0xFF, 0x7F, 0x19); + D_807FBB48->control_state = 0x19; + D_807FBB48->control_state_progress = 0; + extra_player_info_pointer->unk54 = D_807535CC[D_807FD584] * D_8075D5E0; + extra_player_info_pointer->unk50 = 0xC; + func_80614E78(D_807FBB48, 0x10); +} + +void func_806F0878(void) { + if (D_807FBB48->unk78 == 0xC) { + func_80608528(D_807FBB48, 0x76, 0x64, 0x7F, 0); + } + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + func_806CF398(D_807FBB48); + D_807FBB48->control_state = 0x15; + D_807FBB48->control_state_progress = 0; + func_80614E78(D_807FBB48, 6); + D_807FBB48->unk6A |= 0x20; + func_80614D90(D_807FBB48); +} + +void func_806F0930(void) { + if (D_807FBB48->unk78 == 0xC) { + func_80608528(D_807FBB48, 0x76, 0xFF, 0x7F, 0); + } + extra_player_info_pointer->unk38 = D_807531FC[D_807FD584]; + func_806CF398(D_807FBB48); + D_807FBB48->control_state = 0x16; + D_807FBB48->control_state_progress = 0; + func_80614E78(D_807FBB48, 7); + D_807FBB48->unk6A |= 0x20; + func_80614D90(D_807FBB48); +} diff --git a/src/global_asm/code_F4C0.c b/src/global_asm/code_F4C0.c new file mode 100644 index 00000000..dc5811ff --- /dev/null +++ b/src/global_asm/code_F4C0.c @@ -0,0 +1,45 @@ +#include +#include "functions.h" +#include "variables.h" + +// Footstep SFX? +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F4C0/func_8060A7C0.s") + +typedef struct { + s16 unk0; + u8 unk2; + u8 unk3; + s16 unk4; +} GlobalASMStruct50; + +extern s16 D_80745BDE[]; +extern GlobalASMStruct50 D_80746340[]; + +/* +// TODO: Pretty close... Hmm. +s16 func_8060A7C0(s16 arg0, Actor *arg1, u8 arg2) { + s32 phi_v1; + s32 i; + + phi_v1 = FALSE; + for (i = 0; i < 0xE; i++) { + if ((arg0 == D_80746340[i].unk0) && (arg2 == D_80746340[i].unk2)) { + phi_v1 = TRUE; + break; + } + } + if (phi_v1) { + if (((current_actor_pointer->interactable & 1)) && (character_change_array[extra_player_info_pointer->unk1A4].unk2C0 == 2)) { + return 0x97; + } + if ((arg1->unk6A & 4) != 0) { + return 0xA; + } + if (!D_80746340[0].unk4) { + return D_80745BDE[current_map * 2]; + } + return D_80746340[0].unk4; + } + return arg0; +} +*/ diff --git a/src/global_asm/code_F56F0.c b/src/global_asm/code_F56F0.c new file mode 100644 index 00000000..724770d7 --- /dev/null +++ b/src/global_asm/code_F56F0.c @@ -0,0 +1,364 @@ +#include +#include "functions.h" +#include "variables.h" + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F09F0.s") + +void func_80608528(Actor*, s32, s32, s32, s32); + +void func_806F0B34(Actor *arg0) { + switch (current_character_index[cc_player_index]) { + case 0: + func_80608528(arg0, 0x17C, 0xFF, 0x7F, 0x19); + return; + case 1: + func_80608528(arg0, 0x17C, 0xC8, 0xA0, 5); + return; + case 2: + func_80608528(arg0, 0x17C, 0xFF, 0x7F, 5); + return; + case 3: + func_80608528(arg0, 0x185, 0xFF, 0x7F, 0x19); + return; + default: + func_80608528(arg0, 0x18F, 0xFF, 0x7F, 0x19); + return; + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F0C18.s") + +/* +// TODO: Jumptable, Actor +void func_806F0C18(Actor *arg0) { + void *sp20; + s32 temp_v0; + void *temp_v0_2; // TODO: Which aaD? + + temp_v0 = func_80613448(); + if (temp_v0 >= 0x11) { + if (temp_v0 != 0xDB) { + // TODO: Call D_8075D61C[something]() + } else { + func_8068A764(arg0, 1); + func_8068A784(arg0, 0); + } + } else if ((temp_v0 - 1) < 0x10) { + func_8068A784(arg0, 0); + func_8068A784(arg0, 1); + } + if (arg0->unk5C & 1) { + temp_v0_2 = arg0->unk174; + if (temp_v0_2->unk8C != 0) { + sp20 = temp_v0_2; + func_806F0B34(arg0); + temp_v0_2->unk8C = 0; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F0D68.s") + +void func_806F1048(Actor *arg0) { + s32 actorBehaviourIndex = arg0->unk58; + PlayerAdditionalActorData *PaaD = arg0->PaaD; + + switch (actorBehaviourIndex) { + case ACTOR_LANKY: + case 0xC6: // ACTOR_CUTSCENE_LANKY + PaaD->unk1F0 &= ~0x100; + case ACTOR_DIDDY: + case ACTOR_TINY: + case ACTOR_CHUNKY: + case 0xC5: // ACTOR_CUTSCENE_DIDDY + case 0xC7: // ACTOR_CUTSCENE_TINY + case 0xC8: // ACTOR_CUTSCENE_CHUNKY + if (!(PaaD->unk1F0 & 0x40)) { + func_80613214(); + } + break; + } + func_806C8D20(current_actor_pointer); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F10E8.s") + +extern s32 D_807FBB68; + +void func_806086CC(f32, f32, f32, s32, s32, s32, s32, s32, f32, s32); + +void func_806F1250(Actor *arg0) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + if (arg0->unk58 == ACTOR_CHUNKY) { + func_80613194(arg0, 0x10); + func_806086CC(arg0->x_position, arg0->y_position, arg0->z_position, 0x2E2, 0xFF, 0xA0, 0, 0x32, 0.0f, 0); + if ((D_807FBB68 & 2) == 0) { + // Gorilla Gone + playSong(0x6C, 1.0f); + } + } + PaaD->unk1F0 |= 0x40; +} + +void func_806F12FC(Actor *arg0) { + PlayerAdditionalActorData *PaaD = arg0->PaaD; + if (arg0->unk58 == ACTOR_CHUNKY) { + func_80613214(); + func_80602B60(0x6C, 0); + } + PaaD->unk1F0 &= ~0x40; +} + +void func_806F1350(s32 arg0) { + func_806E225C(0, 1); +} + +void func_806F1378(s32 arg0) { + +} + +void func_806F1380(Actor *arg0) { + f32 sp1C; + + func_80614FD8(&sp1C); + arg0->animation_state->unk88 = arg0->unkB8 - sp1C; +} + +extern s16 D_807FD584; + +s32 func_806CD9A0(Actor*, f32, f32, s16, s16); + +void func_806F13C8(Actor *arg0) { + u8 sp27; + + func_80614F28(&sp27); + arg0->animation_state->unk88 = func_806CD9A0(arg0, arg0->unkB8, arg0->unkB8, extra_player_info_pointer->unk4C, D_807FD584) - sp27; +} + +void func_806F142C(Actor *arg0) { + f32 temp_f0; + f32 temp_f2; + + func_806CFF9C(arg0); + temp_f0 = current_actor_pointer->unkB8; + temp_f2 = temp_f0 / 2; + current_actor_pointer->unkB8 = (D_807FD610[cc_player_index].unk8 * (temp_f0 - temp_f2)) + temp_f2; +} + +void func_806F149C(Actor *arg0) { + func_806D0150(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F14BC.s") + +s32 func_806F1668(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + f32 temp_f0, temp_f2, phi_f12; + + if ((arg0 < 0.0f) || (arg2 > 0.0f) || (arg3 >= 0.0f)) { + return 0; + } + temp_f0 = (arg2 - arg1); + temp_f0 /= arg3; + temp_f2 = arg0; + temp_f2 += (((arg1 + arg2) / 2) * temp_f0); + if (temp_f2 > 0.0f) { + phi_f12 = temp_f0 - (temp_f2 / arg2); + } else { + phi_f12 = (-sqrtf((arg1 * arg1) - (2 * arg3 * arg0)) - arg1) / arg3; + } + return phi_f12 + 0.5; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F1768.s") + +// TODO: Very doable, but need to define this struct array +// Sus struct size 0x8 related to PaaD->unk8E +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F1858.s") + +// Same as above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F18F4.s") + +// Same as above +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F1990.s") + +f32 func_80612D10(f32); +f32 func_80612D1C(f32); + +extern f64 D_8075D6D0; +extern f32 D_8075D6D8; +extern f32 D_8075D6DC; +extern f32 D_8075D6E0; +extern f32 D_8075D6E4; +extern f32 D_8075D6E8; +extern f32 D_8075D6EC; + +// TODO: Is this just a float array? Matrix? idk +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} GlobalASMStruct74; + +void func_806F1A18(f32 arg0, f32 arg1, GlobalASMStruct74 *arg2, f32 *arg3) { + s32 temp; + f32 sp20; + + sp20 = func_80612D10(arg2->unk4); + arg2->unk8 += (arg0 * func_80612D10(*arg3) * sp20); + arg2->unk8 -= (arg1 * func_80612D1C(arg2->unk4)); + arg2->unk8 *= D_8075D6D0; + arg2->unk4 += arg2->unk8; + *arg3 += arg2->unk4 + arg2->unk0; +} + +f32 func_806F1AE0(Actor *arg0, GlobalASMStruct74 *arg1, f32 arg2) { + f32 temp_f12; + f32 temp_f2; + + temp_f2 = func_80612790(arg0->y_rotation - arg0->unkEE) * (arg0->unkB8 * D_8075D6D8); + temp_f12 = temp_f2 - arg1->unkC; + arg1->unkC = temp_f2; + return (temp_f12 + temp_f2) * arg2; +} + +// Doable, Actor arg0, unknown struct arg1 +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F1B58.s") + +f32 func_806F1B90(f32 *arg0, f32 arg1) { + f32 phi_f2; + + phi_f2 = arg1 - *arg0; + *arg0 = arg1; + if (D_8075D6DC < phi_f2) { + phi_f2 = D_8075D6E0 - phi_f2; + } else if (phi_f2 < D_8075D6E4) { + phi_f2 = -(D_8075D6E8 + phi_f2); + } + phi_f2 *= D_8075D6EC; + return phi_f2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F1C04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F1EB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F22A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F2754.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F2A40.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F2C48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F2EDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F2FC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F3190.s") + +void func_806F3760(s16 map) { + void *autowalkFile; + + autowalkFile = getPointerTableFile(0x15, map, 1, 0); + func_806F4528(autowalkFile); + if (autowalkFile) { + func_8066B434(autowalkFile, 0x4C, 0x56); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F37BC.s") + +void func_806F386C(u8, Actor*, Actor*, s16, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F386C.s") + +/* +extern void *D_80753E90; +extern u8 D_8076A0B1; +extern s32 D_807FD70C; +extern s32 D_807FD708; +extern Actor *D_807FD710; +extern s16 D_807FD714; +extern s16 D_807FD718; +extern Actor *D_807FD71C; + +// TODO: Very doable, just gotta figure out some structs +void func_806F386C(u8 arg0, Actor *arg1, Actor *arg2, s16 arg3, u8 arg4) { + s32 temp_t6; + void *temp_t5; + PlayerAdditionalActorData *temp_v0; + + temp_v0 = arg1->PaaD; + if (D_80753E90->unk0 >= arg0) { + is_autowalking = 3; + D_8076A0B1 |= 0x10; + D_807FD710 = arg1; + temp_v0->unk1F0 &= ~1; + D_807FD714 = 0; + temp_t5 = D_80753E90->unk4 + (arg0 * 8); + D_807FD708 = temp_t5; + D_807FD70C = temp_t5->unk4; + D_807FD718 = arg3; + D_807FD71C = arg2; + if (arg4 == 0) { + func_806F37BC(arg1, D_807FD70C, arg3); + } + } +} +*/ + +typedef struct { + s16 unk0; + s16 unk2; + s32 unk4; +} GlobalASMStruct75; + +void func_806F3950(GlobalASMStruct75 *arg0) { + func_8061134C(arg0->unk4); + arg0->unk0 = 0; +} + +extern u8 D_807FD716; // bitfield, idk what it's for + +void func_806F397C(Actor *arg0, Actor *arg1, s16 arg2, s16 arg3) { + s32 phi_v0; + + if (arg2 & 0x8000) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + arg2 &= ~0x8000; + func_806F386C(arg2, arg0, arg1, arg3, phi_v0); + D_807FD716 = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F39E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F3BEC.s") + +void func_806F3DB0(void) { + D_807FD716 |= 2; +} + +// Baffling lmao +void func_806F3DC8(u16 *arg0, s16 *arg1, u8 *arg2, u16 arg3) { + if (arg1[0]) { + arg1[0]--; + return; + } + if (arg2[0]) { + arg2[0]--; + arg0[0] |= arg3; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F3E0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F4528.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F56F0/func_806F46B0.s") diff --git a/src/global_asm/code_F600.c b/src/global_asm/code_F600.c new file mode 100644 index 00000000..00304a4b --- /dev/null +++ b/src/global_asm/code_F600.c @@ -0,0 +1,80 @@ +#include +#include "functions.h" +#include "variables.h" + +extern OSContStatus D_807ECCD0; +extern void *D_807ECCE0; +extern OSMesgQueue D_807ECCF0; +extern s8 D_807ECD08; +extern u8 D_807ECD09; +extern u8 D_807ECD10; +extern u8 D_807ECD28; +extern void *D_807ECDE8; +extern void *D_807ECDF4; + +u8 func_8060A900(void) { + osCreateMesgQueue(&D_807ECCF0, &D_807ECCE0, 4); + osSetEventMesg(5, &D_807ECCF0, NULL); + osContInit(&D_807ECCF0, &D_807ECD09, &D_807ECCD0); + func_80007360(4); + if (!(D_807ECD09 & 1)) { + D_807ECD09 = 0; + } + D_807ECD08 = 0; + D_807ECDE8 = &D_807ECD10; + D_807ECDF4 = &D_807ECD28; + func_8060AA58(0xFF); + func_8060E958(); + return D_807ECD09; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060A9BC.s") + +extern u8 D_807467C4; // should_poll_input + +/* +// TODO: Hmm, might need complete segment defintions for this file for this to match +void func_8060A9BC(void) { + func_8060AA04(); + if (!D_807467C4) { + D_807ECD08 = 1; + func_800073D0(&D_807ECCF0); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060AA04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060AA58.s") + +extern u8 D_807ECDFC[]; + +u8 func_8060AB38(s32 arg0) { + return D_807ECDFC[arg0]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060AB48.s") + +extern u8 D_807ECDF8; + +u8 func_8060AC28(void) { + return D_807ECDF8; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060AC34.s") + +void func_80007454(GlobalASMStruct12*); // Probably some libultra stuff related to PI/Controller + +/* +// TODO: They're using some stack, we're not, not sure why +void func_8060AC34(GlobalASMStruct12* arg0) { + if ((D_807467C4 == 0) && (D_807ECD08 != 0)) { + func_80007454(arg0); // subdrag hook function + } + D_807ECD08 = 0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060AC7C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F600/func_8060B110.s") diff --git a/src/global_asm/code_F9450.c b/src/global_asm/code_F9450.c new file mode 100644 index 00000000..7c2ae97e --- /dev/null +++ b/src/global_asm/code_F9450.c @@ -0,0 +1,396 @@ +#include +#include "functions.h" +#include "variables.h" + +extern s16 D_807FD790[]; +extern u8 D_807FD798; +extern s16 D_807FD722; +extern s16 D_807FD724; +extern u8 D_80754238[]; +u8 func_806F6E58(s16); + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} Struct807FD740; + +extern Struct807FD740 D_807FD740[]; +extern s32 D_807FD780[]; + +void func_806F4750() { + func_806F5270(); + func_806F4778(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F4778.s") + +void func_806F4D70(u8 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + D_807FD740[arg0].unk0 = arg1; + D_807FD740[arg0].unk4 = arg2; + D_807FD740[arg0].unk8 = arg3; + D_807FD740[arg0].unkC = arg4; + D_807FD780[arg0] = 0; +} + +// Doable, some kind of struct (0x14, 0x10) init, float stuff too +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F4DC0.s") + +extern s16 D_80753EF0; // TODO: Array of 0xA structs? + +// TODO: Array of 0xA structs? +s32 func_806F4E74(s16 arg0) { + s32 b = 0; + s32 a = FALSE; + s16 *ptr = &D_80753EF0; + + while (!a) { + if (arg0 == *ptr) { + a = TRUE; + } else { + b++; + ptr += 0xA; + } + } + return b; +} + +s32 func_806F4EBC(f32 arg0, f32 arg1) { + s32 temp_f10; + s32 temp_f6; + + temp_f10 = arg0 / 500.0f; + temp_f6 = arg1 / 500.0f; + if ((D_807FD722 < temp_f10) || (D_807FD724 < temp_f6) || (arg0 < 0.0f) || (arg1 < 0.0f)) { + return -1; + } + return (D_807FD722 * temp_f6) + temp_f10; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F4F50.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F50C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F5270.s") + +typedef struct globalASMStruct36 GlobalASMStruct36; + +// TODO: These fields might not all be correct +struct globalASMStruct36 { + s16 unk0; + s16 unk2; + s32 unk4; + s32 unk8; + s32 unkC; + u8 unk10; + u8 unk11; + u8 unk12; + u8 unk13; + f32 unk14; + u8 unk18; + u8 unk19; + u8 unk1A; + u8 unk1B; + GlobalASMStruct36 *next; +}; + +extern GlobalASMStruct36 *D_807FD730; +extern u8 D_807FD738; + +void func_806F5378(void) { + GlobalASMStruct36 *next; + GlobalASMStruct36 *current; + + D_807FD738 = 1; + current = D_807FD730; + while (current) { + next = current->next; + func_806F54E0(0, current->unk2, current->unk1A); + func_806355DC(current->unk0, 1); + func_8061130C(current); + current = next; + } + D_807FD730 = NULL; +} + +// TODO: These fields might not all be correct +typedef struct GlobalASMStruct37 { + s16 unk0; + s16 unk2; + s32 unk4; + s32 unk8; + s32 unkC; + s16 unk10; + u8 unk12; + u8 unk13; + f32 unk14; + u8 unk18; + u8 unk19; + u8 unk1A; + u8 unk1B; +} GlobalASMStruct37; + +GlobalASMStruct36 *func_806F53EC(GlobalASMStruct37 *arg0) { + GlobalASMStruct36 *temp_v0 = malloc(0x20); + temp_v0->unk10 = 0; + temp_v0->unk14 = 0.0f; + temp_v0->unk0 = arg0->unk0; + temp_v0->unk18 = arg0->unk10; + temp_v0->unk2 = arg0->unk2; + temp_v0->unk19 = arg0->unk12; + temp_v0->unk1A = arg0->unk13; + return temp_v0; +} + +s32 func_806F544C(s32 arg0, s32 actorBehaviourIndex, u8 arg2) { + switch (actorBehaviourIndex) { + case 0x91: // Peanut + case 0x15D: // Feather + case 0x15E: // Grape + case 0x15F: // Pineapple + case 0x160: // Coconut + if (arg2) { + arg0 = 3; + } + } + return arg0; +} + +// Rainbow coin FTT check +void func_806F5498(void) { + if (!isFlagSet(0x16C, FLAG_TYPE_PERMANENT)) { + playCutscene(NULL, 0x20, 5); + setFlag(0x16C, TRUE, FLAG_TYPE_PERMANENT); + } +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F54E0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F58A0.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F5A48.s") + +extern s32 D_80754248[]; +extern s32 D_80754264[]; + +s32 func_806F5C30(s32 arg0) { + s32 i; + for (i = 0; i < 7; i++) { + if (arg0 == D_80754248[i]) { + return TRUE; + } + } + return FALSE; +} + +s32 func_806F5CE4(s32 arg0) { + s32 i; + for (i = 0; i < 6; i++) { + if (arg0 == D_80754264[i]) { + return TRUE; + } + } + return FALSE; +} + +void func_806F5D80(s32 *arg0, s32 *arg1) { + *arg0 = D_80754248[((rand() >> 0xF) % 7U)]; + *arg1 = (((rand() >> 0xF) % 32767) % 391) + 0xD2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F5DF8.s") + +/* +typedef struct { + s32 unk0; + s32 unk4; + s16 unk8; + s16 unkA; + s32 unkC; + s32 unk10; +} Struct80754240; + +extern Struct80754240 D_80754240[]; + +void func_806F5DF8(s32 arg0, s32 arg1, s16 arg2, s16 arg3, s16 arg4, s32 arg5) { + s32 temp_a0; + Struct80754240 *temp_v1; + s32 phi_a0; + s32 phi_v0; + + phi_a0 = 0; + for (phi_v0 = 0; phi_v0 < 0x3C && !phi_a0; phi_v0++) { + temp_v1 = &D_80754240[phi_v0]; + if (temp_v1->unk10 == 0) { + temp_v1->unk0 = arg1; + temp_v1->unk4 = arg0; + temp_v1->unk8 = arg2; + temp_v1->unkA = arg3; + temp_v1->unkC = arg4; + temp_v1->unk10 = arg5; + phi_a0 = 1; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F5EB4.s") + +void func_806F5F2C(s32 arg0, s32 arg1, s16 arg2, s16 arg3, s16 arg4) { + if (func_80714608(0) && func_806F5C30(arg0)) { + func_806F5D80(&arg0, &arg1); + } + func_806F5DF8(arg0, 1, arg2, arg3, arg4, arg1); +} + +void func_806F5FA0(s16 arg0, s16 arg1, s16 arg2) { + func_806F5F2C(0x76, 0, arg0, arg1, arg2); +} + +void func_806F5FE8(s32 arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4) { + if (func_806F5CE4(arg0)) { + func_806F5DF8(arg0, 0, arg1, arg2, arg3, arg4); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F603C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F6204.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F6554.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F6644.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F69A8.s") + +// TODO: Odd syntax, cleanup possible? +u8 func_806F6E58(s16 kongIndex) { + u8 phi_v1; + + phi_v1 = 0; + if (kongIndex < 5) { + phi_v1 = D_807FC950->character_progress[kongIndex].moves >= D_80754238[kongIndex]; + } + // Camera/Shockwave unlocked + phi_v1 |= isFlagSet(0x179, FLAG_TYPE_PERMANENT); + return phi_v1; +} + +// TODO: Odd syntax, cleanup possible? +s32 func_806F6EDC(void) { + s32 i; + u8 temp_v1; + + i = 0; + do { + temp_v1 = func_806F6E58(i); + i++; + } while (i < 5 && !temp_v1); + + return temp_v1; +} + +void func_806F6F28(void) { + s16 pad; // TODO: Why is this needed? Fake match? + u8 sp45; + s8 cameraShockaveUnlocked; + u8 playerIndex; + PlayerAdditionalActorData *PaaD; + + cameraShockaveUnlocked = FALSE; + sp45 = FALSE; + if (D_807FBB64 & 0x10000) { + func_806F603C(); + } + // Camera/Shockwave unlocked + if (isFlagSet(0x179, FLAG_TYPE_PERMANENT)) { + cameraShockaveUnlocked = TRUE; + } + if (func_806F6E58(current_character_index[0])) { + sp45 = TRUE; + } + for (playerIndex = 0; playerIndex < cc_number_of_players; playerIndex++) { + PaaD = character_change_array[playerIndex].player_pointer->additional_actor_data; + if (cameraShockaveUnlocked) { + PaaD->unk1F4 |= 1; + } else { + PaaD->unk1F4 &= ~1; + } + if (sp45) { + PaaD->unk1F4 |= 2; + } else { + PaaD->unk1F4 &= ~2; + } + if ((character_change_array[playerIndex].player_pointer->control_state != 0x36) && (D_807FD738 == 0)) { + func_806F69A8(playerIndex & 0xFF); + } + } +} + +s32 func_806F70A8(s16 arg0) { + s32 i; + + for (i = 0; i < D_807FD798; i++) { + if (arg0 == D_807FD790[i]) { + return TRUE; + } + } + return FALSE; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F70FC.s") + +extern f64 D_8075D950; +extern s32 D_8071C48C; // TODO: Datatype +extern s32 D_8071FC58; // TODO: Datatype +extern s32 D_8071C620; // TODO: Datatype + +void func_8071496C(s16); + +/* +// TODO: Kinda close, stack 2 big and datatype issues? +void func_806F70FC(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) { + f64 temp_f20; + s32 phi_s1; + f32 phi_f4; + f32 phi_f6; + f32 phi_f4_2; + + func_80714950(0x1006E); + func_8071498C(&D_8071C48C); + func_807149B8(1); + func_80714CC0(&D_8071FC58, arg3, arg0, arg1, arg2); + temp_f20 = D_8075D950 / (arg4 + arg4); + for (phi_s1 = 0; phi_s1 < arg5; phi_s1++) { + phi_f4 = (func_806119A0() / 10000U) % 1000; + phi_f6 = (func_806119A0() / 10000U) % 1000; + phi_f4_2 = (func_806119A0() / 10000U) % 1000; + func_8071498C(&D_8071C620); + func_8071496C(phi_s1); + func_807149B8(1); + func_80714CC0( + &D_8071FC58, + arg3, + arg0 + ((phi_f4 / arg4) - temp_f20), + arg1 + ((phi_f6 / arg4) - temp_f20), + arg2 + ((phi_f4_2 / arg4) - temp_f20) + ); + } +} +*/ + +f32 func_806F7378(s32 arg0) { + if (arg0 == 0x8C) { + return -13.0f; + } else { + return 0.0f; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F73A0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_F9450/func_806F79E0.s") diff --git a/src/global_asm/code_FCCD0.c b/src/global_asm/code_FCCD0.c new file mode 100644 index 00000000..fb6fea6b --- /dev/null +++ b/src/global_asm/code_FCCD0.c @@ -0,0 +1,583 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_806F8D58(s32 arg0, s32 arg1); +u16 func_80731A04(s32, s32, s32, s32); + +typedef struct global_asm_struct_71 GlobalASMStruct71; + +struct global_asm_struct_71 { + s32 unk0; + s32 unk4; + s32 unk8; // Used + s32 unkC; + s16 unk10; + s16 unk12; + GlobalASMStruct71 *unk14; // Used, prev? + GlobalASMStruct71 *unk18; // Next? +}; + +typedef struct HUDDisplay { + /* 0x000 */ u16* actual_count_pointer; + /* 0x004 */ u16 hud_count; + /* 0x006 */ u8 freeze_timer; + /* 0x007 */ s8 counter_timer; + /* 0x008 */ s32 screen_x; + /* 0x00C */ s32 screen_y; + /* 0x010 */ f32 unk_10; + /* 0x014 */ f32 unk_14; + /* 0x018 */ f32 unk_18; + /* 0x01C */ u8 unk_1c; + /* 0x01D */ u8 unk_1d; + /* 0x01E */ u8 unk_1e; + /* 0x01F */ u8 unk_1f; + /* 0x020 */ u32 hud_state; // 0 = invisible, 1 = appearing, 2 = visible, 3 = disappearing + /* 0x024 */ s32 unk_24; + /* 0x028 */ GlobalASMStruct71* counter_pointer; + /* 0x02C */ u8 unk_2c; // Infinites? + /* 0x02D */ u8 unk_2d; // Infinites? + /* 0x02E */ u8 unk_2e; + /* 0x02F */ u8 unk_2f; +} HUDDisplay; + +typedef struct { + // TODO: Union with friendly field names? + // TODO: Enum with indexes? + // 0 = Coloured Banana + // 1 = Banana Coin + // 2 = ??? + // 3 = ??? + // 4 = ??? + // 5 = Crystal Coconut + // 6 = ??? + // 7 = ??? + // 8 = GB Count (Character) + // 9 = ??? + // 10 = Banana Medal + // 11 = ??? + // 12 = Blueprint + // 13 = Coloured Banana? + // 14 = Banana Coin? + HUDDisplay hud_item[15]; +} PlayerHUD; + +extern PlayerHUD *D_80754280; // HUD + +PlayerHUD* func_806F7FD0(u8 playerIndex) { + return &D_80754280[playerIndex]; +} + +void func_806F8004(f32 arg0, f32 arg1, f32 *arg2, f32 *arg3, f32 *arg4) { + float sp88[4][4]; + float sp48[4][4]; + f32 sp44; + f32 sp40; + f32 sp3C; + f32 temp_f2_2; + f32 sp34; + + sp34 = character_change_array[cc_player_index].near; + guRotateF(&sp88, arg0, 1.0f, 0.0f, 0.0f); + guMtxXFMF(&sp88, 0.0f, 0.0f, -sp34, &sp3C, &sp40, &sp44); + guRotateF(&sp48, arg1, 0.0f, 1.0f, 0.0f); + guMtxXFMF(&sp48, sp3C, sp40, sp44, arg2, arg3, arg4); + temp_f2_2 = -sp34 / *arg4; + *arg2 *= temp_f2_2; + *arg3 *= temp_f2_2; + *arg4 = -sp34; + *arg2 = *arg2 * 10.5; + *arg3 = *arg3 * 10.5; + *arg4 = *arg4 * 10.5; +} + +void func_806F8170(s32 arg0, f32 *arg1, f32 *arg2, f32 *arg3) { + s32 temp_v0; + + if (arg0 < 0) { + func_806F8004(16.5f, 0.0f, arg1, arg2, arg3); + return; + } + if (arg0 == 8) { + func_806F8004(1.5 - (D_80754280->hud_item[arg0].hud_count * 7), 26.0f, arg1, arg2, arg3); + return; + } + *arg1 = D_80754280[0].hud_item[arg0].unk_10; + *arg2 = D_80754280[0].hud_item[arg0].unk_14; + *arg3 = D_80754280[0].hud_item[arg0].unk_18; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F8278.s") + +/* +// TODO: Not sure why this doesn't match +// Similar mismatch to func_806FB370, and func_806FB3D0 +void func_806F8278(u8 playerIndex) { + s32 levelIndex; + s32 totalGBs; + s32 kong; + + totalGBs = 0; + for (levelIndex = 0; levelIndex < 14; levelIndex++) { + for (kong = 0; kong < 5; kong++) { + totalGBs += D_807FC950[playerIndex].character_progress[kong].golden_bananas[levelIndex]; + } + } + D_80754280[playerIndex].hud_item[9].hud_count = totalGBs; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F833C.s") + +void func_806F8A8C(u8 arg0, u8 playerIndex, s32 arg2) { + PlayerHUD* temp = func_806F7FD0(playerIndex); + temp->hud_item[arg0].hud_count = arg2; +} + +u16 func_806F8AD4(u8 arg0, u8 playerIndex) { + u16 phi_a2; + u16 *temp; + s32 sp1C; + HUDDisplay *HUDItem; + s32 levelIndex; + + phi_a2 = 0; + HUDItem = &func_806F7FD0(playerIndex)->hud_item[arg0]; + switch (HUDItem->unk_2c) { + case 0: + // Astonishing... + temp = HUDItem->actual_count_pointer; + if (temp) { + phi_a2 = *((u16*)HUDItem->actual_count_pointer); + } else { + sp1C = func_806C8DE0(playerIndex); + levelIndex = getLevelIndex(D_8076A0AB, TRUE); + phi_a2 = 0; + switch (arg0) { + case 0xC: + phi_a2 = func_80731A04(0x1D5, levelIndex, levelIndex, sp1C); + break; + case 0xA: + phi_a2 = func_80731A04(0x225, levelIndex, levelIndex, sp1C); + break; + } + } + break; + case 1: + phi_a2 = 20; + break; + case 2: + break; + } + return phi_a2; +} + +void func_806F8BC4(s32 arg0, u8 arg1, s32 arg2) { + if ((cc_number_of_players < 2) && (!gameIsInDKTVMode())) { + // TODO: Can this syntax be simplified + if ((arg0 != 8) || (func_806F8BC4(9, arg1, arg2 + 0xA), (current_map != MAP_SNIDES_HQ))) { + D_80754280[0].hud_item[arg0].unk_24 = arg1; + if (D_80754280[0].hud_item[arg0].hud_state == 0) { + D_80754280[0].hud_item[arg0].counter_timer = arg2; + } else { + D_80754280[0].hud_item[arg0].counter_timer = 0; + } + D_80754280[0].hud_item[arg0].hud_state = 1; + if (D_80754280[0].hud_item[arg0].freeze_timer == 0) { + D_80754280[0].hud_item[arg0].freeze_timer = arg1 != 0; + } + } + } +} + +void func_806F8CB0(s32 arg0) { + s32 phi_v1; + GlobalASMStruct71 *phi_v0; + + // GB Count (Character)? + if (arg0 == 8) { + phi_v0 = D_80754280[0].hud_item[arg0].counter_pointer; + phi_v1 = 0; + while (phi_v0) { + phi_v0->unkC = phi_v1; + phi_v1 += 2; + phi_v0 = phi_v0->unk18; + } + } +} + +void func_806F8CFC(s32 arg0, s32 arg1) { + D_80754280[0].hud_item[arg0].counter_timer = 0; + D_80754280[0].hud_item[arg0].freeze_timer = 0; + if (arg0 == 8) { + func_806F8D58(9, 0); + } +} + +typedef struct global_asm_struct_72 GlobalASMStruct72; + +struct global_asm_struct_72 { + s32 unk0; + GlobalASMStruct72 *unk4; // Next? +}; + +extern GlobalASMStruct71 *D_80754284; + +void func_806F8D58(s32 arg0, s32 arg1) { + GlobalASMStruct71 *phi_v0 = D_80754284; + + D_80754280->hud_item[arg0].unk_1c = 0; + while (phi_v0) { + phi_v0->unk0 &= ~(1 << arg0); + phi_v0 = phi_v0->unk4; + } + func_806F8CFC(arg0, arg1); +} + +void func_806F8DC4(u8 *arg0, s32 arg1, s32 arg2) { + s32 levelIndex; + s32 kongIndex; + + levelIndex = getLevelIndex(D_8076A0AB, TRUE); + kongIndex = func_806C8DE0(0); + *arg0 = 0x7F; + switch (arg2) { + case 0xC: + if (func_80731A04(0x1D5, levelIndex, levelIndex, kongIndex)) { + *arg0 = 0xFF; + } + break; + case 0xA: + if (func_80731A04(0x225, levelIndex, levelIndex, kongIndex)) { + *arg0 = 0xFF; + } + break; + case 8: + if (arg1 < D_807FC950[0].character_progress[kongIndex].golden_bananas[levelIndex]) { + *arg0 = 0xFF; + } + break; + } +} + +s32 func_806F8EB4() { + // Count how many fairies have been photographed + return func_80731AA8(0x24D, 20, FLAG_TYPE_PERMANENT); +} + +// Jumptable, getMaxItemCapacity(HUDItemIndex, playerIndex) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F8EDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F91B4.s") + +/* +// TODO: Very close :eyes: +void func_806F91B4(s32 HUDItemIndex, u8 playerIndex, s16 amount) { + s32 flagIndex; + CharacterProgress *sp48; + HUDDisplay *HUDItem; + PlayerHUD *playerHUD; + s32 amountBefore; + s32 maxItemCapacity; + u8 levelIndex; + u16 *temp_v1; + + sp48 = &D_807FC950[playerIndex].character_progress[func_806C8DE0(playerIndex)]; + playerHUD = func_806F7FD0(playerIndex); + HUDItem = &playerHUD->hud_item[HUDItemIndex]; + if ((HUDItem->unk_2d == 0 || amount >= 0) && HUDItem->unk_2c == 0) { + if ((HUDItemIndex != 0xA) && (HUDItemIndex != 0xC)) { + if ((*HUDItem->actual_count_pointer + amount) < 0) { + *HUDItem->actual_count_pointer = 0; + } else { + *HUDItem->actual_count_pointer += amount; + // getMaxItemCapacity(HUDItemIndex, playerIndex) + maxItemCapacity = func_806F8EDC(HUDItemIndex, playerIndex); + if (maxItemCapacity < *HUDItem->actual_count_pointer) { + *HUDItem->actual_count_pointer = maxItemCapacity; + } + if (HUDItemIndex == 8 && (func_805FEF10(&flagIndex) != 0)) { + setFlag(flagIndex, TRUE, FLAG_TYPE_PERMANENT); + } + if (amount > 0 && HUDItemIndex == 0) { + levelIndex = getLevelIndex(D_8076A0AB, 1); + amountBefore = sp48->coloured_bananas[levelIndex] + sp48->coloured_bananas_fed_to_tns[levelIndex]; + if (amountBefore >= 75 && ((amountBefore - amount) < 75)) { + // Award banana medal + setFlag(func_807319D8(0x225, levelIndex, current_character_index[playerIndex]), TRUE, FLAG_TYPE_PERMANENT); + func_80687C48(); + } + if (amountBefore == 100 && (amountBefore - amount) < 100) { + // Play 100 bananas collected jingle + playSong(0xAC, 1.0f); + } + } + } + } + if (HUDItemIndex == 8) { + func_806F8278(playerIndex); + } + } +} +*/ + +void func_806F93EC(u16 *arg0, Maps map) { + *arg0 |= 1 << getLevelIndex(map, TRUE); +} + +void func_806F942C(u16 *arg0, Maps map) { + *arg0 &= ~(1 << getLevelIndex(map, TRUE)); +} + +u8 func_806F9470(u16 arg0, Maps map) { + return (1 << getLevelIndex(map, 1)) & arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F94AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9518.s") + +/* +// TODO: Pretty close... hmm +void func_806F9518(s32 arg0) { + GlobalASMStruct71 *phi_s1; + GlobalASMStruct72 **next; + + D_80754280[0].hud_item[arg0].hud_state = 0; + phi_s1 = D_80754280[0].hud_item[arg0].counter_pointer; + while (phi_s1) { + next = &phi_s1->unk18; + if (phi_s1->unk0 == 1) { + func_80715908(phi_s1->unk14->unk8); + } + func_8061130C(phi_s1->unk14); + func_8061130C(phi_s1); + phi_s1->unk0 = NULL; + phi_s1 = *next; + } +} +*/ + +void func_806F95C8(void) { + s32 i; + for (i = 0; i < 15; i++) { + func_806F9518(i); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9608.s") + +/* +// TODO: Which struct is this? +void func_806F9608(s32 **arg0) { + s32 *temp_a0; + s32 *temp_v0; + + temp_v0 = malloc(0x1C); + temp_a0 = temp_v0; + *arg0 = temp_v0; + func_80611690(temp_a0); + **arg0 = 1; + (*arg0)->unk14 = malloc(0xC); + func_80611690((*arg0)->unk14); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F966C.s") + +/* +// TODO: Which struct is this? +void func_806F966C(s32 **arg0) { + s32 *temp_a0; + s32 *temp_v0; + + temp_v0 = malloc(0x1C); + temp_a0 = temp_v0; + *arg0 = temp_v0; + func_80611690(temp_a0); + **arg0 = 0; + (*arg0)->unk14 = malloc(0x88); + func_80611690((*arg0)->unk14); +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F96CC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9744.s") + +/* +// TODO: Which struct is this? +void func_806F9744(void *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + s32 sp2C; + void *temp_s0; + + temp_s0 = arg0->unk14; + sp2C = 2; + func_8071495C(); + func_807149FC(-1); + if (arg1 == 0xE) { + sp2C = 1; + } + func_80714998(unksp2F); + func_80714944(arg4); + func_80714950(arg0); + func_8071498C(&D_8071BE04); + func_80714A28(0x21); + if (arg1 == 3) { + func_807149C8(0xFF, 0, 0, 0xFF); + } + temp_s0->unk8 = func_80714CC0(func_806FACE8(arg1), 1.0f, arg2, arg3, -10.0f); + temp_s0->unk2 = 0; + if (arg1 == 7) { + temp_s0->unk4 = 1; + } else { + temp_s0->unk4 = 0; + } + // TODO: unk8 is otherSpriteControl*? + func_806F94AC(temp_s0->unk8, arg1); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9848.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9AF0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9B64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9CD0.s") + +void func_806F9744(u8*, s32, f32, f32, s32); + +/* +// TODO: Very close, a single stack offset to fix and registers the wrong way round in an addu +void func_806F9CD0(s32 arg0) { + GlobalASMStruct71 **temp_s0; + GlobalASMStruct71 *sp30; + HUDDisplay *temp_v0; + + temp_s0 = &D_80754280[0].hud_item[arg0].counter_pointer; + func_806F9608(temp_s0); + sp30 = (*temp_s0)->unk14; + func_806F96CC(*temp_s0, arg0); + temp_v0 = &D_80754280[0].hud_item[arg0]; + func_806F9744(*temp_s0, arg0, temp_v0->screen_x, temp_v0->screen_y, 0); + func_806F8DC4(sp30, 0, arg0); + (*temp_s0)->unk10 = 0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806F9D8C.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FA1A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FA504.s") + +/* +// TODO: Which struct is arg1? +s32 func_806FA504(s32 arg0, void *arg1, s32 arg2, s32 arg3) { + s32 phi_s1; + + phi_s1 = arg3; + if (arg1->unk0 == 0) { + if (arg0 != 8) { + phi_s1 = func_806F9D8C(arg3); + } else { + phi_s1 = func_806FA1A4(arg0, arg1, arg3); + } + } else if ((arg0 == 8) || (arg0 == 0xA) || (arg0 == 0xC)) { + func_806F8DC4(arg1->unk14, arg2, arg0); + } + return phi_s1; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FA5A4.s") + +// TODO: This matches but is ugly, can we minify it somehow +// Ternary doesn't work +s32 func_806FA7A4(s32 arg0) { + s32 phi_v1; + + phi_v1 = 1; + if (arg0 == 5) { + phi_v1 = 150; + } + return phi_v1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FA7BC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FA9C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FAB20.s") + +extern s32 D_80754288; + +void func_806FAC64(u8 arg0) { + D_80754280[0].hud_item[0xD].actual_count_pointer = &D_807FC950[0].character_progress[arg0].coloured_bananas_fed_to_tns[getLevelIndex(D_8076A0AB, 0)]; + D_80754280[0].hud_item[0xD].hud_count = *D_80754280[0].hud_item[0xD].actual_count_pointer; + D_80754288 = arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FACE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FAFE4.s") + +void func_806FB218(void) { + s32 i; + + func_806FAFE4(); + for (i = 0; i < 0xF; i++) { + if (D_80754280[0].hud_item[i].freeze_timer != 0) { + func_806F8CFC(i, 0); + } + } +} + +void func_806FB290() { + func_806FAFE4(); + func_806F95C8(); +} + +// Quite fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FB2B8.s") + +// setHudItemAsInfinite(hudItemIndex, playerIndex, unknownValue) +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FB370.s") + +/* +// TODO: Something up with datatypes or struct sizes? +// Similar mismatch to func_806F8278, and func_806FB3D0 +void func_806FB370(u8 HUDItemIndex, u8 playerIndex, u8 arg2) { + HUDDisplay *temp_v0; + + temp_v0 = &D_80754280[playerIndex].hud_item[HUDItemIndex]; + if (temp_v0->unk_2d == 0) { + temp_v0->unk_2c = arg2; + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FCCD0/func_806FB3D0.s") + +/* +// TODO: Same deal as above +u8 func_806FB3D0(u8 HUDItemIndex, u8 playerIndex) { + return D_80754280[playerIndex].hud_item[HUDItemIndex].unk_2c; +} +*/ + +s32 func_806FB418(void) { + s32 kongIndex; + s32 levelIndex; + s32 GBCount = 0; + + for (kongIndex = 0; kongIndex < 5; kongIndex++) { + for (levelIndex = 0; levelIndex < 8; levelIndex++) { + GBCount += D_807FC950[0].character_progress[kongIndex].golden_bananas[levelIndex]; + } + } + return GBCount; +} diff --git a/src/global_asm/code_FE40.c b/src/global_asm/code_FE40.c new file mode 100644 index 00000000..82f7b845 --- /dev/null +++ b/src/global_asm/code_FE40.c @@ -0,0 +1,6 @@ +#include +#include "functions.h" +#include "variables.h" + +// Does DMA, probably could match if we knew the struct types +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_FE40/func_8060B140.s") diff --git a/src/jetpac/code_0.c b/src/jetpac/code_0.c new file mode 100644 index 00000000..b5c8067f --- /dev/null +++ b/src/jetpac/code_0.c @@ -0,0 +1,198 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024000.s") + +/* +extern s32 D_8076A048; +extern f32 D_807FD888; +extern s32 D_8076A088; +extern u8 D_80767CE8[]; +extern u8 D_807444FC; +extern u8 D_8076A0B1; +extern s32 D_8076A08C; +extern s32 D_8076A050[]; + +// TODO: Pretty close +void func_80024000(void) { + s32 sp2C; + void *sp28; + s32 temp_a0; + s32 temp_t5; + u8 temp_t1; + + func_8060A9BC(); + func_80610044(D_8076A050[D_807444FC], D_8076A088, 3, 1, 0x4D2, 1); + temp_t1 = D_807444FC ^ 1; + temp_t5 = (temp_t1 & 0xFF) * 0x11B0; + D_807444FC = temp_t1; + object_timer++; + D_8076A048 = D_80767CE8[temp_t5]; + func_8060AC7C(); + if ((D_8076A0B1 & 1) && (D_807FD888 == 31.0f)) { + sp2C = D_8076A050[D_807444FC]; + } else { + func_8002419C(D_8076A048, &sp2C); + } + temp_a0 = func_80704484(sp2C, 0); + if (is_cutscene_active != 4) { + sp28 = D_8076A048 + 0xDB0; + func_805FE71C(temp_a0, D_807444FC, &D_8076A088, 0); + func_805FE7B4(sp28, D_8076A048, &D_8076A08C, 1); + } else { + func_805FE71C(temp_a0, D_807444FC, &D_8076A088, 1); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_8002419C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024390.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024408.s") +void func_800250A0(); + +void func_8002463C() { + func_80028C3C(); + func_80024390(); + func_800250A0(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_8002466C.s") + +void func_800248A0(Gfx **arg0) { + func_80024408(arg0); + func_800286D0(); + func_800255D4(arg0); + func_80028E88(); + func_800289EC(); + func_80025904(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_800248E8.s") + +/* +// TODO: Doable +extern JetpacPlayerStruct D_8002EC30; +void func_800248E8(s32 arg0) { + void *sp1C; + int score; + void *temp_a0; + Competitor *player; + void *temp_v0_2; + + player = &D_8002EC30.player[D_8002EC30.player_index]; + score = player->current_score; + if (score >= 1000000) { + player->current_score = score - 1000000; + } + func_80024408(arg0, &D_8002EC30); + func_80026D48(); + func_80026CEC(); + player->fun_ptr(player->next_item_pointer); + temp_a0 = player + (player->unk10 * 0x4C); + temp_a0->unk58(temp_a0 + 0x14); + func_8002ABDC(); + func_800255D4(arg0); + func_80028E88(); + func_80026AB0(); + func_8002AD8C(); + func_80028544(); + func_800285DC(); + func_80026CA4(); + func_80025904(arg0); + if (func_80026FE0()) { + D_8002EC30.unk44C++; + } + if (D_8002EC30.unk8 & 0x1000) { + D_8002EC30.unk78C = 3; + D_8002EC30.unkC = 1; + } +} +*/ + +extern s32 D_8002EC48; +void func_80024A4C(void) { + func_8060C648(0x11, 0, 0, 0, D_8002EC48); + func_8060DEA8(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024A8C.s") + +extern JetpacPlayerStruct D_8002EC30; + +void func_80024C90(s32 arg0) { + Competitor *player = &D_8002EC30.player[D_8002EC30.player_index]; + func_80024408(); + func_80026CEC(); + player->fun_ptr(&player->next_item_pointer); + func_800286D0(); + func_8002ABDC(); + func_800255D4(arg0); + func_80028E88(); + func_8002AD8C(); + func_800289EC(); + func_800285DC(); + func_80026CA4(); + func_80025904(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024D48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024E70.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024F24.s") + +extern s32 D_80770DF8[]; + +/* +// It's not putting arg1 on the stack, not sure why +void func_80024F24(s32 arg0, s32 arg1) { + if (D_80770DF8[arg0]) { + func_80737AC4(D_80770DF8[arg0], 0x10, arg1); + } +} +*/ + +void func_80024F64(s32 arg0) { + s32 temp_a1; + + temp_a1 = D_80770DF8[arg0]; + if (temp_a1 != 0) { + func_80737924(temp_a1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80024F9C.s") + +void func_80024F9C(u8); +void func_800275F4(Competitor *); +void func_80027D64(Competitor *); +void func_80028340(Competitor *); +extern JetpacPlayerStruct D_8002EC30; + +void func_800250A0(void) { + Competitor *player; + + player = &D_8002EC30.player[D_8002EC30.player_index]; + if (player->level < 0) { + player->lives--; + } + player->level++; + func_80027D64(player); + if ((player->level & 3) == 0) { + func_800275F4(player); + player->unk114 = 0; + player->unk10 = 1; + func_80024F9C(2); + return; + } + func_80028340(player); + func_80024F9C(1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80025168.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_0/func_80025368.s") diff --git a/src/jetpac/code_1460.c b/src/jetpac/code_1460.c new file mode 100644 index 00000000..03b6268f --- /dev/null +++ b/src/jetpac/code_1460.c @@ -0,0 +1,252 @@ +#include +#include "functions.h" +#include "variables.h" + +extern void func_8070F2FC(Gfx **arg0, s16 arg1, s16 arg2); +extern void func_8070E8F0(Gfx**, Sprite*); +extern void func_8070F2C8(s32, s32, s32, u8); + +typedef struct jetpac_struct_0 { + u8 pad0[0x14]; + u32 unk14; + u32 unk18; + u32 unk1C; + u32 unk20; + u32 unk24; + u32 unk28; + u32 unk2C; +} JetpacStruct0; + +typedef struct +{ + s32 unk0; + s32 unk4; + u8 pad8[0x3]; + u8 unkB; + Sprite *unkC; +} JetpacStruct2; + + +typedef struct { + JetpacStruct2 unk0[6]; + s32 unk60; + u8 unk64; // red + u8 unk65; // green + u8 unk66; // blue + u8 unk67; +} JetpacStruct1; + +JetpacStruct1 D_8002F3D0[0x18][0x20]; +s32 D_80045BD0; + +void func_80025460(void) { + int x, y; + JetpacStruct1 *ptr; + + ptr = &D_8002F3D0[0][0]; + for (x = 0; x < 0x18; x++) { + for (y = 0; y < 0x20; y++) { + ptr->unk60 = 0; + ptr->unk67 = 0; + ptr++; + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_800254B8.s") + +void func_800255D4(Gfx **arg0) { + Gfx *sp1C; + + sp1C = *arg0; + gDPPipeSync(sp1C++); + gDPSetScissor(sp1C++, G_SC_NON_INTERLACE, 32, 24, 288, 216); + gSPClearGeometryMode(sp1C++, -1); + gSPSetGeometryMode(sp1C++, G_SHADE | 0x00200000); + gDPSetRenderMode(sp1C++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(sp1C++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); + gDPSetTextureFilter(sp1C++, G_TF_POINT); + gDPSetTexturePersp(sp1C++, G_TP_NONE); + gDPSetTextureConvert(sp1C++, G_TC_FILT); + gDPSetCycleType(sp1C++, G_CYC_1CYCLE); + gDPSetEnvColor(sp1C++, 0x00, 0x00, 0x00, 0x00); + D_80045BD0 = 0; + func_80025460(); + *arg0 = sp1C; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025700.s") + +#ifndef NONMATCHING +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025904.s") +#else +void func_80025904(Gfx **arg0) { + JetpacStruct1 *s3; + s32 s4; + s32 s7; + Gfx *sp50; + s32 s1; + s16 tmp_a1; + s16 tmp_a2; + + + s3 = &D_8002F3D0[0][0]; + sp50 = *arg0; + for (s7 = 0; s7 < 0x18; s7++) { + for (s4 = 0; s4 < 0x20; s4++) { + if (s3->unk60) { + gDPSetPrimColor(sp50++, 0, 0, s3->unk64, s3->unk65, s3->unk66, 0xff); + } + for (s1 = 0; s1 < s3->unk60; s1++) { + func_8070E8F0(&sp50, s3->unk0[s1].unkC); + func_8070F2C8(0x400, 0x400, s3->unk0[s1].unkB, 0); + tmp_a1 = (s3->unk0[s1].unk0 + 0x20); + tmp_a2 = (s3->unk0[s1].unk4 + 0x18); + func_8070F2FC(&sp50, 4*tmp_a1, 4*tmp_a2); + } + s3++; + } + } + *arg0 = sp50; +} +#endif + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025A60.s") + +typedef struct JetpacStruct5 { + f32 unk0; + u8 pad0[0x1C - 0x4]; + s32 unk1C; +} JetpacStruct5; + +s32 func_80025B70(JetpacStruct5 *arg0) { + return (((s32) arg0->unk0 + arg0->unk1C) / 2) % 4; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025BB8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025C40.s") + +/* +// TODO: Sorry to whoever matched this, I messed up +s32 *func_80025C40(JetpacStruct1 *arg0) { + s32 i; + for (i = 0; i < 4; i++) { + if (arg0[i].unk60 == 0) { + return &arg0[i].unk60; + } + } + return 0; +} +*/ + +void func_80025CA0(JetpacStruct0 *arg0) { + arg0->unk14 = 4; + arg0->unk2C = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025CB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025F48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80025FC4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_800260DC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80026318.s") + +void func_80025368(Competitor*); +extern JetpacPlayerStruct D_8002EC30; +typedef struct JetpacStruct10 { + u8 pad0[0x2C]; + s32 unk2C; +} JetpacStruct10; + +void func_80026A3C(JetpacStruct10 *arg0) { + Competitor *player; + s32 temp_v0; + + player = &D_8002EC30.player[D_8002EC30.player_index]; + if (arg0->unk2C < 0xE) { + arg0->unk2C++; + return; + } + player->lives--; + func_80025368(player); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80026AB0.s") + +void func_80025FC4(JetpacStruct*); +extern JetpacStruct D_8002F09C; +extern JetpacStruct D_8002F1DC; + +void func_80026CA4(void) { + JetpacStruct *phi_s0; + JetpacStruct *phi_s1; + phi_s1 = (phi_s0 = &D_8002F09C) + 4; + + do { + func_80025FC4(phi_s0); + phi_s0++; + } while (phi_s0 != phi_s1); +} + +//function pointer from struct +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80026CEC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80026D48.s") + +extern s32 D_8002F064; + +/* +int func_80026FE0(void); +void func_80026318(s32*); +void func_80024E70(s32); +extern JetpacStruct10 D_8002F050; + +// TODO: Very close, but wtf +void func_80026D48(void) { + s32 phi_v0; + + if (!func_80026FE0()) { + phi_v0 = D_8002F064; + if (phi_v0 == 1) { + func_80024E70(3); + phi_v0 = 3; + } + D_8002F064 = phi_v0; + if (phi_v0 == 3) { + func_80026318(&D_8002F050); + } + if (D_8002F064 == 4) { + func_80026A3C(&D_8002F050); + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_1460/func_80026DC8.s") + +extern s32 D_8002F07C; + +int func_80026FE0(void) { + return D_8002F064 == 1 && D_8002F07C < 0xB4; +} + +typedef struct JetpacStruct3 { + f32 unk0; + f32 unk4; + u8 pad0[0x3C - 0x8]; + s32 unk3C; + s32 unk40; + s32 unk44; +} JetpacStruct3; + +void func_80027010(JetpacStruct3 *arg0) { + if (arg0->unk44 >= 0xE) { + arg0->unk44 = 0; + arg0->unk3C = (s32) ((s32) arg0->unk0 & 0xFFF8); + arg0->unk40 = (s32) (arg0->unk4 + 7.0f); + } +} diff --git a/src/jetpac/code_3060.c b/src/jetpac/code_3060.c new file mode 100644 index 00000000..4949104c --- /dev/null +++ b/src/jetpac/code_3060.c @@ -0,0 +1,97 @@ +#include +#include "functions.h" +#include "variables.h" + +s32 func_80027060(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { + arg0 = MAX(arg0, arg4); + arg1 = MAX(arg1, arg5); + arg2 = MIN(arg2, arg6); + arg3 = MIN(arg3, arg7); + if (arg0 <= arg2 && arg1 <= arg3) { + return 1; + } + return 0; +} + +void func_80027108(f32 arg0, f32 arg1, f32 *arg2, f32 *arg3, f32 *arg4, f32 *arg5) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f2; + f32 temp_f2_2; + + if (arg0 < 0.0f) { + if (arg1 <= 0.0f) { + temp_f0 = arg0 + 256.0f; + temp_f2 = arg1 + 256.0f; + *arg2 = temp_f0; + *arg3 = temp_f2; + *arg4 = temp_f0; + *arg5 = temp_f2; + return; + } + *arg2 = 0.0f; + *arg3 = arg1; + *arg4 = arg0 + 256.0f; + *arg5 = 256.0f; + return; + } + if (arg0 >= 256.0f) { + temp_f0_2 = arg0 - 256.0f; + temp_f2_2 = arg1 - 256.0f; + *arg2 = temp_f0_2; + *arg3 = temp_f2_2; + *arg4 = temp_f0_2; + *arg5 = temp_f2_2; + return; + } + if (arg1 > 256.0f) { + *arg2 = 0.0f; + *arg3 = arg1 - 256.0f; + *arg4 = arg0; + *arg5 = 256.0f; + return; + } + *arg2 = arg0; + *arg3 = arg1; + *arg4 = arg0; + *arg5 = arg1; +} + +extern f32 D_8002EB70; + +f32 func_80027210(void) { + return (f32) ((s32) (rand() >> 0xF) % 60000) / D_8002EB70; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3060/func_80027250.s") + +int func_80027330(f32 arg0) { + return (arg0 >= 165.0f) && (arg0 <= 171.0f); +} + +typedef struct JetpacStruct44 { + f32 unk0; + f32 unk4; + u8 pad0[0x1C - 0x8]; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; +} JetpacStruct44; + +f32 func_80027380(JetpacStruct44 *arg0) { + return (arg0->unk0 + arg0->unk1C) + ((f32)(arg0->unk24 - arg0->unk1C) * 0.5); +} + + +f32 func_800273C8(JetpacStruct44 *arg0) { + return (arg0->unk4 + arg0->unk20) + ((f32)(arg0->unk28 - arg0->unk20) * 0.5); +} + +//math.ceil? +f32 func_80027410(f32 arg0) { + if (arg0 >= 0.0f) { + return (f32) (s32) (arg0 + 0.5f); + } + return (f32) (s32) (arg0 - 0.5f); +} diff --git a/src/jetpac/code_3480.c b/src/jetpac/code_3480.c new file mode 100644 index 00000000..cf4ff34e --- /dev/null +++ b/src/jetpac/code_3480.c @@ -0,0 +1,85 @@ +#include +#include "functions.h" +#include "variables.h" + +f32 func_80027210(); + +s32 func_80027480(void) { + return (s32) ((func_80027210() * 200.0f) + 90.0f); +} + +extern s32 D_8002DC68[]; +f32 func_80027210(); +s32 func_800274C0(void) { + return D_8002DC68[(s32)(func_80027210() * 13.0f) % 13]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80027510.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_800275F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80027728.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80027BE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80027D64.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80027EC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028340.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_800283EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028544.s") + +extern JetpacPlayerStruct D_8002EC30; +void func_800285DC(void) { + Competitor *player = &D_8002EC30.player[D_8002EC30.player_index]; + player->fun_ptr2(&player->next_item_pointer,5); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028634.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_800286D0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028950.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_800289EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028B54.s") + +void func_80028BD0(JetpacStruct*, s32, s32, s32, u8, u8, u8); + +void func_80028BD0(JetpacStruct *arg0, s32 arg1, s32 arg2, s32 arg3, u8 arg4, u8 arg5, u8 arg6) { + arg0->unk30 = arg3; + arg0->unk0 = arg1; + arg0->unk4 = arg2; + arg0->unk8 = 0.0f; + arg0->unkC = 0.0f; + arg0->unk10 = arg4; + arg0->unk11 = arg5; + arg0->unk12 = arg6; + arg0->unk13 = 0xFF; + arg0->unk20 = arg2; + arg0->unk1C = arg1; + // TODO: Why does this need to be on the same line? Just ido being shite? + arg0->unk24 = arg3 * 8 + arg1 + 0x10; arg0->unk28 = arg2 + 0xC; +} + +extern f32 D_8002EF80; +extern f32 D_8002EFB4; +extern f32 D_8002EFE8; +extern f32 D_8002F01C; + +void func_80028C3C(void) { + func_80028BD0(&D_8002EF80, 0xC0, 0x30, 4, 0, 0xBE, 0); + func_80028BD0(&D_8002EFB4, 0x20, 0x48, 4, 0, 0xBE, 0); + func_80028BD0(&D_8002EFE8, 0x78, 0x60, 2, 0, 0xBE, 0); + func_80028BD0(&D_8002F01C, 0, 0xB8, 0x1E, 0xBE, 0xBE, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028CF8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028E04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_3480/func_80028E88.s") diff --git a/src/jetpac/code_4FC0.c b/src/jetpac/code_4FC0.c new file mode 100644 index 00000000..1c8cc509 --- /dev/null +++ b/src/jetpac/code_4FC0.c @@ -0,0 +1,277 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80028FC0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029064.s") + +void func_80024E70(u8); +typedef struct JetpacStruct5 { + f32 unk0; + f32 unk4; + u8 pad0[0x14 - 0x8]; + s32 unk14; + u8 pad1[0x2C - 0x18]; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; +} JetpacStruct5; +void func_800291AC(JetpacStruct5 *arg0) { + arg0->unk14 = 4; + arg0->unk2C = 0; + arg0->unk38 = 0; + arg0->unk30 = (s32) ((s32) arg0->unk0 & 0xFFF8); + arg0->unk34 = (s32) ((s32) arg0->unk4 & 0xFFF8); + func_80024E70(5); +} + +void func_80025700(s32, s32, s32, s32, s32); +void func_80025A60(s32); + +void func_80029204(JetpacStruct *arg0) { + s32 temp_v0; + + temp_v0 = arg0->unk14; + if (temp_v0 == 3) { + func_80025700(arg0->unk4C, arg0->unk0, arg0->unk4, ((s8*)(&(*arg0))) + 0x10, arg0->unk18); + return; + } + if (temp_v0 == 4) { + func_80025A60(((s8*)(&(*arg0))) + 0x30); + if (arg0->unk38 < 7) { + func_80025700(arg0->unk4C, arg0->unk0, arg0->unk4, ((s8*)(&(*arg0))) + 0x10, arg0->unk18); + } + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_800292C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029450.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_800294EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029640.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002976C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029884.s") + +void func_8002976C(JetpacStruct*); +typedef struct JetpacStruct9 { + u8 pad0[0x18]; +} JetpacStruct9; +extern JetpacStruct9 D_8002E800[]; + +void func_800298C8(JetpacStruct *arg0) { + func_8002976C(arg0); + arg0->unk4C = &D_8002E800[(s32)arg0->unk0 % 2]; +} + +extern f32 D_8002EBB0; +extern f32 D_8002EBB4; +extern f32 D_8002EBB8; +extern s32 D_8002E830; +extern void (func_8002998C)(); + +void func_8002992C(JetpacStruct *arg0) { + arg0->unk48 = &func_8002998C; + arg0->unk44 = 0x50; + if (arg0->unk4 < 88.0f) { + arg0->unk8 = D_8002EBB0; + } else { + arg0->unk8 = D_8002EBB4; + } + arg0->unkC = D_8002EBB8; + arg0->unk4C = &D_8002E830; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002998C.s") + +f32 func_80027210(); +void func_80029B90(); +extern f32 D_8002EBBC; +extern f32 D_8002EBC0; +extern void (func_80029C1C)(); + +void func_80029AF8(JetpacStruct *arg0) { + arg0->unk48 = &func_80029C1C; + arg0->unk44 = 0x28; + if (arg0->unk4 < 88.0f) { + arg0->unk8 = D_8002EBBC; + } else { + arg0->unk8 = D_8002EBC0; + } + func_80029B90(); + arg0->unk2C = (func_80027210() * 60.0f) + 10.0f; +} + +extern f32 D_8002EBC4; +extern f32 D_8002EBC8; +typedef struct JetpacStruct8 { + u8 pad0[0xC]; + f32 unkC; +} JetpacStruct8; + +void func_80029B90(JetpacStruct8 *arg0) { + if (arg0->unkC == 0.0) { + if (func_80027210() < 0.5) { + arg0->unkC = (f32) D_8002EBC4; + return; + } + arg0->unkC = D_8002EBC8; + return; + } + arg0->unkC = 0.0f; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029C1C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029E0C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_80029F7C.s") + +void func_8002A374(); +extern void (func_8002A530)(); + +void func_8002A254(JetpacStruct *arg0) { + arg0->unk48 = &func_8002A530; + arg0->unk44 = 0x32; + if (arg0->unk4 < 88.0f) { + arg0->unk18 = 0; + } else { + arg0->unk18 = 1; + } + func_8002A374(); +} + + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A2AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A2DC.s") + +extern f64 D_8002EBF0; +extern f64 D_8002EBF8; +extern f64 D_8002EC00; +extern f64 D_8002EC08; + +/* +// TODO: Close +f32 func_8002A2DC(f32 arg0, f32 arg1) { + f32 phi_f14; + + if (arg0 < 0.0f) { + phi_f14 = arg1 - D_8002EBF0; + } else { + phi_f14 = arg1 + D_8002EBF8; + } + if (phi_f14 < D_8002EC00) { + return D_8002EC00; + } + return MIN(D_8002EC08, phi_f14); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A374.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A530.s") + +extern f64 D_8002EC10; + +void func_8002A67C(JetpacStruct *arg0) { + s32 temp_f6; + + temp_f6 = (arg0->unk2C % 4) + 1; + arg0->unkC = ((f64)D_8002EC10 / (f64) temp_f6); + arg0->unk2C++; +} + + +f32 func_80027210(); +//void func_8002A67C(JetpacStruct *); +extern s32 D_8002E8A8; +extern f32 D_8002EC18; +extern f32 D_8002EC1C; +extern void (func_8002A758)(); + +void func_8002A6C0(JetpacStruct *arg0) { + arg0->unk48 = &func_8002A758; + arg0->unk44 = 0x3C; + arg0->unk2C = (s32) (func_80027210() * 16.0f); + if (arg0->unk4 < 88.0f) { + arg0->unk8 = D_8002EC18; + } else { + arg0->unk8 = D_8002EC1C; + } + func_8002A67C(arg0); + arg0->unk4C = &D_8002E8A8; +} + + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A758.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A8F0.s") +/* .rodata error*/ +/*void func_80029640(f32, f32); +extern s32 D_8002E8C0; +extern void (func_8002976C)(); +typedef struct JetpacStruct4 { + u8 pad0[0x28]; + u8 unk28; + u8 pad1[0x48 - 0x29]; + void *unk48; + s32 *unk4C; +} JetpacStruct4; + +void func_8002A8F0(JetpacStruct4 *arg0) { + arg0->unk28 = 0xE; + arg0->unk4C = &D_8002E8C0; + func_80029640(1.2f, 0.3f); + arg0->unk48 = &func_8002976C; +}*/ + +extern s32 D_8002E8D8; + +void func_8002A944(JetpacStruct *arg0) { + arg0->unk28 = 0xE; + arg0->unk4C = &D_8002E8D8; + func_8002A254(arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002A974.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002AAD4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002ABDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002AD8C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002AE00.s") + +extern s8 D_80045BE0; +extern s8 D_80045BE1; +extern s8 D_80045BE2; +extern s8 D_80045BE3; + +void func_8002AE94(s8 arg0, s8 arg1, s8 arg2, s8 arg3) { + D_80045BE0 = arg0; + D_80045BE1 = arg1; + D_80045BE2 = arg2; + D_80045BE3 = arg3; +} + +extern s8 D_8002E9C0; +extern s8 D_8002E9C4; +extern s8 D_8002E9C8; +extern s8 D_8002E9CC; + +void func_8002AEC8(s8 arg0, s8 arg1, s8 arg2, s8 arg3) { + D_8002E9C0 = arg0; + D_8002E9C4 = arg1; + D_8002E9C8 = arg2; + D_8002E9CC = arg3; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/jetpac/code_4FC0/func_8002AEFC.s") diff --git a/src/menu/code_0.c b/src/menu/code_0.c new file mode 100644 index 00000000..eb095704 --- /dev/null +++ b/src/menu/code_0.c @@ -0,0 +1,127 @@ +#include +#include "functions.h" +#include "variables.h" + +// Weird array/struct stuff going on here +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_80024000.s") + +typedef struct menu_struct_0 { + u8 unk0; + u8 unk1; + u8 pad2; + u8 pad3; + u8 pad4; + u8 pad5; + u8 unk6; + u8 unk7; + otherSpriteControl *unk8; + f32 unkC; + f32 unk10; + f32 unk14; +} MenuStruct0; + +extern f32 D_800339F8; +extern f32 D_800339FC; +extern f32 D_80033A00; +extern s32 D_80720268; +extern s16 D_80750AC8; + +void func_800240BC(MenuStruct0 *arg0) { + arg0->unk10 = D_800339F8; + arg0->unkC = D_800339FC; + arg0->unk14 = D_80033A00; + arg0->unk6 = 0; + func_80714998(0); + func_807149B8(1); + func_807149FC(-1); + func_80714998(0); + arg0->unk8 = func_80714CC0(&D_80720268, 0.3f, 181.0f, 3.0f, 82.0f); +} + +void func_80024154(MenuStruct0 *arg0) { + otherSpriteControl *sprite = arg0->unk8; + + sprite->xPos += arg0->unkC; + sprite->unk_348 += arg0->unk14; + arg0->unk10 += -1.0f; + sprite->yPos += arg0->unk10; + arg0->unk6++; + if (arg0->unk6 >= 0x16) { + arg0->unk6 = 0; + func_80715908(arg0->unk8); + arg0->unk8 = NULL; + } +} + +void func_800241E8(void) { + func_806CFF9C(player_pointer); + func_805FF898(); + playCutscene(NULL, 7, 1); +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_80024224.s") + +void func_80024418(MenuStruct0 *arg0, u8 arg1) { + switch (arg0->unk1) { + case 0: + if (func_80629148()) { + func_8070D8C0(current_actor_pointer, 0xB, arg1); + arg0->unk1++; + } + break; + case 1: + // TODO: Use proper bitfield syntax + if ((s32)current_actor_pointer->object_properties_bitfield << 6 >= 0) { + func_8061CB08(); + arg0->unk1++; + } + break; + case 2: + if (func_80629148()) { + func_80629174(); + arg0->unk0 = 4; + arg0->unk1 = 0; + } + break; + } +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_800244EC.s") + +// Super interesting, somewhat doable +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_80024788.s") + +void func_80024BFC(MenuStruct0 *arg0) { + switch (arg0->unk1) { + case 0: + if (func_80629148()) { + func_80629174(); + arg0->unk1++; + D_80750AC8 = func_80712548(arg0); + func_8070D8C0(current_actor_pointer, 0xB, 8); + } + break; + case 1: + // TODO: Use proper bitfield syntax + if (((s32)current_actor_pointer->object_properties_bitfield << 6) >= 0) { + func_8061CB08(); + arg0->unk1++; + } + break; + } +} + +// Jumptable, 576 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_80024CB0.s") + +// Checks if all blueprints turned in, malloc, current_actor_pointer, playSFX +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_80024EF0.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_0/func_800252AC.s") + +void func_80025AE0(void) { + +} \ No newline at end of file diff --git a/src/menu/code_1AF0.c b/src/menu/code_1AF0.c new file mode 100644 index 00000000..9e9e9473 --- /dev/null +++ b/src/menu/code_1AF0.c @@ -0,0 +1,283 @@ +#include +#include "functions.h" +#include "variables.h" + + +typedef struct menu_struct_1 { + u32 unk0; + s16 unk4; + u16 unk6; + u16 unk8; + u8 unkA; + s8 unkB; + u8 unkC; + u8 unkD; + u8 unkE; + u8 unkF; + u8 unk10; + u8 unk11; +} MenuStruct1; + +extern u8 D_800334DC[]; + +void func_806F91B4(s32, s32, s16); +void func_80709464(s32); +void func_80025FB4(MenuStruct1*, s32, s32); + +void func_806F397C(Actor*, Actor*, s16, s16); + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80025AF0.s") + +/* +// TODO: Close, regalloc? Extra args? +s32 func_80025AF0(MenuStruct1 *arg0, s32 characterIndex) { + s32 phi_v1; + s32 phi_v0; + + phi_v1 = 0; + for (phi_v0 = 0; phi_v0 < 5; phi_v0++) { + if (phi_v0 != current_character_index[0]) { + phi_v1 |= D_807FC950[0].character_progress_as_bytes[phi_v0][arg0->unkB] & (1 << (characterIndex + 0x1F)); + } + if (phi_v1) { + break; + } + } + return phi_v1; +} +*/ + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80025B64.s") + +void func_80025D14(MenuStruct1 *arg0, s32 arg1) { + D_807FC950[0].character_progress_as_bytes[arg1][arg0->unkB] = arg0->unk11; +} + +void func_80025D44(MenuStruct1 *arg0, s32 arg1) { + D_807FC950[0].character_progress_as_bytes[arg1][arg0->unkB] |= 1 << (arg0->unk11 + 0x1F); +} + +void func_80025D8C(MenuStruct1 *arg0, u8 arg1) { + s32 i; + for (i = 0; i < 5; i++) { + if (arg1) { + func_80025D44(arg0, i); + } else { + func_80025D14(arg0, i); + } + } +} + +void func_80025E04(MenuStruct1 *arg0, s32 arg1) { + s16 sp1E; + u8 sp1D; + + sp1E = -1; + sp1D = func_806F6E58(current_character_index[0]); + switch (arg0->unkB) { + case 2: + case 4: + if (arg0->unk11 >= 2) { + func_80025D8C(arg0, 1); + } else { + func_80025D44(arg0, current_character_index[0]); + } + break; + case 1: + case 3: + func_80025D8C(arg0, 0); + break; + default: + func_80025D14(arg0, current_character_index[0]); + break; + } + + if (arg0->unkB == 4) { + if (D_807FC950[0].melons < D_800334DC[arg0->unk11]) { + D_807FC950[0].melons = D_800334DC[arg0->unk11]; + func_80709464(0); + character_change_array->unk2E2 |= 0x11; + } + } + + switch (arg0->unkB) { + case 2: + case 3: + sp1E = 2; + break; + case 4: + sp1E = 7; + break; + case 0: + if ((sp1D == 0) && (func_806F6E58(current_character_index[0]))) { + sp1E = 5; + } + break; + } + func_806F91B4(1, 0, -arg0->unk4); + if (sp1E >= 0) { + func_806F91B4(sp1E, 0, 9999); + } + func_8060DEC8(); // saveTheGame() +} + +// Doable, big project though +// It checks whether levels have been entered and does stuff with actor behaviour index +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80025FB4.s") + +s32 func_800261C0(MenuStruct1 *arg0, s32 arg1) { + s32 ret = 0; + arg0->unkF = 3; + if (arg0->unkB >= 0) { + if (func_806F8AD4(1, 0) >= arg0->unk4) { + ret = 2; + arg0->unkF = 1; + } else { + ret = 3; + } + } else if (arg0->unkB == -2) { + ret = 1; + } + if (arg0->unkA != 0) { + ret += 4; + } + return ret; +} + +int func_80026250(MenuStruct1 *arg0) { + // TODO: ACTOR_CRANKY? + return (current_actor_pointer->unk58 == 0xBD) && + (arg0->unkA == 0) && + (arg0->unkB < 0); +} + +void func_80026290(MenuStruct1 *arg0, u32 *arg1) { + *arg1 = 0; + arg0->unkF = 1; + arg0->unkB = -1; +} + +// Doable, big though +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_800262A8.s") + +void func_80026684(MenuStruct1 *arg0, s32 arg1, s32 arg2) { + switch (arg0->unkE) { + case 0: + func_800262A8(arg0, arg1, arg2); + return; + case 1: + // TODO: Proper bitfield syntax + if ((s32)(current_actor_pointer->object_properties_bitfield << 6) >= 0) { + arg0->unkE = 0; + arg0->unkD = arg0->unkF; + func_8061CB08(arg0, arg1, arg2); + } + return; + } +} + +s32 func_800266F0(MenuStruct1 *arg0, s32 arg1, s32 flagIndex) { + s32 temp_a2 = !isFlagSet(flagIndex, FLAG_TYPE_PERMANENT); + func_80025FB4(arg0, arg1, temp_a2); + arg0->unkD = 0; + arg0->unkE = 0; + // Global: Jetpac in Story Mode + if (!isFlagSet(0x61, FLAG_TYPE_TEMPORARY)) { + if (temp_a2) { + func_806F397C(player_pointer, current_actor_pointer, 0, 0x1B); + playCutscene(NULL, 0, 1); + } else { + playCutscene(NULL, 4, 1); + func_806EB0C0(0x1B, current_actor_pointer, 0); + } + } else { + func_806EB0C0(0x1B, current_actor_pointer, 0); + playCutscene(NULL, 0xB, 1); + } + func_80629174(); + current_actor_pointer->object_properties_bitfield |= 0x10000000; + return temp_a2; +} + +void func_80026804(MenuStruct1 *arg0, s32 arg1) { + arg0->unkA = 1; + playCutscene(NULL, 0xF, 1); + func_80629174(); + func_80025FB4(arg0, arg1, 0); + arg0->unkD = 0; + arg0->unkE = 0; + func_806EB0C0(0x1B, current_actor_pointer, 0); +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80026874.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80026B28.s") + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80026DAC.s") + +void func_80026B28(MenuStruct1*, s32, s32); +void func_80026DAC(MenuStruct1*, s32, s32); + +void func_80027028(MenuStruct1 *arg0, s32 arg1, s32 flagIndex) { + s32 flagIsNotSet = !isFlagSet(flagIndex, FLAG_TYPE_PERMANENT); + switch (arg0->unkD) { + case 0: + func_80026684(arg0, arg1, flagIsNotSet); + break; + case 1: + func_80026874(arg0, arg1); + break; + case 2: + func_80026B28(arg0, arg1, flagIndex); + break; + case 3: + func_80026DAC(arg0, arg1, flagIndex); + break; + } +} + +// jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_800270E0.s") + +s32 func_800275EC(s32 arg0) { + return arg0 + 0x21F44F; +} + +// Appears to CRC some code and compare to a fixed value +// Perhaps a tamper protection mechanism +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_800275FC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80027738.s") + +/* +// TODO: Pretty close, some minor issues with stack, args, regalloc? +void func_80027738(void) { + s32 var1; + func_80729B00(); + if (current_map == 1) { + s32 var1 = D_807FC950[current_character_index]; + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_800266F0(current_actor_pointer->unk178, var1, 0x176); + } + func_80027028(current_actor_pointer->unk178, var1, 0x176); + } + if ((current_actor_pointer->object_properties_bitfield << 3) != 0) { + func_80729B00(); + func_806BFBF4(); + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80027808.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_1AF0/func_80027988.s") + +void func_80027DEC() { + func_80027988(); +} \ No newline at end of file diff --git a/src/menu/code_3E10.c b/src/menu/code_3E10.c new file mode 100644 index 00000000..317e8116 --- /dev/null +++ b/src/menu/code_3E10.c @@ -0,0 +1,906 @@ +#include +#include "functions.h" +#include "variables.h" + +void func_80737C20(s32); +extern s8 D_80745844; +void func_80030340(Actor*, s32, s32, s32); +void func_8061D4E4(s32); +void func_8060C648(s32 arg0, u8 arg1, u8 arg2, u8 fileIndex, s32 arg4); +s32 func_8060C6B8(s32, s32, s32, u8); +extern s32 D_807F5D10; +extern s8 opening_cutscene_transition; +extern s8 D_80745844; +extern s8 D_8076A0D1; +extern f32 adventure_barrel_scale; +extern f32 adventure_icon_scale; +extern f32 battle_barrel_scale; +extern f32 battle_icon_scale; +extern f32 day_night_transition; +extern f32 foreground_shading_intensity; +extern s8 inputs_enabled_timer; +extern s8 is_in_submenu; +extern s8 is_night; +extern s8 is_raining; +extern s8 menu_cutscene_index; +extern f32 mystery_barrel_scale; +extern f32 mystery_icon_scale; +extern f32 options_barrel_scale; +extern f32 options_icon_scale; +extern f32 sound_barrel_scale; +extern f32 sound_icon_scale; +extern s16 menu_cutscene_timer; +extern s16 D_800336A4[]; +extern void *D_807211D0; +extern void *D_80721444; +extern void *D_80721094; +extern void *D_807210EC; +extern void *D_80721170; +extern s32 D_80720C34; +extern s8 current_file_selection; +extern u8 D_80033F38; +extern void *D_8072052C; +extern s32 D_807204BC; +extern s32 D_80720CF0; +extern s32 D_80720D14; +extern s32 D_80720D14; +extern s32 D_80720C34; +extern s32 D_80720D38; +extern f32 D_80033D50; +extern f32 D_80033D58; +extern s8 D_80033F50; +extern f32 D_80033D54; +extern f32 menu_rotation_speed; +extern f32 menu_rotation_speed_left; +extern f32 menu_rotation_speed_right; +extern s8 menu_selection_available; +extern f32 menu_icon_transition_scale; +extern f32 DK_barrel_scale; + +void func_80030894(MenuAdditionalActorData*,void*,u16,u8,f32,u8,u8); // Param 1 is ActorAdditionalData + +void func_80027E10(void) { + s32 phi_a0 = 1; + switch (D_80745844) { + case 0: + phi_a0 = 2; + break; + case 2: + phi_a0 = 4; + break; + } + func_80737C20(phi_a0); +} + +void func_80027E60(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + s32 phi_v1 = FALSE; + + if (opening_cutscene_transition != 0) { + opening_cutscene_transition++; + if (opening_cutscene_transition >= 0xB) { + phi_v1 = TRUE; + } + } + if ((MaaD->unk0 == 0.0) && (phi_v1 || arg1 & 1)) { + MaaD->unk12 = 1; + MaaD->unk16 = -1; + MaaD->unk0 = 1.0f; + func_80030340(arg0, 0, 0, 0); + func_8061D4E4(D_807F5D10); + playSound(0x2C9, 0x7FFF, 63.0f, 1.25f, 0, 0); + opening_cutscene_transition = 0; + } +} + +s32 func_80027F34(s32 arg0, s32 arg1) { + return arg1; +} + +void func_80027F40(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + player_pointer->x_position = 109.0f; + player_pointer->y_position = 6.0f; + player_pointer->z_position = 55.0f; + MaaD->unk0 = 0.0f; + opening_cutscene_transition = 0; + global_properties_bitfield |= 0x10000; +} + +// Large, doable, struct on the stack? +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80027FAC.s") + +// Displaylist stuff, text labels +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_800286C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80028834.s") + +/* +// TODO: Our stack is too big, that's the only difference +void func_80028834(Actor *arg0, s32 arg1) { + s32 temp; + MenuAdditionalActorData *MaaD; + s32 temp2; + + MaaD = arg0->MaaD; + is_in_submenu = 0; + inputs_enabled_timer = 0; + player_pointer->control_state = 0x85; + player_pointer->control_state_progress = 0; + D_80745844 = func_8060C6B8(0x1E, 0, 0, 0); + func_80027E10(); + MaaD->unk17 = D_8076A0D1; + temp = &D_80721444; + func_80030894(MaaD, &D_80720C34, 0xA0, 0xD2, 0.75f, 2, 0); + func_80030894(MaaD, temp, 0, 0, adventure_barrel_scale, 2, 0x12); + func_80030894(MaaD, temp, 1, 0, options_barrel_scale, 2, 0x12); + func_80030894(MaaD, temp, 2, 0, mystery_barrel_scale, 2, 0x12); + func_80030894(MaaD, temp, 3, 0, battle_barrel_scale, 2, 0x12); + func_80030894(MaaD, temp, 4, 0, sound_barrel_scale, 2, 0x12); + func_80030894(MaaD, &D_8072052C, 0, 0, adventure_icon_scale, 2, 6); + func_80030894(MaaD, &D_807211D0, 1, 0, options_icon_scale, 2, 6); + // Is the mystery menu not unlocked? + if (!isFlagSet(0, FLAG_TYPE_GLOBAL)) { + D_80033F38 = 0; + } + func_80030894(MaaD, &D_80721094, 2, 0, mystery_icon_scale, 2, 7); + // Is the multiplayer menu not unlocked? + if (!isFlagSet(0x1C, FLAG_TYPE_GLOBAL)) { + D_80033F38 = 0; + } + func_80030894(MaaD, &D_807210EC, 3, 0, battle_icon_scale, 2, 6); + func_80030894(MaaD, &D_80721170, 4, 0, sound_icon_scale, 2, 6); + func_80030894(MaaD, &D_80720CF0, 0x122, 0xD2, 0.75f, 2, 0); + player_pointer->x_position = 700.0f; + player_pointer->y_position = 100.0f; + player_pointer->z_position = 70.0f; + menu_cutscene_index = 0; + while (D_800336A4[menu_cutscene_index] != -1) { + menu_cutscene_index++; + } + menu_cutscene_timer = 0x1E; + is_raining = 0; + is_night = 0; + day_night_transition = 0.0f; + foreground_shading_intensity = 1.0f; + global_properties_bitfield &= 0xFFFEFFFF; +} +*/ + +void func_80028C18(void) { + +} + +void func_8002FC1C(Actor*, MenuAdditionalActorData*, s32); +void func_8002FD38(MenuAdditionalActorData*, s32, s32); +void func_8002FE08(MenuAdditionalActorData*, s32); +extern s8 D_80033F48; + +void func_80028C20(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD; + s32 three = 3; + + MaaD = arg0->MaaD; + if (MaaD->unk0 == 0.0f) { + if (MaaD->unk4 == 0.0f) { + if (arg1 & 1) { + MaaD->unk16 = 0; + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + if (MaaD->unk17 == 2) { + MaaD->unk13 = 4; + } else { + D_80033F48 = MaaD->unk17; + if (D_80033F48 == three) { + D_80033F48 = 2; + } + MaaD->unk13 = three; + } + } else if (arg1 & 2) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 1; + } else { + func_8002FD38(MaaD, 4, arg1); + } + } + func_8002FE08(MaaD, 4); + } + func_8002FC1C(arg0, MaaD, 1); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80028D3C.s") + +s32 func_800322D0(s8); + +void func_80028EA8(Actor *arg0, s32 arg1) { + PlayerAdditionalActorData* PaaD; + + PaaD = arg0->PaaD; // TODO: Probably MaaD + PaaD->unk17 = current_file_selection; + func_80030894(PaaD, &D_80720C34, 0xA0, 0x78, 0.75f, 2, 4); + arg1 = &D_8072052C; + if (func_800322D0(0)) { + D_80033F38 = 0; + } + func_80030894(PaaD, arg1, 0, 0, 1.0f, 2, 2); + if (func_800322D0(1)) { + D_80033F38 = 0; + } + func_80030894(PaaD, arg1, 1, 0, 1.0f, 2, 2); + if (func_800322D0(2)) { + D_80033F38 = 0; + } + func_80030894(PaaD, arg1, 3, 0, 1.0f, 2, 2); + func_80030894(PaaD, &D_807204BC, 2, 0, 1.0f, 2, 2); + func_80030894(PaaD, &D_80720CF0, 0x122, 0xD2, 0.75f, 2, 0); + func_80030894(PaaD, &D_80720D14, 0x23, 0xD2, 0.75f, 2, 0); +} + +void func_8002907C(void); + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002907C.s") + +extern u8 D_80033818; // Current input index +extern u16 D_8003381C[] = {U_JPAD, L_JPAD, U_JPAD, D_JPAD, R_JPAD, D_JPAD, Z_TRIG}; // Required input sequence +extern s8 D_807563B4; // Enable stack trace upon crash + +/* +// Button code on controller to enable stack trace upon crash +// Accessible from the sound menu +// TODO: Regalloc, goddamnit +void func_8002907C(void) { + if (newly_pressed_input == D_8003381C[D_80033818]) { + D_80033818++; + if (D_80033818 >= 7U) { + D_807563B4 = TRUE; + playSound(0x23C, 0x7FFF, 63.0f, 1.0f, 0, 0); + D_80033818 = 0; + } + } else { + if (newly_pressed_input != 0) { + D_80033818 = 0; + } + } +} +*/ + +void func_8002FC1C(Actor *, MenuAdditionalActorData *, s32); +void func_8060AA58(s32); +void func_807144B8(s8); +extern s8 D_80033F48; + +void func_80029114(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + + if ((MaaD->unk0 == 0.0f) && (MaaD->unk4 == 0.0f)) { + if (arg1 & 1) { + func_8060AA58(1); + func_807144B8(D_80033F48); + } else if ((arg1 & 2) != 0) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 2; + } + } + func_8002FC1C(arg0, MaaD, 1); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_800291CC.s") + +s32 func_800297A8(s32 arg0) { + return arg0 + 0x1EFF0; +} + +// Suspect, CRC, polymorphic code? Tamper protection? +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_800297B8.s") + +void func_80029AAC(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + if (MaaD->unk0 == 0.0f) { + if (MaaD->unk4 == 0.0f) { + if ((arg1 & 1) != 0) { + if (func_800322D0(MaaD->unk17) == 0) { + MaaD->unk16 = 0; + MaaD->unk13 = 5; + D_80033F48 = MaaD->unk17; + } else { + playSound(0x98, 0x7FFF, 63.0f, 1.0f, 0, 0); + } + } else if ((arg1 & 2) != 0) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 2; + } else { + func_8002FD38(MaaD, 3, arg1); + } + } + func_8002FE08(MaaD, 3); + } + func_8002FC1C(arg0, MaaD, 1); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80029BB4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80029D30.s") + +/* +// TODO: Similar to one I ran into before... Not sure why it doesn't match +void func_80029D30(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + MaaD->unk17 = 0; + func_80030894(MaaD, &D_80720CF0, 0x122, 0xD2, 0.75f, 2, 0); + func_80030894(MaaD, &D_80720D14, 0x23, 0xD2, 0.75f, 2, 0); + if (func_800322D0(0)) { + D_80033F38 = 0; + } + func_80030894(MaaD, &D_8072052C, 0, 0, 1.0f, 2, 3); + if (func_800322D0(1)) { + D_80033F38 = 0; + } + func_80030894(MaaD, &D_8072052C, 1, 0, 1.0f, 2, 3); + if (func_800322D0(2)) { + D_80033F38 = 0; + } + func_80030894(MaaD, &D_8072052C, 2, 0, 1.0f, 2, 3); + func_80030894(MaaD, &D_807204BC, 0xA0, 0x78, 1.0f, 2, 4); + func_80030894(MaaD, &D_80720C34, 0xA0, 0xD2, 0.75f, 2, 0); +} +*/ + +extern void* D_8071FBC8; +extern void* D_8071FE08; +extern s8 D_80033FAC; + +void func_8060C830(u8, s32); + +void func_80029EF8(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + if ((MaaD->unk0 == 0.0f) && (MaaD->unk4 == 0.0f)) { + if (arg1 & 1) { + if ((arg1 & 8) && (D_80033FAC != 0)) { + func_8071495C(); + func_80714CC0(&D_8071FBC8, 10.3f, 240.0f, 120.0f, -10.0f); + func_8071495C(); + func_80714CC0(&D_8071FE08, 10.3f, 240.0f, 120.0f, -10.0f); + playSound(0xF6, 0x7FFF, 63.0f, 1.0f, 0, 0); + func_8060C830(D_80033F48, 1); + MaaD->unk16 = 0; + MaaD->unk13 = 2; + } else if ((arg1 & 4) && (D_80033FAC != 0)) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 2; + } + } else if (arg1 & 2) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 2; + } + } + func_8002FC1C(arg0, MaaD, 1); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002A088.s") + +void func_8002A36C(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + + D_80033FAC = 0; + MaaD->unk17 = 0; + func_80030894(MaaD, &D_80720CF0, 0x122, 0xD2, 0.75f, 2, 0); + func_80030894(MaaD, &D_80720D14, 0x23, 0xD2, 0.75f, 2, 0); + func_80030894(MaaD, &D_807204BC, 0xA0, 0x80, 1.0f, 2, 8); + func_80030894(MaaD, &D_80720C34, 0xA0, 0xD2, 0.75f, 2, 0); +} + +extern s16 D_80033670; +extern s8 D_80744538; +extern s8 D_8076A104; +extern s8 barrel_visibility_timer; + +void func_8002A468(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + if (MaaD->unk0 == 0.0f) { + if (MaaD->unk4 == 0.0f) { + if ((arg1 & 1) != 0) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 7; + } else if ((arg1 & 2) != 0) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 1; + barrel_visibility_timer = 3; + } else { + func_8002FD38(MaaD, 2, arg1); + } + if (MaaD->unk17 == 0) { + if (((D_80033670 & 0x10) == 0) && ((arg1 & 0x10) != 0)) { + playSound(0x75, 0x7FFF, 63.0f, 1.0f, 0, 0); + D_80744538 += 1; + if (D_80744538 >= 3) { + D_80744538 = 0; + } + } else if ((( D_80033670 & 0x20) == 0) && ((arg1 & 0x20) != 0)) { + playSound(0x75, 0x7FFF, 63.0f, 1.0f, 0, 0); + D_80744538 += -1; + if (D_80744538 < 0) { + D_80744538 = 2; + } + } + } + } + func_8002FE08(MaaD, 2); + } + D_8076A104 = MaaD->unk17; + func_8002FC1C(arg0, MaaD, 1); +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002A638.s") + +// Doable, but a tiny fiddly loop +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002AA98.s") + +// Doable but fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002AB28.s") + +// Related to above, doable but fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002AB80.s") + +// Related to above, doable but fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002ACD4.s") + +// Related to above, doable but fiddly +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002AD50.s") + +// Huge, something to do with inputs +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002ADC8.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002B708.s") + +// Huge, fiddly struct negative offset stuff +// Reasonably doable though +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002C0C8.s") + +void func_8002F8EC(); +void func_8002FC1C(Actor*, MenuAdditionalActorData*, s32); + +void func_8002C584(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + + if (MaaD->unk0 == 0.0 && arg1 & 1) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 7; + } + func_8002FC1C(arg0, MaaD, 0); + func_8002F8EC(); + global_properties_bitfield &= ~0x10; + global_properties_bitfield |= 0x10000; +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002C634.s") + +// Weird negative struct offset stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002C91C.s") + +// TODO: Huge, very doable, need energy +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002CB18.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002CFA4.s") + +extern s16 D_80033670; +extern s8 D_8074583C; +extern s8 D_80745840; +extern s8 D_80745844; + +void func_8060DEA8(); +typedef struct MenuStruct7 { + s16 unk0; + u8 unk2; + u8 unk3; + u8 unk4; + u8 unk5; +} MenuStruct7; +extern MenuStruct7 D_80744548[]; +extern MenuStruct7 D_80744568[]; + +s32 func_80737B58(s32, u16); +void func_8060A398(s32); + +/* +// TODO: Regalloc v0 v1 +void func_8002CFA4(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + s8 sp23 = FALSE; + + func_8002907C(); + if (MaaD->unk0 == 0.0f) { + if (MaaD->unk4 == 0.0f) { + switch (MaaD->unk17) { + case 0: + if (!(D_80033670 & 0x10) && (arg1 & 0x10)) { + D_80745844++; + if (D_80745844 > 2) { + D_80745844 = 0; + } + sp23 = TRUE; + } else if (!(D_80033670 & 0x20) && (arg1 & 0x20)) { + D_80745844--; + if (D_80745844 < 0) { + D_80745844 = 2; + } + sp23 = TRUE; + } + if (sp23) { + func_80027E10(); + } + break; + case 1: + if (arg1 & 0x10) { + // Regalloc is here + D_8074583C++; + playSound(0x2A0, 0x7FFF, 63.0f, 1.0f, 0, 0); + if (D_8074583C > 0x28) { + D_8074583C = 0x28; + } + } else if (arg1 & 0x20) { + // Regalloc is here + D_8074583C--; + playSound(0x2A0, 0x7FFF, 63.0f, 1.0f, 0, 0); + if (D_8074583C < 0) { + D_8074583C = 0; + } + } + func_80737B58(0, ((D_8074583C * 0x61A8) / 40)); + func_80737B58(1, ((D_8074583C * 0x61A8) / 40)); + func_80737B58(2, ((D_8074583C * 0x61A8) / 40)); + func_80737B58(3, ((D_8074583C * 0x61A8) / 40)); + break; + case 2: + if (arg1 & 0x10) { + D_80745840++; + if (D_80745840 >= 0x29) { + D_80745840 = 0x28; + } + } else if (arg1 & 0x20) { + D_80745840--; + if (D_80745840 < 0) { + D_80745840 = 0; + } + } + func_8060A398(0); + func_8060A398(2); + break; + case 3: + if (arg1 & 0x100) { + D_80745844 = 0; + D_8074583C = 0x28; + D_80745840 = 0x28; + func_80737B58(0, ((D_8074583C * 0x61A8) / 40)); + func_80737B58(1, ((D_8074583C * 0x61A8) / 40)); + func_80737B58(2, ((D_8074583C * 0x61A8) / 40)); + func_80737B58(3, ((D_8074583C * 0x61A8) / 40)); + func_8060A398(0); + func_8060A398(2); + sp23 = 1; + func_80027E10(); + } + break; + } + if (arg1 & 2) { + if (func_8060C6B8(0x1E, 0, 0, 0) != D_80745844) { + func_8060C648(0x1E, 0, 0, 0, D_80745844); + func_8060DEA8(); + } + playSound(0x2C9, 0x7FFF, 63.0f, 1.0f, 0, 0); + MaaD->unk16 = 0; + MaaD->unk13 = 1; + } else { + func_8002FD38(MaaD, 4, arg1); + } + } + func_8002FE08(MaaD, 4); + } + func_8002FC1C(arg0, MaaD, 1); + if (sp23) { + playSound(0x74, 0x7FFF, 63.0f, 1.0f, 0, 0); + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002D520.s") + +void func_8002D7EC(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + + MaaD->unk17 = 0; + func_80030894(MaaD, &D_80720D14, 0x23, 0xD2, 0.75f, 2, 0); + func_80030894(MaaD, &D_80720C34, 0xA0, 0x7D, 0.75f, 2, 4); + func_80030894(MaaD, &D_80720D38, 0xA0, 0xC8, 1.0f, 2, 0xC); +} + +// Jumptable, 816 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002D8AC.s") + +// Jumptable, 780 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002DBDC.s") + +void func_8002DEE8(Actor *arg0, s32 arg1) { + MenuAdditionalActorData *MaaD = arg0->MaaD; + + MaaD->unk17 = 0; + func_80030894(MaaD, &D_80720D14, 0x23, 0xD2, 0.75f, 2, 0); + func_80030894(MaaD, &D_80720C34, 0xA0, 0x7D, 0.75f, 2, 4); + func_80030894(MaaD, &D_80720D38, 0xA0, 0xC8, 1.0f, 2, 0xC); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002DFA8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002E420.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002E8B8.s") + +// Doable, but some weird struct offset stuff going on again +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002ECE8.s") + +void func_8002EE18(void) { + s32 i; + for (i = 0; i < 5; i++) { + func_8060C648(0x19, 0, i, 0, D_80744548[i].unk0); + func_8060C648(0x16, 0, i, 0, D_80744548[i].unk2); + func_8060C648(0x17, 0, i, 0, D_80744548[i].unk3); + func_8060C648(0x18, 0, i, 0, D_80744548[i].unk4); + func_8060C648(0x1D, 0, i, 0, D_80744568[i].unk0); + func_8060C648(0x1A, 0, i, 0, D_80744568[i].unk2); + func_8060C648(0x1B, 0, i, 0, D_80744568[i].unk3); + func_8060C648(0x1C, 0, i, 0, D_80744568[i].unk4); + } + func_8060DEA8(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002EF68.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002F284.s") + +extern s8 D_80033F60; +void func_8002F6C8(Actor *arg0, s32 arg1) { + PlayerAdditionalActorData* PaaD = arg0->PaaD; // TODO: Might be MaaD + + if (D_80033F60 == -1) { + func_80030894(PaaD, &D_80720CF0, 0x122, 0xD2, 0.75f, 2, 0); + func_80030894(PaaD, &D_80720D14, 0x23, 0xD2, 0.75f, 2, 0); + } +} + +// Negative struct offset nonsense +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002F75C.s") + +extern f32 D_80033D44; + +void func_8002F8EC() { + character_change_array->look_at_eye_x = player_pointer->x_position; + character_change_array->look_at_eye_y = player_pointer->y_position + D_80033D44; + character_change_array->look_at_eye_z = player_pointer->z_position - 50.0f; + character_change_array->look_at_at_x = player_pointer->x_position; + character_change_array->look_at_at_y = character_change_array->look_at_eye_y; + character_change_array->look_at_at_z = player_pointer->z_position - 100.0f; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002F980.s") + +// Needs .rodata? +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002FB88.s") + +void func_8002FC1C(Actor *arg0, MenuAdditionalActorData *MaaD, s32 arg2) { + if (MaaD->unk16 == 0) { + MaaD->unk0 += D_80033D50; + if (D_80033D54 < MaaD->unk0) { + MaaD->unk0 = 1.0f; + MaaD->unk12 = MaaD->unk13; + MaaD->unk16 = -1; + func_80030340(arg0, 0, 0, 0); + playSound(0x2C9, 0x7FFF, 63.0f, 1.25f, 0, 0); + } + } else { + if (MaaD->unk0 > 0.0f) { + MaaD->unk0 -= D_80033D58; + if (MaaD->unk0 < 0.0f) { + MaaD->unk0 = 0.0f; + if (arg2 != 0) { + playSound(0x3C, 0x61A8, 63.0f, 1.0f, 0, 0); + D_80033F50 = 3; + } + } + } + } +} + +void func_8002FD38(MenuAdditionalActorData *MaaD, s32 arg1, s32 arg2) { + if (arg2 & 4) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.25f, 0, 0); + menu_rotation_speed = menu_rotation_speed_left; + MaaD->unk17--; + MaaD->unk4 = 1.0f; + if (MaaD->unk17 < 0) { + MaaD->unk17 += arg1; + } + menu_selection_available = 0; + } else if (arg2 & 8) { + playSound(0x2C9, 0x7FFF, 63.0f, 1.25f, 0, 0); + menu_rotation_speed = menu_rotation_speed_right; + menu_selection_available = 0; + } +} + +void func_8002FE08(MenuAdditionalActorData *MaaD, s32 arg1) { + if (menu_rotation_speed > 0.0f) { + MaaD->unk4 += menu_rotation_speed; + if (MaaD->unk4 >= 1.0f) { + MaaD->unk4 = 0.0f; + MaaD->unk17++; + if (MaaD->unk17 >= arg1) { + MaaD->unk17 -= arg1; + } + menu_rotation_speed = 0.0f; + } + } else if (menu_rotation_speed < 0.0f) { + MaaD->unk4 += menu_rotation_speed; + if (MaaD->unk4 <= 0.0f) { + menu_rotation_speed = 0.0f; + MaaD->unk4 = 0.0f; + } + } +} + +// Jumptable, 916 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8002FEBC.s") + +void func_80030250(void) { + +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80030258.s") + +/* +extern Gfx **D_1000118; +extern Mtx D_20000C0; + +void func_80030258(Gfx *dl, s32 arg1) { + gDPPipeSync(dl++); + gSPDisplayList(dl++, &D_1000118); + gDPSetCycleType(dl++, G_CYC_1CYCLE); + gDPSetRenderMode(dl++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetPrimColor(dl++, 0, 0, 0xBF, 0x80, 0x00, 0x00); + gDPSetCombineMode(dl++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gSPMatrix(dl++, &D_20000C0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + func_80030340(arg1, 1, dl, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80030340.s") + +// Jumptable, 508 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80030894.s") + +// Doable, big unknown struct passed in though +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80030A90.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80030C14.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_8003155C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_800317E8.s") + +// Float maths, looks doable, not sure which struct is passed in arg0 though +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80031980.s") + +// Jumptable, 172 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80031A5C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80031B08.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80032024.s") + +extern s8 D_80033738; + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + f32 unk10; + f32 unk14; + f32 unk18; + f32 unk1C; + f32 unk20; + f32 unk24; + f32 unk28; + f32 unk2C; + f32 unk30; + f32 unk34; + f32 unk38; + f32 unk3C; + f32 unk40; + f32 unk44; + f32 unk48; + f32 unk4C; +} Struct8003378C; + +extern Struct8003378C D_8003378C; + +void func_80626F8C(f32, f32, Actor *, f32, f32 *, f32 *, s32, f32, s32); + +/* +// TODO: Pretty close +void func_80032024(void) { + MenuAdditionalActorData *MaaD; + f32 sp70; + f32 sp6C; + f32 sp68; + f32 sp64; + f32 sp60; + f32 sp5C; + f32 sp54; + f32 sp50; + f32 temp_f0; + f32 temp_f0_2; + s32 pad; + + MaaD = current_actor_pointer->MaaD; + if (player_pointer->control_state_progress < 6) { + if (D_80033738 == 0x14) { + func_806782C0(current_actor_pointer); + D_80033738++; + func_80677FA8(0x14D, 0xD7); + temp_f0 = DK_barrel_scale; + D_807FBB44->animation_state->scale_x = temp_f0; + D_807FBB44->animation_state->scale_y = temp_f0; + D_807FBB44->animation_state->scale_z = temp_f0; + } else if (D_80033738 == 0x15) { + func_80671C0C(player_pointer, 2, &sp6C, &sp64, &sp5C); + func_80671C0C(player_pointer, 3, &sp70, &sp68, &sp60); + current_actor_pointer->x_position = (sp70 + sp6C) * 0.5f; + current_actor_pointer->y_position = sp64; + current_actor_pointer->z_position = (sp60 + sp5C) * 0.5f; + MaaD->unk0 = current_actor_pointer->x_position; + MaaD->unk4 = current_actor_pointer->y_position; + MaaD->unk8 = current_actor_pointer->z_position; + current_actor_pointer->y_rotation = 0; + current_actor_pointer->z_rotation = 0x400; + func_80626F8C(current_actor_pointer->x_position, current_actor_pointer->y_position, current_actor_pointer, current_actor_pointer->z_position, &sp54, &sp50, 0, 1.0f, 0); + temp_f0_2 = sp50 - 120.0f; + if (temp_f0_2 < -35.0f && temp_f0_2 > -75.0f) { + D_8003378C.unk0 = temp_f0_2; + D_8003378C.unk44 = temp_f0_2; + } + } + } else { + current_actor_pointer->x_position = MaaD->unk0; + current_actor_pointer->y_position = MaaD->unk4 - (menu_icon_transition_scale * 19.0f); + current_actor_pointer->z_position = MaaD->unk8 - (menu_icon_transition_scale * 50.0f); + } + func_806319C4(current_actor_pointer, 0); + if (barrel_visibility_timer != 0) { + current_actor_pointer->object_properties_bitfield &= ~4; + } else { + current_actor_pointer->object_properties_bitfield |= 4; + } +} +*/ + +s32 func_800322D0(s8 arg0) { + return !func_8060C6B8(0xD, 0, 0, arg0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_80032304.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_3E10/func_800324CC.s") diff --git a/src/menu/code_E550.c b/src/menu/code_E550.c new file mode 100644 index 00000000..58ff9c77 --- /dev/null +++ b/src/menu/code_E550.c @@ -0,0 +1,42 @@ +#include +#include "functions.h" +#include "variables.h" + +s32 func_80629148(void); +void func_806319C4(Actor*, s32); +void func_8068A858(s32 *, s32 *, s32 *); +void func_80729B00(); +extern s32 D_80033FB0; +extern s32 D_80033FB1; +extern s32 D_80033FB2; + +void func_80032550(void) { + Actor *phi_a0_2; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + current_actor_pointer->control_state = 0; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->unkCD = 1; + current_actor_pointer->object_properties_bitfield &= ~4; + } + if (current_actor_pointer->object_properties_bitfield & 4) { + func_8068A858(&D_80033FB0, &D_80033FB1, &D_80033FB2); + } + if ((current_actor_pointer->control_state == 0) && (current_actor_pointer->control_state_progress == 0)) { + if (func_80629148()) { + func_80629174(); + func_80614EBC(current_actor_pointer, 0x2A7); + current_actor_pointer->control_state_progress++; + } + // TODO: Get rid of this somehow, surprisingly getting rid of it causes it to not match + phi_a0_2 = current_actor_pointer; + } + func_806319C4(current_actor_pointer, 0); +} + +// Jumptable, 736 bytes of code +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_E550/func_8003264C.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/menu/code_E550/func_8003292C.s") diff --git a/src/minecart/code_0.c b/src/minecart/code_0.c new file mode 100644 index 00000000..e9df6352 --- /dev/null +++ b/src/minecart/code_0.c @@ -0,0 +1,108 @@ +#include +#include "functions.h" +#include "variables.h" + +s32 func_8070E750(s32, s32, s32); + +void func_80024000(u8 arg0, u8 arg1) { + playSound(0x143, 0x7FFF, 63.0f, 1.0f, 0, 0); + func_8069D2AC(0x81, 0, 0x78, func_8070E750(0x1A, arg1, 1), 0, 0x28, 8, 8); + current_actor_pointer->unk11C->control_state = 0; + playSong(0x28, 1.0f); + func_806EB0C0(0x44, NULL, 0); + current_actor_pointer->control_state++; + if (arg0 != 0) { + playCutscene(player_pointer, 5, 5); + } +} + +void func_800240DC(u8 arg0, u8 arg1) { + s32 temp = func_8070E750(0x1A, arg1, 1); + func_8069D2AC(0x81, 0, 0x78, temp, 0, 0x28, 8, 8); + current_actor_pointer->unk11C->control_state = 0; + playSong(0x2A, 1.0f); + func_806EB0C0(0x43, NULL, 0); + current_actor_pointer->control_state++; + if (arg0 != 0) { + playCutscene(player_pointer, 5, 5); + } +} + +extern s32 D_8071A440; // TODO: Proper datatype +extern s32 D_80028C30; // TODO: Proper datatype +extern s32 D_8072006C; // TODO: Proper datatype + +s32 func_80714C08(void*, f32, Actor*, s32, s32); +u8 func_806119A0(void); + +void func_800241A0(s16 *arg0, u8 arg1, u8 arg2) { + // TODO: Get rid of this typecast if possible + if (((func_806119A0() & 0xFF) >= (u32)arg2) && (*arg0 == 0)) { + func_80608528(current_actor_pointer, 0x8A, 0x96, 0x7F, 0x32); + func_80714950(current_actor_pointer); + func_8071498C(&D_8071A440); + D_80028C30 = func_80714C08(&D_8072006C, 0.4f, current_actor_pointer, arg1 + 7, 2); + } +} + +// struct spaghetti +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_80024254.s") + +// jumptable, can't auto decompile +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_8002430C.s") + +void func_8065A660(f32, f32); +void func_8065A6F8(s32); +void func_8065A708(f32, f32, f32, f32, f32, f32, f32, s32, s32, s32, s32); + +void func_80024768(void) { + f32 sp4C; + f32 sp48; + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + + if (extra_player_info_pointer->unk1F0 & 0x10000002) { + func_80671C0C(current_actor_pointer, 2, &sp38, &sp3C, &sp40); + func_80671C0C(current_actor_pointer, 1, &sp44, &sp48, &sp4C); + } else { + func_80671C0C(current_actor_pointer, 1, &sp38, &sp3C, &sp40); + func_80671C0C(current_actor_pointer, 2, &sp44, &sp48, &sp4C); + } + func_8065A6F8(0xC8); + func_8065A660(20.0f, 40.0f); + func_8065A708(sp38, sp3C, sp40, sp44, sp48, sp4C, 0.0f, 1, 0xFF, 0xFF, 0xFF); +} + +// struct float aaa +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_80024890.s") + +// struct float aaa +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_80024914.s") + +// long, structs +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_80024B00.s") + +// struct, loop +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_80024E78.s") + +// jumptable, can't auto decompile +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_80024FD0.s") + +typedef struct minecart_struct_0 { + u8 pad0[0x20]; + f32 unk20; + f32 unk24; + f32 unk28; +} MinecartStruct0; + +void func_8002538C(MinecartStruct0 *arg0) { + arg0->unk20 = arg0->unk20 + arg0->unk24; + if (arg0->unk28 < arg0->unk20) { + arg0->unk20 = arg0->unk28; + } +} + +// huge, struct, float, loop +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_0/func_800253C0.s") diff --git a/src/minecart/code_25F0.c b/src/minecart/code_25F0.c new file mode 100644 index 00000000..7809cc9f --- /dev/null +++ b/src/minecart/code_25F0.c @@ -0,0 +1,101 @@ +#include +#include "functions.h" +#include "variables.h" + +// jumptable, can't auto decompile +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_800265F0.s") + +f32 func_80612794(s16); + +typedef struct MinecartStruct0 { + s32 unk0; + s32 unk4; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; +} MinecartStruct0; + +void func_80026B6C(MinecartStruct0 *arg0, f32 arg1) { + arg0->unkA = func_80612794(player_pointer->y_rotation) * (extra_player_info_pointer->vehicle_actor_pointer->unkB8 * arg1) + player_pointer->x_position; + arg0->unkC = extra_player_info_pointer->vehicle_actor_pointer->floor; + arg0->unkE = func_80612790(player_pointer->y_rotation) * (extra_player_info_pointer->vehicle_actor_pointer->unkB8 * arg1) + player_pointer->z_position; +} + +extern s32 D_8074E880[]; +extern s32 D_80717D4C; // TODO: Datatype + +void func_80026C54(void) { + func_80714950(((rand() >> 0xF) % 100) + 300); + func_8071498C(&D_80717D4C); + func_807149B8(1); + func_80714A28(4); + func_80714CC0(D_8074E880[((rand() >> 0xF) % 1000) % 3], + 0.5f, + ((rand() >> 0xF) % 20) + (current_actor_pointer->x_position - 10.0f), + current_actor_pointer->y_position, + ((rand() >> 0xF) % 20) + (current_actor_pointer->z_position - 10.0f)); +} + +// huge, jumptable, can't auto decompile +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_80026DA8.s") + +// jumptable, can't auto decompile +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_80027778.s") + +// probably doable, disable &&/|| for cleaner output +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_80027CF4.s") + +// small, structs, TRIPLE dereference +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_80027DA0.s") + +// structs +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_80027E04.s") + +// structs, floats +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_80027EE8.s") + +/* WIP: not too bad +f32 func_8000AC60(f32); +void func_80608528(Actor *, s32, s32, s16, s32); +s32 func_806119A0(); +extern f64 D_80028DD8; +typedef struct MinecartStruct1 { + u8 pad0[0x3A]; + u8 unk3A; + u8 unk3B; + s16 unk3C; +} MinecartStruct1; + +void func_80027EE8(MinecartStruct1 *arg0) { + f32 temp_f0_3; + f64 temp_f18; + s32 temp_v0_2; + u8 temp_t7; + f64 phi_f18; + + temp_f0_3 = func_8000AC60((current_actor_pointer->x_position - D_807FDC94->x_position) * (current_actor_pointer->x_position - D_807FDC94->x_position) + + (current_actor_pointer->y_position - D_807FDC94->y_position) * (current_actor_pointer->y_position - D_807FDC94->y_position) + + (current_actor_pointer->z_position - D_807FDC94->z_position) * (current_actor_pointer->z_position - D_807FDC94->z_position)); + if (temp_f0_3 < 200.0f) { + arg0->unk3A++; + if (arg0->unk3A >= 9) { + func_80608528(current_actor_pointer, 0x1F, 0xFF, 127.0f - (temp_f0_3 - (f32) arg0->unk3C), 0); + phi_f18 = func_806119A0(); + if (phi_f18 < 0) { + phi_f18 = phi_f18 + 4294967296.0; + } + arg0->unk3A = (u8) (u32) ((phi_f18 / D_80028DD8) * 3.0); + } + } + arg0->unk3C = (s16) temp_f0_3; +}*/ + +// big, structs, floats +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_800280BC.s") + +// big, structs, floats +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_8002835C.s") + +// big, structs, floats +#pragma GLOBAL_ASM("asm/nonmatchings/minecart/code_25F0/func_800286EC.s") diff --git a/src/multiplayer/code_0.c b/src/multiplayer/code_0.c new file mode 100644 index 00000000..e7229d17 --- /dev/null +++ b/src/multiplayer/code_0.c @@ -0,0 +1,236 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80024000.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800241F4.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80024254.s") + +typedef struct MultiplayerStruct4 { + u8 pad0[0x4C]; + u8 unk4C; +} MultiplayerStruct4; +void func_800242FC(MultiplayerStruct4 *); + +extern s32 D_807552EC; +extern s8 D_8076A105; // A player index + +extern u8 D_80026F70; +// TODO: Is this a PaaD? +typedef struct MultiplayerStruct0 { + u8 pad0[0x1A4]; + u8 unk1A4; +} MultiplayerStruct0; + +void func_806F91B4(s32, u8, s16); +extern s32 D_807552E8; +void func_800269C8(u8, s32); +s32 func_80026BD8(s32); +void func_806C9434(s32); +void func_806CFF9C(Actor*); + +void func_800242FC(MultiplayerStruct4 *arg0) { + s32 temp_v0; + s32 playerIndex; + s32 phi_s1; + s32 phi_s2; + + D_807552EC = 2; + phi_s2 = 0; + phi_s1 = -99999; + for (playerIndex = 0; playerIndex < cc_number_of_players; playerIndex++) { + temp_v0 = func_80024254(playerIndex); + if (phi_s1 < temp_v0) { + phi_s1 = temp_v0; + phi_s2 = playerIndex; + } else if (temp_v0 == phi_s1) { + phi_s2 = -1; + } + } + global_properties_bitfield |= 0x40001; + func_80714638(); + D_8076A105 = phi_s2; +} + +// u64 nonsense, bleh, PaaD? +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800243C8.s") + +void func_8002449C(void) { + s32 temp_v0; + s32 playerIndex; + + for (playerIndex = 0; playerIndex < cc_number_of_players; playerIndex++) { + temp_v0 = func_80024254(playerIndex); + if ((temp_v0 >= D_807552E4.unkC) || (temp_v0 < -999)) { + func_800242FC(current_actor_pointer->additional_actor_data); + return; + } + } +} + +void func_8002452C(void) { + s32 a = 0; + s32 playerIndex; + + for (playerIndex = 0; playerIndex < cc_number_of_players; playerIndex++) { + if (func_80024254(playerIndex)) { + a++; + } + } + if (a < 2) { + // TODO: Which aaD type are they actually expecting here? + func_800242FC(current_actor_pointer->PaaD); + } +} + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800245B0.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800246EC.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800249D8.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80024CA4.s") + +// Displaylist stuff +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025264.s") + +// D_80026FA4 struct array? Loop +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025378.s") + +s32 func_800253C8(void) { + return (((rand() >> 0xF) % 32767) % 211) + 90; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025404.s") + +// Weird stack stuff +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025608.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025654.s") + +/* +//s32 func_80024254(s32); +void func_800243C8(); +typedef struct MultiplayerStruct3 { + s16 unk0; + s16 unk2; + s16 unk4; +} MultiplayerStruct3; +typedef struct MultiplayerStruct2 { + u8 pad0[0x8]; + MultiplayerStruct3* unk8; +} MultiplayerStruct2; +MultiplayerStruct2 *func_80025378(); +s32 func_80025404(); +s32 func_80025608(s32); +Actor *func_8067ADB4(s32); +s32 func_806F5EB4(s32, s32, s16, s16, s32); +void func_806F5FE8(s32, s16, s16, s16, s32); +extern s32 D_807552E8; +extern s32 D_807552F0; + +// TODO: Pretty close, but dealing with fiddly logic and stack stuff is a pain +void func_80025654(MultiplayerStruct4 *arg0) { + MultiplayerStruct3 *sp20; + s32 temp_v0; + + sp20 = func_80025378()->unk8; + if (gameIsInAdventureMode() && ((global_properties_bitfield & 2) == 0)) { + if (D_807552E8 == 3) { + func_800243C8(); + } + temp_v0 = func_80025404(); + if (temp_v0 == -1) { + if ((arg0->unk4C == 0) && + (!func_8067ADB4(0x7A)) && // DK Coin (Multiplayer) + (func_80025608(0x1D2) == 0) && + (func_806F5EB4(0x1D2, 0, sp20->unk0, sp20->unk2, sp20->unk4) == 0)) { + func_806F5FE8(0x1D2, sp20->unk0, sp20->unk2, sp20->unk4, 0xA); + } + } else if ((D_807552E8 == 5) && (func_80024254(temp_v0) >= D_807552F0)) { + func_800242FC(arg0); + } + if (arg0->unk4C != 0) { + arg0->unk4C--; + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025794.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025B48.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025CE8.s") + +// Doable, loop, struct +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025F84.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80025FFC.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80026094.s") + +void func_800268C0(u8 arg0) { + D_80026F70 |= arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800268DC.s") + +void func_8002698C(MultiplayerStruct0 *arg0) { + if (D_807552E8 == 2) { + func_806F91B4(1, arg0->unk1A4, -3); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_800269C8.s") + +void func_80026B0C(s32 arg0) { + Actor *player = character_change_array[arg0].player_pointer; + player->noclip_byte = 0xC; + switch (D_807552E8) { + case 2: + func_806F91B4(1, arg0, -3); + return; + case 5: + func_806F91B4(7, arg0, -0x40); + case 3: + func_800269C8(arg0, 0); + return; + case 4: + func_806F91B4(7, arg0, -1); + return; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80026BD8.s") + +typedef struct MultiplayerStruct1 { + u8 pad0[0x306]; +} MultiplayerStruct1; +extern MultiplayerStruct1 D_807FCC4B[]; + +void func_80026D40(Actor *arg0, s32 arg1) { + if ((D_807552E8 == 4) && (func_80024254(arg1) == 0)) { + D_807FCC4B[arg1].pad0[0] = 0; + arg0->control_state_progress++; + func_806EB0C0(0x5B, NULL, arg1); + arg0->noclip_byte = 1; + } else { + func_806C9434(func_80026BD8(arg1)); + character_change_array[arg1].unk2E2 |= 1; + func_806CFF9C(arg0); + } +} + +// Surprisingly doable, PaaD and CharacterChange, maybe a sus u16/s16 array/struct lookup +#pragma GLOBAL_ASM("asm/nonmatchings/multiplayer/code_0/func_80026E20.s") diff --git a/src/race/code_0.c b/src/race/code_0.c new file mode 100644 index 00000000..425254fa --- /dev/null +++ b/src/race/code_0.c @@ -0,0 +1,789 @@ +#include +#include "functions.h" +#include "variables.h" + + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80024000.s") + +extern s32 D_8002FC5C[]; +extern s32 D_8002FCAC[]; + +extern u16 D_80750AC4; + +s32 func_8002E8EC(s32, s32, s32); +s32 func_8002E8EC(s32 arg0, s32 arg1, s32 arg2); +void func_80025E9C(Actor *); +void func_80025FDC(); +void func_80029488(); +void func_8002E9F8(s32 *checkpointFile); +void func_8002BCD4(Actor *); +void func_8002D064(); +void func_8002D0FC(); + +void func_805FF544(); +void func_80604CBC(Actor *, s32, s32, s32, s32, s32, f32, s32); +void func_80677FA8(s32, s32); // spawnActorWrapper() + +typedef struct RaceStruct8 { + u8 pad0[0x36]; + u8 unk36; +} RaceStruct8; + +typedef struct RaceStruct9 { + u8 pad0[0x1A]; + s16 unk1A; // Flag index + s32 unk1C; +} RaceStruct9; + +int func_80024634(RaceStruct8 *arg0, RaceStruct9 *arg1) { + return arg0->unk36 && + !isFlagSet(arg1->unk1A, FLAG_TYPE_PERMANENT) && + arg1->unk1C <= D_80750AC4; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80024690.s") + +s32 func_80025770(s32 arg0, s32 arg1) { + s32 temp_v1 = arg1 + 1; + if (arg0 != temp_v1) { + return arg1 + 1; + } + return 0; +} + +s32 func_8002578C(s32 arg0, s32 arg1) { + if (arg1 == 0) { + return arg0 - 1; + } + return arg1 - 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800257A4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002597C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80025E9C.s") + +extern void func_8002CFF0(); + +void func_80025FDC() { + func_8002597C(); + func_8002CFF0(); +} + +typedef struct { + u8 pad0[0x10 - 0x0]; + u8 unk10; + u8 unk11; + u8 unk12; + u8 unk13; + f32 unk14; +} RaceStruct1; + +void func_80026004(RaceStruct1 *arg0, u8 arg1, f32 arg2) { + arg0->unk10 = arg1; + arg0->unk14 = arg2; + playSound(0x1EB, 0x7FFF, 64.0f, 1.0f, 0, 0); +} + +// TODO: Any struct overlap with existing structs? +typedef struct { + u16 unk0; + u16 unk2; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10[4]; + s32 unk20; + u8 unk24; + u8 unk25; + u16 unk26; + s32 unk28; + s32 unk2C; + s32 unk30; + s16 unk34; + s8 unk36; + s8 unk37; + s8 unk38; + s8 unk39; + u16 unk3A; +} RaceStruct6; + +void func_80026050(RaceStruct6 *arg0, RaceStruct6 *arg1, s32 arg2) { + if (arg2 != (arg0->unk2 + 1)) { + arg0->unk2++; + } else { + arg0->unk2 = 0; + if (arg1 != 0) { + arg1->unk37++; + } + } + if (arg1 != 0) { + arg1->unk3A = arg0->unk2 + 1; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80026098.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800261E0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80026354.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80026B20.s") + +void func_80026CA8(void) { + func_80604CBC(current_actor_pointer, 0x12D, 0, 1, 0, 0xFF, 1.0f, 0); + func_80604CBC(current_actor_pointer, 0x12E, 0, 1, 1, 0xFF, 1.0f, 0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80026D2C.s") + +void func_80026EE4(s32 arg0, Actor *arg1) { + // TODO: Which aaD type are they actually expecting here? + func_8002CAC8(arg0, arg1, arg1->PaaD); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80026F04.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800274C0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800276B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80027710.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80027880.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80027920.s") + +typedef struct RaceStruct3 { + u8 unk0; + u8 unk1; + s16 unk2; + f32 unk4; + f32 unk8; +} RaceStruct3; + +void func_80027AF8(RaceStruct3 *arg0, s8 arg1) { + if (arg1 > 0) { + arg0->unk1++; + } else { + arg0->unk1--; + } + arg0->unk8 = 0.0f; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80027B30.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80027BD0.s") + +extern s32 D_80720120; + +void func_80714C08(void*, f32, Actor*, s32, s32); + +void func_80027C60(void) { + s32 phi_s0; + + for (phi_s0 = 1; phi_s0 != 3; phi_s0++) { + func_807149B8(1); + func_80714C08(&D_80720120, 1.0f, current_actor_pointer, phi_s0, 0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80027CE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800280E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800282D8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800283D4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80028440.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80028AD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80028E20.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80029054.s") + +void func_800292B0(s32 arg0, Actor *arg1) { + // TODO: Which aaD type are they actually expecting here? + func_8002CAC8(arg0, arg1, arg1->PaaD); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800292D0.s") + +// need this forward declaration +void initializeSealRace(); +void sealRaceSetup() { + initializeSealRace(); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_800294A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002978C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_80029F88.s") + +s32 func_8002A080(s32 arg0, s32 arg1) { + return D_8002FC5C[func_8002E8EC(arg0, arg1, 0xA)]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002A0AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/initializeCastleCarRace.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002A7F8.s") + +void func_8002AE6C(s32 arg0, Actor *arg1) { + // TODO: Which aaD type are they actually expecting here? + func_8068E474(func_8002CAC8(arg0, arg1, arg1->PaaD), arg1); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002AE9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002B180.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002B518.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002B610.s") + +s32 func_8002B6C8(s32 arg0, s32 arg1) { + return D_8002FCAC[func_8002E8EC(arg0, arg1, 0xA)]; +} + +typedef struct RaceStruct7 { + u8 pad0[0x35]; + u8 unk35; +} RaceStruct7; + +void func_8002B6F4(RaceStruct7 *arg0, s32 arg1) { + if (arg0->unk35 == 0) { + // Castle: Tiny GB: Car Race + if (!isFlagSet(0x145, FLAG_TYPE_PERMANENT)) { + playCutscene(current_actor_pointer, 1, 1); + func_80629174(); + } else { + func_805FF544(); + } + arg0->unk35++; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002B76C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002B964.s") + +void func_80611690(void*); + +void func_8002BBD0(Actor *arg0, s32 arg1) { + RaceAdditionalActorData *sp1C; + void *temp_v0; + + sp1C = arg0->RaaD; + temp_v0 = malloc(arg1 * 8); + sp1C->unk20 = temp_v0; + func_80611690(temp_v0); + sp1C->unk1E = arg1; + sp1C->unk1C = -1; + arg0->control_state = 0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002BC2C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002BCB0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002BCD4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002BDDC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002BEE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002C14C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002C2E8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002C63C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002C76C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002CAC8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002CBEC.s") + +void func_8002CFF0(void) { + TempAAD *temp_v0; + Actor *temp_a0; + + func_80677FA8(0x132, 0); // Spawn actor 306 + temp_a0 = D_807FBB44; + func_80025E9C(temp_a0); + func_8002BCD4(temp_a0); + temp_v0 = temp_a0->TaaD; + temp_v0->unk0 = 0x17; + temp_v0->unk14 = 0x46; + temp_v0->unk16 = 0x47; + temp_v0->unk18 = 0x48; + temp_v0->unk1A = 0x49; + temp_v0->unk24 = 2; +} + +void castleCarRaceSetup() { + RaceAdditionalActorData2 *RaaD; + + func_80677FA8(0x132, 0); // Spawn actor 306 + RaaD = D_807FBB44->RaaD2; + initializeCastleCarRace(D_807FBB44); + RaaD->unk0 = 0xE; + RaaD->unk24 = 2; +} + +void func_8002D0B0() { + RaceAdditionalActorData2 *RaaD; + + func_80677FA8(0x132, 0); // Spawn actor 306 + RaaD = D_807FBB44->RaaD2; + func_800292D0(D_807FBB44); + RaaD->unk0 = 0xE; + RaaD->unk24 = 2; +} + +void func_8002D0FC(void) { + RaceAdditionalActorData2 *RaaD; + + func_80677FA8(0x132, 0); // Spawn actor 306 + RaaD = D_807FBB44->RaaD2; + func_8002E2C8(D_807FBB44); + RaaD->unk0 = 2; + RaaD->unk24 = 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D148.s") + +// RaaD use, possibly new fields? +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D224.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D2C0.s") + +extern f32 D_800300E8; + +typedef struct RaceStruct11 { + u16 unk0; + s16 unk2; + u8 pad4[0x30]; +} RaceStruct11; + +extern RaceStruct11 D_807FD63C[]; + +typedef struct RaceStruct12 { + u8 pad0[0x26]; + u8 unk26; + u8 unk27; + u8 unk28; +} RaceStruct12; + +/* +f32 func_8002D2C0(RaceStruct12 *arg0) { + if ((arg0->unk26 >= 0xB) && (arg0->unk26 < 0xF) && + (D_807FD610[arg0->unk28].unk2A & 0x2000)) { + return (arg0->unk26 - 0xA) * D_800300E8; + } + return 0.0f; +} +*/ + +typedef struct { + u8 pad0[0xC]; + Actor *unkC; +} RaceStruct0; + +void func_8002D338(Actor *arg0, RaceStruct0 *arg1) { + Actor *temp = arg1->unkC; + RaceAdditionalActorData *RaaD = temp->RaaD; + RaaD->unk2C = 0; + func_806782C0(arg0); +} + +extern f32 D_800300EC; +extern f32 D_800300F0; + +// RaaD->actor30?->Raad->stuff +// dx dy dz calculation +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D360.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D40C.s") + +void func_8002D4A0(void) { + s32 song; + f32 phi_f0; + + phi_f0 = 1.0f; + switch (current_map) { + case MAP_AZTEC_BEETLE_RACE: + song = 0x13; + phi_f0 = D_800300F0; + break; + case MAP_GALLEON_SEAL_RACE: + song = 0x3D; + break; + case MAP_CAVES_BEETLE_RACE: + song = 0x66; + break; + case MAP_FACTORY_CAR_RACE: + default: + song = 0x1B; + } + + playSong(song, phi_f0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D524.s") + +void func_8002D72C(Actor *arg0) { + if (arg0 && arg0->control_state == 0) { + RaceAdditionalActorData *RaaD = arg0->RaaD; + RaaD->unk1C = 2; + } +} + +void func_8002D754(Actor *arg0) { + if (arg0 && arg0->control_state == 0) { + RaceAdditionalActorData* RaaD = arg0->RaaD; + RaaD->unk1C = 0; + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002D778.s") + +f32 func_80612794(s16, void *, Actor **); + +void func_8002DA68(RaceStruct3 *arg0) { + f32 temp_f2; + s16 temp_v1; + s16 phi_v0; + + switch (current_actor_pointer->control_state) { + case 0: + temp_v1 = arg0->unk2 % 2048; + if ((temp_v1 >= 0x81) && ((0x800 - temp_v1) >= 0x81)) { + arg0->unk2 += 0x80; + } + break; + case 1: + arg0->unk2 += 0x80; + break; + } + + arg0->unk2 &= 0xFFF; + temp_f2 = (((func_80612794(arg0->unk2, arg0, ¤t_actor_pointer) + 1.0f) * 1.5) + 1.0) * arg0->unk4; + current_actor_pointer->animation_state->scale_x = \ + current_actor_pointer->animation_state->scale_y = \ + current_actor_pointer->animation_state->scale_z = temp_f2; +} + +void func_80688370(Actor*, s32, f32); + +void func_8002DB90(void) { + if (current_actor_pointer->control_state != 0) { + if ((current_actor_pointer->control_state == 1) && (func_80688540(current_actor_pointer, 0) == 0)) { + func_80688370(current_actor_pointer, 0, 1.0f); + func_8068842C(current_actor_pointer, 0, -1); + } + } else if (func_80688540(current_actor_pointer, 0)) { + func_80688460(current_actor_pointer, 0, 1); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002DC24.s") + +void func_80665564(Actor*, f32); + +/* +// TODO: Pretty close, datatype issue for RaaD->unk0 though +// Case 2 function call and default function call may be swapped +void func_8002DC24(void) { + RaceAdditionalActorData *RaaD = current_actor_pointer->RaaD; + if ((current_actor_pointer->object_properties_bitfield & 0x10) == 0) { + RaaD->unk4 = current_actor_pointer->animation_state->scale_y; + } + switch (RaaD->unk0) { + default: + func_8002DB90(); + break; + case 1: + func_8002DB90(); + func_80665564(current_actor_pointer, 0); + current_actor_pointer->y_position = current_actor_pointer->unkAC; + current_actor_pointer->unk6A |= 4; + current_actor_pointer->unk6C |= 4; + break; + case 2: + func_8002DA68(); + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002DCF0.s") + +typedef struct RaceStruct14 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + Actor *unk1C; // Used +} RaceStruct14; + +// TODO: Any overlap with existing PaaD/RaaD? +typedef struct RaceAdditionalActorData3 { + s32 unk0; + s32 unk4; + u8 unk8; // Used +} RaceAdditionalActorData3; + +/* +// TODO: Doable, pretty close +void func_8002DCF0(RaceStruct14 *arg0, s32 arg1) { + s32 temp_t1; + s32 var_v0; + RaceAdditionalActorData3 *temp_a1; + Actor *temp_v1; + + var_v0 = 0; + do { + temp_v1 = arg0[var_v0].unk1C; + temp_t1 = (var_v0 + 1); + if (temp_v1 != NULL) { + temp_a1 = temp_v1->RaaD; + if (arg1 == 1) { + if (temp_a1->unk8 == 0) { + temp_v1->control_state = arg1; + } + temp_a1->unk8++; + } else { + if (temp_a1->unk8 != 0) { + temp_a1->unk8--; + } + if (temp_a1->unk8 == 0) { + temp_v1->control_state = arg1; + } + } + } + var_v0 = temp_t1; + } while (temp_t1 < 2); +} +*/ + +f32 func_8002DD70(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + return ((arg4 - arg2) * ((arg0 - arg1) / (arg3 - arg1))) + arg2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002DDA0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002DE78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002DF38.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E1C8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E2C8.s") + +void func_8002E464(s32 arg0, Actor *arg1) { + // TODO: Which aaD type are they actually expecting here? + func_8002CAC8(arg0, arg1, arg1->PaaD); +} + +// Doable, some aaD stuff +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E484.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E644.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E8EC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E960.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E9AC.s") + +typedef struct RaceStruct2 { + s32 unk0; + s32 unk4; + u16 unk8; + s16 unkA; + s32 unkC; +} RaceStruct2; +extern RaceStruct2 *D_8002FCF0; + +/* +// TODO: Close +s32 func_8002E9AC(u8 arg0, RaceStruct2 *arg1) { + arg1 = D_8002FCF0; + if ((arg1 == 0) || (arg0 >= arg1->unk8)) { + return 0; + } + return arg1->unkC + (arg0 * 0x28); +} +*/ + +// arg0 is checkpoint file pointer +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002E9F8.s") + +void setupRaceOnMapLoad(s32 map) { + s32 *checkpointFile = getPointerTableFile(0x18, map, 1, 1); + D_8002FCF0 = malloc(0x10); + func_80611690(D_8002FCF0); + func_8002E9F8(checkpointFile); + switch (map) { + case MAP_FACTORY_CAR_RACE: + func_80025FDC(); + break; + case MAP_GALLEON_SEAL_RACE: + sealRaceSetup(); + break; + case MAP_AZTEC_BEETLE_RACE: + case MAP_CAVES_BEETLE_RACE: + func_8002D0FC(); + break; + case MAP_CASTLE_CAR_RACE: + castleCarRaceSetup(); + break; + } + D_80750AC4 = 0; +} + +void func_8002ECD4(Actor *arg0, f32 arg1) { + arg0->animation_state->scale_x *= arg1; + arg0->animation_state->scale_y = arg0->animation_state->scale_x; + arg0->animation_state->scale_z = arg0->animation_state->scale_y; +} + +void func_8002ED04(f32 arg0, s32 arg1, u8 arg2) { + RaceAdditionalActorData2 *sp1C; + + switch (arg1) { + case 1: + if (arg2) { + func_80677FA8(0x137, 0xB0); // Spawn checkpoint (actor 311) + func_80614EBC(D_807FBB44, 0x2A9); + } else { + func_80677FA8(0x137, 0xB1); // Spawn checkpoint (actor 311) + func_80614EBC(D_807FBB44, 0x2AA); + } + break; + case 2: + func_80677FA8(0x137, arg2 ? 0xD8 : 0xD9); // Spawn checkpoint (actor 311) + break; + } + sp1C = D_807FBB44->RaaD2; + func_8002ECD4(D_807FBB44, arg0); + sp1C->unk0 = arg1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002EDD4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F04C.s") + +/* +// TODO: REGALLOC +f32 func_8002F04C(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { + f32 temp_f0; + f32 temp_f16; + f32 phi_f2; + + temp_f16 = arg6 * arg3; + temp_f0 = arg7 * arg2; + phi_f2 = 0.0f; + if (temp_f16 != temp_f0) { + phi_f2 = (((arg4 - arg0) * arg3) + (arg2 * (arg1 - arg5))) / (temp_f0 - temp_f16); + } + return phi_f2; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F0AC.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F280.s") + +void func_8002F04C(f32, f32, f32, f32, f32, f32, f32, f32); +typedef struct RaceStruct10 { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + f32 unk8; + f32 unkC; +} RaceStruct10; + +void func_8002F304(RaceStruct10 *arg0, f32 arg1, f32 arg2) { + f32 temp_f0; + f32 temp_f2; + + temp_f0 = arg0->unkC; + temp_f2 = arg0->unk8; + func_8002F04C( arg0->unk0, + arg0->unk4, + -temp_f0, + temp_f2, + arg1, + arg2, + temp_f2, + temp_f0); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F36C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F420.s") + +// TODO: Is this the same as RaceStruct6? +typedef struct RaceStruct13 { + s32 unk0; + u16 *unk4; + u16 unk8; + u16 unkA; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s16 unk38; + u16 unk3A; + u16 unk3C; +} RaceStruct13; + +s32 func_8002F36C(s32, s32); +s32 func_8002E9AC(u8); + +/* +// TODO: Regalloc, boo +void func_8002F420(RaceStruct13 *arg0, RaceStruct13 *arg1) { + if (arg1->unk8) { + if (arg0->unk3A == arg0->unk3C) { + u8 temp2 = arg1->unk4[arg0->unk3C] & 0xFF; + s32 temp = func_8002E9AC(temp2); + func_8002DCF0(temp, 0); + func_8002F36C(arg0, arg1); + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F490.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F784.s") + +f32 func_8002F90C(RaceStruct6 *arg0, RaceStruct6 *arg1, RaceStruct6 *arg2) { + f32 temp = ((arg1->unk37 - 1) * arg0->unk0) + arg1->unk3A; + f32 temp2 = arg2->unk24 * arg0->unk0; + return temp / temp2; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/race/code_0/func_8002F950.s") diff --git a/src/water/code_0.c b/src/water/code_0.c new file mode 100644 index 00000000..ee4096f0 --- /dev/null +++ b/src/water/code_0.c @@ -0,0 +1,448 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u8 D_807444FC; + +typedef struct waterStruct2 WaterStruct2; + +struct waterStruct2 { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + s32 unk4; + WaterStruct2 *next; // At 0x8 + u8 padC[0x24 - 0xC]; + f32 unk24; + u8 pad28[0x1E1 - 0x28]; + u8 unk1E1; + u8 unk1E2; + u8 unk1E3; + s16 unk1E4; + s16 unk1E6; + s32 unk1E8; + s32 unk1EC; +}; + +typedef struct WaterStruct5 { + u8 pad0[0x1C - 0x0]; + u8 unk1C; + u8 pad1D[0x25 - 0x1D]; + u8 unk25; +} WaterStruct5; + +// TODO: Merge into WaterStruct2, they're likely the same type +typedef struct WaterStruct4 { + s16 unk0; + s16 unk2; + s32 unk4; + f32 unk8; + f32 unkC; + f32 unk10; + u8 pad0[0x28 - 0x14]; + f32 unk28; + s32 unk2C; + s32 unk30; + f32 unk34; // Used + f32 unk38; // Used + f32 unk3C; // Used + u8 unk40; // Used + u8 unk41; + u8 unk42; + u8 unk43; + u8 pad2[0x54 - 0x44]; + void *unk54; + WaterStruct5 *unk58; + u8 pad3[0x1E0 - 0x5C]; + u8 unk1E0; + u8 unk1E1; + u8 unk1E2; +} WaterStruct4; + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80024000.s") + +void func_8002409C(WaterStruct2 *arg0) { + WaterStruct2 *phi_v0; + s32 phi_v1; + + phi_v0 = arg0->next; + for (phi_v1 = 0; phi_v1 < arg0->unk2; phi_v1++) { + phi_v0->unk24 = 7.0f; + phi_v0->unk1E4 = 0x82; + phi_v0->unk1E1 |= 2; + phi_v0++; + } +} + +void func_800240EC(WaterStruct2 *arg0) { + WaterStruct2 *phi_v0; + s16 phi_v1; + s16 phi_a1; + s32 phi_a2; + + phi_v0 = arg0->next; + phi_v1 = 0x7A; + phi_a1 = 0x7B; + if (arg0->unk0 == 1) { + phi_v1 = 0x80; + phi_a1 = 0x81; + } + for (phi_a2 = 0; phi_a2 < arg0->unk2; phi_a2++) { + phi_v0->unk24 = 5.0f; + phi_v0->unk1E4 = phi_v1; + phi_v0->unk1E6 = phi_a1; + phi_v0++; + } +} + +// Odd stack struct +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80024154.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_8002427C.s") + +// Doable, similar to below +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_8002448C.s") + +s32 func_8066B0F8(s32, u16, s32, s32); + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80024518.s") + +// TODO: Very doable, we are passed an array of pointers I think +// Not sure on how to write that right now +/* +void func_80024518(WaterStruct2 *arg0) { + WaterStruct2 *phi_s0; + s32 i; + + phi_s0 = arg0; + for (i = 0; i < 8; i += 4) { + if (phi_s0->unk1E8 != 0) { + func_8066B434(phi_s0->unk1E8, 0x179, 0x5A); + phi_s0->unk1E8 = 0; + } + phi_s0++; + } +} +*/ + +void func_80024578(WaterStruct2 *arg0) { + if (arg0->unk1E1 & 1) { + func_8002448C(arg0); + } else { + func_80024518(arg0); + } +} + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_800245B8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_800247F4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80024B78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80024C88.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80024F28.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_8002516C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80025500.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_800255C4.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_800257D4.s") + +/* +// TODO: Displaylist stuff +Gfx *func_800257D4(Gfx *arg0) { + gSPDisplayList(arg0++, 0x01000118); + gDPPipeSync(arg0++); + gDPSetCycleType(arg0++, G_CYC_1CYCLE); + gSPClearGeometryMode(arg0++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | + G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH | + G_CLIPPING | 0x0040F9FA); + gSPMatrix(arg0++, + (&character_change_array[cc_player_index] + (D_807444FC << 6) + 0x88), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(arg0++, 0x20002000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); + gSPMatrix(arg0++, 0x20001800, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + return arg0; +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_800258B0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80025A3C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80025AD0.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80025D1C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80025DB8.s") + +void func_80025DB8(WaterStruct4*, WaterStruct4*, s32, s16, s32); + +void func_80025F3C(void *arg0, s32 arg1, u8 arg2, u8 arg3) { + func_80025DB8(arg0, arg1, arg2, func_806119A0() & 0xFFF, arg3); +} + +typedef struct { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + f32 unk8; + f32 unkC; + f32 unk10; +} WaterStruct6; + +void func_80025F8C(WaterStruct6 *arg0, WaterStruct6 *arg1, u8 arg2) { + func_80025F3C(arg0, arg1, arg2, 0); + arg1->unk8 += arg0->unk0; + arg1->unkC += arg0->unk2; + arg1->unk10 += arg0->unk4; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_8002601C.s") + +typedef struct { + u8 pad0[0x2C]; +} WaterStruct0; + +typedef struct { + u8 pad0[0x4]; + WaterStruct0 *unk4; +} WaterStruct1; + +WaterStruct0 *func_80026298(WaterStruct1 *arg0, u8 arg1) { + WaterStruct0 *temp_v1 = arg0->unk4; + return &temp_v1[arg1]; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_800262C0.s") + +void func_80024000(WaterStruct4*, s32, f32); +void func_800262C0(WaterStruct4*, s32); +extern s32 D_80029BA8; + +typedef struct { + s32 unk0; + s32 unk4; + s16 unk8; + s16 unkA; +} WaterStruct7; +extern WaterStruct7 *D_80029BA4; + +extern void *D_80029BA0; + +// TODO: arg1 might be a different type +void func_80026338(WaterStruct4 *arg0, WaterStruct5 *arg1) { + s32 phi_v0; + + switch (arg1->pad0[0]) { + case 3: + phi_v0 = 6400; + break; + case 0: + case 1: + phi_v0 = 22500; + break; + default: + phi_v0 = 6400; + break; + } + if ((arg0->unk3C < phi_v0) && + (((WaterStruct5*)arg0->unk58)->unk25)) { + arg0->unk1E0 = 2; + if (arg0->unk1E2 == 0) { + arg0->unk54 = D_80029BA4; + } else { + func_800262C0(arg0, arg1); + } + func_80025F3C(arg0->unk54, arg0, 1, 1); + func_80024000(arg0, arg1, arg0->unk38); + } +} + +void func_80026410(WaterStruct4 *arg0) { + f32 dx, dz; + + if (arg0->unk40 != D_807444FC) { + Actor* temp = D_807FBB48; + dx = arg0->unk8 - temp->x_position; + dz = arg0->unk10 - temp->z_position; + arg0->unk3C = (dx * dx) + (dz * dz); + arg0->unk40 = D_807444FC; + } +} + +void func_8002646C(WaterStruct4*, WaterStruct4*); + +void func_8002646C(WaterStruct4 *arg0, WaterStruct4 *arg1) { + arg0->unk28 = arg1->unk28; + arg0->unk58 = arg1->unk58; + arg0->unk1E1 = arg1->unk1E1; + if (arg0->unk54 != arg1->unk54) { + arg0->unk54 = arg1->unk54; + func_80025F3C(arg0->unk54, arg0, 1, 1); + } + arg0->unk1E0 = arg1->unk1E0; + if (!arg0->unk1E0 && !(arg0->unk1E1 & 4)) { + arg0->unk2 = 0; + } else if ((func_806119A0() % 255U) < 0x32) { + func_80025F3C(arg0->unk54, arg0, 1, 1); + } +} + +s32 func_80026530(WaterStruct4 *arg0, s32 arg1) { + func_80024000(arg0, arg1, arg0->unk38 * 0.5); + func_80025F3C(arg0->unk54, arg0, 1, 1); + return 0; +} + +// Seems doable, lots of float bs though +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_8002658C.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80026874.s") + +extern f64 D_8002A078; + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80026904.s") + +s16 func_80665DE0(f32, f32, WaterStruct4*, f32, f32); + +// Doable, pretty close +/* +void func_80026904(WaterStruct4 *arg0, WaterStruct2 *arg1) { + if (arg0->unk1E2 == 2) { + func_8002646C(arg1->next, arg1); + return; + } + if (arg0->unk1E2 == 0) { + if (arg0->unk58->unk25 != 0) { + func_80026410(arg0); + if (D_80029BA4 != arg0->unk54) { + func_80026338(arg0, arg1); + return; + } + if ((arg0->unk1E0 == 2) && (arg0->unk3C < D_80029BA4->unkA)) { + func_80025DB8(arg0->unk54, arg0, 0, ((func_80665DE0(arg0->unk8, arg0->unk10, arg0, D_807FBB48->x_position, D_807FBB48->z_position) + (func_806119A0() & 0x7FF)) - 0x400), 1); + arg0->unk1E0 = 1; + } + } else if (D_80029BA4 == arg0->unk54) { + arg0->unk54 = arg0->unk58; + func_80025F3C(arg0->unk58, arg0, 1, 1); + arg0->unk40 = 0xFF; + } + } +} +*/ + +// TODO: Collapse some structs into 1, ws4, ws5, ws2(?) +s32 func_80026A5C(WaterStruct4 *arg0, s32 arg1) { + WaterStruct5 *temp_v0; + + if (arg0->unk1E2 == 1) { + temp_v0 = arg0->unk54; + arg0->unk58 = temp_v0; + if ((temp_v0->unk1C & 1) != 0) { + arg0->unk2 = 0; + arg0->unk1E0 = 0; + arg0->unk28 = 0.0f; + arg0->unk34 = 0; + return TRUE; + } + func_800262C0(arg0, arg1); + } else if (D_80029BA4 == arg0->unk54) { + if (arg0->unk1E0 == 2) { + arg0->unk1E0 = 1; + } else { + arg0->unk1E0 = 2; + } + func_80025F3C(arg0->unk54, arg0, (arg0->unk1E0 == 2), 1); + } else { + arg0->unk2 = 0; + arg0->unk34 = 0.0f; + if (arg0->unk28 < D_8002A078) { + arg0->unk1E0 = 0; + arg0->unk28 = 0; + return TRUE; + } + } + return FALSE; +} + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80026B78.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80026C9C.s") + +/* +void func_80026C9C(void *arg0) { + s32 temp_s1; + u8 temp_v1; + void *temp_t5; + void *temp_v0; + u8 *phi_s0; + u8 phi_v1; + s32 phi_s1; + + if (arg0 != 0) { + D_80029BA4->unk0 = D_807FBB48->x_position; + D_80029BA4->unk4 = D_807FBB48->z_position; + phi_s0 = arg0->unk4; + phi_s1 = 0; + if (arg0->unk0 > 0) { + do { + temp_v1 = *phi_s0; + phi_v1 = temp_v1; + if (temp_v1 > 0) { + phi_v1 = temp_v1 - 1; + } + temp_v0 = (phi_v1 * 0x18) + ((current_character_index * 0x78) + &D_80029BAC); + D_80029BA4->unk2 = D_807FBB48->y_position + temp_v0->unk14; + temp_t5 = D_80029BA4; + temp_t5->unk8 = temp_v0->unk0; + temp_t5->unkC = temp_v0->unk4; + temp_t5->unk10 = temp_v0->unk8; + temp_t5->unk14 = temp_v0->unkC; + temp_t5->unk18 = temp_v0->unk10; + func_80026B78(phi_s0); + temp_s1 = phi_s1 + 1; + phi_s0 += 0xC; + phi_s1 = temp_s1; + } while (temp_s1 < arg0->unk0); + } + } +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80026E0C.s") + +extern void func_80026E0C(s32); +extern void func_80611690(void*); + +void func_80026FD0(s32 arg0) { + D_80029BA8 = 0; + func_80611690(D_80029BA0 = malloc(8)); + func_80026E0C(arg0); + func_80611690(D_80029BA4 = malloc(0x2C)); +} + +s32 func_80027034(s32 arg0) { + if (global_properties_bitfield & 0x10) { + if (!(global_properties_bitfield & 2)) { + func_80026C9C(D_80029BA0); + } + arg0 = func_80025D1C(arg0, D_80029BA0); + } + return arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_8002708C.s") + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_0/func_80027118.s") diff --git a/src/water/code_3340.c b/src/water/code_3340.c new file mode 100644 index 00000000..01299d5d --- /dev/null +++ b/src/water/code_3340.c @@ -0,0 +1,157 @@ +#include +#include "functions.h" +#include "variables.h" + +extern u32 D_8002A1C0; +extern u32 D_8002A1C8; +extern u32 D_8002A1C4; +extern u16 D_8002A1CE; +extern u16 D_8002A1CC; + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80027340.s") + +void func_80688370(Actor *, s32, s32); +void func_806883F4(Actor *, s32, s16); +void func_8068842C(Actor *, s32, s32); +void func_80688460(Actor *, s32, s32); + +/* +// TODO: Kinda close... hmm +void func_80027340(s32 arg0) { + s32 phi_s0; + s32 phi_s2; + + phi_s0 = 2; + phi_s2 = arg0; + while (phi_s0 >= 0) { + func_8068842C(current_actor_pointer, phi_s0, 1); + func_80688370(current_actor_pointer, phi_s0, 0); + func_806883F4(current_actor_pointer, phi_s0, (phi_s2 % 10) + 1); + func_80688460(current_actor_pointer, phi_s0, 0); + phi_s2 /= 10; + phi_s0--; + } +} +*/ + +// Jumptable +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80027448.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80027DC0.s") + +extern f32 D_8002A110; +extern f32 D_8002A114; + +void func_80604CBC(Actor*, s32, s32, s32, s32, s32, f32, s32); + +/* +// TODO: Regalloc, everything else matches :( +void func_80027DC0(void) { + s32 temp[2]; + Actor *sp34; + f32 dx; + f32 dz; + f32 temp2; + s32 phi_t5; + + func_80729B00(); + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + func_80604CBC(current_actor_pointer, 0x10F, 0x46, 1, 0, 0x1E, 1.0f, 0); + current_actor_pointer->control_state = 0; + // Is the camera not unlocked? + if (!isFlagSet(0x179, FLAG_TYPE_PERMANENT)) { + current_actor_pointer->control_state = 1; + // Is the Rareware GB room open? + } else if (isFlagSet(0x189, FLAG_TYPE_PERMANENT)) { + func_80614EBC(current_actor_pointer, 0x2B5); + // Has the player photographed all 20 fairies? + } else if (func_80731AA8(0x24D, 20, FLAG_TYPE_PERMANENT) == 20) { + func_80614EBC(current_actor_pointer, 0x2B5); + current_actor_pointer->control_state = 3; + } + } + dx = current_actor_pointer->x_position - player_pointer->x_position; + dz = current_actor_pointer->z_position - player_pointer->z_position; + switch (current_actor_pointer->control_state) { + case 1: + temp2 = (dx * dx) + (dz * dz); + phi_t5 = temp2 < D_8002A110; + if (phi_t5) { + // Unlock the camera + setFlag(0x179, TRUE, FLAG_TYPE_PERMANENT); + playCutscene(player_pointer, 0, 1); + func_80629174(); + current_actor_pointer->control_state = 2; + } + break; + case 2: + sp34 = current_actor_pointer; + if (current_actor_pointer->control_state_progress != 0) { + current_actor_pointer->control_state_progress++; + if (current_actor_pointer->control_state_progress < 0x4B) { + current_actor_pointer = player_pointer; + if ((object_timer & 3) == 0) { + func_80684900(0); + } + current_actor_pointer = sp34; + } else { + current_actor_pointer = player_pointer; + player_pointer->control_state = 0x2D; + player_pointer->control_state_progress = 0; + func_80614E78(player_pointer, 0x42); + func_80608528(player_pointer, 0xF2, 0xFF, 0x7F, 0); + current_actor_pointer = sp34; + current_actor_pointer->control_state_progress = 0; + func_80605314(player_pointer, 1); + } + } else if (func_80629148()) { + current_actor_pointer->control_state_progress = 1; + func_80604CBC(player_pointer, 0x104, 0x3C, 1, 1, 0xFF, 1.0f, 0); + func_806F8BC4(6, 0, 0); + func_806F91B4(6, extra_player_info_pointer->unk1A4, 999); + } + break; + case 3: + temp2 = (dx * dx) + (dz * dz); + phi_t5 = temp2 < D_8002A114; + if (phi_t5) { + playCutscene(current_actor_pointer, 1, 1); + func_80629174(); + current_actor_pointer->control_state = 4; + } + break; + case 4: + break; + } + func_806319C4(current_actor_pointer, 0); +} +*/ + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80028120.s") + +void func_80028840() { + D_8002A1C0 = getPointerTableFile(0x13, 4, 1, 1); + D_8002A1C8 = getPointerTableFile(0x13, 5, 1, 1); + D_8002A1C4 = 0; + D_8002A1CE = 0; + D_8002A1CC = 1; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_800288A8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80028A9C.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80028DE8.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80028EE8.s") + +// Weird struct/array accesses. Probably doable. +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_8002904C.s") + +s32 func_80029110(s32 arg0) { + return ~arg0; +} + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_80029118.s") + +#pragma GLOBAL_ASM("asm/nonmatchings/water/code_3340/func_800296DC.s") diff --git a/subyaml/arcade.us.yaml b/subyaml/arcade.us.yaml new file mode 100644 index 00000000..259d5246 --- /dev/null +++ b/subyaml/arcade.us.yaml @@ -0,0 +1,152 @@ +options: + basename: arcade + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.arcade.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.arcade.us.txt + undefined_syms_auto_path: undefined_syms_auto.arcade.us.txt + base_path: . + target_path: build/us/arcade.us.bin + asset_path: bin + build_path: build/us + subalign: 2 +segments: + - name: code + dir: arcade + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - name: data + type: code + dir: arcade + start: 0xE220 + vram: 0x80032220 + subsegments: + - [0xE220, bin, data_E220] + - [0xE228, rgba16, img/arcade_80032228.rgba16, 16, 16] + - [0xE428, bin, data_E428] + - [0xECA8, rgba16, img/arcade_80032CA8.rgba16, 8, 10] + - [0xED48, bin, data_ED48] + - [0xED50, rgba16, img/arcade_80032D50.rgba16, 8, 10] + - [0xEDF0, bin, data_EDF0] + - [0xEE80, rgba16, img/arcade_80032E80.rgba16, 8, 9] + - [0xEF10, bin, data_EF10] + - [0xEF68, rgba16, img/arcade_80032F68.rgba16, 43, 19] + - [0xF5CA, bin, data_F5CA] + - [0xF5D8, rgba16, img/arcade_800335D8.rgba16, 43, 19] + - [0xFC3A, bin, data_FC3A] + - [0xFC48, rgba16, img/arcade_80033C48.rgba16, 43, 19] + - [0x102AA, bin, data_102AA] + - [0x102B8, rgba16, img/arcade_800342B8.rgba16, 8, 10] + - [0x10358, bin, data_10358] + - [0x10360, rgba16, img/arcade_80034360.rgba16, 16, 16] + - [0x10560, bin, data_10560] + - [0x10610, rgba16, img/arcade_80034610.rgba16, 16, 16] + - [0x10810, bin, data_10810] + - [0x10818, rgba16, img/arcade_80034818.rgba16, 16, 16] + - [0x10A18, bin, data_10A18] + - [0x10A20, rgba16, img/arcade_80034A20.rgba16, 16, 16] + - [0x10C20, bin, data_10C20] + - [0x10C28, rgba16, img/arcade_80034C28.rgba16, 16, 16] + - [0x10E28, bin, data_10E28] + - [0x10E30, rgba16, img/arcade_80034E30.rgba16, 16, 16] + - [0x11030, bin, data_11030] + - [0x11038, rgba16, img/arcade_80035038.rgba16, 16, 16] + - [0x11238, bin, data_11238] + - [0x11240, rgba16, img/arcade_80035240.rgba16, 16, 16] + - [0x11440, bin, data_11440] + - [0x11448, rgba16, img/arcade_80035448.rgba16, 16, 16] + - [0x11648, bin, data_11648] + - [0x11650, rgba16, img/arcade_80035650.rgba16, 16, 16] + - [0x11850, bin, data_11850] + - [0x11898, rgba16, img/arcade_80035898.rgba16, 16, 16] + - [0x11A98, bin, data_11A98] + - [0x11AE0, rgba16, img/arcade_80035AE0.rgba16, 16, 16] + - [0x11CE0, bin, data_11CE0] + - [0x11CE8, rgba16, img/arcade_80035CE8.rgba16, 16, 16] + - [0x11EE8, bin, data_11EE8] + - [0x13130, rgba16, img/arcade_80037130.rgba16, 16, 16] + - [0x13330, bin, data_13330] + - [0x13338, rgba16, img/arcade_80037338.rgba16, 16, 17] + - [0x13558, bin, data_13558] + - [0x13580, rgba16, img/arcade_80037580.rgba16, 16, 16] + - [0x13780, bin, data_13780] + - [0x13788, rgba16, img/arcade_80037788.rgba16, 16, 16] + - [0x13988, bin, data_13988] + - [0x13990, rgba16, img/arcade_80037990.rgba16, 16, 16] + - [0x13B90, bin, data_13B90] + - [0x13B98, rgba16, img/arcade_80037B98.rgba16, 16, 16] + - [0x13D98, bin, data_13D98] + - [0x13DA0, rgba16, img/arcade_80037DA0.rgba16, 16, 16] + - [0x13FA0, bin, data_13FA0] + - [0x13FA8, rgba16, img/arcade_80037FA8.rgba16, 16, 16] + - [0x141A8, bin, data_141A8] + - [0x141B0, rgba16, img/arcade_800381B0.rgba16, 16, 16] + - [0x143B0, bin, data_143B0] + - [0x143B8, rgba16, img/arcade_800383B8.rgba16, 16, 16] + - [0x145B8, bin, data_145B8] + - [0x145C0, rgba16, img/arcade_800385C0.rgba16, 16, 16] + - [0x147C0, bin, data_147C0] + - [0x147C8, rgba16, img/arcade_800387C8.rgba16, 16, 16] + - [0x149C8, bin, data_149C8] + - [0x149D0, rgba16, img/arcade_800389D0.rgba16, 16, 16] + - [0x14BD0, bin, data_14BD0] + - [0x14BD8, rgba16, img/arcade_80038BD8.rgba16, 16, 16] + - [0x14DD8, bin, data_14DD8] + - [0x14DE0, rgba16, img/arcade_80038DE0.rgba16, 16, 16] + - [0x14FE0, bin, data_14FE0] + - [0x14FE8, rgba16, img/arcade_80038FE8.rgba16, 16, 16] + - [0x151E8, bin, data_151E8] + - [0x151F0, rgba16, img/arcade_800391F0.rgba16, 16, 16] + - [0x153F0, bin, data_153F0] + - [0x153F8, rgba16, img/arcade_800393F8.rgba16, 16, 16] + - [0x155F8, bin, data_155F8] + - [0x15640, rgba16, img/arcade_80039640.rgba16, 16, 16] + - [0x15840, bin, data_15840] + - [0x15888, rgba16, img/arcade_80039888.rgba16, 16, 16] + - [0x15A88, bin, data_15A88] + - [0x15AD0, rgba16, img/arcade_80039AD0.rgba16, 16, 16] + - [0x15CD0, bin, data_15CD0] + - [0x16638, rgba16, img/arcade_8003A638.rgba16, 16, 16] + - [0x16838, bin, data_16838] + - [0x16840, rgba16, img/arcade_8003A840.rgba16, 16, 16] + - [0x16A40, bin, data_16A40] + - [0x16A48, rgba16, img/arcade_8003AA48.rgba16, 16, 16] + - [0x16C48, bin, data_16C48] + - [0x16C50, rgba16, img/arcade_8003AC50.rgba16, 16, 16] + - [0x16E50, bin, data_16E50] + - [0x16E58, rgba16, img/arcade_8003AE58.rgba16, 20, 20] + - [0x17178, bin, data_17178] + - [0x1A680, rgba16, img/arcade_8003E680.rgba16, 24, 10] + - [0x1A860, bin, data_1A860] + - [0x1A868, rgba16, img/arcade_8003E868.rgba16, 24, 10] + - [0x1AA48, bin, data_1AA48] + - [0x1B9B8, rgba16, img/arcade_8003F9B8.rgba16, 46, 32] + - [0x1C538, bin, data_1C538] + - [0x1C540, rgba16, img/arcade_80040540.rgba16, 48, 41] + - [0x1D4A0, bin, data_1D4A0] + - [0x1D508, rgba16, img/arcade_80041508.rgba16, 48, 41] + - [0x1E468, bin, data_1E468] + - [0x1E4D0, rgba16, img/arcade_800424D0.rgba16, 48, 41] + - [0x1F430, bin, data_1F430] + - [0x20460, rgba16, img/arcade_80044460.rgba16, 48, 41] + - [0x213C0, bin, data_213C0] + - [0x21428, rgba16, img/arcade_80045428.rgba16, 48, 41] + - [0x22388, bin, data_22338] + #- [0x26840, .rodata, code_0] + #- [0x268D0, bin, data_268D0] + - [0x26B80, .rodata, code_0] + - [0x26C00] \ No newline at end of file diff --git a/subyaml/bonus.us.yaml b/subyaml/bonus.us.yaml new file mode 100644 index 00000000..b464291d --- /dev/null +++ b/subyaml/bonus.us.yaml @@ -0,0 +1,41 @@ +options: + basename: bonus + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.bonus.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.bonus.us.txt + undefined_syms_auto_path: undefined_syms_auto.bonus.us.txt + base_path: . + target_path: build/us/bonus.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: bonus + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - [0x12A0, c, code_12A0] + - [0x2690, c, code_2690] + - [0x9010, c, code_9010] + - name: data + dir: bonus + type: code + start: 0x9860 + vram: 0x8002D860 + subsegments: + - [0x9860, bin, data_9860] + - [0x9EF0] \ No newline at end of file diff --git a/subyaml/boss.us.yaml b/subyaml/boss.us.yaml new file mode 100644 index 00000000..c16e2a5e --- /dev/null +++ b/subyaml/boss.us.yaml @@ -0,0 +1,46 @@ +options: + basename: boss + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.boss.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.boss.us.txt + undefined_syms_auto_path: undefined_syms_auto.boss.us.txt + base_path: . + target_path: build/us/boss.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: boss + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - [0x3840, c, code_3840] + - [0x52B0, c, code_52B0] + - [0x6240, c, code_6240] + - [0x8520, c, code_8520] + - [0x9230, c, code_9230] + - [0x9C60, c, code_9C60] + - [0xC920, c, code_C920] + - [0xF0D0, c, code_F0D0] + - name: data + dir: boss + type: code + start: 0x118B0 + vram: 0x800358B0 + subsegments: + - [0x118B0, bin, data_118B0] + - [0x12DC0] \ No newline at end of file diff --git a/subyaml/global_asm.us.yaml b/subyaml/global_asm.us.yaml new file mode 100644 index 00000000..3e04e663 --- /dev/null +++ b/subyaml/global_asm.us.yaml @@ -0,0 +1,178 @@ +options: + basename: global_asm + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.global_asm.us.txt + undefined_syms_auto_path: undefined_syms_auto.global_asm.us.txt + base_path: . + target_path: build/us/global_asm.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: global_asm + type: code + start: 0x00000000 + vram: 0x805FB300 + subsegments: + - [0x0, c, code_0] + - [0x3C10, c, code_3C10] + - [0x5650, c, code_5650] + - [0x5A50, c, code_5A50] + - [0x6710, c, code_6710] + - [0xF4C0, c, code_F4C0] + - [0xF600, c, code_F600] + - [0xFE40, c, code_FE40] + - [0x10130, c, code_10130] + - [0x104F0, c, code_104F0] + - [0x131B0, c, code_131B0] + - [0x14CF0, c, code_14CF0] + - [0x15010, c, code_15010] + - [0x15050, c, code_15050] + - [0x16550, c, code_16550] + - [0x166A0, bin, code_166A0] + - [0x1E2D0, bin, code_1E2D0] + - [0x2C700, c, code_2C700] + - [0x2C910, c, code_2C910] + - [0x2DE90, c, code_2DE90] + - [0x2F550, c, code_2F550] + - [0x35000, c, code_35000] + - [0x36880, c, code_36880] + - [0x42630, c, code_42630] + - [0x54150, c, code_54150] + - [0x55B20, c, code_55B20] + - [0x5DE10, c, code_5DE10] + - [0x5E020, c, code_5E020] + - [0x5E2F0, c, code_5E2F0] + - [0x61690, c, code_61690] + - [0x61AA0, c, code_61AA0] + - [0x63810, c, code_63810] + - [0x63EC0, c, code_63EC0] + - [0x67890, c, code_67890] + - [0x684C0, c, code_684C0] + - [0x68960, c, code_68960] + - [0x68AA0, c, code_68AA0] + - [0x68EA0, c, code_68EA0] + - [0x699B0, c, code_699B0] + - [0x70FD0, c, code_70FD0] + - [0x77B90, c, code_77B90] + - [0x79890, c, code_79890] + - [0x7A510, c, code_7A510] + - [0x7AF60, c, code_7AF60] + - [0x7BBD0, c, code_7BBD0] + - [0x7CA80, c, code_7CA80] + - [0x80150, c, code_80150] + - [0x89250, c, code_89250] + - [0x8CA50, c, code_8CA50] + - [0x8D3E0, c, code_8D3E0] + - [0x8F050, c, code_8F050] + - [0x8F4B0, c, code_8F4B0] + - [0x936B0, c, code_936B0] + - [0x9BF30, c, code_9BF30] + - [0x9CE20, c, code_9CE20] + - [0x9DD70, c, code_9DD70] + - [0xA2F10, c, code_A2F10] + - [0xA6280, c, code_A6280] + - [0xA7710, c, code_A7710] + - [0xA8400, c, code_A8400] + - [0xACDC0, c, code_ACDC0] + - [0xB1F60, c, code_B1F60] + - [0xB2CE0, c, code_B2CE0] + - [0xB5EC0, c, code_B5EC0] + - [0xB6C50, c, code_B6C50] + - [0xB7490, c, code_B7490] + - [0xBA790, c, code_BA790] + - [0xBB300, c, code_BB300] + - [0xBC3B0, c, code_BC3B0] + - [0xBD820, c, code_BD820] + - [0xBDEE0, c, code_BDEE0] + - [0xC0EE0, c, code_C0EE0] + - [0xC1E70, c, code_C1E70] + - [0xC2A90, c, code_C2A90] + - [0xC8C10, c, code_C8C10] + - [0xCB230, c, code_CB230] + - [0xCBEA0, c, code_CBEA0] + - [0xCC800, c, code_CC800] + - [0xCEAE0, c, code_CEAE0] + - [0xEFDC0, c, code_EFDC0] + - [0xF56F0, c, code_F56F0] + - [0xF9450, c, code_F9450] + - [0xFCCD0, c, code_FCCD0] + - [0x100180, c, code_100180] + - [0x1025E0, c, code_1025E0] + - [0x10D2D0, c, code_10D2D0] + - [0x10E1D0, c, code_10E1D0] + - [0x110F00, c, code_110F00] + - [0x112080, c, code_112080] + - [0x1135F0, c, code_1135F0] + - [0x114270, c, code_114270] + - [0x119370, c, code_119370] + - [0x124780, bin, code_124780] #mips3 + - [0x127B00, c, code_127B00] + - [0x1295B0, c, code_1295B0] + - [0x12E800, c, code_12E800] + - [0x1332B0, c, code_1332B0] + - [0x133A90, c, code_133A90] + - [0x135D30, c, code_135D30] + - [0x136820, c, code_136820] + - [0x1371D0, c, code_1371D0] + - [0x137630, c, code_137630] + - [0x137C10, c, code_137C10] + - [0x13A750, c, code_13A750] + - [0x13A7A0, c, code_13A7A0] + - [0x13C920, c, code_13C920] + - [0x13CB30, c, code_13CB30] + - [0x13CB50, c, code_13CB50] + - [0x13CE70, c, code_13CE70] + - [0x13CFA0, c, code_13CFA0] + - [0x13D020, c, code_13D020] + - [0x13D0B0, c, code_13D0B0] + - [0x13D100, c, code_13D100] + - [0x13D170, c, code_13D170] + - [0x13E020, c, audio/n_sl] #DONE + - [0x13E0E0, c, audio/link] #DONE + - [0x13E160, c, audio/synthesizer] + - [0x13EC00, c, audio/seqpstop] #DONE + - [0x13EC40, c, audio/seqpsetseq] #DONE + - [0x13EC90, c, audio/seqpsetvol] #DONE + - [0x13ECE0, c, code_13ECE0] + - [0x13FED0, c, audio/event] #DONE + - [0x140260, c, code_140260] + - [0x140530, c, code_140530] + - [0x140600, c, code_140600] + - [0x141520, c, code_141520] + - [0x1417C0, c, code_1417C0] + - [0x141AD0, c, code_141AD0] + - [0x141C00, c, code_141C00] + - [0x141E40, c, audio/n_syndelete] #DONE + - [0x141E60, c, code_141E60] + - [0x141EF0, c, code_141EF0] + - [0x1435A0, c, code_1435A0] + - [0x1435C0, c, code_1435C0] + - [0x144A90, c, code_144A90] + - [0x144E00, c, code_144E00] + - [0x145950, c, code_145950] + - [0x145D70, bin, code_145D70] #mips3 + - name: data + type: code + dir: global_asm + start: 0x149160 + vram: 0x80744460 + subsegments: + - [0x149160, bin, data_149160] + - [0x165190, .rodata, audio/synthesizer] + - [0x1651A0, bin, data_1651A0] + + - [0x165D50] \ No newline at end of file diff --git a/subyaml/jetpac.us.yaml b/subyaml/jetpac.us.yaml new file mode 100644 index 00000000..36c20cea --- /dev/null +++ b/subyaml/jetpac.us.yaml @@ -0,0 +1,42 @@ +options: + basename: jetpac + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.jetpac.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.jetpac.us.txt + undefined_syms_auto_path: undefined_syms_auto.jetpac.us.txt + base_path: . + target_path: build/us/jetpac.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: jetpac + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - [0x1460, c, code_1460] + - [0x3060, c, code_3060] + - [0x3480, c, code_3480] + - [0x4FC0, c, code_4FC0] + - name: data + type: code + dir: jetpac + start: 0x7090 + vram: 0x8002B090 + subsegments: + - [0x7090, bin, data_7090] + - [0xAC30] \ No newline at end of file diff --git a/subyaml/menu.us.yaml b/subyaml/menu.us.yaml new file mode 100644 index 00000000..4e6cd74c --- /dev/null +++ b/subyaml/menu.us.yaml @@ -0,0 +1,41 @@ +options: + basename: menu + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.menu.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.menu.us.txt + undefined_syms_auto_path: undefined_syms_auto.menu.us.txt + base_path: . + target_path: build/us/menu.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: menu + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - [0x1AF0, c, code_1AF0] + - [0x3E10, c, code_3E10] + - [0xE550, c, code_E550] + - name: data + type: code + dir: menu + start: 0xEF50 + vram: 0x80032F50 + subsegments: + - [0xEF50, bin, data_EF50] + - [0xFF10] \ No newline at end of file diff --git a/subyaml/minecart.us.yaml b/subyaml/minecart.us.yaml new file mode 100644 index 00000000..2a4cbf17 --- /dev/null +++ b/subyaml/minecart.us.yaml @@ -0,0 +1,39 @@ +options: + basename: minecart + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.minecart.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.minecart.us.txt + undefined_syms_auto_path: undefined_syms_auto.minecart.us.txt + base_path: . + target_path: build/us/minecart.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: minecart + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - [0x25F0, c, code_25F0] + - name: data + type: code + dir: minecart + start: 0x4B90 + vram: 0x80028B90 + subsegments: + - [0x4B90, bin, data_4B90] + - [0x4E10] \ No newline at end of file diff --git a/subyaml/multiplayer.us.yaml b/subyaml/multiplayer.us.yaml new file mode 100644 index 00000000..e64bfc7d --- /dev/null +++ b/subyaml/multiplayer.us.yaml @@ -0,0 +1,38 @@ +options: + basename: multiplayer + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.multiplayer.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.multiplayer.us.txt + undefined_syms_auto_path: undefined_syms_auto.multiplayer.us.txt + base_path: . + target_path: build/us/multiplayer.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: multiplayer + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - name: data + type: code + dir: multiplayer + start: 0x2F70 + vram: 0x80026F70 + subsegments: + - [0x2F70, bin, data_2F70] + - [0x3100] \ No newline at end of file diff --git a/subyaml/race.us.yaml b/subyaml/race.us.yaml new file mode 100644 index 00000000..4a120f60 --- /dev/null +++ b/subyaml/race.us.yaml @@ -0,0 +1,38 @@ +options: + basename: race + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.race.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.race.us.txt + undefined_syms_auto_path: undefined_syms_auto.race.us.txt + base_path: . + target_path: build/us/race.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: race + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - name: data + type: code + dir: race + start: 0xBB10 + vram: 0x8002FB10 + subsegments: + - [0xBB10, bin, data_BB10] + - [0xC160] \ No newline at end of file diff --git a/subyaml/water.us.yaml b/subyaml/water.us.yaml new file mode 100644 index 00000000..29e8f0a7 --- /dev/null +++ b/subyaml/water.us.yaml @@ -0,0 +1,39 @@ +options: + basename: water + find_file_boundaries: yes + compiler: "IDO" + platform: n64 + cpp_args: + - "-Iinclude" + - "-Iinclude/2.0L" + - "-D_LANGUAGE_C" + generated_c_preamble: | + #include + #include "functions.h" + #include "variables.h" + create_detected_syms: yes + undefined_syms_path: undefined_syms.us.txt + symbol_addrs_path: symbol_addrs.water.us.txt + undefined_funcs_auto_path: undefined_funcs_auto.water.us.txt + undefined_syms_auto_path: undefined_syms_auto.water.us.txt + base_path: . + target_path: build/us/water.us.bin + asset_path: bin + build_path: build/us +segments: + - name: code + dir: water + type: code + start: 0x00000000 + vram: 0x80024000 + subsegments: + - [0x0, c, code_0] + - [0x3340, c, code_3340] + - name: data + dir: water + type: code + start: 0x57F0 + vram: 0x800297F0 + subsegments: + - [0x57F0, bin, data_57F0] + - [0x61B0] #0x61B0 \ No newline at end of file diff --git a/symbol_addrs.arcade.us.txt b/symbol_addrs.arcade.us.txt new file mode 100644 index 00000000..3e4dab95 --- /dev/null +++ b/symbol_addrs.arcade.us.txt @@ -0,0 +1,83 @@ +arcade_add_points_to_score = 0x80024674; +arcade_get_object_type_count = 0x800248D8; +__arcade_abs_w = 0x8002B378; + +D_80034610 = 0x80034610; +D_80034818 = 0x80034818; +D_80034A20 = 0x80034A20; +D_80034C28 = 0x80034C28; +D_80034E30 = 0x80034E30; +D_80035038 = 0x80035038; +D_80035240 = 0x80035240; +D_80035448 = 0x80035448; +D_80035CE8 = 0x80035CE8; +D_80037DA0 = 0x80037DA0; +D_80037FA8 = 0x80037FA8; +D_80035898 = 0x80035898; +D_80039D18 = 0x80039D18; +D_8004A358 = 0x8004A358; + + +arcade_jumpman_obj_template = 0x8004A398; +arcade_barrel_obj_template = 0x8004A3B8; +arcade_flame_enemy_obj_template = 0x8004A3D8; +arcade_oil_drum_flame_obj_template = 0x8004A3F8; +arcade_spring_obj_template = 0x8004A418; +arcade_bonus_osd_obj_template = 0x8004A438; +arcade_oil_drum_obj_template = 0x8004A458; +arcade_elevator_obj_template = 0x8004A478; +arcade_pulley_obj_template = 0x8004A498; +arcade_pauline_top_obj_template = 0x8004A4B8; +arcade_pauline_bottom_obj_template = 0x8004A4D8; +arcade_nintendo_coin_obj_template = 0x8004A4F8; +arcade_help_text_obj_template = 0x8004A518; +arcade_dk_title_obj_template = 0x8004A538; +arcade_dk_25m_obj_template = 0x8004A558; +arcade_dk_100m_obj_template = 0x8004A578; +arcade_dk_75m_obj_template = 0x8004A598; +arcade_dk_50m_obj_template = 0x8004A5B8; +arcade_dk_how_high_obj_template = 0x8004A5D8; +arcade_points_text_obj_template = 0x8004A5F8; +arcade_bonus_item_obj_template = 0x8004A618; +arcade_hammer_obj_template = 0x8004A638; +arcade_rivet_obj_template = 0x8004A658; +arcade_moving_ladder_obj_template = 0x8004A678; +arcade_name_select_cursor_obj_template = 0x8004A698; +D_8004A6B8 = 0x8004A6B8; +arcade_pie_obj_template = 0x8004A6D8; +arcade_100m_complete_particle_obj_template = 0x8004A6F8; +arcade_barrel_stack_obj_template = 0x8004A718; + +arcade_current_score = 0x8004A748; +arcade_saved_high_scores = 0x8004A74C; +arcade_saved_high_score_initials = 0x8004A778; +D_8004A8D8 = 0x8004A8D8; +arcade_next_sfx = 0x8004C714; +arcade_lives_internal = 0x8004C71B; +arcade_lives_visual = 0x8004C71C; +arcade_game_state = 0x8004C71D; +arcade_background_visual = 0x8004C722; +D_8004A81C = 0x8004A81C; +newly_pressed_input = 0x807ECD48; +D_8004AB7C = 0x8004AB7C; + +D_8004AAA8 = 0x8004AAA8; +D_8004AA78 = 0x8004AA78; +D_8004AA80 = 0x8004AA80; +D_8004AAC8 = 0x8004AAC8; +D_8004AAD8 = 0x8004AAD8; + +D_8004AB10 = 0x8004AB10; + +D_1000040 = 0x1000040; +D_1000090 = 0x1000090; + +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; + +is_cutscene_active = 0x807444EC; +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; diff --git a/symbol_addrs.bonus.us.txt b/symbol_addrs.bonus.us.txt new file mode 100644 index 00000000..7b794641 --- /dev/null +++ b/symbol_addrs.bonus.us.txt @@ -0,0 +1,19 @@ +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +rand = 0x80611A44; +playCutscene = 0x8061CC40; + +is_cutscene_active = 0x807444EC; +enemies_killed = 0x80744508; +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; +current_actor_pointer = 0x807FBB40; +player_pointer = 0x807FBB4C; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +extra_player_info_pointer = 0x807FD580; diff --git a/symbol_addrs.boss.us.txt b/symbol_addrs.boss.us.txt new file mode 100644 index 00000000..1a76af29 --- /dev/null +++ b/symbol_addrs.boss.us.txt @@ -0,0 +1,24 @@ +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +rand = 0x80611A44; +playCutscene = 0x8061CC40; +setIntroStoryPlaying = 0x8070B308; +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; +gameIsInMysteryMenuMinigameMode = 0x8071441C; + +func_8071CDE0 = 0x8071CDE0; + +is_cutscene_active = 0x807444EC; +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; +current_actor_pointer = 0x807FBB40; +player_pointer = 0x807FBB4C; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +extra_player_info_pointer = 0x807FD580; diff --git a/symbol_addrs.dk64_boot.us.txt b/symbol_addrs.dk64_boot.us.txt new file mode 100644 index 00000000..319ca092 --- /dev/null +++ b/symbol_addrs.dk64_boot.us.txt @@ -0,0 +1,188 @@ +osTvType = 0x80000300; +osRomBase = 0x80000308; +osResetType = 0x8000030C; +osMemSize = 0x80000318; +osAppNMIBuffer = 0x8000031C; + +memcpy = 0x80003000; +osInvalDCache = 0x80004520; +osPiRawStartDma = 0x800045D0; +osPiGetStatus = 0x800046B0; +osRecvMesg = 0x800046C0; +osViBlack = 0x80004800; +osSetThreadPri = 0x80004870; +osCreateMesgQueue = 0x80004950; +osSetEventMesg = 0x80004980; +osCreateThread = 0x800049F0; +osStartThread = 0x80004B40; +osCreateViManager = 0x80004C90; +viMgrMain = 0x80004E10; +osViSetMode = 0x80004FA0; +bzero = 0x800051C0; +osInvalICache = 0x80005260; +osWriteBackDCacheAll = 0x800052E0; +osInitialize = 0x80005310; +osWritebackDCache = 0x80005670; +osViSwapBuffer = 0x80005760; +__osGetFpcCsr = 0x80005A80; +guSprite2DInit = 0x80005A90; +osStopThread = 0x80005AE0; +osDpSetStatus = 0x80005BA0; +__osSpSetStatus = 0x80005BB0; +osViSetSpecialFeatures = 0x80005BC0; +guTranslateF = 0x80005D80; +guTranslate = 0x80005DC8; +guPerspectiveF = 0x80005E20; +guPerspective = 0x80006050; +osGetTime = 0x800060B0; +osSetTime = 0x80006140; +guLookAtHiliteF = 0x80006170; +guLookAtHilite = 0x800068A8; +guLookAtF = 0x80006960; +guLookAt = 0x80006C18; +guOrthoF = 0x80006C90; +guOrtho = 0x80006DE4; +osAiSetNextBuffer = 0x80006E50; +osAiGetLength = 0x80006F00; +osPiStartDma = 0x80006F10; +osContInit = 0x80007020; +__osContGetInitData = 0x80007190; +__osPackRequestData = 0x80007260; +__ull_to_f = 0x800075B0; +osSetTimer = 0x800077C0; +osGetThreadId = 0x800078A0; +osEepromLongRead = 0x800078C0; +osEepromWrite = 0x80007950; +__osPackEepWriteData = 0x80007AC8; +__osEepStatus = 0x80007B74; +osEepromProbe = 0x80007D20; +osMotorStartStop = 0x80007D90; +_MakeMotorData = 0x80007EF8; +osMotorInit = 0x80008004; +osDpGetStatus = 0x80008160; +osViGetCurrentFramebuffer = 0x80008170; +osViGetNextFramebuffer = 0x800081B0; +osSpTaskYielded = 0x800081F0; +osSpTaskLoad = 0x8000838C; +osSpTaskStartGo = 0x8000851C; +osSpTaskYield = 0x80008560; +guScaleF = 0x80008580; +guScale = 0x800085D4; +guRotateF = 0x80008620; +guRotate = 0x800087B4; +guMtxXFMF = 0x80008810; +guMtxCatF = 0x800088B0; +guMtxXFML = 0x80008A20; +guMtxCatL = 0x80008A80; +guAlignF = 0x80008AE0; +guAlign = 0x80008CA0; +osPiReadIo = 0x80008CF0; +osViGetCurrentMode = 0x80008D30; +guPositionF = 0x80008D80; +guPosition = 0x80008F30; +osVirtualToPhysical = 0x80008FA0; +__osDisableInt = 0x80009020; +__osRestoreInt = 0x80009040; +__osDequeueThread = 0x80009060; +__osExceptionPreamble = 0x800090A0; +__osException = 0x800090B0; +send_mesg = 0x800095D4; +__osEnqueueAndYield = 0x800096BC; +__osEnqueueThread = 0x800097BC; +__osPopThread = 0x80009804; +__osDispatchThread = 0x80009814; +__osViInit = 0x800099A0; +__osTimerServicesInit = 0x80009AE0; +__osTimerInterrupt = 0x80009B6C; +__osSetTimerIntr = 0x80009CE4; +__osInsertTimer = 0x80009D58; +osGetThreadPri = 0x80009EE0; +__osViGetCurrentContext = 0x80009F00; +__osViSwapContext = 0x80009F10; +osSendMesg = 0x8000A210; +osGetCount = 0x8000A360; +__osSetSR = 0x8000A370; +__osGetSR = 0x8000A380; +__osSetFpcCsr = 0x8000A390; +__osSiRawReadIo = 0x8000A3A0; +__osSiRawWriteIo = 0x8000A3F0; +osUnmapTLBAll = 0x8000A440; +osMapTLBRdb = 0x8000A490; +osPiRawReadIo = 0x8000A4F0; +osCreatePiManager = 0x8000A550; +guMtxF2L = 0x8000A6C0; +guMtxIdentF = 0x8000A7C0; +guMtxIdent = 0x8000A848; +guMtxL2F = 0x8000A878; +cosf = 0x8000A930; +sinf = 0x8000AAA0; +sqrtf = 0x8000AC60; +__osAiDeviceBusy = 0x8000AC70; +osJamMesg = 0x8000ACA0; +osPiGetCmdQueue = 0x8000ADF0; +__osSiRawStartDma = 0x8000AE20; +__osSiCreateAccessQueue = 0x8000AED0; +__osSiGetAccess = 0x8000AF20; +__osSiRelAccess = 0x8000AF64; +osEepromRead = 0x8000AF90; +__osPackEepReadData = 0x8000B154; +__osContAddressCrc = 0x8000B1E0; +__osContDataCrc = 0x8000B2B0; +__osPackRamWriteDataSafe = 0x8000B350; +__osContRamReadData = 0x8000B3D0; +__osSpGetStatus = 0x8000B600; +bcopy = 0x8000B610; +__osSpSetPc = 0x8000B920; +__osSpRawStartDma = 0x8000B960; +__osSpDeviceBusy = 0x8000B9F0; +guNormalize = 0x8000BA20; +__osPiCreateAccessQueue = 0x8000BAB0; +__osPiGetAccess = 0x8000BB00; +__osPiRelAccess = 0x8000BB44; +__osProbeTLB = 0x8000BB70; +osSetIntMask = 0x8000BC30; +osDestroyThread = 0x8000BCD0; +__osSetCompare = 0x8000BDE0; +__osSiDeviceBusy = 0x8000BDF0; +__osDevMgrMain = 0x8000C000; +__osContRamWrite = 0x8000C490; +osPfsIsPlug = 0x8000C6E0; +__osPfsRequestData = 0x8000C880; +__osPfsGetInitData = 0x8000C950; +__osPfsGetStatus = 0x8000CA20; +__osPfsRequestOneChannel = 0x8000CAF0; +__osPfsGetOneChannelData = 0x8000CBB4; +__osResetGlobalIntMask = 0x8000CC50; +osEPiRawWriteIo = 0x8000CCB0; +osEPiRawReadIo = 0x8000CE10; +__osSetGlobalIntMask = 0x8000CF70; +osYieldThread = 0x8000CFC0; +__osSumcalc = 0x8000D010; +__osIdCheckSum = 0x8000D084; +__osRepairPackId = 0x8000D180; +__osCheckPackId = 0x8000D4D0; +__osGetId = 0x8000D634; +__osViDevMgr = 0x8000EF00; +osClockRate = 0x800100A0; +osViClock = 0x800100A8; +__osRunQueue = 0x800100E8; +__osActiveQueue = 0x800100EC; +__osViCurr = 0x80010190; +__osViNext = 0x80010194; +__OSGlobalIntMask = 0x800100B0; +hdwrBugFlag = 0x800100C0; +__osThreadTail = 0x800100E0; +__osRunningThread = 0x800100F0; +__osTimerList = 0x800101A0; +__osPiDevMgr = 0x800101B0; +__osCurrentHandle = 0x800101D0; +__osEventStateTab = 0x80013B10; +retrace = 0x80014DA0; +__osFinalrom = 0x80014DB0; +__osContLastCmd = 0x80014E00; +tmp_task = 0x80014F50; +__osCurrentTime = 0x80014FE0; +__osBaseCounter = 0x80014FE8; +__osViIntrCount = 0x80014FEC; +__osTimerCounter = 0x80014FF0; +__osEepPifRam = 0x800162E0; diff --git a/symbol_addrs.global_asm.us.txt b/symbol_addrs.global_asm.us.txt new file mode 100644 index 00000000..f06d6f4e --- /dev/null +++ b/symbol_addrs.global_asm.us.txt @@ -0,0 +1,193 @@ +playSong = 0x80602A94; +playSound = 0x80609140; +getEEPROMSaveSlot = 0x8060B9D0; +malloc = 0x80610FE8; +rand = 0x80611A44; +playCutscene = 0x8061CC40; +getPointerTableFile = 0x8066B0F8; +areAllKeysTurnedIn = 0x806BDD2C; +getFlagBlockAddress = 0x8060E25C; +getExitData = 0x806C96C4; +loadExits = 0x806C95D0; +setIntroStoryPlaying = 0x8070B308; +isIntroStoryPlaying = 0x8070B318; +clearPermanentFlags = 0x8073106C; +clearGlobalFlags = 0x807310BC; +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; +gameIsInDKTheatreMode = 0x80712658; +gameIsInDKTVMode = 0x807142D8; +gameIsInAdventureMode = 0x8071432C; +gameIsInQuitGameMode = 0x80714394; +gameIsInSnidesBonusGameMode = 0x807143E8; +gameIsInMysteryMenuMinigameMode = 0x8071441C; +gameIsInMainMenuMode = 0x80714450; +playerCanDive = 0x806E770C; +getLevelIndex = 0x805FF030; + +n_alInit = 0x80739320; +n_alClose = 0x8073938C; +alLink = 0x807393E0; +alUnlink = 0x80739414; +n_alSynNew = 0x80739460; +n_alAudioFrame = 0x80739A64; +__n_allocParam = 0x80739C88; +__n_freeParam = 0x80739CE8; +_n_collectPVoices = 0x80739D14; +_n_freePVoice = 0x80739D80; +_n_timeToSamplesNoRound = 0x80739DC0; +__n_nextSampleTime = 0x80739E5C; +alSeqpStop = 0x80739F00; +alSeqpSetSeq = 0x80739F40; +alSepqSetVol = 0x80739F90; +alEvtqNew = 0x8073B1D0; +alEvtqNextEvent = 0x8073B26C; +alEvtqPostEvent = 0x8073B310; +alEvtqFlushType = 0x8073B490; +n_alSynDelete = 0x8073D140; +next_map = 0x807444E4; +next_exit = 0x807444E8; +is_cutscene_active = 0x807444EC; +enemies_killed = 0x80744508; +current_character_index = 0x8074E77C; +action_initiation_function_list = 0x80752C70; +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; +loading_zone_transition_type = 0x8076AEE0; +newly_pressed_input = 0x807ECD48; +newly_pressed_input_copy = 0x807ECD66; +chunk_array_pointer = 0x807F6C18; +actor_list = 0x807FBFF0; +actor_count = 0x807FC3F0; +actor_spawner_pointer = 0x807FC400; +exit_array = 0x807FC900; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +extra_player_info_pointer = 0x807FD580; +loading_zone_transition_speed = 0x807FD88C; +current_menu_selection = 0x8076A0D1; +current_file_selection = 0x8076A0D2; +D_807ECDE8 = 0x807ECDE8; +current_actor_pointer = 0x807FBB40; +player_pointer = 0x807FBB4C; +global_properties_bitfield = 0x807FBB60; +temporary_flag_block = 0x807FDD90; +is_autowalking = 0x807463B8; +widescreen_enabled = 0x807444C0; +story_skip = 0x8074452C; +number_of_exits = 0x807FC904; +current_file = 0x807467C8; + +D_1000020 = 0x1000020; +D_1000030 = 0x1000030; +D_1000040 = 0x1000040; +D_1000068 = 0x1000068; +D_1000090 = 0x1000090; + +D_80753454 = 0x80753454; +D_8075348C = 0x8075348C; +D_807534A8 = 0x807534A8; +D_80753738 = 0x80753738; +D_80753754 = 0x80753754; +D_80759B60 = 0x80759B60; +D_80759B68 = 0x80759B68; +D_8075C398 = 0x8075C398; +D_807F735E = 0x807F735E; +D_807FDC9C = 0x807FDC9C; +D_8075DFB4 = 0x8075DFB4; +D_8076BF20 = 0x8076BF20; +D_8076A0BC = 0x8076A0BC; +D_80768E98 = 0x80768E98; +D_80767E68 = 0x80767E68; +D_807F5D90 = 0x807F5D90; +D_8075CC6C = 0x8075CC6C; +D_80758160 = 0x80758160; + +D_8075D0C8 = 0x8075D0C8; +D_8075D0D0 = 0x8075D0D0; + +D_807FBFE0 = 0x807FBFE0; +D_807FBFE4 = 0x807FBFE4; +D_807FBFE8 = 0x807FBFE8; +D_807FBFEC = 0x807FBFEC; +D_807FD618 = 0x807FD618; +D_8075D100 = 0x8075D100; +D_807537E0 = 0x807537E0; +D_80753364 = 0x80753364; +D_80753380 = 0x80753380; +D_807531FC = 0x807531FC; +D_807535CC = 0x807535CC; +D_80753CB4 = 0x80753CB4; +D_80753604 = 0x80753604; + +D_8000DDE4 = 0x8000DDE4; +D_8000DDE8 = 0x8000DDE8; +D_8076A130 = 0x8076A130; +D_80753D08 = 0x80753D08; +D_8075CE80 = 0x8075CE80; + +D_8075C7A0 = 0x8075C7A0; +D_8075D130 = 0x8075D130; +D_8075371C = 0x8075371C; +D_8075378C = 0x8075378C; + +D_807539DC = 0x807539DC; +D_807538B8 = 0x807538B8; + +D_8075A588 = 0x8075A588; + +D_80753328 = 0x80753328; +D_807532F0 = 0x807532F0; +D_8075330C = 0x8075330C; +D_807532B8 = 0x807532B8; +D_807532D4 = 0x807532D4; +D_80753A78 = 0x80753A78; +D_80753B64 = 0x80753B64; +D_8075395C = 0x8075395C; + +D_8075380C = 0x8075380C; +D_8075381C = 0x8075381C; +D_8075382C = 0x8075382C; +D_8075385C = 0x8075385C; + +D_80750FC4 = 0x80750FC4; +D_8075D320 = 0x8075D320; +D_80753A2C = 0x80753A2C; +D_80753428 = 0x80753428; + +D_8075B878 = 0x8075B878; +D_80756024 = 0x80756024; + +n_alGlobals = 0x807563E0; +n_syn = 0x807563E4; + +func_8002EC08 = 0x8002EC08; + +D_80746340 = 0x80746340; +D_80753924 = 0x80753924; +D_80753940 = 0x80753940; +D_8076A064 = 0x8076A064; + +D_8075383C = 0x8075383C; +D_8075384C = 0x8075384C; +D_80753500 = 0x80753500; +D_8075351C = 0x8075351C; + +D_8075A400 = 0x8075A400; +D_807F93CC = 0x807F93CC; + +D_8075BEC8 = 0x8075BEC8; + +D_8075D6E4 = 0x8075D6E4; +D_807572D0 = 0x807572D0; +D_807572DC = 0x807572DC; + +D_80758918 = 0x80758918; + +D_80748BA0 = 0x80748BA0; +D_8075BAEC = 0x8075BAEC; +D_8075BAF0 = 0x8075BAF0; diff --git a/symbol_addrs.jetpac.us.txt b/symbol_addrs.jetpac.us.txt new file mode 100644 index 00000000..3b8764b6 --- /dev/null +++ b/symbol_addrs.jetpac.us.txt @@ -0,0 +1,18 @@ +malloc = 0x80610FE8; +rand = 0x80611A44; +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; + +is_cutscene_active = 0x807444EC; +object_timer = 0x8076A064; + +D_8002DC68 = 0x8002DC68; +D_8002EBC0 = 0x8002EBC0; +D_8002EBC8 = 0x8002EBC8; +D_8002EBF8 = 0x8002EBF8; +D_8002EC08 = 0x8002EC08; +D_8002EC1C = 0x8002EC1C; +D_8002E9CC = 0x8002E9CC; +D_80045BE3 = 0x80045BE3; +D_8002BA52 = 0x8002BA52; +D_8002E830 = 0x8002E830; diff --git a/symbol_addrs.menu.us.txt b/symbol_addrs.menu.us.txt new file mode 100644 index 00000000..094f53fa --- /dev/null +++ b/symbol_addrs.menu.us.txt @@ -0,0 +1,60 @@ +barrel_visibility_timer = 0x80033698; +dk_screen_transition_height = 0x8003369C; +text_transition_speed = 0x80033C60; +text_label_scale = 0x80033C64; +adventure_barrel_scale = 0x80033C68; +options_barrel_scale = 0x80033C6C; +mystery_barrel_scale = 0x80033C70; +battle_barrel_scale = 0x80033C74; +sound_barrel_scale = 0x80033C78; +adventure_icon_scale = 0x80033C7C; +options_icon_scale = 0x80033C80; +mystery_icon_scale = 0x80033C84; +battle_icon_scale = 0x80033C88; +sound_icon_scale = 0x80033C8C; +opening_cutscene_transition = 0x80033734; +menu_selection_available = 0x800337F0; +inputs_enabled_timer = 0x800337F4; +is_in_submenu = 0x800337F8; +menu_rotation_speed_left = 0x80033D5C; +menu_rotation_speed_right = 0x80033D60; +DK_barrel_scale = 0x80033ED4; +label_string_pointer_array = 0x80033F28; +menu_icon_transition_scale = 0x80033F3C; +menu_selection_speed = 0x80033F40; +menu_rotation_speed = 0x80033F44; +menu_cutscene_timer = 0x80033F52; +menu_cutscene_index = 0x80033F54; +is_raining = 0x80033F55; +is_night = 0x80033F56; +foreground_shading_intensity = 0x80033F58; +day_night_transition = 0x80033F5C; + +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +playCutscene = 0x8061CC40; +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; +getLevelIndex = 0x805FF030; + +widescreen_enabled = 0x807444C0; +story_skip = 0x8074452C; +current_actor_pointer = 0x807FBB40; +player_pointer = 0x807FBB4C; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +global_properties_bitfield = 0x807FBB60; +current_character_index = 0x8074E77C; +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; +newly_pressed_input = 0x807ECD48; +newly_pressed_input_copy = 0x807ECD66; + +D_80033D54 = 0x80033D54; +D_1000118 = 0x1000118; +D_20000C0 = 0x20000C0; diff --git a/symbol_addrs.minecart.us.txt b/symbol_addrs.minecart.us.txt new file mode 100644 index 00000000..eaf8e707 --- /dev/null +++ b/symbol_addrs.minecart.us.txt @@ -0,0 +1,21 @@ +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +rand = 0x80611A44; +playCutscene = 0x8061CC40; + +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; + +current_actor_pointer = 0x807FBB40; +player_pointer = 0x807FBB4C; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +extra_player_info_pointer = 0x807FD580; + +D_8074E880 = 0x8074E880; +D_8072006C = 0x8072006C; diff --git a/symbol_addrs.multiplayer.us.txt b/symbol_addrs.multiplayer.us.txt new file mode 100644 index 00000000..7064a02f --- /dev/null +++ b/symbol_addrs.multiplayer.us.txt @@ -0,0 +1,22 @@ +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +rand = 0x80611A44; +playCutscene = 0x8061CC40; +getExitData = 0x806C96C4; +gameIsInAdventureMode = 0x8071432C; + +current_character_index = 0x8074E77C; + +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; + +current_actor_pointer = 0x807FBB40; +global_properties_bitfield = 0x807FBB60; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +extra_player_info_pointer = 0x807FD580; diff --git a/symbol_addrs.race.us.txt b/symbol_addrs.race.us.txt new file mode 100644 index 00000000..1e993255 --- /dev/null +++ b/symbol_addrs.race.us.txt @@ -0,0 +1,26 @@ +setupRaceOnMapLoad = 0x8002EC08; +castleCarRaceSetup = 0x8002D064; +initializeCastleCarRace = 0x8002A650; +sealRaceSetup = 0x80029488; +initializeSealRace = 0x8002D0B0; + +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +playCutscene = 0x8061CC40; +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; +gameIsInDKTVMode = 0x807142D8; + +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; + +current_actor_pointer = 0x807FBB40; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; + +D_807FD610 = 0x807FD610; diff --git a/symbol_addrs.rom.us.txt b/symbol_addrs.rom.us.txt new file mode 100644 index 00000000..44e6281b --- /dev/null +++ b/symbol_addrs.rom.us.txt @@ -0,0 +1,28 @@ +D_1050 = 0x1050; +D_11320 = 0x11320; +D_113F0 = 0x113F0; +D_CBE70 = 0xCBE70; +D_D4B00 = 0xD4B00; +D_D6B00 = 0xD6B00; +D_D9A40 = 0xD9A40; +D_DF600 = 0xDF600; +D_E6780 = 0xE6780; +D_EA0B0 = 0xEA0B0; +D_F41A0 = 0xF41A0; +D_FD2F0 = 0xFD2F0; +D_101A40 = 0x101A40; +D_1000020 = 0x1000020; +D_1000030 = 0x1000030; +D_1000040 = 0x1000040; +D_1000068 = 0x1000068; +D_1000090 = 0x1000090; +romAssetBin = 0x101C50; +D_188AF20 = 0x188AF20; +D_1897860 = 0x1897860; +D_1A97280 = 0x1A97280; +D_1ABCBF0 = 0x1ABCBF0; +D_1FED020 = 0x1FED020; + + +D_80100000 = 0x80100000; +D_80280000 = 0x80280000; diff --git a/symbol_addrs.water.us.txt b/symbol_addrs.water.us.txt new file mode 100644 index 00000000..f407fd2d --- /dev/null +++ b/symbol_addrs.water.us.txt @@ -0,0 +1,27 @@ +D_8002A078 = 0x8002A078; + +playSong = 0x80602A94; +playSound = 0x80609140; +malloc = 0x80610FE8; +playCutscene = 0x8061CC40; +isFlagSet = 0x8073110C; +setFlag = 0x8073129C; +gameIsInDKTVMode = 0x807142D8; +getLevelIndex = 0x805FF030; + +current_character_index = 0x8074E77C; + +game_mode_copy = 0x80755314; +game_mode = 0x80755318; +object_timer = 0x8076A064; +current_map = 0x8076A0A8; +current_exit = 0x8076A0AC; + +newly_pressed_input = 0x807ECD48; +current_actor_pointer = 0x807FBB40; +player_pointer = 0x807FBB4C; +character_change_array = 0x807FC924; +cc_number_of_players = 0x807FC928; +cc_player_index = 0x807FC929; +global_properties_bitfield = 0x807FBB60; +extra_player_info_pointer = 0x807FD580; diff --git a/tools/asm-differ/.gitignore b/tools/asm-differ/.gitignore new file mode 100644 index 00000000..eb176dc5 --- /dev/null +++ b/tools/asm-differ/.gitignore @@ -0,0 +1,2 @@ +.mypy_cache/ +__pycache__/ diff --git a/tools/asm-differ/README.md b/tools/asm-differ/README.md new file mode 100644 index 00000000..4c0b3b01 --- /dev/null +++ b/tools/asm-differ/README.md @@ -0,0 +1,40 @@ +# asm-differ + +Nice differ for assembly code (MIPS and AArch64; should be easy to hack to support other instruction sets). + +![](screenshot.png) + +## Dependencies + +- Python >= 3.6 +- `python3 -m pip install --user colorama ansiwrap watchdog python-Levenshtein` + +## Usage + +Create a file `diff-settings.sh` in some directory (see the one in this repo for an example). Then from that directory, run + +``` +/path/to/diff.sh [flags] (function|rom addr) +``` + +Recommended flags are `-mwo` (automatically run `make` on source file changes, and include symbols in diff). See `--help` for more details. + +### Tab completion + +[argcomplete](https://kislyuk.github.io/argcomplete/) can be optionally installed (with `python3 -m pip install argcomplete`) to enable tab completion in a bash shell, completing options and symbol names using the linker map. It also requires a bit more setup: + +If invoking the script **exactly** as `./diff.py`, the following should be added to the `.bashrc` according to argcomplete's instructions: + +```sh +eval "$(register-python-argcomplete ./diff.py)" +``` + +If that doesn't work, run `register-python-argcomplete ./diff.py` in your terminal and copy the output to `.bashrc`. + +If setup correctly (don't forget to restart the shell), `complete | grep ./diff.py` should output: + +``` +complete -o bashdefault -o default -o nospace -F _python_argcomplete ./diff.py +``` + +Note for developers or for general troubleshooting: run `export _ARC_DEBUG=` to enable debug output during tab-completion, it may show otherwise silenced errors. Use `unset _ARC_DEBUG` or restart the terminal to disable. diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py new file mode 100755 index 00000000..8f5daead --- /dev/null +++ b/tools/asm-differ/diff.py @@ -0,0 +1,1602 @@ +#!/usr/bin/env python3 +# PYTHON_ARGCOMPLETE_OK +import argparse +import sys +from typing import ( + Any, + Dict, + List, + Match, + NamedTuple, + NoReturn, + Optional, + Set, + Tuple, + Union, + Callable, + Pattern, +) + + +def fail(msg: str) -> NoReturn: + print(msg, file=sys.stderr) + sys.exit(1) + + +# Prefer to use diff_settings.py from the current working directory +sys.path.insert(0, ".") +try: + import diff_settings +except ModuleNotFoundError: + fail("Unable to find diff_settings.py in the same directory.") +sys.path.pop(0) + +# ==== COMMAND-LINE ==== + +try: + import argcomplete # type: ignore +except ModuleNotFoundError: + argcomplete = None + +parser = argparse.ArgumentParser(description="Diff MIPS or AArch64 assembly.") + +start_argument = parser.add_argument( + "start", + help="Function name or address to start diffing from.", +) + +if argcomplete: + + def complete_symbol( + prefix: str, parsed_args: argparse.Namespace, **kwargs: object + ) -> List[str]: + if not prefix or prefix.startswith("-"): + # skip reading the map file, which would + # result in a lot of useless completions + return [] + config: Dict[str, Any] = {} + diff_settings.apply(config, parsed_args) # type: ignore + mapfile = config.get("mapfile") + if not mapfile: + return [] + completes = [] + with open(mapfile) as f: + data = f.read() + # assume symbols are prefixed by a space character + search = f" {prefix}" + pos = data.find(search) + while pos != -1: + # skip the space character in the search string + pos += 1 + # assume symbols are suffixed by either a space + # character or a (unix-style) line return + spacePos = data.find(" ", pos) + lineReturnPos = data.find("\n", pos) + if lineReturnPos == -1: + endPos = spacePos + elif spacePos == -1: + endPos = lineReturnPos + else: + endPos = min(spacePos, lineReturnPos) + if endPos == -1: + match = data[pos:] + pos = -1 + else: + match = data[pos:endPos] + pos = data.find(search, endPos) + completes.append(match) + return completes + + setattr(start_argument, "completer", complete_symbol) + +parser.add_argument( + "end", + nargs="?", + help="Address to end diff at.", +) +parser.add_argument( + "-o", + dest="diff_obj", + action="store_true", + help="Diff .o files rather than a whole binary. This makes it possible to " + "see symbol names. (Recommended)", +) +parser.add_argument( + "-e", + "--elf", + dest="diff_elf_symbol", + metavar="SYMBOL", + help="Diff a given function in two ELFs, one being stripped and the other " + "one non-stripped. Requires objdump from binutils 2.33+.", +) +parser.add_argument( + "--source", + action="store_true", + help="Show source code (if possible). Only works with -o and -e.", +) +parser.add_argument( + "--inlines", + action="store_true", + help="Show inline function calls (if possible). Only works with -o and -e.", +) +parser.add_argument( + "--base-asm", + dest="base_asm", + metavar="FILE", + help="Read assembly from given file instead of configured base img.", +) +parser.add_argument( + "--write-asm", + dest="write_asm", + metavar="FILE", + help="Write the current assembly output to file, e.g. for use with --base-asm.", +) +parser.add_argument( + "-m", + "--make", + dest="make", + action="store_true", + help="Automatically run 'make' on the .o file or binary before diffing.", +) +parser.add_argument( + "-l", + "--skip-lines", + dest="skip_lines", + type=int, + default=0, + metavar="LINES", + help="Skip the first N lines of output.", +) +parser.add_argument( + "-s", + "--stop-jr-ra", + dest="stop_jrra", + action="store_true", + help="Stop disassembling at the first 'jr ra'. Some functions have multiple return points, so use with care!", +) +parser.add_argument( + "-i", + "--ignore-large-imms", + dest="ignore_large_imms", + action="store_true", + help="Pretend all large enough immediates are the same.", +) +parser.add_argument( + "-I", + "--ignore-addr-diffs", + action="store_true", + help="Ignore address differences. Currently only affects AArch64.", +) +parser.add_argument( + "-B", + "--no-show-branches", + dest="show_branches", + action="store_false", + help="Don't visualize branches/branch targets.", +) +parser.add_argument( + "-S", + "--base-shift", + dest="base_shift", + type=str, + default="0", + help="Diff position X in our img against position X + shift in the base img. " + 'Arithmetic is allowed, so e.g. |-S "0x1234 - 0x4321"| is a reasonable ' + "flag to pass if it is known that position 0x1234 in the base img syncs " + "up with position 0x4321 in our img. Not supported together with -o.", +) +parser.add_argument( + "-w", + "--watch", + dest="watch", + action="store_true", + help="Automatically update when source/object files change. " + "Recommended in combination with -m.", +) +parser.add_argument( + "-3", + "--threeway=prev", + dest="threeway", + action="store_const", + const="prev", + help="Show a three-way diff between target asm, current asm, and asm " + "prior to -w rebuild. Requires -w.", +) +parser.add_argument( + "-b", + "--threeway=base", + dest="threeway", + action="store_const", + const="base", + help="Show a three-way diff between target asm, current asm, and asm " + "when diff.py was started. Requires -w.", +) +parser.add_argument( + "--width", + dest="column_width", + type=int, + default=50, + help="Sets the width of the left and right view column.", +) +parser.add_argument( + "--algorithm", + dest="algorithm", + default="levenshtein", + choices=["levenshtein", "difflib"], + help="Diff algorithm to use. Levenshtein gives the minimum diff, while difflib " + "aims for long sections of equal opcodes. Defaults to %(default)s.", +) +parser.add_argument( + "--max-size", + "--max-lines", + dest="max_lines", + type=int, + default=1024, + help="The maximum length of the diff, in lines.", +) + +# Project-specific flags, e.g. different versions/make arguments. +add_custom_arguments_fn = getattr(diff_settings, "add_custom_arguments", None) +if add_custom_arguments_fn: + add_custom_arguments_fn(parser) + +if argcomplete: + argcomplete.autocomplete(parser) + +# ==== IMPORTS ==== + +# (We do imports late to optimize auto-complete performance.) + +import re +import os +import ast +import subprocess +import difflib +import string +import itertools +import threading +import queue +import time + + +MISSING_PREREQUISITES = ( + "Missing prerequisite python module {}. " + "Run `python3 -m pip install --user colorama ansiwrap watchdog python-Levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." +) + +try: + from colorama import Fore, Style, Back # type: ignore + import ansiwrap # type: ignore + import watchdog # type: ignore +except ModuleNotFoundError as e: + fail(MISSING_PREREQUISITES.format(e.name)) + +# ==== CONFIG ==== + +args = parser.parse_args() + +# Set imgs, map file and make flags in a project-specific manner. +config: Dict[str, Any] = {} +diff_settings.apply(config, args) # type: ignore + +arch: str = config.get("arch", "mips") +baseimg: Optional[str] = config.get("baseimg") +myimg: Optional[str] = config.get("myimg") +mapfile: Optional[str] = config.get("mapfile") +makeflags: List[str] = config.get("makeflags", []) +source_directories: Optional[List[str]] = config.get("source_directories") +objdump_executable: Optional[str] = config.get("objdump_executable") +map_format: str = config.get("map_format", "gnu") +mw_build_dir: str = config.get("mw_build_dir", "build/") + +MAX_FUNCTION_SIZE_LINES: int = args.max_lines +MAX_FUNCTION_SIZE_BYTES: int = MAX_FUNCTION_SIZE_LINES * 4 + +COLOR_ROTATION: List[str] = [ + Fore.MAGENTA, + Fore.CYAN, + Fore.GREEN, + Fore.RED, + Fore.LIGHTYELLOW_EX, + Fore.LIGHTMAGENTA_EX, + Fore.LIGHTCYAN_EX, + Fore.LIGHTGREEN_EX, + Fore.LIGHTBLACK_EX, +] + +BUFFER_CMD: List[str] = ["tail", "-c", str(10 ** 9)] +LESS_CMD: List[str] = ["less", "-SRic", "-#6"] + +DEBOUNCE_DELAY: float = 0.1 +FS_WATCH_EXTENSIONS: List[str] = [".c", ".h"] + +# ==== LOGIC ==== + +ObjdumpCommand = Tuple[List[str], str, Optional[str]] + +if args.algorithm == "levenshtein": + try: + import Levenshtein # type: ignore + except ModuleNotFoundError as e: + fail(MISSING_PREREQUISITES.format(e.name)) + +if args.source: + try: + import cxxfilt # type: ignore + except ModuleNotFoundError as e: + fail(MISSING_PREREQUISITES.format(e.name)) + +if args.threeway and not args.watch: + fail("Threeway diffing requires -w.") + +if objdump_executable is None: + for objdump_cand in ["mips-linux-gnu-objdump", "mips64-elf-objdump"]: + try: + subprocess.check_call( + [objdump_cand, "--version"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + objdump_executable = objdump_cand + break + except subprocess.CalledProcessError: + pass + except FileNotFoundError: + pass + +if not objdump_executable: + fail( + "Missing binutils; please ensure mips-linux-gnu-objdump or mips64-elf-objdump exist, or configure objdump_executable." + ) + + +def maybe_eval_int(expr: str) -> Optional[int]: + try: + ret = ast.literal_eval(expr) + if not isinstance(ret, int): + raise Exception("not an integer") + return ret + except Exception: + return None + + +def eval_int(expr: str, emsg: str) -> int: + ret = maybe_eval_int(expr) + if ret is None: + fail(emsg) + return ret + + +def eval_line_num(expr: str) -> int: + return int(expr.strip().replace(":", ""), 16) + + +def run_make(target: str) -> None: + subprocess.check_call(["make"] + makeflags + [target]) + + +def run_make_capture_output(target: str) -> "subprocess.CompletedProcess[bytes]": + return subprocess.run( + ["make"] + makeflags + [target], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + + +def restrict_to_function(dump: str, fn_name: str) -> str: + out: List[str] = [] + search = f"<{fn_name}>:" + found = False + for line in dump.split("\n"): + if found: + if len(out) >= MAX_FUNCTION_SIZE_LINES: + break + out.append(line) + elif search in line: + found = True + return "\n".join(out) + + +def maybe_get_objdump_source_flags() -> List[str]: + if not args.source: + return [] + + flags = [ + "--source", + "--source-comment=│ ", + "-l", + ] + + if args.inlines: + flags.append("--inlines") + + return flags + + +def run_objdump(cmd: ObjdumpCommand) -> str: + flags, target, restrict = cmd + assert objdump_executable, "checked previously" + out = subprocess.check_output( + [objdump_executable] + arch_flags + flags + [target], universal_newlines=True + ) + if restrict is not None: + return restrict_to_function(out, restrict) + return out + + +base_shift: int = eval_int( + args.base_shift, "Failed to parse --base-shift (-S) argument as an integer." +) + + +def search_map_file(fn_name: str) -> Tuple[Optional[str], Optional[int]]: + if not mapfile: + fail(f"No map file configured; cannot find function {fn_name}.") + + try: + with open(mapfile) as f: + contents = f.read() + except Exception: + fail(f"Failed to open map file {mapfile} for reading.") + + if map_format == 'gnu': + lines = contents.split("\n") + + try: + cur_objfile = None + ram_to_rom = None + cands = [] + last_line = "" + for line in lines: + if line.startswith(" .text"): + cur_objfile = line.split()[3] + if "load address" in line: + tokens = last_line.split() + line.split() + ram = int(tokens[1], 0) + rom = int(tokens[5], 0) + ram_to_rom = rom - ram + if line.endswith(" " + fn_name): + ram = int(line.split()[0], 0) + if cur_objfile is not None and ram_to_rom is not None: + cands.append((cur_objfile, ram + ram_to_rom)) + last_line = line + except Exception as e: + import traceback + + traceback.print_exc() + fail(f"Internal error while parsing map file") + + if len(cands) > 1: + fail(f"Found multiple occurrences of function {fn_name} in map file.") + if len(cands) == 1: + return cands[0] + elif map_format == 'mw': + # ram elf rom object name + find = re.findall(re.compile(r' \S+ \S+ (\S+) (\S+) . ' + fn_name + r'(?: \(entry of \.(?:init|text)\))? \t(\S+)'), contents) + if len(find) > 1: + fail(f"Found multiple occurrences of function {fn_name} in map file.") + if len(find) == 1: + rom = int(find[0][1],16) + objname = find[0][2] + # The metrowerks linker map format does not contain the full object path, so we must complete it manually. + objfiles = [os.path.join(dirpath, f) for dirpath, _, filenames in os.walk(mw_build_dir) for f in filenames if f == objname] + if len(objfiles) > 1: + all_objects = "\n".join(objfiles) + fail(f"Found multiple objects of the same name {objname} in {mw_build_dir}, cannot determine which to diff against: \n{all_objects}") + if len(objfiles) == 1: + objfile = objfiles[0] + # TODO Currently the ram-rom conversion only works for diffing ELF executables, but it would likely be more convenient to diff DOLs. + # At this time it is recommended to always use -o when running the diff script as this mode does not make use of the ram-rom conversion + return objfile, rom + else: + fail(f"Linker map format {map_format} unrecognised.") + return None, None + + +def dump_elf() -> Tuple[str, ObjdumpCommand, ObjdumpCommand]: + if not baseimg or not myimg: + fail("Missing myimg/baseimg in config.") + if base_shift: + fail("--base-shift not compatible with -e") + + start_addr = eval_int(args.start, "Start address must be an integer expression.") + + if args.end is not None: + end_addr = eval_int(args.end, "End address must be an integer expression.") + else: + end_addr = start_addr + MAX_FUNCTION_SIZE_BYTES + + flags1 = [ + f"--start-address={start_addr}", + f"--stop-address={end_addr}", + ] + + flags2 = [ + f"--disassemble={args.diff_elf_symbol}", + ] + + objdump_flags = ["-drz", "-j", ".text"] + return ( + myimg, + (objdump_flags + flags1, baseimg, None), + (objdump_flags + flags2 + maybe_get_objdump_source_flags(), myimg, None), + ) + + +def dump_objfile() -> Tuple[str, ObjdumpCommand, ObjdumpCommand]: + if base_shift: + fail("--base-shift not compatible with -o") + if args.end is not None: + fail("end address not supported together with -o") + if args.start.startswith("0"): + fail("numerical start address not supported with -o; pass a function name") + + objfile, _ = search_map_file(args.start) + if not objfile: + fail("Not able to find .o file for function.") + + if args.make: + run_make(objfile) + + if not os.path.isfile(objfile): + fail(f"Not able to find .o file for function: {objfile} is not a file.") + + refobjfile = "expected/" + objfile + if not os.path.isfile(refobjfile): + fail(f'Please ensure an OK .o file exists at "{refobjfile}".') + + objdump_flags = ["-drz"] + return ( + objfile, + (objdump_flags, refobjfile, args.start), + (objdump_flags + maybe_get_objdump_source_flags(), objfile, args.start), + ) + + +def dump_binary() -> Tuple[str, ObjdumpCommand, ObjdumpCommand]: + if not baseimg or not myimg: + fail("Missing myimg/baseimg in config.") + if args.make: + run_make(myimg) + start_addr = maybe_eval_int(args.start) + if start_addr is None: + _, start_addr = search_map_file(args.start) + if start_addr is None: + fail("Not able to find function in map file.") + if args.end is not None: + end_addr = eval_int(args.end, "End address must be an integer expression.") + else: + end_addr = start_addr + MAX_FUNCTION_SIZE_BYTES + objdump_flags = ["-Dz", "-bbinary", "-EB"] + flags1 = [ + f"--start-address={start_addr + base_shift}", + f"--stop-address={end_addr + base_shift}", + ] + flags2 = [f"--start-address={start_addr}", f"--stop-address={end_addr}"] + return ( + myimg, + (objdump_flags + flags1, baseimg, None), + (objdump_flags + flags2, myimg, None), + ) + + +def ansi_ljust(s: str, width: int) -> str: + """Like s.ljust(width), but accounting for ANSI colors.""" + needed: int = width - ansiwrap.ansilen(s) + if needed > 0: + return s + " " * needed + else: + return s + + +if arch == "mips": + re_int = re.compile(r"[0-9]+") + re_comment = re.compile(r"<.*?>") + re_reg = re.compile( + r"\$?\b(a[0-3]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|k[01]|fp|ra|zero)\b" + ) + re_sprel = re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)") + re_large_imm = re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}") + re_imm = re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)") + forbidden = set(string.ascii_letters + "_") + arch_flags = ["-m", "mips:4300"] + branch_likely_instructions = { + "beql", + "bnel", + "beqzl", + "bnezl", + "bgezl", + "bgtzl", + "blezl", + "bltzl", + "bc1tl", + "bc1fl", + } + branch_instructions = branch_likely_instructions.union( + { + "b", + "beq", + "bne", + "beqz", + "bnez", + "bgez", + "bgtz", + "blez", + "bltz", + "bc1t", + "bc1f", + } + ) + instructions_with_address_immediates = branch_instructions.union({"jal", "j"}) +elif arch == "aarch64": + re_int = re.compile(r"[0-9]+") + re_comment = re.compile(r"(<.*?>|//.*$)") + # GPRs and FP registers: X0-X30, W0-W30, [DSHQ]0..31 + # The zero registers and SP should not be in this list. + re_reg = re.compile(r"\$?\b([dshq][12]?[0-9]|[dshq]3[01]|[xw][12]?[0-9]|[xw]30)\b") + re_sprel = re.compile(r"sp, #-?(0x[0-9a-fA-F]+|[0-9]+)\b") + re_large_imm = re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}") + re_imm = re.compile(r"(?|//.*$)") + re_reg = re.compile(r"\$?\b([rf][0-9]+)\b") + re_sprel = re.compile(r"(?<=,)(-?[0-9]+|-?0x[0-9a-f]+)\(r1\)") + re_large_imm = re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}") + re_imm = re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(r1)|[^@]*@(ha|h|lo)") + arch_flags = [] + forbidden = set(string.ascii_letters + "_") + branch_likely_instructions = set() + branch_instructions = { + "b", + "beq", + "beq+", + "beq-", + "bne", + "bne+", + "bne-", + "blt", + "blt+", + "blt-", + "ble", + "ble+", + "ble-", + "bdnz", + "bdnz+", + "bdnz-", + "bge", + "bge+", + "bge-", + "bgt", + "bgt+", + "bgt-", + } + instructions_with_address_immediates = branch_instructions.union({"bl"}) +else: + fail(f"Unknown architecture: {arch}") + + +def hexify_int(row: str, pat: Match[str]) -> str: + full = pat.group(0) + if len(full) <= 1: + # leave one-digit ints alone + return full + start, end = pat.span() + if start and row[start - 1] in forbidden: + return full + if end < len(row) and row[end] in forbidden: + return full + return hex(int(full)) + + +def parse_relocated_line(line: str) -> Tuple[str, str, str]: + try: + ind2 = line.rindex(",") + except ValueError: + try: + ind2 = line.rindex("\t") + except ValueError: + ind2 = line.rindex(" ") + before = line[: ind2 + 1] + after = line[ind2 + 1 :] + ind2 = after.find("(") + if ind2 == -1: + imm, after = after, "" + else: + imm, after = after[:ind2], after[ind2:] + if imm == "0x0": + imm = "0" + return before, imm, after + + +def process_mips_reloc(row: str, prev: str) -> str: + before, imm, after = parse_relocated_line(prev) + repl = row.split()[-1] + if imm != "0": + # MIPS uses relocations with addends embedded in the code as immediates. + # If there is an immediate, show it as part of the relocation. Ideally + # we'd show this addend in both %lo/%hi, but annoyingly objdump's output + # doesn't include enough information to pair up %lo's and %hi's... + # TODO: handle unambiguous cases where all addends for a symbol are the + # same, or show "+???". + mnemonic = prev.split()[0] + if mnemonic in instructions_with_address_immediates and not imm.startswith("0x"): + imm = "0x" + imm + repl += "+" + imm if int(imm, 0) > 0 else imm + if "R_MIPS_LO16" in row: + repl = f"%lo({repl})" + elif "R_MIPS_HI16" in row: + # Ideally we'd pair up R_MIPS_LO16 and R_MIPS_HI16 to generate a + # correct addend for each, but objdump doesn't give us the order of + # the relocations, so we can't find the right LO16. :( + repl = f"%hi({repl})" + elif "R_MIPS_26" in row: + # Function calls + pass + elif "R_MIPS_PC16" in row: + # Branch to glabel. This gives confusing output, but there's not much + # we can do here. + pass + else: + assert False, f"unknown relocation type '{row}' for line '{prev}'" + return before + repl + after + + +def process_ppc_reloc(row: str, prev: str) -> str: + assert any(r in row for r in ["R_PPC_REL24", "R_PPC_ADDR16", "R_PPC_EMB_SDA21"]), f"unknown relocation type '{row}' for line '{prev}'" + before, imm, after = parse_relocated_line(prev) + repl = row.split()[-1] + if "R_PPC_REL24" in row: + # function calls + pass + elif "R_PPC_ADDR16_HI" in row: + # absolute hi of addr + repl = f"{repl}@h" + elif "R_PPC_ADDR16_HA" in row: + # adjusted hi of addr + repl = f"{repl}@ha" + elif "R_PPC_ADDR16_LO" in row: + # lo of addr + repl = f"{repl}@l" + elif "R_PPC_ADDR16" in row: + # 16-bit absolute addr + if "+0x7" in repl: + # remove the very large addends as they are an artifact of (label-_SDA(2)_BASE_) + # computations and are unimportant in a diff setting. + if int(repl.split("+")[1],16) > 0x70000000: + repl = repl.split("+")[0] + elif "R_PPC_EMB_SDA21" in row: + # small data area + pass + return before + repl + after + + +def pad_mnemonic(line: str) -> str: + if "\t" not in line: + return line + mn, args = line.split("\t", 1) + return f"{mn:<7s} {args}" + + +class Line(NamedTuple): + mnemonic: str + diff_row: str + original: str + normalized_original: str + line_num: str + branch_target: Optional[str] + source_lines: List[str] + comment: Optional[str] + + +class DifferenceNormalizer: + def normalize(self, mnemonic: str, row: str) -> str: + """This should be called exactly once for each line.""" + row = self._normalize_arch_specific(mnemonic, row) + if args.ignore_large_imms: + row = re.sub(re_large_imm, "", row) + return row + + def _normalize_arch_specific(self, mnemonic: str, row: str) -> str: + return row + + +class DifferenceNormalizerAArch64(DifferenceNormalizer): + def __init__(self) -> None: + super().__init__() + self._adrp_pair_registers: Set[str] = set() + + def _normalize_arch_specific(self, mnemonic: str, row: str) -> str: + if args.ignore_addr_diffs: + row = self._normalize_adrp_differences(mnemonic, row) + row = self._normalize_bl(mnemonic, row) + return row + + def _normalize_bl(self, mnemonic: str, row: str) -> str: + if mnemonic != "bl": + return row + + row, _ = split_off_branch(row) + return row + + def _normalize_adrp_differences(self, mnemonic: str, row: str) -> str: + """Identifies ADRP + LDR/ADD pairs that are used to access the GOT and + suppresses any immediate differences. + + Whenever an ADRP is seen, the destination register is added to the set of registers + that are part of an ADRP + LDR/ADD pair. Registers are removed from the set as soon + as they are used for an LDR or ADD instruction which completes the pair. + + This method is somewhat crude but should manage to detect most such pairs. + """ + row_parts = row.split("\t", 1) + if mnemonic == "adrp": + self._adrp_pair_registers.add(row_parts[1].strip().split(",")[0]) + row, _ = split_off_branch(row) + elif mnemonic == "ldr": + for reg in self._adrp_pair_registers: + # ldr xxx, [reg] + # ldr xxx, [reg, ] + if f", [{reg}" in row_parts[1]: + self._adrp_pair_registers.remove(reg) + return normalize_imms(row) + elif mnemonic == "add": + for reg in self._adrp_pair_registers: + # add reg, reg, + if row_parts[1].startswith(f"{reg}, {reg}, "): + self._adrp_pair_registers.remove(reg) + return normalize_imms(row) + + return row + + +def make_difference_normalizer() -> DifferenceNormalizer: + if arch == "aarch64": + return DifferenceNormalizerAArch64() + return DifferenceNormalizer() + + +def process(lines: List[str]) -> List[Line]: + normalizer = make_difference_normalizer() + skip_next = False + source_lines = [] + if not args.diff_obj: + lines = lines[7:] + if lines and not lines[-1]: + lines.pop() + + output: List[Line] = [] + stop_after_delay_slot = False + for row in lines: + if args.diff_obj and (">:" in row or not row): + continue + + if args.source and (row and row[0] != " "): + source_lines.append(row) + continue + + if "R_AARCH64_" in row: + # TODO: handle relocation + continue + + if "R_MIPS_" in row: + # N.B. Don't transform the diff rows, they already ignore immediates + # if output[-1].diff_row != "": + # output[-1] = output[-1].replace(diff_row=process_mips_reloc(row, output[-1].row_with_imm)) + new_original = process_mips_reloc(row, output[-1].original) + output[-1] = output[-1]._replace(original=new_original) + continue + + if "R_PPC_" in row: + new_original = process_ppc_reloc(row, output[-1].original) + output[-1] = output[-1]._replace(original=new_original) + continue + + m_comment = re.search(re_comment, row) + comment = m_comment[0] if m_comment else None + row = re.sub(re_comment, "", row) + row = row.rstrip() + tabs = row.split("\t") + row = "\t".join(tabs[2:]) + line_num = tabs[0].strip() + + if "\t" in row: + row_parts = row.split("\t", 1) + else: + # powerpc-eabi-objdump doesn't use tabs + row_parts = [part.lstrip() for part in row.split(" ", 1)] + mnemonic = row_parts[0].strip() + + if mnemonic not in instructions_with_address_immediates: + row = re.sub(re_int, lambda m: hexify_int(row, m), row) + original = row + normalized_original = normalizer.normalize(mnemonic, original) + if skip_next: + skip_next = False + row = "" + mnemonic = "" + if mnemonic in branch_likely_instructions: + skip_next = True + row = re.sub(re_reg, "", row) + row = re.sub(re_sprel, "addr(sp)", row) + row_with_imm = row + if mnemonic in instructions_with_address_immediates: + row = row.strip() + row, _ = split_off_branch(row) + row += "" + else: + row = normalize_imms(row) + + branch_target = None + if mnemonic in branch_instructions: + target = row_parts[1].strip().split(",")[-1] + if mnemonic in branch_likely_instructions: + target = hex(int(target, 16) - 4)[2:] + branch_target = target.strip() + + output.append( + Line( + mnemonic=mnemonic, + diff_row=row, + original=original, + normalized_original=normalized_original, + line_num=line_num, + branch_target=branch_target, + source_lines=source_lines, + comment=comment, + ) + ) + source_lines = [] + + if args.stop_jrra and mnemonic == "jr" and row_parts[1].strip() == "ra": + stop_after_delay_slot = True + elif stop_after_delay_slot: + break + + return output + + +def format_single_line_diff(line1: str, line2: str, column_width: int) -> str: + return ansi_ljust(line1, column_width) + line2 + + +class SymbolColorer: + symbol_colors: Dict[str, str] + + def __init__(self, base_index: int) -> None: + self.color_index = base_index + self.symbol_colors = {} + + def color_symbol(self, s: str, t: Optional[str] = None) -> str: + try: + color = self.symbol_colors[s] + except: + color = COLOR_ROTATION[self.color_index % len(COLOR_ROTATION)] + self.color_index += 1 + self.symbol_colors[s] = color + t = t or s + return f"{color}{t}{Fore.RESET}" + + +def normalize_imms(row: str) -> str: + return re.sub(re_imm, "", row) + + +def normalize_stack(row: str) -> str: + return re.sub(re_sprel, "addr(sp)", row) + + +def split_off_branch(line: str) -> Tuple[str, str]: + parts = line.split(",") + if len(parts) < 2: + parts = line.split(None, 1) + off = len(line) - len(parts[-1]) + return line[:off], line[off:] + +ColorFunction = Callable[[str], str] + +def color_fields(pat: Pattern[str], out1: str, out2: str, color1: ColorFunction, color2: Optional[ColorFunction]=None) -> Tuple[str, str]: + diffs = [of.group() != nf.group() for (of, nf) in zip(pat.finditer(out1), pat.finditer(out2))] + + it = iter(diffs) + def maybe_color(color: ColorFunction, s: str) -> str: + return color(s) if next(it, False) else f"{Style.RESET_ALL}{s}" + + out1 = pat.sub(lambda m: maybe_color(color1, m.group()), out1) + it = iter(diffs) + out2 = pat.sub(lambda m: maybe_color(color2 or color1, m.group()), out2) + + return out1, out2 + + +def color_branch_imms(br1: str, br2: str) -> Tuple[str, str]: + if br1 != br2: + br1 = f"{Fore.LIGHTBLUE_EX}{br1}{Style.RESET_ALL}" + br2 = f"{Fore.LIGHTBLUE_EX}{br2}{Style.RESET_ALL}" + return br1, br2 + + +def diff_sequences_difflib( + seq1: List[str], seq2: List[str] +) -> List[Tuple[str, int, int, int, int]]: + differ = difflib.SequenceMatcher(a=seq1, b=seq2, autojunk=False) + return differ.get_opcodes() + + +def diff_sequences( + seq1: List[str], seq2: List[str] +) -> List[Tuple[str, int, int, int, int]]: + if ( + args.algorithm != "levenshtein" + or len(seq1) * len(seq2) > 4 * 10 ** 8 + or len(seq1) + len(seq2) >= 0x110000 + ): + return diff_sequences_difflib(seq1, seq2) + + # The Levenshtein library assumes that we compare strings, not lists. Convert. + # (Per the check above we know we have fewer than 0x110000 unique elements, so chr() works.) + remapping: Dict[str, str] = {} + + def remap(seq: List[str]) -> str: + seq = seq[:] + for i in range(len(seq)): + val = remapping.get(seq[i]) + if val is None: + val = chr(len(remapping)) + remapping[seq[i]] = val + seq[i] = val + return "".join(seq) + + rem1 = remap(seq1) + rem2 = remap(seq2) + return Levenshtein.opcodes(rem1, rem2) # type: ignore + + +def diff_lines( + lines1: List[Line], + lines2: List[Line], +) -> List[Tuple[Optional[Line], Optional[Line]]]: + ret = [] + for (tag, i1, i2, j1, j2) in diff_sequences( + [line.mnemonic for line in lines1], + [line.mnemonic for line in lines2], + ): + for line1, line2 in itertools.zip_longest(lines1[i1:i2], lines2[j1:j2]): + if tag == "replace": + if line1 is None: + tag = "insert" + elif line2 is None: + tag = "delete" + elif tag == "insert": + assert line1 is None + elif tag == "delete": + assert line2 is None + ret.append((line1, line2)) + + return ret + + +class OutputLine: + base: Optional[str] + fmt2: str + key2: Optional[str] + + def __init__(self, base: Optional[str], fmt2: str, key2: Optional[str]) -> None: + self.base = base + self.fmt2 = fmt2 + self.key2 = key2 + + def __eq__(self, other: object) -> bool: + if not isinstance(other, OutputLine): + return NotImplemented + return self.key2 == other.key2 + + def __hash__(self) -> int: + return hash(self.key2) + + +def do_diff(basedump: str, mydump: str) -> List[OutputLine]: + output: List[OutputLine] = [] + + lines1 = process(basedump.split("\n")) + lines2 = process(mydump.split("\n")) + + sc1 = SymbolColorer(0) + sc2 = SymbolColorer(0) + sc3 = SymbolColorer(4) + sc4 = SymbolColorer(4) + sc5 = SymbolColorer(0) + sc6 = SymbolColorer(0) + bts1: Set[str] = set() + bts2: Set[str] = set() + + if args.show_branches: + for (lines, btset, sc) in [ + (lines1, bts1, sc5), + (lines2, bts2, sc6), + ]: + for line in lines: + bt = line.branch_target + if bt is not None: + btset.add(bt + ":") + sc.color_symbol(bt + ":") + + for (line1, line2) in diff_lines(lines1, lines2): + line_color1 = line_color2 = sym_color = Fore.RESET + line_prefix = " " + if line1 and line2 and line1.diff_row == line2.diff_row: + if line1.normalized_original == line2.normalized_original: + out1 = line1.original + out2 = line2.original + elif line1.diff_row == "": + out1 = f"{Style.BRIGHT}{Fore.LIGHTBLACK_EX}{line1.original}" + out2 = f"{Style.BRIGHT}{Fore.LIGHTBLACK_EX}{line2.original}" + else: + mnemonic = line1.original.split()[0] + out1, out2 = line1.original, line2.original + branch1 = branch2 = "" + if mnemonic in instructions_with_address_immediates: + out1, branch1 = split_off_branch(line1.original) + out2, branch2 = split_off_branch(line2.original) + branchless1 = out1 + branchless2 = out2 + out1, out2 = color_fields(re_imm, out1, out2, lambda s: f"{Fore.LIGHTBLUE_EX}{s}{Style.RESET_ALL}") + + same_relative_target = False + if line1.branch_target is not None and line2.branch_target is not None: + relative_target1 = eval_line_num(line1.branch_target) - eval_line_num(line1.line_num) + relative_target2 = eval_line_num(line2.branch_target) - eval_line_num(line2.line_num) + same_relative_target = relative_target1 == relative_target2 + + if not same_relative_target: + branch1, branch2 = color_branch_imms(branch1, branch2) + + out1 += branch1 + out2 += branch2 + if normalize_imms(branchless1) == normalize_imms(branchless2): + if not same_relative_target: + # only imms differences + sym_color = Fore.LIGHTBLUE_EX + line_prefix = "i" + else: + out1, out2 = color_fields(re_sprel, out1, out2, sc3.color_symbol, sc4.color_symbol) + if normalize_stack(branchless1) == normalize_stack(branchless2): + # only stack differences (luckily stack and imm + # differences can't be combined in MIPS, so we + # don't have to think about that case) + sym_color = Fore.YELLOW + line_prefix = "s" + else: + # regs differences and maybe imms as well + out1, out2 = color_fields(re_reg, out1, out2, sc1.color_symbol, sc2.color_symbol) + line_color1 = line_color2 = sym_color = Fore.YELLOW + line_prefix = "r" + elif line1 and line2: + line_prefix = "|" + line_color1 = Fore.LIGHTBLUE_EX + line_color2 = Fore.LIGHTBLUE_EX + sym_color = Fore.LIGHTBLUE_EX + out1 = line1.original + out2 = line2.original + elif line1: + line_prefix = "<" + line_color1 = sym_color = Fore.RED + out1 = line1.original + out2 = "" + elif line2: + line_prefix = ">" + line_color2 = sym_color = Fore.GREEN + out1 = "" + out2 = line2.original + + if args.source and line2 and line2.comment: + out2 += f" {line2.comment}" + + def format_part( + out: str, + line: Optional[Line], + line_color: str, + btset: Set[str], + sc: SymbolColorer, + ) -> Optional[str]: + if line is None: + return None + in_arrow = " " + out_arrow = "" + if args.show_branches: + if line.line_num in btset: + in_arrow = sc.color_symbol(line.line_num, "~>") + line_color + if line.branch_target is not None: + out_arrow = " " + sc.color_symbol(line.branch_target + ":", "~>") + out = pad_mnemonic(out) + return f"{line_color}{line.line_num} {in_arrow} {out}{Style.RESET_ALL}{out_arrow}" + + part1 = format_part(out1, line1, line_color1, bts1, sc5) + part2 = format_part(out2, line2, line_color2, bts2, sc6) + key2 = line2.original if line2 else None + + mid = f"{sym_color}{line_prefix}" + + if line2: + for source_line in line2.source_lines: + color = Style.DIM + # File names and function names + if source_line and source_line[0] != "│": + color += Style.BRIGHT + # Function names + if source_line.endswith("():"): + # Underline. Colorama does not provide this feature, unfortunately. + color += "\u001b[4m" + try: + source_line = cxxfilt.demangle( + source_line[:-3], external_only=False + ) + except: + pass + output.append( + OutputLine( + None, + f" {color}{source_line}{Style.RESET_ALL}", + source_line, + ) + ) + + fmt2 = mid + " " + (part2 or "") + output.append(OutputLine(part1, fmt2, key2)) + + return output + + +def chunk_diff(diff: List[OutputLine]) -> List[Union[List[OutputLine], OutputLine]]: + cur_right: List[OutputLine] = [] + chunks: List[Union[List[OutputLine], OutputLine]] = [] + for output_line in diff: + if output_line.base is not None: + chunks.append(cur_right) + chunks.append(output_line) + cur_right = [] + else: + cur_right.append(output_line) + chunks.append(cur_right) + return chunks + + +def format_diff( + old_diff: List[OutputLine], new_diff: List[OutputLine] +) -> Tuple[str, List[str]]: + old_chunks = chunk_diff(old_diff) + new_chunks = chunk_diff(new_diff) + output: List[Tuple[str, OutputLine, OutputLine]] = [] + assert len(old_chunks) == len(new_chunks), "same target" + empty = OutputLine("", "", None) + for old_chunk, new_chunk in zip(old_chunks, new_chunks): + if isinstance(old_chunk, list): + assert isinstance(new_chunk, list) + if not old_chunk and not new_chunk: + # Most of the time lines sync up without insertions/deletions, + # and there's no interdiffing to be done. + continue + differ = difflib.SequenceMatcher(a=old_chunk, b=new_chunk, autojunk=False) + for (tag, i1, i2, j1, j2) in differ.get_opcodes(): + if tag in ["equal", "replace"]: + for i, j in zip(range(i1, i2), range(j1, j2)): + output.append(("", old_chunk[i], new_chunk[j])) + if tag in ["insert", "replace"]: + for j in range(j1 + i2 - i1, j2): + output.append(("", empty, new_chunk[j])) + if tag in ["delete", "replace"]: + for i in range(i1 + j2 - j1, i2): + output.append(("", old_chunk[i], empty)) + else: + assert isinstance(new_chunk, OutputLine) + assert new_chunk.base + # old_chunk.base and new_chunk.base have the same text since + # both diffs are based on the same target, but they might + # differ in color. Use the new version. + output.append((new_chunk.base, old_chunk, new_chunk)) + + # TODO: status line, with e.g. approximate permuter score? + width = args.column_width + if args.threeway: + header_line = "TARGET".ljust(width) + " CURRENT".ljust(width) + " PREVIOUS" + diff_lines = [ + ansi_ljust(base, width) + + ansi_ljust(new.fmt2, width) + + (old.fmt2 or "-" if old != new else "") + for (base, old, new) in output + ] + else: + header_line = "" + diff_lines = [ + ansi_ljust(base, width) + new.fmt2 + for (base, old, new) in output + if base or new.key2 is not None + ] + return header_line, diff_lines + + +def debounced_fs_watch( + targets: List[str], + outq: "queue.Queue[Optional[float]]", + debounce_delay: float, +) -> None: + import watchdog.events # type: ignore + import watchdog.observers # type: ignore + + class WatchEventHandler(watchdog.events.FileSystemEventHandler): # type: ignore + def __init__( + self, queue: "queue.Queue[float]", file_targets: List[str] + ) -> None: + self.queue = queue + self.file_targets = file_targets + + def on_modified(self, ev: object) -> None: + if isinstance(ev, watchdog.events.FileModifiedEvent): + self.changed(ev.src_path) + + def on_moved(self, ev: object) -> None: + if isinstance(ev, watchdog.events.FileMovedEvent): + self.changed(ev.dest_path) + + def should_notify(self, path: str) -> bool: + for target in self.file_targets: + if path == target: + return True + if args.make and any( + path.endswith(suffix) for suffix in FS_WATCH_EXTENSIONS + ): + return True + return False + + def changed(self, path: str) -> None: + if self.should_notify(path): + self.queue.put(time.time()) + + def debounce_thread() -> NoReturn: + listenq: "queue.Queue[float]" = queue.Queue() + file_targets: List[str] = [] + event_handler = WatchEventHandler(listenq, file_targets) + observer = watchdog.observers.Observer() + observed = set() + for target in targets: + if os.path.isdir(target): + observer.schedule(event_handler, target, recursive=True) + else: + file_targets.append(target) + target = os.path.dirname(target) or "." + if target not in observed: + observed.add(target) + observer.schedule(event_handler, target) + observer.start() + while True: + t = listenq.get() + more = True + while more: + delay = t + debounce_delay - time.time() + if delay > 0: + time.sleep(delay) + # consume entire queue + more = False + try: + while True: + t = listenq.get(block=False) + more = True + except queue.Empty: + pass + outq.put(t) + + th = threading.Thread(target=debounce_thread, daemon=True) + th.start() + + +class Display: + basedump: str + mydump: str + emsg: Optional[str] + last_diff_output: Optional[List[OutputLine]] + pending_update: Optional[Tuple[str, bool]] + ready_queue: "queue.Queue[None]" + watch_queue: "queue.Queue[Optional[float]]" + less_proc: "Optional[subprocess.Popen[bytes]]" + + def __init__(self, basedump: str, mydump: str) -> None: + self.basedump = basedump + self.mydump = mydump + self.emsg = None + self.last_diff_output = None + + def run_less(self) -> "Tuple[subprocess.Popen[bytes], subprocess.Popen[bytes]]": + if self.emsg is not None: + output = self.emsg + else: + diff_output = do_diff(self.basedump, self.mydump) + last_diff_output = self.last_diff_output or diff_output + if args.threeway != "base" or not self.last_diff_output: + self.last_diff_output = diff_output + header, diff_lines = format_diff(last_diff_output, diff_output) + header_lines = [header] if header else [] + output = "\n".join(header_lines + diff_lines[args.skip_lines :]) + + # Pipe the output through 'tail' and only then to less, to ensure the + # write call doesn't block. ('tail' has to buffer all its input before + # it starts writing.) This also means we don't have to deal with pipe + # closure errors. + buffer_proc = subprocess.Popen( + BUFFER_CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE + ) + less_proc = subprocess.Popen(LESS_CMD, stdin=buffer_proc.stdout) + assert buffer_proc.stdin + assert buffer_proc.stdout + buffer_proc.stdin.write(output.encode()) + buffer_proc.stdin.close() + buffer_proc.stdout.close() + return (buffer_proc, less_proc) + + def run_sync(self) -> None: + proca, procb = self.run_less() + procb.wait() + proca.wait() + + def run_async(self, watch_queue: "queue.Queue[Optional[float]]") -> None: + self.watch_queue = watch_queue + self.ready_queue = queue.Queue() + self.pending_update = None + dthread = threading.Thread(target=self.display_thread) + dthread.start() + self.ready_queue.get() + + def display_thread(self) -> None: + proca, procb = self.run_less() + self.less_proc = procb + self.ready_queue.put(None) + while True: + ret = procb.wait() + proca.wait() + self.less_proc = None + if ret != 0: + # fix the terminal + os.system("tput reset") + if ret != 0 and self.pending_update is not None: + # killed by program with the intent to refresh + msg, error = self.pending_update + self.pending_update = None + if not error: + self.mydump = msg + self.emsg = None + else: + self.emsg = msg + proca, procb = self.run_less() + self.less_proc = procb + self.ready_queue.put(None) + else: + # terminated by user, or killed + self.watch_queue.put(None) + self.ready_queue.put(None) + break + + def progress(self, msg: str) -> None: + # Write message to top-left corner + sys.stdout.write("\x1b7\x1b[1;1f{}\x1b8".format(msg + " ")) + sys.stdout.flush() + + def update(self, text: str, error: bool) -> None: + if not error and not self.emsg and text == self.mydump: + self.progress("Unchanged. ") + return + self.pending_update = (text, error) + if not self.less_proc: + return + self.less_proc.kill() + self.ready_queue.get() + + def terminate(self) -> None: + if not self.less_proc: + return + self.less_proc.kill() + self.ready_queue.get() + + +def main() -> None: + if args.diff_elf_symbol: + make_target, basecmd, mycmd = dump_elf() + elif args.diff_obj: + make_target, basecmd, mycmd = dump_objfile() + else: + make_target, basecmd, mycmd = dump_binary() + + if args.write_asm is not None: + mydump = run_objdump(mycmd) + with open(args.write_asm, "w") as f: + f.write(mydump) + print(f"Wrote assembly to {args.write_asm}.") + sys.exit(0) + + if args.base_asm is not None: + with open(args.base_asm) as f: + basedump = f.read() + else: + basedump = run_objdump(basecmd) + + mydump = run_objdump(mycmd) + + display = Display(basedump, mydump) + + if not args.watch: + display.run_sync() + else: + if not args.make: + yn = input( + "Warning: watch-mode (-w) enabled without auto-make (-m). " + "You will have to run make manually. Ok? (Y/n) " + ) + if yn.lower() == "n": + return + if args.make: + watch_sources = None + watch_sources_for_target_fn = getattr( + diff_settings, "watch_sources_for_target", None + ) + if watch_sources_for_target_fn: + watch_sources = watch_sources_for_target_fn(make_target) + watch_sources = watch_sources or source_directories + if not watch_sources: + fail("Missing source_directories config, don't know what to watch.") + else: + watch_sources = [make_target] + q: "queue.Queue[Optional[float]]" = queue.Queue() + debounced_fs_watch(watch_sources, q, DEBOUNCE_DELAY) + display.run_async(q) + last_build = 0.0 + try: + while True: + t = q.get() + if t is None: + break + if t < last_build: + continue + last_build = time.time() + if args.make: + display.progress("Building...") + ret = run_make_capture_output(make_target) + if ret.returncode != 0: + display.update( + ret.stderr.decode("utf-8-sig", "replace") + or ret.stdout.decode("utf-8-sig", "replace"), + error=True, + ) + continue + mydump = run_objdump(mycmd) + display.update(mydump, error=False) + except KeyboardInterrupt: + display.terminate() + + +main() diff --git a/tools/asm-differ/mypy.ini b/tools/asm-differ/mypy.ini new file mode 100644 index 00000000..f7a01b34 --- /dev/null +++ b/tools/asm-differ/mypy.ini @@ -0,0 +1,16 @@ +[mypy] +check_untyped_defs = True +disallow_any_generics = True +disallow_incomplete_defs = True +disallow_subclassing_any = True +disallow_untyped_calls = True +disallow_untyped_decorators = True +disallow_untyped_defs = True +no_implicit_optional = True +warn_redundant_casts = True +warn_return_any = True +warn_unused_ignores = True +python_version = 3.6 + +[mypy-diff_settings] +ignore_errors = True diff --git a/tools/asm-differ/screenshot.png b/tools/asm-differ/screenshot.png new file mode 100644 index 00000000..32305553 Binary files /dev/null and b/tools/asm-differ/screenshot.png differ diff --git a/tools/build/img/build.py b/tools/build/img/build.py new file mode 100755 index 00000000..1b177f69 --- /dev/null +++ b/tools/build/img/build.py @@ -0,0 +1,284 @@ +#! /usr/bin/python3 + +from sys import argv, stderr +from math import floor, ceil +from glob import glob +from pathlib import Path +import png + +def unpack_color(s): + r = (s >> 11) & 0x1F + g = (s >> 6) & 0x1F + b = (s >> 1) & 0x1F + a = (s & 1) * 0xFF + + r = ceil(0xFF * (r / 31)) + g = ceil(0xFF * (g / 31)) + b = ceil(0xFF * (b / 31)) + + return r, g, b, a + +def pack_color(r, g, b, a): + r = floor(31 * (r / 255)) + g = floor(31 * (g / 255)) + b = floor(31 * (b / 255)) + + s = round(a / 0xFF) + s |= (r & 0x1F) << 11 + s |= (g & 0x1F) << 6 + s |= (b & 0x1F) << 1 + + return s + +def rgb_to_intensity(r, g, b): + return round(r * 0.2126 + g * 0.7152 + 0.0722 * b) + +def iter_in_groups(iterable, n, fillvalue=None): + from itertools import zip_longest + args = [iter(iterable)] * n + return zip_longest(*args, fillvalue=fillvalue) + + + +def reversed_if(iterator, cond): + if cond: + return reversed(list(iterator)) + else: + return iterator + +valid_image_formats = [ + 'rgba32', + 'rgba16', + 'ci8', + 'ci4', + 'palette', + 'ia4', + 'ia8', + 'ia16', + 'i4', + 'i8', +] + +class Converter(): + def __init__(self, mode, infile, outfile, *argv): + self.infile = infile + self.outfile = outfile + self.flip_y = "--flip-y" in argv + + if mode == "auto": + # Extract the image format (rgba16, etc.) from a filename such as x.rgba16.png + inpath = Path(infile) + inpath_suffixes = inpath.suffixes + if len(inpath_suffixes) < 2: + print(f"could not determine format for image {infile}", file=stderr) + exit(1) + img_format = inpath_suffixes[-2][1:] + if not img_format in valid_image_formats: + print(f"invalid format for image {infile}: {img_format}", file=stderr) + exit(1) + self.mode = img_format + else: + self.mode = mode + + self.warned = False + + def warn(self, msg): + if not self.warned: + self.warned = True + print(self.infile + ": warning: " + msg, file=stderr) + + def convert(self): + img = png.Reader(self.infile) + + if self.mode == "rgba32": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + f.write(row) + elif self.mode == "rgba16": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + for rgba in iter_in_groups(row, 4): + if rgba[3] not in (0, 0xFF): + self.warn("alpha mask mode but translucent pixels used") + + color = pack_color(*rgba) + f.write(color.to_bytes(2, byteorder="big")) + elif self.mode == "ci8": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.read()[2], self.flip_y): + f.write(row) + elif self.mode == "ci4": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.read()[2], self.flip_y): + for a, b in iter_in_groups(row, 2): + byte = (a << 4) | b + byte = byte & 0xFF + f.write(byte.to_bytes(1, byteorder="big")) + elif self.mode == "palette": + img.preamble(True) + palette = img.palette(alpha="force") + + with open(self.outfile, "wb") as f: + for rgba in palette: + if rgba[3] not in (0, 0xFF): + self.warn("alpha mask mode but translucent pixels used") + + color = pack_color(*rgba) + f.write(color.to_bytes(2, byteorder="big")) + elif self.mode == "ia4": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + for c1, c2 in iter_in_groups(iter_in_groups(row, 4), 2): + i1 = rgb_to_intensity(*c1[:3]) + a1 = c1[3] + + i2 = rgb_to_intensity(*c2[:3]) + a2 = c2[3] + + i1 = floor(7 * (i1 / 0xFF)) + i2 = floor(7 * (i2 / 0xFF)) + + if a1 not in (0, 0xFF) or a2 not in (0, 0xFF): + self.warn("alpha mask mode but translucent pixels used") + if c1[0] != c1[1] != c1[2]: + self.warn("grayscale mode but image is not") + if c2[0] != c2[1] != c2[2]: + self.warn("grayscale mode but image is not") + + a1 = 1 if a1 > 128 else 0 + a2 = 1 if a2 > 128 else 0 + + h = (i1 << 1) | a1 + l = (i2 << 1) | a2 + + byte = (h << 4) | l + f.write(byte.to_bytes(1, byteorder="big")) + elif self.mode == "ia8": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + for rgba in iter_in_groups(row, 4): + i = rgb_to_intensity(*rgba[:3]) + a = rgba[3] + + i = floor(15 * (i / 0xFF)) + a = floor(15 * (a / 0xFF)) + + if rgba[0] != rgba[1] != rgba[2]: + self.warn("grayscale mode but image is not") + + byte = (i << 4) | a + f.write(byte.to_bytes(1, byteorder="big")) + elif self.mode == "ia16": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + for rgba in iter_in_groups(row, 4): + i = rgb_to_intensity(*rgba[:3]) + a = rgba[3] + + if rgba[0] != rgba[1] != rgba[2]: + self.warn("grayscale mode but image is not") + + f.write(bytes((i, a))) + elif self.mode == "i4": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + for c1, c2 in iter_in_groups(iter_in_groups(row, 4), 2): + if c1[3] != 0xFF or c2[3] != 0xFF: + self.warn("discarding alpha channel") + + i1 = rgb_to_intensity(*c1[:3]) + i2 = rgb_to_intensity(*c2[:3]) + + i1 = floor(15 * (i1 / 0xFF)) + i2 = floor(15 * (i2 / 0xFF)) + + if c1[0] != c1[1] != c1[2]: + self.warn("grayscale mode but image is not") + if c2[0] != c2[1] != c2[2]: + self.warn("grayscale mode but image is not") + + byte = (i1 << 4) | i2 + f.write(byte.to_bytes(1, byteorder="big")) + elif self.mode == "i8": + with open(self.outfile, "wb") as f: + for row in reversed_if(img.asRGBA()[2], self.flip_y): + for rgba in iter_in_groups(row, 4): + if rgba[3] != 0xFF or rgba[3] != 0xFF: + self.warn("discarding alpha channel") + if rgba[0] != rgba[1] != rgba[2]: + self.warn("grayscale mode but image is not") + + i = rgb_to_intensity(*rgba[:3]) + f.write(i.to_bytes(1, byteorder="big")) + elif self.mode == "party": + data = img.read()[2] + img.preamble(True) + palette = img.palette(alpha="force") + + with open(self.outfile, "wb") as f: + # palette + for rgba in palette: + if rgba[3] not in (0, 0xFF): + self.warn("alpha mask mode but translucent pixels used") + + color = pack_color(*rgba) + f.write(color.to_bytes(2, byteorder="big")) + + assert f.tell() == 0x200, "palette has wrong size" + + # ci 8 + for row in reversed_if(data, self.flip_y): + f.write(row) + + f.write(b"\0\0\0\0\0\0\0\0\0\0") # padding + elif self.mode == "bg": + width, height, data, info = img.read() + img.preamble(True) + palettes = [img.palette(alpha="force")] + + for palettepath in glob(self.infile.split(".")[0] + ".*.png"): + pal = png.Reader(palettepath) + pal.preamble(True) + palettes.append(pal.palette(alpha="force")) + + with open(self.outfile, "wb") as f: + baseaddr = 0x80200000 # gBackgroundImage + headers_len = 0x10 * len(palettes) + palettes_len = 0x200 * len(palettes) + + # header (struct BackgroundHeader) + for i, palette in enumerate(palettes): + f.write((baseaddr + palettes_len + headers_len).to_bytes(4, byteorder="big")) # raster offset + f.write((baseaddr + headers_len + 0x200 * i).to_bytes(4, byteorder="big")) # palette offset + f.write((12).to_bytes(2, byteorder="big")) # startX + f.write((20).to_bytes(2, byteorder="big")) # startY + f.write((width).to_bytes(2, byteorder="big")) # width + f.write((height).to_bytes(2, byteorder="big")) # height + + assert f.tell() == headers_len + + for palette in palettes: + # palette + for rgba in palette: + if rgba[3] not in (0, 0xFF): + self.warn("alpha mask mode but translucent pixels used") + + color = pack_color(*rgba) + f.write(color.to_bytes(2, byteorder="big")) + + assert f.tell() == palettes_len + headers_len + + # ci 8 + for row in reversed_if(data, self.flip_y): + f.write(row) + else: + print("unsupported mode", file=stderr) + exit(1) + + +if __name__ == "__main__": + if len(argv) < 4: + print("usage: build.py MODE INFILE OUTFILE [--flip-y]") + exit(1) + + Converter(*argv[1:]).convert() diff --git a/tools/gzip-1.2.4/.configure.swp b/tools/gzip-1.2.4/.configure.swp new file mode 100644 index 00000000..c3346f68 Binary files /dev/null and b/tools/gzip-1.2.4/.configure.swp differ diff --git a/tools/gzip-1.2.4/COPYING b/tools/gzip-1.2.4/COPYING new file mode 100644 index 00000000..a43ea212 --- /dev/null +++ b/tools/gzip-1.2.4/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/tools/gzip-1.2.4/ChangeLog b/tools/gzip-1.2.4/ChangeLog new file mode 100644 index 00000000..7dd0f865 --- /dev/null +++ b/tools/gzip-1.2.4/ChangeLog @@ -0,0 +1,587 @@ +Wed Aug 18 09:34:23 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.2.4 + By default, do not restore file name and timestamp from those saved + inside the .gz file (behave as 'compress'). Added the --name option + to force name and timestamp restoration. + Accept - as synonym for stdin. + Use manlinks=so or ln to support either hard links or .so in man pages + Accept foo.gz~ in zdiff. + Added support for Windows NT + Handle ENAMETOOLONG for strict Posix systems + Use --recursive instead of --recurse to comply with Webster and + the GNU stdandard. + Allow installation of shell scripts with a g prefix: make G=g install + Install by default zcat as gzcat if gzcat already exists in path. + Let zmore behave as more when invoked without parameters (give help) + Let gzip --list reject files not in gzip format even with --force. + Don't complain about non gzip files for options -rt or -rl. + Added advice in INSTALL for several systems. + Added makefile entries for NeXTstep 3.1 (if configure fails) + Avoid problem with memcpy on Pyramid (gave crc error on some files) + Support the -r option when compiled with Borland C++ on msdos. + Force lower case file names only for FAT file systems (not HPFS) + Rewrite one expression in inflate.c to avoid cc bug on Solaris x86. + In the msdos makefiles, get match.asm from the msdos subdirectory. + Catch SIGTERM and SIGHUP only if they are not ignored. + getopt.c: on Amiga, "#if !defined(const)" does not compile. + Use register parameters on Amiga. + Do not force names to lower case on Amiga. + Fix support of Atari TOS (Makefile.st and tailor.h) + In unlzw.c, do not suggest using zcat if zcat already used. + In INSTALL, suggest using bsdinst for HPUX. + Document Turbo C++ 1.0 bug in INSTALL. + Improved the documentation relative to the --no-name option. + Avoid signed/unsigned warnings in several files. + Added pointer to jka-compr19.el in README. + Added pointer to OS/2 executables in README. + Added --block-compress in tar -z example (gzip.1 and gzip.texi). + Don't keep rcsid in executable (avoid compilation warnings). + Check also the correctness of the first byte of an .Z file. + Return non zero status for an invalid option. + Remove "NEWFILES" from os2/gzip.def for Borland C++ on OS/2. + Remove "time stamp restored" message (just obey the -N request). + +Thu Jun 24 10:27:57 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.2.3 + Don't display the output name when decompressing except with --verbose. + Remove usage of alloca in getopt.c and all makefiles. + Use ASCPP instead of CPP to avoid breaking AC_HEADER_CHECK on RiscOS. + Added the zfile shell script in subdirectory sample. + Moved the list of compiler bugs from README to INSTALL. + Added vms/Readme.vms. + Fix DIST_BUFSIZE check in unlzh.c for 16 bit machines. + Fix REGSIGTYP macro in configure.in. + Use 'define' instead of == in vms/gzip.hlp. + Avoid warnings in unlzh.c + Allow separate installation of binaries and man pages. + Simplified handling of file names with spaces in zgrep and znew. + Fix dependencies and remove rule for trees.c in amiga/Makefile.sasc + Add missing quote in gzexe. + +Thu Jun 17 13:47:05 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.2.2 + Fix a compilation error in gzip.c on Sun with cc (worked with gcc). + +Wed Jun 16 11:20:27 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.2.1 + Let zmore act as more if the data is not gzipped. + By default, display output name only when name was actually truncated. + Use absolute path names in gzexe'd programs for better security. + In gzexe, use chmod 700 instead of 755 and don't gzexe tail,rm,etc... + Update vms/gzip.hlp. + Added a note about the fast options (-1 to -3) in algorithm.doc. + Improved man page for zgrep. + Minor fixes to gzip.texi. + Always set LC_ALL and LANG in configure (for tr on HPUX) + +Mon Jun 14 10:03:24 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.2 + Added the --list option to display the file characteristics. + Added the --no-name option: do not save or restore original filename + Save the original name by default. + Allow gunzip --suffix "" to attempt decompression on any file + regardless of its extension if an original name is present. + Add support for the SCO compress -H format. + gzip --fast now compresses faster (speed close to that of compress) + with degraded compression ratio (but still better than compress). + Default level changed to -6 (acts exactly as previous level -5) to + be a better indication of its placement in the speed/ratio range. + Use smart name truncation: 123456789012.c -> 123456789.c.gz + instead of 12345678901.gz + With --force, let zcat pass non gzip'ed data unchanged (zcat == cat) + Added the zgrep shell script. + Made sub.c useful for 16 bit sound, 24 bit images, etc.. + Supress warnings about suffix for gunzip -r, except with --verbose. + Moved the sample programs to a subdirectory sample. + On MSDOS, use .gz extension when possible (files without extension) + Added a "Special targets" section in INSTALL. + Use stty -g correctly in zmore.in. + Use cheaper test for gzipness in zforce.in. + Remove space before $ in match.S (no longer accepted by gas 2.x) + For the shell scripts, do not assume that gzip is in the path. + Fix syntax error and define lnk$library in vms/Makefile.mms + REGSIGTYPE is void on the Amiga. + Do not write empty line when decompressing stdin with --verbose. + Fix the 1.1.2 fix for VMS (bug in get_suffix) + Added warning in README about compiler bug on Solaris 2.1 for x86. + Added warning about 'rehash' in INSTALL. + Removed default value of read_buf in bits.c (supermax doesn't like). + In tailor.h, added support for Borland C and Zortech C on OS/2. + Added warning in gzexe about Ultrix buggy sh (use /bin/sh5 instead). + Added warning in zdiff about AIX buggy sh (use /bin/ksh instead). + In configure.in, do not try the asm code if DEFS contains NO_ASM + +Fri Jun 4 09:49:33 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.1.2 + Fix serious bug for VMS (-gz not removed when decompressing). + Allow suffix other than .gz in znew. + Do not display compression ratio when decompressing stdin. + In zmore.in, work around brain damaged stty -g (Ultrix). + Display a correct compression ratio for .Z files. + Added .z to .gz renaming script in INTALL. + Allow setting CFLAGS in configure. + Add warning in README about bug in Concentrix cc compiler. + Avoid || in Makefile.in (at least one make doesn't support this). + Disable useless --ascii option for the Amiga. + Add a pointer to the Primos executable in README. + Added description of extra field in algorithm.doc. + Do not redefine NULL in alloca.c. + Added check for unsupported compression methods. + Avoid getopt redeclaration on OSF/1. + +Tue Jun 1 09:07:15 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.1.1 + Fix serious bug in vms.c (== instead of =). + Added --ascii option. + Add workaround in configure.in for Ultrix (quote eval argument) + Do not use unset in znew (not supported on Ultrix) + Use tar.gz instead of tar.z for the distribution of gzip. + Add missing menu item in gzip.texi. + Use size_t instead of unsigned, add AC_SIZE_T in configure.in. + +Fri May 28 11:40:01 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.1 + Use .gz suffix by default, add --suffix option. + Let gunzip accept a "_z" suffix (used by one 'compress' on Vax/VMS). + Quit when reading garbage from stdin instead of reporting an error. + Added sub.c and add.c for compression of 8 bit images. + Added makefile for VAX/MMS and support for wildcards on VMS. + Added support for MSC under OS/2. + Added support for Prime/PRIMOS. + Display compression ratio also when decompressing. + Quit after --version (GNU standard) + Use --force to bypass isatty() check. + Accept --silent as synonym for --quiet (see longopts.table) + Accept --to-stdout as synonym for --stdout (see longopts.table) + Accept -H and -? in addition to -h and --help. + Added comparison of zip and gzip in the readme file. + Return an error code in all main compression/decompression functions. + Continue processing other files in case of recoverable error. + Add description of -f in znew.1. + Do not keep uncompressed version for znew -t if .gz already exists. + On Unix, use only st_ino and st_dev in same_file(). + Use S_IRUSR and S_IWUSR if they exist. + "test $1 = -d" -> "test x$1 = x-d" in gzexe. + In match.S, use symbol sysV68 to detect the Motorola Delta. + Do not include memory.h with gcc (conflicting declarations on Sun). + Fix more typos. + On VMS, define unlink as delete also for gcc. + In "make check", unset LANG because "wc -c" fails on Kanji. + Renamed shdir as scriptdir. + Use the 68020 code instead of 68000 code on the NeXT. + Documented --uncompress as synonym for --decompress. + Include the standard header files before gzip.h (needed on Bull). + Do not assume that _POSIX_VERSION implies dirent.h present. + Removed gzip-tar.patch since tar 1.11.2 handles gzip directly. + Use less memory when compiled with -DSMALL_MEM (for MSDOS). + Optimized updcrc(). + Don't complain if cc -E does not work correctly. + Do not attempt reading 64K bytes on 16 bit Unix systems. + Do not use the variable name 'overhead' which is reserved on Lynx! + One BULL compiler does not like *p++ in inflate.c => *p, p++. + Use casts on free and memcmp to avoid warnings. + Remove the "off by more than one minute" time stamp kludge, but + document how to avoid saving the time stamp on pipes if desired. + Include crypt.h in inflate.c (one system predefines the CRYPT symbol). + Add links to gunzip and (g)zcat in the default make rule. + Create installation directories if they do not exist. + Clarified --prefix option in INSTALL. + Use symbol mc68k in match.S for the DIAB DS90. + Guard against zero length _match.s in configure.in. + In zmore, restore all tty options using stty -g. + Added support for MacOS + Simplified makecrc.c. + Avoid warnings in getopt.c, util.c, unlzw.c. + Use autoconf 1.4, in particular for INSTALL and AC_HAVE_POUNDBANG + Use .so instead of hard links for zcat.1, gunzip.1 and zcmp.1. + Fixed declration of sig_type. + Make consistency check in fcfree. + Added ztouch. + Do not complain if utime fails on a directory (for OS/2). + +Thu Mar 18 18:56:43 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.7 + Allow zmore to read from standard input (like more). + Support the 68000 (Atari ST) in match.S. + Retry partial writes (required on Linux when gzip is suspended in + a pipe). + Allow full pathnames and renamings in gzexe. + Don't let gzexe compress setuid executables or gzip itself. + Added vms/Makefile.gcc for gcc on the Vax. + Give a pointer to Solaris and VMS executables of gzip in README. + Allow installation of binaries and shell scripts in different dirs. + Do not use alloca on the Cray. + Provide strspn and strcspn if string.h does not exist. + Define O_CREAT and O_EXCL from FCREAT and FEXCL if necessary. + Remove gzip.doc in make realclean. + Fixed many typos. (Corrections to my English are welcome.) + Put "make manext=l install" at the correct place in INSTALL. + Fix incorrect examples in INSTALL and give more examples. + Include zdiff.1 for install and uninstall. + Allows complex PAGER variable in zmore (e.g.: PAGER="col -x | more") + Avoid warning on unused indfound in getopt.c. + Cast memset arg to void* (required by some buggy compilers). + Include sys/types.h before dirent.h in acgeneral.m4. + Fix acgeneral.m4 AC_COMPILE_CHECK to avoid warnings. + Don't use alloca.c with gcc. (One NeXT user did not have alloca.h). + Change all error messages according to GNU standards. + Restore time stamp only if off by more than one minute. + Allow installation of zcat as gzcat. + Suppress help message and send compressed data to the terminal when + gzip is invoked without parameters and without redirection. + (Explicit request from Noah Friedman.) + Add compile option GNU_STANDARD to respect the GNU coding standards: + with -DGNU_STANDARD, behave as gzip even if invoked under the + name gunzip. (Complaints to /dev/null or the FSF, not to me!) + +Fri Mar 10 13:27:18 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.6 + Let gzexe detect executables that are already gzexe'd. + Don't try restoring record format on VMS (the simple 1.0.5 code + worked correctly only on fixed-512 files). Suppress text_mode. + Added asm version for 68000 in amiga/match.a. + Use asm version for Atari TT. + Fix "make clean" in vms/Makefile.vms. + For OS/2, assume HPFS by default, add flag OS2FAT if necessary. + Fixed some bugs in zdiff and define zcmp as a link to zdiff. + Added zdiff.1 + Remove configure hack for NeXT; add general fix to autoconf instead + Do not strip a ".z" extension if this results in an empty name. + Avoid array overflow in get_prefix() for extensions > 10 chars. + Accept either q or e to quit zmore. + In zmore, try restoring tty mode in all cases. + Use Motorola style for match.S on the NeXT. + configure.in: unsetenv *hangs* with the Siemens csh... + Update vms/gzip.hlp. + +Thu Mar 4 14:13:34 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.5 + For VMS, restore the file type for variable record format, otherwise + extract in fixed length format (not perfect, but better than + forcing all files to be in stream_LF format). + Use "-z" suffix for VMS. + Use only .z, .*-z, .tgz, .taz as valid gzip extensions; update + zforce accordingly. + Allow a version number in input file names for VMS. + Added sample program zread.c. + Fix "make check" for some implementations of /bin/sh. + Don't rely on stat() for filenames with extension > 3 chars + on MSDOS, OS2 and Atari. + Garbage collect files in /tmp created by gzexe. + Quote $opt in znew. + Use TOUCH env variable in znew if it exists. + Better error message for gunzip on empty or truncated file. + Allow prototypes in getopt.h when __STDC__ defined but 0. + Added "make clean" in vms/Makefile.vms. + Removed -g from default CFLAGS (with Noah's permission!) + Avoid too many HAVE_xxx_H for most systems; use common defaults. + Moved default Atari flags into tailor.h for consistency. + Use memzero() to clear the hash table. + Update vms/gzip.hlp to reflect the VMS behavior. + Fix OS_CODE (to fit in a byte). + Add utime.h for the Amiga. + Add gcc support for the Amiga. + Work around incorrect dirent.h for NeXT 2.0. + Added Makefile entry for Coherent. + +Fri Feb 22 11:20:49 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.4 + Added optimized asm version for 68020. + Add support for DJGPP. + Add support for the Atari ST. + Added zforce to rename gzip'ed files with truncated names. + Do not install with name uncompress (some systems rely on the + absence of any check in the old uncompress). + Added missing function (fcfree) in msdos/tailor.c + Let gunzip handle .tgz files, and let gzip skip them. + Added 'stty min 1' in zmore for SysV and fixed trap code. + Suppress .PHONY in Makefile.in, which breaks old makes. + Added documentation about pcat and unpack in INSTALL. + Add cast to getenv for systems without stdlib.h. + Use VAXC instead of VMS to avoid confusion for gcc. + Add -K to znew.1. + Add gzexe.1. + Try preserving file permissions in gzexe. + Added -d option for gzexe. + Guard against spaces in file names in gzexe. + Use CMP env. variable in zcmp. + Return a warning exit status for gzip of file with .z suffix. + Suppress usage of d_ino which is not portable to all systems. + Use #ifdef instead of #if for consistency. + For VMS, use "cc util.c" instead of "cc util" (pb with logical names) + Added utime() for Amiga. + Renamed gzcat.1 as zcat.1. + Include fcntl.h for Amiga (for read and write). + For VMS, add definition of symbols and links in the makefiles. + Give a VMS look to vms/gzip.hlp. + Save the original name only when necessary. + Add a mode parameter for open in read mode (required by VMS). + For VMS, remove the version suffix from the original name. + Accept both / and \ as path separator for MSDOS. + Let gunzip extract stored .zip files correctly. + Added warning about VFC format in vms/gzip.hlp. + In znew, skip a bad file but process the others. + Cleanup tailor.h. + Use GZIP_OPT for VMS to avoid conflict with program name. + Added description of GZIP variable in gzip.texi. + +Thu Feb 11 17:21:32 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.3 + Add -K option for znew to keep old .Z files if smaller. + Add -q option (quiet) to cancel -v in GZIP env variable. + For Turbo C, normalize pointers before freeing them. + Add more safety checks in add_envopt(). + Add do_exit() for uniform exit path (always free memory). + Reduce MAX_PATH_LEN for MSDOS. + Include sys/types.h before signal.h + Avoid strdup, the NeXT does not have it. + Made gzexe safer on systems with filename limitation to 14 chars. + +Fri Feb 10 09:45:49 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.2 + Added env variable GZIP for default options. + Added support for the Amiga. + znew now keeps the old .Z if it is smaller than the .z file. + Added gzexe to compress rarely used executables. + Reduce memory usage when using static allocation (no DYN_ALLOC). + Better separation of warning and error return codes. + Fix unlzw.c to make DYN_ALLOC and MAXSEG_64K independent options. + Allow INBUFSIZ to be >= 32K in unlzw (don't use sign of rsize) + Generate tar file in old format to avoid problems with old systems. + Preserve time stamp in znew -P if touch -r works. + Use ${PAGER-more} instead of ${PAGER:-more} in zmore. + Do not use unsigned instead of mode_t. + Better error message for trailing garbage in .z file; ignore this + garbage on VMS. + In zmore, use icanon instead of -cbreak on SYSV. + Add trap handler in zmore. + Use char* instead of void* for non STDC compilers. + Added makefile entry for Xenix on 286. + Return an error code when existing file was not overwritten. + Use prototype of lzw.h for lzw.c. + Fix znew with -P option alone. + Give warning for directories even without -v. + Close output file before unlink() in case of error. + Suppress all target dependent ifdef from the portable files. + Free all dynamically allocated variables upon exit. + +Thu Feb 4 18:23:56 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0.1 + Fixed some trivial errors in msdos/Makefile.bor + +Thu Feb 4 10:00:59 1993 Jean-loup Gailly (jloup@chorus.fr) + + * version 1.0 + gzip now runs on Vax/VMS (Amiga support will come in next version). + Do not overwrite files without -f when using /bin/sh. + Support the test option -t for compressed (.Z) files. + Flush output for bad compressed files. Add warning in README. + Added makefiles for MSDOS. + Don't rely on presence of csh in configure + Added gunzip.1 and gzcat.1. + Updated znew.1. + Check reserved flags in unlzw(). + Return dummy value in main to avoid lint warning. + Define OF in lzw.h for lint. + Allow both "znew -v -t" and "znew -vt". + Don't overwrite the output file name for multiple parts. + Echo just a warning if configure is out of date. + Use ; instead of , in trees.c (confuses the SAS Amiga compiler). + In INSTALL, document "DEFS='-DM_XENIX' ./configure". + Use OTHER_PATH_SEP for more portability (DOS, OS2, VMS, AMIGA). + Make all directories world writable for broken versions of tar. + Use gzip -cd instead of zcat in zmore, zcmp, zdiff. + Don't use GNU tar for distributions, some systems can't untar. + Do not exit() for gzip --version. + +Mon Jan 26 10:26:42 1993 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.8.2 + Avoid 'far' declarations for MSDOS. + Use test -f instead of test -x in configure.in (for Ultrix) + Add empty else part to if in Makefile.in for broken shells. + Use NO_UNDERLINE instead of UNDERLINE (pb with Linux cpp) + Accept continuation files with -ff (for damage recovery) + Small patch to Makefile.os2 + Use memzero instead of bzero to avoid potential conflicts + Document restriction on extraction of zip files. + Fix quoting in ACL_HAVE_SHELL_HACK. + Do not check file size on MSDOS because of bug in DIET. + Allow zcat on a file with multiple links. + Add fix in inflate.c for compatibility with pkzip 2.04c. + Release gzip in tar.z and tar format. (No tar.Z). + +Fri Jan 22 10:04:13 1993 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.8.1 + Fixed Makefile.os2 + Fixed #if directives that TurboC does not like. + Don't rely on uncompress in znew, use gzip -d. + Add the pipe option -P in znew. + Add some more ideas in TODO. + Support both NDIR and SYSNDIR. + +Sat Jan 21 15:46:38 1993 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.8 + Support unpack. + Check for _match.o in configure.in in addition to return status. + Include in zip.c + Define local variables and functions as local. + Accept more alternative names for the program (pcat, gzcat, ...). + Accept .exe as well as .EXE. + Uncompress files with multiple links only with -f. + Better error message for gunzip of non-existent file.z. + Fix the entry for /etc/magic in INSTALL. + Use AC_HAVE_HEADERS uniformly instead of special macros. + Install the man pages as .1 by default instead of .l. + Document crypt++.el in README. + Fix for unlzw() on 16-bit machines (bitmask must be unsigned). + Complain if input and output files are identical. + Create a correct output name for files of exactly 13 chars. + Do not overwrite CPP if set + Check for i386 before trying to assemble match.s + Check for underline in external name before assembling + Add patch for tar 1.11.1. + +Mon Jan 5 10:16:24 1993 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.7 + Use "make check" instead of "make test". + Do not rely on dirname in znew. + Keep time stamp and pass options to gzip in znew. + Rename .l files back to .1 to avoid conflict with lex + Do not create .z.z files with gzip -r. + Use nice_match in match.asm + Unroll loops in deflate.c + Do not attempt matches beyond the window end + Allow again gunzip .zip files (was working in 0.5) + Allow again compilation with TurboC 2.0 (was working in 0.4) + +Tue Dec 30 20:00:19 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.6 + The .z extension is used by pack, not compact (README, gzip.1) + Accept gzcat in addition to zcat. + Use PAGER in zmore if defined. + Man pages for /usr/local/man/manl should have extension .l. + Don't redefine bzero on the NeXT + Allow incomplete Huffman table if there is only one code. + Don't lookahead more than 7 bits (caused premature EOF). + Added "make test" to check for compiler bugs. + Don't rely on `i386`; try to assemble directly + Change magic header to avoid conflict with freeze 1.x. + Added entry for /etc/magic in INSTALL. + Do not destroy an input .zip file with more than one member. + Display "untested" instead of "OK" for gzip -t foo.Z + With -t, skip stdin in .Z format + Allow multiple compressed members in an input file. + Ignore a zero time stamp. + Made znew safer. + +Tue Dec 29 10:00:19 1992 Noah Friedman (friedman@gnu.ai.mit.edu) + + Added test for #!/bin/sh in configure.in. + Fix some references to $srcdir in Makefile.in + +Mon Dec 21 17:33:35 1992 Jean-Loup Gailly (jloup@chorus.fr) + + * Beta version 0.5 + Put RCS ids in all files. + Added znew to recompress old .Z files with gzip. + Avoid "already .z suffix" messages for -r and no -v. + Put back check for d_ino in treat_dir(). + Use HAVE_STRING_H instead of USG. + Added os2/Makefile.os2 + Use SYSUTIME on OS/2. + Info dir is $(prefix)/info, not $(prefix)/lib/info. + Support long options, added getopt and alloca + Support -V and -t + Reorder configure.in according to suggestions in autoconf.info + Allow links when not removing original file + Allow either .z or .Z in zdiff + +Wed Nov 25 11:40:04 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.4.1 + Save only the original base name, don't include any directory prefix. + Don't use HAVE_LONG_FILE_NAMES (support multiple file system types). + Fix declaration of abort_gzip in gzip.h. + Include unistd.h when it exists to avoid warnings with gcc -Wall. + +Mon Nov 23 12:39:01 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.4 + Lots of cleanup + Use autoconf generated 'configure' + Fixed the NO_MULTIPLE_DOTS code + Fixed the save_orig_name code + Support for MSDOS (Turbo C) + +Thu Nov 19 15:18:22 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Beta version 0.3 + Added auto configuration. Just type "make" now. + Don't overwrite compress by default in "make install". Use + "make install_compress" to overwrite. + Add match.s for 386 boxes. + Added documentation in texinfo format. + Provide help for "gunzip" invoked without redirected input. + Save original file name when necessary. + Support OS/2 (Kai-Uwe Rommel). + +Tue Nov 17 14:32:53 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Alpha version 0.2.4 + Return 0 in get_istat() when ok (caused error with zcat). + Don't update crc on compressed data (caused crc errors on + large files). + +Fri Nov 13 15:04:12 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Alpha version 0.2.3 + Initialize rsize in unlzw.c + Initialize ofd for zcat. + Do not use volatile ifname as argument of treat_dir. + Add -1 to -9 in gzip.1. + +Sat Oct 31 18:30:00 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Alpha version 0.2.2. + Fix error messages. + Accept gunzip on zip files. + +Sat Oct 31 17:15:00 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Alpha version 0.2.1 + Use ctype.h in util.c (problem on SysV). + Create BINDIR if it does not exist. + Use cc by default. + Added zcmp, zmore, zdiff. + Fixed the man page gzip.1. + +Sat Oct 31 17:00:00 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Alpha version 0.2 + Fixed compilation problems with gcc + +Sat Oct 31 12:46:00 1992 Jean-loup Gailly (jloup@chorus.fr) + + * Alpha version 0.1 released (under time pressure), so it's not + much tested, sorry. + diff --git a/tools/gzip-1.2.4/INSTALL b/tools/gzip-1.2.4/INSTALL new file mode 100644 index 00000000..b2011654 --- /dev/null +++ b/tools/gzip-1.2.4/INSTALL @@ -0,0 +1,273 @@ +This is a generic INSTALL file for utilities distributions. +Some features specific to gzip have been added. + +To compile this package: + +1. Configure the package for your system. In the directory that this +file is in, type `./configure'. If you're using `csh' on an old +version of System V, you might need to type `sh configure' instead to +prevent `csh' from trying to execute `configure' itself. If you +are using Ultrix, you might need to type `sh5 configure' to avoid +bugs in /bin/sh. Note that 'sh -x configure' may give different results +than 'sh configure', making it difficult to debug configure scripts. + +The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation, and +creates the Makefile(s) (one in each subdirectory of the source +directory). In some packages it creates a C header file containing +system-dependent definitions. It also creates a file `config.status' +that you can run in the future to recreate the current configuration. + +Running `configure' takes a minute or two. While it is running, it +prints some messages that tell what it is doing. If you don't want to +see the messages, run `configure' with its standard output redirected +to `/dev/null'; for example, `./configure >/dev/null'. + +To compile the package in a different directory from the one +containing the source code, you must use a version of `make' that +supports the VPATH variable, such as GNU `make'. `cd' to the directory +where you want the object files and executables to go and run +`configure'. `configure' automatically checks for the source code in +the directory that `configure' is in and in `..'. If for some reason +`configure' is not in the source code directory that you are +configuring, then it will report that it can't find the source code. +In that case, run `configure' with the option `--srcdir=DIR', where +DIR is the directory that contains the source code. + +By default, `make install' will install the package's files in +/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify an +installation prefix other than /usr/local by giving `configure' the option +`--prefix=PATH'. Alternately, you can do so by consistently giving a value +for the `prefix' variable when you run `make', e.g., + make prefix=/usr/gnu + make prefix=/usr/gnu install + +You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If +you give `configure' the option `--exec-prefix=PATH' or set the +`make' variable `exec_prefix' to PATH, the package will use PATH as +the prefix for installing programs and libraries. Data files and +documentation will still use the regular prefix. Normally, all files +are installed using the regular prefix. + +Another `configure' option is useful mainly in `Makefile' rules for +updating `config.status' and `Makefile'. The `--no-create' option +figures out the configuration for your system and records it in +`config.status', without actually configuring the package (creating +`Makefile's and perhaps a configuration header file). Later, you can +run `./config.status' to actually configure the package. You can also +give `config.status' the `--recheck' option, which makes it re-run +`configure' with the same arguments you used before. This option is +useful if you change `configure'. + +`configure' ignores any other arguments that you give it. + +If your system requires unusual options for compilation or linking +that `configure' doesn't know about, you can give `configure' initial +values for some variables by setting them in the environment. In +Bourne-compatible shells, you can do that on the command line like +this: + CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure + +For csh compatible shells, you can do something like this: + + (setenv CC 'gcc -traditional' ; ./configure) + +The `make' variables that you might want to override with environment +variables when running `configure' are: + +(For these variables, any value given in the environment overrides the +value that `configure' would choose:) +CC C compiler program. + Default is `cc', or `gcc' if `gcc' is in your PATH. +INSTALL Program to use to install files. + Default is `install' if you have it, `cp' otherwise. + If you have an non-standard `install', use INSTALL="cp -p" + +(For these variables, any value given in the environment is added to +the value that `configure' chooses:) +DEFS Configuration options, in the form `-Dfoo -Dbar ...' +CFLAGS Compiler options, such as `-O -g ...' +LIBS Libraries to link with, in the form `-lfoo -lbar ...' + +If you need to do unusual things to compile the package, we encourage +you to figure out how `configure' could check whether to do them, and +mail diffs or instructions to the address given in the README so we +can include them in the next release. + +2. Type `make' to compile the package. If you want, you can override +the `make' variables CFLAGS and LDFLAGS like this: + + make CFLAGS=-O2 LDFLAGS=-s + +3. The package comes with self-tests. If you want to run them, +type `make check'. + +4. Type `make install' to install programs, data files, and +documentation. This creates links between gzip, gunzip and zcat. +You can create additional links uncompress, ungzip and gzcat if +you prefer these names. You can also create links to unpack and pcat +if your system uses packed files by default and you want to transform +them transparently to gzip'ed files. + +If you wish to use only the name gzcat and not overwrite an existing zcat, use: + + make ZCAT=gzcat install + +The man pages are installed by default with an extension `.1' (one). +If you want the extension `.l' (lower case L) use: + + make manext=l install + +If you are using csh or tcsh, you must type `rehash' after `make install' +to make sure that the command `gzip' will invoke the new executable. + +5. You can remove the program binaries and object files from the +source directory by typing `make clean'. To also remove the +Makefile(s), the header file containing system-dependent definitions +(if the package uses one), and `config.status' (all the files that +`configure' created), type `make distclean'. + +The file `configure.in' is used as a template to create `configure' by +a program called `autoconf'. You will only need it if you want to +regenerate `configure' using a newer version of `autoconf'. + +6. You can add the following lines to your /etc/magic file so that +file(1), if your system supports it, will recognize files created by +gzip: + +0 string \037\213 gzip compressed data +>2 byte 8 - deflate method +>3 byte &0x1 , ascii +>3 byte &0x2 , continuation +>3 byte &0x4 , extra field +>3 byte &0x8 , original file name +>3 byte &0x10 , comment +>3 byte &0x20 , encrypted +>8 byte 2 , max compression +>8 byte 4 , max speed + +If your version of 'file' does not accept octal numbers in strings, replace the +first line with one of these: + +0 short 0x8b1f gzip compressed data +0 short 0105437 gzip compressed data + +0 short 0x1f8b gzip compressed data +0 short 017613 gzip compressed data + +Use the first or second form if your machine is a 386 or a Vax or a +MIPS configured in little-endian mode or any other little-endian +machine. Use the third or fourth form on big-endian machines. +On some systems, the field separators must contain only tabs (no spaces). + +7. To rename .z files with the new .gz suffix, you can use or adapt + the following shell script: + +#!/bin/sh +find . -name '*.z' -type f -print | while read i +do + new=`echo "$i" | sed 's/\.z$/.gz/'` + mv "$i" "$new" || echo Failed renaming $i to $new +done + +If you wish to keep the old .z suffix as default without setting the +GZIP environment variable to "--suffix .z", you can compile gzip with: + + make CFLAGS='-DZ_SUFFIX=\".z\"' + + +8. Special targets + +- For MSDOS, OS/2, VMS, Atari, Amiga, Primos, use the makefile or command + file provided in the appropriate subdirectory. For Turbo C++ 1.0, read + the warning at the top of Makefile.bor. + +- On some systems memcpy() may not work as expected. (Problem found on + Pyramid only so far.) If you get "crc error" on some .gz files, add + -DNOMEMCPY to CFLAGS and recompile inflate.o. For example: + rm -f inflate.o + make CFLAGS="-O2 -DNOMEMCPY" + + The memcpy problem affects only gunzip, not gzip. You can safely define + -DNOMEMCPY on all systems, but this may degrade performance of gunzip. + +- If your system is a pure BSD system but incorrectly links string.h to + strings.h, you may get undefined mem* and str* symbols. Try recompiling with + + make clean + make CFLAGS="-DNO_STRING_H" + +- On some systems (reported on Dec Ultrix), "cc -E" and /lib/cpp behave + differently. If you have trouble with the default configuration, try: + + CPP=/lib/cpp ./configure + make clean + make + +- On Ultrix, /bin/sh is too buggy. Use "sh5 configure" instead of "configure". + +- On Mips Dec Ultrix, gunzip behaves non-deterministically with regard + to some .gz files. The same command either succeeds or gives a CRC error. + This problem is still being investigated. The files produced by gzip + are correct (can reliably be extracted on other systems). + +- On Xenix, some preprocessors do not define M_XENIX. You may have to do: + + DEFS='-DM_XENIX' ./configure + +- On Xenix 2.3.2 for 286, do: make xenix_286 + +- On Coherent, do: make coherent + +- On NeXTstep 3.1, many people (but not all) have had trouble with + configure. Try first + + (setenv DEFS -DNO_UTIME_H; ./configure) + make test + + If this fails, then try "make next". configure should work correctly + on NeXTstep versions up to 3.0. + + To build a gzip package that can run on either the m68k or i386 family, + use configure then "make next-fat". + + On some versions of NeXT, either "cc -finline-functions" or "cc -O4" + is broken. gzip produces valid .gz files but they are much too large + because the string matching code misses most matches. Use "cc -O" instead. + +- There is an optimization bug in the IRIX 4.0.5 IDO 4.1 assembler which is + triggered by GCC -O. IDO 4.1.1 should fix this. If you have to use IDO 4.1 + then you can avoid the bug in one of the following ways: + + 1. Use SGI CC + 2. Add the -noasmopt flag to GCC + 3. Reconfigure GCC with the "mips-sgi-irix4loser" target which effectively + does the same as specifying "-noasmopt" all by default. + 4. Don't use -O at all with GCC. + +- On Solaris 2.1 for x86, the January 1993 "OEM" compiler release + generates bad code. This is fixed in the June 1993 "FCS" release. + +- on Sparc with SunOS 4.1.1 and the SC1.0 compiler, the optimizer + works up to -O3 but -O4 does not work. + +- MSC 5.1 with -Ox and -DDYN_ALLOC generates bad code in inflate.c. + The default is static allocation (no DYN_ALLOC) and -Ox works on inflate.c. + But -Ox does not work on util.c and unlzh.c, so you must use -Oait -Gs. + +- The exit() function in Turbo C++ 1.0 seems to be broken. gzip crashes + even if exit(0) is the first statement in main(). The problem is avoided + by adding -Dexit=_exit to CFLAGS in Makefile.bor. + +- On dnix 5.3 2.2 cc version 2.37c is buggy. Version 2.38d works. + +- On an Alliant running Concentrix, cc (even without optimization) generates + incorrect code. You have to use gcc. + +- On Cray running CSOS 1.0 with compiler version dev-125, you must compile + with the flag "-hnoopt" to avoid an optimizer bug. + +- On HPUX, configure can't find a correct install. Use: + + INSTALL=/usr/local/bin/bsdinst ./configure diff --git a/tools/gzip-1.2.4/Makefile b/tools/gzip-1.2.4/Makefile new file mode 100644 index 00000000..380753bc --- /dev/null +++ b/tools/gzip-1.2.4/Makefile @@ -0,0 +1,387 @@ +# Generated automatically from Makefile.in by configure. +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# $Id: Makefile.in,v 0.23 1993/06/24 11:51:47 jloup Exp $ + +#### Start of system configuration section. #### + + +srcdir = . +VPATH = . + +CC = gcc +ASCPP = /lib/cpp -DNO_UNDERLINE + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 + +# Things you might add to DEFS (configure usually figures out what to do): +# -DGNU_STANDARD Behave as gzip even if invoked as gunzip (GNU standard) +# -DDIRENT Use for recursion (-r) +# -DSYSDIR Use for recursion (-r) +# -DSYSNDIR Use for recursion (-r) +# -DNDIR Use for recursion (-r) +# -DSTDC_HEADERS Use +# -DHAVE_UNISTD_H Use +# -DNO_FCNTL_H Don't use +# -DNO_UTIME_H Don't use +# -DHAVE_SYSUTIME_H Use +# -DNO_MEMORY_H Don't use . Not needed if STDC_HEADERS. +# -DNO_STRING_H Use strings.h, not string.h. Not needed if STDC_HEADERS +# -DRETSIGTYPE=int Define this if signal handlers must return an int. +# -DNO_SYMLINK OS defines S_IFLNK but does not support symbolic links +# -DNO_MULTIPLE_DOTS System does not allow file names with multiple dots +# -DNO_UTIME System does not support setting file modification time +# -DNO_CHOWN System does not support setting file owner +# -DNO_DIR System does not support readdir() +# -DPROTO Force function prototypes even if __STDC__ not defined +# -DASMV Use asm version match.S +# -DMSDOS MSDOS specific +# -DOS2 OS/2 specific +# -DVAXC Vax/VMS with Vax C compiler +# -DVMS Vax/VMS with gcc +# -DDEBUG Debug code +# -DDYN_ALLOC Use dynamic allocation of large data structures +# -DMAXSEG_64K Maximum array size is 64K (for 16 bit system) +# -DRECORD_IO read() and write() are rounded to record sizes. +# -DNO_STDIN_FSTAT fstat() is not available on stdin +# -DNO_FSTAT fstat() is not available +# -DNO_SIZE_CHECK stat() does not give a reliable file size + +DEFS = -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DDIRENT=1 +LIBS = + +# additional assembly sources for particular systems may be required. +OBJA = + +SEDCMD = + +CFLAGS = -O +# If you want debug on by default, use: CFLAGS="-g" ./configure +LDFLAGS = $(CFLAGS) + +G= +# To install znew, zmore, etc... as gznew, gzmore... use: G=g + +ZCAT=zcat +# To install zcat executable and man page as gzcat, use: ZCAT=gzcat + +X= +# For OS/2 or MSDOS, use: X=.exe + +O=.o +# For OS/2 or MSDOS, use: O=.obj + +prefix = /usr/local +exec_prefix = $(prefix) + +bindir = $(exec_prefix)/bin +scriptdir = $(bindir) +# scriptdir is the directory in which shell scripts should be installed +datadir = $(prefix)/lib +libdir = $(prefix)/lib +infodir = $(prefix)/info + +# Extension (not including `.') for the installed manual page filenames. +manext = 1 +# Where to install the manual pages. +mandir = $(prefix)/man/man$(manext) +# Use manlinks=so to use the .so method instead of hard links +manlinks = ln + +alldirs = $(bindir) $(scriptdir) $(datadir) $(libdir) $(infodir) $(mandir) + +#### End of system configuration section. #### + +SHELL = /bin/sh + +LOADLIBES = $(LIBS) + +TAR = tar + +SRCS = gzip.c zip.c deflate.c trees.c bits.c unzip.c inflate.c util.c crypt.c\ + lzw.c unlzw.c unpack.c unlzh.c getopt.c match.S + +OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \ + crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O $(OBJA) + +HDRS = gzip.h lzw.h tailor.h revision.h crypt.h getopt.h + +GENFILES = README NEWS INSTALL Makefile.in configure.in configure COPYING \ + TODO THANKS ChangeLog $(SRCS) $(HDRS) zmore.in znew.in zdiff.in zgrep.in \ + zforce.in gzexe.in gzip.1 zdiff.1 zgrep.1 zmore.1 znew.1 gzexe.1 zforce.1 \ + gzip.doc algorithm.doc gzip.texi texinfo.tex gpl.texinfo gzip.info + +sampleFILES = sample/makecrc.c sample/zread.c sample/add.c sample/sub.c \ + sample/ztouch sample/zfile + +msdosFILES = msdos/tailor.c msdos/match.asm msdos/gzip.prj msdos/doturboc.bat \ + msdos/Makefile.msc msdos/Makefile.bor msdos/Makefile.djg + +os2FILES = os2/Makefile.os2 os2/gzip.def os2/gzip16.def + +ntFILES = nt/Makefile.nt + +vmsFILES = vms/Readme.vms vms/Makefile.vms vms/Makefile.gcc vms/makegzip.com \ + vms/Makefile.mms vms/vms.c vms/gzip.hlp + +amigaFILES = amiga/Makefile.sasc amiga/Makefile.gcc amiga/tailor.c \ + amiga/utime.h amiga/match.a + +atariFILES = atari/Makefile.st + +primosFILES = primos/readme primos/primos.c primos/ci.opts \ + primos/build.cpl primos/include/errno.h primos/include/fcntl.h \ + primos/include/stdlib.h primos/include/sysStat.h primos/include/sysTypes.h + +DISTFILES = $(GENFILES) $(sampleFILES) $(msdosFILES) $(os2FILES) $(ntFILES)\ + $(vmsFILES) $(amigaFILES) $(atariFILES) $(primosFILES) + +SCRIPTS = $(G)zdiff $(G)zgrep $(G)zmore $(G)znew $(G)zforce gzexe + +%$O:%.c + $(CC) -c $(DEFS) $(CFLAGS) $< + +#.PHONY: default all force test check + +default: gzip$X +all: gzip$X $(G)zdiff $(G)zgrep $(G)zmore $(G)znew $(G)zforce gzexe +force: + +#### Start of specific targets section. #### +# +# 'configure' works only on Unix systems. For other systems able to make +# sense of this makefile, you can define target specific entries here. +# For other systems such as MSDOS, separate Makefiles are +# provided in subdirectories. + +# NeXT 2.x, 3.0, 3.1 thin. For gcc, replace -bsd with -D__STRICT_BSD__. +next: + $(MAKE) all CFLAGS="-O -bsd -DASMV" \ + DEFS="-DNO_STDLIB_H -DNO_STRING_H -DNO_UTIME_H -DSYSDIR -DRETSIGTYPE=int" + +# NeXT 3.1 fat (68k + 386). For gcc, replace -bsd with -D__STRICT_BSD__. +next-fat: + $(MAKE) all OBJA=match-next.o \ + CFLAGS="-O2 -bsd -DASMV -fno-builtin -arch m68k -arch i386" \ + DEFS="-DNO_STDLIB_H -DNO_STRING_H -DNO_UTIME_H -DSYSDIR -DRETSIGTYPE=int" + +match-next.o: match.S + cat $(srcdir)/match.S > match-next.s + $(CC) -arch m68k -arch i386 -c match-next.s + rm -f match-next.s + +# gcc with emx 0.8f kit (use by preference os2/Makefile.os2) +os2_gcc: + $(MAKE) all CC=gcc CFLAGS="-O -DOS2" X=".exe" + +# Xenix 2.3.2 for 286: +xenix_286: + $(MAKE) all CFLAGS="-LARGE -M2l" + +# Coherent (with broken /bin/sh): +coherent: + $(MAKE) all OBJA=match.o DEFS=\ + "-DASMV -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DDIRENT=1" + +#### End of specific targets section. #### + +install: installdirs installbin installman + +installbin: all + $(INSTALL_PROGRAM) gzip$X $(bindir)/gzip$X + for f in $(SCRIPTS); do \ + $(INSTALL_PROGRAM) $${f} $(scriptdir)/$${f}; done + rm -f $(scriptdir)/$(G)zcmp; \ + ln $(scriptdir)/$(G)zdiff $(scriptdir)/$(G)zcmp + for f in gunzip$X ungzip$X $(ZCAT)$X ; do \ + rm -f $(bindir)/$${f}; done + @if echo $(DEFS) | grep GNU_STANDARD > /dev/null; then \ + echo 'exec gzip -d $${1+"$$@"}' > $(bindir)/gunzip$X; \ + echo 'exec gzip -dc $${1+"$$@"}' > $(bindir)/$(ZCAT)$X; \ + chmod 755 $(bindir)/gunzip$X $(bindir)/$(ZCAT)$X; \ + else \ + ln $(bindir)/gzip$X $(bindir)/gunzip$X; \ + ln $(bindir)/gzip$X $(bindir)/$(ZCAT)$X; \ + fi + +installman: gzip.info + for f in gzip gunzip $(ZCAT) $(SCRIPTS) $(G)zcmp; do \ + rm -f $(mandir)/$${f}.$(manext); done + -cd $(srcdir); for f in gzip gzexe; do \ + $(INSTALL_DATA) $${f}.1 $(mandir)/$${f}.$(manext); done + -cd $(srcdir); for f in zdiff zgrep zmore znew zforce; do \ + $(INSTALL_DATA) $${f}.1 $(mandir)/$(G)$${f}.$(manext); done + -cd $(mandir); if test $(manlinks) = so; then \ + echo .so man$(manext)/gzip.$(manext) > $(ZCAT).$(manext);\ + echo .so man$(manext)/$(G)zdiff.$(manext) > $(G)zcmp.$(manext);\ + echo .so man$(manext)/gzip.$(manext) > gunzip.$(manext);\ + chmod 644 $(ZCAT).$(manext) $(G)zcmp.$(manext) gunzip.$(manext);\ + else \ + ln gzip.$(manext) $(ZCAT).$(manext);\ + ln $(G)zdiff.$(manext) $(G)zcmp.$(manext);\ + ln gzip.$(manext) gunzip.$(manext);\ + fi + -cd $(srcdir); for f in gzip.info* ; do $(INSTALL_DATA) $${f} \ + $(infodir)/$${f}; done + +uninstall: force + -cd $(bindir); rm -f gzip$X gunzip$X $(ZCAT)$X + -cd $(scriptdir); rm -f $(SCRIPTS) $(G)zcmp + -for f in gzip gunzip $(ZCAT) $(SCRIPTS) $(G)zcmp; do \ + rm -f $(mandir)/$${f}.$(manext); done + -cd $(infodir); rm -f gzip.info* + +# install all files and replace compress (not recommended) +install_compress: install + -test -f $(bindir)/compress.old || \ + mv $(bindir)/compress$X $(bindir)/compress.old + ln $(bindir)/gzip$X $(bindir)/compress$X + rm -f $(bindir)/uncompress$X + ln $(bindir)/gzip$X $(bindir)/uncompress$X + +# Make sure all installation directories, e.g. $(bindir) actually exist by +# making them if necessary. At most one level is created (except for man). +installdirs: + -if test ! -d $(prefix)/man; then \ + mkdir $(prefix)/man; fi + -for dir in $(alldirs) ; do \ + if test ! -d $${dir}; then \ + mkdir $${dir}; fi; \ + done + +test: check +check: gzip$X + ./gzip -6 < $(srcdir)/texinfo.tex > _gztest.gz + @LANG=""; export LANG; if test `wc -c < _gztest.gz` -eq 30890; then \ + true; \ + else \ + echo FAILED gzip test: incorrect size; \ + fi + rm -f _gztest + ./gzip -d _gztest.gz + @if cmp _gztest $(srcdir)/texinfo.tex; then \ + echo gzip test OK; \ + else \ + echo FAILED gzip test: incorrect decompress; \ + fi + rm -f _gztest* + +TAGS: $(SRCS) $(HDRS) + cd $(srcdir); etags $(SRCS) $(HDRS) + +Makefile: Makefile.in ./config.status + ./config.status + +./config.status: configure + $(srcdir)/configure --srcdir=$(srcdir) --no-create + +configure: configure.in + @echo Warning: configure is out of date +# cd $(srcdir); autoconf + +clean: + rm -f *$O gzip$X gunzip$X ungzip$X $(ZCAT)$X add$X sub$X a.out core + rm -f $(G)zcmp $(SCRIPTS) _gztest* + rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.log + rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status + +realclean: distclean + rm -f TAGS gzip.info* gzip.doc + +dist: $(DISTFILES) Makefile + d=gzip-`sed -e '/VERSION/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ + -e q revision.h` ; \ + rm -f ../$$d; \ + ln -s `pwd` ../$$d; \ + cd ..; \ + files=""; \ + for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ + GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ + rm -f $$d + +zipdist: $(DISTFILES) Makefile + zip -u9T gzip`sed -e '/VERSION/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ + -e s/[.]//g -e q revision.h` $(DISTFILES) + +# Actual build-related targets + +gzip$X: Makefile $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + rm -f gunzip$X $(ZCAT)$X + ln gzip$X gunzip$X + ln gzip$X $(ZCAT)$X + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +gzip$O getopt$O: getopt.h + +match$O: match.S + $(ASCPP) $(srcdir)/match.S > _match.s + $(CC) -c _match.s + mv _match$O match$O + rm -f _match.s + +$(G)zdiff: zdiff.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zdiff.in > $@ + chmod 755 $@ + +$(G)zgrep: zgrep.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zgrep.in > $@ + chmod 755 $@ + +$(G)zmore: zmore.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zmore.in > $@ + chmod 755 $@ + +$(G)znew: znew.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/znew.in > $@ + chmod 755 $@ + +$(G)zforce: zforce.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zforce.in > $@ + chmod 755 $@ + +gzexe: gzexe.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/gzexe.in > $@ + chmod 755 $@ + +gzip.info: gzip.texi + cd $(srcdir); makeinfo gzip.texi + +gzip.dvi: gzip.texi + cd $(srcdir); texi2dvi gzip.texi + +gzip.doc: gzip.1 + nroff -man $(srcdir)/gzip.1 | col -b | uniq > gzip.doc + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: + +# end of file diff --git a/tools/gzip-1.2.4/Makefile.in b/tools/gzip-1.2.4/Makefile.in new file mode 100644 index 00000000..90723e14 --- /dev/null +++ b/tools/gzip-1.2.4/Makefile.in @@ -0,0 +1,386 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# $Id: Makefile.in,v 0.23 1993/06/24 11:51:47 jloup Exp $ + +#### Start of system configuration section. #### + + +srcdir = @srcdir@ +VPATH = @srcdir@ + +CC = @CC@ +ASCPP = @ASCPP@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +# Things you might add to DEFS (configure usually figures out what to do): +# -DGNU_STANDARD Behave as gzip even if invoked as gunzip (GNU standard) +# -DDIRENT Use for recursion (-r) +# -DSYSDIR Use for recursion (-r) +# -DSYSNDIR Use for recursion (-r) +# -DNDIR Use for recursion (-r) +# -DSTDC_HEADERS Use +# -DHAVE_UNISTD_H Use +# -DNO_FCNTL_H Don't use +# -DNO_UTIME_H Don't use +# -DHAVE_SYSUTIME_H Use +# -DNO_MEMORY_H Don't use . Not needed if STDC_HEADERS. +# -DNO_STRING_H Use strings.h, not string.h. Not needed if STDC_HEADERS +# -DRETSIGTYPE=int Define this if signal handlers must return an int. +# -DNO_SYMLINK OS defines S_IFLNK but does not support symbolic links +# -DNO_MULTIPLE_DOTS System does not allow file names with multiple dots +# -DNO_UTIME System does not support setting file modification time +# -DNO_CHOWN System does not support setting file owner +# -DNO_DIR System does not support readdir() +# -DPROTO Force function prototypes even if __STDC__ not defined +# -DASMV Use asm version match.S +# -DMSDOS MSDOS specific +# -DOS2 OS/2 specific +# -DVAXC Vax/VMS with Vax C compiler +# -DVMS Vax/VMS with gcc +# -DDEBUG Debug code +# -DDYN_ALLOC Use dynamic allocation of large data structures +# -DMAXSEG_64K Maximum array size is 64K (for 16 bit system) +# -DRECORD_IO read() and write() are rounded to record sizes. +# -DNO_STDIN_FSTAT fstat() is not available on stdin +# -DNO_FSTAT fstat() is not available +# -DNO_SIZE_CHECK stat() does not give a reliable file size + +DEFS = @DEFS@ +LIBS = @LIBS@ + +# additional assembly sources for particular systems may be required. +OBJA = @OBJA@ + +SEDCMD = @SEDCMD@ + +CFLAGS = @CFLAGS@ +# If you want debug on by default, use: CFLAGS="-g" ./configure +LDFLAGS = $(CFLAGS) + +G=@G@ +# To install znew, zmore, etc... as gznew, gzmore... use: G=g + +ZCAT=@ZCAT@ +# To install zcat executable and man page as gzcat, use: ZCAT=gzcat + +X= +# For OS/2 or MSDOS, use: X=.exe + +O=.o +# For OS/2 or MSDOS, use: O=.obj + +prefix = /usr/local +exec_prefix = $(prefix) + +bindir = $(exec_prefix)/bin +scriptdir = $(bindir) +# scriptdir is the directory in which shell scripts should be installed +datadir = $(prefix)/lib +libdir = $(prefix)/lib +infodir = $(prefix)/info + +# Extension (not including `.') for the installed manual page filenames. +manext = 1 +# Where to install the manual pages. +mandir = $(prefix)/man/man$(manext) +# Use manlinks=so to use the .so method instead of hard links +manlinks = ln + +alldirs = $(bindir) $(scriptdir) $(datadir) $(libdir) $(infodir) $(mandir) + +#### End of system configuration section. #### + +SHELL = /bin/sh + +LOADLIBES = $(LIBS) + +TAR = tar + +SRCS = gzip.c zip.c deflate.c trees.c bits.c unzip.c inflate.c util.c crypt.c\ + lzw.c unlzw.c unpack.c unlzh.c getopt.c match.S + +OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \ + crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O $(OBJA) + +HDRS = gzip.h lzw.h tailor.h revision.h crypt.h getopt.h + +GENFILES = README NEWS INSTALL Makefile.in configure.in configure COPYING \ + TODO THANKS ChangeLog $(SRCS) $(HDRS) zmore.in znew.in zdiff.in zgrep.in \ + zforce.in gzexe.in gzip.1 zdiff.1 zgrep.1 zmore.1 znew.1 gzexe.1 zforce.1 \ + gzip.doc algorithm.doc gzip.texi texinfo.tex gpl.texinfo gzip.info + +sampleFILES = sample/makecrc.c sample/zread.c sample/add.c sample/sub.c \ + sample/ztouch sample/zfile + +msdosFILES = msdos/tailor.c msdos/match.asm msdos/gzip.prj msdos/doturboc.bat \ + msdos/Makefile.msc msdos/Makefile.bor msdos/Makefile.djg + +os2FILES = os2/Makefile.os2 os2/gzip.def os2/gzip16.def + +ntFILES = nt/Makefile.nt + +vmsFILES = vms/Readme.vms vms/Makefile.vms vms/Makefile.gcc vms/makegzip.com \ + vms/Makefile.mms vms/vms.c vms/gzip.hlp + +amigaFILES = amiga/Makefile.sasc amiga/Makefile.gcc amiga/tailor.c \ + amiga/utime.h amiga/match.a + +atariFILES = atari/Makefile.st + +primosFILES = primos/readme primos/primos.c primos/ci.opts \ + primos/build.cpl primos/include/errno.h primos/include/fcntl.h \ + primos/include/stdlib.h primos/include/sysStat.h primos/include/sysTypes.h + +DISTFILES = $(GENFILES) $(sampleFILES) $(msdosFILES) $(os2FILES) $(ntFILES)\ + $(vmsFILES) $(amigaFILES) $(atariFILES) $(primosFILES) + +SCRIPTS = $(G)zdiff $(G)zgrep $(G)zmore $(G)znew $(G)zforce gzexe + +%$O:%.c + $(CC) -c $(DEFS) $(CFLAGS) $< + +#.PHONY: default all force test check + +default: gzip$X +all: gzip$X $(G)zdiff $(G)zgrep $(G)zmore $(G)znew $(G)zforce gzexe +force: + +#### Start of specific targets section. #### +# +# 'configure' works only on Unix systems. For other systems able to make +# sense of this makefile, you can define target specific entries here. +# For other systems such as MSDOS, separate Makefiles are +# provided in subdirectories. + +# NeXT 2.x, 3.0, 3.1 thin. For gcc, replace -bsd with -D__STRICT_BSD__. +next: + $(MAKE) all CFLAGS="-O -bsd -DASMV" \ + DEFS="-DNO_STDLIB_H -DNO_STRING_H -DNO_UTIME_H -DSYSDIR -DRETSIGTYPE=int" + +# NeXT 3.1 fat (68k + 386). For gcc, replace -bsd with -D__STRICT_BSD__. +next-fat: + $(MAKE) all OBJA=match-next.o \ + CFLAGS="-O2 -bsd -DASMV -fno-builtin -arch m68k -arch i386" \ + DEFS="-DNO_STDLIB_H -DNO_STRING_H -DNO_UTIME_H -DSYSDIR -DRETSIGTYPE=int" + +match-next.o: match.S + cat $(srcdir)/match.S > match-next.s + $(CC) -arch m68k -arch i386 -c match-next.s + rm -f match-next.s + +# gcc with emx 0.8f kit (use by preference os2/Makefile.os2) +os2_gcc: + $(MAKE) all CC=gcc CFLAGS="-O -DOS2" X=".exe" + +# Xenix 2.3.2 for 286: +xenix_286: + $(MAKE) all CFLAGS="-LARGE -M2l" + +# Coherent (with broken /bin/sh): +coherent: + $(MAKE) all OBJA=match.o DEFS=\ + "-DASMV -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DDIRENT=1" + +#### End of specific targets section. #### + +install: installdirs installbin installman + +installbin: all + $(INSTALL_PROGRAM) gzip$X $(bindir)/gzip$X + for f in $(SCRIPTS); do \ + $(INSTALL_PROGRAM) $${f} $(scriptdir)/$${f}; done + rm -f $(scriptdir)/$(G)zcmp; \ + ln $(scriptdir)/$(G)zdiff $(scriptdir)/$(G)zcmp + for f in gunzip$X ungzip$X $(ZCAT)$X ; do \ + rm -f $(bindir)/$${f}; done + @if echo $(DEFS) | grep GNU_STANDARD > /dev/null; then \ + echo 'exec gzip -d $${1+"$$@"}' > $(bindir)/gunzip$X; \ + echo 'exec gzip -dc $${1+"$$@"}' > $(bindir)/$(ZCAT)$X; \ + chmod 755 $(bindir)/gunzip$X $(bindir)/$(ZCAT)$X; \ + else \ + ln $(bindir)/gzip$X $(bindir)/gunzip$X; \ + ln $(bindir)/gzip$X $(bindir)/$(ZCAT)$X; \ + fi + +installman: gzip.info + for f in gzip gunzip $(ZCAT) $(SCRIPTS) $(G)zcmp; do \ + rm -f $(mandir)/$${f}.$(manext); done + -cd $(srcdir); for f in gzip gzexe; do \ + $(INSTALL_DATA) $${f}.1 $(mandir)/$${f}.$(manext); done + -cd $(srcdir); for f in zdiff zgrep zmore znew zforce; do \ + $(INSTALL_DATA) $${f}.1 $(mandir)/$(G)$${f}.$(manext); done + -cd $(mandir); if test $(manlinks) = so; then \ + echo .so man$(manext)/gzip.$(manext) > $(ZCAT).$(manext);\ + echo .so man$(manext)/$(G)zdiff.$(manext) > $(G)zcmp.$(manext);\ + echo .so man$(manext)/gzip.$(manext) > gunzip.$(manext);\ + chmod 644 $(ZCAT).$(manext) $(G)zcmp.$(manext) gunzip.$(manext);\ + else \ + ln gzip.$(manext) $(ZCAT).$(manext);\ + ln $(G)zdiff.$(manext) $(G)zcmp.$(manext);\ + ln gzip.$(manext) gunzip.$(manext);\ + fi + -cd $(srcdir); for f in gzip.info* ; do $(INSTALL_DATA) $${f} \ + $(infodir)/$${f}; done + +uninstall: force + -cd $(bindir); rm -f gzip$X gunzip$X $(ZCAT)$X + -cd $(scriptdir); rm -f $(SCRIPTS) $(G)zcmp + -for f in gzip gunzip $(ZCAT) $(SCRIPTS) $(G)zcmp; do \ + rm -f $(mandir)/$${f}.$(manext); done + -cd $(infodir); rm -f gzip.info* + +# install all files and replace compress (not recommended) +install_compress: install + -test -f $(bindir)/compress.old || \ + mv $(bindir)/compress$X $(bindir)/compress.old + ln $(bindir)/gzip$X $(bindir)/compress$X + rm -f $(bindir)/uncompress$X + ln $(bindir)/gzip$X $(bindir)/uncompress$X + +# Make sure all installation directories, e.g. $(bindir) actually exist by +# making them if necessary. At most one level is created (except for man). +installdirs: + -if test ! -d $(prefix)/man; then \ + mkdir $(prefix)/man; fi + -for dir in $(alldirs) ; do \ + if test ! -d $${dir}; then \ + mkdir $${dir}; fi; \ + done + +test: check +check: gzip$X + ./gzip -6 < $(srcdir)/texinfo.tex > _gztest.gz + @LANG=""; export LANG; if test `wc -c < _gztest.gz` -eq 30890; then \ + true; \ + else \ + echo FAILED gzip test: incorrect size; \ + fi + rm -f _gztest + ./gzip -d _gztest.gz + @if cmp _gztest $(srcdir)/texinfo.tex; then \ + echo gzip test OK; \ + else \ + echo FAILED gzip test: incorrect decompress; \ + fi + rm -f _gztest* + +TAGS: $(SRCS) $(HDRS) + cd $(srcdir); etags $(SRCS) $(HDRS) + +Makefile: Makefile.in ./config.status + ./config.status + +./config.status: configure + $(srcdir)/configure --srcdir=$(srcdir) --no-create + +configure: configure.in + @echo Warning: configure is out of date +# cd $(srcdir); autoconf + +clean: + rm -f *$O gzip$X gunzip$X ungzip$X $(ZCAT)$X add$X sub$X a.out core + rm -f $(G)zcmp $(SCRIPTS) _gztest* + rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.log + rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status + +realclean: distclean + rm -f TAGS gzip.info* gzip.doc + +dist: $(DISTFILES) Makefile + d=gzip-`sed -e '/VERSION/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ + -e q revision.h` ; \ + rm -f ../$$d; \ + ln -s `pwd` ../$$d; \ + cd ..; \ + files=""; \ + for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ + GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ + rm -f $$d + +zipdist: $(DISTFILES) Makefile + zip -u9T gzip`sed -e '/VERSION/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ + -e s/[.]//g -e q revision.h` $(DISTFILES) + +# Actual build-related targets + +gzip$X: Makefile $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + rm -f gunzip$X $(ZCAT)$X + ln gzip$X gunzip$X + ln gzip$X $(ZCAT)$X + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +gzip$O getopt$O: getopt.h + +match$O: match.S + $(ASCPP) $(srcdir)/match.S > _match.s + $(CC) -c _match.s + mv _match$O match$O + rm -f _match.s + +$(G)zdiff: zdiff.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zdiff.in > $@ + chmod 755 $@ + +$(G)zgrep: zgrep.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zgrep.in > $@ + chmod 755 $@ + +$(G)zmore: zmore.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zmore.in > $@ + chmod 755 $@ + +$(G)znew: znew.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/znew.in > $@ + chmod 755 $@ + +$(G)zforce: zforce.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/zforce.in > $@ + chmod 755 $@ + +gzexe: gzexe.in + sed -e "$(SEDCMD)" -e "s|BINDIR|$(bindir)|" $(srcdir)/gzexe.in > $@ + chmod 755 $@ + +gzip.info: gzip.texi + cd $(srcdir); makeinfo gzip.texi + +gzip.dvi: gzip.texi + cd $(srcdir); texi2dvi gzip.texi + +gzip.doc: gzip.1 + nroff -man $(srcdir)/gzip.1 | col -b | uniq > gzip.doc + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: + +# end of file diff --git a/tools/gzip-1.2.4/NEWS b/tools/gzip-1.2.4/NEWS new file mode 100644 index 00000000..ef5f8335 --- /dev/null +++ b/tools/gzip-1.2.4/NEWS @@ -0,0 +1,221 @@ +Current Version: 1.2.4. +See the file ChangeLog for the details of all changes. + +Major changes from 1.2.3 to 1.2.4 +* By default, do not restore file name and timestamp from those saved + inside the .gz file (behave as 'compress'). Added the --name option + to force name and timestamp restoration. +* Accept - as synonym for stdin. +* Use manlinks=so or ln to support either hard links or .so in man pages +* Accept foo.gz~ in zdiff. +* Added support for Windows NT +* Handle ENAMETOOLONG for strict Posix systems +* Use --recursive instead of --recurse to comply with Webster and + the GNU stdandard. +* Allow installation of shell scripts with a g prefix: make G=g install +* Install by default zcat as gzcat if gzcat already exists in path. +* Let zmore behave as more when invoked without parameters (give help) +* Let gzip --list reject files not in gzip format even with --force. +* Don't complain about non gzip files for options -rt or -rl. +* Added advice in INSTALL for several systems. + +Major changes from 1.2.2 to 1.2.3 +* Don't display the output name when decompressing except with --verbose. +* Remove usage of alloca in getopt.c and all makefiles. +* Added the zfile shell script in subdirectory sample. +* Moved the list of compiler bugs from README to INSTALL. +* Added vms/Readme.vms. + +Major changes from 1.2.1 to 1.2.2 +* Fix a compilation error on Sun with cc (worked with gcc). + +Major changes from 1.2 to 1.2.1 +* Let zmore act as more if the data is not gzipped. +* made gzexe more secure (don't rely on PATH). +* By default, display output name only when the name was actually truncated. + +Major changes from 1.1.2 to 1.2 +* Added the --list option to display the file characteristics. +* Added the --no-name option: do not save or restore original filename + Save the original name by default. +* Allow gunzip --suffix "" to attempt decompression on any file + regardless of its extension if an original name is present. +* Add support for the SCO compress -H format. +* gzip --fast now compresses faster (speed close to that of compress) + with degraded compression ratio (but still better than compress). + Default level changed to -6 (acts exactly as previous level -5) to + be a better indication of its placement in the speed/ratio range. +* Use smart name truncation: 123456789012.c -> 123456789.c.gz + instead of 12345678901.gz +* With --force, let zcat pass non gzip'ed data unchanged (zcat == cat) +* Added the zgrep shell script. +* Made sub.c useful for 16 bit sound, 24 bit images, etc.. +* Supress warnings about suffix for gunzip -r, except with --verbose. +* On MSDOS, use .gz extension when possible (files without extension) +* Moved the sample programs to a subdirectory sample. +* Added a "Special targets" section in INSTALL. + +Major changes from 1.1.1 to 1.1.2. +* Fix serious bug for VMS (-gz not removed when decompressing). +* Allow suffix other than .gz in znew. +* Do not display compression ratio when decompressing stdin. +* In zmore.in, work around brain damaged stty -g (Ultrix). +* Display a correct compression ratio for .Z files. +* Added .z to .gz renaming script in INTALL. +* Allow setting CFLAGS in configure. + +Major changes from 1.1 to 1.1.1. +* Fix serious bug in vms.c (affects Vax/VMS only). +* Added --ascii option. +* Add workaround in configure.in for Ultrix (quote eval argument) + +Major changes from 1.0.7 to 1.1. +* Use .gz suffix by default, add --suffix option. +* Let gunzip accept a "_z" suffix (used by one 'compress' on Vax/VMS). +* Quit when reading garbage from stdin instead of reporting an error. +* Added makefile for VAX/MMS and support for wildcards on VMS. +* Added support for MSC under OS/2. +* Added support for Prime/PRIMOS. +* Display compression ratio also when decompressing (with --verbose). +* Quit after --version (GNU standard) +* Use --force to bypass isatty() check +* Continue processing other files in case of recoverable error. +* Added comparison of zip and gzip in the readme file. +* Added small sample programs (ztouch, sub, add) +* Use less memory when compiled with -DSMALL_MEM (for MSDOS). +* Remove the "off by more than one minute" time stamp kludge + +Major changes from 1.0.6 to 1.0.7. +* Allow zmore to read from standard input (like more). +* Support the 68000 (Atari ST) in match.S. +* Retry partial writes (required on Linux when gzip is suspended in a pipe). +* Allow full pathnames and renamings in gzexe. +* Don't let gzexe compress setuid executables or gzip itself. +* Added vms/Makefile.gcc for gcc on the Vax. +* Allow installation of binaries and shell scripts in different dirs. +* Allows complex PAGER variable in zmore (e.g.: PAGER="col -x | more") +* Allow installation of zcat as gzcat. +* Several small changes for portability to old or weird systems. +* Suppress help message and send compressed data to the terminal when + gzip is invoked without parameters and without redirection. +* Add compile option GNU_STANDARD to respect the GNU coding standards: + with -DGNU_STANDARD, behave as gzip even if invoked under the name gunzip. +(I don't like the last two changes, which were requested by the FSF.) + +Major changes from 1.0.5 to 1.0.6. +* Let gzexe detect executables that are already gzexe'd. +* Keep file attributes in znew and gzexe if cpmod is available. +* Don't try restoring record format on VMS (1.0.5 did not work correctly) +* Added asm version for 68000 in amiga/match.a. + Use asm version for Atari TT and NeXT. +* For OS/2, assume HPFS by default, add flag OS2FAT if necessary. +* Fixed some bugs in zdiff and define zcmp as a link to zdiff. + + +Major changes from 1.0.4 to 1.0.5. +* For VMS, restore the file type for variable record format, otherwise + extract in fixed length format (not perfect, but better than + forcing all files to be in stream_LF format). +* For VMS, use "-z" default suffix and accept a version number in file names. +* For Unix, allow compression of files with name ending in 'z'. Use only + .z, .*-z, .tgz, .taz as valid gzip extensions. In the last two cases, + extract to .tar by default. +* On some versions of MSDOS, files with a 3 character extension could not + be compressed. +* Garbage collect files in /tmp created by gzexe. +* Fix the 'OS code' byte in the gzip header. +* For the Amiga, add the missing utime.h and add support for gcc. + + +Major changes from 1.0.3 to 1.0.4. +* Added optimized asm version for 68020. +* Add support for DJGPP. + +* Add support for the Atari ST. +* Added zforce to rename gzip'ed files with truncated names. +* Do not install with name uncompress (some systems rely on the + absence of any check in the old uncompress). +* Added missing function (fcfree) in msdos/tailor.c +* Let gunzip handle .tgz files, and let gzip skip them. +* Added -d option (decompress) for gzexe and try preserving file permissions. +* Suppress all warnings with -q. +* Use GZIP_OPT for VMS to avoid conflict with program name. +* ... and many other small changes (see ChangeLog) + + +Major changes from 1.0.2 to 1.0.3 +* Added -K option for znew to keep old .Z files if smaller +* Added -q option (quiet) to cancel -v in GZIP env variable. +* Made gzexe safer on systems with filename limitation to 14 chars. +* Fixed bugs in handling of GZIP env variable and incorrect free with Turbo C. + + +Major changes from 1.0.1 to 1.0.2 +* Added env variable GZIP for default options. Example: + for sh: GZIP="-8 -v"; export GZIP + for csh: setenv GZIP "-8 -v" +* Added support for the Amiga. +* znew now keeps the old .Z if it is smaller than the .z file. + This can happen for some large and very redundant files. +* Do not complain about trailing garbage for record oriented IO (Vax/VMS). + This implies however that multi-part gzip files are not supported + on such systems. +* Added gzexe to compress rarely used executables. +* Reduce memory usage (required for MSDOS and useful on all systems). +* Preserve time stamp in znew -P (pipe option) if touch -r works. + + +Major changes from 1.0 to 1.0.1 +* fix trivial errors in the Borland makefile (msdos/Makefile.bor) + + +Major changes from 0.8.2 to 1.0 +* gzip now runs on Vax/VMS +* gzip will not not overwrite files without -f when using /bin/sh in + background. +* Support the test option -t for compressed (.Z) files. + Allow some data recovery for bad .Z files. +* Added makefiles for MSDOS (Only tested for MSC, not Borland). +* still more changes to configure for several systems + + +Major changes from 0.8.1 to 0.8.2: +* yet more changes to configure for Linux and other systems +* Allow zcat on a file with multiple links. + + +Major changes from 0.8 to 0.8.1: +* znew has now a pipe option -P to reduce the disk space requirements, + but this option does not preserve timestamps. +* Fixed some #if directives for compilation with TurboC. + + +Major changes from 0.7 to 0.8: +* gzip can now extract .z files created by 'pack'. +* configure should no longer believe that every machine is a 386 +* Fix the entry for /etc/magic in INSTALL. +* Add patch for GNU tar 1.11.1 and a pointer to crypt++.el +* Uncompress files with multiple links only with -f. +* Fix for uncompress of .Z files on 16-bit machines +* Create a correct output name for file names of exactly N-1 chars when + the system has a limit of N chars. + + +Major changes from 0.6 to 0.7: +* Use "make check" instead of "make test". +* Keep time stamp and pass options to gzip in znew. +* Do not create .z.z files with gzip -r. +* Allow again gunzip .zip files (was working in 0.5) +* Allow again compilation with TurboC 2.0 (was working in 0.4) + + +Major changes form 0.5 to 0.6: +* gunzip reported an error when extracting certain .z files. The .z files + produced by gzip 0.5 are correct and can be read by gunzip 0.6. +* gunzip now supports multiple compressed members within a single .z file. +* Fix the check for i386 in configure. +* Added "make test" to check for compiler bugs. (gcc -finline-functions + is broken at least on the NeXT.) +* Use environment variable PAGER in zmore if it is defined. +* Accept gzcat in addition to zcat for people having /usr/bin before + /usr/local/bin in their path. diff --git a/tools/gzip-1.2.4/README b/tools/gzip-1.2.4/README new file mode 100644 index 00000000..fdd73114 --- /dev/null +++ b/tools/gzip-1.2.4/README @@ -0,0 +1,144 @@ +This is the file README for the gzip distribution, version 1.2.4. + +gzip (GNU zip) is a compression utility designed to be a replacement +for 'compress'. Its main advantages over compress are much better +compression and freedom from patented algorithms. The GNU Project +uses it as the standard compression program for its system. + +gzip currently uses by default the LZ77 algorithm used in zip 1.9 (the +portable pkzip compatible archiver). The gzip format was however +designed to accommodate several compression algorithms. See below +for a comparison of zip and gzip. + +gunzip can currently decompress files created by gzip, compress or +pack. The detection of the input format is automatic. For the +gzip format, gunzip checks a 32 bit CRC. For pack, gunzip checks the +uncompressed length. The 'compress' format was not designed to allow +consistency checks. However gunzip is sometimes able to detect a bad +.Z file because there is some redundancy in the .Z compression format. +If you get an error when uncompressing a .Z file, do not assume that +the .Z file is correct simply because the standard uncompress does not +complain. This generally means that the standard uncompress does not +check its input, and happily generates garbage output. + +gzip produces files with a .gz extension. Previous versions of gzip +used the .z extension, which was already used by the 'pack' +Huffman encoder. gunzip is able to decompress .z files (packed +or gzip'ed). + +Several planned features are not yet supported (see the file TODO). +See the file NEWS for a summary of changes since 0.5. See the file +INSTALL for installation instructions. Some answers to frequently +asked questions are given in the file INSTALL, please read it. (In +particular, please don't ask me once more for an /etc/magic entry.) + +WARNING: on several systems, compiler bugs cause gzip to fail, in +particular when optimization options are on. See the section "Special +targets" at the end of the INSTALL file for a list of known problems. +For all machines, use "make check" to check that gzip was compiled +correctly. Try compiling gzip without any optimization if you have a +problem. + +Please send all comments and bug reports by electronic mail to: + Jean-loup Gailly + +or, if this fails, to bug-gnu-utils@prep.ai.mit.edu. +Bug reports should ideally include: + + * The complete output of "gzip -V" (or the contents of revision.h + if you can't get gzip to compile) + * The hardware and operating system (try "uname -a") + * The compiler used to compile (if it is gcc, use "gcc -v") + * A description of the bug behavior + * The input to gzip, that triggered the bug + +If you send me patches for machines I don't have access to, please test them +very carefully. gzip is used for backups, it must be extremely reliable. + +The package crypt++.el is highly recommended to manipulate gzip'ed +file from emacs. It recognizes automatically encrypted and compressed +files when they are first visited or written. It is available via +anonymous ftp to roebling.poly.edu [128.238.5.31] in /pub/crypt++.el. +The same directory contains also patches to dired, ange-ftp and info. +GNU tar 1.11.2 has a -z option to invoke directly gzip, so you don't have to +patch it. The package ftp.uu.net:/languages/emacs-lisp/misc/jka-compr19.el.Z +also supports gzip'ed files. + +The znew and gzexe shell scripts provided with gzip benefit from +(but do not require) the cpmod utility to transfer file attributes. +It is available by anonymous ftp on gatekeeper.dec.com in +/.0/usenet/comp.sources.unix/volume11/cpmod.Z. + +The sample programs zread.c, sub.c and add.c in subdirectory sample +are provided as examples of useful complements to gzip. Read the +comments inside each source file. The perl script ztouch is also +provided as example (not installed by default since it relies on perl). + + +gzip is free software, you can redistribute it and/or modify it under +the terms of the GNU General Public License, a copy of which is +provided under the name COPYING. The latest version of gzip are always +available by ftp in prep.ai.mit.edu:/pub/gnu, or in any of the prep +mirror sites: + +- sources in gzip-*.tar (or .shar or .tar.gz). +- Solaris 2 executables in sparc-sun-solaris2/gzip-binaries-*.tar +- MSDOS lha self-extracting exe in gzip-msdos-*.exe. Once extracted, + copy gzip.exe to gunzip.exe and zcat.exe, or use "gzip -d" to decompress. + gzip386.exe runs much faster but only on 386 and above; it is compiled with + djgpp 1.10 available in directory omnigate.clarkson.edu:/pub/msdos/djgpp. + +A VMS executable is available in ftp.spc.edu:[.macro32.savesets]gzip-1-*.zip +(use [.macro32]unzip.exe to extract). A PRIMOS executable is available +in ftp.lysator.liu.se:/pub/primos/run/gzip.run. +OS/2 executables (16 and 32 bits versions) are available in +ftp.tu-muenchen.de:/pub/comp/os/os2/archiver/gz*-[16,32].zip + +Some ftp servers can automatically make a tar.Z from a tar file. If +you are getting gzip for the first time, you can ask for a tar.Z file +instead of the much larger tar file. + +Many thanks to those who provided me with bug reports and feedback. +See the files THANKS and ChangeLog for more details. + + + Note about zip vs. gzip: + +The name 'gzip' was a very unfortunate choice, because zip and gzip +are two really different programs, although the actual compression and +decompression sources were written by the same persons. A different +name should have been used for gzip, but it is too late to change now. + +zip is an archiver: it compresses several files into a single archive +file. gzip is a simple compressor: each file is compressed separately. +Both share the same compression and decompression code for the +'deflate' method. unzip can also decompress old zip archives +(implode, shrink and reduce methods). gunzip can also decompress files +created by compress and pack. zip 1.9 and gzip do not support +compression methods other than deflation. (zip 1.0 supports shrink and +implode). Better compression methods may be added in future versions +of gzip. zip will always stick to absolute compatibility with pkzip, +it is thus constrained by PKWare, which is a commercial company. The +gzip header format is deliberately different from that of pkzip to +avoid such a constraint. + +On Unix, gzip is mostly useful in combination with tar. GNU tar +1.11.2 has a -z option to invoke gzip automatically. "tar -z" +compresses better than zip, since gzip can then take advantage of +redundancy between distinct files. The drawback is that you must +scan the whole tar.gz file in order to extract a single file near +the end; unzip can directly seek to the end of the zip file. There +is no overhead when you extract the whole archive anyway. +If a member of a .zip archive is damaged, other files can still +be recovered. If a .tar.gz file is damaged, files beyond the failure +point cannot be recovered. (Future versions of gzip will have +error recovery features.) + +gzip and gunzip are distributed as a single program. zip and unzip +are, for historical reasons, two separate programs, although the +authors of these two programs work closely together in the info-zip +team. zip and unzip are not associated with the GNU project. +The sources are available by ftp in + + oak.oakland.edu:/pub/misc/unix/zip19p1.zip + oak.oakland.edu:/pub/misc/unix/unz50p1.tar-z diff --git a/tools/gzip-1.2.4/THANKS b/tools/gzip-1.2.4/THANKS new file mode 100644 index 00000000..6a545cb6 --- /dev/null +++ b/tools/gzip-1.2.4/THANKS @@ -0,0 +1,276 @@ +gzip was written by Jean-loup Gailly , with portions +written by Mark Adler (inflate.c), Peter Jannesen (unlzw.c) and +Haruhiko Okumura (unlzh.c). The zip deflate format was defined by Phil Katz. +Thanks to those who reported problems and suggested various +improvements. Here is a partial list of them: + +Robert Abramovitz bromo@cougar.tandem.com +Jay Adams jka@ece.cmu.edu +Mark Adler madler@cco.caltech.edu +Edwin Allum edwin@csri.toronto.edu +Joseph Arceneaux jla@gnu.ai.mit.edu +Tim Auckland tda10@cus.cam.ac.uk +Ken-ichiro Aoki aoki@madonna.physics.ucla.edu +David Ascher da@marlowe.cog.brown.edu +Eric Backus ericb@lsid.hp.com +Becky A. Badgett badgett@cs.utexas.edu +Bo Nygaard Bai bai@iesd.auc.dk +Dave Barber dbarber@apocalypse.bbn.com +Rene Beaulieu reneb@distri.hydro.qc.ca +Neal Becker neal@ctd.comsat.com +Dieter Becker becker@med-in.uni-sb.de +Nelson H. F. Beebe beebe@geronimo.math.utah.edu +Jeff Beadles jeff@onion.rain.com +David J. N. Begley dbegley@st.nepean.uws.edu.au +Bob Beresh rberesh@rd.hydro.on.ca +Jim Bernard jbernard@iola.mines.colorado.edu +Karl Berry karl@cs.umb.edu +James W. Birdsall jwbirdsa@picarefy.picarefy.com +Scott Bolte scott@craycos.com +Wayne E. Bouchard web@paladine.hacks.arizona.edu +Marc Boucher marc@cam.org +Ola Brahammar pt90ob@pt.hk-r.se +Dave Brennan brennan@hal.com +Alan Brown dogbowl@dogbox.acme.gen.nz +Michael L. Brown brown@wi.extrel.com +Rodney Brown rdb@mel.cocam.oz.au +Bruce bde@runx.oz.au +Bill Bumgarner bbum@stone.com +Leila Burrell-Davis leilabd@syma.sussex.ac.uk +Roger Butenuth butenuth@ira.uka.de +Jon Cargille jcargill@cs.wisc.edu +Bud Carlson bud@isle.pegasus.com +Lim Fung Chai fclim@i1sin.daq.semi.harris.com +Wes Chalfant wes@kofax.com +Andrew A. Chernov ache@astral.msk.su +Paul Close pdc@lunch.wpd.sgi.com +Jeff Coffler coffler@jac.enet.dec.com +Will Colley wcc3@occs.cs.oberlin.edu +Roger Cornelius sherpa!rac@uunet.uu.net +Kevin Cosgrove kevinc@tekig6.pen.tek.com +Stephen J Cowley s.j.cowley@amtp.cam.ac.uk +Ron Cox roncox@indirect.com +Frank Crawford frank@photon.ansto.gov.au +James R. Crawford qralston@cislabs.pitt.edu +Lawrence Crowl crowl@research.cs.orst.edu +Klaus Dahlenburg kdburg@incoahe.hanse.de +William E Davidsen davidsen@ariel.crd.ge.com +John M. DeDourek dedourek@aixive2.cs.unb.ca +Jeff Deifik jdeifik@isi.edu +Vince DeMarco vince@whatnxt.cuc.ab.ca +Michael De La Rue p91152@cplab.physics.edinburgh.ac.uk +Jeff Delinck delinck@pa621a.inland.com +John DeRoo deroo@grout.adv.shr.dec.com +Jim Diamond zsd@axe.drea.dnd.ca +Stefano Diomedi sd@teculx.tecsiel.it +Lawrence R. Dodd dodd@roebling.poly.edu +Matthew Donadio donadio@mxd120.rh.psu.edu +Andy Dougherty andy@crystal.phys.lafayette.edu +Darrell Duane dduane@mason1.gmu.edu +John Eaton jwe@che.utexas.edu +Will Edgington wedgingt@ptolemy.arc.nasa.gov +Brian Edmonds edmonds@edmonds.home.cs.ubc.ca +Paul Eggert eggert@twinsun.com +Enami enami@sys.ptg.sony.co.jp +Kristoffer Eriksson ske@pkmab.se +Daniel Eriksson m91der@bellatrix.tdb.uu.se +Rik Faith faith@cs.unc.edu +Larry Fahnoe fahnoe@c1mpls.mn.org +Cristian Ferretti cfs@poincare.mat.puc.cl +Karl-Jose Filler pla_jfi@pki-nbg.philips.de +Valery Fine fine@vxcern.cern.ch +Bob Fischer bobf@milne.geology.yale.edu +Per Foreby perf@efd.lth.se +Alexander Fraser alex@cs.umb.edu +Noah Friedman friedman@gnu.ai.mit.edu +Bob Friesenhahn bfriesen@iphase.com +Gerhard Friesland-Koepke frieslan@rzdspc3.informatik.uni-hamburg.de +Andy Fyfe andy@scp.caltech.edu +Geoff geoff@frs.faxon.com +Arnd Gerns gerns@informatik.uni-hildesheim.de +Kaveh R. Ghazi ghazi@staccato.rutgers.edu +Torbjorn Granlund tege@sics.se +Carl Greco cgreco@parrot.creighton.edu +Bruno Haible haible@ma2s2.mathematik.uni-karlsruhe.de +Junio Hamano junio@shadow.twinsun.com +Harald Hanche-Olsen hanche@ams.sunysb.edu +Darrel R. Hankerson hankedr@mail.auburn.edu +Mark Hanning-Lee markhl@romeo.caltech.edu +Lars Hecking st000002@hrz1.hrz.th-darmstadt.de +Ruediger Helsch ruediger@ramz.ing.tu-bs.de +Mark C. Henderson mch@sqwest.wimsey.bc.ca +Karl Heuer karl@kelp.boston.ma.us +Jarkko Hietaniemi jhi@dol-guldur.hut.fi +Thomas Hiller hiller@fzi.de +Eiji Hirai hirai@cc.swarthmore.edu +Kjetil Torgrim Homme kjetilho@ifi.uio.no +Robert D. Houk rdh@sli.com +Jim Howard jim_howard@mentorg.com +Preston Hunt gt5708a@prism.gatech.edu +Shane C Hutchins sch@nymph.msel.unh.edu +Hutch hutchinson@wrair-emh1.army.mil +Lester Ingber ingber@alumni.caltech.edu +Ken Ishii ishii@sni-usa.com +Per Steinar Iversen iversen@vsfys1.fi.uib.no +Chris Jacobsen jacobsen@xray1.physics.sunysb.edu +Michal Jaegermann ntomczak@vm.ucs.ualberta.ca +Brian Jones brianj@skat.usc.edu +Denny de Jonge witaddj@dutrex.tudelft.nl +Arne H. Juul arnej@lise.unit.no +Dana Jacobsen jacobsd@solar.cor2.epa.gov +Peter Jannesen peter@ncs.nl +Brian D. Johnston johnstonb@med.ge.com +Walter W. Jones wwj@candela.cfr.nist.gov +Tom Judson judson@scf.usc.edu +Henry G. Juengst juengst@saph2.physik.uni-bonn.de +Sarantos Kapidakis sarantos%manteion@ics.forth.gr +Amir J. Katz amir@matis.ingr.com +Steve Kelem kelem@castor.xilinx.com +Steven Kimball kimball@shrew.sanders.lockheed.com +Randy Kirchhof rkk@posms.aus.tx.us +Ned Kittlitz kittlitz@seagoon.sw.stratus.com +Sakai Kiyotaka ksakai@mtl.t.u-tokyo.ac.jp +Philip C Kizer pckizer@gonzo.tamu.edu +Pete Klammer pklammer@ouray.denver.colorado.edu +Fritz Kleemann kleemann@informatik.uni-wuerzburg.dbp.de +Wilhelm B. Kloke wb@ifado.arb-phys.uni-dortmund.de +Tom Kloos tk@sequent.com +Carsten Koch carsten.koch@icem.de +Winfried Koenig win@in.rhein-main.de +Mathias Koerber mathias@solomon.technet.sg +Steph Konigsdorfer s.konigsdorfer@frmy.bull.fr +Leif Kornstaedt leif@rumtifsl.ruessel.sub.org +Michael D. Lawler mdlawler@bsu-cs.bsu.edu +Kevin Layer layer@franz.com +Howard D. Leadmon howardl@wb3ffv.ampr.org +Alexander Lehmann alex@hal.rhein-main.de +Simon Leinen simon@lia.di.epfl.ch +Burt Leland burt@molecular.com +Tony Leneis tony@plaza.adp.ds.com +Hugues Leroy hugues.leroy@irisa.fr +Marty Leisner leisner@eso.mc.xerox.com +Charles Levert charles@aramis.comm.polymtl.ca +Richard Levitte levitte@e.kth.se +Torbj|rn Lindh toobii@elixir.e.kth.se +David R. Linn drl@vuse.vanderbilt.edu +Antonio Lioy cat@athena.polito.it +Jamie Lokier u90jl@ecs.oxford.ac.uk +Richard Lloyd R.K.Lloyd@csc.liv.ac.uk +David J. MacKenzie djm@eng.umd.edu +John R MacMillan john@chance.gts.org +Ron Male male@eso.mc.xerox.com +Don R. Maszle maze@bea.lbl.gov +Jaye Mathisen osyjm@cs.montana.edu +Telly Mavroidis mavroidi@acf2.nyu.edu +Imed Eddine Mbarki mbarki@pacific.cmpe.psu.edu +Steeve McCauley steeve@pooh.geophys.mcgill.ca +Tom McConnell tmcconne@sedona.intel.com +Tod McQuillin mcquill@ccit05.duq.edu +Tye McQueen tye@spillman.com +Bernd Melchers melchers@chemie.fu-berlin.de +Jason Merrill jason@jarthur.claremont.edu +Dean S. Messing deanm@medulla.labs.tek.com +M. Mesturino mesturino@cselt.stet.it +Luke Mewburn zak@rmit.edu.au +Jim Meyering meyering@cs.utexas.edu +Dragan Milicic milicic@math.utah.edu +Frederic Miserey none.fred@applelink.apple.com +Marcel J.E. Mol marcel@duteca.et.tudelft.nl +Soren Juul Moller sjm@dde.dk +Chris Moore moore@src.bae.co.uk +Dan Mosedale mosedale@genome.stanford.edu +Helmut Muelner hmuelner@fiicmds04.tu-graz.ac.at +Urban D Mueller umueller@amiga.physik.unizh.ch +Ulrich Mueller ulm@vsnhdb.cern.ch +Timothy Murphy tim@maths.tcd.ie +Greg Naber greg@squally.halcyon.com +Jay Nayegandhi jayng@bbiv02.enet.dec.com +Paul K. Neville II pkn2@idsi.com +Karl L. Noell noell@informatik.fh-wiesbaden.dbp.de +Demizu Noritoshi nori-d@is.aist-nara.ac.jp +Todd Ogasawara todd@protege.pegasus.com +Helge Oldach helge.oldach@stollmann.de +Arthur David Olson ado@elsie.nci.nih.gov +Piet van Oostrum piet@cs.ruu.nl +Rafael R. Pappalardo rafapa@obelix.cica.es +Mike Pearlman canuck@masc38.rice.edu +Yves Perrenoud pyves@nuga.alphanet.ch +Hal Peterson hrp@pecan.cray.com +Pascal Petit petit@cadillac.ibp.fr +Bruno Pillard bp@chorus.fr +Franc,ois Pinard pinard@iro.umontreal.ca +Jay Pinkos pinkos@butyng.bu.edu +Thomas Plass thomas@cogsci.ed.ac.uk +Mike Polo mikep@cfsmo.honeywell.com +Francesco Potorti pot@fly.cnuce.cnr.it +Will Priest bpriest@lobby.ti.com +David Purves purves@apogee.com +Andreas Raab ar@nvmr.robin.de +Eric S. Raymond esr@snark.thyrsus.com +Klaus Reimann kr@cip.physik.uni-stuttgart.de +Michael Rendell michael@mercury.cs.mun.ca +Hal Render render@massive.uccs.edu +Julian F. Reschke julian@math.uni-muenster.de +Phil Richards Phil.Richards@prg.oxford.ac.uk +Roland B Roberts roberts@nsrl31.nsrl.rochester.edu +Arnold Robbins arnold@cc.gatech.edu +Kevin Rodgers kevin@rolling-stone.den.mmc.com +Kai Uwe Rommel rommel@informatik.tu-muenchen.de +Paul Rubin phr@america.telebit.com +Wolfgang Rupprecht wolfgang@wsrcc.com +Jonathan Ryshpan jon@amito.hitachi.com +Paul A Sand pas@unh.edu +Tony Sanders sanders@bsdi.com +Mike Sangrey mike@sojurn.lns.pa.us +Niimi Satoshi a01309@cfi.waseda.ac.jp +Marc Schaefer sysadm@alphanet.ch +Andreas Schwab schwab@lamothe.informatik.uni-dortmund.de +Eric Schenk schenk@cs.toronto.edu +Eric P. Scott eps@cs.sfsu.edu +Olaf Seibert rhialto@mbfys.kun.nl +Sunando Sen sens@fasecon.econ.nyu.edu +Harry Shamansky hts@hertz.eng.ohio-state.edu +Amos Shapira amoss@cs.huji.ac.il +Rick Sladkey jrs@world.std.com +Daniel L Smith dls@autodesk.com +Fred Smith fredex%fcshome@merk.merk.com +Stephen Soliday soliday@ncat.edu +Paul Southworth pauls@css.itd.umich.edu +Rob Spencer robbie@winkle.bhpese.oz.au +Richard Stallman rms@gnu.ai.mit.edu +Carsten Steger carsten.steger@informatik.tu-muenchen.de +David Sundstrom sunds@anon.asic.sc.ti.com +Ed Sznyter ews@babel.babel.com +Hideaki Tanabe arctanx@iyeyasu.ynl.t.u-tokyo.ac.jp +Andrew Telford ajt@peregrin.resmel.bhp.com.au +Glenn E. Thobe thobe@getunx.info.com +Kei Thomsen kt@keihh.hanse.de +Karsten Thygesen karthy@dannug.dk +Mark Towfiq towfiq@microdyne.com +Jeff Treece treece@sabbagh.com +Oliver Trepte oliver@ikaros.fysik4.kth.se +Stephane Tsacas slt@is21.isoft.fr +Stephen Tweedie sct@dcs.ed.ac.uk +John R. Vanderpool fish@daacdev1.stx.com +Sotiris Vassilopoulos vassilopoulos@virginia.edu +Pedro A. M. Vazquez vazquez@iqm.unicamp.br +Arjan de Vet devet@win.tue.nl +Larry W. Virden lvirden@cas.org +Vadim V. Vlasov vvlasov@inucres.msk.su +Eduard Vopicka eduard.vopicka@vse.cs +Theo Vosse vosse@ruls41.leidenuniv.nl +Darin Wayrynen darin@pcg.uucp +Marcel Waldvogel marcel@nice.usergroup.ethz.ch +Stephen J. Walick steve@nshore.org +Gray Watson gray@antaire.com +David Watt dmwatt@smersh.cambridge.ma.us +Scott Weikart scott@igc.apc.org +Ivo Welch iwelch@agsm.ucla.edu +Jochen Wiedmann zrawi01@zmcipdec1.zdv.uni-tuebingen.de +Gijsb. Wiesenekker wiesenecker@sara.nl +Wietze van Winden wietze@swi.psy.uva.nl +Frank Wuebbeling wuebbel@math.uni-muenster.de +Larry W. Virden lwv26@cas.org +Bill Wohler wohler@sap-ag.de +Jamie Zawinski jwz@lucid.com +Christos Zoulas christos@deshaw.com diff --git a/tools/gzip-1.2.4/TODO b/tools/gzip-1.2.4/TODO new file mode 100644 index 00000000..865be925 --- /dev/null +++ b/tools/gzip-1.2.4/TODO @@ -0,0 +1,58 @@ +TODO file for gzip. + +Some of the planned features include: + +- Structure the sources so that the compression and decompression code + form a library usable by any program, and write both gzip and zip on + top of this library. This would ideally be a reentrant (thread safe) + library, but this would degrade performance. In the meantime, you can + look at the sample program zread.c. + + The library should have one mode in which compressed data is sent + as soon as input is available, instead of waiting for complete + blocks. This can be useful for sending compressed data to/from interactive + programs. + +- Make it convenient to define alternative user interfaces (in + particular for windowing environments). + +- Support in-memory compression for arbitrarily large amounts of data + (zip currently supports in-memory compression only for a single buffer.) + +- Map files in memory when possible, this is generally much faster + than read/write. (zip currently maps entire files at once, this + should be done in chunks to reduce memory usage.) + +- Add a super-fast compression method, suitable for implementing + file systems with transparent compression. One problem is that the + best candidate (lzrw1) is patented twice (Waterworth 4,701,745 + and Gibson & Graybill 5,049,881). The lzrw series of algorithms + are available by ftp in ftp.adelaide.edu.au:/pub/compression/lzrw*. + +- Add a super-tight (but slow) compression method, suitable for long + term archives. One problem is that the best versions of arithmetic + coding are patented (4,286,256 4,295,125 4,463,342 4,467,317 + 4,633,490 4,652,856 4,891,643 4,905,297 4,935,882 4,973,961 + 5,023,611 5,025,258). + + Note: I will introduce new compression methods only if they are + significantly better in either speed or compression ratio than the + existing method(s). So the total number of different methods should + reasonably not exceed 3. (The current 9 compression levels are just + tuning parameters for a single method, deflation.) + +- Add optional error correction. One problem is that the current version + of ecc cannot recover from inserted or missing bytes. It would be + nice to recover from the most common error (transfer of a binary + file in ascii mode). + +- Add a block size (-b) option to improve error recovery in case of + failure of a complete sector. Each block could be extracted + independently, but this reduces the compression ratio. + +- Use a larger window size to deal with some large redundant files that + 'compress' currently handles better than gzip. + +- Implement the -e (encrypt) option. + +Send comments to Jean-loup Gailly . diff --git a/tools/gzip-1.2.4/algorithm.doc b/tools/gzip-1.2.4/algorithm.doc new file mode 100644 index 00000000..15b09e70 --- /dev/null +++ b/tools/gzip-1.2.4/algorithm.doc @@ -0,0 +1,164 @@ +1. Algorithm + +The deflation algorithm used by zip and gzip is a variation of LZ77 +(Lempel-Ziv 1977, see reference below). It finds duplicated strings in +the input data. The second occurrence of a string is replaced by a +pointer to the previous string, in the form of a pair (distance, +length). Distances are limited to 32K bytes, and lengths are limited +to 258 bytes. When a string does not occur anywhere in the previous +32K bytes, it is emitted as a sequence of literal bytes. (In this +description, 'string' must be taken as an arbitrary sequence of bytes, +and is not restricted to printable characters.) + +Literals or match lengths are compressed with one Huffman tree, and +match distances are compressed with another tree. The trees are stored +in a compact form at the start of each block. The blocks can have any +size (except that the compressed data for one block must fit in +available memory). A block is terminated when zip determines that it +would be useful to start another block with fresh trees. (This is +somewhat similar to compress.) + +Duplicated strings are found using a hash table. All input strings of +length 3 are inserted in the hash table. A hash index is computed for +the next 3 bytes. If the hash chain for this index is not empty, all +strings in the chain are compared with the current input string, and +the longest match is selected. + +The hash chains are searched starting with the most recent strings, to +favor small distances and thus take advantage of the Huffman encoding. +The hash chains are singly linked. There are no deletions from the +hash chains, the algorithm simply discards matches that are too old. + +To avoid a worst-case situation, very long hash chains are arbitrarily +truncated at a certain length, determined by a runtime option (zip -1 +to -9). So zip does not always find the longest possible match but +generally finds a match which is long enough. + +zip also defers the selection of matches with a lazy evaluation +mechanism. After a match of length N has been found, zip searches for a +longer match at the next input byte. If a longer match is found, the +previous match is truncated to a length of one (thus producing a single +literal byte) and the longer match is emitted afterwards. Otherwise, +the original match is kept, and the next match search is attempted only +N steps later. + +The lazy match evaluation is also subject to a runtime parameter. If +the current match is long enough, zip reduces the search for a longer +match, thus speeding up the whole process. If compression ratio is more +important than speed, zip attempts a complete second search even if +the first match is already long enough. + +The lazy match evaluation is no performed for the fastest compression +modes (speed options -1 to -3). For these fast modes, new strings +are inserted in the hash table only when no match was found, or +when the match is not too long. This degrades the compression ratio +but saves time since there are both fewer insertions and fewer searches. + + +2. gzip file format + +The pkzip format imposes a lot of overhead in various headers, which +are useful for an archiver but not necessary when only one file is +compressed. gzip uses a much simpler structure. Numbers are in little +endian format, and bit 0 is the least significant bit. +A gzip file is a sequence of compressed members. Each member has the +following structure: + +2 bytes magic header 0x1f, 0x8b (\037 \213) +1 byte compression method (0..7 reserved, 8 = deflate) +1 byte flags + bit 0 set: file probably ascii text + bit 1 set: continuation of multi-part gzip file + bit 2 set: extra field present + bit 3 set: original file name present + bit 4 set: file comment present + bit 5 set: file is encrypted + bit 6,7: reserved +4 bytes file modification time in Unix format +1 byte extra flags (depend on compression method) +1 byte operating system on which compression took place + +2 bytes optional part number (second part=1) +2 bytes optional extra field length +? bytes optional extra field +? bytes optional original file name, zero terminated +? bytes optional file comment, zero terminated +12 bytes optional encryption header +? bytes compressed data +4 bytes crc32 +4 bytes uncompressed input size modulo 2^32 + +The format was designed to allow single pass compression without any +backwards seek, and without a priori knowledge of the uncompressed +input size or the available size on the output media. If input does +not come from a regular disk file, the file modification time is set +to the time at which compression started. + +The time stamp is useful mainly when one gzip file is transferred over +a network. In this case it would not help to keep ownership +attributes. In the local case, the ownership attributes are preserved +by gzip when compressing/decompressing the file. A time stamp of zero +is ignored. + +Bit 0 in the flags is only an optional indication, which can be set by +a small lookahead in the input data. In case of doubt, the flag is +cleared indicating binary data. For systems which have different +file formats for ascii text and binary data, the decompressor can +use the flag to choose the appropriate format. + +The extra field, if present, must consist of one or more subfields, +each with the following format: + + subfield id : 2 bytes + subfield size : 2 bytes (little-endian format) + subfield data + +The subfield id can consist of two letters with some mnemonic value. +Please send any such id to jloup@chorus.fr. Ids with a zero second +byte are reserved for future use. The following ids are defined: + + Ap (0x41, 0x70) : Apollo file type information + +The subfield size is the size of the subfield data and does not +include the id and the size itself. The field 'extra field length' is +the total size of the extra field, including subfield ids and sizes. + +It must be possible to detect the end of the compressed data with any +compression format, regardless of the actual size of the compressed +data. If the compressed data cannot fit in one file (in particular for +diskettes), each part starts with a header as described above, but +only the last part has the crc32 and uncompressed size. A decompressor +may prompt for additional data for multipart compressed files. It is +desirable but not mandatory that multiple parts be extractable +independently so that partial data can be recovered if one of the +parts is damaged. This is possible only if no compression state is +kept from one part to the other. The compression-type dependent flags +can indicate this. + +If the file being compressed is on a file system with case insensitive +names, the original name field must be forced to lower case. There is +no original file name if the data was compressed from standard input. + +Compression is always performed, even if the compressed file is +slightly larger than the original. The worst case expansion is +a few bytes for the gzip file header, plus 5 bytes every 32K block, +or an expansion ratio of 0.015% for large files. Note that the actual +number of used disk blocks almost never increases. + +The encryption is that of zip 1.9. For the encryption check, the +last byte of the decoded encryption header must be zero. The time +stamp of an encrypted file might be set to zero to avoid giving a clue +about the construction of the random header. + +Jean-loup Gailly +jloup@chorus.fr + +References: + +[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data +Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3, +pp. 337-343. + +APPNOTE.TXT documentation file in PKZIP 1.93a. It is available by +ftp in ftp.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59] +Use "unzip pkz193a.exe APPNOTE.TXT" to extract (note: unzip, not gunzip). diff --git a/tools/gzip-1.2.4/amiga/Makefile.gcc b/tools/gzip-1.2.4/amiga/Makefile.gcc new file mode 100644 index 00000000..98635c1a --- /dev/null +++ b/tools/gzip-1.2.4/amiga/Makefile.gcc @@ -0,0 +1,62 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation + +# Amiga GCC version, written by Preston Hunt + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +CC = gcc +CPP = cpp + +CFLAGS = -m68020 -m68881 -O2 +#CFLAGS = -m68000 -O2 +#for the 68000, set below: OBJA= +CPPFLAGS = -Dmc68020 +LDFLAGS = +O = .o + +SRCS = gzip.c zip.c deflate.c trees.c bits.c unzip.c inflate.c util.c crypt.c\ + lzw.c unlzw.c unpack.c unlzh.c makecrc.c getopt.c match.S + +OBJA = match$O + +OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \ + crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O match$O + +HDRS = gzip.h lzw.h tailor.h revision.h crypt.h getopt.h + +.c.o: + $(CC) -c $(DEFS) $(CFLAGS) $< + +.PHONY: default all +all: gzip + +gzip: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +gzip$O getopt$O: getopt.h + +match$O: match.S + $(CPP) $(CPPFLAGS) match.S > _match.s + $(CC) -c _match.s + mv _match$O match$O + rm -f _match.s diff --git a/tools/gzip-1.2.4/amiga/Makefile.sasc b/tools/gzip-1.2.4/amiga/Makefile.sasc new file mode 100644 index 00000000..faf15fd3 --- /dev/null +++ b/tools/gzip-1.2.4/amiga/Makefile.sasc @@ -0,0 +1,59 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# This Makefile is for SAS/C 6.3 on the Amiga +# Don't use it with SAS/C 6.2 or earlier versions. These versions will +# produce incorrect code for trees.c because of a bug in the optimizer. +# Made by Carsten Steger (carsten.steger@informatik.tu-muenchen.de) + +# Some notes on gzip for the Amiga: +# Due to a strange implementation of the RAM-Disk on Commodore's part +# you should not use gzip -r on a directory in the RAM-Disk. To zip all +# files in a directory 'dir' in the RAM-Disk use something like +# gzip ram:dir/#? ram:dir/#?/#? ... +# where the number of '#?'s reflects the depth of the directory 'dir'. +# +# Alas, the program has it's full functionality only if you have +# Kickstart 2.0 or higher installed. This affects the expansion of +# wildcards and the preservation of file access times. You should use +# a shell that does wildcard expansion under Kickstart 1.3. + + +CC = sc + +# If you have a 68020 or more you can define UNALIGNED_OK below +DEFS = DEF=AMIGA +LIBS = LIB LIB:scnb.lib + +CFLAGS = DATA=FAR NOSTKCHK PARM=R IDIR= +OPTFLAGS = OPT OPTGO OPTPEEP OPTCOMP=3 OPTDEP=3 OPTRDEP=3 +LDFLAGS = FROM LIB:c.o + +OBJS = gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o util.o \ + crypt.o lzw.o unlzw.o unpack.o unlzh.o getopt.o tailor.o match.o + +.c.o: + $(CC) $(DEFS) $(CFLAGS) $(OPTFLAGS) $< +.a.o: + $(CC) $(DEFS) $(CFLAGS) $< + +all: gzip + +gzip: $(OBJS) + slink $(LDFLAGS) $(OBJS) TO $@ $(LIBS) + +gzip.o: gzip.c gzip.h tailor.h revision.h lzw.h getopt.h +zip.o: zip.c gzip.h tailor.h crypt.h +deflate.o: deflate.c gzip.h tailor.h lzw.h +trees.o: trees.c gzip.h tailor.h +bits.o: bits.c gzip.h tailor.h crypt.h +unzip.o: unzip.c gzip.h tailor.h crypt.h +inflate.o: inflate.c gzip.h tailor.h +util.o: util.c gzip.h tailor.h crypt.h +lzw.o: lzw.c lzw.h gzip.h tailor.h +unlzw.o: unlzw.c gzip.h tailor.h lzw.h +unpack.o: unpack.c gzip.h tailor.h crypt.h +unlzh.o: unlzh.c gzip.h tailor.h lzw.h +crypt.o: crypt.c +getopt.o: getopt.c getopt.h +tailor.o: tailor.c + +match.o: match.a diff --git a/tools/gzip-1.2.4/amiga/tailor.c b/tools/gzip-1.2.4/amiga/tailor.c new file mode 100644 index 00000000..9f14cc45 --- /dev/null +++ b/tools/gzip-1.2.4/amiga/tailor.c @@ -0,0 +1,183 @@ +/* tailor.c -- target dependent functions + * Copyright (C) 1993 Carsten Steger (carsten.steger@informatik.tu-muenchen.de) + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* + * This file contains Amiga specific functions for gzip. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXPATH 1024 +#define MAXARGS 512 + +extern struct DosLibrary *DOSBase; + +extern void *xmalloc(unsigned int size); + +static char *expand_next_file (char *pattern); +static int in_prev_args (char *arg, char **argv, int argc); +extern void _expand_args (int *oargc, char ***oargv); + + +static char *expand_next_file (pattern) + char *pattern; +{ + long err; + char *pathname; + static struct AnchorPath *an = NULL; + + pathname = NULL; + if (pattern == NULL) + err = -1; + else + do + { + if (an == NULL) + { + an = xmalloc (sizeof (struct AnchorPath) + MAXPATH); + memset (an, 0, sizeof (struct AnchorPath) + MAXPATH); + an->ap_BreakBits = SIGBREAKF_CTRL_C; + an->ap_Strlen = MAXPATH; + an->ap_Flags = APF_DOWILD; + err = MatchFirst (pattern, an); + } + else + err = MatchNext (an); + + pathname = an->ap_Buf; + } while (err == 0 && pathname == NULL); + + if (err) + { + MatchEnd (an); + free (an); + an = NULL; + return NULL; + } + else + return pathname; +} + + +static int in_prev_args (arg, argv, argc) + char *arg, **argv; + int argc; +{ + int i, is_in_args; + + is_in_args = 0; + for (i = 1; i < argc - 1; i++) + if (stricmp (arg, argv[i]) == 0) + is_in_args = 1; + return is_in_args; +} + + +void _expand_args (oargc, oargv) + int *oargc; + char ***oargv; +{ + int i; + char *str, **argv; + static char buf[MAXPATH]; + int argc, no_match_at_all, num_matches, contains_wildcards; + + /* With Kickstart 1.3 wildcards can't be expanded. */ + if (DOSBase->dl_lib.lib_Version < 37) return; + + no_match_at_all = 1; + contains_wildcards = 0; + argc = 0; + argv = xmalloc (MAXARGS * sizeof (char *)); + + argv[argc++] = (*oargv)[0]; + for (i = 1; i < *oargc; i++) + { + if (ParsePattern ((*oargv)[i], buf, MAXPATH)) + { + contains_wildcards = 1; + num_matches = 0; + while (str = expand_next_file ((*oargv)[i])) + if (argc >= MAXARGS) + { + expand_next_file (NULL); + fprintf (stderr,"Too many files.\n"); + exit (20); + } + else + { + /* Avoid duplicate entries */ + if (!in_prev_args (str, argv, argc)) + { + argv[argc++] = strdup (str); + num_matches++; + } + } + if (num_matches != 0) + no_match_at_all = 0; + } + else + if (argc >= MAXARGS) + { + fprintf (stderr,"Too many files.\n"); + exit (20); + } + else + { + if (!in_prev_args ((*oargv)[i], argv, argc)) + argv[argc++] = (*oargv)[i]; + } + } + *oargc = argc; + *oargv = argv; + if (no_match_at_all && contains_wildcards) { + fprintf (stderr,"No match.\n"); + exit (20); + } +} + + +int utime (path, times) + char *path; + struct utimbuf *times; +{ + struct DateStamp date; + LONG error; + time_t modtime; + + /* With Kickstart 1.3 setting the filedate could be done, I guess. + * Maybe someone else will implement and test the code for this + * case (I don't have Kickstart 1.3). */ + if (DOSBase->dl_lib.lib_Version < 37) return 0; + + /* Amiga dates are counted from 1. Jan 1978 as opposed to 1. Jan 1970 + * on Unix. Therefore we have to subtract 2922 days (8*365+2). We also + * have to subtract the value of __timezone since SAS/C uses "CST+06" + * as the default value. */ + modtime = times->modtime - __timezone; + date.ds_Days = (modtime / 86400) - 2922; + modtime %= 86400; + date.ds_Minute = modtime / 60; + modtime %= 60; + date.ds_Tick = modtime * TICKS_PER_SECOND; + error = SetFileDate (path, &date); + if (error == DOSFALSE) + { + errno = EOSERR; + return -1; + } + return 0; +} diff --git a/tools/gzip-1.2.4/amiga/utime.h b/tools/gzip-1.2.4/amiga/utime.h new file mode 100644 index 00000000..8c35a1aa --- /dev/null +++ b/tools/gzip-1.2.4/amiga/utime.h @@ -0,0 +1,15 @@ +#ifndef _UTIME_H +#define _UTIME_H 1 + +#ifndef _TIME_H +#include +#endif + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +extern int utime (char *path, struct utimbuf *times); + +#endif diff --git a/tools/gzip-1.2.4/atari/Makefile.st b/tools/gzip-1.2.4/atari/Makefile.st new file mode 100644 index 00000000..c32fe9a4 --- /dev/null +++ b/tools/gzip-1.2.4/atari/Makefile.st @@ -0,0 +1,48 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# This is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License, see the file COPYING. + +# Simple Atari-specific makefile for gcc. +# Written by Daniel Eriksson +# Modified by Andreas Schwab +# and Robert Fischer . + +# This Makefile is configured by default for the Atari ST using the +# Minix filesytem. It can be modified (for efficiency) for an Atari TT +# according to the instructions given below. It must be modified +# for building a TOS-filesystem version. + +CC=gcc +BASIC_FLAGS = -O2 -DATARI + +# Use this for a TT-only version +#TT_FLAGS = -m68020 + +# CFLAGS for building a Minix-filesystem version +CFLAGS = $(BASIC_FLAGS) $(TT_FLAGS) + +# CFLAGS for building a TOS-filesystem version +#CFLAGS = $(BASIC_FLAGS) $(TT_FLAGS) -DTOSFS + +AS=$(CC) -c +ASFLAGS = $(CFLAGS) +LDFLAGS = + +OBJA = match.o +OBJS = bits.o crypt.o deflate.o getopt.o gzip.o inflate.o lzw.o \ + trees.o unlzw.o unpack.o unlzh.o unzip.o util.o zip.o $(OBJA) + +gzip.ttp: $(OBJS) + $(CC) $(LDFLAGS) -o gzip.ttp $(OBJS) + +gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o: gzip.h tailor.h +util.o lzw.o unlzw.o unpack.o unlzh.o crypt.o: gzip.h tailor.h + +gzip.o unlzw.o: revision.h lzw.h + +bits.o unzip.o util.o zip.o: crypt.h + +gzip.o getopt.o: getopt.h + +match.o: match.S + $(AS) $(ASLAGS) match.S diff --git a/tools/gzip-1.2.4/bits.c b/tools/gzip-1.2.4/bits.c new file mode 100644 index 00000000..544d6da9 --- /dev/null +++ b/tools/gzip-1.2.4/bits.c @@ -0,0 +1,205 @@ +/* bits.c -- output variable-length bit strings + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + + +/* + * PURPOSE + * + * Output variable-length bit strings. Compression can be done + * to a file or to memory. (The latter is not supported in this version.) + * + * DISCUSSION + * + * The PKZIP "deflate" file format interprets compressed file data + * as a sequence of bits. Multi-bit strings in the file may cross + * byte boundaries without restriction. + * + * The first bit of each byte is the low-order bit. + * + * The routines in this file allow a variable-length bit value to + * be output right-to-left (useful for literal values). For + * left-to-right output (useful for code strings from the tree routines), + * the bits must have been reversed first with bi_reverse(). + * + * For in-memory compression, the compressed bit stream goes directly + * into the requested output buffer. The input data is read in blocks + * by the mem_read() function. The buffer is limited to 64K on 16 bit + * machines. + * + * INTERFACE + * + * void bi_init (FILE *zipfile) + * Initialize the bit string routines. + * + * void send_bits (int value, int length) + * Write out a bit string, taking the source bits right to + * left. + * + * int bi_reverse (int value, int length) + * Reverse the bits of a bit string, taking the source bits left to + * right and emitting them right to left. + * + * void bi_windup (void) + * Write out any remaining bits in an incomplete byte. + * + * void copy_block(char *buf, unsigned len, int header) + * Copy a stored block to the zip file, storing first the length and + * its one's complement if requested. + * + */ + +#include "tailor.h" +#include "gzip.h" +#include "crypt.h" + +#ifdef DEBUG +# include +#endif + +#ifdef RCSID +static char rcsid[] = "$Id: bits.c,v 0.9 1993/06/11 10:16:58 jloup Exp $"; +#endif + +/* =========================================================================== + * Local data used by the "bit string" routines. + */ + +local file_t zfile; /* output gzip file */ + +local unsigned short bi_buf; +/* Output buffer. bits are inserted starting at the bottom (least significant + * bits). + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +local int bi_valid; +/* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + +int (*read_buf) OF((char *buf, unsigned size)); +/* Current input function. Set to mem_read for in-memory compression */ + +#ifdef DEBUG + ulg bits_sent; /* bit length of the compressed data */ +#endif + +/* =========================================================================== + * Initialize the bit string routines. + */ +void bi_init (zipfile) + file_t zipfile; /* output zip file, NO_FILE for in-memory compression */ +{ + zfile = zipfile; + bi_buf = 0; + bi_valid = 0; +#ifdef DEBUG + bits_sent = 0L; +#endif + + /* Set the defaults for file compression. They are set by memcompress + * for in-memory compression. + */ + if (zfile != NO_FILE) { + read_buf = file_read; + } +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +void send_bits(value, length) + int value; /* value to send */ + int length; /* number of bits */ +{ +#ifdef DEBUG + Tracev((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + bits_sent += (ulg)length; +#endif + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (bi_valid > (int)Buf_size - length) { + bi_buf |= (value << bi_valid); + put_short(bi_buf); + bi_buf = (ush)value >> (Buf_size - bi_valid); + bi_valid += length - Buf_size; + } else { + bi_buf |= value << bi_valid; + bi_valid += length; + } +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Write out any remaining bits in an incomplete byte. + */ +void bi_windup() +{ + if (bi_valid > 8) { + put_short(bi_buf); + } else if (bi_valid > 0) { + put_byte(bi_buf); + } + bi_buf = 0; + bi_valid = 0; +#ifdef DEBUG + bits_sent = (bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block to the zip file, storing first the length and its + * one's complement if requested. + */ +void copy_block(buf, len, header) + char *buf; /* the input data */ + unsigned len; /* its length */ + int header; /* true if block header must be written */ +{ + bi_windup(); /* align on byte boundary */ + + if (header) { + put_short((ush)len); + put_short((ush)~len); +#ifdef DEBUG + bits_sent += 2*16; +#endif + } +#ifdef DEBUG + bits_sent += (ulg)len<<3; +#endif + while (len--) { +#ifdef CRYPT + int t; + if (key) zencode(*buf, t); +#endif + put_byte(*buf++); + } +} diff --git a/tools/gzip-1.2.4/config.status b/tools/gzip-1.2.4/config.status new file mode 100755 index 00000000..ecddee0b --- /dev/null +++ b/tools/gzip-1.2.4/config.status @@ -0,0 +1,72 @@ +#!/bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host Mittenz: +# +# ./configure dummy gcc + +for arg +do + case "$arg" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + exec /bin/sh ./configure dummy gcc ;; + *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; + esac +done + +trap 'rm -f Makefile; exit 1' 1 3 15 +CC='gcc' +CPP='${CC-cc} -E' +INSTALL='/usr/bin/install -c' +INSTALL_PROGRAM='$(INSTALL)' +INSTALL_DATA='$(INSTALL) -m 644' +ZCAT='zcat' +G='' +CFLAGS='-O' +ASCPP='/lib/cpp -DNO_UNDERLINE' +OBJA='' +SEDCMD='' +LIBS='' +srcdir='.' +DEFS=' -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DDIRENT=1' +prefix='' +exec_prefix='' +prsub='' + +top_srcdir=$srcdir + +# Allow make-time overrides of the generated file list. +test -n "$gen_files" || gen_files="Makefile" + +for file in .. $gen_files; do if [ "x$file" != "x.." ]; then + srcdir=$top_srcdir + # Remove last slash and all that follows it. Not all systems have dirname. + dir=`echo $file|sed 's%/[^/][^/]*$%%'` + if test "$dir" != "$file"; then + test "$top_srcdir" != . && srcdir=$top_srcdir/$dir + test ! -d $dir && mkdir $dir + fi + echo creating $file + rm -f $file + echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file + sed -e " +$prsub +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@INSTALL@%$INSTALL%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@ZCAT@%$ZCAT%g +s%@G@%$G%g +s%@CFLAGS@%$CFLAGS%g +s%@ASCPP@%$ASCPP%g +s%@OBJA@%$OBJA%g +s%@SEDCMD@%$SEDCMD%g +s%@LIBS@%$LIBS%g +s%@srcdir@%$srcdir%g +s%@DEFS@%$DEFS% +" $top_srcdir/${file}.in >> $file +fi; done + +exit 0 diff --git a/tools/gzip-1.2.4/configure b/tools/gzip-1.2.4/configure new file mode 100755 index 00000000..df9eab36 --- /dev/null +++ b/tools/gzip-1.2.4/configure @@ -0,0 +1,826 @@ +#!/bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf. +# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create] +# [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET] +# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and +# --with-PACKAGE unless this script has special code to handle it. + + +for arg +do + # Handle --exec-prefix with a space before the argument. + if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix= + # Handle --host with a space before the argument. + elif test x$next_host = xyes; then next_host= + # Handle --prefix with a space before the argument. + elif test x$next_prefix = xyes; then prefix=$arg; next_prefix= + # Handle --srcdir with a space before the argument. + elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir= + else + case $arg in + # For backward compatibility, also recognize exact --exec_prefix. + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*) + exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e) + next_exec_prefix=yes ;; + + -gas | --gas | --ga | --g) ;; + + -host=* | --host=* | --hos=* | --ho=* | --h=*) ;; + -host | --host | --hos | --ho | --h) + next_host=yes ;; + + -nfp | --nfp | --nf) ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no) + no_create=1 ;; + + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + next_prefix=yes ;; + + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*) + srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s) + next_srcdir=yes ;; + + -with-* | --with-*) + package=`echo $arg|sed 's/-*with-//'` + # Delete all the valid chars; see if any are left. + if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then + echo "configure: $package: invalid package name" >&2; exit 1 + fi + eval "with_`echo $package|sed s/-/_/g`=1" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb | --ver | --ve | --v) + verbose=yes ;; + + *) ;; + esac + fi +done + +trap 'rm -f conftest* core; exit 1' 1 3 15 + +# Needed for some versions of `tr' so that character classes in `[]' work. +if test "${LANG+set}" = "set" ; then + LANG=C + LC_ALL=C + export LANG LC_ALL +fi + +rm -f conftest* +compile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1' + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +unique_file=gzip.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + srcdirdefaulted=yes + # Try the directory containing this script, then `..'. + prog=$0 + confdir=`echo $prog|sed 's%/[^/][^/]*$%%'` + test "X$confdir" = "X$prog" && confdir=. + srcdir=$confdir + if test ! -r $srcdir/$unique_file; then + srcdir=.. + fi +fi +if test ! -r $srcdir/$unique_file; then + if test x$srcdirdefaulted = xyes; then + echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2 + else + echo "configure: Can not find sources in \`${srcdir}'." 1>&2 + fi + exit 1 +fi +# Preserve a srcdir of `.' to avoid automounter screwups with pwd. +# But we can't avoid them for `..', to make subdirectories work. +case $srcdir in + .|/*|~*) ;; + *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute. +esac + +if test -z "$CC"; then + # Extract the first word of `gcc', so it can be a program name with args. + set dummy gcc; word=$2 + echo checking for $word + IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/$word; then + CC="gcc" + break + fi + done + IFS="$saveifs" +fi +test -z "$CC" && CC="cc" +test -n "$CC" -a -n "$verbose" && echo " setting CC to $CC" + +# Find out if we are using GNU C, under whatever name. +cat > conftest.c < conftest.out 2>&1 +if egrep yes conftest.out >/dev/null 2>&1; then + GCC=1 # For later tests. + CFLAGS="${CFLAGS--O}" +fi +rm -f conftest* + +echo checking how to run the C preprocessor +if test -z "$CPP"; then + CPP='${CC-cc} -E' + cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + : +else + CPP=/lib/cpp +fi +rm -f conftest* +fi + +echo checking for underline in external names +test -z "$ASCPP" -a -f /lib/cpp && ASCPP=/lib/cpp +test -z "$ASCPP" && ASCPP="$CC -E" +cat > conftest.c < /dev/null 2>&1" +if nm conftest.o | grep _foo > /dev/null 2>&1 ; then + : +else + ASCPP="${ASCPP} -DNO_UNDERLINE" +fi +rm -f _match.o conftest.c conftest.o +if echo "$DEFS" | grep NO_ASM >/dev/null; then + : +else + echo checking for assembler + OBJA="" + if eval "$ASCPP $srcdir/match.S > _match.s 2>/dev/null"; then + if test ! -s _match.s || grep error < _match.s > /dev/null; then + : + elif eval "$CC -c _match.s >/dev/null 2>&1" && test -f _match.o; then + DEFS="${DEFS} -DASMV" + OBJA=match.o + fi + fi + rm -f _match.s _match.o +fi +# Make sure to not get the incompatible SysV /etc/install and +# /usr/sbin/install, which might be in PATH before a BSD-like install, +# or the SunOS /usr/etc/install directory, or the AIX /bin/install, +# or the AFS install, which mishandles nonexistent args, or +# /usr/ucb/install on SVR4, which tries to use the nonexistent group +# `staff'. On most BSDish systems install is in /usr/bin, not /usr/ucb +# anyway. Sigh. +if test "z${INSTALL}" = "z" ; then + echo checking for install + IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + case $dir in + /etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;; + *) + if test -f $dir/installbsd; then + INSTALL="$dir/installbsd -c" # OSF1 + INSTALL_PROGRAM='$(INSTALL)' + INSTALL_DATA='$(INSTALL) -m 644' + break + fi + if test -f $dir/install; then + if grep dspmsg $dir/install >/dev/null 2>&1; then + : # AIX + else + INSTALL="$dir/install -c" + INSTALL_PROGRAM='$(INSTALL)' + INSTALL_DATA='$(INSTALL) -m 644' + break + fi + fi + ;; + esac + done + IFS="$saveifs" +fi +INSTALL=${INSTALL-cp} +INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} +INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} + +echo checking for AIX +cat > conftest.c < conftest.out 2>&1" +if egrep "yes" conftest.out >/dev/null 2>&1; then + { +test -n "$verbose" && \ +echo ' defining' _ALL_SOURCE +DEFS="$DEFS -D_ALL_SOURCE=1" +} + +fi +rm -f conftest* + + +echo checking for minix/config.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + MINIX=1 +fi +rm -f conftest* + +# The Minix shell can't assign to the same variable on the same line! +if test -n "$MINIX"; then + { +test -n "$verbose" && \ +echo ' defining' _POSIX_SOURCE +DEFS="$DEFS -D_POSIX_SOURCE=1" +} + + { +test -n "$verbose" && \ +echo ' defining' _POSIX_1_SOURCE to be '2' +DEFS="$DEFS -D_POSIX_1_SOURCE=2" +} + + { +test -n "$verbose" && \ +echo ' defining' _MINIX +DEFS="$DEFS -D_MINIX=1" +} + +fi + +echo checking for POSIXized ISC +if test -d /etc/conf/kconfig.d && + grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 +then + ISC=1 # If later tests want to check for ISC. + { +test -n "$verbose" && \ +echo ' defining' _POSIX_SOURCE +DEFS="$DEFS -D_POSIX_SOURCE=1" +} + + if test -n "$GCC"; then + CC="$CC -posix" + else + CC="$CC -Xp" + fi +fi + +echo checking for DYNIX/ptx libseq +cat > conftest.c < conftest.out 2>&1" +if egrep "yes" conftest.out >/dev/null 2>&1; then + SEQUENT=1 +fi +rm -f conftest* + +test -n "$SEQUENT" && test -f /usr/lib/libseq.a && + LIBS="$LIBS -lseq" + +echo checking for ANSI C header files +cat > conftest.c < +#include +#include +#include +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +echo '#include ' > conftest.c +eval "$CPP \$DEFS conftest.c > conftest.out 2>&1" +if egrep "memchr" conftest.out >/dev/null 2>&1; then + # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +cat > conftest.c < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +eval $compile +if test -s conftest && (./conftest; exit) 2>/dev/null; then + { +test -n "$verbose" && \ +echo ' defining' STDC_HEADERS +DEFS="$DEFS -DSTDC_HEADERS=1" +} + +fi +rm -f conftest* +fi +rm -f conftest* + +fi +rm -f conftest* + +echo checking for string.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + : +else + { +test -n "$verbose" && \ +echo ' defining' NO_STRING_H +DEFS="$DEFS -DNO_STRING_H=1" +} + +fi +rm -f conftest* + +echo checking for stdlib.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + : +else + { +test -n "$verbose" && \ +echo ' defining' NO_STDLIB_H +DEFS="$DEFS -DNO_STDLIB_H=1" +} + +fi +rm -f conftest* + +echo checking for memory.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + : +else + { +test -n "$verbose" && \ +echo ' defining' NO_MEMORY_H +DEFS="$DEFS -DNO_MEMORY_H=1" +} + +fi +rm -f conftest* + +echo checking for fcntl.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + : +else + { +test -n "$verbose" && \ +echo ' defining' NO_FCNTL_H +DEFS="$DEFS -DNO_FCNTL_H=1" +} + +fi +rm -f conftest* + +echo checking for time.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + : +else + { +test -n "$verbose" && \ +echo ' defining' NO_TIME_H +DEFS="$DEFS -DNO_TIME_H=1" +} + +fi +rm -f conftest* + +for hdr in unistd.h +do +trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'` +echo checking for ${hdr} +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + { +test -n "$verbose" && \ +echo ' defining' ${trhdr} +DEFS="$DEFS -D${trhdr}=1" +} + +fi +rm -f conftest* +done + +utime=0 +echo checking for utime.h +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + utime=1 +else + { +test -n "$verbose" && \ +echo ' defining' NO_UTIME_H +DEFS="$DEFS -DNO_UTIME_H=1" +} + +fi +rm -f conftest* + +if test $utime -eq 0; then + for hdr in sys/utime.h +do +trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'` +echo checking for ${hdr} +cat > conftest.c < +EOF +err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"` +if test -z "$err"; then + { +test -n "$verbose" && \ +echo ' defining' ${trhdr} +DEFS="$DEFS -D${trhdr}=1" +} + +fi +rm -f conftest* +done + +fi +echo checking for directory library header +dirheader= +if test -z "$dirheader"; then + echo checking for dirent.h +cat > conftest.c < +#include +int main() { exit(0); } +int t() { DIR *dirp = opendir ("/"); } +EOF +if eval $compile; then + { +test -n "$verbose" && \ +echo ' defining' DIRENT +DEFS="$DEFS -DDIRENT=1" +} + dirheader=dirent.h +fi +rm -f conftest* +fi +if test -z "$dirheader"; then + echo checking for sys/ndir.h +cat > conftest.c < +#include +int main() { exit(0); } +int t() { DIR *dirp = opendir ("/"); } +EOF +if eval $compile; then + { +test -n "$verbose" && \ +echo ' defining' SYSNDIR +DEFS="$DEFS -DSYSNDIR=1" +} + dirheader=sys/ndir.h +fi +rm -f conftest* +fi +if test -z "$dirheader"; then + echo checking for sys/dir.h +cat > conftest.c < +#include +int main() { exit(0); } +int t() { DIR *dirp = opendir ("/"); } +EOF +if eval $compile; then + { +test -n "$verbose" && \ +echo ' defining' SYSDIR +DEFS="$DEFS -DSYSDIR=1" +} + dirheader=sys/dir.h +fi +rm -f conftest* +fi +if test -z "$dirheader"; then + echo checking for ndir.h +cat > conftest.c < +#include +int main() { exit(0); } +int t() { DIR *dirp = opendir ("/"); } +EOF +if eval $compile; then + { +test -n "$verbose" && \ +echo ' defining' NDIR +DEFS="$DEFS -DNDIR=1" +} + dirheader=ndir.h +fi +rm -f conftest* +fi + +echo checking for closedir return value +cat > conftest.c < +#include <$dirheader> +int closedir(); main() { exit(closedir(opendir(".")) != 0); } +EOF +eval $compile +if test -s conftest && (./conftest; exit) 2>/dev/null; then + : +else + { +test -n "$verbose" && \ +echo ' defining' VOID_CLOSEDIR +DEFS="$DEFS -DVOID_CLOSEDIR=1" +} + +fi +rm -f conftest* + +echo checking for Xenix +cat > conftest.c < conftest.out 2>&1" +if egrep "yes" conftest.out >/dev/null 2>&1; then + XENIX=1 +fi +rm -f conftest* + +if test -n "$XENIX"; then + LIBS="$LIBS -lx" + case "$DEFS" in + *SYSNDIR*) ;; + *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx. + esac +fi + +echo checking for return type of signal handlers +cat > conftest.c < +#include +#ifdef signal +#undef signal +#endif +extern void (*signal ()) (); +int main() { exit(0); } +int t() { int i; } +EOF +if eval $compile; then + : +else + { +test -n "$verbose" && \ +echo ' defining' RETSIGTYPE to be 'int' +DEFS="$DEFS -DRETSIGTYPE=int" +} + +fi +rm -f conftest* + + +echo checking for size_t in sys/types.h +echo '#include ' > conftest.c +eval "$CPP \$DEFS conftest.c > conftest.out 2>&1" +if egrep "size_t" conftest.out >/dev/null 2>&1; then + : +else + { +test -n "$verbose" && \ +echo ' defining' size_t to be 'unsigned' +DEFS="$DEFS -Dsize_t=unsigned" +} + +fi +rm -f conftest* + +echo '#include ' > conftest.c +eval "$CPP \$DEFS conftest.c > conftest.out 2>&1" +if egrep "off_t" conftest.out >/dev/null 2>&1; then + : +else + { +test -n "$verbose" && \ +echo ' defining' NO_OFF_T +DEFS="$DEFS -DNO_OFF_T=1" +} + +fi +rm -f conftest* + +echo "checking if \`#!' works in shell scripts" +cat <<'__EOF__' > conftest.csh +#!/bin/csh -f +setenv SHELL /bin/csh +# Avoid tcsh bug 'Bad Hertz Value': +setenv HZ 60 +# Make sure foo doesn't get exported into the environment +# Astoundingly, some versions of csh don't have unsetenv. +if (${?foo}) unsetenv foo >& /dev/null +if (${?foo}) unset foo +set output="`./conftest.sh`" +if ( "$output" == "foo=bar" ) then + exit 0 +endif +exit 1 +__EOF__ +cat <<'__EOF__' > conftest.sh +#!/bin/sh +set foo=bar +echo "$*" +__EOF__ +chmod 777 conftest.csh conftest.sh +(csh -f ./conftest.csh) 2> /dev/null +if test $? = 0 ; then + :; SEDCMD="1d" +else + :; SEDCMD="" +fi +rm -f conftest.csh conftest.sh + +if test -z "$prefix" +then + echo checking for gzip to derive installation directory prefix + IFS="${IFS= }"; saveifs="$IFS"; IFS="$IFS:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test $dir != . && test -f $dir/gzip; then + # Not all systems have dirname. + prefix=`echo $dir|sed 's%/[^/][^/]*$%%'` + break + fi + done + IFS="$saveifs" + echo " chose installation directory prefix ${prefix}" +fi + +if test -z "$G" -a -n "$prefix" -a -f $prefix/bin/gznew; then + G=g +fi +if test -z "$ZCAT"; then + if test -n "$prefix" -a -f $prefix/bin/gzcat; then + ZCAT=gzcat + else + ZCAT=${G}zcat + fi +fi +if test -n "$prefix"; then + test -z "$exec_prefix" && exec_prefix='${prefix}' + prsub="s%^prefix\\([ ]*\\)=\\([ ]*\\).*$%prefix\\1=\\2$prefix%" +fi +if test -n "$exec_prefix"; then + prsub="$prsub +s%^exec_prefix\\([ ]*\\)=\\([ ]*\\).*$%\ +exec_prefix\\1=\\2$exec_prefix%" +fi +cat >conftest.def < config.status </dev/null | sed 1q`: +# +# $0 $* + +for arg +do + case "\$arg" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + exec /bin/sh $0 $* ;; + *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; + esac +done + +trap 'rm -f Makefile; exit 1' 1 3 15 +CC='$CC' +CPP='$CPP' +INSTALL='$INSTALL' +INSTALL_PROGRAM='$INSTALL_PROGRAM' +INSTALL_DATA='$INSTALL_DATA' +ZCAT='$ZCAT' +G='$G' +CFLAGS='$CFLAGS' +ASCPP='$ASCPP' +OBJA='$OBJA' +SEDCMD='$SEDCMD' +LIBS='$LIBS' +srcdir='$srcdir' +DEFS='$DEFS' +prefix='$prefix' +exec_prefix='$exec_prefix' +prsub='$prsub' +EOF +cat >> config.status <<\EOF + +top_srcdir=$srcdir + +# Allow make-time overrides of the generated file list. +test -n "$gen_files" || gen_files="Makefile" + +for file in .. $gen_files; do if [ "x$file" != "x.." ]; then + srcdir=$top_srcdir + # Remove last slash and all that follows it. Not all systems have dirname. + dir=`echo $file|sed 's%/[^/][^/]*$%%'` + if test "$dir" != "$file"; then + test "$top_srcdir" != . && srcdir=$top_srcdir/$dir + test ! -d $dir && mkdir $dir + fi + echo creating $file + rm -f $file + echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file + sed -e " +$prsub +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@INSTALL@%$INSTALL%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@ZCAT@%$ZCAT%g +s%@G@%$G%g +s%@CFLAGS@%$CFLAGS%g +s%@ASCPP@%$ASCPP%g +s%@OBJA@%$OBJA%g +s%@SEDCMD@%$SEDCMD%g +s%@LIBS@%$LIBS%g +s%@srcdir@%$srcdir%g +s%@DEFS@%$DEFS% +" $top_srcdir/${file}.in >> $file +fi; done + +exit 0 +EOF +chmod +x config.status +test -n "$no_create" || ./config.status + diff --git a/tools/gzip-1.2.4/configure.in b/tools/gzip-1.2.4/configure.in new file mode 100644 index 00000000..7f8a4535 --- /dev/null +++ b/tools/gzip-1.2.4/configure.in @@ -0,0 +1,98 @@ +dnl Process this file with autoconf to produce a configure script for gzip +dnl +dnl Same as AC_RETSIGTYPE, but use a void default. +dnl +define(AC_RETSIGTYP, +[AC_COMPILE_CHECK([return type of signal handlers], +[#include +#include +#ifdef signal +#undef signal +#endif +extern void (*signal ()) ();], +[int i;], +[], +[AC_DEFINE(RETSIGTYPE, int)], +)] +)dnl +dnl +dnl End of local macros +dnl +AC_INIT(gzip.c) +AC_PROG_CC +AC_PROG_CPP +dnl +dnl Try to assemble match.S with and without leading underline. +dnl cc -E produces incorrect asm files on SVR4, we must use /lib/cpp. +dnl Also, "gcc -E match.s" ignores -E, so we must use match.S. +echo checking for underline in external names +test -z "$ASCPP" -a -f /lib/cpp && ASCPP=/lib/cpp +test -z "$ASCPP" && ASCPP="$CC -E" +cat > conftest.c < /dev/null 2>&1" +if nm conftest.o | grep _foo > /dev/null 2>&1 ; then + : +else + ASCPP="${ASCPP} -DNO_UNDERLINE" +fi +rm -f _match.o conftest.c conftest.o +if echo "$DEFS" | grep NO_ASM >/dev/null; then + : +else + echo checking for assembler + OBJA="" + if eval "$ASCPP $srcdir/match.S > _match.s 2>/dev/null"; then + if test ! -s _match.s || grep error < _match.s > /dev/null; then + : + elif eval "$CC -c _match.s >/dev/null 2>&1" && test -f _match.o; then + DEFS="${DEFS} -DASMV" + OBJA=match.o + fi + fi + rm -f _match.s _match.o +fi +dnl +AC_PROG_INSTALL +AC_AIX +AC_MINIX +AC_ISC_POSIX +AC_DYNIX_SEQ +AC_STDC_HEADERS +dnl if STDC_HEADERS can't be defined, look for special files: +AC_HEADER_CHECK(string.h, ,AC_DEFINE(NO_STRING_H)) +AC_HEADER_CHECK(stdlib.h, ,AC_DEFINE(NO_STDLIB_H)) +AC_HEADER_CHECK(memory.h, ,AC_DEFINE(NO_MEMORY_H)) +AC_HEADER_CHECK(fcntl.h, ,AC_DEFINE(NO_FCNTL_H)) +AC_HEADER_CHECK(time.h, ,AC_DEFINE(NO_TIME_H)) +AC_HAVE_HEADERS(unistd.h) +utime=0 +AC_HEADER_CHECK(utime.h, utime=1 ,AC_DEFINE(NO_UTIME_H)) +if test $utime -eq 0; then + AC_HAVE_HEADERS(sys/utime.h) +fi +AC_DIR_HEADER +AC_XENIX_DIR +AC_RETSIGTYP +AC_SIZE_T +AC_HEADER_EGREP(off_t, sys/types.h, ,AC_DEFINE(NO_OFF_T)) +AC_HAVE_POUNDBANG([SEDCMD="1d"], [SEDCMD=""]) +AC_PREFIX(gzip) +if test -z "$G" -a -n "$prefix" -a -f $prefix/bin/gznew; then + G=g +fi +if test -z "$ZCAT"; then + if test -n "$prefix" -a -f $prefix/bin/gzcat; then + ZCAT=gzcat + else + ZCAT=${G}zcat + fi +fi +AC_SUBST(ZCAT)dnl +AC_SUBST(G)dnl +AC_SUBST(CFLAGS)dnl +AC_SUBST(ASCPP)dnl +AC_SUBST(OBJA)dnl +AC_SUBST(SEDCMD)dnl +AC_OUTPUT(Makefile) diff --git a/tools/gzip-1.2.4/crypt.c b/tools/gzip-1.2.4/crypt.c new file mode 100644 index 00000000..cbce024a --- /dev/null +++ b/tools/gzip-1.2.4/crypt.c @@ -0,0 +1,6 @@ +/* crypt.c (dummy version) -- do not perform encryption + * Hardly worth copyrighting :-) + */ +#ifdef RCSID +static char rcsid[] = "$Id: crypt.c,v 0.6 1993/03/22 09:48:47 jloup Exp $"; +#endif diff --git a/tools/gzip-1.2.4/crypt.h b/tools/gzip-1.2.4/crypt.h new file mode 100644 index 00000000..2a4c203c --- /dev/null +++ b/tools/gzip-1.2.4/crypt.h @@ -0,0 +1,12 @@ +/* crypt.h (dummy version) -- do not perform encryption + * Hardly worth copyrighting :-) + */ + +#ifdef CRYPT +# undef CRYPT /* dummy version */ +#endif + +#define RAND_HEAD_LEN 12 /* length of encryption random header */ + +#define zencode +#define zdecode diff --git a/tools/gzip-1.2.4/deflate.c b/tools/gzip-1.2.4/deflate.c new file mode 100644 index 00000000..7f52b64f --- /dev/null +++ b/tools/gzip-1.2.4/deflate.c @@ -0,0 +1,763 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* + * PURPOSE + * + * Identify new text as repetitions of old text within a fixed- + * length sliding window trailing behind the new text. + * + * DISCUSSION + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many info-zippers for bug reports and testing. + * + * REFERENCES + * + * APPNOTE.TXT documentation file in PKZIP 1.93a distribution. + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + * INTERFACE + * + * void lm_init (int pack_level, ush *flags) + * Initialize the "longest match" routines for a new file + * + * ulg deflate (void) + * Processes a new input file and return its compressed length. Sets + * the compressed length, crc, deflate flags and internal file + * attributes. + */ + +#include + +#include "tailor.h" +#include "gzip.h" +#include "lzw.h" /* just for consistency checking */ + +#ifdef RCSID +static char rcsid[] = "$Id: deflate.c,v 0.15 1993/06/24 10:53:53 jloup Exp $"; +#endif + +/* =========================================================================== + * Configuration parameters + */ + +/* Compile with MEDIUM_MEM to reduce the memory requirements or + * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the + * entire input file can be held in memory (not possible on 16 bit systems). + * Warning: defining these symbols affects HASH_BITS (see below) and thus + * affects the compression ratio. The compressed output + * is still correct, and might even be smaller in some cases. + */ + +#ifdef SMALL_MEM +# define HASH_BITS 13 /* Number of bits used to hash strings */ +#endif +#ifdef MEDIUM_MEM +# define HASH_BITS 14 +#endif +#ifndef HASH_BITS +# define HASH_BITS 15 + /* For portability to 16 bit machines, do not use values above 15. */ +#endif + +/* To save space (see unlzw.c), we overlay prev+head with tab_prefix and + * window with tab_suffix. Check that we can do this: + */ +#if (WSIZE<<1) > (1< BITS-1 + error: cannot overlay head with tab_prefix1 +#endif + +#define HASH_SIZE (unsigned)(1<= HASH_BITS + */ + +unsigned int near prev_length; +/* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + unsigned near strstart; /* start of string to insert */ + unsigned near match_start; /* start of matching string */ +local int eofile; /* flag set at end of input file */ +local unsigned lookahead; /* number of valid bytes ahead in window */ + +unsigned near max_chain_length; +/* To speed up deflation, hash chains are never searched beyond this length. + * A higher limit improves compression ratio but degrades the speed. + */ + +local unsigned int max_lazy_match; +/* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +#define max_insert_length max_lazy_match +/* Insert new strings in the hash table only if the match length + * is not greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + +local int compr_level; +/* compression level (1..9) */ + +unsigned near good_match; +/* Use a faster search when the previous match is longer than this */ + + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ + +typedef struct config { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; +} config; + +#ifdef FULL_SEARCH +# define nice_match MAX_MATCH +#else + int near nice_match; /* Stop searching when current match exceeds this */ +#endif + +local config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0}, /* store only */ +/* 1 */ {4, 4, 8, 4}, /* maximum speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8}, +/* 3 */ {4, 6, 32, 32}, + +/* 4 */ {4, 4, 16, 16}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32}, +/* 6 */ {8, 16, 128, 128}, +/* 7 */ {8, 32, 128, 256}, +/* 8 */ {32, 128, 258, 1024}, +/* 9 */ {32, 258, 258, 4096}}; /* maximum compression */ + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +/* =========================================================================== + * Prototypes for local functions. + */ +local void fill_window OF((void)); +local ulg deflate_fast OF((void)); + + int longest_match OF((IPos cur_match)); +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ +#endif + +#ifdef DEBUG +local void check_match OF((IPos start, IPos match, int length)); +#endif + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(h,c) (h = (((h)< 9) error("bad pack level"); + compr_level = pack_level; + + /* Initialize the hash table. */ +#if defined(MAXSEG_64K) && HASH_BITS == 15 + for (j = 0; j < HASH_SIZE; j++) head[j] = NIL; +#else + memzero((char*)head, HASH_SIZE*sizeof(*head)); +#endif + /* prev will be initialized on the fly */ + + /* Set the default configuration parameters: + */ + max_lazy_match = configuration_table[pack_level].max_lazy; + good_match = configuration_table[pack_level].good_length; +#ifndef FULL_SEARCH + nice_match = configuration_table[pack_level].nice_length; +#endif + max_chain_length = configuration_table[pack_level].max_chain; + if (pack_level == 1) { + *flags |= FAST; + } else if (pack_level == 9) { + *flags |= SLOW; + } + /* ??? reduce max_chain_length for binary files */ + + strstart = 0; + block_start = 0L; +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif + + lookahead = read_buf((char*)window, + sizeof(int) <= 2 ? (unsigned)WSIZE : 2*WSIZE); + + if (lookahead == 0 || lookahead == (unsigned)EOF) { + eofile = 1, lookahead = 0; + return; + } + eofile = 0; + /* Make sure that we always have enough lookahead. This is important + * if input comes from a device such as a tty. + */ + while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); + + ins_h = 0; + for (j=0; j= 1 + */ +#ifndef ASMV +/* For MSDOS, OS/2 and 386 Unix, an optimized version is in match.asm or + * match.s. The code is functionally equivalent, so you can use the C version + * if desired. + */ +int longest_match(cur_match) + IPos cur_match; /* current match */ +{ + unsigned chain_length = max_chain_length; /* max hash chain length */ + register uch *scan = window + strstart; /* current string */ + register uch *match; /* matched string */ + register int len; /* length of current match */ + int best_len = prev_length; /* best match length so far */ + IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + +/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ +#if HASH_BITS < 8 || MAX_MATCH != 258 + error: Code too clever +#endif + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register uch *strend = window + strstart + MAX_MATCH - 1; + register ush scan_start = *(ush*)scan; + register ush scan_end = *(ush*)(scan+best_len-1); +#else + register uch *strend = window + strstart + MAX_MATCH; + register uch scan_end1 = scan[best_len-1]; + register uch scan_end = scan[best_len]; +#endif + + /* Do not waste too much time if we already have a good match: */ + if (prev_length >= good_match) { + chain_length >>= 2; + } + Assert(strstart <= window_size-MIN_LOOKAHEAD, "insufficient lookahead"); + + do { + Assert(cur_match < strstart, "no future"); + match = window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2: + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ush*)(match+best_len-1) != scan_end || + *(ush*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + scan++, match++; + do { + } while (*(ush*)(scan+=2) == *(ush*)(match+=2) && + *(ush*)(scan+=2) == *(ush*)(match+=2) && + *(ush*)(scan+=2) == *(ush*)(match+=2) && + *(ush*)(scan+=2) == *(ush*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= window+(unsigned)(window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ush*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & WMASK]) > limit + && --chain_length != 0); + + return best_len; +} +#endif /* ASMV */ + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(start, match, length) + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (memcmp((char*)window + match, + (char*)window + start, length) != EQUAL) { + fprintf(stderr, + " start %d, match %d, length %d\n", + start, match, length); + error("invalid match"); + } + if (verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(start, match, length) +#endif + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead, and sets eofile if end of input file. + * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 + * OUT assertions: at least one byte has been read, or eofile is set; + * file reads are performed for at least two bytes (required for the + * translate_eol option). + */ +local void fill_window() +{ + register unsigned n, m; + unsigned more = (unsigned)(window_size - (ulg)lookahead - (ulg)strstart); + /* Amount of free space at the end of the window. */ + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (more == (unsigned)EOF) { + /* Very unlikely, but possible on 16 bit machine if strstart == 0 + * and lookahead == 1 (input done one byte at time) + */ + more--; + } else if (strstart >= WSIZE+MAX_DIST) { + /* By the IN assertion, the window is not empty so we can't confuse + * more == 0 with more == 64K on a 16 bit machine. + */ + Assert(window_size == (ulg)2*WSIZE, "no sliding with BIG_MEM"); + + memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE); + match_start -= WSIZE; + strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ + + block_start -= (long) WSIZE; + + for (n = 0; n < HASH_SIZE; n++) { + m = head[n]; + head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); + } + for (n = 0; n < WSIZE; n++) { + m = prev[n]; + prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } + more += WSIZE; + } + /* At this point, more >= 2 */ + if (!eofile) { + n = read_buf((char*)window+strstart+lookahead, more); + if (n == 0 || n == (unsigned)EOF) { + eofile = 1; + } else { + lookahead += n; + } + } +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK(eof) \ + flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \ + (char*)NULL, (long)strstart - block_start, (eof)) + +/* =========================================================================== + * Processes a new input file and return its compressed length. This + * function does not perform lazy evaluationof matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local ulg deflate_fast() +{ + IPos hash_head; /* head of the hash chain */ + int flush; /* set if current block must be flushed */ + unsigned match_length = 0; /* length of best match */ + + prev_length = MIN_MATCH-1; + while (lookahead != 0) { + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + INSERT_STRING(strstart, hash_head); + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && strstart - hash_head <= MAX_DIST) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + match_length = longest_match (hash_head); + /* longest_match() sets match_start */ + if (match_length > lookahead) match_length = lookahead; + } + if (match_length >= MIN_MATCH) { + check_match(strstart, match_start, match_length); + + flush = ct_tally(strstart-match_start, match_length - MIN_MATCH); + + lookahead -= match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ + if (match_length <= max_insert_length) { + match_length--; /* string at strstart already in hash table */ + do { + strstart++; + INSERT_STRING(strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH + * these bytes are garbage, but it does not matter since + * the next lookahead bytes will be emitted as literals. + */ + } while (--match_length != 0); + strstart++; + } else { + strstart += match_length; + match_length = 0; + ins_h = window[strstart]; + UPDATE_HASH(ins_h, window[strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c",window[strstart])); + flush = ct_tally (0, window[strstart]); + lookahead--; + strstart++; + } + if (flush) FLUSH_BLOCK(0), block_start = strstart; + + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); + + } + return FLUSH_BLOCK(1); /* eof */ +} + +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +ulg deflate() +{ + IPos hash_head; /* head of hash chain */ + IPos prev_match; /* previous match */ + int flush; /* set if current block must be flushed */ + int match_available = 0; /* set if previous match exists */ + register unsigned match_length = MIN_MATCH-1; /* length of best match */ +#ifdef DEBUG + extern long isize; /* byte length of input file, for debug only */ +#endif + + if (compr_level <= 3) return deflate_fast(); /* optimized for speed */ + + /* Process the input block. */ + while (lookahead != 0) { + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + INSERT_STRING(strstart, hash_head); + + /* Find the longest match, discarding those <= prev_length. + */ + prev_length = match_length, prev_match = match_start; + match_length = MIN_MATCH-1; + + if (hash_head != NIL && prev_length < max_lazy_match && + strstart - hash_head <= MAX_DIST) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + match_length = longest_match (hash_head); + /* longest_match() sets match_start */ + if (match_length > lookahead) match_length = lookahead; + + /* Ignore a length 3 match if it is too distant: */ + if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){ + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + match_length--; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (prev_length >= MIN_MATCH && match_length <= prev_length) { + + check_match(strstart-1, prev_match, prev_length); + + flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. + */ + lookahead -= prev_length-1; + prev_length -= 2; + do { + strstart++; + INSERT_STRING(strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH + * these bytes are garbage, but it does not matter since the + * next lookahead bytes will always be emitted as literals. + */ + } while (--prev_length != 0); + match_available = 0; + match_length = MIN_MATCH-1; + strstart++; + if (flush) FLUSH_BLOCK(0), block_start = strstart; + + } else if (match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c",window[strstart-1])); + if (ct_tally (0, window[strstart-1])) { + FLUSH_BLOCK(0), block_start = strstart; + } + strstart++; + lookahead--; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + match_available = 1; + strstart++; + lookahead--; + } + Assert (strstart <= isize && lookahead <= isize, "a bit too far"); + + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); + } + if (match_available) ct_tally (0, window[strstart-1]); + + return FLUSH_BLOCK(1); /* eof */ +} diff --git a/tools/gzip-1.2.4/getopt.c b/tools/gzip-1.2.4/getopt.c new file mode 100644 index 00000000..55fad843 --- /dev/null +++ b/tools/gzip-1.2.4/getopt.c @@ -0,0 +1,755 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif + +/* This tells Alpha OSF/1 not to define a getopt prototype in . */ +#ifndef _NO_PROTO +#define _NO_PROTO +#endif + +#include +#include "tailor.h" + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +#include +#endif /* GNU C library. */ + +/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a + long-named option. Because this is not POSIX.2 compliant, it is + being phased out. */ +/* #define GETOPT_COMPAT */ + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = 0; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* XXX 1003.2 says this must be 1 before any call. */ +int optind = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +#define BAD_OPTION '\0' +int optopt = BAD_OPTION; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +#include +#define my_index strchr +#define my_strlen strlen +#else + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#if __STDC__ || defined(PROTO) +extern char *getenv(const char *name); +extern int strcmp (const char *s1, const char *s2); +extern int strncmp(const char *s1, const char *s2, int n); + +static int my_strlen(const char *s); +static char *my_index (const char *str, int chr); +#else +extern char *getenv (); +#endif + +static int +my_strlen (str) + const char *str; +{ + int n = 0; + while (*str++) + n++; + return n; +} + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +#endif /* GNU C library. */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. + + To perform the swap, we first reverse the order of all elements. So + all options now come before all non options, but they are in the + wrong order. So we put back the options and non options in original + order by reversing them again. For example: + original input: a b c -x -y + reverse all: -y -x c b a + reverse options: -x -y c b a + reverse non options: -x -y a b c +*/ + +#if __STDC__ || defined(PROTO) +static void exchange (char **argv); +#endif + +static void +exchange (argv) + char **argv; +{ + char *temp, **first, **last; + + /* Reverse all the elements [first_nonopt, optind) */ + first = &argv[first_nonopt]; + last = &argv[optind-1]; + while (first < last) { + temp = *first; *first = *last; *last = temp; first++; last--; + } + /* Put back the options in order */ + first = &argv[first_nonopt]; + first_nonopt += (optind - last_nonopt); + last = &argv[first_nonopt - 1]; + while (first < last) { + temp = *first; *first = *last; *last = temp; first++; last--; + } + + /* Put back the non options in order */ + first = &argv[first_nonopt]; + last_nonopt = optind; + last = &argv[last_nonopt-1]; + while (first < last) { + temp = *first; *first = *last; *last = temp; first++; last--; + } +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns `EOF'. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return BAD_OPTION after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return BAD_OPTION. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + int option_index; + + optarg = 0; + + /* Initialize the internal data when the first call is made. + Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + if (optind == 0) + { + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (getenv ("POSIXLY_CORRECT") != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + } + + if (nextchar == NULL || *nextchar == '\0') + { + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Now skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc + && (argv[optind][0] != '-' || argv[optind][1] == '\0') +#ifdef GETOPT_COMPAT + && (longopts == NULL + || argv[optind][0] != '+' || argv[optind][1] == '\0') +#endif /* GETOPT_COMPAT */ + ) + optind++; + last_nonopt = optind; + } + + /* Special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return EOF; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if ((argv[optind][0] != '-' || argv[optind][1] == '\0') +#ifdef GETOPT_COMPAT + && (longopts == NULL + || argv[optind][0] != '+' || argv[optind][1] == '\0') +#endif /* GETOPT_COMPAT */ + ) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + if (longopts != NULL + && ((argv[optind][0] == '-' + && (argv[optind][1] == '-' || long_only)) +#ifdef GETOPT_COMPAT + || argv[optind][0] == '+' +#endif /* GETOPT_COMPAT */ + )) + { + const struct option *p; + char *s = nextchar; + int exact = 0; + int ambig = 0; + const struct option *pfound = NULL; + int indfound = 0; + + while (*s && *s != '=') + s++; + + /* Test all options for either exact match or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; + p++, option_index++) + if (!strncmp (p->name, nextchar, s - nextchar)) + { + if (s - nextchar == my_strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += my_strlen (nextchar); + optind++; + return BAD_OPTION; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*s) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = s + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } + nextchar += my_strlen (nextchar); + return BAD_OPTION; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += my_strlen (nextchar); + return optstring[0] == ':' ? ':' : BAD_OPTION; + } + } + nextchar += my_strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' +#ifdef GETOPT_COMPAT + || argv[optind][0] == '+' +#endif /* GETOPT_COMPAT */ + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, "%s: unrecognized option `--%s'\n", + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + return BAD_OPTION; + } + } + + /* Look at and handle the next option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { +#if 0 + if (c < 040 || c >= 0177) + fprintf (stderr, "%s: unrecognized option, character code 0%o\n", + argv[0], c); + else + fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); +#else + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); +#endif + } + optopt = c; + return BAD_OPTION; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = 0; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { +#if 0 + fprintf (stderr, "%s: option `-%c' requires an argument\n", + argv[0], c); +#else + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: option requires an argument -- %c\n", + argv[0], c); +#endif + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = BAD_OPTION; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case BAD_OPTION: + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/tools/gzip-1.2.4/getopt.h b/tools/gzip-1.2.4/getopt.h new file mode 100644 index 00000000..0abce6e9 --- /dev/null +++ b/tools/gzip-1.2.4/getopt.h @@ -0,0 +1,127 @@ +/* Declarations for getopt. + Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +#if __STDC__ + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#if __STDC__ || defined(PROTO) +#if defined(__GNU_LIBRARY__) +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); +#endif /* not __GNU_LIBRARY__ */ +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* not __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff --git a/tools/gzip-1.2.4/gpl.texinfo b/tools/gzip-1.2.4/gpl.texinfo new file mode 100644 index 00000000..6fb0afb4 --- /dev/null +++ b/tools/gzip-1.2.4/gpl.texinfo @@ -0,0 +1,394 @@ +@setfilename gpl.info + +@unnumbered GNU GENERAL PUBLIC LICENSE +@center Version 2, June 1991 + +@display +Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. +675 Mass Ave, Cambridge, MA 02139, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@unnumberedsec Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software---to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + +@iftex +@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end iftex +@ifinfo +@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end ifinfo + +@enumerate +@item +This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The ``Program'', below, +refers to any such program or work, and a ``work based on the Program'' +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term ``modification''.) Each licensee is addressed as ``you''. + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +@item +You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +@item +You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + +@enumerate a +@item +You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + +@item +You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any +part thereof, to be licensed as a whole at no charge to all third +parties under the terms of this License. + +@item +If the modified program normally reads commands interactively +when run, you must cause it, when started running for such +interactive use in the most ordinary way, to print or display an +announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide +a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this +License. (Exception: if the Program itself is interactive but +does not normally print such an announcement, your work based on +the Program is not required to print an announcement.) +@end enumerate + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +@item +You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + +@enumerate a +@item +Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections +1 and 2 above on a medium customarily used for software interchange; or, + +@item +Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your +cost of physically performing source distribution, a complete +machine-readable copy of the corresponding source code, to be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +@item +Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form with such +an offer, in accord with Subsection b above.) +@end enumerate + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +@item +You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + +@item +You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +@item +Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +@item +If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +@item +If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +@item +The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and ``any +later version'', you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +@item +If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +@iftex +@heading NO WARRANTY +@end iftex +@ifinfo +@center NO WARRANTY +@end ifinfo + +@item +BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +@item +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. +@end enumerate + +@iftex +@heading END OF TERMS AND CONDITIONS +@end iftex +@ifinfo +@center END OF TERMS AND CONDITIONS +@end ifinfo + +@page +@unnumberedsec How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the ``copyright'' line and a pointer to where the full notice is found. + +@smallexample +@var{one line to give the program's name and an idea of what it does.} +Copyright (C) 19@var{yy} @var{name of author} + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +@end smallexample + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +@smallexample +Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details +type `show w'. This is free software, and you are welcome +to redistribute it under certain conditions; type `show c' +for details. +@end smallexample + +The hypothetical commands @samp{show w} and @samp{show c} should show +the appropriate parts of the General Public License. Of course, the +commands you use may be called something other than @samp{show w} and +@samp{show c}; they could even be mouse-clicks or menu items---whatever +suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a ``copyright disclaimer'' for the program, if +necessary. Here is a sample; alter the names: + +@example +Yoyodyne, Inc., hereby disclaims all copyright +interest in the program `Gnomovision' +(which makes passes at compilers) written +by James Hacker. + +@var{signature of Ty Coon}, 1 April 1989 +Ty Coon, President of Vice +@end example + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/tools/gzip-1.2.4/gunzip b/tools/gzip-1.2.4/gunzip new file mode 100755 index 00000000..9f13d0ce Binary files /dev/null and b/tools/gzip-1.2.4/gunzip differ diff --git a/tools/gzip-1.2.4/gzexe.1 b/tools/gzip-1.2.4/gzexe.1 new file mode 100644 index 00000000..8b62cd60 --- /dev/null +++ b/tools/gzip-1.2.4/gzexe.1 @@ -0,0 +1,43 @@ +.TH GZEXE 1 +.SH NAME +gzexe \- compress executable files in place +.SH SYNOPSIS +.B gzexe +[ name ... ] +.SH DESCRIPTION +The +.I gzexe +utility allows you to compress executables in place and have them +automatically uncompress and execute when you run them (at a penalty +in performance). For example if you execute ``gzexe /bin/cat'' it +will create the following two files: +.nf +.br + -r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat + -r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat~ +.fi +/bin/cat~ is the original file and /bin/cat is the self-uncompressing +executable file. You can remove /bin/cat~ once you are sure that +/bin/cat works properly. +.PP +This utility is most useful on systems with very small disks. +.SH OPTIONS +.TP +.B \-d +Decompress the given executables instead of compressing them. +.SH "SEE ALSO" +gzip(1), znew(1), zmore(1), zcmp(1), zforce(1) +.SH CAVEATS +The compressed executable is a shell script. This may create some +security holes. In particular, the compressed executable relies +on the PATH environment variable to find +.I gzip +and some other utilities +.I (tail, chmod, ln, sleep). +.SH "BUGS" +.I gzexe +attempts to retain the original file attributes on the compressed executable, +but you may have to fix them manually in some cases, using +.I chmod +or +.I chown. diff --git a/tools/gzip-1.2.4/gzexe.in b/tools/gzip-1.2.4/gzexe.in new file mode 100755 index 00000000..fcba5afe --- /dev/null +++ b/tools/gzip-1.2.4/gzexe.in @@ -0,0 +1,151 @@ +: +#!/bin/sh +# gzexe: compressor for Unix executables. +# Use this only for binaries that you do not use frequently. +# +# The compressed version is a shell script which decompresses itself after +# skipping $skip lines of shell commands. We try invoking the compressed +# executable with the original name (for programs looking at their name). +# We also try to retain the original file permissions on the compressed file. +# For safety reasons, gzexe will not create setuid or setgid shell scripts. + +# WARNING: the first line of this file must be either : or #!/bin/sh +# The : is required for some old versions of csh. +# On Ultrix, /bin/sh is too buggy, change the first line to: #!/bin/sh5 + +x=`basename $0` +if test $# = 0; then + echo compress executables. original file foo is renamed to foo~ + echo usage: ${x} [-d] files... + echo " -d decompress the executables" + exit 1 +fi + +tmp=gz$$ +trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15 + +decomp=0 +res=0 +test "$x" = "ungzexe" && decomp=1 +if test "x$1" = "x-d"; then + decomp=1 + shift +fi + +echo hi > zfoo1$$ +echo hi > zfoo2$$ +if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then + cpmod=${CPMOD-cpmod} +fi +rm -f zfoo[12]$$ + +tail="" +IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" +for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/tail; then + tail="$dir/tail" + break + fi +done +IFS="$saveifs" +if test -z "$tail"; then + echo cannot find tail + exit 1 +fi + +for i do + if test ! -f "$i" ; then + echo ${x}: $i not a file + res=1 + continue + fi + if test $decomp -eq 0; then + if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then + echo "${x}: $i is already gzexe'd" + continue + fi + fi + if ls -l "$i" | grep '^...[sS]' > /dev/null; then + echo "${x}: $i has setuid permission, unchanged" + continue + fi + if ls -l "$i" | grep '^......[sS]' > /dev/null; then + echo "${x}: $i has setgid permission, unchanged" + continue + fi + case "`basename $i`" in + gzip | tail | chmod | ln | sleep | rm) + echo "${x}: $i would depend on itself"; continue ;; + esac + if test -z "$cpmod"; then + cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp + if test -w $tmp 2>/dev/null; then + writable=1 + else + writable=0 + chmod u+w $tmp 2>/dev/null + fi + fi + if test $decomp -eq 0; then + sed 1q $0 > $tmp + sed "s|^if tail|if $tail|" >> $tmp <<'EOF' +skip=18 +if tail +$skip $0 | "BINDIR"/gzip -cd > /tmp/gztmp$$; then + /bin/chmod 700 /tmp/gztmp$$ + prog="`echo $0 | /bin/sed 's|^.*/||'`" + if /bin/ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then + trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0 + (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null & + /tmp/"$prog" ${1+"$@"}; res=$? + else + trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0 + (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null & + /tmp/gztmp$$ ${1+"$@"}; res=$? + fi +else + echo Cannot decompress $0; exit 1 +fi; exit $res +EOF + "BINDIR"/gzip -cv9 "$i" >> $tmp || { + /bin/rm -f $tmp + echo ${x}: compression not possible for $i, file unchanged. + res=1 + continue + } + + else + # decompression + skip=18 + if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then + eval `sed -e 1d -e 2q "$i"` + fi + if tail +$skip "$i" | "BINDIR"/gzip -cd > $tmp; then + : + else + echo ${x}: $i probably not in gzexe format, file unchanged. + res=1 + continue + fi + fi + rm -f "$i~" + mv "$i" "$i~" || { + echo ${x}: cannot backup $i as $i~ + rm -f $tmp + res=1 + continue + } + mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || { + echo ${x}: cannot create $i + rm -f $tmp + res=1 + continue + } + rm -f $tmp + if test -n "$cpmod"; then + $cpmod "$i~" "$i" 2>/dev/null + elif test $writable -eq 0; then + chmod u-w $i 2>/dev/null + fi +done +exit $res diff --git a/tools/gzip-1.2.4/gzip b/tools/gzip-1.2.4/gzip new file mode 100755 index 00000000..9f13d0ce Binary files /dev/null and b/tools/gzip-1.2.4/gzip differ diff --git a/tools/gzip-1.2.4/gzip.1 b/tools/gzip-1.2.4/gzip.1 new file mode 100644 index 00000000..6fa79862 --- /dev/null +++ b/tools/gzip-1.2.4/gzip.1 @@ -0,0 +1,478 @@ +.PU +.TH GZIP 1 local +.SH NAME +gzip, gunzip, zcat \- compress or expand files +.SH SYNOPSIS +.ll +8 +.B gzip +.RB [ " \-acdfhlLnNrtvV19 " ] +.RB [ \-S\ suffix ] +[ +.I "name \&..." +] +.ll -8 +.br +.B gunzip +.RB [ " \-acfhlLnNrtvV " ] +.RB [ \-S\ suffix ] +[ +.I "name \&..." +] +.br +.B zcat +.RB [ " \-fhLV " ] +[ +.I "name \&..." +] +.SH DESCRIPTION +.I Gzip +reduces the size of the named files using Lempel-Ziv coding (LZ77). +Whenever possible, +each file is replaced by one with the extension +.B "\&.gz," +while keeping the same ownership modes, access and modification times. +(The default extension is +.B "\-gz" +for VMS, +.B "z" +for MSDOS, OS/2 FAT, Windows NT FAT and Atari.) +If no files are specified, or if a file name is "-", the standard input is +compressed to the standard output. +.I Gzip +will only attempt to compress regular files. +In particular, it will ignore symbolic links. +.PP +If the compressed file name is too long for its file system, +.I gzip +truncates it. +.I Gzip +attempts to truncate only the parts of the file name longer than 3 characters. +(A part is delimited by dots.) If the name consists of small parts only, +the longest parts are truncated. For example, if file names are limited +to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz. +Names are not truncated on systems which do not have a limit on file name +length. +.PP +By default, +.I gzip +keeps the original file name and timestamp in the compressed file. These +are used when decompressing the file with the +.B \-N +option. This is useful when the compressed file name was truncated or +when the time stamp was not preserved after a file transfer. +.PP +Compressed files can be restored to their original form using +.I gzip -d +or +.I gunzip +or +.I zcat. +If the original name saved in the compressed file is not suitable for its +file system, a new name is constructed from the original one to make it +legal. +.PP +.I gunzip +takes a list of files on its command line and replaces each +file whose name ends with .gz, -gz, .z, -z, _z or .Z +and which begins with the correct magic number with an uncompressed +file without the original extension. +.I gunzip +also recognizes the special extensions +.B "\&.tgz" +and +.B "\&.taz" +as shorthands for +.B "\&.tar.gz" +and +.B "\&.tar.Z" +respectively. +When compressing, +.I gzip +uses the +.B "\&.tgz" +extension if necessary instead of truncating a file with a +.B "\&.tar" +extension. +.PP +.I gunzip +can currently decompress files created by +.I gzip, zip, compress, compress -H +or +.I pack. +The detection of the input format is automatic. When using +the first two formats, +.I gunzip +checks a 32 bit CRC. For +.I pack, gunzip +checks the uncompressed length. The standard +.I compress +format was not designed to allow consistency checks. However +.I gunzip +is sometimes able to detect a bad .Z file. If you get an error +when uncompressing a .Z file, do not assume that the .Z file is +correct simply because the standard +.I uncompress +does not complain. This generally means that the standard +.I uncompress +does not check its input, and happily generates garbage output. +The SCO compress -H format (lzh compression method) does not include a CRC +but also allows some consistency checks. +.PP +Files created by +.I zip +can be uncompressed by gzip only if they have a single member compressed +with the 'deflation' method. This feature is only intended to help +conversion of tar.zip files to the tar.gz format. To extract zip files +with several members, use +.I unzip +instead of +.I gunzip. +.PP +.I zcat +is identical to +.I gunzip +.B \-c. +(On some systems, +.I zcat +may be installed as +.I gzcat +to preserve the original link to +.I compress.) +.I zcat +uncompresses either a list of files on the command line or its +standard input and writes the uncompressed data on standard output. +.I zcat +will uncompress files that have the correct magic number whether +they have a +.B "\&.gz" +suffix or not. +.PP +.I Gzip +uses the Lempel-Ziv algorithm used in +.I zip +and PKZIP. +The amount of compression obtained depends on the size of the +input and the distribution of common substrings. +Typically, text such as source code or English +is reduced by 60\-70%. +Compression is generally much better than that achieved by +LZW (as used in +.IR compress ), +Huffman coding (as used in +.IR pack ), +or adaptive Huffman coding +.RI ( compact ). +.PP +Compression is always performed, even if the compressed file is +slightly larger than the original. The worst case expansion is +a few bytes for the gzip file header, plus 5 bytes every 32K block, +or an expansion ratio of 0.015% for large files. Note that the actual +number of used disk blocks almost never increases. +.I gzip +preserves the mode, ownership and timestamps of files when compressing +or decompressing. + +.SH OPTIONS +.TP +.B \-a --ascii +Ascii text mode: convert end-of-lines using local conventions. This option +is supported only on some non-Unix systems. For MSDOS, CR LF is converted +to LF when compressing, and LF is converted to CR LF when decompressing. +.TP +.B \-c --stdout --to-stdout +Write output on standard output; keep original files unchanged. +If there are several input files, the output consists of a sequence of +independently compressed members. To obtain better compression, +concatenate all input files before compressing them. +.TP +.B \-d --decompress --uncompress +Decompress. +.TP +.B \-f --force +Force compression or decompression even if the file has multiple links +or the corresponding file already exists, or if the compressed data +is read from or written to a terminal. If the input data is not in +a format recognized by +.I gzip, +and if the option --stdout is also given, copy the input data without change +to the standard ouput: let +.I zcat +behave as +.I cat. +If +.B \-f +is not given, +and when not running in the background, +.I gzip +prompts to verify whether an existing file should be overwritten. +.TP +.B \-h --help +Display a help screen and quit. +.TP +.B \-l --list +For each compressed file, list the following fields: + + compressed size: size of the compressed file + uncompressed size: size of the uncompressed file + ratio: compression ratio (0.0% if unknown) + uncompressed_name: name of the uncompressed file + +The uncompressed size is given as -1 for files not in gzip format, +such as compressed .Z files. To get the uncompressed size for such a file, +you can use: + + zcat file.Z | wc -c + +In combination with the --verbose option, the following fields are also +displayed: + + method: compression method + crc: the 32-bit CRC of the uncompressed data + date & time: time stamp for the uncompressed file + +The compression methods currently supported are deflate, compress, lzh +(SCO compress -H) and pack. The crc is given as ffffffff for a file +not in gzip format. + +With --name, the uncompressed name, date and time are +those stored within the compress file if present. + +With --verbose, the size totals and compression ratio for all files +is also displayed, unless some sizes are unknown. With --quiet, +the title and totals lines are not displayed. +.TP +.B \-L --license +Display the +.I gzip +license and quit. +.TP +.B \-n --no-name +When compressing, do not save the original file name and time stamp by +default. (The original name is always saved if the name had to be +truncated.) When decompressing, do not restore the original file name +if present (remove only the +.I gzip +suffix from the compressed file name) and do not restore the original +time stamp if present (copy it from the compressed file). This option +is the default when decompressing. +.TP +.B \-N --name +When compressing, always save the original file name and time stamp; this +is the default. When decompressing, restore the original file name and +time stamp if present. This option is useful on systems which have +a limit on file name length or when the time stamp has been lost after +a file transfer. +.TP +.B \-q --quiet +Suppress all warnings. +.TP +.B \-r --recursive +Travel the directory structure recursively. If any of the file names +specified on the command line are directories, +.I gzip +will descend into the directory and compress all the files it finds there +(or decompress them in the case of +.I gunzip +). +.TP +.B \-S .suf --suffix .suf +Use suffix .suf instead of .gz. Any suffix can be given, but suffixes +other than .z and .gz should be avoided to avoid confusion when files +are transferred to other systems. A null suffix forces gunzip to try +decompression on all given files regardless of suffix, as in: + + gunzip -S "" * (*.* for MSDOS) + +Previous versions of gzip used +the .z suffix. This was changed to avoid a conflict with +.IR pack "(1)". +.TP +.B \-t --test +Test. Check the compressed file integrity. +.TP +.B \-v --verbose +Verbose. Display the name and percentage reduction for each file compressed +or decompressed. +.TP +.B \-V --version +Version. Display the version number and compilation options then quit. +.TP +.B \-# --fast --best +Regulate the speed of compression using the specified digit +.IR # , +where +.B \-1 +or +.B \-\-fast +indicates the fastest compression method (less compression) +and +.B \-9 +or +.B \-\-best +indicates the slowest compression method (best compression). +The default compression level is +.BR \-6 +(that is, biased towards high compression at expense of speed). +.SH "ADVANCED USAGE" +Multiple compressed files can be concatenated. In this case, +.I gunzip +will extract all members at once. For example: + + gzip -c file1 > foo.gz + gzip -c file2 >> foo.gz + +Then + gunzip -c foo + +is equivalent to + + cat file1 file2 + +In case of damage to one member of a .gz file, other members can +still be recovered (if the damaged member is removed). However, +you can get better compression by compressing all members at once: + + cat file1 file2 | gzip > foo.gz + +compresses better than + + gzip -c file1 file2 > foo.gz + +If you want to recompress concatenated files to get better compression, do: + + gzip -cd old.gz | gzip > new.gz + +If a compressed file consists of several members, the uncompressed +size and CRC reported by the --list option applies to the last member +only. If you need the uncompressed size for all members, you can use: + + gzip -cd file.gz | wc -c + +If you wish to create a single archive file with multiple members so +that members can later be extracted independently, use an archiver +such as tar or zip. GNU tar supports the -z option to invoke gzip +transparently. gzip is designed as a complement to tar, not as a +replacement. +.SH "ENVIRONMENT" +The environment variable +.B GZIP +can hold a set of default options for +.I gzip. +These options are interpreted first and can be overwritten by +explicit command line parameters. For example: + for sh: GZIP="-8v --name"; export GZIP + for csh: setenv GZIP "-8v --name" + for MSDOS: set GZIP=-8v --name + +On Vax/VMS, the name of the environment variable is GZIP_OPT, to +avoid a conflict with the symbol set for invocation of the program. +.SH "SEE ALSO" +znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), compress(1), +pack(1), compact(1) +.SH "DIAGNOSTICS" +Exit status is normally 0; +if an error occurs, exit status is 1. If a warning occurs, exit status is 2. +.PP +Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...] +.in +8 +Invalid options were specified on the command line. +.in -8 +.IR file : +not in gzip format +.in +8 +The file specified to +.I gunzip +has not been compressed. +.in -8 +.IR file: +Corrupt input. Use zcat to recover some data. +.in +8 +The compressed file has been damaged. The data up to the point of failure +can be recovered using +.in +8 +zcat file > recover +.in -16 +.IR file : +compressed with +.I xx +bits, can only handle +.I yy +bits +.in +8 +.I File +was compressed (using LZW) by a program that could deal with +more +.I bits +than the decompress code on this machine. +Recompress the file with gzip, which compresses better and uses +less memory. +.in -8 +.IR file : +already has .gz suffix -- no change +.in +8 +The file is assumed to be already compressed. +Rename the file and try again. +.in -8 +.I file +already exists; do you wish to overwrite (y or n)? +.in +8 +Respond "y" if you want the output file to be replaced; "n" if not. +.in -8 +gunzip: corrupt input +.in +8 +A SIGSEGV violation was detected which usually means that the input file has +been corrupted. +.in -8 +.I "xx.x%" +.in +8 +Percentage of the input saved by compression. +(Relevant only for +.BR \-v +and +.BR \-l \.) +.in -8 +-- not a regular file or directory: ignored +.in +8 +When the input file is not a regular file or directory, +(e.g. a symbolic link, socket, FIFO, device file), it is +left unaltered. +.in -8 +-- has +.I xx +other links: unchanged +.in +8 +The input file has links; it is left unchanged. See +.IR ln "(1)" +for more information. Use the +.B \-f +flag to force compression of multiply-linked files. +.in -8 +.SH CAVEATS +When writing compressed data to a tape, it is generally necessary to +pad the output with zeroes up to a block boundary. When the data is +read and the whole block is passed to +.I gunzip +for decompression, +.I gunzip +detects that there is extra trailing garbage after the compressed data +and emits a warning by default. You have to use the --quiet option to +suppress the warning. This option can be set in the +.B GZIP +environment variable as in: + for sh: GZIP="-q" tar -xfz --block-compress /dev/rst0 + for csh: (setenv GZIP -q; tar -xfz --block-compr /dev/rst0 + +In the above example, gzip is invoked implicitly by the -z option of +GNU tar. Make sure that the same block size (-b option of tar) is used +for reading and writing compressed data on tapes. (This example +assumes you are using the GNU version of tar.) +.SH BUGS +The --list option reports incorrect sizes if they exceed 2 gigabytes. +The --list option reports sizes as -1 and crc as ffffffff if the +compressed file is on a non seekable media. + +In some rare cases, the --best option gives worse compression than +the default compression level (-6). On some highly redundant files, +.I compress +compresses better than +.I gzip. diff --git a/tools/gzip-1.2.4/gzip.c b/tools/gzip-1.2.4/gzip.c new file mode 100644 index 00000000..09fe9a16 --- /dev/null +++ b/tools/gzip-1.2.4/gzip.c @@ -0,0 +1,1744 @@ +/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface + * Copyright (C) 1992-1993 Jean-loup Gailly + * The unzip code was written and put in the public domain by Mark Adler. + * Portions of the lzw code are derived from the public domain 'compress' + * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, + * Ken Turkowski, Dave Mack and Peter Jannesen. + * + * See the license_msg below and the file COPYING for the software license. + * See the file algorithm.doc for the compression algorithms and file formats. + */ + +static char *license_msg[] = { +" Copyright (C) 1992-1993 Jean-loup Gailly", +" This program is free software; you can redistribute it and/or modify", +" it under the terms of the GNU General Public License as published by", +" the Free Software Foundation; either version 2, or (at your option)", +" any later version.", +"", +" This program is distributed in the hope that it will be useful,", +" but WITHOUT ANY WARRANTY; without even the implied warranty of", +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", +" GNU General Public License for more details.", +"", +" You should have received a copy of the GNU General Public License", +" along with this program; if not, write to the Free Software", +" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.", +0}; + +/* Compress files with zip algorithm and 'compress' interface. + * See usage() and help() functions below for all options. + * Outputs: + * file.gz: compressed file with same mode, owner, and utimes + * or stdout with -c option or if stdin used as input. + * If the output file name had to be truncated, the original name is kept + * in the compressed file. + * On MSDOS, file.tmp -> file.tmz. On VMS, file.tmp -> file.tmp-gz. + * + * Using gz on MSDOS would create too many file name conflicts. For + * example, foo.txt -> foo.tgz (.tgz must be reserved as shorthand for + * tar.gz). Similarly, foo.dir and foo.doc would both be mapped to foo.dgz. + * I also considered 12345678.txt -> 12345txt.gz but this truncates the name + * too heavily. There is no ideal solution given the MSDOS 8+3 limitation. + * + * For the meaning of all compilation flags, see comments in Makefile.in. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: gzip.c,v 0.24 1993/06/24 10:52:07 jloup Exp $"; +#endif + +#include +#include +#include +#include +#include + +#include "tailor.h" +#include "gzip.h" +#include "lzw.h" +#include "revision.h" +#include "getopt.h" + + /* configuration */ + +#ifdef NO_TIME_H +# include +#else +# include +#endif + +#ifndef NO_FCNTL_H +# include +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif + +#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) +# include +#else + extern int errno; +#endif + +#if defined(DIRENT) +# include + typedef struct dirent dir_type; +# define NLENGTH(dirent) ((int)strlen((dirent)->d_name)) +# define DIR_OPT "DIRENT" +#else +# define NLENGTH(dirent) ((dirent)->d_namlen) +# ifdef SYSDIR +# include + typedef struct direct dir_type; +# define DIR_OPT "SYSDIR" +# else +# ifdef SYSNDIR +# include + typedef struct direct dir_type; +# define DIR_OPT "SYSNDIR" +# else +# ifdef NDIR +# include + typedef struct direct dir_type; +# define DIR_OPT "NDIR" +# else +# define NO_DIR +# define DIR_OPT "NO_DIR" +# endif +# endif +# endif +#endif + +#ifndef NO_UTIME +# ifndef NO_UTIME_H +# include +# define TIME_OPT "UTIME" +# else +# ifdef HAVE_SYS_UTIME_H +# include +# define TIME_OPT "SYS_UTIME" +# else + struct utimbuf { + time_t actime; + time_t modtime; + }; +# define TIME_OPT "" +# endif +# endif +#else +# define TIME_OPT "NO_UTIME" +#endif + +#if !defined(S_ISDIR) && defined(S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif +#if !defined(S_ISREG) && defined(S_IFREG) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +typedef RETSIGTYPE (*sig_type) OF((int)); + +#ifndef O_BINARY +# define O_BINARY 0 /* creation mode for open() */ +#endif + +#ifndef O_CREAT + /* Pure BSD system? */ +# include +# ifndef O_CREAT +# define O_CREAT FCREAT +# endif +# ifndef O_EXCL +# define O_EXCL FEXCL +# endif +#endif + +#ifndef S_IRUSR +# define S_IRUSR 0400 +#endif +#ifndef S_IWUSR +# define S_IWUSR 0200 +#endif +#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */ + +#ifndef MAX_PATH_LEN +# define MAX_PATH_LEN 1024 /* max pathname length */ +#endif + +#ifndef SEEK_END +# define SEEK_END 2 +#endif + +#ifdef NO_OFF_T + typedef long off_t; + off_t lseek OF((int fd, off_t offset, int whence)); +#endif + +/* Separator for file name parts (see shorten_name()) */ +#ifdef NO_MULTIPLE_DOTS +# define PART_SEP "-" +#else +# define PART_SEP "." +#endif + + /* global buffers */ + +DECLARE(uch, inbuf, INBUFSIZ +INBUF_EXTRA); +DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA); +DECLARE(ush, d_buf, DIST_BUFSIZE); +DECLARE(uch, window, 2L*WSIZE); +#ifndef MAXSEG_64K + DECLARE(ush, tab_prefix, 1L< 4 && strequ(progname+proglen-4, ".exe")) { + progname[proglen-4] = '\0'; + } + + /* Add options in GZIP environment variable if there is one */ + env = add_envopt(&argc, &argv, OPTIONS_VAR); + if (env != NULL) args = argv; + + foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; + if (foreground) { + (void) signal (SIGINT, (sig_type)abort_gzip); + } +#ifdef SIGTERM + if (signal(SIGTERM, SIG_IGN) != SIG_IGN) { + (void) signal(SIGTERM, (sig_type)abort_gzip); + } +#endif +#ifdef SIGHUP + if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { + (void) signal(SIGHUP, (sig_type)abort_gzip); + } +#endif + +#ifndef GNU_STANDARD + /* For compatibility with old compress, use program name as an option. + * If you compile with -DGNU_STANDARD, this program will behave as + * gzip even if it is invoked under the name gunzip or zcat. + * + * Systems which do not support links can still use -d or -dc. + * Ignore an .exe extension for MSDOS, OS/2 and VMS. + */ + if ( strncmp(progname, "un", 2) == 0 /* ungzip, uncompress */ + || strncmp(progname, "gun", 3) == 0) { /* gunzip */ + decompress = 1; + } else if (strequ(progname+1, "cat") /* zcat, pcat, gcat */ + || strequ(progname, "gzcat")) { /* gzcat */ + decompress = to_stdout = 1; + } +#endif + + strncpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)-1); + z_len = strlen(z_suffix); + + while ((optc = getopt_long (argc, argv, "ab:cdfhH?lLmMnNqrS:tvVZ123456789", + longopts, (int *)0)) != EOF) { + switch (optc) { + case 'a': + ascii = 1; break; + case 'b': + maxbits = atoi(optarg); + break; + case 'c': + to_stdout = 1; break; + case 'd': + decompress = 1; break; + case 'f': + force++; break; + case 'h': case 'H': case '?': + help(); do_exit(OK); break; + case 'l': + list = decompress = to_stdout = 1; break; + case 'L': + license(); do_exit(OK); break; + case 'm': /* undocumented, may change later */ + no_time = 1; break; + case 'M': /* undocumented, may change later */ + no_time = 0; break; + case 'n': + no_name = no_time = 1; break; + case 'N': + no_name = no_time = 0; break; + case 'q': + quiet = 1; verbose = 0; break; + case 'r': +#ifdef NO_DIR + fprintf(stderr, "%s: -r not supported on this system\n", progname); + usage(); + do_exit(ERROR); break; +#else + recursive = 1; break; +#endif + case 'S': +#ifdef NO_MULTIPLE_DOTS + if (*optarg == '.') optarg++; +#endif + z_len = strlen(optarg); + strcpy(z_suffix, optarg); + break; + case 't': + test = decompress = to_stdout = 1; + break; + case 'v': + verbose++; quiet = 0; break; + case 'V': + version(); do_exit(OK); break; + case 'Z': +#ifdef LZW + do_lzw = 1; break; +#else + fprintf(stderr, "%s: -Z not supported in this version\n", + progname); + usage(); + do_exit(ERROR); break; +#endif + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + level = optc - '0'; + break; + default: + /* Error message already emitted by getopt_long. */ + usage(); + do_exit(ERROR); + } + } /* loop on all arguments */ + + /* By default, save name and timestamp on compression but do not + * restore them on decompression. + */ + if (no_time < 0) no_time = decompress; + if (no_name < 0) no_name = decompress; + + file_count = argc - optind; + +#if O_BINARY +#else + if (ascii && !quiet) { + fprintf(stderr, "%s: option --ascii ignored on this system\n", + progname); + } +#endif + if ((z_len == 0 && !decompress) || z_len > MAX_SUFFIX) { + fprintf(stderr, "%s: incorrect suffix '%s'\n", + progname, optarg); + do_exit(ERROR); + } + if (do_lzw && !decompress) work = lzw; + + /* Allocate all global buffers (for DYN_ALLOC option) */ + ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA); + ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA); + ALLOC(ush, d_buf, DIST_BUFSIZE); + ALLOC(uch, window, 2L*WSIZE); +#ifndef MAXSEG_64K + ALLOC(ush, tab_prefix, 1L< 1) { + do_list(-1, -1); /* print totals */ + } + do_exit(exit_code); + return exit_code; /* just to avoid lint warning */ +} + +/* ======================================================================== + * Compress or decompress stdin + */ +local void treat_stdin() +{ + if (!force && !list && + isatty(fileno((FILE *)(decompress ? stdin : stdout)))) { + /* Do not send compressed data to the terminal or read it from + * the terminal. We get here when user invoked the program + * without parameters, so be helpful. According to the GNU standards: + * + * If there is one behavior you think is most useful when the output + * is to a terminal, and another that you think is most useful when + * the output is a file or a pipe, then it is usually best to make + * the default behavior the one that is useful with output to a + * terminal, and have an option for the other behavior. + * + * Here we use the --force option to get the other behavior. + */ + fprintf(stderr, + "%s: compressed data not %s a terminal. Use -f to force %scompression.\n", + progname, decompress ? "read from" : "written to", + decompress ? "de" : ""); + fprintf(stderr,"For help, type: %s -h\n", progname); + do_exit(ERROR); + } + + if (decompress || !ascii) { + SET_BINARY_MODE(fileno(stdin)); + } + if (!test && !list && (!decompress || !ascii)) { + SET_BINARY_MODE(fileno(stdout)); + } + strcpy(ifname, "stdin"); + strcpy(ofname, "stdout"); + + /* Get the time stamp on the input file. */ + time_stamp = 0; /* time unknown by default */ + +#ifndef NO_STDIN_FSTAT + if (list || !no_time) { + if (fstat(fileno(stdin), &istat) != 0) { + error("fstat(stdin)"); + } +# ifdef NO_PIPE_TIMESTAMP + if (S_ISREG(istat.st_mode)) +# endif + time_stamp = istat.st_mtime; +#endif /* NO_STDIN_FSTAT */ + } + ifile_size = -1L; /* convention for unknown size */ + + clear_bufs(); /* clear input and output buffers */ + to_stdout = 1; + part_nb = 0; + + if (decompress) { + method = get_method(ifd); + if (method < 0) { + do_exit(exit_code); /* error message already emitted */ + } + } + if (list) { + do_list(ifd, method); + return; + } + + /* Actually do the compression/decompression. Loop over zipped members. + */ + for (;;) { + if ((*work)(fileno(stdin), fileno(stdout)) != OK) return; + + if (!decompress || last_member || inptr == insize) break; + /* end of file */ + + method = get_method(ifd); + if (method < 0) return; /* error message already emitted */ + bytes_out = 0; /* required for length check */ + } + + if (verbose) { + if (test) { + fprintf(stderr, " OK\n"); + + } else if (!decompress) { + display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr); + fprintf(stderr, "\n"); +#ifdef DISPLAY_STDIN_RATIO + } else { + display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out,stderr); + fprintf(stderr, "\n"); +#endif + } + } +} + +/* ======================================================================== + * Compress or decompress the given file + */ +local void treat_file(iname) + char *iname; +{ + /* Accept "-" as synonym for stdin */ + if (strequ(iname, "-")) { + int cflag = to_stdout; + treat_stdin(); + to_stdout = cflag; + return; + } + + /* Check if the input file is present, set ifname and istat: */ + if (get_istat(iname, &istat) != OK) return; + + /* If the input name is that of a directory, recurse or ignore: */ + if (S_ISDIR(istat.st_mode)) { +#ifndef NO_DIR + if (recursive) { + struct stat st; + st = istat; + treat_dir(iname); + /* Warning: ifname is now garbage */ +# ifndef NO_UTIME + reset_times (iname, &st); +# endif + } else +#endif + WARN((stderr,"%s: %s is a directory -- ignored\n", progname, ifname)); + return; + } + if (!S_ISREG(istat.st_mode)) { + WARN((stderr, + "%s: %s is not a directory or a regular file - ignored\n", + progname, ifname)); + return; + } + if (istat.st_nlink > 1 && !to_stdout && !force) { + WARN((stderr, "%s: %s has %d other link%c -- unchanged\n", + progname, ifname, + (int)istat.st_nlink - 1, istat.st_nlink > 2 ? 's' : ' ')); + return; + } + + ifile_size = istat.st_size; + time_stamp = no_time && !list ? 0 : istat.st_mtime; + + /* Generate output file name. For -r and (-t or -l), skip files + * without a valid gzip suffix (check done in make_ofname). + */ + if (to_stdout && !list && !test) { + strcpy(ofname, "stdout"); + + } else if (make_ofname() != OK) { + return; + } + + /* Open the input file and determine compression method. The mode + * parameter is ignored but required by some systems (VMS) and forbidden + * on other systems (MacOS). + */ + ifd = OPEN(ifname, ascii && !decompress ? O_RDONLY : O_RDONLY | O_BINARY, + RW_USER); + if (ifd == -1) { + fprintf(stderr, "%s: ", progname); + perror(ifname); + exit_code = ERROR; + return; + } + clear_bufs(); /* clear input and output buffers */ + part_nb = 0; + + if (decompress) { + method = get_method(ifd); /* updates ofname if original given */ + if (method < 0) { + close(ifd); + return; /* error message already emitted */ + } + } + if (list) { + do_list(ifd, method); + close(ifd); + return; + } + + /* If compressing to a file, check if ofname is not ambiguous + * because the operating system truncates names. Otherwise, generate + * a new ofname and save the original name in the compressed file. + */ + if (to_stdout) { + ofd = fileno(stdout); + /* keep remove_ofname as zero */ + } else { + if (create_outfile() != OK) return; + + if (!decompress && save_orig_name && !verbose && !quiet) { + fprintf(stderr, "%s: %s compressed to %s\n", + progname, ifname, ofname); + } + } + /* Keep the name even if not truncated except with --no-name: */ + if (!save_orig_name) save_orig_name = !no_name; + + if (verbose) { + fprintf(stderr, "%s:\t%s", ifname, (int)strlen(ifname) >= 15 ? + "" : ((int)strlen(ifname) >= 7 ? "\t" : "\t\t")); + } + + /* Actually do the compression/decompression. Loop over zipped members. + */ + for (;;) { + if ((*work)(ifd, ofd) != OK) { + method = -1; /* force cleanup */ + break; + } + if (!decompress || last_member || inptr == insize) break; + /* end of file */ + + method = get_method(ifd); + if (method < 0) break; /* error message already emitted */ + bytes_out = 0; /* required for length check */ + } + + close(ifd); + if (!to_stdout && close(ofd)) { + write_error(); + } + if (method == -1) { + if (!to_stdout) unlink (ofname); + return; + } + /* Display statistics */ + if(verbose) { + if (test) { + fprintf(stderr, " OK"); + } else if (decompress) { + display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out,stderr); + } else { + display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr); + } + if (!test && !to_stdout) { + fprintf(stderr, " -- replaced with %s", ofname); + } + fprintf(stderr, "\n"); + } + /* Copy modes, times, ownership, and remove the input file */ + if (!to_stdout) { + copy_stat(&istat); + } +} + +/* ======================================================================== + * Create the output file. Return OK or ERROR. + * Try several times if necessary to avoid truncating the z_suffix. For + * example, do not create a compressed file of name "1234567890123." + * Sets save_orig_name to true if the file name has been truncated. + * IN assertions: the input file has already been open (ifd is set) and + * ofname has already been updated if there was an original name. + * OUT assertions: ifd and ofd are closed in case of error. + */ +local int create_outfile() +{ + struct stat ostat; /* stat for ofname */ + int flags = O_WRONLY | O_CREAT | O_EXCL | O_BINARY; + + if (ascii && decompress) { + flags &= ~O_BINARY; /* force ascii text mode */ + } + for (;;) { + /* Make sure that ofname is not an existing file */ + if (check_ofname() != OK) { + close(ifd); + return ERROR; + } + /* Create the output file */ + remove_ofname = 1; + ofd = OPEN(ofname, flags, RW_USER); + if (ofd == -1) { + perror(ofname); + close(ifd); + exit_code = ERROR; + return ERROR; + } + + /* Check for name truncation on new file (1234567890123.gz) */ +#ifdef NO_FSTAT + if (stat(ofname, &ostat) != 0) { +#else + if (fstat(ofd, &ostat) != 0) { +#endif + fprintf(stderr, "%s: ", progname); + perror(ofname); + close(ifd); close(ofd); + unlink(ofname); + exit_code = ERROR; + return ERROR; + } + if (!name_too_long(ofname, &ostat)) return OK; + + if (decompress) { + /* name might be too long if an original name was saved */ + WARN((stderr, "%s: %s: warning, name truncated\n", + progname, ofname)); + return OK; + } + close(ofd); + unlink(ofname); +#ifdef NO_MULTIPLE_DOTS + /* Should never happen, see check_ofname() */ + fprintf(stderr, "%s: %s: name too long\n", progname, ofname); + do_exit(ERROR); +#endif + shorten_name(ofname); + } +} + +/* ======================================================================== + * Use lstat if available, except for -c or -f. Use stat otherwise. + * This allows links when not removing the original file. + */ +local int do_stat(name, sbuf) + char *name; + struct stat *sbuf; +{ + errno = 0; +#if (defined(S_IFLNK) || defined (S_ISLNK)) && !defined(NO_SYMLINK) + if (!to_stdout && !force) { + return lstat(name, sbuf); + } +#endif + return stat(name, sbuf); +} + +/* ======================================================================== + * Return a pointer to the 'z' suffix of a file name, or NULL. For all + * systems, ".gz", ".z", ".Z", ".taz", ".tgz", "-gz", "-z" and "_z" are + * accepted suffixes, in addition to the value of the --suffix option. + * ".tgz" is a useful convention for tar.z files on systems limited + * to 3 characters extensions. On such systems, ".?z" and ".??z" are + * also accepted suffixes. For Unix, we do not want to accept any + * .??z suffix as indicating a compressed file; some people use .xyz + * to denote volume data. + * On systems allowing multiple versions of the same file (such as VMS), + * this function removes any version suffix in the given name. + */ +local char *get_suffix(name) + char *name; +{ + int nlen, slen; + char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */ + static char *known_suffixes[] = + {z_suffix, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z", +#ifdef MAX_EXT_CHARS + "z", +#endif + NULL}; + char **suf = known_suffixes; + + if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */ + +#ifdef SUFFIX_SEP + /* strip a version number from the file name */ + { + char *v = strrchr(name, SUFFIX_SEP); + if (v != NULL) *v = '\0'; + } +#endif + nlen = strlen(name); + if (nlen <= MAX_SUFFIX+2) { + strcpy(suffix, name); + } else { + strcpy(suffix, name+nlen-MAX_SUFFIX-2); + } + strlwr(suffix); + slen = strlen(suffix); + do { + int s = strlen(*suf); + if (slen > s && suffix[slen-s-1] != PATH_SEP + && strequ(suffix + slen - s, *suf)) { + return name+nlen-s; + } + } while (*++suf != NULL); + + return NULL; +} + + +/* ======================================================================== + * Set ifname to the input file name (with a suffix appended if necessary) + * and istat to its stats. For decompression, if no file exists with the + * original name, try adding successively z_suffix, .gz, .z, -z and .Z. + * For MSDOS, we try only z_suffix and z. + * Return OK or ERROR. + */ +local int get_istat(iname, sbuf) + char *iname; + struct stat *sbuf; +{ + int ilen; /* strlen(ifname) */ + static char *suffixes[] = {z_suffix, ".gz", ".z", "-z", ".Z", NULL}; + char **suf = suffixes; + char *s; +#ifdef NO_MULTIPLE_DOTS + char *dot; /* pointer to ifname extension, or NULL */ +#endif + + strcpy(ifname, iname); + + /* If input file exists, return OK. */ + if (do_stat(ifname, sbuf) == 0) return OK; + + if (!decompress || errno != ENOENT) { + perror(ifname); + exit_code = ERROR; + return ERROR; + } + /* file.ext doesn't exist, try adding a suffix (after removing any + * version number for VMS). + */ + s = get_suffix(ifname); + if (s != NULL) { + perror(ifname); /* ifname already has z suffix and does not exist */ + exit_code = ERROR; + return ERROR; + } +#ifdef NO_MULTIPLE_DOTS + dot = strrchr(ifname, '.'); + if (dot == NULL) { + strcat(ifname, "."); + dot = strrchr(ifname, '.'); + } +#endif + ilen = strlen(ifname); + if (strequ(z_suffix, ".gz")) suf++; + + /* Search for all suffixes */ + do { + s = *suf; +#ifdef NO_MULTIPLE_DOTS + if (*s == '.') s++; +#endif +#ifdef MAX_EXT_CHARS + strcpy(ifname, iname); + /* Needed if the suffixes are not sorted by increasing length */ + + if (*dot == '\0') strcpy(dot, "."); + dot[MAX_EXT_CHARS+1-strlen(s)] = '\0'; +#endif + strcat(ifname, s); + if (do_stat(ifname, sbuf) == 0) return OK; + ifname[ilen] = '\0'; + } while (*++suf != NULL); + + /* No suffix found, complain using z_suffix: */ +#ifdef MAX_EXT_CHARS + strcpy(ifname, iname); + if (*dot == '\0') strcpy(dot, "."); + dot[MAX_EXT_CHARS+1-z_len] = '\0'; +#endif + strcat(ifname, z_suffix); + perror(ifname); + exit_code = ERROR; + return ERROR; +} + +/* ======================================================================== + * Generate ofname given ifname. Return OK, or WARNING if file must be skipped. + * Sets save_orig_name to true if the file name has been truncated. + */ +local int make_ofname() +{ + char *suff; /* ofname z suffix */ + + strcpy(ofname, ifname); + /* strip a version number if any and get the gzip suffix if present: */ + suff = get_suffix(ofname); + + if (decompress) { + if (suff == NULL) { + /* Whith -t or -l, try all files (even without .gz suffix) + * except with -r (behave as with just -dr). + */ + if (!recursive && (list || test)) return OK; + + /* Avoid annoying messages with -r */ + if (verbose || (!recursive && !quiet)) { + WARN((stderr,"%s: %s: unknown suffix -- ignored\n", + progname, ifname)); + } + return WARNING; + } + /* Make a special case for .tgz and .taz: */ + strlwr(suff); + if (strequ(suff, ".tgz") || strequ(suff, ".taz")) { + strcpy(suff, ".tar"); + } else { + *suff = '\0'; /* strip the z suffix */ + } + /* ofname might be changed later if infile contains an original name */ + + } else if (suff != NULL) { + /* Avoid annoying messages with -r (see treat_dir()) */ + if (verbose || (!recursive && !quiet)) { + fprintf(stderr, "%s: %s already has %s suffix -- unchanged\n", + progname, ifname, suff); + } + if (exit_code == OK) exit_code = WARNING; + return WARNING; + } else { + save_orig_name = 0; + +#ifdef NO_MULTIPLE_DOTS + suff = strrchr(ofname, '.'); + if (suff == NULL) { + strcat(ofname, "."); +# ifdef MAX_EXT_CHARS + if (strequ(z_suffix, "z")) { + strcat(ofname, "gz"); /* enough room */ + return OK; + } + /* On the Atari and some versions of MSDOS, name_too_long() + * does not work correctly because of a bug in stat(). So we + * must truncate here. + */ + } else if (strlen(suff)-1 + z_len > MAX_SUFFIX) { + suff[MAX_SUFFIX+1-z_len] = '\0'; + save_orig_name = 1; +# endif + } +#endif /* NO_MULTIPLE_DOTS */ + strcat(ofname, z_suffix); + + } /* decompress ? */ + return OK; +} + + +/* ======================================================================== + * Check the magic number of the input file and update ofname if an + * original name was given and to_stdout is not set. + * Return the compression method, -1 for error, -2 for warning. + * Set inptr to the offset of the next byte to be processed. + * Updates time_stamp if there is one and --no-time is not used. + * This function may be called repeatedly for an input file consisting + * of several contiguous gzip'ed members. + * IN assertions: there is at least one remaining compressed member. + * If the member is a zip file, it must be the only one. + */ +local int get_method(in) + int in; /* input file descriptor */ +{ + uch flags; /* compression flags */ + char magic[2]; /* magic header */ + ulg stamp; /* time stamp */ + + /* If --force and --stdout, zcat == cat, so do not complain about + * premature end of file: use try_byte instead of get_byte. + */ + if (force && to_stdout) { + magic[0] = (char)try_byte(); + magic[1] = (char)try_byte(); + /* If try_byte returned EOF, magic[1] == 0xff */ + } else { + magic[0] = (char)get_byte(); + magic[1] = (char)get_byte(); + } + method = -1; /* unknown yet */ + part_nb++; /* number of parts in gzip file */ + header_bytes = 0; + last_member = RECORD_IO; + /* assume multiple members in gzip file except for record oriented I/O */ + + if (memcmp(magic, GZIP_MAGIC, 2) == 0 + || memcmp(magic, OLD_GZIP_MAGIC, 2) == 0) { + + method = (int)get_byte(); + if (method != DEFLATED) { + fprintf(stderr, + "%s: %s: unknown method %d -- get newer version of gzip\n", + progname, ifname, method); + exit_code = ERROR; + return -1; + } + work = unzip; + flags = (uch)get_byte(); + + if ((flags & ENCRYPTED) != 0) { + fprintf(stderr, + "%s: %s is encrypted -- get newer version of gzip\n", + progname, ifname); + exit_code = ERROR; + return -1; + } + if ((flags & CONTINUATION) != 0) { + fprintf(stderr, + "%s: %s is a a multi-part gzip file -- get newer version of gzip\n", + progname, ifname); + exit_code = ERROR; + if (force <= 1) return -1; + } + if ((flags & RESERVED) != 0) { + fprintf(stderr, + "%s: %s has flags 0x%x -- get newer version of gzip\n", + progname, ifname, flags); + exit_code = ERROR; + if (force <= 1) return -1; + } + stamp = (ulg)get_byte(); + stamp |= ((ulg)get_byte()) << 8; + stamp |= ((ulg)get_byte()) << 16; + stamp |= ((ulg)get_byte()) << 24; + if (stamp != 0 && !no_time) time_stamp = stamp; + + (void)get_byte(); /* Ignore extra flags for the moment */ + (void)get_byte(); /* Ignore OS type for the moment */ + + if ((flags & CONTINUATION) != 0) { + unsigned part = (unsigned)get_byte(); + part |= ((unsigned)get_byte())<<8; + if (verbose) { + fprintf(stderr,"%s: %s: part number %u\n", + progname, ifname, part); + } + } + if ((flags & EXTRA_FIELD) != 0) { + unsigned len = (unsigned)get_byte(); + len |= ((unsigned)get_byte())<<8; + if (verbose) { + fprintf(stderr,"%s: %s: extra field of %u bytes ignored\n", + progname, ifname, len); + } + while (len--) (void)get_byte(); + } + + /* Get original file name if it was truncated */ + if ((flags & ORIG_NAME) != 0) { + if (no_name || (to_stdout && !list) || part_nb > 1) { + /* Discard the old name */ + char c; /* dummy used for NeXTstep 3.0 cc optimizer bug */ + do {c=get_byte();} while (c != 0); + } else { + /* Copy the base name. Keep a directory prefix intact. */ + char *p = basename(ofname); + char *base = p; + for (;;) { + *p = (char)get_char(); + if (*p++ == '\0') break; + if (p >= ofname+sizeof(ofname)) { + error("corrupted input -- file name too large"); + } + } + /* If necessary, adapt the name to local OS conventions: */ + if (!list) { + MAKE_LEGAL_NAME(base); + if (base) list=0; /* avoid warning about unused variable */ + } + } /* no_name || to_stdout */ + } /* ORIG_NAME */ + + /* Discard file comment if any */ + if ((flags & COMMENT) != 0) { + while (get_char() != 0) /* null */ ; + } + if (part_nb == 1) { + header_bytes = inptr + 2*sizeof(long); /* include crc and size */ + } + + } else if (memcmp(magic, PKZIP_MAGIC, 2) == 0 && inptr == 2 + && memcmp((char*)inbuf, PKZIP_MAGIC, 4) == 0) { + /* To simplify the code, we support a zip file when alone only. + * We are thus guaranteed that the entire local header fits in inbuf. + */ + inptr = 0; + work = unzip; + if (check_zipfile(in) != OK) return -1; + /* check_zipfile may get ofname from the local header */ + last_member = 1; + + } else if (memcmp(magic, PACK_MAGIC, 2) == 0) { + work = unpack; + method = PACKED; + + } else if (memcmp(magic, LZW_MAGIC, 2) == 0) { + work = unlzw; + method = COMPRESSED; + last_member = 1; + + } else if (memcmp(magic, LZH_MAGIC, 2) == 0) { + work = unlzh; + method = LZHED; + last_member = 1; + + } else if (force && to_stdout && !list) { /* pass input unchanged */ + method = STORED; + work = copy; + inptr = 0; + last_member = 1; + } + if (method >= 0) return method; + + if (part_nb == 1) { + fprintf(stderr, "\n%s: %s: not in gzip format\n", progname, ifname); + exit_code = ERROR; + return -1; + } else { + WARN((stderr, "\n%s: %s: decompression OK, trailing garbage ignored\n", + progname, ifname)); + return -2; + } +} + +/* ======================================================================== + * Display the characteristics of the compressed file. + * If the given method is < 0, display the accumulated totals. + * IN assertions: time_stamp, header_bytes and ifile_size are initialized. + */ +local void do_list(ifd, method) + int ifd; /* input file descriptor */ + int method; /* compression method */ +{ + ulg crc; /* original crc */ + static int first_time = 1; + static char* methods[MAX_METHODS] = { + "store", /* 0 */ + "compr", /* 1 */ + "pack ", /* 2 */ + "lzh ", /* 3 */ + "", "", "", "", /* 4 to 7 reserved */ + "defla"}; /* 8 */ + char *date; + + if (first_time && method >= 0) { + first_time = 0; + if (verbose) { + printf("method crc date time "); + } + if (!quiet) { + printf("compressed uncompr. ratio uncompressed_name\n"); + } + } else if (method < 0) { + if (total_in <= 0 || total_out <= 0) return; + if (verbose) { + printf(" %9lu %9lu ", + total_in, total_out); + } else if (!quiet) { + printf("%9ld %9ld ", total_in, total_out); + } + display_ratio(total_out-(total_in-header_bytes), total_out, stdout); + /* header_bytes is not meaningful but used to ensure the same + * ratio if there is a single file. + */ + printf(" (totals)\n"); + return; + } + crc = (ulg)~0; /* unknown */ + bytes_out = -1L; + bytes_in = ifile_size; + +#if RECORD_IO == 0 + if (method == DEFLATED && !last_member) { + /* Get the crc and uncompressed size for gzip'ed (not zip'ed) files. + * If the lseek fails, we could use read() to get to the end, but + * --list is used to get quick results. + * Use "gunzip < foo.gz | wc -c" to get the uncompressed size if + * you are not concerned about speed. + */ + bytes_in = (long)lseek(ifd, (off_t)(-8), SEEK_END); + if (bytes_in != -1L) { + uch buf[8]; + bytes_in += 8L; + if (read(ifd, (char*)buf, sizeof(buf)) != sizeof(buf)) { + read_error(); + } + crc = LG(buf); + bytes_out = LG(buf+4); + } + } +#endif /* RECORD_IO */ + date = ctime((time_t*)&time_stamp) + 4; /* skip the day of the week */ + date[12] = '\0'; /* suppress the 1/100sec and the year */ + if (verbose) { + printf("%5s %08lx %11s ", methods[method], crc, date); + } + printf("%9ld %9ld ", bytes_in, bytes_out); + if (bytes_in == -1L) { + total_in = -1L; + bytes_in = bytes_out = header_bytes = 0; + } else if (total_in >= 0) { + total_in += bytes_in; + } + if (bytes_out == -1L) { + total_out = -1L; + bytes_in = bytes_out = header_bytes = 0; + } else if (total_out >= 0) { + total_out += bytes_out; + } + display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out, stdout); + printf(" %s\n", ofname); +} + +/* ======================================================================== + * Return true if the two stat structures correspond to the same file. + */ +local int same_file(stat1, stat2) + struct stat *stat1; + struct stat *stat2; +{ + return stat1->st_ino == stat2->st_ino + && stat1->st_dev == stat2->st_dev +#ifdef NO_ST_INO + /* Can't rely on st_ino and st_dev, use other fields: */ + && stat1->st_mode == stat2->st_mode + && stat1->st_uid == stat2->st_uid + && stat1->st_gid == stat2->st_gid + && stat1->st_size == stat2->st_size + && stat1->st_atime == stat2->st_atime + && stat1->st_mtime == stat2->st_mtime + && stat1->st_ctime == stat2->st_ctime +#endif + ; +} + +/* ======================================================================== + * Return true if a file name is ambiguous because the operating system + * truncates file names. + */ +local int name_too_long(name, statb) + char *name; /* file name to check */ + struct stat *statb; /* stat buf for this file name */ +{ + int s = strlen(name); + char c = name[s-1]; + struct stat tstat; /* stat for truncated name */ + int res; + + tstat = *statb; /* Just in case OS does not fill all fields */ + name[s-1] = '\0'; + res = stat(name, &tstat) == 0 && same_file(statb, &tstat); + name[s-1] = c; + Trace((stderr, " too_long(%s) => %d\n", name, res)); + return res; +} + +/* ======================================================================== + * Shorten the given name by one character, or replace a .tar extension + * with .tgz. Truncate the last part of the name which is longer than + * MIN_PART characters: 1234.678.012.gz -> 123.678.012.gz. If the name + * has only parts shorter than MIN_PART truncate the longest part. + * For decompression, just remove the last character of the name. + * + * IN assertion: for compression, the suffix of the given name is z_suffix. + */ +local void shorten_name(name) + char *name; +{ + int len; /* length of name without z_suffix */ + char *trunc = NULL; /* character to be truncated */ + int plen; /* current part length */ + int min_part = MIN_PART; /* current minimum part length */ + char *p; + + len = strlen(name); + if (decompress) { + if (len <= 1) error("name too short"); + name[len-1] = '\0'; + return; + } + p = get_suffix(name); + if (p == NULL) error("can't recover suffix\n"); + *p = '\0'; + save_orig_name = 1; + + /* compress 1234567890.tar to 1234567890.tgz */ + if (len > 4 && strequ(p-4, ".tar")) { + strcpy(p-4, ".tgz"); + return; + } + /* Try keeping short extensions intact: + * 1234.678.012.gz -> 123.678.012.gz + */ + do { + p = strrchr(name, PATH_SEP); + p = p ? p+1 : name; + while (*p) { + plen = strcspn(p, PART_SEP); + p += plen; + if (plen > min_part) trunc = p-1; + if (*p) p++; + } + } while (trunc == NULL && --min_part != 0); + + if (trunc != NULL) { + do { + trunc[0] = trunc[1]; + } while (*trunc++); + trunc--; + } else { + trunc = strrchr(name, PART_SEP[0]); + if (trunc == NULL) error("internal error in shorten_name"); + if (trunc[1] == '\0') trunc--; /* force truncation */ + } + strcpy(trunc, z_suffix); +} + +/* ======================================================================== + * If compressing to a file, check if ofname is not ambiguous + * because the operating system truncates names. Otherwise, generate + * a new ofname and save the original name in the compressed file. + * If the compressed file already exists, ask for confirmation. + * The check for name truncation is made dynamically, because different + * file systems on the same OS might use different truncation rules (on SVR4 + * s5 truncates to 14 chars and ufs does not truncate). + * This function returns -1 if the file must be skipped, and + * updates save_orig_name if necessary. + * IN assertions: save_orig_name is already set if ofname has been + * already truncated because of NO_MULTIPLE_DOTS. The input file has + * already been open and istat is set. + */ +local int check_ofname() +{ + struct stat ostat; /* stat for ofname */ + +#ifdef ENAMETOOLONG + /* Check for strictly conforming Posix systems (which return ENAMETOOLONG + * instead of silently truncating filenames). + */ + errno = 0; + while (stat(ofname, &ostat) != 0) { + if (errno != ENAMETOOLONG) return 0; /* ofname does not exist */ + shorten_name(ofname); + } +#else + if (stat(ofname, &ostat) != 0) return 0; +#endif + /* Check for name truncation on existing file. Do this even on systems + * defining ENAMETOOLONG, because on most systems the strict Posix + * behavior is disabled by default (silent name truncation allowed). + */ + if (!decompress && name_too_long(ofname, &ostat)) { + shorten_name(ofname); + if (stat(ofname, &ostat) != 0) return 0; + } + + /* Check that the input and output files are different (could be + * the same by name truncation or links). + */ + if (same_file(&istat, &ostat)) { + if (strequ(ifname, ofname)) { + fprintf(stderr, "%s: %s: cannot %scompress onto itself\n", + progname, ifname, decompress ? "de" : ""); + } else { + fprintf(stderr, "%s: %s and %s are the same file\n", + progname, ifname, ofname); + } + exit_code = ERROR; + return ERROR; + } + /* Ask permission to overwrite the existing file */ + if (!force) { + char response[80]; + strcpy(response,"n"); + fprintf(stderr, "%s: %s already exists;", progname, ofname); + if (foreground && isatty(fileno(stdin))) { + fprintf(stderr, " do you wish to overwrite (y or n)? "); + fflush(stderr); + (void)fgets(response, sizeof(response)-1, stdin); + } + if (tolow(*response) != 'y') { + fprintf(stderr, "\tnot overwritten\n"); + if (exit_code == OK) exit_code = WARNING; + return ERROR; + } + } + (void) chmod(ofname, 0777); + if (unlink(ofname)) { + fprintf(stderr, "%s: ", progname); + perror(ofname); + exit_code = ERROR; + return ERROR; + } + return OK; +} + + +#ifndef NO_UTIME +/* ======================================================================== + * Set the access and modification times from the given stat buffer. + */ +local void reset_times (name, statb) + char *name; + struct stat *statb; +{ + struct utimbuf timep; + + /* Copy the time stamp */ + timep.actime = statb->st_atime; + timep.modtime = statb->st_mtime; + + /* Some systems (at least OS/2) do not support utime on directories */ + if (utime(name, &timep) && !S_ISDIR(statb->st_mode)) { + WARN((stderr, "%s: ", progname)); + if (!quiet) perror(ofname); + } +} +#endif + + +/* ======================================================================== + * Copy modes, times, ownership from input file to output file. + * IN assertion: to_stdout is false. + */ +local void copy_stat(ifstat) + struct stat *ifstat; +{ +#ifndef NO_UTIME + if (decompress && time_stamp != 0 && ifstat->st_mtime != time_stamp) { + ifstat->st_mtime = time_stamp; + if (verbose > 1) { + fprintf(stderr, "%s: time stamp restored\n", ofname); + } + } + reset_times(ofname, ifstat); +#endif + /* Copy the protection modes */ + if (chmod(ofname, ifstat->st_mode & 07777)) { + WARN((stderr, "%s: ", progname)); + if (!quiet) perror(ofname); + } +#ifndef NO_CHOWN + chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */ +#endif + remove_ofname = 0; + /* It's now safe to remove the input file: */ + (void) chmod(ifname, 0777); + if (unlink(ifname)) { + WARN((stderr, "%s: ", progname)); + if (!quiet) perror(ifname); + } +} + +#ifndef NO_DIR + +/* ======================================================================== + * Recurse through the given directory. This code is taken from ncompress. + */ +local void treat_dir(dir) + char *dir; +{ + dir_type *dp; + DIR *dirp; + char nbuf[MAX_PATH_LEN]; + int len; + + dirp = opendir(dir); + + if (dirp == NULL) { + fprintf(stderr, "%s: %s unreadable\n", progname, dir); + exit_code = ERROR; + return ; + } + /* + ** WARNING: the following algorithm could occasionally cause + ** compress to produce error warnings of the form ".gz + ** already has .gz suffix - ignored". This occurs when the + ** .gz output file is inserted into the directory below + ** readdir's current pointer. + ** These warnings are harmless but annoying, so they are suppressed + ** with option -r (except when -v is on). An alternative + ** to allowing this would be to store the entire directory + ** list in memory, then compress the entries in the stored + ** list. Given the depth-first recursive algorithm used here, + ** this could use up a tremendous amount of memory. I don't + ** think it's worth it. -- Dave Mack + ** (An other alternative might be two passes to avoid depth-first.) + */ + + while ((dp = readdir(dirp)) != NULL) { + + if (strequ(dp->d_name,".") || strequ(dp->d_name,"..")) { + continue; + } + len = strlen(dir); + if (len + NLENGTH(dp) + 1 < MAX_PATH_LEN - 1) { + strcpy(nbuf,dir); + if (len != 0 /* dir = "" means current dir on Amiga */ +#ifdef PATH_SEP2 + && dir[len-1] != PATH_SEP2 +#endif +#ifdef PATH_SEP3 + && dir[len-1] != PATH_SEP3 +#endif + ) { + nbuf[len++] = PATH_SEP; + } + strcpy(nbuf+len, dp->d_name); + treat_file(nbuf); + } else { + fprintf(stderr,"%s: %s/%s: pathname too long\n", + progname, dir, dp->d_name); + exit_code = ERROR; + } + } + closedir(dirp); +} +#endif /* ? NO_DIR */ + +/* ======================================================================== + * Free all dynamically allocated variables and exit with the given code. + */ +local void do_exit(exitcode) + int exitcode; +{ + static int in_exit = 0; + + if (in_exit) exit(exitcode); + in_exit = 1; + if (env != NULL) free(env), env = NULL; + if (args != NULL) free((char*)args), args = NULL; + FREE(inbuf); + FREE(outbuf); + FREE(d_buf); + FREE(window); +#ifndef MAXSEG_64K + FREE(tab_prefix); +#else + FREE(tab_prefix0); + FREE(tab_prefix1); +#endif + exit(exitcode); +} + +/* ======================================================================== + * Signal and error handler. + */ +RETSIGTYPE abort_gzip() +{ + if (remove_ofname) { + close(ofd); + unlink (ofname); + } + do_exit(ERROR); +} diff --git a/tools/gzip-1.2.4/gzip.doc b/tools/gzip-1.2.4/gzip.doc new file mode 100644 index 00000000..5b2238b6 --- /dev/null +++ b/tools/gzip-1.2.4/gzip.doc @@ -0,0 +1,350 @@ + +GZIP(1) USER COMMANDS GZIP(1) + +NAME + gzip, gunzip, zcat - compress or expand files + +SYNOPSIS + gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] + gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] + zcat [ -fhLV ] [ name ... ] + +DESCRIPTION + Gzip reduces the size of the named files using Lempel-Ziv + coding (LZ77). Whenever possible, each file is replaced by + one with the extension .gz, while keeping the same ownership + modes, access and modification times. (The default exten- + sion is -gz for VMS, z for MSDOS, OS/2 FAT, Windows NT FAT + and Atari.) If no files are specified, or if a file name is + "-", the standard input is compressed to the standard out- + put. Gzip will only attempt to compress regular files. In + particular, it will ignore symbolic links. + + If the compressed file name is too long for its file system, + gzip truncates it. Gzip attempts to truncate only the parts + of the file name longer than 3 characters. (A part is del- + imited by dots.) If the name consists of small parts only, + the longest parts are truncated. For example, if file names + are limited to 14 characters, gzip.msdos.exe is compressed + to gzi.msd.exe.gz. Names are not truncated on systems which + do not have a limit on file name length. + + By default, gzip keeps the original file name and timestamp + in the compressed file. These are used when decompressing + the file with the -N option. This is useful when the + compressed file name was truncated or when the time stamp + was not preserved after a file transfer. + + Compressed files can be restored to their original form + using gzip -d or gunzip or zcat. If the original name saved + in the compressed file is not suitable for its file system, + a new name is constructed from the original one to make it + legal. + + gunzip takes a list of files on its command line and + replaces each file whose name ends with .gz, -gz, .z, -z, _z + or .Z and which begins with the correct magic number with an + uncompressed file without the original extension. gunzip + also recognizes the special extensions .tgz and .taz as + shorthands for .tar.gz and .tar.Z respectively. When + compressing, gzip uses the .tgz extension if necessary + instead of truncating a file with a .tar extension. + + gunzip can currently decompress files created by gzip, zip, + compress, compress -H or pack. The detection of the input + format is automatic. When using the first two formats, + gunzip checks a 32 bit CRC. For pack, gunzip checks the + uncompressed length. The standard compress format was not + designed to allow consistency checks. However gunzip is + sometimes able to detect a bad .Z file. If you get an error + when uncompressing a .Z file, do not assume that the .Z file + is correct simply because the standard uncompress does not + complain. This generally means that the standard uncompress + does not check its input, and happily generates garbage out- + put. The SCO compress -H format (lzh compression method) + does not include a CRC but also allows some consistency + checks. + + Files created by zip can be uncompressed by gzip only if + they have a single member compressed with the 'deflation' + method. This feature is only intended to help conversion of + tar.zip files to the tar.gz format. To extract zip files + with several members, use unzip instead of gunzip. + + zcat is identical to gunzip -c. (On some systems, zcat may + be installed as gzcat to preserve the original link to + compress.) zcat uncompresses either a list of files on the + command line or its standard input and writes the + uncompressed data on standard output. zcat will uncompress + files that have the correct magic number whether they have a + .gz suffix or not. + + Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP. + The amount of compression obtained depends on the size of + the input and the distribution of common substrings. Typi- + cally, text such as source code or English is reduced by + 60-70%. Compression is generally much better than that + achieved by LZW (as used in compress), Huffman coding (as + used in pack), or adaptive Huffman coding (compact). + + Compression is always performed, even if the compressed file + is slightly larger than the original. The worst case expan- + sion is a few bytes for the gzip file header, plus 5 bytes + every 32K block, or an expansion ratio of 0.015% for large + files. Note that the actual number of used disk blocks + almost never increases. gzip preserves the mode, ownership + and timestamps of files when compressing or decompressing. + +OPTIONS + -a --ascii + Ascii text mode: convert end-of-lines using local con- + ventions. This option is supported only on some non- + Unix systems. For MSDOS, CR LF is converted to LF when + compressing, and LF is converted to CR LF when + decompressing. + + -c --stdout --to-stdout + Write output on standard output; keep original files + unchanged. If there are several input files, the out- + put consists of a sequence of independently compressed + members. To obtain better compression, concatenate all + input files before compressing them. + + -d --decompress --uncompress + Decompress. + + -f --force + Force compression or decompression even if the file has + multiple links or the corresponding file already + exists, or if the compressed data is read from or writ- + ten to a terminal. If the input data is not in a format + recognized by gzip, and if the option --stdout is also + given, copy the input data without change to the stan- + dard ouput: let zcat behave as cat. If -f is not given, + and when not running in the background, gzip prompts to + verify whether an existing file should be overwritten. + + -h --help + Display a help screen and quit. + + -l --list + For each compressed file, list the following fields: + + compressed size: size of the compressed file + uncompressed size: size of the uncompressed file + ratio: compression ratio (0.0% if unknown) + uncompressed_name: name of the uncompressed file + + The uncompressed size is given as -1 for files not in + gzip format, such as compressed .Z files. To get the + uncompressed size for such a file, you can use: + + zcat file.Z | wc -c + + In combination with the --verbose option, the following + fields are also displayed: + + method: compression method + crc: the 32-bit CRC of the uncompressed data + date & time: time stamp for the uncompressed file + + The compression methods currently supported are + deflate, compress, lzh (SCO compress -H) and pack. The + crc is given as ffffffff for a file not in gzip format. + + With --name, the uncompressed name, date and time are + those stored within the compress file if present. + + With --verbose, the size totals and compression ratio + for all files is also displayed, unless some sizes are + unknown. With --quiet, the title and totals lines are + not displayed. + + -L --license + Display the gzip license and quit. + + -n --no-name + When compressing, do not save the original file name + and time stamp by default. (The original name is always + saved if the name had to be truncated.) When + decompressing, do not restore the original file name if + present (remove only the gzip suffix from the + compressed file name) and do not restore the original + time stamp if present (copy it from the compressed + file). This option is the default when decompressing. + + -N --name + When compressing, always save the original file name + and time stamp; this is the default. When decompress- + ing, restore the original file name and time stamp if + present. This option is useful on systems which have a + limit on file name length or when the time stamp has + been lost after a file transfer. + + -q --quiet + Suppress all warnings. + + -r --recursive + Travel the directory structure recursively. If any of + the file names specified on the command line are direc- + tories, gzip will descend into the directory and + compress all the files it finds there (or decompress + them in the case of gunzip ). + + -S .suf --suffix .suf + Use suffix .suf instead of .gz. Any suffix can be + given, but suffixes other than .z and .gz should be + avoided to avoid confusion when files are transferred + to other systems. A null suffix forces gunzip to try + decompression on all given files regardless of suffix, + as in: + + gunzip -S "" * (*.* for MSDOS) + + Previous versions of gzip used the .z suffix. This was + changed to avoid a conflict with pack(1). + + -t --test + Test. Check the compressed file integrity. + + -v --verbose + Verbose. Display the name and percentage reduction for + each file compressed or decompressed. + + -V --version + Version. Display the version number and compilation + options then quit. + + -# --fast --best + Regulate the speed of compression using the specified + digit #, where -1 or --fast indicates the fastest + compression method (less compression) and -9 or --best + indicates the slowest compression method (best compres- + sion). The default compression level is -6 (that is, + biased towards high compression at expense of speed). + +ADVANCED USAGE + Multiple compressed files can be concatenated. In this case, + gunzip will extract all members at once. For example: + + gzip -c file1 > foo.gz + gzip -c file2 >> foo.gz + + Then + gunzip -c foo + + is equivalent to + + cat file1 file2 + + In case of damage to one member of a .gz file, other members + can still be recovered (if the damaged member is removed). + However, you can get better compression by compressing all + members at once: + + cat file1 file2 | gzip > foo.gz + + compresses better than + + gzip -c file1 file2 > foo.gz + + If you want to recompress concatenated files to get better + compression, do: + + gzip -cd old.gz | gzip > new.gz + + If a compressed file consists of several members, the + uncompressed size and CRC reported by the --list option + applies to the last member only. If you need the + uncompressed size for all members, you can use: + + gzip -cd file.gz | wc -c + + If you wish to create a single archive file with multiple + members so that members can later be extracted indepen- + dently, use an archiver such as tar or zip. GNU tar supports + the -z option to invoke gzip transparently. gzip is designed + as a complement to tar, not as a replacement. + +ENVIRONMENT + The environment variable GZIP can hold a set of default + options for gzip. These options are interpreted first and + can be overwritten by explicit command line parameters. For + example: + for sh: GZIP="-8v --name"; export GZIP + for csh: setenv GZIP "-8v --name" + for MSDOS: set GZIP=-8v --name + + On Vax/VMS, the name of the environment variable is + GZIP_OPT, to avoid a conflict with the symbol set for invo- + cation of the program. + +SEE ALSO + znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), + unzip(1), compress(1), pack(1), compact(1) + +DIAGNOSTICS + Exit status is normally 0; if an error occurs, exit status + is 1. If a warning occurs, exit status is 2. + + Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...] + Invalid options were specified on the command line. + file: not in gzip format + The file specified to gunzip has not been + compressed. + file: Corrupt input. Use zcat to recover some data. + The compressed file has been damaged. The data up to + the point of failure can be recovered using + zcat file > recover + file: compressed with xx bits, can only handle yy bits + File was compressed (using LZW) by a program that + could deal with more bits than the decompress code + on this machine. Recompress the file with gzip, + which compresses better and uses less memory. + file: already has .gz suffix -- no change + The file is assumed to be already compressed. + Rename the file and try again. + file already exists; do you wish to overwrite (y or n)? + Respond "y" if you want the output file to be + replaced; "n" if not. + gunzip: corrupt input + A SIGSEGV violation was detected which usually means + that the input file has been corrupted. + xx.x% + Percentage of the input saved by compression. + (Relevant only for -v and -l.) + -- not a regular file or directory: ignored + When the input file is not a regular file or direc- + tory, (e.g. a symbolic link, socket, FIFO, device + file), it is left unaltered. + -- has xx other links: unchanged + The input file has links; it is left unchanged. See + ln(1) for more information. Use the -f flag to force + compression of multiply-linked files. + +CAVEATS + When writing compressed data to a tape, it is generally + necessary to pad the output with zeroes up to a block boun- + dary. When the data is read and the whole block is passed to + gunzip for decompression, gunzip detects that there is extra + trailing garbage after the compressed data and emits a warn- + ing by default. You have to use the --quiet option to + suppress the warning. This option can be set in the GZIP + environment variable as in: + for sh: GZIP="-q" tar -xfz --block-compress /dev/rst0 + for csh: (setenv GZIP -q; tar -xfz --block-compr /dev/rst0 + + In the above example, gzip is invoked implicitly by the -z + option of GNU tar. Make sure that the same block size (-b + option of tar) is used for reading and writing compressed + data on tapes. (This example assumes you are using the GNU + version of tar.) + +BUGS + The --list option reports incorrect sizes if they exceed 2 + gigabytes. The --list option reports sizes as -1 and crc as + ffffffff if the compressed file is on a non seekable media. + + In some rare cases, the --best option gives worse compres- + sion than the default compression level (-6). On some highly + redundant files, compress compresses better than gzip. diff --git a/tools/gzip-1.2.4/gzip.h b/tools/gzip-1.2.4/gzip.h new file mode 100644 index 00000000..88b07101 --- /dev/null +++ b/tools/gzip-1.2.4/gzip.h @@ -0,0 +1,315 @@ +/* gzip.h -- common declarations for all gzip modules + * Copyright (C) 1992-1993 Jean-loup Gailly. + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +#if defined(__STDC__) || defined(PROTO) +# define OF(args) args +#else +# define OF(args) () +#endif + +#ifdef __STDC__ + typedef void *voidp; +#else + typedef char *voidp; +#endif + +/* I don't like nested includes, but the string and io functions are used + * too often + */ +#include +#if !defined(NO_STRING_H) || defined(STDC_HEADERS) +# include +# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__) +# include +# endif +# define memzero(s, n) memset ((voidp)(s), 0, (n)) +#else +# include +# define strchr index +# define strrchr rindex +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# define memcmp(s1, s2, n) bcmp((s1), (s2), (n)) +# define memzero(s, n) bzero((s), (n)) +#endif + +#ifndef RETSIGTYPE +# define RETSIGTYPE void +#endif + +#define local static + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +/* Return codes from gzip */ +#define OK 0 +#define ERROR 1 +#define WARNING 2 + +/* Compression methods (see algorithm.doc) */ +#define STORED 0 +#define COMPRESSED 1 +#define PACKED 2 +#define LZHED 3 +/* methods 4 to 7 reserved */ +#define DEFLATED 8 +#define MAX_METHODS 9 +extern int method; /* compression method */ + +/* To save memory for 16 bit systems, some arrays are overlaid between + * the various modules: + * deflate: prev+head window d_buf l_buf outbuf + * unlzw: tab_prefix tab_suffix stack inbuf outbuf + * inflate: window inbuf + * unpack: window inbuf prefix_len + * unlzh: left+right window c_table inbuf c_len + * For compression, input is done in window[]. For decompression, output + * is done in window except for unlzw. + */ + +#ifndef INBUFSIZ +# ifdef SMALL_MEM +# define INBUFSIZ 0x2000 /* input buffer size */ +# else +# define INBUFSIZ 0x8000 /* input buffer size */ +# endif +#endif +#define INBUF_EXTRA 64 /* required by unlzw() */ + +#ifndef OUTBUFSIZ +# ifdef SMALL_MEM +# define OUTBUFSIZ 8192 /* output buffer size */ +# else +# define OUTBUFSIZ 16384 /* output buffer size */ +# endif +#endif +#define OUTBUF_EXTRA 2048 /* required by unlzw() */ + +#ifndef DIST_BUFSIZE +# ifdef SMALL_MEM +# define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */ +# else +# define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */ +# endif +#endif + +#ifdef DYN_ALLOC +# define EXTERN(type, array) extern type * near array +# define DECLARE(type, array, size) type * near array +# define ALLOC(type, array, size) { \ + array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ + if (array == NULL) error("insufficient memory"); \ + } +# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} +#else +# define EXTERN(type, array) extern type array[] +# define DECLARE(type, array, size) type array[size] +# define ALLOC(type, array, size) +# define FREE(array) +#endif + +EXTERN(uch, inbuf); /* input buffer */ +EXTERN(uch, outbuf); /* output buffer */ +EXTERN(ush, d_buf); /* buffer for distances, see trees.c */ +EXTERN(uch, window); /* Sliding window and suffix table (unlzw) */ +#define tab_suffix window +#ifndef MAXSEG_64K +# define tab_prefix prev /* hash link (see deflate.c) */ +# define head (prev+WSIZE) /* hash head (see deflate.c) */ + EXTERN(ush, tab_prefix); /* prefix code (see unlzw.c) */ +#else +# define tab_prefix0 prev +# define head tab_prefix1 + EXTERN(ush, tab_prefix0); /* prefix for even codes */ + EXTERN(ush, tab_prefix1); /* prefix for odd codes */ +#endif + +extern unsigned insize; /* valid bytes in inbuf */ +extern unsigned inptr; /* index of next byte to be processed in inbuf */ +extern unsigned outcnt; /* bytes in output buffer */ + +extern long bytes_in; /* number of input bytes */ +extern long bytes_out; /* number of output bytes */ +extern long header_bytes;/* number of bytes in gzip header */ + +#define isize bytes_in +/* for compatibility with old zip sources (to be cleaned) */ + +extern int ifd; /* input file descriptor */ +extern int ofd; /* output file descriptor */ +extern char ifname[]; /* input file name or "stdin" */ +extern char ofname[]; /* output file name or "stdout" */ +extern char *progname; /* program name */ + +extern long time_stamp; /* original time stamp (modification time) */ +extern long ifile_size; /* input file size, -1 for devices (debug only) */ + +typedef int file_t; /* Do not use stdio */ +#define NO_FILE (-1) /* in memory compression */ + + +#define PACK_MAGIC "\037\036" /* Magic header for packed files */ +#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */ +#define OLD_GZIP_MAGIC "\037\236" /* Magic header for gzip 0.5 = freeze 1.x */ +#define LZH_MAGIC "\037\240" /* Magic header for SCO LZH Compress files*/ +#define PKZIP_MAGIC "\120\113\003\004" /* Magic header for pkzip files */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ +#define RESERVED 0xC0 /* bit 6,7: reserved */ + +/* internal file attribute */ +#define UNKNOWN 0xffff +#define BINARY 0 +#define ASCII 1 + +#ifndef WSIZE +# define WSIZE 0x8000 /* window size--must be a power of two, and */ +#endif /* at least 32K for zip's deflate method */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST (WSIZE-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +extern int decrypt; /* flag to turn on decryption */ +extern int exit_code; /* program exit code */ +extern int verbose; /* be verbose (-v) */ +extern int quiet; /* be quiet (-q) */ +extern int level; /* compression level */ +extern int test; /* check .z file integrity */ +extern int to_stdout; /* output to stdout (-c) */ +extern int save_orig_name; /* set if original name must be saved */ + +#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(0)) +#define try_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf(1)) + +/* put_byte is used for the compressed output, put_ubyte for the + * uncompressed output. However unlzw() uses window for its + * suffix table instead of its output buffer, so it does not use put_ubyte + * (to be cleaned up). + */ +#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\ + flush_outbuf();} +#define put_ubyte(c) {window[outcnt++]=(uch)(c); if (outcnt==WSIZE)\ + flush_window();} + +/* Output a 16 bit value, lsb first */ +#define put_short(w) \ +{ if (outcnt < OUTBUFSIZ-2) { \ + outbuf[outcnt++] = (uch) ((w) & 0xff); \ + outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \ + } else { \ + put_byte((uch)((w) & 0xff)); \ + put_byte((uch)((ush)(w) >> 8)); \ + } \ +} + +/* Output a 32 bit value to the bit stream, lsb first */ +#define put_long(n) { \ + put_short((n) & 0xffff); \ + put_short(((ulg)(n)) >> 16); \ +} + +#define seekable() 0 /* force sequential output */ +#define translate_eol 0 /* no option -a yet */ + +#define tolow(c) (isupper(c) ? (c)-'A'+'a' : (c)) /* force to lower case */ + +/* Macros for getting two-byte and four-byte header values */ +#define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8)) +#define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16)) + +/* Diagnostic functions */ +#ifdef DEBUG +# define Assert(cond,msg) {if(!(cond)) error(msg);} +# define Trace(x) fprintf x +# define Tracev(x) {if (verbose) fprintf x ;} +# define Tracevv(x) {if (verbose>1) fprintf x ;} +# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} +# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +#define WARN(msg) {if (!quiet) fprintf msg ; \ + if (exit_code == OK) exit_code = WARNING;} + + /* in zip.c: */ +extern int zip OF((int in, int out)); +extern int file_read OF((char *buf, unsigned size)); + + /* in unzip.c */ +extern int unzip OF((int in, int out)); +extern int check_zipfile OF((int in)); + + /* in unpack.c */ +extern int unpack OF((int in, int out)); + + /* in unlzh.c */ +extern int unlzh OF((int in, int out)); + + /* in gzip.c */ +RETSIGTYPE abort_gzip OF((void)); + + /* in deflate.c */ +void lm_init OF((int pack_level, ush *flags)); +ulg deflate OF((void)); + + /* in trees.c */ +void ct_init OF((ush *attr, int *method)); +int ct_tally OF((int dist, int lc)); +ulg flush_block OF((char *buf, ulg stored_len, int eof)); + + /* in bits.c */ +void bi_init OF((file_t zipfile)); +void send_bits OF((int value, int length)); +unsigned bi_reverse OF((unsigned value, int length)); +void bi_windup OF((void)); +void copy_block OF((char *buf, unsigned len, int header)); +extern int (*read_buf) OF((char *buf, unsigned size)); + + /* in util.c: */ +extern int copy OF((int in, int out)); +extern ulg updcrc OF((uch *s, unsigned n)); +extern void clear_bufs OF((void)); +extern int fill_inbuf OF((int eof_ok)); +extern void flush_outbuf OF((void)); +extern void flush_window OF((void)); +extern void write_buf OF((int fd, voidp buf, unsigned cnt)); +extern char *strlwr OF((char *s)); +extern char *basename OF((char *fname)); +extern void make_simple_name OF((char *name)); +extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); +extern void error OF((char *m)); +extern void warn OF((char *a, char *b)); +extern void read_error OF((void)); +extern void write_error OF((void)); +extern void display_ratio OF((long num, long den, FILE *file)); +extern voidp xmalloc OF((unsigned int size)); + + /* in inflate.c */ +extern int inflate OF((void)); diff --git a/tools/gzip-1.2.4/gzip.info b/tools/gzip-1.2.4/gzip.info new file mode 100644 index 00000000..3ff69c78 --- /dev/null +++ b/tools/gzip-1.2.4/gzip.info @@ -0,0 +1,809 @@ +Info file gzip.info, produced by Makeinfo, -*- Text -*- from input +file gzip.texi. + + This file documents the the GNU `gzip' command for compressing +files. + + Copyright (C) 1992-1993 Jean-loup Gailly + + Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: gzip.info, Node: Top, Up: (dir) + + This file documents the `gzip' command to compress files. + +* Menu: + +* Copying:: How you can copy and share `gzip'. +* Overview:: Preliminary information. +* Sample:: Sample output from `gzip'. +* Invoking gzip:: How to run `gzip'. +* Advanced usage:: Concatenated files. +* Environment:: The `GZIP' environment variable +* Tapes:: Using `gzip' on tapes. +* Problems:: Reporting bugs. +* Concept Index:: Index of concepts. + + +File: gzip.info, Node: Copying, Next: Overview, Up: Top + +GNU GENERAL PUBLIC LICENSE +************************** + + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +Preamble +======== + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, +and (2) offer you this license which gives you legal permission to +copy, distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, +we want its recipients to know that what they have is not the +original, so that any problems introduced by others will not reflect +on the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 1. This License applies to any program or other work which contains + a notice placed by the copyright holder saying it may be + distributed under the terms of this General Public License. The + "Program", below, refers to any such program or work, and a "work + based on the Program" means either the Program or any derivative + work under copyright law: that is to say, a work containing the + Program or a portion of it, either verbatim or with modifications + and/or translated into another language. (Hereinafter, + translation is included without limitation in the term + "modification".) Each licensee is addressed as "you". + + Activities other than copying, distribution and modification + are not covered by this License; they are outside its scope. The + act of running the Program is not restricted, and the output from + the Program is covered only if its contents constitute a work + based on the Program (independent of having been made by running + the Program). Whether that is true depends on what the Program + does. + + 2. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an + appropriate copyright notice and disclaimer of warranty; keep + intact all the notices that refer to this License and to the + absence of any warranty; and give any other recipients of the + Program a copy of this License along with the Program. + + You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + + 3. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + 1. You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any + change. + + 2. You must cause any work that you distribute or publish, that + in whole or in part contains or is derived from the Program + or any part thereof, to be licensed as a whole at no charge + to all third parties under the terms of this License. + + 3. If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or + display an announcement including an appropriate copyright + notice and a notice that there is no warranty (or else, + saying that you provide a warranty) and that users may + redistribute the program under these conditions, and telling + the user how to view a copy of this License. (Exception: if + the Program itself is interactive but does not normally + print such an announcement, your work based on the Program + is not required to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the + Program, and can be reasonably considered independent and + separate works in themselves, then this License, and its terms, + do not apply to those sections when you distribute them as + separate works. But when you distribute the same sections as + part of a whole which is a work based on the Program, the + distribution of the whole must be on the terms of this License, + whose permissions for other licensees extend to the entire whole, + and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or + contest your rights to work written entirely by you; rather, the + intent is to exercise the right to control the distribution of + derivative or collective works based on the Program. + + In addition, mere aggregation of another work not based on the + Program with the Program (or with a work based on the Program) on + a volume of a storage or distribution medium does not bring the + other work under the scope of this License. + + 4. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the + terms of Sections 1 and 2 above provided that you also do one of + the following: + + 1. Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Sections 1 and 2 above on a medium customarily used for + software interchange; or, + + 2. Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than + your cost of physically performing source distribution, a + complete machine-readable copy of the corresponding source + code, to be distributed under the terms of Sections 1 and 2 + above on a medium customarily used for software interchange; + or, + + 3. Accompany it with the information you received as to the + offer to distribute corresponding source code. (This + alternative is allowed only for noncommercial distribution + and only if you received the program in object code or + executable form with such an offer, in accord with + Subsection b above.) + + The source code for a work means the preferred form of the + work for making modifications to it. For an executable work, + complete source code means all the source code for all modules it + contains, plus any associated interface definition files, plus + the scripts used to control compilation and installation of the + executable. However, as a special exception, the source code + distributed need not include anything that is normally + distributed (in either source or binary form) with the major + components (compiler, kernel, and so on) of the operating system + on which the executable runs, unless that component itself + accompanies the executable. + + If distribution of executable or object code is made by + offering access to copy from a designated place, then offering + equivalent access to copy the source code from the same place + counts as distribution of the source code, even though third + parties are not compelled to copy the source along with the + object code. + + 5. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 6. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify + or distribute the Program or its derivative works. These actions + are prohibited by law if you do not accept this License. + Therefore, by modifying or distributing the Program (or any work + based on the Program), you indicate your acceptance of this + License to do so, and all its terms and conditions for copying, + distributing or modifying the Program or works based on it. + + 7. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program + subject to these terms and conditions. You may not impose any + further restrictions on the recipients' exercise of the rights + granted herein. You are not responsible for enforcing compliance + by third parties to this License. + + 8. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent + issues), conditions are imposed on you (whether by court order, + agreement or otherwise) that contradict the conditions of this + License, they do not excuse you from the conditions of this + License. If you cannot distribute so as to satisfy + simultaneously your obligations under this License and any other + pertinent obligations, then as a consequence you may not + distribute the Program at all. For example, if a patent license + would not permit royalty-free redistribution of the Program by + all those who receive copies directly or indirectly through you, + then the only way you could satisfy both it and this License + would be to refrain entirely from distribution of the Program. + + If any portion of this section is held invalid or + unenforceable under any particular circumstance, the balance of + the section is intended to apply and the section as a whole is + intended to apply in other circumstances. + + It is not the purpose of this section to induce you to + infringe any patents or other property right claims or to contest + validity of any such claims; this section has the sole purpose of + protecting the integrity of the free software distribution + system, which is implemented by public license practices. Many + people have made generous contributions to the wide range of + software distributed through that system in reliance on + consistent application of that system; it is up to the + author/donor to decide if he or she is willing to distribute + software through any other system and a licensee cannot impose + that choice. + + This section is intended to make thoroughly clear what is + believed to be a consequence of the rest of this License. + + 9. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, + the original copyright holder who places the Program under this + License may add an explicit geographical distribution limitation + excluding those countries, so that distribution is permitted only + in or among countries not thus excluded. In such case, this + License incorporates the limitation as if written in the body of + this License. + + 10. The Free Software Foundation may publish revised and/or new + versions of the General Public License from time to time. Such + new versions will be similar in spirit to the present version, + but may differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the + Program specifies a version number of this License which applies + to it and "any later version", you have the option of following + the terms and conditions either of that version or of any later + version published by the Free Software Foundation. If the + Program does not specify a version number of this License, you + may choose any version ever published by the Free Software + Foundation. + + 11. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to + the author to ask for permission. For software which is + copyrighted by the Free Software Foundation, write to the Free + Software Foundation; we sometimes make exceptions for this. Our + decision will be guided by the two goals of preserving the free + status of all derivatives of our free software and of promoting + the sharing and reuse of software generally. + + NO WARRANTY + + 12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE + LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT + HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT + WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE + QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY + SERVICING, REPAIR OR CORRECTION. + + 13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY + MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE + LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, + INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR + INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS + OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY + YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH + ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs +============================================= + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES. + Copyright (C) 19YY NAME OF AUTHOR + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Also add information on how to contact you by electronic and paper +mail. + + If the program is interactive, make it output a short notice like +this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details + type `show w'. This is free software, and you are welcome + to redistribute it under certain conditions; type `show c' + for details. + + The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + + You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the program, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright + interest in the program `Gnomovision' + (which makes passes at compilers) written + by James Hacker. + + SIGNATURE OF TY COON, 1 April 1989 + Ty Coon, President of Vice + + This General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use +the GNU Library General Public License instead of this License. + + +File: gzip.info, Node: Overview, Next: Sample, Prev: Copying, Up: Top + +Overview +******** + + `gzip' reduces the size of the named files using Lempel-Ziv coding +(LZ77). Whenever possible, each file is replaced by one with the +extension `.gz', while keeping the same ownership modes, access and +modification times. (The default extension is `-gz' for VMS, `z' for +MSDOS, OS/2 FAT and Atari.) If no files are specified or if a file +name is "-", the standard input is compressed to the standard output. +`gzip' will only attempt to compress regular files. In particular, it +will ignore symbolic links. + + If the new file name is too long for its file system, `gzip' +truncates it. `gzip' attempts to truncate only the parts of the file +name longer than 3 characters. (A part is delimited by dots.) If the +name consists of small parts only, the longest parts are truncated. +For example, if file names are limited to 14 characters, gzip.msdos.exe +is compressed to gzi.msd.exe.gz. Names are not truncated on systems +which do not have a limit on file name length. + + By default, `gzip' keeps the original file name and timestamp in +the compressed file. These are used when decompressing the file with +the `-N' option. This is useful when the compressed file name was +truncated or when the time stamp was not preserved after a file +transfer. + + Compressed files can be restored to their original form using `gzip +-d' or `gunzip' or `zcat'. If the original name saved in the +compressed file is not suitable for its file system, a new name is +constructed from the original one to make it legal. + + `gunzip' takes a list of files on its command line and replaces +each file whose name ends with `.gz', `.z', `.Z', `-gz', `-z' or `_z' +and which begins with the correct magic number with an uncompressed +file without the original extension. `gunzip' also recognizes the +special extensions `.tgz' and `.taz' as shorthands for `.tar.gz' and +`.tar.Z' respectively. When compressing, `gzip' uses the `.tgz' +extension if necessary instead of truncating a file with a `.tar' +extension. + + `gunzip' can currently decompress files created by `gzip', `zip', +`compress' or `pack'. The detection of the input format is automatic. +When using the first two formats, `gunzip' checks a 32 bit CRC (cyclic +redundancy check). For `pack', `gunzip' checks the uncompressed +length. The `compress' format was not designed to allow consistency +checks. However `gunzip' is sometimes able to detect a bad `.Z' file. +If you get an error when uncompressing a `.Z' file, do not assume that +the `.Z' file is correct simply because the standard `uncompress' does +not complain. This generally means that the standard `uncompress' +does not check its input, and happily generates garbage output. The +SCO `compress -H' format (`lzh' compression method) does not include a +CRC but also allows some consistency checks. + + Files created by `zip' can be uncompressed by `gzip' only if they +have a single member compressed with the 'deflation' method. This +feature is only intended to help conversion of `tar.zip' files to the +`tar.gz' format. To extract `zip' files with several members, use +`unzip' instead of `gunzip'. + + `zcat' is identical to `gunzip -c'. `zcat' uncompresses either a +list of files on the command line or its standard input and writes the +uncompressed data on standard output. `zcat' will uncompress files +that have the correct magic number whether they have a `.gz' suffix or +not. + + `gzip' uses the Lempel-Ziv algorithm used in `zip' and PKZIP. The +amount of compression obtained depends on the size of the input and +the distribution of common substrings. Typically, text such as source +code or English is reduced by 60-70%. Compression is generally much +better than that achieved by LZW (as used in `compress'), Huffman +coding (as used in `pack'), or adaptive Huffman coding (`compact'). + + Compression is always performed, even if the compressed file is +slightly larger than the original. The worst case expansion is a few +bytes for the `gzip' file header, plus 5 bytes every 32K block, or an +expansion ratio of 0.015% for large files. Note that the actual number +of used disk blocks almost never increases. `gzip' preserves the mode, +ownership and timestamps of files when compressing or decompressing. + + +File: gzip.info, Node: Sample, Next: Invoking gzip, Prev: Overview, Up: Top + +Sample Output +************* + + Here are some realistic examples of running `gzip'. + + This is the output of the command `gzip -h': + + gzip 1.2.4 (18 Aug 93) + usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...] + -c --stdout write on standard output, keep original files unchanged + -d --decompress decompress + -f --force force overwrite of output file and compress links + -h --help give this help + -l --list list compressed file contents + -L --license display software license + -n --no-name do not save or restore the original name and time stamp + -N --name save or restore the original name and time stamp + -q --quiet suppress all warnings + -r --recursive operate recursively on directories + -S .suf --suffix .suf use suffix .suf on compressed files + -t --test test compressed file integrity + -v --verbose verbose mode + -V --version display version number + -1 --fast compress faster + -9 --best compress better + file... files to (de)compress. If none given, use standard input. + + This is the output of the command `gzip -v texinfo.tex': + + texinfo.tex: 71.6% -- replaced with texinfo.tex.gz + + The following command will find all `gzip' files in the current +directory and subdirectories, and extract them in place without +destroying the original: + + find . -name '*.gz' -print | sed 's/^\(.*\)[.]gz$/gunzip < "&" > "\1"/' | sh + + +File: gzip.info, Node: Invoking gzip, Next: Advanced usage, Prev: Sample, Up: Top + +Invoking `gzip' +*************** + + The format for running the `gzip' program is: + + gzip OPTION ... + + `gzip' supports the following options: + +`--stdout' +`--to-stdout' +`-c' + Write output on standard output; keep original files unchanged. + If there are several input files, the output consists of a + sequence of independently compressed members. To obtain better + compression, concatenate all input files before compressing them. + +`--decompress' +`--uncompress' +`-d' + Decompress. + +`--force' +`-f' + Force compression or decompression even if the file has multiple + links or the corresponding file already exists, or if the + compressed data is read from or written to a terminal. If the + input data is not in a format recognized by `gzip', and if the + option --stdout is also given, copy the input data without change + to the standard ouput: let `zcat' behave as `cat'. If `-f' is not + given, and when not running in the background, `gzip' prompts to + verify whether an existing file should be overwritten. + +`--help' +`-h' + Print an informative help message describing the options then + quit. + +`--list' +`-l' + For each compressed file, list the following fields: + + compressed size: size of the compressed file + uncompressed size: size of the uncompressed file + ratio: compression ratio (0.0% if unknown) + uncompressed_name: name of the uncompressed file + + The uncompressed size is given as `-1' for files not in `gzip' + format, such as compressed `.Z' files. To get the uncompressed + size for such a file, you can use: + + zcat file.Z | wc -c + + In combination with the --verbose option, the following fields + are also displayed: + + method: compression method (deflate,compress,lzh,pack) + crc: the 32-bit CRC of the uncompressed data + date & time: time stamp for the uncompressed file + + The crc is given as ffffffff for a file not in gzip format. + + With --verbose, the size totals and compression ratio for all + files is also displayed, unless some sizes are unknown. With + --quiet, the title and totals lines are not displayed. + +`--license' +`-L' + Display the `gzip' license then quit. + +`--no-name' +`-n' + When compressing, do not save the original file name and time + stamp by default. (The original name is always saved if the name + had to be truncated.) When decompressing, do not restore the + original file name if present (remove only the `gzip' suffix from + the compressed file name) and do not restore the original time + stamp if present (copy it from the compressed file). This option + is the default when decompressing. + +`--name' +`-N' + When compressing, always save the original file name and time + stamp; this is the default. When decompressing, restore the + original file name and time stamp if present. This option is + useful on systems which have a limit on file name length or when + the time stamp has been lost after a file transfer. + +`--quiet' +`-q' + Suppress all warning messages. + +`--recursive' +`-r' + Travel the directory structure recursively. If any of the file + names specified on the command line are directories, `gzip' will + descend into the directory and compress all the files it finds + there (or decompress them in the case of `gunzip'). + +`--suffix SUF' +`-S SUF' + Use suffix `SUF' instead of `.gz'. Any suffix can be given, but + suffixes other than `.z' and `.gz' should be avoided to avoid + confusion when files are transferred to other systems. A null + suffix forces gunzip to try decompression on all given files + regardless of suffix, as in: + + gunzip -S "" * (*.* for MSDOS) + + Previous versions of gzip used the `.z' suffix. This was changed + to avoid a conflict with `pack'. + +`--test' +`-t' + Test. Check the compressed file integrity. + +`--verbose' +`-v' + Verbose. Display the name and percentage reduction for each file + compressed. + +`--version' +`-V' + Version. Display the version number and compilation options, then + quit. + +`--fast' +`--best' +`-N' + Regulate the speed of compression using the specified digit N, + where `-1' or `--fast' indicates the fastest compression method + (less compression) and `--best' or `-9' indicates the slowest + compression method (optimal compression). The default + compression level is `-6' (that is, biased towards high + compression at expense of speed). + + +File: gzip.info, Node: Advanced usage, Next: Environment, Prev: Invoking gzip, Up: Top + +Advanced usage +************** + + Multiple compressed files can be concatenated. In this case, +`gunzip' will extract all members at once. If one member is damaged, +other members might still be recovered after removal of the damaged +member. Better compression can be usually obtained if all members are +decompressed and then recompressed in a single step. + + This is an example of concatenating `gzip' files: + + gzip -c file1 > foo.gz + gzip -c file2 >> foo.gz + + Then + + gunzip -c foo + + is equivalent to + + cat file1 file2 + + In case of damage to one member of a `.gz' file, other members can +still be recovered (if the damaged member is removed). However, you +can get better compression by compressing all members at once: + + cat file1 file2 | gzip > foo.gz + + compresses better than + + gzip -c file1 file2 > foo.gz + + If you want to recompress concatenated files to get better +compression, do: + + zcat old.gz | gzip > new.gz + + If a compressed file consists of several members, the uncompressed +size and CRC reported by the `--list' option applies to the last member +only. If you need the uncompressed size for all members, you can use: + + zcat file.gz | wc -c + + If you wish to create a single archive file with multiple members so +that members can later be extracted independently, use an archiver such +as `tar' or `zip'. GNU `tar' supports the `-z' option to invoke `gzip' +transparently. `gzip' is designed as a complement to `tar', not as a +replacement. + + +File: gzip.info, Node: Environment, Next: Tapes, Prev: Advanced usage, Up: Top + +Environment +*********** + + The environment variable `GZIP' can hold a set of default options +for `gzip'. These options are interpreted first and can be +overwritten by explicit command line parameters. For example: + + for sh: GZIP="-8v --name"; export GZIP + for csh: setenv GZIP "-8v --name" + for MSDOS: set GZIP=-8v --name + + On Vax/VMS, the name of the environment variable is `GZIP_OPT', to +avoid a conflict with the symbol set for invocation of the program. + + +File: gzip.info, Node: Tapes, Next: Problems, Prev: Environment, Up: Top + +Using `gzip' on tapes +********************* + + When writing compressed data to a tape, it is generally necessary +to pad the output with zeroes up to a block boundary. When the data is +read and the whole block is passed to `gunzip' for decompression, +`gunzip' detects that there is extra trailing garbage after the +compressed data and emits a warning by default. You have to use the +`--quiet' option to suppress the warning. This option can be set in the +`GZIP' environment variable, as in: + + for sh: GZIP="-q" tar -xfz --block-compress /dev/rst0 + for csh: (setenv GZIP "-q"; tar -xfz --block-compress /dev/rst0) + + In the above example, `gzip' is invoked implicitly by the `-z' +option of GNU `tar'. Make sure that the same block size (`-b' option +of `tar') is used for reading and writing compressed data on tapes. +(This example assumes you are using the GNU version of `tar'.) + + +File: gzip.info, Node: Problems, Next: Concept Index, Prev: Tapes, Up: Top + +Reporting Bugs +************** + + If you find a bug in `gzip', please send electronic mail to +`jloup@chorus.fr' or, if this fails, to +`bug-gnu-utils@prep.ai.mit.edu'. Include the version number, which +you can find by running `gzip -V'. Also include in your message the +hardware and operating system, the compiler used to compile `gzip', a +description of the bug behavior, and the input to `gzip' that triggered +the bug. + + +File: gzip.info, Node: Concept Index, Prev: Problems, Up: Top + +Concept Index +************* + +* Menu: + +* Environment: Environment. +* bugs: Problems. +* concatenated files: Advanced usage. +* invoking: Invoking gzip. +* options: Invoking gzip. +* overview: Overview. +* sample: Sample. +* tapes: Tapes. + + + +Tag Table: +Node: Top864 +Node: Copying1344 +Node: Overview20602 +Node: Sample24911 +Node: Invoking gzip26528 +Node: Advanced usage31183 +Node: Environment32772 +Node: Tapes33340 +Node: Problems34317 +Node: Concept Index34822 + +End Tag Table diff --git a/tools/gzip-1.2.4/gzip.texi b/tools/gzip-1.2.4/gzip.texi new file mode 100644 index 00000000..07be3718 --- /dev/null +++ b/tools/gzip-1.2.4/gzip.texi @@ -0,0 +1,479 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename gzip.info +@settitle Gzip User's Manual +@finalout +@setchapternewpage odd +@c %**end of header + +@ifinfo +This file documents the the GNU @code{gzip} command for compressing files. + +Copyright (C) 1992-1993 Jean-loup Gailly + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end ifinfo + +@titlepage +@title gzip +@subtitle The data compression program +@subtitle Edition 1.2.4, for Gzip Version 1.2.4 +@subtitle July 1993 +@author by Jean-loup Gailly + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1992-1993 Jean-loup Gailly + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end titlepage + +@node Top, , , (dir) + +@ifinfo +This file documents the @code{gzip} command to compress files. +@end ifinfo + +@menu +* Copying:: How you can copy and share @code{gzip}. +* Overview:: Preliminary information. +* Sample:: Sample output from @code{gzip}. +* Invoking gzip:: How to run @code{gzip}. +* Advanced usage:: Concatenated files. +* Environment:: The @code{GZIP} environment variable +* Tapes:: Using @code{gzip} on tapes. +* Problems:: Reporting bugs. +* Concept Index:: Index of concepts. +@end menu + +@node Copying, Overview, , Top +@include gpl.texinfo + +@node Overview, Sample, Copying, Top +@chapter Overview +@cindex overview + +@code{gzip} reduces the size of the named files using Lempel-Ziv coding +(LZ77). Whenever possible, each file is replaced by one with the +extension @samp{.gz}, while keeping the same ownership modes, access and +modification times. (The default extension is @samp{-gz} for VMS, +@samp{z} for MSDOS, OS/2 FAT and Atari.) If no files are specified or +if a file name is "-", the standard input is compressed to the standard +output. @code{gzip} will only attempt to compress regular files. In +particular, it will ignore symbolic links. + +If the new file name is too long for its file system, @code{gzip} +truncates it. @code{gzip} attempts to truncate only the parts of the +file name longer than 3 characters. (A part is delimited by dots.) If +the name consists of small parts only, the longest parts are truncated. +For example, if file names are limited to 14 characters, gzip.msdos.exe +is compressed to gzi.msd.exe.gz. Names are not truncated on systems +which do not have a limit on file name length. + +By default, @code{gzip} keeps the original file name and timestamp in +the compressed file. These are used when decompressing the file with the +@samp{-N} option. This is useful when the compressed file name was +truncated or when the time stamp was not preserved after a file +transfer. + +Compressed files can be restored to their original form using @samp{gzip -d} +or @code{gunzip} or @code{zcat}. If the original name saved in the +compressed file is not suitable for its file system, a new name is +constructed from the original one to make it legal. + +@code{gunzip} takes a list of files on its command line and replaces +each file whose name ends with @samp{.gz}, @samp{.z}, @samp{.Z}, +@samp{-gz}, @samp{-z} or @samp{_z} and which begins with the correct +magic number with an uncompressed file without the original extension. +@code{gunzip} also recognizes the special extensions @samp{.tgz} and +@samp{.taz} as shorthands for @samp{.tar.gz} and @samp{.tar.Z} +respectively. When compressing, @code{gzip} uses the @samp{.tgz} +extension if necessary instead of truncating a file with a @samp{.tar} +extension. + +@code{gunzip} can currently decompress files created by @code{gzip}, +@code{zip}, @code{compress} or @code{pack}. The detection of the input +format is automatic. When using the first two formats, @code{gunzip} +checks a 32 bit CRC (cyclic redundancy check). For @code{pack}, +@code{gunzip} checks the uncompressed length. The @code{compress} format +was not designed to allow consistency checks. However @code{gunzip} is +sometimes able to detect a bad @samp{.Z} file. If you get an error when +uncompressing a @samp{.Z} file, do not assume that the @samp{.Z} file is +correct simply because the standard @code{uncompress} does not complain. +This generally means that the standard @code{uncompress} does not check +its input, and happily generates garbage output. The SCO @samp{compress +-H} format (@code{lzh} compression method) does not include a CRC but +also allows some consistency checks. + +Files created by @code{zip} can be uncompressed by @code{gzip} only if +they have a single member compressed with the 'deflation' method. This +feature is only intended to help conversion of @code{tar.zip} files to +the @code{tar.gz} format. To extract @code{zip} files with several +members, use @code{unzip} instead of @code{gunzip}. + +@code{zcat} is identical to @samp{gunzip -c}. @code{zcat} +uncompresses either a list of files on the command line or its standard +input and writes the uncompressed data on standard output. @code{zcat} +will uncompress files that have the correct magic number whether they +have a @samp{.gz} suffix or not. + +@code{gzip} uses the Lempel-Ziv algorithm used in @code{zip} and PKZIP. +The amount of compression obtained depends on the size of the input and +the distribution of common substrings. Typically, text such as source +code or English is reduced by 60-70%. Compression is generally much +better than that achieved by LZW (as used in @code{compress}), Huffman +coding (as used in @code{pack}), or adaptive Huffman coding +(@code{compact}). + +Compression is always performed, even if the compressed file is slightly +larger than the original. The worst case expansion is a few bytes for +the @code{gzip} file header, plus 5 bytes every 32K block, or an expansion +ratio of 0.015% for large files. Note that the actual number of used +disk blocks almost never increases. @code{gzip} preserves the mode, +ownership and timestamps of files when compressing or decompressing. + +@node Sample, Invoking gzip, Overview, Top +@chapter Sample Output +@cindex sample + +Here are some realistic examples of running @code{gzip}. + +This is the output of the command @samp{gzip -h}: + +@example +gzip 1.2.4 (18 Aug 93) +usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...] + -c --stdout write on standard output, keep original files unchanged + -d --decompress decompress + -f --force force overwrite of output file and compress links + -h --help give this help + -l --list list compressed file contents + -L --license display software license + -n --no-name do not save or restore the original name and time stamp + -N --name save or restore the original name and time stamp + -q --quiet suppress all warnings + -r --recursive operate recursively on directories + -S .suf --suffix .suf use suffix .suf on compressed files + -t --test test compressed file integrity + -v --verbose verbose mode + -V --version display version number + -1 --fast compress faster + -9 --best compress better + file... files to (de)compress. If none given, use standard input. +@end example + +This is the output of the command @samp{gzip -v texinfo.tex}: + +@example +texinfo.tex: 71.6% -- replaced with texinfo.tex.gz +@end example + +The following command will find all @code{gzip} files in the current +directory and subdirectories, and extract them in place without +destroying the original: + +@example +find . -name '*.gz' -print | sed 's/^\(.*\)[.]gz$/gunzip < "&" > "\1"/' | sh +@end example + +@node Invoking gzip, Advanced usage, Sample, Top +@chapter Invoking @code{gzip} +@cindex invoking +@cindex options + +The format for running the @code{gzip} program is: + +@example +gzip @var{option} @dots{} +@end example + +@code{gzip} supports the following options: + +@table @samp +@item --stdout +@itemx --to-stdout +@itemx -c +Write output on standard output; keep original files unchanged. +If there are several input files, the output consists of a sequence of +independently compressed members. To obtain better compression, +concatenate all input files before compressing them. + +@item --decompress +@itemx --uncompress +@itemx -d +Decompress. + +@item --force +@itemx -f +Force compression or decompression even if the file has multiple links +or the corresponding file already exists, or if the compressed data +is read from or written to a terminal. If the input data is not in +a format recognized by @code{gzip}, and if the option --stdout is also +given, copy the input data without change to the standard ouput: let +@code{zcat} behave as @code{cat}. If @samp{-f} is not given, and +when not running in the background, @code{gzip} prompts to verify +whether an existing file should be overwritten. + +@item --help +@itemx -h +Print an informative help message describing the options then quit. + +@item --list +@itemx -l +For each compressed file, list the following fields: + +@example +compressed size: size of the compressed file +uncompressed size: size of the uncompressed file +ratio: compression ratio (0.0% if unknown) +uncompressed_name: name of the uncompressed file +@end example + +The uncompressed size is given as @samp{-1} for files not in @code{gzip} +format, such as compressed @samp{.Z} files. To get the uncompressed size for +such a file, you can use: + +@example +zcat file.Z | wc -c +@end example + +In combination with the --verbose option, the following fields are also +displayed: + +@example +method: compression method (deflate,compress,lzh,pack) +crc: the 32-bit CRC of the uncompressed data +date & time: time stamp for the uncompressed file +@end example + +The crc is given as ffffffff for a file not in gzip format. + +With --verbose, the size totals and compression ratio for all files +is also displayed, unless some sizes are unknown. With --quiet, +the title and totals lines are not displayed. + +@item --license +@itemx -L +Display the @code{gzip} license then quit. + +@item --no-name +@itemx -n +When compressing, do not save the original file name and time stamp by +default. (The original name is always saved if the name had to be +truncated.) When decompressing, do not restore the original file name +if present (remove only the @code{gzip} +suffix from the compressed file name) and do not restore the original +time stamp if present (copy it from the compressed file). This option +is the default when decompressing. + +@item --name +@itemx -N +When compressing, always save the original file name and time stamp; this +is the default. When decompressing, restore the original file name and +time stamp if present. This option is useful on systems which have +a limit on file name length or when the time stamp has been lost after +a file transfer. + +@item --quiet +@itemx -q +Suppress all warning messages. + +@item --recursive +@itemx -r +Travel the directory structure recursively. If any of the file names +specified on the command line are directories, @code{gzip} will descend +into the directory and compress all the files it finds there (or +decompress them in the case of @code{gunzip}). + +@item --suffix @var{suf} +@itemx -S @var{suf} +Use suffix @samp{@var{suf}} instead of @samp{.gz}. Any suffix can be +given, but suffixes other than @samp{.z} and @samp{.gz} should be +avoided to avoid confusion when files are transferred to other systems. +A null suffix forces gunzip to try decompression on all given files +regardless of suffix, as in: + +@example +gunzip -S "" * (*.* for MSDOS) +@end example + +Previous versions of gzip used the @samp{.z} suffix. This was changed to +avoid a conflict with @code{pack}. + +@item --test +@itemx -t +Test. Check the compressed file integrity. + +@item --verbose +@itemx -v +Verbose. Display the name and percentage reduction for each file compressed. + +@item --version +@itemx -V +Version. Display the version number and compilation options, then quit. + +@item --fast +@itemx --best +@itemx -@var{n} +Regulate the speed of compression using the specified digit @var{n}, +where @samp{-1} or @samp{--fast} indicates the fastest compression +method (less compression) and @samp{--best} or @samp{-9} indicates the +slowest compression method (optimal compression). The default +compression level is @samp{-6} (that is, biased towards high compression at +expense of speed). +@end table + +@node Advanced usage, Environment, Invoking gzip, Top +@chapter Advanced usage +@cindex concatenated files + +Multiple compressed files can be concatenated. In this case, +@code{gunzip} will extract all members at once. If one member is +damaged, other members might still be recovered after removal of the +damaged member. Better compression can be usually obtained if all +members are decompressed and then recompressed in a single step. + +This is an example of concatenating @code{gzip} files: + +@example +gzip -c file1 > foo.gz +gzip -c file2 >> foo.gz +@end example + +Then + +@example +gunzip -c foo +@end example + +is equivalent to + +@example +cat file1 file2 +@end example + +In case of damage to one member of a @samp{.gz} file, other members can +still be recovered (if the damaged member is removed). However, +you can get better compression by compressing all members at once: + +@example +cat file1 file2 | gzip > foo.gz +@end example + +compresses better than + +@example +gzip -c file1 file2 > foo.gz +@end example + +If you want to recompress concatenated files to get better compression, do: + +@example +zcat old.gz | gzip > new.gz +@end example + +If a compressed file consists of several members, the uncompressed +size and CRC reported by the @samp{--list} option applies to the last member +only. If you need the uncompressed size for all members, you can use: + +@example +zcat file.gz | wc -c +@end example + +If you wish to create a single archive file with multiple members so +that members can later be extracted independently, use an archiver such +as @code{tar} or @code{zip}. GNU @code{tar} supports the @samp{-z} +option to invoke @code{gzip} transparently. @code{gzip} is designed as a +complement to @code{tar}, not as a replacement. + +@node Environment, Tapes, Advanced usage, Top +@chapter Environment +@cindex Environment + +The environment variable @code{GZIP} can hold a set of default options for +@code{gzip}. These options are interpreted first and can be overwritten by +explicit command line parameters. For example: + +@example +for sh: GZIP="-8v --name"; export GZIP +for csh: setenv GZIP "-8v --name" +for MSDOS: set GZIP=-8v --name +@end example + +On Vax/VMS, the name of the environment variable is @code{GZIP_OPT}, to +avoid a conflict with the symbol set for invocation of the program. + +@node Tapes, Problems, Environment, Top +@chapter Using @code{gzip} on tapes +@cindex tapes + +When writing compressed data to a tape, it is generally necessary to pad +the output with zeroes up to a block boundary. When the data is read and +the whole block is passed to @code{gunzip} for decompression, +@code{gunzip} detects that there is extra trailing garbage after the +compressed data and emits a warning by default. You have to use the +@samp{--quiet} option to suppress the warning. This option can be set in the +@code{GZIP} environment variable, as in: + +@example +for sh: GZIP="-q" tar -xfz --block-compress /dev/rst0 +for csh: (setenv GZIP "-q"; tar -xfz --block-compress /dev/rst0) +@end example + +In the above example, @code{gzip} is invoked implicitly by the @samp{-z} +option of GNU @code{tar}. Make sure that the same block size (@samp{-b} +option of @code{tar}) is used for reading and writing compressed data on +tapes. (This example assumes you are using the GNU version of +@code{tar}.) + +@node Problems, Concept Index, Tapes, Top +@chapter Reporting Bugs +@cindex bugs + +If you find a bug in @code{gzip}, please send electronic mail to +@w{@samp{jloup@@chorus.fr}} or, if this fails, to +@w{@samp{bug-gnu-utils@@prep.ai.mit.edu}}. Include the version number, +which you can find by running @w{@samp{gzip -V}}. Also include in your +message the hardware and operating system, the compiler used to compile +@code{gzip}, +a description of the bug behavior, and the input to @code{gzip} that triggered +the bug.@refill + +@node Concept Index, , Problems, Top +@unnumbered Concept Index + +@printindex cp + +@contents +@bye diff --git a/tools/gzip-1.2.4/inflate.c b/tools/gzip-1.2.4/inflate.c new file mode 100644 index 00000000..ede36562 --- /dev/null +++ b/tools/gzip-1.2.4/inflate.c @@ -0,0 +1,954 @@ +/* inflate.c -- Not copyrighted 1992 by Mark Adler + version c10p1, 10 January 1993 */ + +/* You can do whatever you like with this source file, though I would + prefer that if you modify it and redistribute it that you include + comments to that effect with your name and the date. Thank you. + [The history has been moved to the file ChangeLog.] + */ + +/* + Inflate deflated (PKZIP's method 8 compressed) data. The compression + method searches for as much of the current string of bytes (up to a + length of 258) in the previous 32K bytes. If it doesn't find any + matches (of at least length 3), it codes the next byte. Otherwise, it + codes the length of the matched string and its distance backwards from + the current position. There is a single Huffman code that codes both + single bytes (called "literals") and match lengths. A second Huffman + code codes the distance information, which follows a length code. Each + length or distance code actually represents a base value and a number + of "extra" (sometimes zero) bits to get to add to the base value. At + the end of each deflated block is a special end-of-block (EOB) literal/ + length code. The decoding process is basically: get a literal/length + code; if EOB then done; if a literal, emit the decoded byte; if a + length then get the distance and emit the referred-to bytes from the + sliding window of previously emitted data. + + There are (currently) three kinds of inflate blocks: stored, fixed, and + dynamic. The compressor deals with some chunk of data at a time, and + decides which method to use on a chunk-by-chunk basis. A chunk might + typically be 32K or 64K. If the chunk is uncompressible, then the + "stored" method is used. In this case, the bytes are simply stored as + is, eight bits per byte, with none of the above coding. The bytes are + preceded by a count, since there is no longer an EOB code. + + If the data is compressible, then either the fixed or dynamic methods + are used. In the dynamic method, the compressed data is preceded by + an encoding of the literal/length and distance Huffman codes that are + to be used to decode this block. The representation is itself Huffman + coded, and so is preceded by a description of that code. These code + descriptions take up a little space, and so for small blocks, there is + a predefined set of codes, called the fixed codes. The fixed method is + used if the block codes up smaller that way (usually for quite small + chunks), otherwise the dynamic method is used. In the latter case, the + codes are customized to the probabilities in the current block, and so + can code it much better than the pre-determined fixed codes. + + The Huffman codes themselves are decoded using a mutli-level table + lookup, in order to maximize the speed of decoding plus the speed of + building the decoding tables. See the comments below that precede the + lbits and dbits tuning parameters. + */ + + +/* + Notes beyond the 1.93a appnote.txt: + + 1. Distance pointers never point before the beginning of the output + stream. + 2. Distance pointers can point back across blocks, up to 32k away. + 3. There is an implied maximum of 7 bits for the bit length table and + 15 bits for the actual data. + 4. If only one code exists, then it is encoded using one bit. (Zero + would be more efficient, but perhaps a little confusing.) If two + codes exist, they are coded using one bit each (0 and 1). + 5. There is no way of sending zero distance codes--a dummy must be + sent if there are none. (History: a pre 2.0 version of PKZIP would + store blocks with no distance codes, but this was discovered to be + too harsh a criterion.) Valid only for 1.93a. 2.04c does allow + zero distance codes, which is sent as one code of zero bits in + length. + 6. There are up to 286 literal/length codes. Code 256 represents the + end-of-block. Note however that the static length tree defines + 288 codes just to fill out the Huffman codes. Codes 286 and 287 + cannot be used though, since there is no length base or extra bits + defined for them. Similarly, there are up to 30 distance codes. + However, static trees define 32 codes (all 5 bits) to fill out the + Huffman codes, but the last two had better not show up in the data. + 7. Unzip can check dynamic Huffman blocks for complete code sets. + The exception is that a single code would not be complete (see #4). + 8. The five bits following the block type is really the number of + literal codes sent minus 257. + 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits + (1+6+6). Therefore, to output three times the length, you output + three codes (1+1+1), whereas to output four times the same length, + you only need two codes (1+3). Hmm. + 10. In the tree reconstruction algorithm, Code = Code + Increment + only if BitLength(i) is not zero. (Pretty obvious.) + 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) + 12. Note: length code 284 can represent 227-258, but length code 285 + really is 258. The last length deserves its own, short code + since it gets used a lot in very redundant files. The length + 258 is special since 258 - 3 (the min match length) is 255. + 13. The literal/length and distance code bit lengths are read as a + single stream of lengths. It is possible (and advantageous) for + a repeat code (16, 17, or 18) to go across the boundary between + the two sets of lengths. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp $"; +#endif + +#include + +#include "tailor.h" + +#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) +# include +#endif + +#include "gzip.h" +#define slide window + +/* Huffman code lookup table entry--this entry is four bytes for machines + that have 16-bit pointers (e.g. PC's in the small or medium model). + Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16 + means that v is a literal, 16 < e < 32 means that v is a pointer to + the next table, which codes e - 16 bits, and lastly e == 99 indicates + an unused code. If a code with e == 99 is looked up, this implies an + error in the data. */ +struct huft { + uch e; /* number of extra bits or operation */ + uch b; /* number of bits in this code or subcode */ + union { + ush n; /* literal, length base, or distance base */ + struct huft *t; /* pointer to next level of table */ + } v; +}; + + +/* Function prototypes */ +int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *, + struct huft **, int *)); +int huft_free OF((struct huft *)); +int inflate_codes OF((struct huft *, struct huft *, int, int)); +int inflate_stored OF((void)); +int inflate_fixed OF((void)); +int inflate_dynamic OF((void)); +int inflate_block OF((int *)); +int inflate OF((void)); + + +/* The inflate algorithm uses a sliding 32K byte window on the uncompressed + stream to find repeated byte strings. This is implemented here as a + circular buffer. The index is updated simply by incrementing and then + and'ing with 0x7fff (32K-1). */ +/* It is left to other modules to supply the 32K area. It is assumed + to be usable as if it were declared "uch slide[32768];" or as just + "uch *slide;" and then malloc'ed in the latter case. The definition + must be in unzip.h, included above. */ +/* unsigned wp; current position in slide */ +#define wp outcnt +#define flush_output(w) (wp=(w),flush_window()) + +/* Tables for deflate from PKZIP's appnote.txt. */ +static unsigned border[] = { /* Order of the bit length code lengths */ + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; +static ush cplens[] = { /* Copy lengths for literal codes 257..285 */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + /* note: see note #13 above about the 258 in this list. */ +static ush cplext[] = { /* Extra bits for literal codes 257..285 */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ +static ush cpdist[] = { /* Copy offsets for distance codes 0..29 */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; +static ush cpdext[] = { /* Extra bits for distance codes */ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + + + +/* Macros for inflate() bit peeking and grabbing. + The usage is: + + NEEDBITS(j) + x = b & mask_bits[j]; + DUMPBITS(j) + + where NEEDBITS makes sure that b has at least j bits in it, and + DUMPBITS removes the bits from b. The macros use the variable k + for the number of bits in b. Normally, b and k are register + variables for speed, and are initialized at the beginning of a + routine that uses these macros from a global bit buffer and count. + + If we assume that EOB will be the longest code, then we will never + ask for bits with NEEDBITS that are beyond the end of the stream. + So, NEEDBITS should not read any more bytes than are needed to + meet the request. Then no bytes need to be "returned" to the buffer + at the end of the last block. + + However, this assumption is not true for fixed blocks--the EOB code + is 7 bits, but the other literal/length codes can be 8 or 9 bits. + (The EOB code is shorter than other codes because fixed blocks are + generally short. So, while a block always has an EOB, many other + literal/length codes have a significantly lower probability of + showing up at all.) However, by making the first table have a + lookup of seven bits, the EOB code will be found in that first + lookup, and so will not require that too many bits be pulled from + the stream. + */ + +ulg bb; /* bit buffer */ +unsigned bk; /* bits in bit buffer */ + +ush mask_bits[] = { + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + +#ifdef CRYPT + uch cc; +# define NEXTBYTE() \ + (decrypt ? (cc = get_byte(), zdecode(cc), cc) : get_byte()) +#else +# define NEXTBYTE() (uch)get_byte() +#endif +#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<>=(n);k-=(n);} + + +/* + Huffman code decoding is performed using a multi-level table lookup. + The fastest way to decode is to simply build a lookup table whose + size is determined by the longest code. However, the time it takes + to build this table can also be a factor if the data being decoded + is not very long. The most common codes are necessarily the + shortest codes, so those codes dominate the decoding time, and hence + the speed. The idea is you can have a shorter table that decodes the + shorter, more probable codes, and then point to subsidiary tables for + the longer codes. The time it costs to decode the longer codes is + then traded against the time it takes to make longer tables. + + This results of this trade are in the variables lbits and dbits + below. lbits is the number of bits the first level table for literal/ + length codes can decode in one step, and dbits is the same thing for + the distance codes. Subsequent tables are also less than or equal to + those sizes. These values may be adjusted either when all of the + codes are shorter than that, in which case the longest code length in + bits is used, or when the shortest code is *longer* than the requested + table size, in which case the length of the shortest code in bits is + used. + + There are two different values for the two tables, since they code a + different number of possibilities each. The literal/length table + codes 286 possible values, or in a flat code, a little over eight + bits. The distance table codes 30 possible values, or a little less + than five bits, flat. The optimum values for speed end up being + about one bit more than those, so lbits is 8+1 and dbits is 5+1. + The optimum values may differ though from machine to machine, and + possibly even between compilers. Your mileage may vary. + */ + + +int lbits = 9; /* bits in base literal/length lookup table */ +int dbits = 6; /* bits in base distance lookup table */ + + +/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ +#define BMAX 16 /* maximum bit length of any code (16 for explode) */ +#define N_MAX 288 /* maximum number of codes in any set */ + + +unsigned hufts; /* track memory usage */ + + +int huft_build(b, n, s, d, e, t, m) +unsigned *b; /* code lengths in bits (all assumed <= BMAX) */ +unsigned n; /* number of codes (assumed <= N_MAX) */ +unsigned s; /* number of simple-valued codes (0..s-1) */ +ush *d; /* list of base values for non-simple codes */ +ush *e; /* list of extra bits for non-simple codes */ +struct huft **t; /* result: starting table */ +int *m; /* maximum lookup bits, returns actual */ +/* Given a list of code lengths and a maximum table size, make a set of + tables to decode that set of codes. Return zero on success, one if + the given code set is incomplete (the tables are still built in this + case), two if the input is invalid (all zero length codes or an + oversubscribed set of lengths), and three if not enough memory. */ +{ + unsigned a; /* counter for codes of length k */ + unsigned c[BMAX+1]; /* bit length count table */ + unsigned f; /* i repeats in table every f entries */ + int g; /* maximum code length */ + int h; /* table level */ + register unsigned i; /* counter, current code */ + register unsigned j; /* counter */ + register int k; /* number of bits in current code */ + int l; /* bits per table (returned in m) */ + register unsigned *p; /* pointer into c[], b[], or v[] */ + register struct huft *q; /* points to current table */ + struct huft r; /* table entry for structure assignment */ + struct huft *u[BMAX]; /* table stack */ + unsigned v[N_MAX]; /* values in order of bit length */ + register int w; /* bits before this table == (l * h) */ + unsigned x[BMAX+1]; /* bit offsets, then code stack */ + unsigned *xp; /* pointer into x */ + int y; /* number of dummy codes added */ + unsigned z; /* number of entries in current table */ + + + /* Generate counts for each bit length */ + memzero(c, sizeof(c)); + p = b; i = n; + do { + Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"), + n-i, *p)); + c[*p]++; /* assume all entries <= BMAX */ + p++; /* Can't combine with above line (Solaris bug) */ + } while (--i); + if (c[0] == n) /* null input--all zero length codes */ + { + *t = (struct huft *)NULL; + *m = 0; + return 0; + } + + + /* Find minimum and maximum length, bound *m by those */ + l = *m; + for (j = 1; j <= BMAX; j++) + if (c[j]) + break; + k = j; /* minimum code length */ + if ((unsigned)l < j) + l = j; + for (i = BMAX; i; i--) + if (c[i]) + break; + g = i; /* maximum code length */ + if ((unsigned)l > i) + l = i; + *m = l; + + + /* Adjust last length count to fill out codes, if needed */ + for (y = 1 << j; j < i; j++, y <<= 1) + if ((y -= c[j]) < 0) + return 2; /* bad input: more codes than bits */ + if ((y -= c[i]) < 0) + return 2; + c[i] += y; + + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; xp = x + 2; + while (--i) { /* note that i == g from above */ + *xp++ = (j += *p++); + } + + + /* Make a table of values in order of bit lengths */ + p = b; i = 0; + do { + if ((j = *p++) != 0) + v[x[j]++] = i; + } while (++i < n); + + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + h = -1; /* no tables yet--level -1 */ + w = -l; /* bits decoded == (l * h) */ + u[0] = (struct huft *)NULL; /* just to keep compilers happy */ + q = (struct huft *)NULL; /* ditto */ + z = 0; /* ditto */ + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > w + l) + { + h++; + w += l; /* previous table always l bits */ + + /* compute minimum size table less than or equal to l bits */ + z = (z = g - w) > (unsigned)l ? l : z; /* upper limit on table size */ + if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ + { /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) + break; /* enough codes to use up j bits */ + f -= *xp; /* else deduct codes from patterns */ + } + } + z = 1 << j; /* table entries for j-bit table */ + + /* allocate and link in new table */ + if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) == + (struct huft *)NULL) + { + if (h) + huft_free(u[0]); + return 3; /* not enough memory */ + } + hufts += z + 1; /* track memory usage */ + *t = q + 1; /* link to list for huft_free() */ + *(t = &(q->v.t)) = (struct huft *)NULL; + u[h] = ++q; /* table starts after link */ + + /* connect to last table, if there is one */ + if (h) + { + x[h] = i; /* save pattern for backing up */ + r.b = (uch)l; /* bits to dump before this table */ + r.e = (uch)(16 + j); /* bits in this table */ + r.v.t = q; /* pointer to this table */ + j = i >> (w - l); /* (get around Turbo C bug) */ + u[h-1][j] = r; /* connect to last table */ + } + } + + /* set up table entry in r */ + r.b = (uch)(k - w); + if (p >= v + n) + r.e = 99; /* out of values--invalid code */ + else if (*p < s) + { + r.e = (uch)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */ + r.v.n = (ush)(*p); /* simple code is just the value */ + p++; /* one compiler does not like *p++ */ + } + else + { + r.e = (uch)e[*p - s]; /* non-simple--look up in lists */ + r.v.n = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + q[j] = r; + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i & j; j >>= 1) + i ^= j; + i ^= j; + + /* backup over finished tables */ + while ((i & ((1 << w) - 1)) != x[h]) + { + h--; /* don't need to update q */ + w -= l; + } + } + } + + + /* Return true (1) if we were given an incomplete table */ + return y != 0 && g != 1; +} + + + +int huft_free(t) +struct huft *t; /* table to free */ +/* Free the malloc'ed tables built by huft_build(), which makes a linked + list of the tables it made, with the links in a dummy first entry of + each table. */ +{ + register struct huft *p, *q; + + + /* Go through linked list, freeing from the malloced (t[-1]) address. */ + p = t; + while (p != (struct huft *)NULL) + { + q = (--p)->v.t; + free((char*)p); + p = q; + } + return 0; +} + + +int inflate_codes(tl, td, bl, bd) +struct huft *tl, *td; /* literal/length and distance decoder tables */ +int bl, bd; /* number of bits decoded by tl[] and td[] */ +/* inflate (decompress) the codes in a deflated (compressed) block. + Return an error code or zero if it all goes ok. */ +{ + register unsigned e; /* table entry flag/number of extra bits */ + unsigned n, d; /* length and index for copy */ + unsigned w; /* current window position */ + struct huft *t; /* pointer to table entry */ + unsigned ml, md; /* masks for bl and bd bits */ + register ulg b; /* bit buffer */ + register unsigned k; /* number of bits in bit buffer */ + + + /* make local copies of globals */ + b = bb; /* initialize bit buffer */ + k = bk; + w = wp; /* initialize window position */ + + /* inflate the coded data */ + ml = mask_bits[bl]; /* precompute masks for speed */ + md = mask_bits[bd]; + for (;;) /* do until end of block */ + { + NEEDBITS((unsigned)bl) + if ((e = (t = tl + ((unsigned)b & ml))->e) > 16) + do { + if (e == 99) + return 1; + DUMPBITS(t->b) + e -= 16; + NEEDBITS(e) + } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16); + DUMPBITS(t->b) + if (e == 16) /* then it's a literal */ + { + slide[w++] = (uch)t->v.n; + Tracevv((stderr, "%c", slide[w-1])); + if (w == WSIZE) + { + flush_output(w); + w = 0; + } + } + else /* it's an EOB or a length */ + { + /* exit if end of block */ + if (e == 15) + break; + + /* get length of block to copy */ + NEEDBITS(e) + n = t->v.n + ((unsigned)b & mask_bits[e]); + DUMPBITS(e); + + /* decode distance of block to copy */ + NEEDBITS((unsigned)bd) + if ((e = (t = td + ((unsigned)b & md))->e) > 16) + do { + if (e == 99) + return 1; + DUMPBITS(t->b) + e -= 16; + NEEDBITS(e) + } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16); + DUMPBITS(t->b) + NEEDBITS(e) + d = w - t->v.n - ((unsigned)b & mask_bits[e]); + DUMPBITS(e) + Tracevv((stderr,"\\[%d,%d]", w-d, n)); + + /* do the copy */ + do { + n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); +#if !defined(NOMEMCPY) && !defined(DEBUG) + if (w - d >= e) /* (this test assumes unsigned comparison) */ + { + memcpy(slide + w, slide + d, e); + w += e; + d += e; + } + else /* do it slow to avoid memcpy() overlap */ +#endif /* !NOMEMCPY */ + do { + slide[w++] = slide[d++]; + Tracevv((stderr, "%c", slide[w-1])); + } while (--e); + if (w == WSIZE) + { + flush_output(w); + w = 0; + } + } while (n); + } + } + + + /* restore the globals from the locals */ + wp = w; /* restore global window pointer */ + bb = b; /* restore global bit buffer */ + bk = k; + + /* done */ + return 0; +} + + + +int inflate_stored() +/* "decompress" an inflated type 0 (stored) block. */ +{ + unsigned n; /* number of bytes in block */ + unsigned w; /* current window position */ + register ulg b; /* bit buffer */ + register unsigned k; /* number of bits in bit buffer */ + + + /* make local copies of globals */ + b = bb; /* initialize bit buffer */ + k = bk; + w = wp; /* initialize window position */ + + + /* go to byte boundary */ + n = k & 7; + DUMPBITS(n); + + + /* get the length and its complement */ + NEEDBITS(16) + n = ((unsigned)b & 0xffff); + DUMPBITS(16) + NEEDBITS(16) + if (n != (unsigned)((~b) & 0xffff)) + return 1; /* error in compressed data */ + DUMPBITS(16) + + + /* read and output the compressed data */ + while (n--) + { + NEEDBITS(8) + slide[w++] = (uch)b; + if (w == WSIZE) + { + flush_output(w); + w = 0; + } + DUMPBITS(8) + } + + + /* restore the globals from the locals */ + wp = w; /* restore global window pointer */ + bb = b; /* restore global bit buffer */ + bk = k; + return 0; +} + + + +int inflate_fixed() +/* decompress an inflated type 1 (fixed Huffman codes) block. We should + either replace this with a custom decoder, or at least precompute the + Huffman tables. */ +{ + int i; /* temporary variable */ + struct huft *tl; /* literal/length code table */ + struct huft *td; /* distance code table */ + int bl; /* lookup bits for tl */ + int bd; /* lookup bits for td */ + unsigned l[288]; /* length list for huft_build */ + + + /* set up literal table */ + for (i = 0; i < 144; i++) + l[i] = 8; + for (; i < 256; i++) + l[i] = 9; + for (; i < 280; i++) + l[i] = 7; + for (; i < 288; i++) /* make a complete, but wrong code set */ + l[i] = 8; + bl = 7; + if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) + return i; + + + /* set up distance table */ + for (i = 0; i < 30; i++) /* make an incomplete code set */ + l[i] = 5; + bd = 5; + if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) + { + huft_free(tl); + return i; + } + + + /* decompress until an end-of-block code */ + if (inflate_codes(tl, td, bl, bd)) + return 1; + + + /* free the decoding tables, return */ + huft_free(tl); + huft_free(td); + return 0; +} + + + +int inflate_dynamic() +/* decompress an inflated type 2 (dynamic Huffman codes) block. */ +{ + int i; /* temporary variables */ + unsigned j; + unsigned l; /* last length */ + unsigned m; /* mask for bit lengths table */ + unsigned n; /* number of lengths to get */ + struct huft *tl; /* literal/length code table */ + struct huft *td; /* distance code table */ + int bl; /* lookup bits for tl */ + int bd; /* lookup bits for td */ + unsigned nb; /* number of bit length codes */ + unsigned nl; /* number of literal/length codes */ + unsigned nd; /* number of distance codes */ +#ifdef PKZIP_BUG_WORKAROUND + unsigned ll[288+32]; /* literal/length and distance code lengths */ +#else + unsigned ll[286+30]; /* literal/length and distance code lengths */ +#endif + register ulg b; /* bit buffer */ + register unsigned k; /* number of bits in bit buffer */ + + + /* make local bit buffer */ + b = bb; + k = bk; + + + /* read in table lengths */ + NEEDBITS(5) + nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */ + DUMPBITS(5) + NEEDBITS(5) + nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */ + DUMPBITS(5) + NEEDBITS(4) + nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */ + DUMPBITS(4) +#ifdef PKZIP_BUG_WORKAROUND + if (nl > 288 || nd > 32) +#else + if (nl > 286 || nd > 30) +#endif + return 1; /* bad lengths */ + + + /* read in bit-length-code lengths */ + for (j = 0; j < nb; j++) + { + NEEDBITS(3) + ll[border[j]] = (unsigned)b & 7; + DUMPBITS(3) + } + for (; j < 19; j++) + ll[border[j]] = 0; + + + /* build decoding table for trees--single level, 7 bit lookup */ + bl = 7; + if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) + { + if (i == 1) + huft_free(tl); + return i; /* incomplete code set */ + } + + + /* read in literal and distance code lengths */ + n = nl + nd; + m = mask_bits[bl]; + i = l = 0; + while ((unsigned)i < n) + { + NEEDBITS((unsigned)bl) + j = (td = tl + ((unsigned)b & m))->b; + DUMPBITS(j) + j = td->v.n; + if (j < 16) /* length of code in bits (0..15) */ + ll[i++] = l = j; /* save last length in l */ + else if (j == 16) /* repeat last length 3 to 6 times */ + { + NEEDBITS(2) + j = 3 + ((unsigned)b & 3); + DUMPBITS(2) + if ((unsigned)i + j > n) + return 1; + while (j--) + ll[i++] = l; + } + else if (j == 17) /* 3 to 10 zero length codes */ + { + NEEDBITS(3) + j = 3 + ((unsigned)b & 7); + DUMPBITS(3) + if ((unsigned)i + j > n) + return 1; + while (j--) + ll[i++] = 0; + l = 0; + } + else /* j == 18: 11 to 138 zero length codes */ + { + NEEDBITS(7) + j = 11 + ((unsigned)b & 0x7f); + DUMPBITS(7) + if ((unsigned)i + j > n) + return 1; + while (j--) + ll[i++] = 0; + l = 0; + } + } + + + /* free decoding table for trees */ + huft_free(tl); + + + /* restore the global bit buffer */ + bb = b; + bk = k; + + + /* build the decoding tables for literal/length and distance codes */ + bl = lbits; + if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) + { + if (i == 1) { + fprintf(stderr, " incomplete literal tree\n"); + huft_free(tl); + } + return i; /* incomplete code set */ + } + bd = dbits; + if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) + { + if (i == 1) { + fprintf(stderr, " incomplete distance tree\n"); +#ifdef PKZIP_BUG_WORKAROUND + i = 0; + } +#else + huft_free(td); + } + huft_free(tl); + return i; /* incomplete code set */ +#endif + } + + + /* decompress until an end-of-block code */ + if (inflate_codes(tl, td, bl, bd)) + return 1; + + + /* free the decoding tables, return */ + huft_free(tl); + huft_free(td); + return 0; +} + + + +int inflate_block(e) +int *e; /* last block flag */ +/* decompress an inflated block */ +{ + unsigned t; /* block type */ + register ulg b; /* bit buffer */ + register unsigned k; /* number of bits in bit buffer */ + + + /* make local bit buffer */ + b = bb; + k = bk; + + + /* read in last block bit */ + NEEDBITS(1) + *e = (int)b & 1; + DUMPBITS(1) + + + /* read in block type */ + NEEDBITS(2) + t = (unsigned)b & 3; + DUMPBITS(2) + + + /* restore the global bit buffer */ + bb = b; + bk = k; + + + /* inflate that block type */ + if (t == 2) + return inflate_dynamic(); + if (t == 0) + return inflate_stored(); + if (t == 1) + return inflate_fixed(); + + + /* bad block type */ + return 2; +} + + + +int inflate() +/* decompress an inflated entry */ +{ + int e; /* last block flag */ + int r; /* result code */ + unsigned h; /* maximum struct huft's malloc'ed */ + + + /* initialize window, bit buffer */ + wp = 0; + bk = 0; + bb = 0; + + + /* decompress until the last block */ + h = 0; + do { + hufts = 0; + if ((r = inflate_block(&e)) != 0) + return r; + if (hufts > h) + h = hufts; + } while (!e); + + /* Undo too much lookahead. The next read will be byte aligned so we + * can discard unused bits in the last meaningful byte. + */ + while (bk >= 8) { + bk -= 8; + inptr--; + } + + /* flush out slide */ + flush_output(wp); + + + /* return success */ +#ifdef DEBUG + fprintf(stderr, "<%u> ", h); +#endif /* DEBUG */ + return 0; +} diff --git a/tools/gzip-1.2.4/lzw.c b/tools/gzip-1.2.4/lzw.c new file mode 100644 index 00000000..12bf5c61 --- /dev/null +++ b/tools/gzip-1.2.4/lzw.c @@ -0,0 +1,26 @@ +/* lzw.c -- compress files in LZW format. + * This is a dummy version avoiding patent problems. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: lzw.c,v 0.9 1993/06/10 13:27:31 jloup Exp $"; +#endif + +#include "tailor.h" +#include "gzip.h" +#include "lzw.h" + +static int msg_done = 0; + +/* Compress in to out with lzw method. */ +int lzw(in, out) + int in, out; +{ + if (msg_done) return ERROR; + msg_done = 1; + fprintf(stderr,"output in compress .Z format not supported\n"); + if (in != out) { /* avoid warnings on unused variables */ + exit_code = ERROR; + } + return ERROR; +} diff --git a/tools/gzip-1.2.4/lzw.h b/tools/gzip-1.2.4/lzw.h new file mode 100644 index 00000000..4b7ac868 --- /dev/null +++ b/tools/gzip-1.2.4/lzw.h @@ -0,0 +1,42 @@ +/* lzw.h -- define the lzw functions. + * Copyright (C) 1992-1993 Jean-loup Gailly. + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +#if !defined(OF) && defined(lint) +# include "gzip.h" +#endif + +#ifndef BITS +# define BITS 16 +#endif +#define INIT_BITS 9 /* Initial number of bits per code */ + +#define LZW_MAGIC "\037\235" /* Magic header for lzw files, 1F 9D */ + +#define BIT_MASK 0x1f /* Mask for 'number of compression bits' */ +/* Mask 0x20 is reserved to mean a fourth header byte, and 0x40 is free. + * It's a pity that old uncompress does not check bit 0x20. That makes + * extension of the format actually undesirable because old compress + * would just crash on the new format instead of giving a meaningful + * error message. It does check the number of bits, but it's more + * helpful to say "unsupported format, get a new version" than + * "can only handle 16 bits". + */ + +#define BLOCK_MODE 0x80 +/* Block compression: if table is full and compression rate is dropping, + * clear the dictionary. + */ + +#define LZW_RESERVED 0x60 /* reserved bits */ + +#define CLEAR 256 /* flush the dictionary */ +#define FIRST (CLEAR+1) /* first free entry */ + +extern int maxbits; /* max bits per code for LZW */ +extern int block_mode; /* block compress mode -C compatible with 2.0 */ + +extern int lzw OF((int in, int out)); +extern int unlzw OF((int in, int out)); diff --git a/tools/gzip-1.2.4/match.S b/tools/gzip-1.2.4/match.S new file mode 100644 index 00000000..4a3d681c --- /dev/null +++ b/tools/gzip-1.2.4/match.S @@ -0,0 +1,379 @@ +/* match.s -- optional optimized asm version of longest match in deflate.c + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + * + * The 68020 version has been written by Francesco Potorti` + * with adaptations by Carsten Steger , + * Andreas Schwab and + * Kristoffer Eriksson + */ + +/* $Id: match.S,v 0.14 1993/06/11 18:33:24 jloup Exp $ */ + +/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix + * external symbols with an underline character '_'. + */ +#ifdef NO_UNDERLINE +# define _prev prev +# define _window window +# define _match_start match_start +# define _prev_length prev_length +# define _good_match good_match +# define _nice_match nice_match +# define _strstart strstart +# define _max_chain_length max_chain_length + +# define _match_init match_init +# define _longest_match longest_match +#endif + +#ifdef DYN_ALLOC + error: DYN_ALLOC not yet supported in match.s +#endif + +#if defined(i386) || defined(_I386) + +/* This version is for 386 Unix or OS/2 in 32 bit mode. + * Warning: it uses the AT&T syntax: mov source,dest + * This file is only optional. If you want to force the C version, + * add -DNO_ASM to CFLAGS in Makefile and set OBJA to an empty string. + * If you have reduced WSIZE in gzip.h, then change its value below. + * This version assumes static allocation of the arrays (-DDYN_ALLOC not used). + */ + + .file "match.S" + +#define MAX_MATCH 258 +#define MAX_MATCH2 $128 /* MAX_MATCH/2-1 */ +#define MIN_MATCH 3 +#define WSIZE $32768 +#define MAX_DIST WSIZE - MAX_MATCH - MIN_MATCH - 1 + + .globl _match_init + .globl _longest_match + + .text + +_match_init: + ret + +/*----------------------------------------------------------------------- + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + */ + +_longest_match: /* int longest_match(cur_match) */ + +#define cur_match 20(%esp) + /* return address */ /* esp+16 */ + push %ebp /* esp+12 */ + push %edi /* esp+8 */ + push %esi /* esp+4 */ + push %ebx /* esp */ + +/* + * match equ esi + * scan equ edi + * chain_length equ ebp + * best_len equ ebx + * limit equ edx + */ + mov cur_match,%esi + mov _max_chain_length,%ebp /* chain_length = max_chain_length */ + mov _strstart,%edi + mov %edi,%edx + sub MAX_DIST,%edx /* limit = strstart-MAX_DIST */ + jae limit_ok + sub %edx,%edx /* limit = NIL */ +limit_ok: + add $2+_window,%edi /* edi = offset(window+strstart+2) */ + mov _prev_length,%ebx /* best_len = prev_length */ + movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ + movw -2(%edi),%cx /* cx = scan[0..1] */ + cmp _good_match,%ebx /* do we have a good match already? */ + jb do_scan + shr $2,%ebp /* chain_length >>= 2 */ + jmp do_scan + + .align 4 +long_loop: +/* at this point, edi == scan+2, esi == cur_match */ + movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ + movw -2(%edi),%cx /* cx = scan[0..1] */ +short_loop: +/* + * at this point, di == scan+2, si == cur_match, + * ax = scan[best_len-1..best_len] and cx = scan[0..1] + */ + and WSIZE-1, %esi + movw _prev(%esi,%esi),%si /* cur_match = prev[cur_match] */ + /* top word of esi is still 0 */ + cmp %edx,%esi /* cur_match <= limit ? */ + jbe the_end + dec %ebp /* --chain_length */ + jz the_end +do_scan: + cmpw _window-1(%ebx,%esi),%ax/* check match at best_len-1 */ + jne short_loop + cmpw _window(%esi),%cx /* check min_match_length match */ + jne short_loop + + lea _window+2(%esi),%esi /* si = match */ + mov %edi,%eax /* ax = scan+2 */ + mov MAX_MATCH2,%ecx /* scan for at most MAX_MATCH bytes */ + rep; cmpsw /* loop until mismatch */ + je maxmatch /* match of length MAX_MATCH? */ +mismatch: + movb -2(%edi),%cl /* mismatch on first or second byte? */ + subb -2(%esi),%cl /* cl = 0 if first bytes equal */ + xchg %edi,%eax /* edi = scan+2, eax = end of scan */ + sub %edi,%eax /* eax = len */ + sub %eax,%esi /* esi = cur_match + 2 + offset(window) */ + sub $2+_window,%esi /* esi = cur_match */ + subb $1,%cl /* set carry if cl == 0 (cannot use DEC) */ + adc $0,%eax /* eax = carry ? len+1 : len */ + cmp %ebx,%eax /* len > best_len ? */ + jle long_loop + mov %esi,_match_start /* match_start = cur_match */ + mov %eax,%ebx /* ebx = best_len = len */ + cmp _nice_match,%eax /* len >= nice_match ? */ + jl long_loop +the_end: + mov %ebx,%eax /* result = eax = best_len */ + pop %ebx + pop %esi + pop %edi + pop %ebp + ret +maxmatch: + cmpsb + jmp mismatch + +#else + +/* ======================== 680x0 version ================================= */ + +#if defined(m68k)||defined(mc68k)||defined(__mc68000__)||defined(__MC68000__) +# ifndef mc68000 +# define mc68000 +# endif +#endif + +#if defined(__mc68020__) || defined(__MC68020__) || defined(sysV68) +# ifndef mc68020 +# define mc68020 +# endif +#endif + +#if defined(mc68020) || defined(mc68000) + +#if (defined(mc68020) || defined(NeXT)) && !defined(UNALIGNED_OK) +# define UNALIGNED_OK +#endif + +#ifdef sysV68 /* Try Motorola Delta style */ + +# define GLOBAL(symbol) global symbol +# define TEXT text +# define FILE(filename) file filename +# define invert_maybe(src,dst) dst,src +# define imm(data) &data +# define reg(register) %register + +# define addl add.l +# define addql addq.l +# define blos blo.b +# define bhis bhi.b +# define bras bra.b +# define clrl clr.l +# define cmpmb cmpm.b +# define cmpw cmp.w +# define cmpl cmp.l +# define lslw lsl.w +# define lsrl lsr.l +# define movel move.l +# define movew move.w +# define moveb move.b +# define moveml movem.l +# define subl sub.l +# define subw sub.w +# define subql subq.l + +# define IndBase(bd,An) (bd,An) +# define IndBaseNdxl(bd,An,Xn) (bd,An,Xn.l) +# define IndBaseNdxw(bd,An,Xn) (bd,An,Xn.w) +# define predec(An) -(An) +# define postinc(An) (An)+ + +#else /* default style (Sun 3, NeXT, Amiga, Atari) */ + +# define GLOBAL(symbol) .globl symbol +# define TEXT .text +# define FILE(filename) .even +# define invert_maybe(src,dst) src,dst +# if defined(sun) || defined(mc68k) +# define imm(data) #data +# else +# define imm(data) \#data +# endif +# define reg(register) register + +# define blos bcss +# if defined(sun) || defined(mc68k) +# define movel movl +# define movew movw +# define moveb movb +# endif +# define IndBase(bd,An) An@(bd) +# define IndBaseNdxl(bd,An,Xn) An@(bd,Xn:l) +# define IndBaseNdxw(bd,An,Xn) An@(bd,Xn:w) +# define predec(An) An@- +# define postinc(An) An@+ + +#endif /* styles */ + +#define Best_Len reg(d0) /* unsigned */ +#define Cur_Match reg(d1) /* Ipos */ +#define Loop_Counter reg(d2) /* int */ +#define Scan_Start reg(d3) /* unsigned short */ +#define Scan_End reg(d4) /* unsigned short */ +#define Limit reg(d5) /* IPos */ +#define Chain_Length reg(d6) /* unsigned */ +#define Scan_Test reg(d7) +#define Scan reg(a0) /* *uch */ +#define Match reg(a1) /* *uch */ +#define Prev_Address reg(a2) /* *Pos */ +#define Scan_Ini reg(a3) /* *uch */ +#define Match_Ini reg(a4) /* *uch */ +#define Stack_Pointer reg(sp) + +#define MAX_MATCH 258 +#define MIN_MATCH 3 +#define WSIZE 32768 +#define MAX_DIST (WSIZE - MAX_MATCH - MIN_MATCH - 1) + + GLOBAL (_match_init) + GLOBAL (_longest_match) + + TEXT + + FILE ("match.S") + +_match_init: + rts + +/*----------------------------------------------------------------------- + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + */ + +/* int longest_match (cur_match) */ + +#ifdef UNALIGNED_OK +# define pushreg 15928 /* d2-d6/a2-a4 */ +# define popreg 7292 +#else +# define pushreg 16184 /* d2-d7/a2-a4 */ +# define popreg 7420 +#endif + +_longest_match: + movel IndBase(4,Stack_Pointer),Cur_Match + moveml imm(pushreg),predec(Stack_Pointer) + movel _max_chain_length,Chain_Length + movel _prev_length,Best_Len + movel imm(_prev),Prev_Address + movel imm(_window+MIN_MATCH),Match_Ini + movel _strstart,Limit + movel Match_Ini,Scan_Ini + addl Limit,Scan_Ini + subw imm(MAX_DIST),Limit + bhis L__limit_ok + clrl Limit +L__limit_ok: + cmpl invert_maybe(_good_match,Best_Len) + blos L__length_ok + lsrl imm(2),Chain_Length +L__length_ok: + subql imm(1),Chain_Length +#ifdef UNALIGNED_OK + movew IndBase(-MIN_MATCH,Scan_Ini),Scan_Start + movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End +#else + moveb IndBase(-MIN_MATCH,Scan_Ini),Scan_Start + lslw imm(8),Scan_Start + moveb IndBase(-MIN_MATCH+1,Scan_Ini),Scan_Start + moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End + lslw imm(8),Scan_End + moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End +#endif + bras L__do_scan + +L__long_loop: +#ifdef UNALIGNED_OK + movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End +#else + moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End + lslw imm(8),Scan_End + moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End +#endif + +L__short_loop: + lslw imm(1),Cur_Match + movew IndBaseNdxl(0,Prev_Address,Cur_Match),Cur_Match + cmpw invert_maybe(Limit,Cur_Match) + dbls Chain_Length,L__do_scan + bras L__return + +L__do_scan: + movel Match_Ini,Match + addl Cur_Match,Match +#ifdef UNALIGNED_OK + cmpw invert_maybe(IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_End) + bne L__short_loop + cmpw invert_maybe(IndBase(-MIN_MATCH,Match),Scan_Start) + bne L__short_loop +#else + moveb IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_Test + lslw imm(8),Scan_Test + moveb IndBaseNdxw(-MIN_MATCH,Match,Best_Len),Scan_Test + cmpw invert_maybe(Scan_Test,Scan_End) + bne L__short_loop + moveb IndBase(-MIN_MATCH,Match),Scan_Test + lslw imm(8),Scan_Test + moveb IndBase(-MIN_MATCH+1,Match),Scan_Test + cmpw invert_maybe(Scan_Test,Scan_Start) + bne L__short_loop +#endif + + movew imm((MAX_MATCH-MIN_MATCH+1)-1),Loop_Counter + movel Scan_Ini,Scan +L__scan_loop: + cmpmb postinc(Match),postinc(Scan) + dbne Loop_Counter,L__scan_loop + + subl Scan_Ini,Scan + addql imm(MIN_MATCH-1),Scan + cmpl invert_maybe(Best_Len,Scan) + bls L__short_loop + movel Scan,Best_Len + movel Cur_Match,_match_start + cmpl invert_maybe(_nice_match,Best_Len) + blos L__long_loop +L__return: + moveml postinc(Stack_Pointer),imm(popreg) + rts + +#else + error: this asm version is for 386 or 680x0 only +#endif /* mc68000 || mc68020 */ +#endif /* i386 || _I386 */ diff --git a/tools/gzip-1.2.4/msdos/Makefile.bor b/tools/gzip-1.2.4/msdos/Makefile.bor new file mode 100644 index 00000000..1165b7cf --- /dev/null +++ b/tools/gzip-1.2.4/msdos/Makefile.bor @@ -0,0 +1,118 @@ +# Makefile for gzip +# Borland (Turbo) C++. +# Warning: this file is not suitable for Turbo C 2.0. In this case, read +# then invoke the file doturboc.bat. + +# To use, do "make -fmakefile.bor" + +# Turbo C++ 1.0 seems to have a buggy exit() function. You must add +# to CFLAGS: -Dexit=_exit + +# WARNING: the small model is not supported. The compact model is used +# here. If you want to use the large model, add -D__LARGE__ to ASFLAGS +# Add -DSMALL_MEM to CFLAGS if you wish to reduce the memory +# requirements. Add -DNO_ASM to CFLAGS and remove match.obj from OBJA if +# you do not have tasm. + +# ------------- Turbo C++, Borland C++ ------------- +MODEL=-mc +#CFLAGS=-w -w-eff -w-def -w-sig -w-cln -a -d -G -O -Z $(MODEL) +CFLAGS=-O2 -Z $(MODEL) +CC=bcc +LD=bcc +# replace bcc with tcc for Turbo C++ 1.0 +LDFLAGS=$(MODEL) +AS=tasm +ASFLAGS=-ml -t -DDYN_ALLOC -DSS_NEQ_DS +LIB = c:\bcc\lib + +# ------------- Common declarations: +STRIP=rem +# If you don't have lzexe, get it (by ftp on wuarchive.wustl.edu +# in /mirrors/msdos/filutl/lzexe91e.zip). Then define: +#STRIP=lzexe +# Or if you've registered PKLITE, then define: +#STRIP=pklite +# This makes a big difference in .exe size (and possibly load time) + +O=.obj +OBJA=match$(O) tailor$(O) $(LIB)\wildargs.obj + +# ------------- Used by install rule +# set BIN to the directory you want to install the executables to +BIN = c:\bin + +# variables +OBJ1 = gzip$(O) zip$(O) deflate$(O) trees$(O) bits$(O) unzip$(O) inflate$(O) \ + util$(O) +OBJ2 = crypt$(O) lzw$(O) unlzw$(O) unpack$(O) unlzh$(O) getopt$(O) $(OBJA) + +all: gzip.exe + +gzip.obj: gzip.c gzip.h tailor.h crypt.h revision.h lzw.h + $(CC) -c $(CFLAGS) $*.c + +zip.obj: zip.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +deflate.obj: deflate.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +trees.obj: trees.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +bits.obj: bits.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +unzip.obj: unzip.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +inflate.obj: inflate.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +util.obj: util.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +crypt.obj: crypt.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +lzw.obj: lzw.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +unlzw.obj: unlzw.c gzip.h tailor.h lzw.h + $(CC) -c $(CFLAGS) $*.c + +unpack.obj: unpack.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +unlzh.obj: unlzh.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +tailor.obj: msdos\tailor.c gzip.h tailor.h + $(CC) -c $(CFLAGS) msdos\$*.c + +getopt.obj: getopt.c getopt.h + $(CC) -c $(CFLAGS) $*.c + +match.obj: msdos\match.asm + $(AS) $(ASFLAGS) msdos\match, match; + +# we must cut the command line to fit in the MS/DOS 128 byte limit: +gzip.exe: $(OBJ1) $(OBJ2) + echo $(OBJ1) > gzip.rsp + echo $(OBJ2) >> gzip.rsp + $(LD) $(LDFLAGS) @gzip.rsp + del gzip.rsp + $(STRIP) gzip.exe +# If you use Borland make, you can use instead: +# $(LD) $(LDFLAGS) @&&| +#$** +#| + +install: gzip.exe + copy /b gzip.exe $(BIN) + copy /b gzip.exe $(BIN)\gunzip.exe + +clean: + del *.obj + del *.exe diff --git a/tools/gzip-1.2.4/msdos/Makefile.djg b/tools/gzip-1.2.4/msdos/Makefile.djg new file mode 100644 index 00000000..514d963d --- /dev/null +++ b/tools/gzip-1.2.4/msdos/Makefile.djg @@ -0,0 +1,224 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation +# Modified for GNUish make/MS_SH200/DJGPP 1.09+ by Eric Backus + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# $Id: Makefile.djg,v 1.3 1993/06/22 15:43:24 jloup Exp $ + +#### Start of system configuration section. #### + +.SUFFIXES: .o +LONGARGS = gcc:rm + +srcdir = . +VPATH = . + +CC = gcc +CPP = gcc -O -E + +INSTALL = install -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 + +# tailor.h defines things for DJGPP so nothing is needed here +DEFS = +LIBS = + +# additional assembly sources for particular systems may be required. +OBJA = match.o + +SEDCMD = 1d + +CFLAGS = -O2 -finline-functions -fomit-frame-pointer +LDFLAGS = -s + +X=.exe +# For OS/2 or MSDOS, use: X=.exe + +O=.o +# For OS/2 or MSDOS, use: O=.obj + +prefix = /usr/local +exec_prefix = $(prefix) + +bindir = $(exec_prefix)/bin +datadir = $(prefix)/lib +libdir = $(prefix)/lib +infodir = $(prefix)/info + +# Extension (not including `.') for the installed manual page filenames. +manext = 1 +# Where to install the manual pages. +mandir = $(prefix)/man/man$(manext) + +#### End of system configuration section. #### + +SHELL = /bin/sh + +LOADLIBES = $(LIBS) + +TAR = tar + +SRCS = gzip.c zip.c deflate.c trees.c bits.c unzip.c inflate.c util.c crypt.c\ + lzw.c unlzw.c unpack.c unlzh.c makecrc.c getopt.c match.S + +OBJ1 = gzip$(O) zip$(O) deflate$(O) trees$(O) bits$(O) unzip$(O) inflate$(O) \ + util$(O) +OBJ2 = crypt$(O) lzw$(O) unlzw$(O) unpack$(O) unlzh$(O) getopt$(O) $(OBJA) + +HDRS = gzip.h lzw.h tailor.h revision.h crypt.h getopt.h + +.c$O: + $(CC) -c $(DEFS) $(CFLAGS) $< + +#.PHONY: default all force test check + +default: all +all: gzip$X zcmp zdiff zmore znew zforce gzexe +force: + +install: all + for f in gzip$X zcmp zdiff zmore znew zforce gzexe; do \ + $(INSTALL_PROGRAM) $${f} $(bindir)/$${f}; done + for f in gunzip$X zcat$X ; do \ + rm -f $(bindir)/$${f}; ln $(bindir)/gzip$X $(bindir)/$${f}; done + -cd $(srcdir); \ + for f in gzip gunzip zcat zcmp zmore znew zforce gzexe; do \ + rm -f $(mandir)/$${f}.$(manext); \ + $(INSTALL_DATA) $${f}.1 $(mandir)/$${f}.$(manext); done + -cd $(srcdir); for f in gzip.info* ; do $(INSTALL_DATA) $${f} \ + $(infodir)/$${f}; done + +uninstall: force + -cd $(bindir); rm -f gzip$X gunzip$X zcat$X \ + zcmp zdiff zmore znew zforce gzexe + -for f in gzip gunzip zcat zcmp zmore znew gzexe; do \ + rm -f $(mandir)/$${f}.$(manext); done + -cd $(infodir); rm -f gzip.info* + +# install all files and replace compress (not recommended) +install_compress: install + -test -f $(bindir)/compress.old || \ + mv $(bindir)/compress$X $(bindir)/compress.old + ln $(bindir)/gzip$X $(bindir)/compress$X + rm -f $(bindir)/uncompress$X + ln $(bindir)/gzip$X $(bindir)/uncompress$X + +test: check +check: all + ./gzip -5 < $(srcdir)/texinfo.tex > _gztest.z + # Either GNUish make or MS_SH has trouble with backquotes + #@if test `wc -c < _gztest.z` -ne 30890; then \ + # echo FAILED gzip test: incorrect size; rm -f _gztest*; exit 1; \ + # else :; fi + @echo Should be 30890:\\c + @wc -c < _gztest.z + rm -f _gztest + ./gzip -d _gztest.z + @if cmp _gztest $(srcdir)/texinfo.tex; then \ + echo gzip test OK; \ + else \ + echo FAILED gzip test: incorrect decompress; \ + fi + rm -f _gztest* + +TAGS: $(SRCS) $(HDRS) + cd $(srcdir); etags $(SRCS) $(HDRS) + +Makefile: Makefile.in ./config.status + ./config.status + +./config.status: configure + $(srcdir)/configure --srcdir=$(srcdir) --no-create + +configure: configure.in + @echo Warning: configure is out of date +# cd $(srcdir); autoconf + +clean: + rm -f *$O gzip$X gunzip$X zcat$X a.out core gzip + rm -f zcmp zdiff zmore znew zforce gzexe _gztest* + rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.log + rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status + +realclean: distclean + rm -f TAGS gzip.info* + +# Actual build-related targets + +gzip$X: gzip + aout2exe gzip + +gzip: $(OBJ1) $(OBJ2) + echo $(OBJ1) > gzip.rsp + echo $(OBJ2) $(LIBS) >> gzip.rsp + $(CC) $(LDFLAGS) -o $@ @gzip.rsp + del gzip.rsp + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +gzip$O getopt$O: getopt.h + +match$O: match.S + $(CC) -c match.S + +zcmp: zcmp.in + sed "$(SEDCMD)" $(srcdir)/zcmp.in > zcmp + chmod 755 zcmp + +zdiff: zdiff.in + sed "$(SEDCMD)" $(srcdir)/zdiff.in > zdiff + chmod 755 zdiff + +zmore: zmore.in + sed "$(SEDCMD)" $(srcdir)/zmore.in > zmore + chmod 755 zmore + +znew: znew.in + sed "$(SEDCMD)" $(srcdir)/znew.in > znew + chmod 755 znew + +zforce: zforce.in + sed "$(SEDCMD)" $(srcdir)/zforce.in > zforce + chmod 755 zforce + +gzexe: gzexe.in + sed "$(SEDCMD)" $(srcdir)/gzexe.in > gzexe + chmod 755 gzexe + +gzip.info: gzip.texi + cd $(srcdir); makeinfo gzip.texi + +gzip.dvi: gzip.texi + cd $(srcdir); texi2dvi gzip.texi + +gzip.doc: gzip.1 + cd $(srcdir); nroff -man gzip.1 | col -b | uniq > gzip.doc + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: + +# end of file diff --git a/tools/gzip-1.2.4/msdos/Makefile.msc b/tools/gzip-1.2.4/msdos/Makefile.msc new file mode 100644 index 00000000..e2aceba1 --- /dev/null +++ b/tools/gzip-1.2.4/msdos/Makefile.msc @@ -0,0 +1,108 @@ +# Makefile for gzip +# Microsoft C 5.1 or 6.0. + +# To use, do "make makefile.msc" + +# WARNING: the small model is not supported. The compact model is used +# here. If you want to use the large model, add -D__LARGE__ to ASFLAGS +# Add -DSMALL_MEM to CFLAGS if you wish to reduce the memory +# requirements. Add -DNO_ASM to CFLAGS and remove match.obj from OBJI if +# you do not have masm. + +# ------------- Microsoft C 5.1 and later ------------- +MODEL=-AC +FP= +CFLAGS=-Ox -nologo $(MODEL) +BFLAGS=-Oait -Gs -nologo $(MODEL) +# BFLAGS are the 'bug workaround' flags. +CC=cl +LD=link +LDFLAGS=/e/st:0x1000/noe +# If you use lzexe as recommended, remove /e from LDFLAGS +AS=masm +# For MSC 6.0, use: AS=ml +ASFLAGS=-ml -t +# Add -DDYN_ALLOC to ASFLAGS if you have defined it in tailor.h or CFLAGS +LIB = c:\c51\lib + +# ------------- Common declarations: +STRIP=rem +# If you don't have lzexe, get it (by ftp on wuarchive.wustl.edu +# in /mirrors/msdos/filutl/lzexe91e.zip). Then define: +#STRIP=lzexe +# Or if you've registered PKLITE, then define: +#STRIP=pklite +# This makes a big difference in .exe size (and possibly load time) + +O=.obj +OBJA=match$(O) $(LIB)\setargv$(O) + +# ------------- Used by install rule +# set BIN to the directory you want to install the executables to +BIN = c:\bin + +# variables +OBJ1 = gzip$(O) zip$(O) deflate$(O) trees$(O) bits$(O) unzip$(O) inflate$(O) \ + util$(O) +OBJ2 = crypt$(O) lzw$(O) unlzw$(O) unpack$(O) unlzh$(O) getopt$(O) $(OBJA) + +gzip.obj: gzip.c gzip.h tailor.h crypt.h revision.h lzw.h + $(CC) -c $(CFLAGS) $*.c + +zip.obj: zip.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +deflate.obj: deflate.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +trees.obj: trees.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +bits.obj: bits.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +unzip.obj: unzip.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +inflate.obj: inflate.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +util.obj: util.c gzip.h tailor.h crypt.h + $(CC) -c $(BFLAGS) $*.c + +crypt.obj: crypt.c gzip.h tailor.h crypt.h + $(CC) -c $(CFLAGS) $*.c + +lzw.obj: lzw.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +unlzw.obj: unlzw.c gzip.h tailor.h lzw.h + $(CC) -c $(CFLAGS) $*.c + +unpack.obj: unpack.c gzip.h tailor.h + $(CC) -c $(CFLAGS) $*.c + +unlzh.obj: unlzh.c gzip.h tailor.h + $(CC) -c $(BFLAGS) $*.c + +getopt.obj: getopt.c getopt.h + $(CC) -c $(CFLAGS) $*.c + +match.obj: msdos\match.asm + $(AS) $(ASFLAGS) msdos\match, match; + +# we must cut the command line to fit in the MS/DOS 128 byte limit: +gzip.exe: $(OBJ1) $(OBJ2) + echo $(OBJ1)+ > gzip.rsp + echo $(OBJ2); >> gzip.rsp + $(LD) $(LDFLAGS) @gzip.rsp + del gzip.rsp + $(STRIP) gzip.exe + +install: gzip.exe + copy /b gzip.exe $(BIN) + copy /b gzip.exe $(BIN)\gunzip.exe + +#clean: +# del *.obj +# del *.exe diff --git a/tools/gzip-1.2.4/msdos/doturboc.bat b/tools/gzip-1.2.4/msdos/doturboc.bat new file mode 100644 index 00000000..eacd68b6 --- /dev/null +++ b/tools/gzip-1.2.4/msdos/doturboc.bat @@ -0,0 +1,18 @@ +: This file is a complement to gzip.prj for Turbo C 2.0 users. +: To construct gzip, first transform all files to msdos CR LF format. +: (Use utilities such as flip or do file transfers in ascii mode.) +: Then invoke this file. Then enter Turbo C, set the the +: compilation model to compact, and the project file to gzip.prj. +: Change the compilation flags if you wish (add SMALL_MEM +: to reduce the memory requirements), and press F9... +: WARNING: you must use the compact or large model in this version. +: To use the large model, add -D__LARGE__ in the tasm command below. +: To get the file wildargs.obj, do: +: +: pkunpak \tcc\startup wildargs.obj +: +: pkunpak is available in wuarchive.wustl.edu:/mirrors/msdos/starter/pk361.exe +: +: After compiling gzip.exe, do: copy gzip.exe gunzip.exe +: +tasm -ml -DDYN_ALLOC -DSS_NEQ_DS msdos\match, match; diff --git a/tools/gzip-1.2.4/msdos/gzip.prj b/tools/gzip-1.2.4/msdos/gzip.prj new file mode 100644 index 00000000..1601d51e --- /dev/null +++ b/tools/gzip-1.2.4/msdos/gzip.prj @@ -0,0 +1,17 @@ +gzip.c (gzip.h tailor.h crypt.h revision.h lzw.h) +zip.c (gzip.h tailor.h crypt.h) +deflate.c (gzip.h tailor.h) +trees.c (gzip.h tailor.h) +bits.c (gzip.h tailor.h crypt.h) +unzip.c (gzip.h tailor.h crypt.h) +inflate.c (gzip.h tailor.h) +util.c (gzip.h tailor.h crypt.h) +crypt.c (gzip.h tailor.h crypt.h) +lzw.c (gzip.h tailor.h) +unlzw.c (gzip.h tailor.h lzw.h) +unpack.c (gzip.h tailor.h) +unlzh.c (gzip.h tailor.h) +msdos\tailor.c (gzip.h tailor.h) +getopt.c (getopt.h) +match.obj +wildargs.obj diff --git a/tools/gzip-1.2.4/msdos/match.asm b/tools/gzip-1.2.4/msdos/match.asm new file mode 100644 index 00000000..cee59c59 --- /dev/null +++ b/tools/gzip-1.2.4/msdos/match.asm @@ -0,0 +1,240 @@ +; match.asm -- optional optimized asm version of longest match in deflate.c +; Copyright (C) 1992-1993 Jean-loup Gailly +; This is free software; you can redistribute it and/or modify it under the +; terms of the GNU General Public License, see the file COPYING. +; +; Must be assembled with masm -ml. To be used only with C compact model +; or large model. (For large model, assemble with -D__LARGE__). +; This file is only optional. If you don't have masm or tasm, use the +; C version (add -DNO_ASM to CFLAGS in makefile.msc and remove match.obj +; from OBJI). If you have reduced WSIZE in zip.h, then change its value +; below. +; +; Turbo C 2.0 does not support static allocation of more than 64K bytes per +; file, and does not have SS == DS. So TC and BC++ users must use: +; tasm -ml -DDYN_ALLOC -DSS_NEQ_DS match; +; +; To simplify the code, the option -DDYN_ALLOC is supported for OS/2 +; only if the arrays are guaranteed to have zero offset (allocated by +; halloc). We also require SS==DS. This is satisfied for MSC but not Turbo C. + +; $Id: match.asm,v 0.6 1993/01/21 18:49:05 jloup Exp $ + + name match + +ifndef DYN_ALLOC + extrn _prev : word + extrn _window : byte + prev equ _prev ; offset part + window equ _window +endif + +_DATA segment word public 'DATA' + extrn _nice_match : word + extrn _match_start : word + extrn _prev_length : word + extrn _good_match : word + extrn _strstart : word + extrn _max_chain_length : word +ifdef DYN_ALLOC + extrn _prev : word + extrn _window : word + prev equ 0 ; offset forced to zero + window equ 0 + window_seg equ _window[2] + window_off equ 0 +else + wseg dw seg _window + window_seg equ wseg + window_off equ offset _window +endif +_DATA ends + +DGROUP group _DATA + +_TEXT segment word public 'CODE' + assume cs: _TEXT, ds: DGROUP + + public _match_init + public _longest_match + + MIN_MATCH equ 3 + MAX_MATCH equ 258 + WSIZE equ 32768 ; keep in sync with zip.h ! + MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) + MAX_DIST equ (WSIZE-MIN_LOOKAHEAD) + +prev_ptr dw seg _prev ; pointer to the prev array +ifdef SS_NEQ_DS + match_start dw 0 ; copy of _match_start if SS != DS + nice_match dw 0 ; copy of _nice_match if SS != DS +endif + +; initialize or check the variables used in match.asm. + +ifdef __LARGE__ +_match_init proc far ; 'proc far' for large model +else +_match_init proc near ; 'proc near' for compact model +endif +ifdef SS_NEQ_DS + ma_start equ cs:match_start ; does not work on OS/2 + nice equ cs:nice_match + mov ax,_nice_match + mov cs:nice_match,ax ; ugly write to code, crash on OS/2 +else + assume ss: DGROUP + ma_start equ ss:_match_start + nice equ ss:_nice_match + mov ax,ds + mov bx,ss + cmp ax,bx ; SS == DS? + jne error +endif +ifdef DYN_ALLOC + cmp _prev[0],0 ; verify zero offset + jne error + cmp _window[0],0 + jne error + ifdef SS_NEQ_DS + mov ax,_prev[2] ; segment value + mov cs:prev_ptr,ax ; ugly write to code, crash on OS/2 + prev_seg equ cs:prev_ptr + else + prev_seg equ ss:_prev[2] ; works on OS/2 if SS == DS + endif +else + prev_seg equ cs:prev_ptr +endif + ret +ifdef __LARGE__ + extrn _exit : far ; 'far' for large model +else + extrn _exit : near ; 'near' for compact model +endif +error: call _exit + +_match_init endp + +; ----------------------------------------------------------------------- +; Set match_start to the longest match starting at the given string and +; return its length. Matches shorter or equal to prev_length are discarded, +; in which case the result is equal to prev_length and match_start is +; garbage. +; IN assertions: cur_match is the head of the hash chain for the current +; string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + +; int longest_match(cur_match) + +ifdef __LARGE__ +_longest_match proc far ; 'proc far' for large model +else +_longest_match proc near ; 'proc near' for compact model +endif + push bp + mov bp,sp + push di + push si + push ds + +ifdef __LARGE__ + cur_match equ word ptr [bp+6] ; [bp+6] for large model +else + cur_match equ word ptr [bp+4] ; [bp+4] for compact model +endif + +; window equ es:window (es:0 for DYN_ALLOC) +; prev equ ds:prev +; match equ es:si +; scan equ es:di +; chain_length equ bp +; best_len equ bx +; limit equ dx + + mov si,cur_match ; use bp before it is destroyed + mov bp,_max_chain_length ; chain_length = max_chain_length + mov di,_strstart + mov dx,di + sub dx,MAX_DIST ; limit = strstart-MAX_DIST + jae limit_ok + sub dx,dx ; limit = NIL +limit_ok: + add di,2+window_off ; di = offset(window + strstart + 2) + mov bx,_prev_length ; best_len = prev_length + mov es,window_seg + mov ax,es:[bx+di-3] ; ax = scan[best_len-1..best_len] + mov cx,es:[di-2] ; cx = scan[0..1] + cmp bx,_good_match ; do we have a good match already? + mov ds,prev_seg ; (does not destroy the flags) + assume ds: nothing + jb do_scan ; good match? + shr bp,1 ; chain_length >>= 2 + shr bp,1 + jmp short do_scan + + even ; align destination of branch +long_loop: +; at this point, ds:di == scan+2, ds:si == cur_match + mov ax,[bx+di-3] ; ax = scan[best_len-1..best_len] + mov cx,[di-2] ; cx = scan[0..1] + mov ds,prev_seg ; reset ds to address the prev array +short_loop: +; at this point, di == scan+2, si = cur_match, +; ax = scan[best_len-1..best_len] and cx = scan[0..1] +if (WSIZE-32768) + and si,WSIZE-1 ; not needed if WSIZE=32768 +endif + shl si,1 ; cur_match as word index + mov si,prev[si] ; cur_match = prev[cur_match] + cmp si,dx ; cur_match <= limit ? + jbe the_end + dec bp ; --chain_length + jz the_end +do_scan: + cmp ax,word ptr es:window[bx+si-1] ; check match at best_len-1 + jne short_loop + cmp cx,word ptr es:window[si] ; check min_match_length match + jne short_loop + + lea si,window[si+2] ; si = match + mov ax,di ; ax = scan+2 + mov cx,es + mov ds,cx ; ds = es = window + mov cx,(MAX_MATCH-2)/2 ; scan for at most MAX_MATCH bytes + repe cmpsw ; loop until mismatch + je maxmatch ; match of length MAX_MATCH? +mismatch: + mov cl,[di-2] ; mismatch on first or second byte? + sub cl,[si-2] ; cl = 0 if first bytes equal + xchg ax,di ; di = scan+2, ax = end of scan + sub ax,di ; ax = len + sub si,ax ; si = cur_match + 2 + offset(window) + sub si,2+window_off ; si = cur_match + sub cl,1 ; set carry if cl == 0 (can't use DEC) + adc ax,0 ; ax = carry ? len+1 : len + cmp ax,bx ; len > best_len ? + jle long_loop + mov ma_start,si ; match_start = cur_match + mov bx,ax ; bx = best_len = len + cmp ax,nice ; len >= nice_match ? + jl long_loop +the_end: + pop ds + assume ds: DGROUP +ifdef SS_NEQ_DS + mov ax,ma_start ; garbage if no match found + mov ds:_match_start,ax +endif + pop si + pop di + pop bp + mov ax,bx ; result = ax = best_len + ret +maxmatch: ; come here if maximum match + cmpsb ; increment si and di + jmp mismatch ; force match_length = MAX_LENGTH + +_longest_match endp + +_TEXT ends +end diff --git a/tools/gzip-1.2.4/msdos/tailor.c b/tools/gzip-1.2.4/msdos/tailor.c new file mode 100644 index 00000000..4d41b22a --- /dev/null +++ b/tools/gzip-1.2.4/msdos/tailor.c @@ -0,0 +1,58 @@ +/* tailor.c -- target dependent functions + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* tailor.c is a bunch of non portable routines. + * It should be kept to a minimum. + */ + +#include "tailor.h" +#include "gzip.h" + +#ifndef lint +static char rcsid[] = "$Id: tailor.c,v 0.8 1993/02/24 18:24:54 jloup Exp $"; +#endif + +#ifdef __TURBOC__ + +/************************/ +/* Function fcalloc() */ +/************************/ + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use fcfree(). + * For MSC, use halloc instead of this function (see tailor.h). + */ +static ush ptr_offset = 0; + +void * fcalloc(items, size) + unsigned items; /* number of items */ + unsigned size; /* item size */ +{ + void * buf = farmalloc((ulg)items*size + 16L); + if (buf == NULL) return NULL; + /* Normalize the pointer to seg:0 */ + if (ptr_offset == 0) { + ptr_offset = (ush)((uch*)buf-0); + } else if (ptr_offset != (ush)((uch*)buf-0)) { + error("inconsistent ptr_offset"); + } + *((ush*)&buf+1) += (ptr_offset + 15) >> 4; + *(ush*)&buf = 0; + return buf; +} + +void fcfree(ptr) + void *ptr; /* region allocated with fcalloc() */ +{ + /* Put the pointer back to its original form: */ + *((ush*)&ptr+1) -= (ptr_offset + 15) >> 4; + *(ush*)&ptr = ptr_offset; + farfree(ptr); + } + +#endif /* __TURBOC__ */ diff --git a/tools/gzip-1.2.4/nt/Makefile.nt b/tools/gzip-1.2.4/nt/Makefile.nt new file mode 100644 index 00000000..0a7604c9 --- /dev/null +++ b/tools/gzip-1.2.4/nt/Makefile.nt @@ -0,0 +1,66 @@ +# Simple makefile for Windows NT +# Written by Ron Cox + +# This is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License, see the file COPYING. + +# This makefile is suitable for NTFS only. To build a gzip executable suitable +# for a FAT file system, add -DNTFAT to DEFS. + +# To build debug version, define environment variable DEBUG, or include a +# -DDEBUG on the commandline (i.e.: nmake -DDEBUG) + +.silent: + +!include + +# +# Object files +# +OBJS = gzip.obj zip.obj deflate.obj trees.obj bits.obj unzip.obj inflate.obj \ + util.obj crypt.obj lzw.obj unlzw.obj unpack.obj getopt.obj unlzh.obj + +DEFS = +# for FAT support, set: DEFS = -DNTFAT + +# +# How to build .obj's from .c's +# +.c.obj: + $(cc) $(DEFS) -Ox $(cflags) $(cvarsdll) $< + +# +# Main target +# +all: gzip.exe + +# +# Link target. setargv.obj is provided in the compiler library directory. +# +gzip.exe: $(OBJS) + $(link) $(linkdebug) $(conflags) -out:gzip.exe $(OBJS) setargv.obj \ + $(conlibsdll) + +# +# Dependencies +# +gzip.obj: gzip.c gzip.h tailor.h +zip.obj: zip.c gzip.h tailor.h crypt.h +deflate.obj: deflate.c gzip.h tailor.h +trees.obj: trees.c gzip.h tailor.h +bits.obj: bits.c gzip.h tailor.h crypt.h +unzip.obj: unzip.c gzip.h tailor.h crypt.h +inflate.obj: inflate.c gzip.h tailor.h crypt.h +util.obj: util.c gzip.h tailor.h +lzw.obj: lzw.c gzip.h tailor.h +unlzw.obj: unlzw.c gzip.h tailor.h revision.h lzw.h +unpack.obj: unpack.c gzip.h tailor.h +crypt.obj: crypt.c gzip.h tailor.h +unlzh.obj: unlzh.c gzip.h tailor.h lzw.h + + +clean: + -rm $(OBJS) + +clobber: clean + -rm gzip.exe diff --git a/tools/gzip-1.2.4/os2/Makefile.os2 b/tools/gzip-1.2.4/os2/Makefile.os2 new file mode 100644 index 00000000..e4afc2ec --- /dev/null +++ b/tools/gzip-1.2.4/os2/Makefile.os2 @@ -0,0 +1,81 @@ +# Makefile for gzip (GNU zip), OS/2 version -*- Indented-Text -*- +# Written by Kai Uwe Rommel + +# specialized version for OS/2 + +default: + @echo "Enter $(MAKE) -f makefile.os2 target" + @echo "where target is one of:" + @echo " msc mscdebug gcc gccdyn gccdebug" + +# compilation with emx 0.8f (gcc 2.3.3) or newer +# +# release version, statically linked C runtime +gcc: + $(MAKE) -f Makefile.os2 all \ + CC="gcc -Zomf -Zsys" O=".obj" S=".S" \ + AS="gcc -Zomf -xassembler-with-cpp -c -o" \ + CFLAGS="-O" LDFLAGS="gzip.def -s" +# +# release version, dynamically linked C runtime +gccdyn: + $(MAKE) -f Makefile.os2 all \ + CC="gcc -Zomf -Zmt" O=".obj" S=".S" \ + AS="gcc -Zomf -xassembler-with-cpp -c -o" \ + CFLAGS="-O" LDFLAGS="gzip.def -s" +# +# debugging version +gccdebug: + $(MAKE) -f Makefile.os2 all \ + CC="gcc -g" O=".o" S=".S" \ + AS="gcc -g -xassembler-with-cpp -c -o" \ + CFLAGS="" LDFLAGS="gzip.def" + +# compilation with MS C 6.00 +# +# release version +msc: + $(MAKE) -f Makefile.os2 all \ + CC="cl -nologo -AC" O=".obj" S=".asm" \ + AS="ml -nologo -Zm -Cp -c -Fo" \ + CFLAGS=" -W1 -Zap -J -G2s -Ocegit" \ + LDFLAGS="-Lp -F 2000 setargv.obj gzip16.def -link /noe" +# +# debugging version +mscdebug: + $(MAKE) -f Makefile.os2 all \ + CC="cl -nologo -AC -Zi" O=".obj" S=".asm" \ + AS="ml -nologo -Zm -Zi -Cp -c -Fo" \ + CFLAGS="-W1 -Zap -J -G2 -Od" \ + LDFLAGS="-Lp -F 2000 setargv.obj gzip16.def -link /noe /exe" + +DEFS = -DOS2 -DASMV + +OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \ + crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O match$O + +.SUFFIXES: .c $O + +.c$O: + $(CC) $(CFLAGS) $(DEFS) -c $< + +all: gzip.exe gzip.info gzip.doc + +gzip.exe: $(OBJS) + $(CC) -o $@ $(OBJS) $(LDFLAGS) + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +match$O: match$S + $(AS) $@ match$S + +gzip.info: gzip.texi gpl.texinfo + makeinfo gzip.texi + +gzip.doc: gzip.1 + groff -man gzip.1 > $@ diff --git a/tools/gzip-1.2.4/os2/gzip.def b/tools/gzip-1.2.4/os2/gzip.def new file mode 100644 index 00000000..c7af3ea2 --- /dev/null +++ b/tools/gzip-1.2.4/os2/gzip.def @@ -0,0 +1,3 @@ +NAME GZIP WINDOWCOMPAT +DESCRIPTION 'GNU gzip file compression program' +STACKSIZE 0x80000 diff --git a/tools/gzip-1.2.4/os2/gzip16.def b/tools/gzip-1.2.4/os2/gzip16.def new file mode 100644 index 00000000..74c20d91 --- /dev/null +++ b/tools/gzip-1.2.4/os2/gzip16.def @@ -0,0 +1,2 @@ +NAME GZIP WINDOWCOMPAT NEWFILES +DESCRIPTION 'GNU gzip file compression program' diff --git a/tools/gzip-1.2.4/primos/build.cpl b/tools/gzip-1.2.4/primos/build.cpl new file mode 100644 index 00000000..6d82fa0c --- /dev/null +++ b/tools/gzip-1.2.4/primos/build.cpl @@ -0,0 +1,76 @@ +/* Gzip build file for Primos. +/* author: Peter Eriksson, pen@lysator.liu.se +/* +type +type 'Building GZIP for PRIMOS - Please Wait...' +type +&if ^ [exists *>PRIMOS>OBJ -dir] &then &do + type 'Creating *>PRIMOS>OBJ directory...' + type + create *>PRIMOS>OBJ + &end + +type 'Compiling... + +&set_var unit := 0 + +/* +&set_var cdefines := -debug + +como *>primos>compile.como +&do file &items [wild *>@@.c -single unit] + &set_var filebase := [before %file% .] + &if ^ [exists *>primos>obj>%filebase%.bin] &then &do + type 'Compiling "'%file%'"...' + ci *>%file% -binary *>primos>obj>=.bin %cdefines% -optionsfile *>primos>ci.opts + &end +&end +close -unit %unit% +&set_var unit := 0 + +&do file &items [wild *>primos>@@.c -single unit] + &set_var filebase := [before %file% .] + &if ^ [exists *>primos>obj>%filebase%.bin] &then &do + type 'Compiling "'%file%'"...' + ci *>primos>%file% -binary *>primos>obj>=.bin %cdefines% -optionsfile *>primos>ci.opts + &end +&end +como -end + +type +type +type 'Binding...' + +&set_var unit := 0 +&data bind + li ccmain + load *>primos>obj>gzip + load *>primos>obj>bits + load *>primos>obj>crypt + load *>primos>obj>deflate + load *>primos>obj>getopt + load *>primos>obj>inflate + load *>primos>obj>lzw + load *>primos>obj>makecrc + load *>primos>obj>primos + load *>primos>obj>trees + load *>primos>obj>unlzw + load *>primos>obj>unpack + load *>primos>obj>unlzh + load *>primos>obj>unzip + load *>primos>obj>util + load *>primos>obj>zip + li c_lib + li + dynt -all + nwc + nitr + ntw + compress + file *>primos>gzip.run +&end + +type +type +type 'All done. (Hopefully). The executable should be in *>PRIMOS>GZIP.RUN' +&return diff --git a/tools/gzip-1.2.4/primos/ci.opts b/tools/gzip-1.2.4/primos/ci.opts new file mode 100644 index 00000000..bb4f9b3a --- /dev/null +++ b/tools/gzip-1.2.4/primos/ci.opts @@ -0,0 +1,6 @@ +-define PRIMOS +-include *>PRIMOS>INCLUDE +-ignoreregister +-packbytes +-sof + diff --git a/tools/gzip-1.2.4/primos/include/errno.h b/tools/gzip-1.2.4/primos/include/errno.h new file mode 100644 index 00000000..ee891468 --- /dev/null +++ b/tools/gzip-1.2.4/primos/include/errno.h @@ -0,0 +1,17 @@ +/* +** errno.h +** +** Emulation of the Unix errno.h header file for PRIMOS +** +** Author: Peter Eriksson +*/ + +#ifndef __ERRNO_H__ +#define __ERRNO_H__ + +#include + +#define ENOENT e$fntf + +#endif + diff --git a/tools/gzip-1.2.4/primos/include/fcntl.h b/tools/gzip-1.2.4/primos/include/fcntl.h new file mode 100644 index 00000000..9e4b1dc8 --- /dev/null +++ b/tools/gzip-1.2.4/primos/include/fcntl.h @@ -0,0 +1,22 @@ +/* +** fcntl.h +** +** Emulation of the Unix fcntl.h header file for PRIMOS +** +** Author: Peter Eriksson +*/ + +#ifndef __FCNTL_H__ +#define __FCNTL_H__ + +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 + +#define O_BINARY 0 +#define O_EXCL 0 +#define O_NDELAY 0 +#define O_CREAT 0 +#define O_TRUNC 0 + +#endif diff --git a/tools/gzip-1.2.4/primos/include/stdlib.h b/tools/gzip-1.2.4/primos/include/stdlib.h new file mode 100644 index 00000000..49fbfc38 --- /dev/null +++ b/tools/gzip-1.2.4/primos/include/stdlib.h @@ -0,0 +1,16 @@ +/* +** stdlib.h +** +** Emulation of the Unix stdlib.h header file for PRIMOS +** +** Author: Peter Eriksson +*/ + +#ifndef __STDLIB_H__ +#define __STDLIB_H__ + +extern char *malloc(); +extern char *calloc(); + +#endif + diff --git a/tools/gzip-1.2.4/primos/include/sysStat.h b/tools/gzip-1.2.4/primos/include/sysStat.h new file mode 100644 index 00000000..c24d20b6 --- /dev/null +++ b/tools/gzip-1.2.4/primos/include/sysStat.h @@ -0,0 +1,92 @@ +/* +** sys/stat.h +** +** Emulation of the Unix sys/stat.h header file for PRIMOS +** +** Author: Peter Eriksson +*/ + +#ifndef __SYS_STAT_H__ +#define __SYS_STAT_H__ + + +#include + +struct stat { + /* First some PRIMOS standard entries */ + off_t st_size; + time_t st_mtime; + short st_type; /* Primos file type */ + short st_rwlock; /* Primos read/write lock */ + + /* Begin Unix compatibility - don't believe these entries! */ + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + short st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + time_t st_atime; + time_t st_ctime; + long st_blksize; + long st_blocks; +}; + +#define _IFMT 0170000 /* type of file */ +#define _IFREG 0100000 /* regular */ +#define _IFDIR 0040000 /* directory */ + +/* Some stupid programs check if these are defined and then + believe these are supported in the OS - not so in PRIMOS ... */ +#ifndef __50SERIES +# define _IFCHR 0020000 +# define _IFBLK 0060000 +# define _IFLNK 0120000 +# define _IFSOCK 0140000 +# define _IFIFO 0010000 +#endif + +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 +#define S_IREAD 0000400 +#define S_IWRITE 0000200 +#define S_IEXEC 0000100 + +#define S_ENFMT 0002000 + +#define S_IFMT _IFMT +#define S_IFREG _IFREG +#define S_IFDIR _IFDIR +#ifndef __50SERIES +# define S_IFCHR _IFCHR +# define S_IFBLK _IFBLK +# define S_IFLNK _IFLNK +# define S_IFSOCK _IFSOCK +# define S_IFIFO _IFIFO +#endif + +#define S_IRWXU 0000700 +#define S_IRUSR 0000400 +#define S_IWUSR 0000200 +#define S_IXUSR 0000100 +#define S_IRWXG 0000070 +#define S_IRGRP 0000040 +#define S_IWGRP 0000020 +#define S_IXGRP 0000010 +#define S_IRWXO 0000007 +#define S_IROTH 0000004 +#define S_IWOTH 0000002 +#define S_IXOTH 0000001 + +#define S_ISREG(m) (((m) & _IFMT) == _IFREG) +#define S_ISDIR(m) (((m) & _IFMT) == _IFDIR) +#ifndef __50SERIES +# define S_ISBLK(m) (((m) & _IFMT) == _IFBLK) +# define S_ISCHR(m) (((m) & _IFMT) == _IFCHR) +# define S_ISFIFO(m) (((m) & _IFMT) == _IFIFO) +#endif + + +#endif diff --git a/tools/gzip-1.2.4/primos/include/sysTypes.h b/tools/gzip-1.2.4/primos/include/sysTypes.h new file mode 100644 index 00000000..ec6c5b15 --- /dev/null +++ b/tools/gzip-1.2.4/primos/include/sysTypes.h @@ -0,0 +1,25 @@ +/* +** sys/types.h +** +** Emulation of the Unix sys/types.h header file for PRIMOS +** +** Author: Peter Eriksson +*/ + +#ifndef __SYS_TYPES_H__ +#define __SYS_TYPES_H__ + +typedef long size_t; +typedef long time_t; + +typedef long off_t; +typedef short dev_t; +typedef short ino_t; +typedef short mode_t; +typedef short uid_t; +typedef short gid_t; + +typedef char *caddr_t; + +#endif + diff --git a/tools/gzip-1.2.4/primos/primos.c b/tools/gzip-1.2.4/primos/primos.c new file mode 100644 index 00000000..c751c9a2 --- /dev/null +++ b/tools/gzip-1.2.4/primos/primos.c @@ -0,0 +1,122 @@ +/* +** primos.c +** +** This file contains emulation routines for some common Unix functions +** +** Author: Peter Eriksson +*/ + +#ifdef __50SERIES + +#include +#include +#include + + +uid_t primos_uid = 42; +gid_t primos_gid = 42; +mode_t primos_mode = 600; + +/* Dummy do-nothing routine for chmod() */ +int chmod(path, mode) + char *path; + int mode; +{ + return 0; +} + +char *getenv(var) + char *var; +{ + char buf[256]; + extern char *gvget(); + + buf[0] = '.'; + strcpy(buf+1, var); + + return gvget(buf); +} + + +unlink(path) + char *path; +{ + return delete(path); +} + +int lstat(path, buf) + char *path; + struct stat *buf; +{ + return stat(path, buf); +} + +int stat(path, buf) + char *path; + struct stat *buf; +{ + buf->st_dev = 1; + buf->st_ino = 1; + buf->st_nlink = 1; + buf->st_uid = primos_uid; + buf->st_gid = primos_gid; + buf->st_rdev = 1; + buf->st_blksize = 2048; + + buf->st_rwlock = frwlock(path); + switch (buf->st_type = ftype(path)) + { + case 0: + case 1: + /* Regular file (SAM or DAM) */ + buf->st_size = fsize(path); + buf->st_mtime = fdtm(path); + + buf->st_mode = S_IFREG|primos_mode; + break; + + case 4: + buf->st_size = 0; + buf->st_mtime = fdtm(path); + + buf->st_mode = S_IFDIR|primos_mode; + break; + + case -1: + return -1; + + default: + buf->st_mode = primos_mode; + buf->st_size = fsize(path); + buf->st_mtime = fdtm(path); + } + + buf->st_blocks = (buf->st_size-1) / buf->st_blksize + 1; + + /* Should be fixed to really fetch these values, but that + * would require calling some PRIMOS subroutines and I don't have + * a copy of the Primos Subroutine reference manuals here.. + */ + buf->st_atime = buf->st_mtime; + buf->st_ctime = buf->st_mtime; + + return 0; +} + +int fstat(fd, buf) + int fd; + struct stat *buf; +{ + char path[1025]; + + return stat(getname(fd, path), buf); +} + +int ascii2pascii(c) + int c; +{ + return (c ? (c | 0x80) : '\0'); +} + + +#endif /* __50SERIES */ diff --git a/tools/gzip-1.2.4/primos/readme b/tools/gzip-1.2.4/primos/readme new file mode 100644 index 00000000..6c9dc01c --- /dev/null +++ b/tools/gzip-1.2.4/primos/readme @@ -0,0 +1,27 @@ +To build GZIP for PRIMOS you should just have to type: + + r *>primos>build + +while standing in the directory above this PRIMOS subdirectory. + +If the files in these directories looks strange, then it might be +because they are in normal ASCII. You'll need to convert them into +PASCII before you will be able to build the GZIP executable. + +You can find a simple ASCII to PASCII converter via anonymous FTP +from "ftp.lysator.liu.se" in the directory "pub/primos/run" as +the file "topascii.run". + +You can reach me at a number of places in case there are any bugs +in this port to report... + + Email: + + pen@signum.se Signum is a company giving support for + Free Software. Call/Mail us if you're + interrested! (Phone: +46-13-21-46-00) + + pen@lysator.liu.se Lysator is a computer society at the + Linkoping University in Sweden. + +Peter Eriksson, 25 May 1993 diff --git a/tools/gzip-1.2.4/revision.h b/tools/gzip-1.2.4/revision.h new file mode 100644 index 00000000..f99b65f9 --- /dev/null +++ b/tools/gzip-1.2.4/revision.h @@ -0,0 +1,16 @@ +/* revision.h -- define the version number + * Copyright (C) 1992-1993 Jean-loup Gailly. + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +#define VERSION "1.2.4" +#define PATCHLEVEL 0 +#define REVDATE "18 Aug 93" + +/* This version does not support compression into old compress format: */ +#ifdef LZW +# undef LZW +#endif + +/* $Id: revision.h,v 0.25 1993/06/24 08:29:52 jloup Exp $ */ diff --git a/tools/gzip-1.2.4/sample/add.c b/tools/gzip-1.2.4/sample/add.c new file mode 100644 index 00000000..0058d9e3 --- /dev/null +++ b/tools/gzip-1.2.4/sample/add.c @@ -0,0 +1,57 @@ +/* add.c not copyrighted (n) 1993 by Mark Adler */ +/* version 1.1 11 Jun 1993 */ + +/* This filter reverses the effect of the sub filter. It requires no + arguments, since sub puts the information necessary for extraction + in the stream. See sub.c for what the filtering is and what it's + good for. */ + +#include + +#define MAGIC1 'S' /* sub data */ +#define MAGIC2 26 /* ^Z */ +#define MAX_DIST 16384 + +char a[MAX_DIST]; /* last byte buffer for up to MAX_DIST differences */ + +int main() +{ + int n; /* number of differences */ + int i; /* difference counter */ + int c; /* byte from input */ + + /* check magic word */ + if (getchar() != MAGIC1 || getchar() != MAGIC2) + { + fputs("add: input stream not made by sub\n", stderr); + exit(1); + } + + /* get number of differences from data */ + if ((n = getchar()) == EOF || (i = getchar()) == EOF) { + fputs("add: unexpected end of file\n", stderr); + exit(1); + } + n += (i<<8); + if (n <= 0 || n > MAX_DIST) { + fprintf(stderr, "add: incorrect distance %d\n", n); + exit(1); + } + + /* initialize last byte */ + i = n; + do { + a[--i] = 0; + } while (i); + + /* read differenced data and restore original */ + while ((c = getchar()) != EOF) + { + c = (a[i++] += c) & 0xff; /* restore data, save last byte */ + putchar(c); /* write original */ + if (i == n) /* cycle on n differences */ + i = 0; + } + exit(0); + return 0; /* avoid warning */ +} diff --git a/tools/gzip-1.2.4/sample/makecrc.c b/tools/gzip-1.2.4/sample/makecrc.c new file mode 100644 index 00000000..2b60f476 --- /dev/null +++ b/tools/gzip-1.2.4/sample/makecrc.c @@ -0,0 +1,63 @@ +/* Not copyrighted 1990 Mark Adler */ + +#ifndef lint +static char rcsid[] = "$Id: makecrc.c,v 0.6 1993/05/28 07:42:59 jloup Exp $"; +#endif + +#include + +main() +/* + Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The table is simply the CRC of all possible eight bit values. This is all + the information needed to generate CRC's on data a byte at a time for all + combinations of CRC register values and incoming bytes. The table is + written to stdout as 256 long hexadecimal values in C language format. +*/ +{ + unsigned long c; /* crc shift register */ + unsigned long e; /* polynomial exclusive-or pattern */ + int i; /* counter for all possible eight bit values */ + int k; /* byte being shifted into crc apparatus */ + + /* terms of polynomial defining this crc (except x^32): */ + static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* Make exclusive-or pattern from polynomial (0xedb88320) */ + e = 0; + for (i = 0; i < sizeof(p)/sizeof(int); i++) + e |= 1L << (31 - p[i]); + + /* Compute and print table of CRC's, five per line */ + printf(" 0x00000000L"); + for (i = 1; i < 256; i++) + { + c = i; + /* The idea to initialize the register with the byte instead of + * zero was stolen from Haruhiko Okumura's ar002 + */ + for (k = 8; k; k--) + c = c & 1 ? (c >> 1) ^ e : c >> 1; + printf(i % 5 ? ", 0x%08lxL" : ",\n 0x%08lxL", c); + } + putchar('\n'); + return 0; +} diff --git a/tools/gzip-1.2.4/sample/sub.c b/tools/gzip-1.2.4/sample/sub.c new file mode 100644 index 00000000..ec57ca4f --- /dev/null +++ b/tools/gzip-1.2.4/sample/sub.c @@ -0,0 +1,88 @@ +/* sub.c not copyrighted (n) 1993 by Mark Adler */ +/* version 1.1 11 Jun 1993 */ + +/* sub is a simple filter to preprocess a data file before compression. + It can increase compression for data whose points tend to be close to + the last point. The output is the difference of successive bytes of + the input. The add filter is used to undo what sub does. This could + be used on 8-bit sound or graphics data. + + sub can also take an argument to apply this to interleaved sets of + bytes. For example, if the data are 16-bit sound samples, then you + can use "sub 2" to take differences on the low-byte stream and the + high-byte stream. (This gives nearly the same effect as subtracting + the 16-bit values, but avoids the complexities of endianess of the + data.) The concept extends to RGB image data (sub 3), 16-bit stereo + data (sub 4), floating point data (sub 4 or sub 8), etc. + + add takes no options, since the number of interleaved byte streams + is put in the first two bytes of the output stream for add to use + (in little-endian format). + + Examples: + + sub < graph.vga | gzip -9 > graph.vga.sgz + sub < phone.snd | gzip -9 > phone.snd.sgz + sub 2 < audio.snd | gzip -9 > audio.snd.sgz + sub 3 < picture.rgb | gzip -9 > picture.rgb.sgz + sub 4 < stereo.snd | gzip -9 > stereo.snd.sgz + sub 8 < double.data | gzip -9 > double.data.sgz + + To expand, use the reverse operation, as in: + + gunzip < double.data.sgz | add > double.data +*/ + +#include + +#define MAGIC1 'S' /* sub data */ +#define MAGIC2 26 /* ^Z */ +#define MAX_DIST 16384 + +char a[MAX_DIST]; /* last byte buffer for up to MAX_DIST differences */ + +int main(argc, argv) + int argc; + char **argv; +{ + int n = 1; /* number of differences */ + int i; /* difference counter */ + int c; /* byte from input */ + int atoi(); /* (avoid including stdlib for portability) */ + + /* process arguments */ + if (argc > 2) + { + fputs("sub: only one argument needed--# of differences\n", stderr); + exit(1); + } + if (argc > 1) + n = atoi(argv[1]); + + if (n < 0) n = -n; /* tolerate "sub -2" */ + if (n == 0 || n > MAX_DIST) { + fputs("sub: incorrect distance\n", stderr); + exit(1); + } + + /* initialize last byte */ + i = n; + do { + a[--i] = 0; + } while (i); + + /* write differenced data */ + putchar(MAGIC1); putchar(MAGIC2); /* magic word for add */ + putchar(n & 0xff); /* so add knows what to do */ + putchar((n>>8) & 0xff); + + while ((c = getchar()) != EOF) + { + putchar((c - a[i]) & 0xff); /* write difference */ + a[i++] = c; /* save last byte */ + if (i == n) /* cycle on n differences */ + i = 0; + } + exit(0); + return 0; /* avoid warning */ +} diff --git a/tools/gzip-1.2.4/sample/zfile b/tools/gzip-1.2.4/sample/zfile new file mode 100755 index 00000000..6b4514cc --- /dev/null +++ b/tools/gzip-1.2.4/sample/zfile @@ -0,0 +1,28 @@ +#!/bin/sh + +if test $# = 0; then + echo 'zfile: file(1) for programs which may be compressed with gzexe' + echo usage: `basename $0` files... + exit 1 +fi + +tmp=/tmp/gz$$ + +for i do + if test ! -f "$i" ; then + echo `basename $0`: $i not a file + res=1 + continue + fi + skip=18 + if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then + eval `sed -e 1d -e 2q "$i"` + fi + if tail +$skip "$i" | gzip --list >/dev/null 2>&1; then + tail +$skip "$i" | gzip -cd | dd count=1 >$tmp 2>/dev/null + file $tmp | sed "s|^$tmp|$i|" + else + file "$i" + fi + rm -f $tmp +done diff --git a/tools/gzip-1.2.4/sample/zread.c b/tools/gzip-1.2.4/sample/zread.c new file mode 100644 index 00000000..3163d42a --- /dev/null +++ b/tools/gzip-1.2.4/sample/zread.c @@ -0,0 +1,53 @@ +#include + +/* Trivial example of reading a gzip'ed file or gzip'ed standard input + * using stdio functions fread(), getc(), etc... fseek() is not supported. + * Modify according to your needs. You can easily construct the symmetric + * zwrite program. + * + * Usage: zread [file[.gz]] + * This programs assumes that gzip is somewhere in your path. + */ +int main(argc, argv) + int argc; + char **argv; +{ + FILE *infile; + char cmd[256]; + char buf[BUFSIZ]; + int n; + + if (argc < 1 || argc > 2) { + fprintf(stderr, "usage: %s [file[.gz]]\n", argv[0]); + exit(1); + } + strcpy(cmd, "gzip -dc "); /* use "gzip -c" for zwrite */ + if (argc == 2) { + strncat(cmd, argv[1], sizeof(cmd)-strlen(cmd)); + } + infile = popen(cmd, "r"); /* use "w" for zwrite */ + if (infile == NULL) { + fprintf(stderr, "%s: popen('%s', 'r') failed\n", argv[0], cmd); + exit(1); + } + /* Read one byte using getc: */ + n = getc(infile); + if (n == EOF) { + pclose(infile); + exit(0); + } + putchar(n); + + /* Read the rest using fread: */ + for (;;) { + n = fread(buf, 1, BUFSIZ, infile); + if (n <= 0) break; + fwrite(buf, 1, n, stdout); + } + if (pclose(infile) != 0) { + fprintf(stderr, "%s: pclose failed\n", argv[0]); + exit(1); + } + exit(0); + return 0; /* just to make compiler happy */ +} diff --git a/tools/gzip-1.2.4/sample/ztouch b/tools/gzip-1.2.4/sample/ztouch new file mode 100755 index 00000000..e408e2bc --- /dev/null +++ b/tools/gzip-1.2.4/sample/ztouch @@ -0,0 +1,15 @@ +#! /usr/local/bin/perl +# Set the time stamp of a gzip'ed file from that stored in the file. +# usage: ztouch files... + +foreach $file (@ARGV) { + open (FILE, $file); + read (FILE, $_, 8); + ($magic, $method, $flags, $time) = unpack ("A2C2V", $_); + if ($magic eq "\037\213") { + utime ($time, $time, $file); + } + else { + warn "$file is not compressed with gzip!\n"; + } +} diff --git a/tools/gzip-1.2.4/tailor.h b/tools/gzip-1.2.4/tailor.h new file mode 100644 index 00000000..a97d8bee --- /dev/null +++ b/tools/gzip-1.2.4/tailor.h @@ -0,0 +1,328 @@ +/* tailor.h -- target dependent definitions + * Copyright (C) 1992-1993 Jean-loup Gailly. + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* The target dependent definitions should be defined here only. + * The target dependent functions should be defined in tailor.c. + */ + +/* $Id: tailor.h,v 0.18 1993/06/14 19:32:20 jloup Exp $ */ + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +#if defined(__OS2__) && !defined(OS2) +# define OS2 +#endif + +#if defined(OS2) && defined(MSDOS) /* MS C under OS/2 */ +# undef MSDOS +#endif + +#ifdef MSDOS +# ifdef __GNUC__ + /* DJGPP version 1.09+ on MS-DOS. + * The DJGPP 1.09 stat() function must be upgraded before gzip will + * fully work. + * No need for DIRENT, since defines POSIX_SOURCE which + * implies DIRENT. + */ +# define near +# else +# define MAXSEG_64K +# ifdef __TURBOC__ +# define NO_OFF_T +# ifdef __BORLANDC__ +# define DIRENT +# else +# define NO_UTIME +# endif +# else /* MSC */ +# define HAVE_SYS_UTIME_H +# define NO_UTIME_H +# endif +# endif +# define PATH_SEP2 '\\' +# define PATH_SEP3 ':' +# define MAX_PATH_LEN 128 +# define NO_MULTIPLE_DOTS +# define MAX_EXT_CHARS 3 +# define Z_SUFFIX "z" +# define NO_CHOWN +# define PROTO +# define STDC_HEADERS +# define NO_SIZE_CHECK +# define casemap(c) tolow(c) /* Force file names to lower case */ +# include +# define OS_CODE 0x00 +# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) +# if !defined(NO_ASM) && !defined(ASMV) +# define ASMV +# endif +#else +# define near +#endif + +#ifdef OS2 +# define PATH_SEP2 '\\' +# define PATH_SEP3 ':' +# define MAX_PATH_LEN 260 +# ifdef OS2FAT +# define NO_MULTIPLE_DOTS +# define MAX_EXT_CHARS 3 +# define Z_SUFFIX "z" +# define casemap(c) tolow(c) +# endif +# define NO_CHOWN +# define PROTO +# define STDC_HEADERS +# include +# define OS_CODE 0x06 +# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) +# ifdef _MSC_VER +# define HAVE_SYS_UTIME_H +# define NO_UTIME_H +# define MAXSEG_64K +# undef near +# define near _near +# endif +# ifdef __EMX__ +# define HAVE_SYS_UTIME_H +# define NO_UTIME_H +# define DIRENT +# define EXPAND(argc,argv) \ + {_response(&argc, &argv); _wildcard(&argc, &argv);} +# endif +# ifdef __BORLANDC__ +# define DIRENT +# endif +# ifdef __ZTC__ +# define NO_DIR +# define NO_UTIME_H +# include +# define EXPAND(argc,argv) \ + {response_expand(&argc, &argv);} +# endif +#endif + +#ifdef WIN32 /* Windows NT */ +# define HAVE_SYS_UTIME_H +# define NO_UTIME_H +# define PATH_SEP2 '\\' +# define PATH_SEP3 ':' +# define MAX_PATH_LEN 260 +# define NO_CHOWN +# define PROTO +# define STDC_HEADERS +# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) +# include +# include +# ifdef NTFAT +# define NO_MULTIPLE_DOTS +# define MAX_EXT_CHARS 3 +# define Z_SUFFIX "z" +# define casemap(c) tolow(c) /* Force file names to lower case */ +# endif +# define OS_CODE 0x0b +#endif + +#ifdef MSDOS +# ifdef __TURBOC__ +# include +# define DYN_ALLOC + /* Turbo C 2.0 does not accept static allocations of large arrays */ + void * fcalloc (unsigned items, unsigned size); + void fcfree (void *ptr); +# else /* MSC */ +# include +# define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize)) +# define fcfree(ptr) hfree(ptr) +# endif +#else +# ifdef MAXSEG_64K +# define fcalloc(items,size) calloc((items),(size)) +# else +# define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size)) +# endif +# define fcfree(ptr) free(ptr) +#endif + +#if defined(VAXC) || defined(VMS) +# define PATH_SEP ']' +# define PATH_SEP2 ':' +# define SUFFIX_SEP ';' +# define NO_MULTIPLE_DOTS +# define Z_SUFFIX "-gz" +# define RECORD_IO 1 +# define casemap(c) tolow(c) +# define OS_CODE 0x02 +# define OPTIONS_VAR "GZIP_OPT" +# define STDC_HEADERS +# define NO_UTIME +# define EXPAND(argc,argv) vms_expand_args(&argc,&argv); +# include +# define unlink delete +# ifdef VAXC +# define NO_FCNTL_H +# include +# endif +#endif + +#ifdef AMIGA +# define PATH_SEP2 ':' +# define STDC_HEADERS +# define OS_CODE 0x01 +# define ASMV +# ifdef __GNUC__ +# define DIRENT +# define HAVE_UNISTD_H +# else /* SASC */ +# define NO_STDIN_FSTAT +# define SYSDIR +# define NO_SYMLINK +# define NO_CHOWN +# define NO_FCNTL_H +# include /* for read() and write() */ +# define direct dirent + extern void _expand_args(int *argc, char ***argv); +# define EXPAND(argc,argv) _expand_args(&argc,&argv); +# undef O_BINARY /* disable useless --ascii option */ +# endif +#endif + +#if defined(ATARI) || defined(atarist) +# ifndef STDC_HEADERS +# define STDC_HEADERS +# define HAVE_UNISTD_H +# define DIRENT +# endif +# define ASMV +# define OS_CODE 0x05 +# ifdef TOSFS +# define PATH_SEP2 '\\' +# define PATH_SEP3 ':' +# define MAX_PATH_LEN 128 +# define NO_MULTIPLE_DOTS +# define MAX_EXT_CHARS 3 +# define Z_SUFFIX "z" +# define NO_CHOWN +# define casemap(c) tolow(c) /* Force file names to lower case */ +# define NO_SYMLINK +# endif +#endif + +#ifdef MACOS +# define PATH_SEP ':' +# define DYN_ALLOC +# define PROTO +# define NO_STDIN_FSTAT +# define NO_CHOWN +# define NO_UTIME +# define chmod(file, mode) (0) +# define OPEN(name, flags, mode) open(name, flags) +# define OS_CODE 0x07 +# ifdef MPW +# define isatty(fd) ((fd) <= 2) +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define PATH_SEP '>' +# define STDC_HEADERS +# define NO_MEMORY_H +# define NO_UTIME_H +# define NO_UTIME +# define NO_CHOWN +# define NO_STDIN_FSTAT +# define NO_SIZE_CHECK +# define NO_SYMLINK +# define RECORD_IO 1 +# define casemap(c) tolow(c) /* Force file names to lower case */ +# define put_char(c) put_byte((c) & 0x7F) +# define get_char(c) ascii2pascii(get_byte()) +# define OS_CODE 0x0F /* temporary, subject to change */ +# ifdef SIGTERM +# undef SIGTERM /* We don't want a signal handler for SIGTERM */ +# endif +#endif + +#if defined(pyr) && !defined(NOMEMCPY) /* Pyramid */ +# define NOMEMCPY /* problem with overlapping copies */ +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifndef unix +# define NO_ST_INO /* don't rely on inode numbers */ +#endif + + + /* Common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef PATH_SEP +# define PATH_SEP '/' +#endif + +#ifndef casemap +# define casemap(c) (c) +#endif + +#ifndef OPTIONS_VAR +# define OPTIONS_VAR "GZIP" +#endif + +#ifndef Z_SUFFIX +# define Z_SUFFIX ".gz" +#endif + +#ifdef MAX_EXT_CHARS +# define MAX_SUFFIX MAX_EXT_CHARS +#else +# define MAX_SUFFIX 30 +#endif + +#ifndef MAKE_LEGAL_NAME +# ifdef NO_MULTIPLE_DOTS +# define MAKE_LEGAL_NAME(name) make_simple_name(name) +# else +# define MAKE_LEGAL_NAME(name) +# endif +#endif + +#ifndef MIN_PART +# define MIN_PART 3 + /* keep at least MIN_PART chars between dots in a file name. */ +#endif + +#ifndef EXPAND +# define EXPAND(argc,argv) +#endif + +#ifndef RECORD_IO +# define RECORD_IO 0 +#endif + +#ifndef SET_BINARY_MODE +# define SET_BINARY_MODE(fd) +#endif + +#ifndef OPEN +# define OPEN(name, flags, mode) open(name, flags, mode) +#endif + +#ifndef get_char +# define get_char() get_byte() +#endif + +#ifndef put_char +# define put_char(c) put_byte(c) +#endif diff --git a/tools/gzip-1.2.4/texinfo.tex b/tools/gzip-1.2.4/texinfo.tex new file mode 100644 index 00000000..203dca72 --- /dev/null +++ b/tools/gzip-1.2.4/texinfo.tex @@ -0,0 +1,3350 @@ +%% TeX macros to handle texinfo files + +% Copyright (C) 1985, 1986, 1988, 1990, 1991 Free Software Foundation, Inc. + +%This texinfo.tex file is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License as +%published by the Free Software Foundation; either version 2, or (at +%your option) any later version. + +%This texinfo.tex file is distributed in the hope that it will be +%useful, but WITHOUT ANY WARRANTY; without even the implied warranty +%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%General Public License for more details. + +%You should have received a copy of the GNU General Public License +%along with this texinfo.tex file; see the file COPYING. If not, write +%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, +%USA. + + +%In other words, you are welcome to use, share and improve this program. +%You are forbidden to forbid anyone else to use, share and improve +%what you give them. Help stamp out software-hoarding! + +\def\texinfoversion{2.73} +\message{Loading texinfo package [Version \texinfoversion]:} +\message{} + +% Print the version number if in a .fmt file. +\everyjob{\message{[Texinfo version \texinfoversion]}\message{}} + +% Save some parts of plain tex whose names we will redefine. + +\let\ptexlbrace=\{ +\let\ptexrbrace=\} +\let\ptexdots=\dots +\let\ptexdot=\. +\let\ptexstar=\* +\let\ptexend=\end +\let\ptexbullet=\bullet +\let\ptexb=\b +\let\ptexc=\c +\let\ptexi=\i +\let\ptext=\t +\let\ptexl=\l +\let\ptexL=\L + +\def\tie{\penalty 10000\ } % Save plain tex definition of ~. + +\message{Basics,} +\chardef\other=12 + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +\hyphenation{ap-pen-dix} +\hyphenation{mini-buf-fer mini-buf-fers} +\hyphenation{eshell} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen \bindingoffset \bindingoffset=0pt +\newdimen \normaloffset \normaloffset=\hoffset +\newdimen\pagewidth \newdimen\pageheight +\pagewidth=\hsize \pageheight=\vsize + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\def\loggingall{\tracingcommands2 \tracingstats2 + \tracingpages1 \tracingoutput1 \tracinglostchars1 + \tracingmacros2 \tracingparagraphs1 \tracingrestores1 + \showboxbreadth\maxdimen\showboxdepth\maxdimen +}% + +%---------------------Begin change----------------------- +% +%%%% For @cropmarks command. +% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\cornerlong \newdimen\cornerthick +\newdimen \topandbottommargin +\newdimen \outerhsize \newdimen \outervsize +\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks +\outerhsize=7in +%\outervsize=9.5in +% Alternative @smallbook page size is 9.25in +\outervsize=9.25in +\topandbottommargin=.75in +% +%---------------------End change----------------------- + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions itself, but you have to call it yourself. +\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} +\def\onepageout#1{\hoffset=\normaloffset +\ifodd\pageno \advance\hoffset by \bindingoffset +\else \advance\hoffset by -\bindingoffset\fi +{\escapechar=`\\\relax % makes sure backslash is used in output files. +\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% +{\let\hsize=\pagewidth \makefootline}}}% +\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} + +%%%% For @cropmarks command %%%% + +% Here is a modification of the main output routine for Near East Publications +% This provides right-angle cropmarks at all four corners. +% The contents of the page are centerlined into the cropmarks, +% and any desired binding offset is added as an \hskip on either +% site of the centerlined box. (P. A. MacKay, 12 November, 1986) +% +\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up + \shipout + \vbox to \outervsize{\hsize=\outerhsize + \vbox{\line{\ewtop\hfill\ewtop}} + \nointerlineskip + \line{\vbox{\moveleft\cornerthick\nstop} + \hfill + \vbox{\moveright\cornerthick\nstop}} + \vskip \topandbottommargin + \centerline{\ifodd\pageno\hskip\bindingoffset\fi + \vbox{ + {\let\hsize=\pagewidth \makeheadline} + \pagebody{#1} + {\let\hsize=\pagewidth \makefootline}} + \ifodd\pageno\else\hskip\bindingoffset\fi} + \vskip \topandbottommargin plus1fill minus1fill + \boxmaxdepth\cornerthick + \line{\vbox{\moveleft\cornerthick\nsbot} + \hfill + \vbox{\moveright\cornerthick\nsbot}} + \nointerlineskip + \vbox{\line{\ewbot\hfill\ewbot}} + } + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi} +% +% Do @cropmarks to get crop marks +\def\cropmarks{\let\onepageout=\croppageout } + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +\dimen@=\dp#1 \unvbox#1 +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. +% The argument can be delimited with [...] or with "..." or braces +% or it can be a whole line. +% #1 should be a macro which expects +% an ordinary undelimited TeX argument. + +\def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx} + +\def\parseargx{% +\ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else% +\aftergroup \parseargline % +\fi \endgroup} + +{\obeyspaces % +\gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}} + +\gdef\obeyedspace{\ } + +\def\parseargline{\begingroup \obeylines \parsearglinex} +{\obeylines % +\gdef\parsearglinex #1^^M{\endgroup \next {#1}}} + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +%% These are used to keep @begin/@end levels from running away +%% Call \inENV within environments (after a \begingroup) +\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} +\def\ENVcheck{% +\ifENV\errmessage{Still within an environment. Type Return to continue.} +\endgroup\fi} % This is not perfect, but it should reduce lossage + +% @begin foo is the same as @foo, for now. +\newhelp\EMsimple{Type to continue} + +\outer\def\begin{\parsearg\beginxxx} + +\def\beginxxx #1{% +\expandafter\ifx\csname #1\endcsname\relax +{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else +\csname #1\endcsname\fi} + +%% @end foo executes the definition of \Efoo. +%% foo can be delimited by doublequotes or brackets. + +\def\end{\parsearg\endxxx} + +\def\endxxx #1{% +\expandafter\ifx\csname E#1\endcsname\relax +\expandafter\ifx\csname #1\endcsname\relax +\errmessage{Undefined command @end #1}\else +\errorE{#1}\fi\fi +\csname E#1\endcsname} +\def\errorE#1{ +{\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}} + +% Single-spacing is done by various environments. + +\newskip\singlespaceskip \singlespaceskip = \baselineskip +\def\singlespace{% +{\advance \baselineskip by -\singlespaceskip +\kern \baselineskip}% +\baselineskip=\singlespaceskip +} + +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt \char '100}} + +% Define @` and @' to be the same as ` and ' +% but suppressing ligatures. +\def\`{{`}} +\def\'{{'}} + +% Used to generate quoted braces. + +\def\mylbrace {{\tt \char '173}} +\def\myrbrace {{\tt \char '175}} +\let\{=\mylbrace +\let\}=\myrbrace + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\hfil\break\hbox{}\ignorespaces} + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=3000 } + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +\def\group{\begingroup + \ifnum\catcode13=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + \def\Egroup{\egroup\endgroup}% + \vtop\bgroup +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\def\need{\parsearg\needx} + +% Old definition--didn't work. +%\def\needx #1{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 +%\prevdepth=-1000pt +%}} + +\def\needx#1{% + % Go into vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % Don't add any leading before our big empty box, but allow a page + % break, since the best break might be right here. + \allowbreak + \nointerlineskip + \vtop to #1\mil{\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak +} + +% @br forces paragraph break + +\let\br = \par + +% @dots{} output some dots + +\def\dots{$\ldots$} + +% @page forces the start of a new page + +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\def\exdent{\parsearg\exdentyyy} +\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} + +% This defn is used inside nofill environments such as @example. +\def\nofillexdent{\parsearg\nofillexdentyyy} +\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount +\leftline{\hskip\leftskip{\rm#1}}}} + +%\hbox{{\rm#1}}\hfil\break}} + +% @include file insert text of that file as input. + +\def\include{\parsearg\includezzz} +\def\includezzz #1{{\def\thisfile{#1}\input #1 +}} + +\def\thisfile{} + +% @center line outputs that line, centered + +\def\center{\parsearg\centerzzz} +\def\centerzzz #1{{\advance\hsize by -\leftskip +\advance\hsize by -\rightskip +\centerline{#1}}} + +% @sp n outputs n lines of vertical space + +\def\sp{\parsearg\spxxx} +\def\spxxx #1{\par \vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment + +\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% +\parsearg \commentxxx} + +\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } + +\let\c=\comment + +% Prevent errors for section commands. +% Used in @ignore and in failing conditionals. +\def\ignoresections{% +\let\chapter=\relax +\let\unnumbered=\relax +\let\top=\relax +\let\unnumberedsec=\relax +\let\unnumberedsection=\relax +\let\unnumberedsubsec=\relax +\let\unnumberedsubsection=\relax +\let\unnumberedsubsubsec=\relax +\let\unnumberedsubsubsection=\relax +\let\section=\relax +\let\subsec=\relax +\let\subsubsec=\relax +\let\subsection=\relax +\let\subsubsection=\relax +\let\appendix=\relax +\let\appendixsec=\relax +\let\appendixsection=\relax +\let\appendixsubsec=\relax +\let\appendixsubsection=\relax +\let\appendixsubsubsec=\relax +\let\appendixsubsubsection=\relax +\let\contents=\relax +\let\smallbook=\relax +\let\titlepage=\relax +} + +\def\ignore{\begingroup\ignoresections +% Make sure that spaces turn into tokens that match what \ignorexxx wants. +\catcode32=10 +\ignorexxx} +\long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces} + +\def\direntry{\begingroup\direntryxxx} +\long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces} + +% Conditionals to test whether a flag is set. + +\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx} + +\def\ifsetxxx #1{\endgroup +\expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail +\else \let\temp=\relax \fi +\temp} +\def\Eifset{} +\def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx} +\long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces} + +\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx} + +\def\ifclearxxx #1{\endgroup +\expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax +\else \let\temp=\ifclearfail \fi +\temp} +\def\Eifclear{} +\def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx} +\long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces} + +% @set foo to set the flag named foo. +% @clear foo to clear the flag named foo. +\def\set{\parsearg\setxxx} +\def\setxxx #1{ +\expandafter\let\csname IF#1\endcsname=\set} + +\def\clear{\parsearg\clearxxx} +\def\clearxxx #1{ +\expandafter\let\csname IF#1\endcsname=\relax} + +% Some texinfo constructs that are trivial in tex + +\def\iftex{} +\def\Eiftex{} +\def\ifinfo{\begingroup\ignoresections\ifinfoxxx} +\long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces} + +\long\def\menu #1\end menu{} +\def\asis#1{#1} + +% @math means output in math mode. +% We don't use $'s directly in the definition of \math because control +% sequences like \math are expanded when the toc file is written. Then, +% we read the toc file back, the $'s will be normal characters (as they +% should be, according to the definition of Texinfo). So we must use a +% control sequence to switch into and out of math mode. +% +% This isn't quite enough for @math to work properly in indices, but it +% seems unlikely it will ever be needed there. +% +\let\implicitmath = $ +\def\math#1{\implicitmath #1\implicitmath} + +\def\node{\ENVcheck\parsearg\nodezzz} +\def\nodezzz#1{\nodexxx [#1,]} +\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} +\let\lastnode=\relax + +\def\donoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\setref{\lastnode}\fi +\let\lastnode=\relax} + +\def\unnumbnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi +\let\lastnode=\relax} + +\def\appendixnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi +\let\lastnode=\relax} + +\let\refill=\relax + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \readauxfile + \opencontents + \openindices + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \global\let\setfilename=\comment % Ignore extra @setfilename cmds. + \comment % Ignore the actual filename. +} + +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, + node \samp{\losespace#1{}}} +\def\losespace #1{#1} + +\message{fonts,} + +% Font-change commands. + +% Texinfo supports the sans serif font style, which plain TeX does not. +% So we set up a \sf analogous to plain's \rm, etc. +\newfam\sffam +\def\sf{\fam=\sffam \tensf} +\let\li = \sf % Sometimes we call it \li, not \sf. + +%% Try out Computer Modern fonts at \magstephalf +\let\mainmagstep=\magstephalf + +\ifx\bigger\relax +\let\mainmagstep=\magstep1 +\font\textrm=cmr12 +\font\texttt=cmtt12 +\else +\font\textrm=cmr10 scaled \mainmagstep +\font\texttt=cmtt10 scaled \mainmagstep +\fi +% Instead of cmb10, you many want to use cmbx10. +% cmbx10 is a prettier font on its own, but cmb10 +% looks better when embedded in a line with cmr10. +\font\textbf=cmb10 scaled \mainmagstep +\font\textit=cmti10 scaled \mainmagstep +\font\textsl=cmsl10 scaled \mainmagstep +\font\textsf=cmss10 scaled \mainmagstep +\font\textsc=cmcsc10 scaled \mainmagstep +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep + +% A few fonts for @defun, etc. +\font\defbf=cmbx10 scaled \magstep1 %was 1314 +\font\deftt=cmtt10 scaled \magstep1 +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} + +% Fonts for indices and small examples. +% We actually use the slanted font rather than the italic, +% because texinfo normally uses the slanted fonts for that. +% Do not make many font distinctions in general in the index, since they +% aren't very useful. +\font\ninett=cmtt9 +\font\indrm=cmr9 +\font\indit=cmsl9 +\let\indsl=\indit +\let\indtt=\ninett +\let\indsf=\indrm +\let\indbf=\indrm +\let\indsc=\indrm +\font\indi=cmmi9 +\font\indsy=cmsy9 + +% Fonts for headings +\font\chaprm=cmbx12 scaled \magstep2 +\font\chapit=cmti12 scaled \magstep2 +\font\chapsl=cmsl12 scaled \magstep2 +\font\chaptt=cmtt12 scaled \magstep2 +\font\chapsf=cmss12 scaled \magstep2 +\let\chapbf=\chaprm +\font\chapsc=cmcsc10 scaled\magstep3 +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 + +\font\secrm=cmbx12 scaled \magstep1 +\font\secit=cmti12 scaled \magstep1 +\font\secsl=cmsl12 scaled \magstep1 +\font\sectt=cmtt12 scaled \magstep1 +\font\secsf=cmss12 scaled \magstep1 +\font\secbf=cmbx12 scaled \magstep1 +\font\secsc=cmcsc10 scaled\magstep2 +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 + +% \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. +% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. +% \font\ssecsl=cmsl10 scaled \magstep1 +% \font\ssectt=cmtt10 scaled \magstep1 +% \font\ssecsf=cmss10 scaled \magstep1 + +%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. +%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than +%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. +%\font\ssectt=cmtt10 scaled 1315 +%\font\ssecsf=cmss10 scaled 1315 + +%\let\ssecbf=\ssecrm + +\font\ssecrm=cmbx12 scaled \magstephalf +\font\ssecit=cmti12 scaled \magstephalf +\font\ssecsl=cmsl12 scaled \magstephalf +\font\ssectt=cmtt12 scaled \magstephalf +\font\ssecsf=cmss12 scaled \magstephalf +\font\ssecbf=cmbx12 scaled \magstephalf +\font\ssecsc=cmcsc10 scaled \magstep1 +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled \magstep1 +% The smallcaps and symbol fonts should actually be scaled \magstep1.5, +% but that is not a standard magnification. + +% Fonts for title page: +\font\titlerm = cmbx12 scaled \magstep3 +\let\authorrm = \secrm + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts, we +% don't bother to reset \scriptfont and \scriptscriptfont (which would +% also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy + \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf + \textfont\ttfam = \tentt \textfont\sffam = \tensf +} + + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this so that font changes will continue to work +% in math mode, where it is the current \fam that is relevant in most +% cases, not the current. Plain TeX does, for example, +% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need +% to redefine \bf itself. +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \resetmathfonts} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy + \resetmathfonts} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \resetmathfonts} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \resetmathfonts} +\def\indexfonts{% + \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl + \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc + \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy + \resetmathfonts} + +% Set up the default fonts, so we can use them for creating boxes. +% +\textfonts + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Fonts for short table of contents. +\font\shortcontrm=cmr12 +\font\shortcontbf=cmbx12 +\font\shortcontsl=cmsl12 + +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic + +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} +\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} + +\let\i=\smartitalic +\let\var=\smartitalic +\let\dfn=\smartitalic +\let\emph=\smartitalic +\let\cite=\smartitalic + +\def\b#1{{\bf #1}} +\let\strong=\b + +\def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null} +\let\ttfont = \t +%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} +\def\samp #1{`\tclose{#1}'\null} +\def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null} +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +\let\file=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\newdimen\tclosesave +\newdimen\tcloserm +\def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font +\fontdimen2\font=\tcloserm +% prevent breaking lines at hyphens. +\exhyphenpenalty=10000 +\def\ {{\fontdimen2\font=\tclosesave{} }}% + \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null} +\let\code=\tclose +%\let\exp=\tclose %Was temporary + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else\tclose{\look}\fi +\else\tclose{\look}\fi} + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of +% @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} + +\def\l#1{{\li #1}\null} % + +\def\r#1{{\rm #1}} % roman font +% Use of \lowercase was suggested. +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\def\titlefont#1{{\titlerm #1}} + +\newtoks\realeverypar +\newif\ifseenauthor +\newif\iffinishedtitlepage + +\def\titlepage{\begingroup \parindent=0pt \textfonts + \let\subtitlerm=\tenrm +% I deinstalled the following change because \cmr12 is undefined. +% This change was not in the ChangeLog anyway. --rms. +% \let\subtitlerm=\cmr12 + \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% + % + \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% + % + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % + % Now you can print the title using @title. + \def\title{\parsearg\titlezzz}% + \def\titlezzz##1{\leftline{\titlefont{##1}} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt \vskip4pt}% + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Now you can put text using @subtitle. + \def\subtitle{\parsearg\subtitlezzz}% + \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% + % + % @author should come last, but may come many times. + \def\author{\parsearg\authorzzz}% + \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi + {\authorfont \leftline{##1}}}% + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \oldpage + \let\page = \oldpage + \hbox{}}% +% \def\page{\oldpage \hbox{}} +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + \HEADINGSon +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +%%% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks \evenheadline % Token sequence for heading line of even pages +\newtoks \oddheadline % Token sequence for heading line of odd pages +\newtoks \evenfootline % Token sequence for footing line of even pages +\newtoks \oddfootline % Token sequence for footing line of odd pages + +% Now make Tex use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + +\def\evenheading{\parsearg\evenheadingxxx} +\def\oddheading{\parsearg\oddheadingxxx} +\def\everyheading{\parsearg\everyheadingxxx} + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\oddfooting{\parsearg\oddfootingxxx} +\def\everyfooting{\parsearg\everyfootingxxx} + +{\catcode`\@=0 % + +\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} +\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} +\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} +\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} +\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} +\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} +\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} +% +}% unbind the catcode of @. + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\HEADINGSoff{ +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} + +% Subroutines used in generating headings +% Produces Day Month Year style of output. +\def\today{\number\day\space +\ifcase\month\or +January\or February\or March\or April\or May\or June\or +July\or August\or September\or October\or November\or December\fi +\space\number\year} + +% Use this if you want the Month Day, Year style of output. +%\def\today{\ifcase\month\or +%January\or February\or March\or April\or May\or June\or +%July\or August\or September\or October\or November\or December\fi +%\space\number\day, \number\year} + +% @settitle line... specifies the title of the document, for headings +% It generates no output of its own + +\def\thistitle{No Title} +\def\settitle{\parsearg\settitlezzz} +\def\settitlezzz #1{\gdef\thistitle{#1}} + +\message{tables,} + +% @tabs -- simple alignment + +% These don't work. For one thing, \+ is defined as outer. +% So these macros cannot even be defined. + +%\def\tabs{\parsearg\tabszzz} +%\def\tabszzz #1{\settabs\+#1\cr} +%\def\tabline{\parsearg\tablinezzz} +%\def\tablinezzz #1{\+#1\cr} +%\def\&{&} + +% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @vtable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\par \parsearg\itemzzz} + +\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} +\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz} + +\def\internalBkitem{\smallbreak \parsearg\kitemzzz} +\def\internalBkitemx{\par \parsearg\kitemzzz} + +\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% + \itemzzz {#1}} + +\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% + \itemzzz {#1}} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemfont{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % Be sure we are not still in the middle of a paragraph. + \parskip=0in + \par + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0 + \nobreak + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. Since that + % text will be indented by \tableindent, we make the item text be in + % a zero-width box. + \noindent + \rlap{\hskip -\tableindent\box0}% + \fi + \endgroup +} + +\def\item{\errmessage{@item while not in a table}} +\def\itemx{\errmessage{@itemx while not in a table}} +\def\kitem{\errmessage{@kitem while not in a table}} +\def\kitemx{\errmessage{@kitemx while not in a table}} +\def\xitem{\errmessage{@xitem while not in a table}} +\def\xitemx{\errmessage{@xitemx while not in a table}} + +%% Contains a kludge to get @end[description] to work +\def\description{\tablez{\dontindex}{1}{}{}{}{}} + +\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} +{\obeylines\obeyspaces% +\gdef\tablex #1^^M{% +\tabley\dontindex#1 \endtabley}} + +\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} +{\obeylines\obeyspaces% +\gdef\ftablex #1^^M{% +\tabley\fnitemindex#1 \endtabley +\def\Eftable{\endgraf\endgroup\afterenvbreak}% +\let\Etable=\relax}} + +\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} +{\obeylines\obeyspaces% +\gdef\vtablex #1^^M{% +\tabley\vritemindex#1 \endtabley +\def\Evtable{\endgraf\endgroup\afterenvbreak}% +\let\Etable=\relax}} + +\def\dontindex #1{} +\def\fnitemindex #1{\doind {fn}{\code{#1}}}% +\def\vritemindex #1{\doind {vr}{\code{#1}}}% + +{\obeyspaces % +\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% +\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} + +\def\tablez #1#2#3#4#5#6{% +\aboveenvbreak % +\begingroup % +\def\Edescription{\Etable}% Neccessary kludge. +\let\itemindex=#1% +\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % +\ifnum 0#4>0 \tableindent=#4\mil \fi % +\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % +\def\itemfont{#2}% +\itemmax=\tableindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \tableindent % +\exdentamount=\tableindent +\parindent = 0pt +\parskip = \smallskipamount +\ifdim \parskip=0pt \parskip=2pt \fi% +\def\Etable{\endgraf\endgroup\afterenvbreak}% +\let\item = \internalBitem % +\let\itemx = \internalBitemx % +\let\kitem = \internalBkitem % +\let\kitemx = \internalBkitemx % +\let\xitem = \internalBxitem % +\let\xitemx = \internalBxitemx % +} + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\def\itemize{\parsearg\itemizezzz} + +\def\itemizezzz #1{% + \begingroup % ended by the @end itemsize + \itemizey {#1}{\Eitemize} +} + +\def\itemizey #1#2{% +\aboveenvbreak % +\itemmax=\itemindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \itemindent % +\exdentamount=\itemindent +\parindent = 0pt % +\parskip = \smallskipamount % +\ifdim \parskip=0pt \parskip=2pt \fi% +\def#2{\endgraf\endgroup\afterenvbreak}% +\def\itemcontents{#1}% +\let\item=\itemizeitem} + +\def\bullet{$\ptexbullet$} +\def\minus{$-$} + +% Set sfcode to normal for the chars that usually have another value. +% These are `.?!:;,' +\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 + \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\def\enumerate{\parsearg\enumeratezzz} +\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + \begingroup % ended by the @end enumerate + % + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a . + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call itemizey, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \itemizey{#1.}\Eenumerate\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + +% Definition of @item while inside @itemize. + +\def\itemizeitem{% +\advance\itemno by 1 +{\let\par=\endgraf \smallbreak}% +\ifhmode \errmessage{\in hmode at itemizeitem}\fi +{\parskip=0in \hskip 0pt +\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% +\vadjust{\penalty 1200}}% +\flushcr} + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within \newindex. +{\catcode`\@=11 +\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. + +\def\newindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#1}} +} + +% @defindex foo == \newindex{foo} + +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. + +\def\newcodeindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#1}} +} + +\def\defcodeindex{\parsearg\newcodeindex} + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +\def\synindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#2}}% +} + +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +\def\syncodeindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#2}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +\def\indexdummies{% +\def\_{{\realbackslash _}}% +\def\w{\realbackslash w }% +\def\bf{\realbackslash bf }% +\def\rm{\realbackslash rm }% +\def\sl{\realbackslash sl }% +\def\sf{\realbackslash sf}% +\def\tt{\realbackslash tt}% +\def\gtr{\realbackslash gtr}% +\def\less{\realbackslash less}% +\def\hat{\realbackslash hat}% +\def\char{\realbackslash char}% +\def\TeX{\realbackslash TeX}% +\def\dots{\realbackslash dots }% +\def\copyright{\realbackslash copyright }% +\def\tclose##1{\realbackslash tclose {##1}}% +\def\code##1{\realbackslash code {##1}}% +\def\samp##1{\realbackslash samp {##1}}% +\def\t##1{\realbackslash r {##1}}% +\def\r##1{\realbackslash r {##1}}% +\def\i##1{\realbackslash i {##1}}% +\def\b##1{\realbackslash b {##1}}% +\def\cite##1{\realbackslash cite {##1}}% +\def\key##1{\realbackslash key {##1}}% +\def\file##1{\realbackslash file {##1}}% +\def\var##1{\realbackslash var {##1}}% +\def\kbd##1{\realbackslash kbd {##1}}% +} + +% \indexnofonts no-ops all font-change commands. +% This is used when outputting the strings to sort the index by. +\def\indexdummyfont#1{#1} +\def\indexdummytex{TeX} +\def\indexdummydots{...} + +\def\indexnofonts{% +\let\w=\indexdummyfont +\let\t=\indexdummyfont +\let\r=\indexdummyfont +\let\i=\indexdummyfont +\let\b=\indexdummyfont +\let\emph=\indexdummyfont +\let\strong=\indexdummyfont +\let\cite=\indexdummyfont +\let\sc=\indexdummyfont +%Don't no-op \tt, since it isn't a user-level command +% and is used in the definitions of the active chars like <, >, |... +%\let\tt=\indexdummyfont +\let\tclose=\indexdummyfont +\let\code=\indexdummyfont +\let\file=\indexdummyfont +\let\samp=\indexdummyfont +\let\kbd=\indexdummyfont +\let\key=\indexdummyfont +\let\var=\indexdummyfont +\let\TeX=\indexdummytex +\let\dots=\indexdummydots +} + +% To define \realbackslash, we must make \ not be an escape. +% We must first make another character (@) an escape +% so we do not become unable to do a definition. + +{\catcode`\@=0 \catcode`\\=\other +@gdef@realbackslash{\}} + +\let\indexbackslash=0 %overridden during \printindex. + +\def\doind #1#2{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% Expand all macros now EXCEPT \folio +\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now +% so it will be output as is; and it will print as backslash in the indx. +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}}}% +\temp }% +}\penalty\count10}} + +\def\dosubind #1#2#3{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% +\def\rawbackslashxx{\indexbackslash}% +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2 #3}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% +\temp }% +}\penalty\count10}} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% This is what you call to cause a particular index to get printed. +% Write +% @unnumbered Function Index +% @printindex fn + +\def\printindex{\parsearg\doprintindex} + +\def\doprintindex#1{% + \tex + \dobreak \chapheadingskip {10000} + \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other + \catcode`\$=\other\catcode`\_=\other + \catcode`\~=\other + % + % The following don't help, since the chars were translated + % when the raw index was written, and their fonts were discarded + % due to \indexnofonts. + %\catcode`\"=\active + %\catcode`\^=\active + %\catcode`\_=\active + %\catcode`\|=\active + %\catcode`\<=\active + %\catcode`\>=\active + % % + \def\indexbackslash{\rawbackslashxx} + \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt + \begindoublecolumns + % + % See if the index file exists and is nonempty. + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + (Index is nonexistent) + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + (Index is empty) + \else + \input \jobname.#1s + \fi + \fi + \closein 1 + \enddoublecolumns + \Etex +} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +% Same as \bigskipamount except no shrink. +% \balancecolumns gets confused if there is any shrink. +\newskip\initialskipamount \initialskipamount 12pt plus4pt + +\def\initial #1{% +{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt +\ifdim\lastskip<\initialskipamount +\removelastskip \penalty-200 \vskip \initialskipamount\fi +\line{\secbf#1\hfill}\kern 2pt\penalty10000}} + +\def\entry #1#2{\begingroup + \parfillskip=0in \parskip=0in \parindent=0in + % + % \hangindent is only relevant when the page number and the entry text + % don't fit on one line. In that case, bob suggests starting the dots + % pretty far over on the line. + % \hangafter is reset to 1 at the start of each paragraph. + \hangindent=.75\hsize + \noindent + % + % Don't break the text of the index entry. + \hbox{#1}% + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without, a spurious underfull \hbox ensues. + \ #2% The page number ends the paragraph. + \par +\endgroup} + +% Like \dotfill except takes at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm + +\def\secondary #1#2{ +{\parfillskip=0in \parskip=0in +\hangindent =1in \hangafter=1 +\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par +}} + +%% Define two-column mode, which is used in indexes. +%% Adapted from the TeXBook, page 416 +\catcode `\@=11 + +\newbox\partialpage + +\newdimen\doublecolumnhsize \doublecolumnhsize = 3.11in +\newdimen\doublecolumnvsize \doublecolumnvsize = 19.1in +\newdimen\availdimen@ + +\def\begindoublecolumns{\begingroup + \output={\global\setbox\partialpage= + \vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject + \output={\doublecolumnout}% + \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize} +\def\enddoublecolumns{\output={\balancecolumns}\eject + \endgroup \pagegoal=\vsize} + +\def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth + \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ + \onepageout\pagesofar \unvbox255 \penalty\outputpenalty} +\def\pagesofar{\unvbox\partialpage % + \hsize=\doublecolumnhsize % have to restore this since output routine +% changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986) + \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} +\def\balancecolumns{% +% Unset the glue. + \setbox255=\vbox{\unvbox255} + \dimen@=\ht255 + \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip + \divide\dimen@ by2 + \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage +% If the remaining data is too big for one page, +% output one page normally, then work with what remains. + \ifdim \dimen@>\availdimen@ + { + \splittopskip=\topskip \splitmaxdepth=\maxdepth + \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ + \onepageout\pagesofar + } +% Recompute size of what remains, in case we just output some of it. + \dimen@=\ht255 + \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip + \divide\dimen@ by2 + \fi + \setbox0=\vbox{\unvbox255} + \splittopskip=\topskip + {\vbadness=10000 \loop \global\setbox3=\copy0 + \global\setbox1=\vsplit3 to\dimen@ + \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat} + \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox3} + \pagesofar} + +\catcode `\@=\other +\message{sectioning,} +% Define chapters, sections, etc. + +\newcount \chapno +\newcount \secno \secno=0 +\newcount \subsecno \subsecno=0 +\newcount \subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +\newcount \appendixno \appendixno = `\@ +\def\appendixletter{\char\the\appendixno} + +\newwrite \contentsfile +% This is called from \setfilename. +\def\opencontents{\openout \contentsfile = \jobname.toc} + +% Each @chapter defines this as the name of the chapter. +% page headings and footings can use it. @section does likewise + +\def\thischapter{} \def\thissection{} +\def\seccheck#1{\if \pageno<0 % +\errmessage{@#1 not allowed after generating table of contents}\fi +% +} + +\def\chapternofonts{% +\let\rawbackslash=\relax% +\let\frenchspacing=\relax% +\def\result{\realbackslash result} +\def\equiv{\realbackslash equiv} +\def\expansion{\realbackslash expansion} +\def\print{\realbackslash print} +\def\TeX{\realbackslash TeX} +\def\dots{\realbackslash dots} +\def\copyright{\realbackslash copyright} +\def\tt{\realbackslash tt} +\def\bf{\realbackslash bf } +\def\w{\realbackslash w} +\def\less{\realbackslash less} +\def\gtr{\realbackslash gtr} +\def\hat{\realbackslash hat} +\def\char{\realbackslash char} +\def\tclose##1{\realbackslash tclose {##1}} +\def\code##1{\realbackslash code {##1}} +\def\samp##1{\realbackslash samp {##1}} +\def\r##1{\realbackslash r {##1}} +\def\b##1{\realbackslash b {##1}} +\def\key##1{\realbackslash key {##1}} +\def\file##1{\realbackslash file {##1}} +\def\kbd##1{\realbackslash kbd {##1}} +% These are redefined because @smartitalic wouldn't work inside xdef. +\def\i##1{\realbackslash i {##1}} +\def\cite##1{\realbackslash cite {##1}} +\def\var##1{\realbackslash var {##1}} +\def\emph##1{\realbackslash emph {##1}} +\def\dfn##1{\realbackslash dfn {##1}} +} + +\def\thischaptername{No Chapter Title} +\outer\def\chapter{\parsearg\chapterzzz} +\def\chapterzzz #1{\seccheck{chapter}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \chapno by 1 \message{Chapter \the\chapno}% +\chapmacro {#1}{\the\chapno}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +% We don't substitute the actual chapter name into \thischapter +% because we don't want its macros evaluated now. +\xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% +{\chapternofonts% +\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec +}} + +\outer\def\appendix{\parsearg\appendixzzz} +\def\appendixzzz #1{\seccheck{appendix}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \appendixno by 1 \message{Appendix \appendixletter}% +\chapmacro {#1}{Appendix \appendixletter}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +\xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% +{\chapternofonts% +\edef\temp{{\realbackslash chapentry + {#1}{Appendix \appendixletter}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\global\let\section = \appendixsec +\global\let\subsection = \appendixsubsec +\global\let\subsubsection = \appendixsubsubsec +}} + +\outer\def\top{\parsearg\unnumberedzzz} +\outer\def\unnumbered{\parsearg\unnumberedzzz} +\def\unnumberedzzz #1{\seccheck{unnumbered}% +\secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)} +\unnumbchapmacro {#1}% +\gdef\thischapter{#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\global\let\section = \unnumberedsec +\global\let\subsection = \unnumberedsubsec +\global\let\subsubsection = \unnumberedsubsubsec +}} + +\outer\def\numberedsec{\parsearg\seczzz} +\def\seczzz #1{\seccheck{section}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% +{\chapternofonts% +\edef\temp{{\realbackslash secentry % +{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsection{\parsearg\appendixsectionzzz} +\outer\def\appendixsec{\parsearg\appendixsectionzzz} +\def\appendixsectionzzz #1{\seccheck{appendixsection}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% +{\chapternofonts% +\edef\temp{{\realbackslash secentry % +{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsec{\parsearg\unnumberedseczzz} +\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsec{\parsearg\numberedsubseczzz} +\def\numberedsubseczzz #1{\seccheck{subsection}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsecentry % +{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsec{\parsearg\appendixsubseczzz} +\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsecentry % +{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz} +\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz} +\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsubsecentry % + {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} + {\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz} +\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsubsecentry{#1}% + {\appendixletter} + {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} +\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +% These are variants which are not "outer", so they can appear in @ifinfo. +% Actually, they should now be obsolete; ordinary section commands should work. +\def\infotop{\parsearg\unnumberedzzz} +\def\infounnumbered{\parsearg\unnumberedzzz} +\def\infounnumberedsec{\parsearg\unnumberedseczzz} +\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} +\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} + +\def\infoappendix{\parsearg\appendixzzz} +\def\infoappendixsec{\parsearg\appendixseczzz} +\def\infoappendixsubsec{\parsearg\appendixsubseczzz} +\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} + +\def\infochapter{\parsearg\chapterzzz} +\def\infosection{\parsearg\sectionzzz} +\def\infosubsection{\parsearg\subsectionzzz} +\def\infosubsubsection{\parsearg\subsubsectionzzz} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +% NOTE on use of \vbox for chapter headings, section headings, and +% such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + + +\def\majorheading{\parsearg\majorheadingzzz} +\def\majorheadingzzz #1{% +{\advance\chapheadingskip by 10pt \chapbreak }% +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\chapheading{\parsearg\chapheadingzzz} +\def\chapheadingzzz #1{\chapbreak % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\heading{\parsearg\secheadingi} + +\def\subheading{\parsearg\subsecheadingi} + +\def\subsubheading{\parsearg\subsubsecheadingi} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +%%% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} + +%%% Define plain chapter starts, and page on/off switching for it +% Parameter controlling skip before chapter headings (if needed) + +\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt + +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{ +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{ +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{ +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +\def\CHAPFplain{ +\global\let\chapmacro=\chfplain +\global\let\unnumbchapmacro=\unnchfplain} + +\def\chfplain #1#2{% + \pchapsepmacro + {% + \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #2\enspace #1}% + }% + \bigskip + \penalty5000 +} + +\def\unnchfplain #1{% +\pchapsepmacro % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} +\CHAPFplain % The default + +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} + +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} + +\def\CHAPFopen{ +\global\let\chapmacro=\chfopen +\global\let\unnumbchapmacro=\unnchfopen} + +% Parameter controlling skip before section headings. + +\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt +\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} + +\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt +\def\secheadingbreak{\dobreak \secheadingskip {-1000}} + +% @paragraphindent is defined for the Info formatting commands only. +\let\paragraphindent=\comment + +% Section fonts are the base font at magstep2, which produces +% a size a bit more than 14 points in the default situation. + +\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} +\def\plainsecheading #1{\secheadingi {#1}} +\def\secheadingi #1{{\advance \secheadingskip by \parskip % +\secheadingbreak}% +{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + + +% Subsection fonts are the base font at magstep1, +% which produces a size of 12 points. + +\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} +\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + +\def\subsubsecfonts{\subsecfonts} % Maybe this should change: + % Perhaps make sssec fonts scaled + % magstep half +\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} +\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} + + +\message{toc printing,} + +% Finish up the main text and prepare to read what we've written +% to \contentsfile. + +\newskip\contentsrightmargin \contentsrightmargin=1in +\def\startcontents#1{% + \pagealignmacro + \immediate\closeout \contentsfile + \ifnum \pageno>0 + \pageno = -1 % Request roman numbered pages. + \fi + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \unnumbchapmacro{#1}\def\thischapter{}% + \begingroup % Set up to handle contents files properly. + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. +} + + +% Normal (long) toc. +\outer\def\contents{% + \startcontents{Table of Contents}% + \input \jobname.toc + \endgroup + \vfill \eject +} + +% And just the chapters. +\outer\def\summarycontents{% + \startcontents{Short Contents}% + % + \let\chapentry = \shortchapentry + \let\unnumbchapentry = \shortunnumberedentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl + \rm + \advance\baselineskip by 1pt % Open it up a little. + \def\secentry ##1##2##3##4{} + \def\unnumbsecentry ##1##2{} + \def\subsecentry ##1##2##3##4##5{} + \def\unnumbsubsecentry ##1##2{} + \def\subsubsecentry ##1##2##3##4##5##6{} + \def\unnumbsubsubsecentry ##1##2{} + \input \jobname.toc + \endgroup + \vfill \eject +} +\let\shortcontents = \summarycontents + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Chapter-level things, for both the long and short contents. +\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} + +% See comments in \dochapentry re vbox and related settings +\def\shortchapentry#1#2#3{% + \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\strut\raggedright + {#2\labelspace #1}\dotfill\doshortpageno{#3}}% +} + +\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} +\def\shortunnumberedentry#1#2{% + \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\strut\raggedright + #1\dotfill\doshortpageno{#2}}% +} + +% Sections. +\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} +\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} + +% Subsections. +\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} +\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} + +% And subsubsections. +\def\subsubsecentry#1#2#3#4#5#6{% + \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} +\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} + + +% This parameter controls the indentation of the various levels. +\newdimen\tocindent \tocindent = 3pc + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we would want to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip\baselineskip + % This \vbox (and similar ones in dosecentry etc.) used to be a + % \line; changed to permit linebreaks for long headings. See + % comments above \majorheading. Here we also use \strut to + % keep the top end of the vbox from jamming up against the previous + % entry in the table of contents. + \vbox{\chapentryfonts + \hyphenpenalty=10000\tolerance=5000 % this line and next introduced + \parindent=0pt\strut\raggedright % with \line -> \vbox change + #1\dotfill + \dopageno{#2}}% + \nobreak\vskip .25\baselineskip +} + +\def\dosecentry#1#2{% + \vbox{\secentryfonts \leftskip=\tocindent + \hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\strut\raggedright #1\dotfill + \dopageno{#2}}% +} + +\def\dosubsecentry#1#2{% + \vbox{\subsecentryfonts \leftskip=2\tocindent + \hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\strut\raggedright #1\dotfill + \dopageno{#2}}% +} + +\def\dosubsubsecentry#1#2{% + \vbox{\subsubsecentryfonts \leftskip=3\tocindent + \hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\strut\raggedright #1\dotfill + \dopageno{#2}}% +} + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\let\subsecentryfonts = \textfonts +\let\subsubsecentryfonts = \textfonts + + +\message{environments,} + +% Since these characters are used in examples, it should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% Furthermore, these definitions must come after we define our fonts. +\newbox\dblarrowbox \newbox\longdblarrowbox +\newbox\pushcharbox \newbox\bullbox +\newbox\equivbox \newbox\errorbox + +\let\ptexequiv = \equiv + +%{\tentt +%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} +%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} +%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} +%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} +% Adapted from the manmac format (p.420 of TeXbook) +%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex +% depth .1ex\hfil} +%} + +\def\point{$\star$} + +\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} + +\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% Adapted from the TeXbook's \boxit. +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} + +\global\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{ + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} + +% The @error{} command. +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @tex ... @end tex escapes into raw Tex temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain tex @ character. + +\def\tex{\begingroup +\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 +\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 +\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie +\catcode `\%=14 +\catcode 43=12 +\catcode`\"=12 +\catcode`\==12 +\catcode`\|=12 +\catcode`\<=12 +\catcode`\>=12 +\escapechar=`\\ +% +\let\{=\ptexlbrace +\let\}=\ptexrbrace +\let\.=\ptexdot +\let\*=\ptexstar +\let\dots=\ptexdots +\def\@{@}% +\let\bullet=\ptexbullet +\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl +\let\L=\ptexL +% +\let\Etex=\endgroup} + +% Define @lisp ... @endlisp. +% @lisp does a \begingroup so it can rebind things, +% including the definition of @endlisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^M gets inside @lisp +% phr: changed space to \null, to avoid overfull hbox problems. +{\obeyspaces% +\gdef\lisppar{\null\endgraf}} + +% Cause \obeyspaces to make each Space cause a word-separation +% rather than the default which is that it acts punctuation. +% This is because space in tt font looks funny. +{\obeyspaces % +\gdef\sepspaces{\def {\ }}} + +\newskip\aboveenvskipamount \aboveenvskipamount= 0pt +\def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip +\endgraf \ifdim\lastskip<\aboveenvskipamount +\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}} + +\def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount +\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi} + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. +\let\nonarrowing=\relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \cartouche: draw rectangle w/rounded corners around argument +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\long\def\cartouche{% +\begingroup + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt %we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18pt % allow for 3pt kerns on either +% side, and for 6pt waste from +% each corner char + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing=\comment + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \hsize=\cartinner + \kern3pt + \begingroup + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip +\def\Ecartouche{% + \endgroup + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup +\endgroup +}} + +\def\lisp{\aboveenvbreak +\begingroup\inENV % This group ends at the end of the @lisp body +\hfuzz=12truept % Don't be fussy +% Make spaces be word-separators rather than space tokens. +\sepspaces % +% Single space lines +\singlespace % +% The following causes blank lines not to be ignored +% by adding a space to the end of each line. +\let\par=\lisppar +\def\Elisp{\endgroup\afterenvbreak}% +\parskip=0pt +% @cartouche defines \nonarrowing to inhibit narrowing +% at next level down. +\ifx\nonarrowing\relax +\advance \leftskip by \lispnarrowing +\exdentamount=\lispnarrowing +\let\exdent=\nofillexdent +\let\nonarrowing=\relax +\fi +\parindent=0pt +\obeyspaces \obeylines \tt \rawbackslash +\def\next##1{}\next} + + +\let\example=\lisp +\def\Eexample{\Elisp} + +\let\smallexample=\lisp +\def\Esmallexample{\Elisp} + +% Macro for 9 pt. examples, necessary to print with 5" lines. +% From Pavel@xerox. This is not really used unless the +% @smallbook command is given. + +\def\smalllispx{\aboveenvbreak\begingroup\inENV +% This group ends at the end of the @lisp body +\hfuzz=12truept % Don't be fussy +% Make spaces be word-separators rather than space tokens. +\sepspaces % +% Single space lines +\singlespace % +% The following causes blank lines not to be ignored +% by adding a space to the end of each line. +\let\par=\lisppar +\def\Esmalllisp{\endgroup\afterenvbreak}% +%%%% Smaller baseline skip for small examples. +\baselineskip 10pt +\parskip=0pt +% @cartouche defines \nonarrowing to inhibit narrowing +% at next level down. +\ifx\nonarrowing\relax +\advance \leftskip by \lispnarrowing +\exdentamount=\lispnarrowing +\let\exdent=\nofillexdent +\let\nonarrowing=\relax +\fi +\parindent=0pt +\obeyspaces \obeylines \ninett \indexfonts \rawbackslash +\def\next##1{}\next} + +% This is @display; same as @lisp except use roman font. + +\def\display{\begingroup\inENV %This group ends at the end of the @display body +\aboveenvbreak +% Make spaces be word-separators rather than space tokens. +\sepspaces % +% Single space lines +\singlespace % +% The following causes blank lines not to be ignored +% by adding a space to the end of each line. +\let\par=\lisppar +\def\Edisplay{\endgroup\afterenvbreak}% +\parskip=0pt +% @cartouche defines \nonarrowing to inhibit narrowing +% at next level down. +\ifx\nonarrowing\relax +\advance \leftskip by \lispnarrowing +\exdentamount=\lispnarrowing +\let\exdent=\nofillexdent +\let\nonarrowing=\relax +\fi +\parindent=0pt +\obeyspaces \obeylines +\def\next##1{}\next} + +% This is @format; same as @lisp except use roman font and don't narrow margins + +\def\format{\begingroup\inENV %This group ends at the end of the @format body +\aboveenvbreak +% Make spaces be word-separators rather than space tokens. +\sepspaces % +\singlespace % +% The following causes blank lines not to be ignored +% by adding a space to the end of each line. +\let\par=\lisppar +\def\Eformat{\endgroup\afterenvbreak} +\parskip=0pt \parindent=0pt +\obeyspaces \obeylines +\def\next##1{}\next} + +% @flushleft and @flushright + +\def\flushleft{% +\begingroup\inENV %This group ends at the end of the @format body +\aboveenvbreak +% Make spaces be word-separators rather than space tokens. +\sepspaces % +% The following causes blank lines not to be ignored +% by adding a space to the end of each line. +% This also causes @ to work when the directive name +% is terminated by end of line. +\let\par=\lisppar +\def\Eflushleft{\endgroup\afterenvbreak}% +\parskip=0pt \parindent=0pt +\obeyspaces \obeylines +\def\next##1{}\next} + +\def\flushright{% +\begingroup\inENV %This group ends at the end of the @format body +\aboveenvbreak +% Make spaces be word-separators rather than space tokens. +\sepspaces % +% The following causes blank lines not to be ignored +% by adding a space to the end of each line. +% This also causes @ to work when the directive name +% is terminated by end of line. +\let\par=\lisppar +\def\Eflushright{\endgroup\afterenvbreak}% +\parskip=0pt \parindent=0pt +\advance \leftskip by 0pt plus 1fill +\obeyspaces \obeylines +\def\next##1{}\next} + +% @quotation - narrow the margins. + +\def\quotation{% +\begingroup\inENV %This group ends at the end of the @quotation body +{\parskip=0pt % because we will skip by \parskip too, later +\aboveenvbreak}% +\singlespace +\parindent=0pt +\def\Equotation{\par\endgroup\afterenvbreak}% +% @cartouche defines \nonarrowing to inhibit narrowing +% at next level down. +\ifx\nonarrowing\relax +\advance \leftskip by \lispnarrowing +\advance \rightskip by \lispnarrowing +\exdentamount=\lispnarrowing +\let\nonarrowing=\relax +\fi} + +\message{defuns,} +% Define formatter for defuns +% First, allow user to change definition object font (\df) internally +\def\setdeffont #1 {\csname DEF#1\endcsname} + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deftypemargin \deftypemargin=12pt +\newskip\deflastargmargin \deflastargmargin=18pt + +\newcount\parencount +% define \functionparens, which makes ( and ) and & do special things. +% \functionparens affects the group it is contained in. +\def\activeparens{% +\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active +\catcode`\[=\active \catcode`\]=\active} +{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) +\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } +\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} + +% Definitions of (, ) and & used in args for functions. +% This is the definition of ( outside of all parentheses. +\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % +\global\advance\parencount by 1 } +% +% This is the definition of ( when already inside a level of parens. +\gdef\opnested{\char`\(\global\advance\parencount by 1 } +% +\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. +% also in that case restore the outer-level definition of (. +\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi +\global\advance \parencount by -1 } +% If we encounter &foo, then turn on ()-hacking afterwards +\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } +% +\gdef\normalparens{\boldbrax\let&=\ampnr} +} % End of definition inside \activeparens +%% These parens (in \boldbrax) actually are a little bolder than the +%% contained text. This is especially needed for [ and ] +\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} +\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} + +% First, defname, which formats the header line itself. +% #1 should be the function name. +% #2 should be the type of definition, such as "Function". + +\def\defname #1#2{% +% Get the values of \leftskip and \rightskip as they were +% outside the @def... +\dimen2=\leftskip +\advance\dimen2 by -\defbodyindent +\dimen3=\rightskip +\advance\dimen3 by -\defbodyindent +\noindent % +\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% +\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line +\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations +\parshape 2 0in \dimen0 \defargsindent \dimen1 % +% Now output arg 2 ("Function" or some such) +% ending at \deftypemargin from the right margin, +% but stuck inside a box of width 0 so it does not interfere with linebreaking +{% Adjust \hsize to exclude the ambient margins, +% so that \rightline will obey them. +\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 +\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% +% Make all lines underfull and no complaints: +\tolerance=10000 \hbadness=10000 +\advance\leftskip by -\defbodyindent +\exdentamount=\defbodyindent +{\df #1}\enskip % Generate function name +} + +% Actually process the body of a definition +% #1 should be the terminating control sequence, such as \Edefun. +% #2 should be the "another name" control sequence, such as \defunx. +% #3 should be the control sequence that actually processes the header, +% such as \defunheader. + +\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % +\obeylines\activeparens\spacesplit#3} + +\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} + +\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} + +% These parsing functions are similar to the preceding ones +% except that they do not make parens into active characters. +% These are used for "variables" since they have no arguments. + +\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % +\obeylines\spacesplit#3} + +\def\defvrparsebody #1#2#3#4 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\spacesplit{#3{#4}}} + +\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\spacesplit{#3{#5}}} + +% Split up #2 at the first space token. +% call #1 with two arguments: +% the first is all of #2 before the space token, +% the second is all of #2 after that space token. +% If #2 contains no space token, all of it is passed as the first arg +% and the second is passed as empty. + +{\obeylines +\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% +\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% +\ifx\relax #3% +#1{#2}{}\else #1{#2}{#3#4}\fi}} + +% So much for the things common to all kinds of definitions. + +% Define @defun. + +% First, define the processing that is wanted for arguments of \defun +% Use this to expand the args and terminate the paragraph they make up + +\def\defunargs #1{\functionparens \sl +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +\hyphenchar\tensl=0 +#1% +\hyphenchar\tensl=45 +\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +\def\deftypefunargs #1{% +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +\functionparens +\code{#1}% +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +% Do complete processing of one @defun or @defunx line already parsed. + +% @deffn Command forward-char nchars + +\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} + +\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% +\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defun == @deffn Function + +\def\defun{\defparsebody\Edefun\defunx\defunheader} + +\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Function}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefun int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} + +% #1 is the data type. #2 is the name and args. +\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} +% #1 is the data type, #2 the name, #3 the args. +\def\deftypefunheaderx #1#2 #3\relax{% +\doind {fn}{\code{#2}}% Make entry in function index +\begingroup\defname {\code{#1} #2}{Function}% +\deftypefunargs {#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} + +% #1 is the classification. #2 is the data type. #3 is the name and args. +\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} +% #1 is the classification, #2 the data type, #3 the name, #4 the args. +\def\deftypefnheaderx #1#2#3 #4\relax{% +\doind {fn}{\code{#3}}% Make entry in function index +\begingroup\defname {\code{#2} #3}{#1}% +\deftypefunargs {#4}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defmac == @deffn Macro + +\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} + +\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Macro}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defspec == @deffn Special Form + +\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} + +\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Special Form}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% This definition is run if you use @defunx +% anywhere other than immediately after a @defun or @defunx. + +\def\deffnx #1 {\errmessage{@deffnx in invalid context}} +\def\defunx #1 {\errmessage{@defunx in invalid context}} +\def\defmacx #1 {\errmessage{@defmacx in invalid context}} +\def\defspecx #1 {\errmessage{@defspecx in invalid context}} +\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} +\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} + +% @defmethod, and so on + +% @defop {Funny Method} foo-class frobnicate argument + +\def\defop #1 {\def\defoptype{#1}% +\defopparsebody\Edefop\defopx\defopheader\defoptype} + +\def\defopheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index +\begingroup\defname {#2}{\defoptype{} on #1}% +\defunargs {#3}\endgroup % +} + +% @defmethod == @defop Method + +\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} + +\def\defmethodheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% entry in function index +\begingroup\defname {#2}{Method on #1}% +\defunargs {#3}\endgroup % +} + +% @defcv {Class Option} foo-class foo-flag + +\def\defcv #1 {\def\defcvtype{#1}% +\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} + +\def\defcvarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{\defcvtype{} of #1}% +\defvarargs {#3}\endgroup % +} + +% @defivar == @defcv {Instance Variable} + +\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} + +\def\defivarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{Instance Variable of #1}% +\defvarargs {#3}\endgroup % +} + +% These definitions are run if you use @defmethodx, etc., +% anywhere other than immediately after a @defmethod, etc. + +\def\defopx #1 {\errmessage{@defopx in invalid context}} +\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} +\def\defcvx #1 {\errmessage{@defcvx in invalid context}} +\def\defivarx #1 {\errmessage{@defivarx in invalid context}} + +% Now @defvar + +% First, define the processing that is wanted for arguments of @defvar. +% This is actually simple: just print them in roman. +% This must expand the args and terminate the paragraph they make up +\def\defvarargs #1{\normalparens #1% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000} + +% @defvr Counter foo-count + +\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} + +\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% +\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} + +% @defvar == @defvr Variable + +\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} + +\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{Variable}% +\defvarargs {#2}\endgroup % +} + +% @defopt == @defvr {User Option} + +\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} + +\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{User Option}% +\defvarargs {#2}\endgroup % +} + +% @deftypevar int foobar + +\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} + +% #1 is the data type. #2 is the name. +\def\deftypevarheader #1#2{% +\doind {vr}{\code{#2}}% Make entry in variables index +\begingroup\defname {\code{#1} #2}{Variable}% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% @deftypevr {Global Flag} int enable + +\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} + +\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% +\begingroup\defname {\code{#2} #3}{#1} +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% This definition is run if you use @defvarx +% anywhere other than immediately after a @defvar or @defvarx. + +\def\defvrx #1 {\errmessage{@defvrx in invalid context}} +\def\defvarx #1 {\errmessage{@defvarx in invalid context}} +\def\defoptx #1 {\errmessage{@defoptx in invalid context}} +\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} +\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} + +% Now define @deftp +% Args are printed in bold, a slight difference from @defvar. + +\def\deftpargs #1{\bf \defvarargs{#1}} + +% @deftp Class window height width ... + +\def\deftp{\defvrparsebody\Edeftp\deftpx\deftpheader} + +\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% +\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} + +% This definition is run if you use @deftpx, etc +% anywhere other than immediately after a @deftp, etc. + +\def\deftpx #1 {\errmessage{@deftpx in invalid context}} + +\message{cross reference,} +% Define cross-reference macros +\newwrite \auxfile + +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% \setref{foo} defines a cross-reference point named foo. + +\def\setref#1{% +%\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ysectionnumberandtype}} + +\def\unnumbsetref#1{% +%\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ynothing}} + +\def\appendixsetref#1{% +%\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Yappendixletterandtype}} + +% \xref, \pxref, and \ref generate cross-references to specified points. +% For \xrefX, #1 is the node name, #2 the name of the Info +% cross-reference, #3 the printed node name, #4 the name of the Info +% file, #5 the name of the printed manual. All but the node name can be +% omitted. +% +\def\pxref#1{see \xrefX[#1,,,,,,,]} +\def\xref#1{See \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% +\def\printedmanual{\ignorespaces #5}% +\def\printednodename{\ignorespaces #3}% +% +\setbox1=\hbox{\printedmanual}% +\setbox0=\hbox{\printednodename}% +\ifdim \wd0=0pt% +\def\printednodename{\ignorespaces #1}% +%%% Uncommment the following line to make the actual chapter or section title +%%% appear inside the square brackets. +%\def\printednodename{#1-title}% +\fi% +% +% +% If we use \unhbox0 and \unhbox1 to print the node names, TeX does +% not insert empty discretionaries after hyphens, which means that it +% will not find a line break at a hyphen in a node names. Since some +% manuals are best written with fairly long node names, containing +% hyphens, this is a loss. Therefore, we simply give the text of +% the node name again, so it is as if TeX is seeing it for the first +% time. +\ifdim \wd1>0pt +section ``\printednodename'' in \cite{\printedmanual}% +\else% +\turnoffactive% +\refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% +\fi +\endgroup} + +% \dosetq is the interface for calls from other macros + +% Use \turnoffactive so that punctuation chars such as underscore +% work in node names. +\def\dosetq #1#2{{\let\folio=0 \turnoffactive% +\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% +\next}} + +% \internalsetq {foo}{page} expands into +% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} +% When the aux file is read, ' is the escape character + +\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} + +% Things to be expanded by \internalsetq + +\def\Ypagenumber{\folio} + +\def\Ytitle{\thischapter} + +\def\Ynothing{} + +\def\Ysectionnumberandtype{% +\ifnum\secno=0 Chapter\xreftie\the\chapno % +\else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % +\else \ifnum \subsubsecno=0 % +Section\xreftie\the\chapno.\the\secno.\the\subsecno % +\else % +Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\def\Yappendixletterandtype{% +\ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% +\else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % +\else \ifnum \subsubsecno=0 % +Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % +\else % +Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\gdef\xreftie{'tie} + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Non-3.0. +\else + \def\linenumber{\the\inputlineno:\space} +\fi + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. + +\def\refx#1#2{% + \expandafter\ifx\csname X#1\endcsname\relax + % If not defined, say something at least. + $\langle$un\-de\-fined$\rangle$% + \ifhavexrefs + \message{\linenumber Undefined cross reference `#1'.}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \else + % It's defined, so just use it. + \csname X#1\endcsname + \fi + #2% Output the suffix in any case. +} + +% Read the last existing aux file, if any. No error if none exists. + +% This is the macro invoked by entries in the aux file. +\def\xrdef #1#2{ +{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} + +\def\readauxfile{% +\begingroup +\catcode `\^^@=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\^^C=\other +\catcode `\^^D=\other +\catcode `\^^E=\other +\catcode `\^^F=\other +\catcode `\^^G=\other +\catcode `\^^H=\other +\catcode `\ =\other +\catcode `\^^L=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode 26=\other +\catcode `\^^[=\other +\catcode `\^^\=\other +\catcode `\^^]=\other +\catcode `\^^^=\other +\catcode `\^^_=\other +\catcode `\@=\other +\catcode `\^=\other +\catcode `\~=\other +\catcode `\[=\other +\catcode `\]=\other +\catcode`\"=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode `\$=\other +\catcode `\#=\other +\catcode `\&=\other +% the aux file uses ' as the escape. +% Turn off \ as an escape so we do not lose on +% entries which were dumped with control sequences in their names. +% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ +% Reference to such entries still does not work the way one would wish, +% but at least they do not bomb out when the aux file is read in. +\catcode `\{=1 \catcode `\}=2 +\catcode `\%=\other +\catcode `\'=0 +\catcode `\\=\other +\openin 1 \jobname.aux +\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue +\fi +% Open the new aux file. Tex will close it automatically at exit. +\openout \auxfile=\jobname.aux +\endgroup} + + +% Footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for info output only.. +\let\footnotestyle=\comment + +\let\ptexfootnote=\footnote + +{\catcode `\@=11 +\long\gdef\footnote #1{\global\advance \footnoteno by \@ne +\unskip +\edef\thisfootno{$^{\the\footnoteno}$}% +\let\@sf\empty +\ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi +\thisfootno\@sf \footnotezzz{#1}} +% \parsearg\footnotezzz} + +\long\gdef\footnotezzz #1{\insert\footins{ +\interlinepenalty\interfootnotelinepenalty +\splittopskip\ht\strutbox % top baseline for broken footnotes +\splitmaxdepth\dp\strutbox \floatingpenalty\@MM +\leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip +\footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}} + +}%end \catcode `\@=11 + +% End of control word definitions. + +\message{and turning on texinfo input format.} + +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% Set some numeric style parameters, for 8.5 x 11 format. + +%\hsize = 6.5in +\newdimen\defaultparindent \defaultparindent = 15pt +\parindent = \defaultparindent +\parskip 18pt plus 1pt +\baselineskip 15pt +\advance\topskip by 1.2cm + +% Prevent underfull vbox error messages. +\vbadness=10000 + +% Following George Bush, just get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. This makes it come to about 9pt for the 8.5x11 format. +% +\ifx\emergencystretch\thisisundefined \else + \emergencystretch = \hsize + \divide\emergencystretch by 45 +\fi + +% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) +\def\smallbook{ +\global\lispnarrowing = 0.3in +\global\baselineskip 12pt +\advance\topskip by -1cm +\global\parskip 3pt plus 1pt +\global\hsize = 5in +\global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in +\global\vsize=7.5in +\global\tolerance=700 +\global\hfuzz=1pt +\global\contentsrightmargin=0pt + +\global\pagewidth=\hsize +\global\pageheight=\vsize + +\global\let\smalllisp=\smalllispx +\global\let\smallexample=\smalllispx +\global\def\Esmallexample{\Esmalllisp} +} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{ +\global\tolerance=700 +\global\hfuzz=1pt +\global\baselineskip=12pt +\global\parskip 15pt plus 1pt + +\global\vsize= 53\baselineskip +\advance\vsize by \topskip +%\global\hsize= 5.85in % A4 wide 10pt +\global\hsize= 6.5in +\global\outerhsize=\hsize +\global\advance\outerhsize by 0.5in +\global\outervsize=\vsize +\global\advance\outervsize by 0.6in +\global\doublecolumnhsize=\hsize +\global\divide\doublecolumnhsize by 2 +\global\advance\doublecolumnhsize by -0.1in +\global\doublecolumnvsize=\vsize +\global\multiply\doublecolumnvsize by 2 +\global\advance\doublecolumnvsize by 0.1in + +\global\pagewidth=\hsize +\global\pageheight=\vsize +} + +%% For a final copy, take out the rectangles +%% that mark overfull boxes (in case you have decided +%% that the text looks ok even though it passes the margin). +\def\finalout{\overfullrule=0pt} + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} + +% This macro is used to make a character print one way in ttfont +% where it can probably just be output, and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt \char '042}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt \char '176}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +% Subroutine for the previous macro. +\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} + +% \lvvmode is equivalent in function to \leavevmode. +% Using \leavevmode runs into trouble when written out to +% an index file due to the expansion of \leavevmode into ``\unhbox +% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our +% magic tricks with @. +\def\lvvmode{\vbox to 0pt{}} + +\catcode`\|=\active +\def|{{\tt \char '174}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +%\catcode 27=\active +%\def^^[{$\diamondsuit$} + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +\def\turnoffactive{\let"=\normaldoublequote +\let~=\normaltilde +\let^=\normalcaret +\let_=\normalunderscore +\let|=\normalverticalbar +\let<=\normalless +\let>=\normalgreater +\let+=\normalplus} + +% Set up an active definition for =, but don't enable it most of the time. +{\catcode`\==\active +\global\def={{\tt \char 61}}} + +\catcode`\@=0 + +% \rawbackslashxx output one backslash character in current font +\global\chardef\rawbackslashxx=`\\ +%{\catcode`\\=\other +%@gdef@rawbackslashxx{\}} + +% \rawbackslash redefines \ as input to do \rawbackslashxx. +{\catcode`\\=\active +@gdef@rawbackslash{@let\=@rawbackslashxx }} + +% \normalbackslash outputs one backslash in fixed width font. +\def\normalbackslash{{\tt\rawbackslashxx}} + +% Say @foo, not \foo, in error messages. +\escapechar=`\@ + +% \catcode 17=0 % Define control-q +\catcode`\\=\active + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\{ in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% +@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} + +%% These look ok in all fonts, so just make them not special. The @rm below +%% makes sure that the current font starts out as the newly loaded cmr10 +@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other + +@textfonts +@rm + +@c Local variables: +@c page-delimiter: "^\\\\message" +@c End: diff --git a/tools/gzip-1.2.4/trees.c b/tools/gzip-1.2.4/trees.c new file mode 100644 index 00000000..db3b4b70 --- /dev/null +++ b/tools/gzip-1.2.4/trees.c @@ -0,0 +1,1075 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* + * PURPOSE + * + * Encode various sets of source values using variable-length + * binary code trees. + * + * DISCUSSION + * + * The PKZIP "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in the ZIP file in a compressed form + * which is itself a Huffman encoding of the lengths of + * all the code strings (in ascending order by source values). + * The actual code strings are reconstructed from the lengths in + * the UNZIP process, as described in the "application note" + * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program. + * + * REFERENCES + * + * Lynch, Thomas J. + * Data Compression: Techniques and Applications, pp. 53-55. + * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7. + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + * + * INTERFACE + * + * void ct_init (ush *attr, int *methodp) + * Allocate the match buffer, initialize the various tables and save + * the location of the internal file attribute (ascii/binary) and + * method (DEFLATE/STORE) + * + * void ct_tally (int dist, int lc); + * Save the match info and tally the frequency counts. + * + * long flush_block (char *buf, ulg stored_len, int eof) + * Determine the best encoding for the current block: dynamic trees, + * static trees or store, and output the encoded block to the zip + * file. Returns the total compressed length for the file so far. + * + */ + +#include + +#include "tailor.h" +#include "gzip.h" + +#ifdef RCSID +static char rcsid[] = "$Id: trees.c,v 0.12 1993/06/10 13:27:54 jloup Exp $"; +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + + +local int near extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local int near extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local int near extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#ifndef LIT_BUFSIZE +# ifdef SMALL_MEM +# define LIT_BUFSIZE 0x2000 +# else +# ifdef MEDIUM_MEM +# define LIT_BUFSIZE 0x4000 +# else +# define LIT_BUFSIZE 0x8000 +# endif +# endif +#endif +#ifndef DIST_BUFSIZE +# define DIST_BUFSIZE LIT_BUFSIZE +#endif +/* Sizes of match buffers for literals/lengths and distances. There are + * 4 reasons for limiting LIT_BUFSIZE to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input data is + * still in the window so we can still emit a stored block even when input + * comes from standard input. (This can also be done for all blocks if + * LIT_BUFSIZE is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting trees + * more frequently. + * - I can't count above 4 + * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save + * memory at the expense of compression). Some optimizations would be possible + * if we rely on DIST_BUFSIZE == LIT_BUFSIZE. + */ +#if LIT_BUFSIZE > INBUFSIZ + error cannot overlay l_buf and inbuf +#endif + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +/* =========================================================================== + * Local data + */ + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +local ct_data near dyn_ltree[HEAP_SIZE]; /* literal and length tree */ +local ct_data near dyn_dtree[2*D_CODES+1]; /* distance tree */ + +local ct_data near static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see ct_init + * below). + */ + +local ct_data near static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +local ct_data near bl_tree[2*BL_CODES+1]; +/* Huffman tree for the bit lengths */ + +typedef struct tree_desc { + ct_data near *dyn_tree; /* the dynamic tree */ + ct_data near *static_tree; /* corresponding static tree or NULL */ + int near *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ + int max_code; /* largest code with non zero frequency */ +} tree_desc; + +local tree_desc near l_desc = +{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0}; + +local tree_desc near d_desc = +{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0}; + +local tree_desc near bl_desc = +{bl_tree, (ct_data near *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0}; + + +local ush near bl_count[MAX_BITS+1]; +/* number of codes at each bit length for an optimal tree */ + +local uch near bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +local int near heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ +local int heap_len; /* number of elements in the heap */ +local int heap_max; /* element of largest frequency */ +/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + +local uch near depth[2*L_CODES+1]; +/* Depth of each subtree used as tie breaker for trees of equal frequency */ + +local uch length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local uch dist_code[512]; +/* distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +local int near base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int near base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#define l_buf inbuf +/* DECLARE(uch, l_buf, LIT_BUFSIZE); buffer for literals or lengths */ + +/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */ + +local uch near flag_buf[(LIT_BUFSIZE/8)]; +/* flag_buf is a bit array distinguishing literals from lengths in + * l_buf, thus indicating the presence or absence of a distance. + */ + +local unsigned last_lit; /* running index in l_buf */ +local unsigned last_dist; /* running index in d_buf */ +local unsigned last_flags; /* running index in flag_buf */ +local uch flags; /* current flags not yet saved in flag_buf */ +local uch flag_bit; /* current bit used in flags */ +/* bits are filled in flags starting at bit 0 (least significant). + * Note: these flags are overkill in the current code since we don't + * take advantage of DIST_BUFSIZE == LIT_BUFSIZE. + */ + +local ulg opt_len; /* bit length of current block with optimal trees */ +local ulg static_len; /* bit length of current block with static trees */ + +local ulg compressed_len; /* total bit length of compressed file */ + +local ulg input_len; /* total byte length of input file */ +/* input_len is for debugging only since we can get it by other means. */ + +ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */ +int *file_method; /* pointer to DEFLATE or STORE */ + +#ifdef DEBUG +extern ulg bits_sent; /* bit length of the compressed data */ +extern long isize; /* byte length of input file */ +#endif + +extern long block_start; /* window offset of current block */ +extern unsigned near strstart; /* window offset of current string */ + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void init_block OF((void)); +local void pqdownheap OF((ct_data near *tree, int k)); +local void gen_bitlen OF((tree_desc near *desc)); +local void gen_codes OF((ct_data near *tree, int max_code)); +local void build_tree OF((tree_desc near *desc)); +local void scan_tree OF((ct_data near *tree, int max_code)); +local void send_tree OF((ct_data near *tree, int max_code)); +local int build_bl_tree OF((void)); +local void send_all_trees OF((int lcodes, int dcodes, int blcodes)); +local void compress_block OF((ct_data near *ltree, ct_data near *dtree)); +local void set_file_type OF((void)); + + +#ifndef DEBUG +# define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(c, tree) \ + { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(tree[c].Code, tree[c].Len); } +#endif + +#define d_code(dist) \ + ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. dist_code[256] and dist_code[257] are never + * used. + */ + +#define MAX(a,b) (a >= b ? a : b) +/* the arguments must not have side effects */ + +/* =========================================================================== + * Allocate the match buffer, initialize the various tables and save the + * location of the internal file attribute (ascii/binary) and method + * (DEFLATE/STORE). + */ +void ct_init(attr, methodp) + ush *attr; /* pointer to internal file attribute */ + int *methodp; /* pointer to compression method */ +{ + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + + file_type = attr; + file_method = methodp; + compressed_len = input_len = 0L; + + if (static_dtree[0].Len != 0) return; /* ct_init already called */ + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "ct_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data near *)static_ltree, L_CODES+1); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse(n, 5); + } + + /* Initialize the first block of the first file: */ + init_block(); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block() +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0; + + dyn_ltree[END_BLOCK].Freq = 1; + opt_len = static_len = 0L; + last_lit = last_dist = last_flags = 0; + flags = 0; flag_bit = 1; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(tree, top) \ +{\ + top = heap[SMALLEST]; \ + heap[SMALLEST] = heap[heap_len--]; \ + pqdownheap(tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(tree, k) + ct_data near *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = heap[k]; + int j = k << 1; /* left son of k */ + while (j <= heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++; + + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, heap[j])) break; + + /* Exchange v with the smallest son */ + heap[k] = heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(desc) + tree_desc near *desc; /* the tree descriptor */ +{ + ct_data near *tree = desc->dyn_tree; + int near *extra = desc->extra_bits; + int base = desc->extra_base; + int max_code = desc->max_code; + int max_length = desc->max_length; + ct_data near *stree = desc->static_tree; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[heap[heap_max]].Len = 0; /* root of the heap */ + + for (h = heap_max+1; h < HEAP_SIZE; h++) { + n = heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + opt_len += (ulg)f * (bits + xbits); + if (stree) static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (bl_count[bits] == 0) bits--; + bl_count[bits]--; /* move one leaf down the tree */ + bl_count[bits+1] += 2; /* move one overflow item as its brother */ + bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = bl_count[bits]; + while (n != 0) { + m = heap[--h]; + if (m > max_code) continue; + if (tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + opt_len += ((long)bits-(long)tree[m].Len)*(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code) + ct_data near *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + ct_data near *stree = desc->static_tree; + int elems = desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node = elems; /* next internal node of the tree */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + heap_len = 0, heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + heap[++heap_len] = max_code = n; + depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (heap_len < 2) { + int new = heap[++heap_len] = (max_code < 2 ? ++max_code : 0); + tree[new].Freq = 1; + depth[new] = 0; + opt_len--; if (stree) static_len -= stree[new].Len; + /* new is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + do { + pqremove(tree, n); /* n = node of least frequency */ + m = heap[SMALLEST]; /* m = node of next least frequency */ + + heap[--heap_max] = n; /* keep the nodes sorted by frequency */ + heap[--heap_max] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + depth[node] = (uch) (MAX(depth[n], depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + heap[SMALLEST] = node++; + pqdownheap(tree, SMALLEST); + + } while (heap_len >= 2); + + heap[--heap_max] = heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen((tree_desc near *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data near *)tree, max_code); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. Updates opt_len to take into account the repeat + * counts. (The contribution of the bit length codes will be added later + * during the construction of bl_tree.) + */ +local void scan_tree (tree, max_code) + ct_data near *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) bl_tree[curlen].Freq++; + bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + bl_tree[REPZ_3_10].Freq++; + } else { + bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (tree, max_code) + ct_data near *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(curlen, bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(curlen, bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(REP_3_6, bl_tree); send_bits(count-3, 2); + + } else if (count <= 10) { + send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3); + + } else { + send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree() +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree((ct_data near *)dyn_ltree, l_desc.max_code); + scan_tree((ct_data near *)dyn_dtree, d_desc.max_code); + + /* Build the bit length tree: */ + build_tree((tree_desc near *)(&bl_desc)); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(lcodes, dcodes, blcodes) + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(dcodes-1, 5); + send_bits(blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", bits_sent)); + + send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", bits_sent)); + + send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", bits_sent)); +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. This function + * returns the total compressed length for the file so far. + */ +ulg flush_block(buf, stored_len, eof) + char *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex; /* index of last bit length code of non zero freq */ + + flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */ + + /* Check if the file is ascii or binary */ + if (*file_type == (ush)UNKNOWN) set_file_type(); + + /* Construct the literal and distance trees */ + build_tree((tree_desc near *)(&l_desc)); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len)); + + build_tree((tree_desc near *)(&d_desc)); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(); + + /* Determine the best encoding. Compute first the block length in bytes */ + opt_lenb = (opt_len+3+7)>>3; + static_lenb = (static_len+3+7)>>3; + input_len += stored_len; /* for debugging only */ + + Trace((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", + opt_lenb, opt_len, static_lenb, static_len, stored_len, + last_lit, last_dist)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + /* If compression failed and this is the first and last block, + * and if the zip file can be seeked (to rewrite the local header), + * the whole file is transformed into a stored file: + */ +#ifdef FORCE_METHOD + if (level == 1 && eof && compressed_len == 0L) { /* force stored file */ +#else + if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) { +#endif + /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ + if (buf == (char*)0) error ("block vanished"); + + copy_block(buf, (unsigned)stored_len, 0); /* without header */ + compressed_len = stored_len << 3; + *file_method = STORED; + +#ifdef FORCE_METHOD + } else if (level == 2 && buf != (char*)0) { /* force stored block */ +#else + } else if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */ + compressed_len = (compressed_len + 3 + 7) & ~7L; + compressed_len += (stored_len + 4) << 3; + + copy_block(buf, (unsigned)stored_len, 1); /* with header */ + +#ifdef FORCE_METHOD + } else if (level == 3) { /* force static trees */ +#else + } else if (static_lenb == opt_lenb) { +#endif + send_bits((STATIC_TREES<<1)+eof, 3); + compress_block((ct_data near *)static_ltree, (ct_data near *)static_dtree); + compressed_len += 3 + static_len; + } else { + send_bits((DYN_TREES<<1)+eof, 3); + send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1); + compress_block((ct_data near *)dyn_ltree, (ct_data near *)dyn_dtree); + compressed_len += 3 + opt_len; + } + Assert (compressed_len == bits_sent, "bad compressed size"); + init_block(); + + if (eof) { + Assert (input_len == isize, "bad input size"); + bi_windup(); + compressed_len += 7; /* align on byte boundary */ + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3, + compressed_len-7*eof)); + + return compressed_len >> 3; +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int ct_tally (dist, lc) + int dist; /* distance of matched string */ + int lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + l_buf[last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + dyn_ltree[lc].Freq++; + } else { + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match"); + + dyn_ltree[length_code[lc]+LITERALS+1].Freq++; + dyn_dtree[d_code(dist)].Freq++; + + d_buf[last_dist++] = (ush)dist; + flags |= flag_bit; + } + flag_bit <<= 1; + + /* Output the flags if they fill a byte: */ + if ((last_lit & 7) == 0) { + flag_buf[last_flags++] = flags; + flags = 0, flag_bit = 1; + } + /* Try to guess if it is profitable to stop the current block here */ + if (level > 2 && (last_lit & 0xfff) == 0) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)last_lit*8L; + ulg in_length = (ulg)strstart-block_start; + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)dyn_dtree[dcode].Freq*(5L+extra_dbits[dcode]); + } + out_length >>= 3; + Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", + last_lit, last_dist, in_length, out_length, + 100L - out_length*100L/in_length)); + if (last_dist < last_lit/2 && out_length < in_length/2) return 1; + } + return (last_lit == LIT_BUFSIZE-1 || last_dist == DIST_BUFSIZE); + /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(ltree, dtree) + ct_data near *ltree; /* literal tree */ + ct_data near *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned dx = 0; /* running index in d_buf */ + unsigned fx = 0; /* running index in flag_buf */ + uch flag = 0; /* current flags */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (last_lit != 0) do { + if ((lx & 7) == 0) flag = flag_buf[fx++]; + lc = l_buf[lx++]; + if ((flag & 1) == 0) { + send_code(lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = length_code[lc]; + send_code(code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(lc, extra); /* send the extra length bits */ + } + dist = d_buf[dx++]; + /* Here, dist is the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + flag >>= 1; + } while (lx < last_lit); + + send_code(END_BLOCK, ltree); +} + +/* =========================================================================== + * Set the file type to ASCII or BINARY, using a crude approximation: + * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. + * IN assertion: the fields freq of dyn_ltree are set and the total of all + * frequencies does not exceed 64K (to fit in an int on 16 bit machines). + */ +local void set_file_type() +{ + int n = 0; + unsigned ascii_freq = 0; + unsigned bin_freq = 0; + while (n < 7) bin_freq += dyn_ltree[n++].Freq; + while (n < 128) ascii_freq += dyn_ltree[n++].Freq; + while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq; + *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; + if (*file_type == BINARY && translate_eol) { + warn("-l used on binary file", ""); + } +} diff --git a/tools/gzip-1.2.4/unlzh.c b/tools/gzip-1.2.4/unlzh.c new file mode 100644 index 00000000..e318e5ed --- /dev/null +++ b/tools/gzip-1.2.4/unlzh.c @@ -0,0 +1,401 @@ +/* unlzh.c -- decompress files in SCO compress -H (LZH) format. + * The code in this file is directly derived from the public domain 'ar002' + * written by Haruhiko Okumura. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: unlzh.c,v 1.2 1993/06/24 10:59:01 jloup Exp $"; +#endif + +#include + +#include "tailor.h" +#include "gzip.h" +#include "lzw.h" /* just for consistency checking */ + +/* decode.c */ + +local unsigned decode OF((unsigned count, uch buffer[])); +local void decode_start OF((void)); + +/* huf.c */ +local void huf_decode_start OF((void)); +local unsigned decode_c OF((void)); +local unsigned decode_p OF((void)); +local void read_pt_len OF((int nn, int nbit, int i_special)); +local void read_c_len OF((void)); + +/* io.c */ +local void fillbuf OF((int n)); +local unsigned getbits OF((int n)); +local void init_getbits OF((void)); + +/* maketbl.c */ + +local void make_table OF((int nchar, uch bitlen[], + int tablebits, ush table[])); + + +#define DICBIT 13 /* 12(-lh4-) or 13(-lh5-) */ +#define DICSIZ ((unsigned) 1 << DICBIT) + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +#ifndef UCHAR_MAX +# define UCHAR_MAX 255 +#endif + +#define BITBUFSIZ (CHAR_BIT * 2 * sizeof(char)) +/* Do not use CHAR_BIT * sizeof(bitbuf), does not work on machines + * for which short is not on 16 bits (Cray). + */ + +/* encode.c and decode.c */ + +#define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */ +#define THRESHOLD 3 /* choose optimal value */ + +/* huf.c */ + +#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD) + /* alphabet = {0, 1, 2, ..., NC - 1} */ +#define CBIT 9 /* $\lfloor \log_2 NC \rfloor + 1$ */ +#define CODE_BIT 16 /* codeword length */ + +#define NP (DICBIT + 1) +#define NT (CODE_BIT + 3) +#define PBIT 4 /* smallest integer such that (1U << PBIT) > NP */ +#define TBIT 5 /* smallest integer such that (1U << TBIT) > NT */ +#if NT > NP +# define NPT NT +#else +# define NPT NP +#endif + +/* local ush left[2 * NC - 1]; */ +/* local ush right[2 * NC - 1]; */ +#define left prev +#define right head +#if NC > (1<<(BITS-2)) + error cannot overlay left+right and prev +#endif + +/* local uch c_len[NC]; */ +#define c_len outbuf +#if NC > OUTBUFSIZ + error cannot overlay c_len and outbuf +#endif + +local uch pt_len[NPT]; +local unsigned blocksize; +local ush pt_table[256]; + +/* local ush c_table[4096]; */ +#define c_table d_buf +#if (DIST_BUFSIZE-1) < 4095 + error cannot overlay c_table and d_buf +#endif + +/*********************************************************** + io.c -- input/output +***********************************************************/ + +local ush bitbuf; +local unsigned subbitbuf; +local int bitcount; + +local void fillbuf(n) /* Shift bitbuf n bits left, read n bits */ + int n; +{ + bitbuf <<= n; + while (n > bitcount) { + bitbuf |= subbitbuf << (n -= bitcount); + subbitbuf = (unsigned)try_byte(); + if ((int)subbitbuf == EOF) subbitbuf = 0; + bitcount = CHAR_BIT; + } + bitbuf |= subbitbuf >> (bitcount -= n); +} + +local unsigned getbits(n) + int n; +{ + unsigned x; + + x = bitbuf >> (BITBUFSIZ - n); fillbuf(n); + return x; +} + +local void init_getbits() +{ + bitbuf = 0; subbitbuf = 0; bitcount = 0; + fillbuf(BITBUFSIZ); +} + +/*********************************************************** + maketbl.c -- make table for decoding +***********************************************************/ + +local void make_table(nchar, bitlen, tablebits, table) + int nchar; + uch bitlen[]; + int tablebits; + ush table[]; +{ + ush count[17], weight[17], start[18], *p; + unsigned i, k, len, ch, jutbits, avail, nextcode, mask; + + for (i = 1; i <= 16; i++) count[i] = 0; + for (i = 0; i < (unsigned)nchar; i++) count[bitlen[i]]++; + + start[1] = 0; + for (i = 1; i <= 16; i++) + start[i + 1] = start[i] + (count[i] << (16 - i)); + if ((start[17] & 0xffff) != 0) + error("Bad table\n"); + + jutbits = 16 - tablebits; + for (i = 1; i <= (unsigned)tablebits; i++) { + start[i] >>= jutbits; + weight[i] = (unsigned) 1 << (tablebits - i); + } + while (i <= 16) { + weight[i] = (unsigned) 1 << (16 - i); + i++; + } + + i = start[tablebits + 1] >> jutbits; + if (i != 0) { + k = 1 << tablebits; + while (i != k) table[i++] = 0; + } + + avail = nchar; + mask = (unsigned) 1 << (15 - tablebits); + for (ch = 0; ch < (unsigned)nchar; ch++) { + if ((len = bitlen[ch]) == 0) continue; + nextcode = start[len] + weight[len]; + if (len <= (unsigned)tablebits) { + for (i = start[len]; i < nextcode; i++) table[i] = ch; + } else { + k = start[len]; + p = &table[k >> jutbits]; + i = len - tablebits; + while (i != 0) { + if (*p == 0) { + right[avail] = left[avail] = 0; + *p = avail++; + } + if (k & mask) p = &right[*p]; + else p = &left[*p]; + k <<= 1; i--; + } + *p = ch; + } + start[len] = nextcode; + } +} + +/*********************************************************** + huf.c -- static Huffman +***********************************************************/ + +local void read_pt_len(nn, nbit, i_special) + int nn; + int nbit; + int i_special; +{ + int i, c, n; + unsigned mask; + + n = getbits(nbit); + if (n == 0) { + c = getbits(nbit); + for (i = 0; i < nn; i++) pt_len[i] = 0; + for (i = 0; i < 256; i++) pt_table[i] = c; + } else { + i = 0; + while (i < n) { + c = bitbuf >> (BITBUFSIZ - 3); + if (c == 7) { + mask = (unsigned) 1 << (BITBUFSIZ - 1 - 3); + while (mask & bitbuf) { mask >>= 1; c++; } + } + fillbuf((c < 7) ? 3 : c - 3); + pt_len[i++] = c; + if (i == i_special) { + c = getbits(2); + while (--c >= 0) pt_len[i++] = 0; + } + } + while (i < nn) pt_len[i++] = 0; + make_table(nn, pt_len, 8, pt_table); + } +} + +local void read_c_len() +{ + int i, c, n; + unsigned mask; + + n = getbits(CBIT); + if (n == 0) { + c = getbits(CBIT); + for (i = 0; i < NC; i++) c_len[i] = 0; + for (i = 0; i < 4096; i++) c_table[i] = c; + } else { + i = 0; + while (i < n) { + c = pt_table[bitbuf >> (BITBUFSIZ - 8)]; + if (c >= NT) { + mask = (unsigned) 1 << (BITBUFSIZ - 1 - 8); + do { + if (bitbuf & mask) c = right[c]; + else c = left [c]; + mask >>= 1; + } while (c >= NT); + } + fillbuf((int) pt_len[c]); + if (c <= 2) { + if (c == 0) c = 1; + else if (c == 1) c = getbits(4) + 3; + else c = getbits(CBIT) + 20; + while (--c >= 0) c_len[i++] = 0; + } else c_len[i++] = c - 2; + } + while (i < NC) c_len[i++] = 0; + make_table(NC, c_len, 12, c_table); + } +} + +local unsigned decode_c() +{ + unsigned j, mask; + + if (blocksize == 0) { + blocksize = getbits(16); + if (blocksize == 0) { + return NC; /* end of file */ + } + read_pt_len(NT, TBIT, 3); + read_c_len(); + read_pt_len(NP, PBIT, -1); + } + blocksize--; + j = c_table[bitbuf >> (BITBUFSIZ - 12)]; + if (j >= NC) { + mask = (unsigned) 1 << (BITBUFSIZ - 1 - 12); + do { + if (bitbuf & mask) j = right[j]; + else j = left [j]; + mask >>= 1; + } while (j >= NC); + } + fillbuf((int) c_len[j]); + return j; +} + +local unsigned decode_p() +{ + unsigned j, mask; + + j = pt_table[bitbuf >> (BITBUFSIZ - 8)]; + if (j >= NP) { + mask = (unsigned) 1 << (BITBUFSIZ - 1 - 8); + do { + if (bitbuf & mask) j = right[j]; + else j = left [j]; + mask >>= 1; + } while (j >= NP); + } + fillbuf((int) pt_len[j]); + if (j != 0) j = ((unsigned) 1 << (j - 1)) + getbits((int) (j - 1)); + return j; +} + +local void huf_decode_start() +{ + init_getbits(); blocksize = 0; +} + +/*********************************************************** + decode.c +***********************************************************/ + +local int j; /* remaining bytes to copy */ +local int done; /* set at end of input */ + +local void decode_start() +{ + huf_decode_start(); + j = 0; + done = 0; +} + +/* Decode the input and return the number of decoded bytes put in buffer + */ +local unsigned decode(count, buffer) + unsigned count; + uch buffer[]; + /* The calling function must keep the number of + bytes to be processed. This function decodes + either 'count' bytes or 'DICSIZ' bytes, whichever + is smaller, into the array 'buffer[]' of size + 'DICSIZ' or more. + Call decode_start() once for each new file + before calling this function. + */ +{ + local unsigned i; + unsigned r, c; + + r = 0; + while (--j >= 0) { + buffer[r] = buffer[i]; + i = (i + 1) & (DICSIZ - 1); + if (++r == count) return r; + } + for ( ; ; ) { + c = decode_c(); + if (c == NC) { + done = 1; + return r; + } + if (c <= UCHAR_MAX) { + buffer[r] = c; + if (++r == count) return r; + } else { + j = c - (UCHAR_MAX + 1 - THRESHOLD); + i = (r - decode_p() - 1) & (DICSIZ - 1); + while (--j >= 0) { + buffer[r] = buffer[i]; + i = (i + 1) & (DICSIZ - 1); + if (++r == count) return r; + } + } + } +} + + +/* =========================================================================== + * Unlzh in to out. Return OK or ERROR. + */ +int unlzh(in, out) + int in; + int out; +{ + unsigned n; + ifd = in; + ofd = out; + + decode_start(); + while (!done) { + n = decode((unsigned) DICSIZ, window); + if (!test && n > 0) { + write_buf(out, (char*)window, n); + } + } + return OK; +} diff --git a/tools/gzip-1.2.4/unlzw.c b/tools/gzip-1.2.4/unlzw.c new file mode 100644 index 00000000..15d2a313 --- /dev/null +++ b/tools/gzip-1.2.4/unlzw.c @@ -0,0 +1,377 @@ +/* unlzw.c -- decompress files in LZW format. + * The code in this file is directly derived from the public domain 'compress' + * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, + * Ken Turkowski, Dave Mack and Peter Jannesen. + * + * This is a temporary version which will be rewritten in some future version + * to accommodate in-memory decompression. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: unlzw.c,v 0.15 1993/06/10 13:28:35 jloup Exp $"; +#endif + +#include + +#include "tailor.h" + +#ifdef HAVE_UNISTD_H +# include +#endif +#ifndef NO_FCNTL_H +# include +#endif + +#include "gzip.h" +#include "lzw.h" + +typedef unsigned char char_type; +typedef long code_int; +typedef unsigned long count_int; +typedef unsigned short count_short; +typedef unsigned long cmp_code_int; + +#define MAXCODE(n) (1L << (n)) + +#ifndef REGISTERS +# define REGISTERS 2 +#endif +#define REG1 +#define REG2 +#define REG3 +#define REG4 +#define REG5 +#define REG6 +#define REG7 +#define REG8 +#define REG9 +#define REG10 +#define REG11 +#define REG12 +#define REG13 +#define REG14 +#define REG15 +#define REG16 +#if REGISTERS >= 1 +# undef REG1 +# define REG1 register +#endif +#if REGISTERS >= 2 +# undef REG2 +# define REG2 register +#endif +#if REGISTERS >= 3 +# undef REG3 +# define REG3 register +#endif +#if REGISTERS >= 4 +# undef REG4 +# define REG4 register +#endif +#if REGISTERS >= 5 +# undef REG5 +# define REG5 register +#endif +#if REGISTERS >= 6 +# undef REG6 +# define REG6 register +#endif +#if REGISTERS >= 7 +# undef REG7 +# define REG7 register +#endif +#if REGISTERS >= 8 +# undef REG8 +# define REG8 register +#endif +#if REGISTERS >= 9 +# undef REG9 +# define REG9 register +#endif +#if REGISTERS >= 10 +# undef REG10 +# define REG10 register +#endif +#if REGISTERS >= 11 +# undef REG11 +# define REG11 register +#endif +#if REGISTERS >= 12 +# undef REG12 +# define REG12 register +#endif +#if REGISTERS >= 13 +# undef REG13 +# define REG13 register +#endif +#if REGISTERS >= 14 +# undef REG14 +# define REG14 register +#endif +#if REGISTERS >= 15 +# undef REG15 +# define REG15 register +#endif +#if REGISTERS >= 16 +# undef REG16 +# define REG16 register +#endif + +#ifndef BYTEORDER +# define BYTEORDER 0000 +#endif + +#ifndef NOALLIGN +# define NOALLIGN 0 +#endif + + +union bytes { + long word; + struct { +#if BYTEORDER == 4321 + char_type b1; + char_type b2; + char_type b3; + char_type b4; +#else +#if BYTEORDER == 1234 + char_type b4; + char_type b3; + char_type b2; + char_type b1; +#else +# undef BYTEORDER + int dummy; +#endif +#endif + } bytes; +}; + +#if BYTEORDER == 4321 && NOALLIGN == 1 +# define input(b,o,c,n,m){ \ + (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \ + (o) += (n); \ + } +#else +# define input(b,o,c,n,m){ \ + REG1 char_type *p = &(b)[(o)>>3]; \ + (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \ + ((long)(p[2])<<16))>>((o)&0x7))&(m); \ + (o) += (n); \ + } +#endif + +#ifndef MAXSEG_64K + /* DECLARE(ush, tab_prefix, (1<>1] +# define clear_tab_prefixof() \ + memzero(tab_prefix0, 128), \ + memzero(tab_prefix1, 128); +#endif +#define de_stack ((char_type *)(&d_buf[DIST_BUFSIZE-1])) +#define tab_suffixof(i) tab_suffix[i] + +int block_mode = BLOCK_MODE; /* block compress mode -C compatible with 2.0 */ + +/* ============================================================================ + * Decompress in to out. This routine adapts to the codes in the + * file building the "string" table on-the-fly; requiring no table to + * be stored in the compressed file. + * IN assertions: the buffer inbuf contains already the beginning of + * the compressed data, from offsets iptr to insize-1 included. + * The magic header has already been checked and skipped. + * bytes_in and bytes_out have been initialized. + */ +int unlzw(in, out) + int in, out; /* input and output file descriptors */ +{ + REG2 char_type *stackp; + REG3 code_int code; + REG4 int finchar; + REG5 code_int oldcode; + REG6 code_int incode; + REG7 long inbits; + REG8 long posbits; + REG9 int outpos; +/* REG10 int insize; (global) */ + REG11 unsigned bitmask; + REG12 code_int free_ent; + REG13 code_int maxcode; + REG14 code_int maxmaxcode; + REG15 int n_bits; + REG16 int rsize; + +#ifdef MAXSEG_64K + tab_prefix[0] = tab_prefix0; + tab_prefix[1] = tab_prefix1; +#endif + maxbits = get_byte(); + block_mode = maxbits & BLOCK_MODE; + if ((maxbits & LZW_RESERVED) != 0) { + WARN((stderr, "\n%s: %s: warning, unknown flags 0x%x\n", + progname, ifname, maxbits & LZW_RESERVED)); + } + maxbits &= BIT_MASK; + maxmaxcode = MAXCODE(maxbits); + + if (maxbits > BITS) { + fprintf(stderr, + "\n%s: %s: compressed with %d bits, can only handle %d bits\n", + progname, ifname, maxbits, BITS); + exit_code = ERROR; + return ERROR; + } + rsize = insize; + maxcode = MAXCODE(n_bits = INIT_BITS)-1; + bitmask = (1<= 0 ; --code) { + tab_suffixof(code) = (char_type)code; + } + do { + REG1 int i; + int e; + int o; + + resetbuf: + e = insize-(o = (posbits>>3)); + + for (i = 0 ; i < e ; ++i) { + inbuf[i] = inbuf[i+o]; + } + insize = e; + posbits = 0; + + if (insize < INBUF_EXTRA) { + if ((rsize = read(in, (char*)inbuf+insize, INBUFSIZ)) == EOF) { + read_error(); + } + insize += rsize; + bytes_in += (ulg)rsize; + } + inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 : + ((long)insize<<3)-(n_bits-1)); + + while (inbits > posbits) { + if (free_ent > maxcode) { + posbits = ((posbits-1) + + ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3))); + ++n_bits; + if (n_bits == maxbits) { + maxcode = maxmaxcode; + } else { + maxcode = MAXCODE(n_bits)-1; + } + bitmask = (1<= 256) error("corrupt input."); + outbuf[outpos++] = (char_type)(finchar = (int)(oldcode=code)); + continue; + } + if (code == CLEAR && block_mode) { + clear_tab_prefixof(); + free_ent = FIRST - 1; + posbits = ((posbits-1) + + ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3))); + maxcode = MAXCODE(n_bits = INIT_BITS)-1; + bitmask = (1<= free_ent) { /* Special case for KwKwK string. */ + if (code > free_ent) { +#ifdef DEBUG + char_type *p; + + posbits -= n_bits; + p = &inbuf[posbits>>3]; + fprintf(stderr, + "code:%ld free_ent:%ld n_bits:%d insize:%u\n", + code, free_ent, n_bits, insize); + fprintf(stderr, + "posbits:%ld inbuf:%02X %02X %02X %02X %02X\n", + posbits, p[-1],p[0],p[1],p[2],p[3]); +#endif + if (!test && outpos > 0) { + write_buf(out, (char*)outbuf, outpos); + bytes_out += (ulg)outpos; + } + error(to_stdout ? "corrupt input." : + "corrupt input. Use zcat to recover some data."); + } + *--stackp = (char_type)finchar; + code = oldcode; + } + + while ((cmp_code_int)code >= (cmp_code_int)256) { + /* Generate output characters in reverse order */ + *--stackp = tab_suffixof(code); + code = tab_prefixof(code); + } + *--stackp = (char_type)(finchar = tab_suffixof(code)); + + /* And put them out in forward order */ + { + REG1 int i; + + if (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) { + do { + if (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos; + + if (i > 0) { + memcpy(outbuf+outpos, stackp, i); + outpos += i; + } + if (outpos >= OUTBUFSIZ) { + if (!test) { + write_buf(out, (char*)outbuf, outpos); + bytes_out += (ulg)outpos; + } + outpos = 0; + } + stackp+= i; + } while ((i = (de_stack-stackp)) > 0); + } else { + memcpy(outbuf+outpos, stackp, i); + outpos += i; + } + } + + if ((code = free_ent) < maxmaxcode) { /* Generate the new entry. */ + + tab_prefixof(code) = (unsigned short)oldcode; + tab_suffixof(code) = (char_type)finchar; + free_ent = code+1; + } + oldcode = incode; /* Remember previous code. */ + } + } while (rsize != 0); + + if (!test && outpos > 0) { + write_buf(out, (char*)outbuf, outpos); + bytes_out += (ulg)outpos; + } + return OK; +} diff --git a/tools/gzip-1.2.4/unpack.c b/tools/gzip-1.2.4/unpack.c new file mode 100644 index 00000000..a00fdaef --- /dev/null +++ b/tools/gzip-1.2.4/unpack.c @@ -0,0 +1,239 @@ +/* unpack.c -- decompress files in pack format. + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: unpack.c,v 1.4 1993/06/11 19:25:36 jloup Exp $"; +#endif + +#include "tailor.h" +#include "gzip.h" +#include "crypt.h" + +#define MIN(a,b) ((a) <= (b) ? (a) : (b)) +/* The arguments must not have side effects. */ + +#define MAX_BITLEN 25 +/* Maximum length of Huffman codes. (Minor modifications to the code + * would be needed to support 32 bits codes, but pack never generates + * more than 24 bits anyway.) + */ + +#define LITERALS 256 +/* Number of literals, excluding the End of Block (EOB) code */ + +#define MAX_PEEK 12 +/* Maximum number of 'peek' bits used to optimize traversal of the + * Huffman tree. + */ + +local ulg orig_len; /* original uncompressed length */ +local int max_len; /* maximum bit length of Huffman codes */ + +local uch literal[LITERALS]; +/* The literal bytes present in the Huffman tree. The EOB code is not + * represented. + */ + +local int lit_base[MAX_BITLEN+1]; +/* All literals of a given bit length are contiguous in literal[] and + * have contiguous codes. literal[code+lit_base[len]] is the literal + * for a code of len bits. + */ + +local int leaves [MAX_BITLEN+1]; /* Number of leaves for each bit length */ +local int parents[MAX_BITLEN+1]; /* Number of parents for each bit length */ + +local int peek_bits; /* Number of peek bits currently used */ + +/* local uch prefix_len[1 << MAX_PEEK]; */ +#define prefix_len outbuf +/* For each bit pattern b of peek_bits bits, prefix_len[b] is the length + * of the Huffman code starting with a prefix of b (upper bits), or 0 + * if all codes of prefix b have more than peek_bits bits. It is not + * necessary to have a huge table (large MAX_PEEK) because most of the + * codes encountered in the input stream are short codes (by construction). + * So for most codes a single lookup will be necessary. + */ +#if (1< OUTBUFSIZ + error cannot overlay prefix_len and outbuf +#endif + +local ulg bitbuf; +/* Bits are added on the low part of bitbuf and read from the high part. */ + +local int valid; /* number of valid bits in bitbuf */ +/* all bits above the last valid bit are always zero */ + +/* Set code to the next 'bits' input bits without skipping them. code + * must be the name of a simple variable and bits must not have side effects. + * IN assertions: bits <= 25 (so that we still have room for an extra byte + * when valid is only 24), and mask = (1<> (valid-(bits))) & (mask); \ +} + +/* Skip the given number of bits (after having peeked at them): */ +#define skip_bits(bits) (valid -= (bits)) + +#define clear_bitbuf() (valid = 0, bitbuf = 0) + +/* Local functions */ + +local void read_tree OF((void)); +local void build_tree OF((void)); + +/* =========================================================================== + * Read the Huffman tree. + */ +local void read_tree() +{ + int len; /* bit length */ + int base; /* base offset for a sequence of leaves */ + int n; + + /* Read the original input size, MSB first */ + orig_len = 0; + for (n = 1; n <= 4; n++) orig_len = (orig_len << 8) | (ulg)get_byte(); + + max_len = (int)get_byte(); /* maximum bit length of Huffman codes */ + if (max_len > MAX_BITLEN) { + error("invalid compressed data -- Huffman code > 32 bits"); + } + + /* Get the number of leaves at each bit length */ + n = 0; + for (len = 1; len <= max_len; len++) { + leaves[len] = (int)get_byte(); + n += leaves[len]; + } + if (n > LITERALS) { + error("too many leaves in Huffman tree"); + } + Trace((stderr, "orig_len %ld, max_len %d, leaves %d\n", + orig_len, max_len, n)); + /* There are at least 2 and at most 256 leaves of length max_len. + * (Pack arbitrarily rejects empty files and files consisting of + * a single byte even repeated.) To fit the last leaf count in a + * byte, it is offset by 2. However, the last literal is the EOB + * code, and is not transmitted explicitly in the tree, so we must + * adjust here by one only. + */ + leaves[max_len]++; + + /* Now read the leaves themselves */ + base = 0; + for (len = 1; len <= max_len; len++) { + /* Remember where the literals of this length start in literal[] : */ + lit_base[len] = base; + /* And read the literals: */ + for (n = leaves[len]; n > 0; n--) { + literal[base++] = (uch)get_byte(); + } + } + leaves[max_len]++; /* Now include the EOB code in the Huffman tree */ +} + +/* =========================================================================== + * Build the Huffman tree and the prefix table. + */ +local void build_tree() +{ + int nodes = 0; /* number of nodes (parents+leaves) at current bit length */ + int len; /* current bit length */ + uch *prefixp; /* pointer in prefix_len */ + + for (len = max_len; len >= 1; len--) { + /* The number of parent nodes at this level is half the total + * number of nodes at parent level: + */ + nodes >>= 1; + parents[len] = nodes; + /* Update lit_base by the appropriate bias to skip the parent nodes + * (which are not represented in the literal array): + */ + lit_base[len] -= nodes; + /* Restore nodes to be parents+leaves: */ + nodes += leaves[len]; + } + /* Construct the prefix table, from shortest leaves to longest ones. + * The shortest code is all ones, so we start at the end of the table. + */ + peek_bits = MIN(max_len, MAX_PEEK); + prefixp = &prefix_len[1< prefix_len) *--prefixp = 0; +} + +/* =========================================================================== + * Unpack in to out. This routine does not support the old pack format + * with magic header \037\037. + * + * IN assertions: the buffer inbuf contains already the beginning of + * the compressed data, from offsets inptr to insize-1 included. + * The magic header has already been checked. The output buffer is cleared. + */ +int unpack(in, out) + int in, out; /* input and output file descriptors */ +{ + int len; /* Bit length of current code */ + unsigned eob; /* End Of Block code */ + register unsigned peek; /* lookahead bits */ + unsigned peek_mask; /* Mask for peek_bits bits */ + + ifd = in; + ofd = out; + + read_tree(); /* Read the Huffman tree */ + build_tree(); /* Build the prefix table */ + clear_bitbuf(); /* Initialize bit input */ + peek_mask = (1< 0) { + peek >>= peek_bits - len; /* discard the extra bits */ + } else { + /* Code of more than peek_bits bits, we must traverse the tree */ + ulg mask = peek_mask; + len = peek_bits; + do { + len++, mask = (mask<<1)+1; + look_bits(peek, len, mask); + } while (peek < (unsigned)parents[len]); + /* loop as long as peek is a parent node */ + } + /* At this point, peek is the next complete code, of len bits */ + if (peek == eob && len == max_len) break; /* end of file? */ + put_ubyte(literal[peek+lit_base[len]]); + Tracev((stderr,"%02d %04x %c\n", len, peek, + literal[peek+lit_base[len]])); + skip_bits(len); + } /* for (;;) */ + + flush_window(); + Trace((stderr, "bytes_out %ld\n", bytes_out)); + if (orig_len != (ulg)bytes_out) { + error("invalid compressed data--length error"); + } + return OK; +} diff --git a/tools/gzip-1.2.4/unzip.c b/tools/gzip-1.2.4/unzip.c new file mode 100644 index 00000000..7e287a15 --- /dev/null +++ b/tools/gzip-1.2.4/unzip.c @@ -0,0 +1,199 @@ +/* unzip.c -- decompress files in gzip or pkzip format. + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + * + * The code in this file is derived from the file funzip.c written + * and put in the public domain by Mark Adler. + */ + +/* + This version can extract files in gzip or pkzip format. + For the latter, only the first entry is extracted, and it has to be + either deflated or stored. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: unzip.c,v 0.13 1993/06/10 13:29:00 jloup Exp $"; +#endif + +#include "tailor.h" +#include "gzip.h" +#include "crypt.h" + +/* PKZIP header definitions */ +#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */ +#define LOCFLG 6 /* offset of bit flag */ +#define CRPFLG 1 /* bit for encrypted entry */ +#define EXTFLG 8 /* bit for extended local header */ +#define LOCHOW 8 /* offset of compression method */ +#define LOCTIM 10 /* file mod time (for decryption) */ +#define LOCCRC 14 /* offset of crc */ +#define LOCSIZ 18 /* offset of compressed size */ +#define LOCLEN 22 /* offset of uncompressed length */ +#define LOCFIL 26 /* offset of file name field length */ +#define LOCEXT 28 /* offset of extra field length */ +#define LOCHDR 30 /* size of local header, including sig */ +#define EXTHDR 16 /* size of extended local header, inc sig */ + + +/* Globals */ + +int decrypt; /* flag to turn on decryption */ +char *key; /* not used--needed to link crypt.c */ +int pkzip = 0; /* set for a pkzip file */ +int ext_header = 0; /* set if extended local header */ + +/* =========================================================================== + * Check zip file and advance inptr to the start of the compressed data. + * Get ofname from the local header if necessary. + */ +int check_zipfile(in) + int in; /* input file descriptors */ +{ + uch *h = inbuf + inptr; /* first local header */ + + ifd = in; + + /* Check validity of local header, and skip name and extra fields */ + inptr += LOCHDR + SH(h + LOCFIL) + SH(h + LOCEXT); + + if (inptr > insize || LG(h) != LOCSIG) { + fprintf(stderr, "\n%s: %s: not a valid zip file\n", + progname, ifname); + exit_code = ERROR; + return ERROR; + } + method = h[LOCHOW]; + if (method != STORED && method != DEFLATED) { + fprintf(stderr, + "\n%s: %s: first entry not deflated or stored -- use unzip\n", + progname, ifname); + exit_code = ERROR; + return ERROR; + } + + /* If entry encrypted, decrypt and validate encryption header */ + if ((decrypt = h[LOCFLG] & CRPFLG) != 0) { + fprintf(stderr, "\n%s: %s: encrypted file -- use unzip\n", + progname, ifname); + exit_code = ERROR; + return ERROR; + } + + /* Save flags for unzip() */ + ext_header = (h[LOCFLG] & EXTFLG) != 0; + pkzip = 1; + + /* Get ofname and time stamp from local header (to be done) */ + return OK; +} + +/* =========================================================================== + * Unzip in to out. This routine works on both gzip and pkzip files. + * + * IN assertions: the buffer inbuf contains already the beginning of + * the compressed data, from offsets inptr to insize-1 included. + * The magic header has already been checked. The output buffer is cleared. + */ +int unzip(in, out) + int in, out; /* input and output file descriptors */ +{ + ulg orig_crc = 0; /* original crc */ + ulg orig_len = 0; /* original uncompressed length */ + int n; + uch buf[EXTHDR]; /* extended local header */ + + ifd = in; + ofd = out; + + updcrc(NULL, 0); /* initialize crc */ + + if (pkzip && !ext_header) { /* crc and length at the end otherwise */ + orig_crc = LG(inbuf + LOCCRC); + orig_len = LG(inbuf + LOCLEN); + } + + /* Decompress */ + if (method == DEFLATED) { + + int res = inflate(); + + if (res == 3) { + error("out of memory"); + } else if (res != 0) { + error("invalid compressed data--format violated"); + } + + } else if (pkzip && method == STORED) { + + register ulg n = LG(inbuf + LOCLEN); + + if (n != LG(inbuf + LOCSIZ) - (decrypt ? RAND_HEAD_LEN : 0)) { + + fprintf(stderr, "len %ld, siz %ld\n", n, LG(inbuf + LOCSIZ)); + error("invalid compressed data--length mismatch"); + } + while (n--) { + uch c = (uch)get_byte(); +#ifdef CRYPT + if (decrypt) zdecode(c); +#endif + put_ubyte(c); + } + flush_window(); + } else { + error("internal error, invalid method"); + } + + /* Get the crc and original length */ + if (!pkzip) { + /* crc32 (see algorithm.doc) + * uncompressed input size modulo 2^32 + */ + for (n = 0; n < 8; n++) { + buf[n] = (uch)get_byte(); /* may cause an error if EOF */ + } + orig_crc = LG(buf); + orig_len = LG(buf+4); + + } else if (ext_header) { /* If extended header, check it */ + /* signature - 4bytes: 0x50 0x4b 0x07 0x08 + * CRC-32 value + * compressed size 4-bytes + * uncompressed size 4-bytes + */ + for (n = 0; n < EXTHDR; n++) { + buf[n] = (uch)get_byte(); /* may cause an error if EOF */ + } + orig_crc = LG(buf+4); + orig_len = LG(buf+12); + } + + /* Validate decompression */ + if (orig_crc != updcrc(outbuf, 0)) { + error("invalid compressed data--crc error"); + } + if (orig_len != (ulg)bytes_out) { + error("invalid compressed data--length error"); + } + + /* Check if there are more entries in a pkzip file */ + if (pkzip && inptr + 4 < insize && LG(inbuf+inptr) == LOCSIG) { + if (to_stdout) { + WARN((stderr, + "%s: %s has more than one entry--rest ignored\n", + progname, ifname)); + } else { + /* Don't destroy the input zip file */ + fprintf(stderr, + "%s: %s has more than one entry -- unchanged\n", + progname, ifname); + exit_code = ERROR; + ext_header = pkzip = 0; + return ERROR; + } + } + ext_header = pkzip = 0; /* for next file */ + return OK; +} diff --git a/tools/gzip-1.2.4/util.c b/tools/gzip-1.2.4/util.c new file mode 100644 index 00000000..70375d85 --- /dev/null +++ b/tools/gzip-1.2.4/util.c @@ -0,0 +1,462 @@ +/* util.c -- utility functions for gzip support + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: util.c,v 0.15 1993/06/15 09:04:13 jloup Exp $"; +#endif + +#include +#include +#include + +#include "tailor.h" + +#ifdef HAVE_UNISTD_H +# include +#endif +#ifndef NO_FCNTL_H +# include +#endif + +#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) +# include +#else + extern int errno; +#endif + +#include "gzip.h" +#include "crypt.h" + +extern ulg crc_32_tab[]; /* crc table, defined below */ + +/* =========================================================================== + * Copy input to output unchanged: zcat == cat with --force. + * IN assertion: insize bytes have already been read in inbuf. + */ +int copy(in, out) + int in, out; /* input and output file descriptors */ +{ + errno = 0; + while (insize != 0 && (int)insize != EOF) { + write_buf(out, (char*)inbuf, insize); + bytes_out += insize; + insize = read(in, (char*)inbuf, INBUFSIZ); + } + if ((int)insize == EOF && errno != 0) { + read_error(); + } + bytes_in = bytes_out; + return OK; +} + +/* =========================================================================== + * Run a set of bytes through the crc shift register. If s is a NULL + * pointer, then initialize the crc shift register contents instead. + * Return the current crc in either case. + */ +ulg updcrc(s, n) + uch *s; /* pointer to bytes to pump through */ + unsigned n; /* number of bytes in s[] */ +{ + register ulg c; /* temporary variable */ + + static ulg crc = (ulg)0xffffffffL; /* shift register contents */ + + if (s == NULL) { + c = 0xffffffffL; + } else { + c = crc; + if (n) do { + c = crc_32_tab[((int)c ^ (*s++)) & 0xff] ^ (c >> 8); + } while (--n); + } + crc = c; + return c ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */ +} + +/* =========================================================================== + * Clear input and output buffers + */ +void clear_bufs() +{ + outcnt = 0; + insize = inptr = 0; + bytes_in = bytes_out = 0L; +} + +/* =========================================================================== + * Fill the input buffer. This is called only when the buffer is empty. + */ +int fill_inbuf(eof_ok) + int eof_ok; /* set if EOF acceptable as a result */ +{ + int len; + + /* Read as much as possible */ + insize = 0; + errno = 0; + do { + len = read(ifd, (char*)inbuf+insize, INBUFSIZ-insize); + if (len == 0 || len == EOF) break; + insize += len; + } while (insize < INBUFSIZ); + + if (insize == 0) { + if (eof_ok) return EOF; + read_error(); + } + bytes_in += (ulg)insize; + inptr = 1; + return inbuf[0]; +} + +/* =========================================================================== + * Write the output buffer outbuf[0..outcnt-1] and update bytes_out. + * (used for the compressed data only) + */ +void flush_outbuf() +{ + if (outcnt == 0) return; + + write_buf(ofd, (char *)outbuf, outcnt); + bytes_out += (ulg)outcnt; + outcnt = 0; +} + +/* =========================================================================== + * Write the output window window[0..outcnt-1] and update crc and bytes_out. + * (Used for the decompressed data only.) + */ +void flush_window() +{ + if (outcnt == 0) return; + updcrc(window, outcnt); + + if (!test) { + write_buf(ofd, (char *)window, outcnt); + } + bytes_out += (ulg)outcnt; + outcnt = 0; +} + +/* =========================================================================== + * Does the same as write(), but also handles partial pipe writes and checks + * for error return. + */ +void write_buf(fd, buf, cnt) + int fd; + voidp buf; + unsigned cnt; +{ + unsigned n; + + while ((n = write(fd, buf, cnt)) != cnt) { + if (n == (unsigned)(-1)) { + write_error(); + } + cnt -= n; + buf = (voidp)((char*)buf+n); + } +} + +/* ======================================================================== + * Put string s in lower case, return s. + */ +char *strlwr(s) + char *s; +{ + char *t; + for (t = s; *t; t++) *t = tolow(*t); + return s; +} + +/* ======================================================================== + * Return the base name of a file (remove any directory prefix and + * any version suffix). For systems with file names that are not + * case sensitive, force the base name to lower case. + */ +char *basename(fname) + char *fname; +{ + char *p; + + if ((p = strrchr(fname, PATH_SEP)) != NULL) fname = p+1; +#ifdef PATH_SEP2 + if ((p = strrchr(fname, PATH_SEP2)) != NULL) fname = p+1; +#endif +#ifdef PATH_SEP3 + if ((p = strrchr(fname, PATH_SEP3)) != NULL) fname = p+1; +#endif +#ifdef SUFFIX_SEP + if ((p = strrchr(fname, SUFFIX_SEP)) != NULL) *p = '\0'; +#endif + if (casemap('A') == 'a') strlwr(fname); + return fname; +} + +/* ======================================================================== + * Make a file name legal for file systems not allowing file names with + * multiple dots or starting with a dot (such as MSDOS), by changing + * all dots except the last one into underlines. A target dependent + * function can be used instead of this simple function by defining the macro + * MAKE_LEGAL_NAME in tailor.h and providing the function in a target + * dependent module. + */ +void make_simple_name(name) + char *name; +{ + char *p = strrchr(name, '.'); + if (p == NULL) return; + if (p == name) p++; + do { + if (*--p == '.') *p = '_'; + } while (p != name); +} + + +#if defined(NO_STRING_H) && !defined(STDC_HEADERS) + +/* Provide missing strspn and strcspn functions. */ + +# ifndef __STDC__ +# define const +# endif + +int strspn OF((const char *s, const char *accept)); +int strcspn OF((const char *s, const char *reject)); + +/* ======================================================================== + * Return the length of the maximum initial segment + * of s which contains only characters in accept. + */ +int strspn(s, accept) + const char *s; + const char *accept; +{ + register const char *p; + register const char *a; + register int count = 0; + + for (p = s; *p != '\0'; ++p) { + for (a = accept; *a != '\0'; ++a) { + if (*p == *a) break; + } + if (*a == '\0') return count; + ++count; + } + return count; +} + +/* ======================================================================== + * Return the length of the maximum inital segment of s + * which contains no characters from reject. + */ +int strcspn(s, reject) + const char *s; + const char *reject; +{ + register int count = 0; + + while (*s != '\0') { + if (strchr(reject, *s++) != NULL) return count; + ++count; + } + return count; +} + +#endif /* NO_STRING_H */ + +/* ======================================================================== + * Add an environment variable (if any) before argv, and update argc. + * Return the expanded environment variable to be freed later, or NULL + * if no options were added to argv. + */ +#define SEPARATOR " \t" /* separators in env variable */ + +char *add_envopt(argcp, argvp, env) + int *argcp; /* pointer to argc */ + char ***argvp; /* pointer to argv */ + char *env; /* name of environment variable */ +{ + char *p; /* running pointer through env variable */ + char **oargv; /* runs through old argv array */ + char **nargv; /* runs through new argv array */ + int oargc = *argcp; /* old argc */ + int nargc = 0; /* number of arguments in env variable */ + + env = (char*)getenv(env); + if (env == NULL) return NULL; + + p = (char*)xmalloc(strlen(env)+1); + env = strcpy(p, env); /* keep env variable intact */ + + for (p = env; *p; nargc++ ) { /* move through env */ + p += strspn(p, SEPARATOR); /* skip leading separators */ + if (*p == '\0') break; + + p += strcspn(p, SEPARATOR); /* find end of word */ + if (*p) *p++ = '\0'; /* mark it */ + } + if (nargc == 0) { + free(env); + return NULL; + } + *argcp += nargc; + /* Allocate the new argv array, with an extra element just in case + * the original arg list did not end with a NULL. + */ + nargv = (char**)calloc(*argcp+1, sizeof(char *)); + if (nargv == NULL) error("out of memory"); + oargv = *argvp; + *argvp = nargv; + + /* Copy the program name first */ + if (oargc-- < 0) error("argc<=0"); + *(nargv++) = *(oargv++); + + /* Then copy the environment args */ + for (p = env; nargc > 0; nargc--) { + p += strspn(p, SEPARATOR); /* skip separators */ + *(nargv++) = p; /* store start */ + while (*p++) ; /* skip over word */ + } + + /* Finally copy the old args and add a NULL (usual convention) */ + while (oargc--) *(nargv++) = *(oargv++); + *nargv = NULL; + return env; +} + +/* ======================================================================== + * Error handlers. + */ +void error(m) + char *m; +{ + fprintf(stderr, "\n%s: %s: %s\n", progname, ifname, m); + abort_gzip(); +} + +void warn(a, b) + char *a, *b; /* message strings juxtaposed in output */ +{ + WARN((stderr, "%s: %s: warning: %s%s\n", progname, ifname, a, b)); +} + +void read_error() +{ + fprintf(stderr, "\n%s: ", progname); + if (errno != 0) { + perror(ifname); + } else { + fprintf(stderr, "%s: unexpected end of file\n", ifname); + } + abort_gzip(); +} + +void write_error() +{ + fprintf(stderr, "\n%s: ", progname); + perror(ofname); + abort_gzip(); +} + +/* ======================================================================== + * Display compression ratio on the given stream on 6 characters. + */ +void display_ratio(num, den, file) + long num; + long den; + FILE *file; +{ + long ratio; /* 1000 times the compression ratio */ + + if (den == 0) { + ratio = 0; /* no compression */ + } else if (den < 2147483L) { /* (2**31 -1)/1000 */ + ratio = 1000L*num/den; + } else { + ratio = num/(den/1000L); + } + if (ratio < 0) { + putc('-', file); + ratio = -ratio; + } else { + putc(' ', file); + } + fprintf(file, "%2ld.%1ld%%", ratio / 10L, ratio % 10L); +} + + +/* ======================================================================== + * Semi-safe malloc -- never returns NULL. + */ +voidp xmalloc (size) + unsigned size; +{ + voidp cp = (voidp)malloc (size); + + if (cp == NULL) error("out of memory"); + return cp; +} + +/* ======================================================================== + * Table of CRC-32's of all single-byte values (made by makecrc.c) + */ +ulg crc_32_tab[] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; diff --git a/tools/gzip-1.2.4/vms/Makefile.gcc b/tools/gzip-1.2.4/vms/Makefile.gcc new file mode 100644 index 00000000..04506759 --- /dev/null +++ b/tools/gzip-1.2.4/vms/Makefile.gcc @@ -0,0 +1,131 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation +# VMS version made by Klaus Reimann , +# revised by Roland B Roberts . +# This version is for gcc. + +# After constructing gzip.exe with this Makefile, you should set up +# symbols for gzip.exe. Edit the example below, changing +# "disk:[directory]" as appropriate. +# +# $ gzip == "$disk:[directory]gzip.exe" +# $ gunzip == "$disk:[directory]gunzip.exe" +# $ zcat == "$disk:[directory]zcat.exe" + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +#### Start of system configuration section. #### + +CC = gcc +LINK = link + +CFLAGS = +# CFLAGS = /warning +LDFLAGS = + +# Things you might add to DEFS +# -DDIRENT Use for recursion (-r) +# -DSYSDIR Use for recursion (-r) +# -DSYSNDIR Use for recursion (-r) +# -DNDIR Use for recursion (-r) +# -DSTDC_HEADERS Use +# -DHAVE_UNISTD_H Use +# -DNO_UTIME_H Don't use +# -DHAVE_SYSUTIME_H Use +# -DNO_MEMORY_H Don't use . Not needed if STDC_HEADERS. +# -DNO_STRING_H Use strings.h, not string.h. Not needed if STDC_HEADERS +# -DRETSIGTYPE=int Define this if signal handlers must return an int. +# -DNO_SYMLINK OS defines S_IFLNK but does not support symbolic links +# -DNO_MULTIPLE_DOTS System does not allow file names with multiple dots +# -DNO_UTIME System does not support setting file modification time +# -DNO_CHOWN System does not support setting file owner +# -DNO_DIR System does not support readdir() +# -DPROTO Force function prototypes even if __STDC__ not defined +# -DASMV Use asm version match.S +# -DMSDOS MSDOS specific +# -DOS2 OS/2 specific +# -DVAXC Vax/VMS with Vax C compiler +# -DVMS Vax/VMS with gcc +# -DDEBUG Debug code +# -DDYN_ALLOC Use dynamic allocation of large data structures +# -DMAXSEG_64K Maximum array size is 64K (for 16 bit system) +# -DRECORD_IO read() and write() are rounded to record sizes. +# -DNO_STDIN_FSTAT fstat() is not available on stdin +# -DNO_SIZE_CHECK stat() does not give a reliable file size + +DEFS = /define=(VMS) +LIBS = #@LIBS@ + +X=.exe +O=.obj + +# additional assembly sources for particular systems be required. +OBJA = #@OBJA@ + +#### End of system configuration section. #### + +OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \ + crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O vms$O $(OBJA) + +# --- rules --- + +*$O: *.c + $(CC) $* $(DEFS) $(CFLAGS) +# create sys$output +# $(CC) $* $(DEFS) $(CFLAGS)$ + +default: all + +all: gzip$X #zcmp zdiff zmore znew + +gzip$X : $(OBJS) #Makefile + linkobjs:=$(OBJS) + Schleife: + p = f$locate(" ",linkobjs) + if p .lt. f$length(linkobjs) + then linkobjs[p,1]:="," + goto Schleife + endif + write sys$output "linking ''linkobjs'" + $(LINK) $(LDFLAGS) /exec=gzip$X 'linkobjs',sys$input/opt + GNU_CC:[000000]GCCLIB/LIB,SYS$LIBRARY:VAXCRTL/SHARE $ + +# Create a hard link. To remove both files, use "make clean". Using a hard +# link saves disk space, by the way. Note, however, that copying a hard link +# copies the data, not just the link. Therefore, set up the link in the +# directory in which the executable is to reside, or else rename (move) the +# executables into the directory. +# + set file/enter=gunzip.exe gzip.exe + set file/enter=zcat.exe gzip.exe + + +clean: + set file/remove gunzip.exe;0 + set file/remove zcat.exe;0 + delete gzip.exe;0 + delete *$O;0 + +# Actual build-related targets + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +gzip$O getopt$O: getopt.h diff --git a/tools/gzip-1.2.4/vms/Makefile.mms b/tools/gzip-1.2.4/vms/Makefile.mms new file mode 100644 index 00000000..046ce509 --- /dev/null +++ b/tools/gzip-1.2.4/vms/Makefile.mms @@ -0,0 +1,122 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation +# VMS version made by Klaus Reimann , +# revised by Roland B Roberts +# and Karl-Jose Filler +# This version is for VAXC with MMS. + +# After constructing gzip.exe with this Makefile, you should set up +# symbols for gzip.exe. Edit the example below, changing +# "disk:[directory]" as appropriate. +# +# $ gzip == "$disk:[directory]gzip.exe" +# $ gunzip == "$disk:[directory]gunzip.exe" +# $ zcat == "$disk:[directory]zcat.exe" + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +#### Start of system configuration section. #### + +CC = cc +LINK = link + +CFLAGS = +# CFLAGS = /warning +LDFLAGS = + +# Things you might add to DEFS +# -DDIRENT Use for recursion (-r) +# -DSYSDIR Use for recursion (-r) +# -DSYSNDIR Use for recursion (-r) +# -DNDIR Use for recursion (-r) +# -DSTDC_HEADERS Use +# -DHAVE_UNISTD_H Use +# -DNO_UTIME_H Don't use +# -DHAVE_SYSUTIME_H Use +# -DNO_MEMORY_H Don't use . Not needed if STDC_HEADERS. +# -DNO_STRING_H Use strings.h, not string.h. Not needed if STDC_HEADERS +# -DRETSIGTYPE=int Define this if signal handlers must return an int. +# -DNO_SYMLINK OS defines S_IFLNK but does not support symbolic links +# -DNO_MULTIPLE_DOTS System does not allow file names with multiple dots +# -DNO_UTIME System does not support setting file modification time +# -DNO_CHOWN System does not support setting file owner +# -DNO_DIR System does not support readdir() +# -DPROTO Force function prototypes even if __STDC__ not defined +# -DASMV Use asm version match.S +# -DMSDOS MSDOS specific +# -DOS2 OS/2 specific +# -DVAXC Vax/VMS with Vax C compiler +# -DVMS Vax/VMS with gcc +# -DDEBUG Debug code +# -DDYN_ALLOC Use dynamic allocation of large data structures +# -DMAXSEG_64K Maximum array size is 64K (for 16 bit system) +# -DRECORD_IO read() and write() are rounded to record sizes. +# -DNO_STDIN_FSTAT fstat() is not available on stdin +# -DNO_SIZE_CHECK stat() does not give a reliable file size + +# DEFS = /define=(VAXC) +DEFS = +LIBS = + +X=.exe +O=.obj + +# additional assembly sources for particular systems be required. +OBJA = + +#### End of system configuration section. #### + +OBJS = gzip.obj zip.obj deflate.obj trees.obj bits.obj unzip.obj inflate.obj \ + util.obj crypt.obj lzw.obj unlzw.obj unpack.obj unlzh.obj getopt.obj \ + vms.obj $(OBJA) + +# --- rules --- + +.c.obj : + define/user sys sys$library + $(CC) $* $(DEFS) $(CFLAGS) +# create sys.output +# $(CC) $* $(DEFS) $(CFLAGS)$ + +gzip.exe : $(OBJS) + define lnk$library sys$share:vaxcrtl + $(LINK) $(LDFLAGS) /exec=gzip $+ +# +# Create a hard link. To remove both files, use "make clean". Using a hard +# link saves disk space, by the way. Note, however, that copying a hard link +# copies the data, not just the link. Therefore, set up the link in the +# directory in which the executable is to reside, or else rename (move) the +# executables into the directory. +# + set file/enter=gunzip.exe gzip.exe + set file/enter=zcat.exe gzip.exe + +clean : + set file/remove gunzip.exe;0 + set file/remove zcat.exe;0 + delete gzip.exe;0 + delete *.obj;0 + +# Actual build-related targets + +gzip.obj zip.obj deflate.obj trees.obj bits.obj unzip.obj inflate.obj : gzip.h tailor.h +util.obj lzw.obj unlzw.obj unpack.obj unlzh.obj crypt.obj : gzip.h tailor.h + +gzip.obj unlzw.obj : revision.h lzw.h + +bits.obj unzip.obj util.obj zip.obj : crypt.h + +gzip.obj getopt.obj : getopt.h diff --git a/tools/gzip-1.2.4/vms/Makefile.vms b/tools/gzip-1.2.4/vms/Makefile.vms new file mode 100644 index 00000000..9401295f --- /dev/null +++ b/tools/gzip-1.2.4/vms/Makefile.vms @@ -0,0 +1,133 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation +# VMS version made by Klaus Reimann , +# revised by Roland B Roberts . +# This version is for VAXC. Tested with Todd Aven's MAKE/VMS. + +# After constructing gzip.exe with this Makefile, you should set up +# symbols for gzip.exe. Edit the example below, changing +# "disk:[directory]" as appropriate. +# +# $ gzip == "$disk:[directory]gzip.exe" +# $ gunzip == "$disk:[directory]gunzip.exe" +# $ zcat == "$disk:[directory]zcat.exe" + + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +#### Start of system configuration section. #### + +CC = cc +LINK = link + +CFLAGS = +# CFLAGS = /warning +LDFLAGS = + +# Things you might add to DEFS +# -DDIRENT Use for recursion (-r) +# -DSYSDIR Use for recursion (-r) +# -DSYSNDIR Use for recursion (-r) +# -DNDIR Use for recursion (-r) +# -DSTDC_HEADERS Use +# -DHAVE_UNISTD_H Use +# -DNO_UTIME_H Don't use +# -DHAVE_SYSUTIME_H Use +# -DNO_MEMORY_H Don't use . Not needed if STDC_HEADERS. +# -DNO_STRING_H Use strings.h, not string.h. Not needed if STDC_HEADERS +# -DRETSIGTYPE=int Define this if signal handlers must return an int. +# -DNO_SYMLINK OS defines S_IFLNK but does not support symbolic links +# -DNO_MULTIPLE_DOTS System does not allow file names with multiple dots +# -DNO_UTIME System does not support setting file modification time +# -DNO_CHOWN System does not support setting file owner +# -DNO_DIR System does not support readdir() +# -DPROTO Force function prototypes even if __STDC__ not defined +# -DASMV Use asm version match.S +# -DMSDOS MSDOS specific +# -DOS2 OS/2 specific +# -DVAXC Vax/VMS with Vax C compiler +# -DVMS Vax/VMS with gcc +# -DDEBUG Debug code +# -DDYN_ALLOC Use dynamic allocation of large data structures +# -DMAXSEG_64K Maximum array size is 64K (for 16 bit system) +# -DRECORD_IO read() and write() are rounded to record sizes. +# -DNO_STDIN_FSTAT fstat() is not available on stdin +# -DNO_SIZE_CHECK stat() does not give a reliable file size + +# DEFS = /define=(VAXC) +DEFS = +LIBS = + +X=.exe +O=.obj + +# additional assembly sources for particular systems be required. +OBJA = + +#### End of system configuration section. #### + +OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \ + crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O vms$O $(OBJA) + +# --- rules --- + +*$O: *.c + define/user sys sys$library + $(CC) $* $(DEFS) $(CFLAGS) +# create sys$output +# $(CC) $* $(DEFS) $(CFLAGS)$ + +default: all + +all: gzip$X #zcmp zdiff zmore znew + +gzip$X : $(OBJS) #Makefile + linkobjs:=$(OBJS) + Schleife: + p = f$locate(" ",linkobjs) + if p .lt. f$length(linkobjs) + then linkobjs[p,1]:="," + goto Schleife + endif + write sys$output "linking ''linkobjs'" + $(LINK) $(LDFLAGS) /exec=gzip$X 'linkobjs',sys$input/opt + SYS$LIBRARY:VAXCRTL/SHARE $ +# +# Create a hard link. To remove both files, use "make clean". Using a hard +# link saves disk space, by the way. Note, however, that copying a hard link +# copies the data, not just the link. Therefore, set up the link in the +# directory in which the executable is to reside, or else rename (move) the +# executables into the directory. +# + set file/enter=gunzip.exe gzip.exe + set file/enter=zcat.exe gzip.exe + + +clean: + set file/remove gunzip.exe;0 + set file/remove zcat.exe;0 + delete gzip.exe;0 + delete *$O;0 + +# Actual build-related targets + +gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h +util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h + +gzip$O unlzw$O: revision.h lzw.h + +bits$O unzip$O util$O zip$O: crypt.h + +gzip$O getopt$O: getopt.h diff --git a/tools/gzip-1.2.4/vms/Readme.vms b/tools/gzip-1.2.4/vms/Readme.vms new file mode 100644 index 00000000..4b9797ca --- /dev/null +++ b/tools/gzip-1.2.4/vms/Readme.vms @@ -0,0 +1,87 @@ +README file for gzip on VMS +written by Klaus Reimann + +Here is a list of the files in [.vms]: + +GZIP.HLP ! Help-file, how to use gzip +MAKEFILE.GCC ! Description for (vms-)make, using gcc +MAKEFILE.MMS ! Description for MMS-utility, using vaxc +MAKEFILE.VMS ! Description for (vms-)make, using vaxc +MAKEGZIP.COM ! simple and robust DCL-Script, using vaxc +README.VMS ! this file, how to install gzip +VMS.C ! VMS-specific functions in gzip + +This file describe, how to compile and install the VMS-Port of gzip. +>>For restrictions or bugs due to the structure of the vms-filesystem +refer to gzip.hlp.<< + +Installing gzip + +Since there are many makefiles there are many possibilities +compiling and installing gzip. For most of them, it is important, +that you start them from the SOURCE-Directory (that is where +gzip.c is), not from the [.vms]-directory. Otherwise the compiler +won't find the source-files. + +Using gcc saves disk-space, but needs longer to compile + VAXC gzip.exe 95/96 Blocks + gcc2.3.3 gzip.exe 86/87 Blocks + +To install gzip one has to perform the following steps: + 1. compile sources (*.c, [.vms]*.c) + 2. link executable gzip.exe + 3. Make entries gunzip.exe and zcat.exe to gzip.exe. + These are similar to hardlinks in UNIX + >>If You wish to do this by hand, see for example makegzip.com.<< + The Entries can't be simply deleted, use 'set file /remove' . + + 4. Rename executables (*.exe) to Your prefered exe-directory. If it is on + another Device, then you should only copy gzip.exe and do the + entries gunzip.exe and zcat.exe by hand (3.). + + 5. Setting up Symbols for the executables: + Place the following lines in Your login.com + Change "disk:[directory]" as appropriate. + $ gzip == "$disk:[directory]gzip.exe" + $ gunzip == "$disk:[directory]gunzip.exe" + $ zcat == "$disk:[directory]zcat.exe" + 6. insert help-file gzip.hlp in any Help-library, + for example in sys$help:helplib. + this can be done by $lib sys$help:helplib/help gzip + (I did not try this command) + +Steps (4.)5. through 6 must be done by hand. +Steps 1 through 3(4.) may be done by one of the makefiles: + +a) MAKEGZIP.COM +This was crated from MAKEFILE.VMS and later on edited. It uses the +VAXC-Compiler and does compiling, linking and making the entries. +Usage: +- change to the Source-Directory +- copy vms.c + $copy [.vms]vms.c [] +- start compiling, linking, entries + $@[.vms]makegzip +if everything is OK. then you get gzip.exe, gunzip.exe, zcat.exe +continue at Step 4. + +b) MAKEFILE.VMS +Makefile for a vms-make utility (NOT gnu-make). +Is uses the VAXC-Compiler and has the Advantage over MAKEGZIP.COM +that make checks dependencies. This is helpfull if You have to +recompile several times, for example after editing the sources. +- change to the Source-Directory +- copy vms.c + $copy [.vms]vms.c [] +- start compiling, linking, entries + $make /input=[.vms]makefile.vms +if everything is OK. then you get gzip.exe, gunzip.exe, zcat.exe +Continue at Step 4. + +c) MAKEFILE.GCC +Same as MAKEFILE.VMS, but uses gcc +- Use $make /input=[.vms]makefile.gcc instead of make .... + +d) MAKEFILE.MMS +Makefile for the MMS-utility. Similar to MAKEFILE.VMS +- Use $mms /description=[.vms]makefile.mms instead of make .... diff --git a/tools/gzip-1.2.4/vms/gzip.hlp b/tools/gzip-1.2.4/vms/gzip.hlp new file mode 100644 index 00000000..ba53cc64 --- /dev/null +++ b/tools/gzip-1.2.4/vms/gzip.hlp @@ -0,0 +1,297 @@ +1 GZIP +NAME + gzip, gunzip, zcat - compress or expand files + +SYNOPSIS + gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] + gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] + zcat [ -fhLV ] [ name ... ] + +2 DESCRIPTION + Gzip reduces the size of the named files using Lempel-Ziv + coding (LZ77). Whenever possible, each file is replaced by + one with the extension .gz, while keeping the same ownership + modes, access and modification times. (The default exten- + sion is -gz for VMS, z for MSDOS, OS/2 FAT, Windows NT FAT + and Atari.) If no files are specified, or if a file name is + "-", the standard input is compressed to the standard out- + put. Gzip will only attempt to compress regular files. + + If the compressed file name is too long for its file system, + gzip truncates it. Gzip attempts to truncate only the parts + of the file name longer than 3 characters. (A part is del- + imited by dots.) If the name consists of small parts only, + the longest parts are truncated. For example, if file names + are limited to 14 characters, gzip.msdos.exe is compressed + to gzi.msd.exe.gz. Names are not truncated on systems which + do not have a limit on file name length. + + By default, gzip keeps the original file name and timestamp + in the compressed file. These are used when decompressing + the file with the -N option. This is useful when the + compressed file name was truncated or when the time stamp + was not preserved after a file transfer. + + Compressed files can be restored to their original form + using gzip -d or gunzip or zcat. If the original name saved + in the compressed file is not suitable for its file system, + a new name is constructed from the original one to make it + legal. + + gunzip takes a list of files on its command line and + replaces each file whose name ends with .gz, -gz, .z, -z, _z + or .Z and which begins with the correct magic number with an + uncompressed file without the original extension. gunzip + also recognizes the special extensions .tgz and .taz as + shorthands for .tar.gz and .tar.Z respectively. When + compressing, gzip uses the .tgz extension if necessary + instead of truncating a file with a .tar extension. + + gunzip can currently decompress files created by gzip, zip, + compress, compress -H or pack. The detection of the input + format is automatic. When using the first two formats, + gunzip checks a 32 bit CRC. For pack, gunzip checks the + uncompressed length. The standard compress format was not + designed to allow consistency checks. However gunzip is + sometimes able to detect a bad .Z file. If you get an error + when uncompressing a .Z file, do not assume that the .Z file + is correct simply because the standard uncompress does not + complain. This generally means that the standard uncompress + does not check its input, and happily generates garbage out- + put. The SCO compress -H format (lzh compression method) + does not include a CRC but also allows some consistency + checks. + + Files created by zip can be uncompressed by gzip only if + they have a single member compressed with the 'deflation' + method. This feature is only intended to help conversion of + tar.zip files to the tar.gz format. To extract zip files + with several members, use unzip instead of gunzip. + + zcat is identical to gunzip -c. (On some systems, zcat may + be installed as gzcat to preserve the original link to + compress.) zcat uncompresses either a list of files on the + command line or its standard input and writes the + uncompressed data on standard output. zcat will uncompress + files that have the correct magic number whether they have a + .gz suffix or not. + + Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP. + The amount of compression obtained depends on the size of + the input and the distribution of common substrings. Typi- + cally, text such as source code or English is reduced by + 60-70%. Compression is generally much better than that + achieved by LZW (as used in compress), Huffman coding (as + used in pack), or adaptive Huffman coding (compact). + + Compression is always performed, even if the compressed file + is slightly larger than the original. The worst case expan- + sion is a few bytes for the gzip file header, plus 5 bytes + every 32K block, or an expansion ratio of 0.015% for large + files. Note that the actual number of used disk blocks + almost never increases. gzip preserves the mode, ownership + and timestamps of files when compressing or decompressing. + +2 OPTIONS + -a --ascii + Ascii text mode: convert end-of-lines using local con- + ventions. This option is supported only on some non- + Unix systems. For MSDOS, CR LF is converted to LF when + compressing, and LF is converted to CR LF when + decompressing. + + -c --stdout --to-stdout + Write output on standard output; keep original files + unchanged. If there are several input files, the out- + put consists of a sequence of independently compressed + members. To obtain better compression, concatenate all + input files before compressing them. + + -d --decompress --uncompress + Decompress. + + -f --force + Force compression or decompression even if the file has + multiple links or the corresponding file already + exists, or if the compressed data is read from or writ- + ten to a terminal. If the input data is not in a format + recognized by gzip, and if the option --stdout is also + given, copy the input data without change to the stan- + dard ouput: let zcat behave as cat. If -f is not given, + and when not running in the background, gzip prompts to + verify whether an existing file should be overwritten. + + -h --help + Display a help screen and quit. + + -l --list + For each compressed file, list the following fields: + + compressed size: size of the compressed file + uncompressed size: size of the uncompressed file + ratio: compression ratio (0.0% if unknown) + uncompressed_name: name of the uncompressed file + + The uncompressed size is given as -1 on VMS because it + it is not possible to seek reliably to the end of the + compressed file, where this size is stored. + + In combination with the --verbose option, the following + fields are also displayed: + + method: compression method + crc: the 32-bit CRC of the uncompressed data + date & time: time stamp for the uncompressed file + + The compression methods currently supported are + deflate, compress, lzh (SCO compress -H) and pack. The + crc is given as ffffffff on VMS for the reason given + above about the uncompressed size. + + With --name, the uncompressed name, date and time are + those stored within the compress file if present. + + With --verbose, the size totals and compression ratio + for all files is also displayed, unless some sizes are + unknown. With --quiet, the title and totals lines are + not displayed. + + -L --license + Display the gzip license and quit. + + -n --no-name + When compressing, do not save the original file name + and time stamp by default. (The original name is always + saved if the name had to be truncated.) When + decompressing, do not restore the original file name if + present (remove only the gzip suffix from the + compressed file name) and do not restore the original + time stamp if present (copy it from the compressed + file). This option is the default when decompressing. + + -N --name + When compressing, always save the original file name + and time stamp; this is the default. When decompress- + ing, restore the original file name and time stamp if + present. This option is useful on systems which have a + limit on file name length or when the time stamp has + been lost after a file transfer. + + -q --quiet + Suppress all warnings. + + -r --recursive + Travel the directory structure recursively. If any of + the file names specified on the command line are direc- + tories, gzip will descend into the directory and + compress all the files it finds there (or decompress + them in the case of gunzip ). + + -S suf --suffix suf + Use suffix suf instead of -gz. Any suffix can be + given, but suffixes other than -z and -gz should be + avoided to avoid confusion when files are transferred + to other. A null suffix forces gunzip to try + decompression on all given files regardless of suffix, + as in: + + gunzip --suffix "" *.* + + Previous versions of gzip used the -z suffix. This was + changed to avoid a conflict with pack on Unix. + + -t --test + Test. Check the compressed file integrity. + + -v --verbose + Verbose. Display the name and percentage reduction for + each file compressed or decompressed. + + -V --version + Version. Display the version number and compilation + options then quit. + + -# --fast --best + Regulate the speed of compression using the specified + digit #, where -1 or --fast indicates the fastest + compression method (less compression) and -9 or --best + indicates the slowest compression method (best compres- + sion). The default compression level is -6 (that is, + biased towards high compression at expense of speed). + +2 ENVIRONMENT + The environment variable GZIP_OPT can hold a set of default + options for gzip. These options are interpreted first and + can be overwritten by explicit command line parameters. For + example: + define GZIP_OPT "-8 -v" + +2 SEE ALSO + compress, zip, unzip + +2 DIAGNOSTICS + Exit status is normally 0; if an error occurs, exit status + is 1. If a warning occurs, exit status is 2. + + Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...] + Invalid options were specified on the command line. + file: not in gzip format + The file specified to gunzip has not been + compressed. + file: Corrupt input. Use zcat to recover some data. + The compressed file has been damaged. The data up to + the point of failure can be recovered using + define /user sys$output file.recover + zcat file + file: compressed with xx bits, can only handle yy bits + File was compressed (using LZW) by a program that + could deal with more bits than the decompress code + on this machine. Recompress the file with gzip, + which compresses better and uses less memory. + file: already has -gz suffix -- no change + The file is assumed to be already compressed. + Rename the file and try again. + file already exists; do you wish to overwrite (y or n)? + Respond "y" if you want the output file to be + replaced; "n" if not. + gunzip: corrupt input + A SIGSEGV violation was detected which usually means + that the input file has been corrupted. + xx.x% + Percentage of the input saved by compression. + (Relevant only for -v and -l.) + -- not a regular file or directory: ignored + When the input file is not a regular file or direc- + tory, it is left unaltered. + +2 CAVEATS + On VMS: + - upper case options need quotes: gzip "-V". + - restoration of timestamps and version numbers is not supported + - If a compressed file already exists, gzip -f overwrites it, it + does not create a new version. + - multi-part gzip files are not supported. + - gunzip does not preserve the input file format. You can use a + separate utility to restore the original format. + - gunzip and zcat can be used only if you have created the + links to gzip as documented in makegzip.com. Otherwise + you must use explicit parameters ("gzip -c" or "gzip -dc"). + - gzip --list cannot give the uncompressed size and crc. + + When writing compressed data to a tape, it is generally + necessary to pad the output with zeroes up to a block boun- + dary. When the data is read and the whole block is passed to + gunzip for decompression, gunzip detects that there is extra + trailing garbage after the compressed data and emits a warn- + ing by default. You have to use the --quiet option to + suppress the warning. This option can be set in the GZIP_OPT + environment variable as in: + define GZIP_OPT "-q" + +2 BUGS + On VMS, files in VFC record format are not correctly handled by + the C runtime library (the linefeed character is suppressed). + + In some rare cases, the --best option gives worse compres- + sion than the default compression level (-6). On some highly + redundant files, compress compresses better than gzip. diff --git a/tools/gzip-1.2.4/vms/makegzip.com b/tools/gzip-1.2.4/vms/makegzip.com new file mode 100644 index 00000000..def90f64 --- /dev/null +++ b/tools/gzip-1.2.4/vms/makegzip.com @@ -0,0 +1,71 @@ +$! Makefile for VMS +$! DCL-Shell-language. Edit the symbols section at the end. +$! +$ On Control_Y Then Goto The_Exit +$ On Error Then Goto The_Exit +$ define/user sys sys$library +$ cc gzip.c /define=(VAXC) +$ define/user sys sys$library +$ cc zip.c /define=(VAXC) +$ define/user sys sys$library +$ cc deflate.c /define=(VAXC) +$ define/user sys sys$library +$ cc trees.c /define=(VAXC) +$ define/user sys sys$library +$ cc bits.c /define=(VAXC) +$ define/user sys sys$library +$ cc unzip.c /define=(VAXC) +$ define/user sys sys$library +$ cc inflate.c /define=(VAXC) +$ define/user sys sys$library +$ cc util.c /define=(VAXC) +$ define/user sys sys$library +$ cc crypt.c /define=(VAXC) +$ define/user sys sys$library +$ cc lzw.c /define=(VAXC) +$ define/user sys sys$library +$ cc unlzw.c /define=(VAXC) +$ define/user sys sys$library +$ cc unpack.c /define=(VAXC) +$ define/user sys sys$library +$ cc unlzh.c /define=(VAXC) +$ define/user sys sys$library +$ cc getopt.c /define=(VAXC) +$ define/user sys sys$library +$ cc vms.c /define=(VAXC) +$ linkobjs:=gzip.obj zip.obj deflate.obj trees.obj bits.obj unzip.obj - + inflate.obj util.obj crypt.obj lzw.obj unlzw.obj unpack.obj unlzh.obj - + getopt.obj vms.obj +$ Schleife: +$ p = f$locate(" ",linkobjs) +$ if p .lt. f$length(linkobjs) +$ then linkobjs[p,1]:="," +$ goto Schleife +$ endif +$ write sys$output "linking ''linkobjs'" +$ link /exec=gzip.exe 'linkobjs',sys$input/opt +SYS$LIBRARY:VAXCRTL/SHARE +$ +$ ! Create a hard link. (To remove both files, delete the copy FIRST, then +$ ! the original. Otherwise, if original deleted first [copy says "no such +$ ! file"], must use "set file/remove gunzip.exe;#" to get rid of the copy. +$ ! Unlike in Unix, deleting the original ALWAYS destroys the data--but not +$ ! the directory entry of the copy.) Using a hard link saves disk space, by +$ ! the way. Note, however, that copying a hard link copies the data, not +$ ! just the link. Therefore, set up the link in the directory in which the +$ ! executable is to reside, or else rename (move) the executables into the +$ ! directory. +$ ! +$ set file/enter=gunzip.exe gzip.exe +$ set file/enter=zcat.exe gzip.exe +$ +$ ! Set up symbols for the gzip executable. Edit the example below, +$ ! changing "disk:[directory]" as appropriate. +$ ! +$ gzip == "$disk:[directory]gzip.exe" +$ gunzip == "$disk:[directory]gunzip.exe" +$ zcat == "$disk:[directory]zcat.exe" +$ +$The_Exit: +$ Save_Status = $STATUS +$ exit Save_Status diff --git a/tools/gzip-1.2.4/vms/vms.c b/tools/gzip-1.2.4/vms/vms.c new file mode 100644 index 00000000..51b891a2 --- /dev/null +++ b/tools/gzip-1.2.4/vms/vms.c @@ -0,0 +1,102 @@ +/* vms.c -- target dependent functions for VMS + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + * + * This file was written by Karl-Jose Filler + * and updated by Jean-loup Gailly. + */ + +#include + +static char **vms_argv = NULL; + +static int max_files = 10000; + +struct Str_desc { + int length; + char *addr; +}; + +vms_expand_args(old_argc, argv) + int *old_argc; + char **argv[]; +{ + int i; + int new_argc = 0; + int context, status; + char buf[255], *p; + + vms_argv = (char**)xmalloc((max_files+1)*sizeof(char*)); + + vms_argv[new_argc++] = **argv; + + for (i=1; i < *old_argc; i++) { + if (*argv[0][i] == '-') { /* switches */ + if (new_argc < max_files) { + vms_argv[new_argc++] = argv[0][i]; + } + } else { /* Files */ + context = 0; + if (find_file_c(argv[0][i], buf, sizeof(buf), &context) & 1 != 1) { + /* + * Wrong file ? + * forward it to gzip + */ + if (new_argc < max_files) { + vms_argv[new_argc++] = argv[0][i]; + } + } else { + p = (char*)xmalloc(strlen(buf)+1); + strcpy(p, buf); + if (new_argc < max_files) { + vms_argv[new_argc++] = p; + } + while (find_file_c(argv[0][i], buf, + sizeof(buf), &context) & 1 == 1) { + p = (char*)xmalloc(strlen(buf)+1); + strcpy(p, buf); + if (new_argc < max_files) { + vms_argv[new_argc++] = p; + } + } + } + } + } + if (new_argc <= max_files) { + *old_argc = new_argc; + vms_argv[new_argc] = NULL; + *argv = vms_argv; + } else { + free(vms_argv); /* the expanded file names should also be freed ... */ + vms_argv = NULL; + max_files = new_argc + 1; + vms_expand_args(old_argc, argv); + } +} + +int find_file_c(in,out,out_len,context) + char *in; + char *out; + int out_len; + int *context; +{ + struct Str_desc in_desc,out_desc; + int status; + char *p; + + in_desc.addr = in; + in_desc.length = strlen(in); + + out_desc.addr = out; + out_desc.length = out_len; + + status = lib$find_file(&in_desc,&out_desc,context); + + p = out_desc.addr; + while(*p != ' ') { + p++; + } + *p = 0; + + return status; +} diff --git a/tools/gzip-1.2.4/zcat b/tools/gzip-1.2.4/zcat new file mode 100755 index 00000000..9f13d0ce Binary files /dev/null and b/tools/gzip-1.2.4/zcat differ diff --git a/tools/gzip-1.2.4/zdiff.1 b/tools/gzip-1.2.4/zdiff.1 new file mode 100644 index 00000000..ea3bf410 --- /dev/null +++ b/tools/gzip-1.2.4/zdiff.1 @@ -0,0 +1,44 @@ +.TH ZDIFF 1 +.SH NAME +zcmp, zdiff \- compare compressed files +.SH SYNOPSIS +.B zcmp +[ cmp_options ] file1 +[ file2 ] +.br +.B zdiff +[ diff_options ] file1 +[ file2 ] +.SH DESCRIPTION +.I Zcmp +and +.I zdiff +are used to invoke the +.I cmp +or the +.I diff +program on compressed files. All options specified are passed directly to +.I cmp +or +.IR diff "." +If only 1 file is specified, then the files compared are +.I file1 +and an uncompressed +.IR file1 ".gz." +If two files are specified, then they are uncompressed if necessary and fed to +.I cmp +or +.IR diff "." +The exit status from +.I cmp +or +.I diff +is preserved. +.SH "SEE ALSO" +cmp(1), diff(1), zmore(1), zgrep(1), znew(1), zforce(1), gzip(1), gzexe(1) +.SH BUGS +Messages from the +.I cmp +or +.I diff +programs refer to temporary filenames instead of those specified. diff --git a/tools/gzip-1.2.4/zdiff.in b/tools/gzip-1.2.4/zdiff.in new file mode 100755 index 00000000..110454cc --- /dev/null +++ b/tools/gzip-1.2.4/zdiff.in @@ -0,0 +1,70 @@ +: +#!/bin/sh +# sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh + +# Zcmp and zdiff are used to invoke the cmp or the diff pro- +# gram on compressed files. All options specified are passed +# directly to cmp or diff. If only 1 file is specified, then +# the files compared are file1 and an uncompressed file1.gz. +# If two files are specified, then they are uncompressed (if +# necessary) and fed to cmp or diff. The exit status from cmp +# or diff is preserved. + +PATH="BINDIR:$PATH"; export PATH +prog=`echo $0 | sed 's|.*/||'` +case "$prog" in + *cmp) comp=${CMP-cmp} ;; + *) comp=${DIFF-diff} ;; +esac + +OPTIONS= +FILES= +for ARG +do + case "$ARG" in + -*) OPTIONS="$OPTIONS $ARG";; + *) if test -f "$ARG"; then + FILES="$FILES $ARG" + else + echo "${prog}: $ARG not found or not a regular file" + exit 1 + fi ;; + esac +done +if test -z "$FILES"; then + echo "Usage: $prog [${comp}_options] file [file]" + exit 1 +fi +set $FILES +if test $# -eq 1; then + FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'` + gzip -cd "$1" | $comp $OPTIONS - "$FILE" + STAT="$?" + +elif test $# -eq 2; then + case "$1" in + *[-.]gz* | *[-.][zZ] | *.t[ga]z) + case "$2" in + *[-.]gz* | *[-.][zZ] | *.t[ga]z) + F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'` + gzip -cdfq "$2" > /tmp/"$F".$$ + gzip -cdfq "$1" | $comp $OPTIONS - /tmp/"$F".$$ + STAT="$?" + /bin/rm -f /tmp/"$F".$$;; + + *) gzip -cdfq "$1" | $comp $OPTIONS - "$2" + STAT="$?";; + esac;; + *) case "$2" in + *[-.]gz* | *[-.][zZ] | *.t[ga]z) + gzip -cdfq "$2" | $comp $OPTIONS "$1" - + STAT="$?";; + *) $comp $OPTIONS "$1" "$2" + STAT="$?";; + esac;; + esac + exit "$STAT" +else + echo "Usage: $prog [${comp}_options] file [file]" + exit 1 +fi diff --git a/tools/gzip-1.2.4/zforce.1 b/tools/gzip-1.2.4/zforce.1 new file mode 100644 index 00000000..37c6aba6 --- /dev/null +++ b/tools/gzip-1.2.4/zforce.1 @@ -0,0 +1,20 @@ +.TH ZFORCE 1 +.SH NAME +zforce \- force a '.gz' extension on all gzip files +.SH SYNOPSIS +.B zforce +[ name ... ] +.SH DESCRIPTION +.I zforce +forces a .gz extension on all +.I gzip +files so that +.I gzip +will not compress them twice. +This can be useful for files with names truncated after a file transfer. +On systems with a 14 char limitation on file names, the original name +is truncated to make room for the .gz suffix. For example, +12345678901234 is renamed to 12345678901.gz. A file name such as foo.tgz +is left intact. +.SH "SEE ALSO" +gzip(1), znew(1), zmore(1), zgrep(1), zdiff(1), gzexe(1) diff --git a/tools/gzip-1.2.4/zforce.in b/tools/gzip-1.2.4/zforce.in new file mode 100755 index 00000000..4ae5763c --- /dev/null +++ b/tools/gzip-1.2.4/zforce.in @@ -0,0 +1,42 @@ +: +#!/bin/sh +# zforce: force a gz extension on all gzip files so that gzip will not +# compress them twice. +# +# This can be useful for files with names truncated after a file transfer. +# 12345678901234 is renamed to 12345678901.gz + +PATH="BINDIR:$PATH"; export PATH +x=`basename $0` +if test $# = 0; then + echo "force a '.gz' extension on all gzip files" + echo usage: $x files... + exit 1 +fi + +res=0 +for i do + if test ! -f "$i" ; then + echo ${x}: $i not a file + res=1 + continue + fi + test `expr "$i" : '.*[.-]z$'` -eq 0 || continue + test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue + test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue + + if gzip -l < "$i" 2>/dev/null | grep '^defl' > /dev/null; then + + if test `expr "$i" : '^............'` -eq 12; then + new=`expr "$i" : '\(.*\)...$`.gz + else + new="$i.gz" + fi + if mv "$i" "$new" 2>/dev/null; then + echo $i -- replaced with $new + continue + fi + res=1; echo ${x}: cannot rename $i to $new + fi +done +exit $res diff --git a/tools/gzip-1.2.4/zgrep.1 b/tools/gzip-1.2.4/zgrep.1 new file mode 100644 index 00000000..a52a88ab --- /dev/null +++ b/tools/gzip-1.2.4/zgrep.1 @@ -0,0 +1,44 @@ +.TH ZGREP 1 +.SH NAME +zgrep \- search possibly compressed files for a regular expression +.SH SYNOPSIS +.B zgrep +[ grep_options ] +.BI [\ -e\ ] " pattern" +.IR filename ".\|.\|." +.SH DESCRIPTION +.IR Zgrep +is used to invoke the +.I grep +on compress'ed or gzip'ed files. All options specified are passed directly to +.I grep. +If no file is specified, then the standard input is decompressed +if necessary and fed to grep. +Otherwise the given files are uncompressed if necessary and fed to +.I grep. +.PP +If +.I zgrep +is invoked as +.I zegrep +or +.I zfgrep +then +.I egrep +or +.I fgrep +is used instead of +.I grep. +If the GREP environment variable is set, +.I zgrep +uses it as the +.I grep +program to be invoked. For example: + + for sh: GREP=fgrep zgrep string files + for csh: (setenv GREP fgrep; zgrep string files) +.SH AUTHOR +Charles Levert (charles@comm.polymtl.ca) +.SH "SEE ALSO" +grep(1), egrep(1), fgrep(1), zdiff(1), zmore(1), znew(1), zforce(1), +gzip(1), gzexe(1) diff --git a/tools/gzip-1.2.4/zgrep.in b/tools/gzip-1.2.4/zgrep.in new file mode 100755 index 00000000..9fcd8282 --- /dev/null +++ b/tools/gzip-1.2.4/zgrep.in @@ -0,0 +1,67 @@ +: +#!/bin/sh + +# zgrep -- a wrapper around a grep program that decompresses files as needed +# Adapted from a version sent by Charles Levert + +PATH="BINDIR:$PATH"; export PATH + +prog=`echo $0 | sed 's|.*/||'` +case "$prog" in + *egrep) grep=${EGREP-egrep} ;; + *fgrep) grep=${FGREP-fgrep} ;; + *) grep=${GREP-grep} ;; +esac +pat="" +while test $# -ne 0; do + case "$1" in + -e | -f) opt="$opt $1"; shift; pat="$1" + if test "$grep" = grep; then # grep is buggy with -e on SVR4 + grep=egrep + fi;; + -*) opt="$opt $1";; + *) if test -z "$pat"; then + pat="$1" + else + break; + fi;; + esac + shift +done + +if test -z "$pat"; then + echo "grep through gzip files" + echo "usage: $prog [grep_options] pattern [files]" + exit 1 +fi + +list=0 +silent=0 +op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` +case "$op" in + *l*) list=1 +esac +case "$op" in + *h*) silent=1 +esac + +if test $# -eq 0; then + gzip -cdfq | $grep $opt "$pat" + exit $? +fi + +res=0 +for i do + if test $list -eq 1; then + gzip -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i + r=$? + elif test $# -eq 1 -o $silent -eq 1; then + gzip -cdfq "$i" | $grep $opt "$pat" + r=$? + else + gzip -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|" + r=$? + fi + test "$r" -ne 0 && res="$r" +done +exit $res diff --git a/tools/gzip-1.2.4/zip.c b/tools/gzip-1.2.4/zip.c new file mode 100644 index 00000000..507d1616 --- /dev/null +++ b/tools/gzip-1.2.4/zip.c @@ -0,0 +1,117 @@ +/* zip.c -- compress files to the gzip or pkzip format + * Copyright (C) 1992-1993 Jean-loup Gailly + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +#ifdef RCSID +static char rcsid[] = "$Id: zip.c,v 0.17 1993/06/10 13:29:25 jloup Exp $"; +#endif + +#include +#include + +#include "tailor.h" +#include "gzip.h" +#include "crypt.h" + +#ifdef HAVE_UNISTD_H +# include +#endif +#ifndef NO_FCNTL_H +# include +#endif + +local ulg crc; /* crc on uncompressed file data */ +long header_bytes; /* number of bytes in gzip header */ + +/* =========================================================================== + * Deflate in to out. + * IN assertions: the input and output buffers are cleared. + * The variables time_stamp and save_orig_name are initialized. + */ +int zip(in, out) + int in, out; /* input and output file descriptors */ +{ + uch flags = 0; /* general purpose bit flags */ + ush attr = 0; /* ascii/binary flag */ + ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */ + + ifd = in; + ofd = out; + outcnt = 0; + + /* Write the header to the gzip file. See algorithm.doc for the format */ + + method = DEFLATED; + put_byte(GZIP_MAGIC[0]); /* magic header */ + put_byte(GZIP_MAGIC[1]); + put_byte(DEFLATED); /* compression method */ + + if (save_orig_name) { + flags |= ORIG_NAME; + } + put_byte(flags); /* general flags */ + put_long(time_stamp); + + /* Write deflated file to zip file */ + crc = updcrc(0, 0); + + bi_init(out); + ct_init(&attr, &method); + lm_init(level, &deflate_flags); + + put_byte((uch)deflate_flags); /* extra flags */ + put_byte(OS_CODE); /* OS identifier */ + + if (save_orig_name) { + char *p = basename(ifname); /* Don't save the directory part. */ + do { + put_char(*p); + } while (*p++); + } + header_bytes = (long)outcnt; + + (void)deflate(); + +#if !defined(NO_SIZE_CHECK) && !defined(RECORD_IO) + /* Check input size (but not in VMS -- variable record lengths mess it up) + * and not on MSDOS -- diet in TSR mode reports an incorrect file size) + */ + if (ifile_size != -1L && isize != (ulg)ifile_size) { + Trace((stderr, " actual=%ld, read=%ld ", ifile_size, isize)); + fprintf(stderr, "%s: %s: file size changed while zipping\n", + progname, ifname); + } +#endif + + /* Write the crc and uncompressed size */ + put_long(crc); + put_long(isize); + header_bytes += 2*sizeof(long); + + flush_outbuf(); + return OK; +} + + +/* =========================================================================== + * Read a new buffer from the current input file, perform end-of-line + * translation, and update the crc and input file size. + * IN assertion: size >= 2 (for end-of-line translation) + */ +int file_read(buf, size) + char *buf; + unsigned size; +{ + unsigned len; + + Assert(insize == 0, "inbuf not empty"); + + len = read(ifd, buf, size); + if (len == (unsigned)(-1) || len == 0) return (int)len; + + crc = updcrc((uch*)buf, len); + isize += (ulg)len; + return (int)len; +} diff --git a/tools/gzip-1.2.4/zmore.1 b/tools/gzip-1.2.4/zmore.1 new file mode 100644 index 00000000..f7f1843d --- /dev/null +++ b/tools/gzip-1.2.4/zmore.1 @@ -0,0 +1,145 @@ +.TH ZMORE 1 +.SH NAME +zmore \- file perusal filter for crt viewing of compressed text +.SH SYNOPSIS +.B zmore +[ name ... ] +.SH DESCRIPTION +.I Zmore +is a filter which allows examination of compressed or plain text files +one screenful at a time on a soft-copy terminal. +.I zmore +works on files compressed with +.I compress, pack +or +.I gzip, +and also on uncompressed files. +If a file does not exist, +.I zmore +looks for a file of the same name with the addition of a .gz, .z or .Z suffix. +.PP +.I Zmore +normally pauses after each screenful, printing --More-- +at the bottom of the screen. +If the user then types a carriage return, one more line is displayed. +If the user hits a space, +another screenful is displayed. Other possibilities are enumerated later. +.PP +.I Zmore +looks in the file +.I /etc/termcap +to determine terminal characteristics, +and to determine the default window size. +On a terminal capable of displaying 24 lines, +the default window size is 22 lines. +To use a pager other than the default +.I more, +set environment variable PAGER to the name of the desired program, such as +.I less. +.PP +Other sequences which may be typed when +.I zmore +pauses, and their effects, are as follows (\fIi\fP is an optional integer +argument, defaulting to 1) : +.PP +.IP \fIi\|\fP +display +.I i +more lines, (or another screenful if no argument is given) +.PP +.IP ^D +display 11 more lines (a ``scroll''). +If +.I i +is given, then the scroll size is set to \fIi\|\fP. +.PP +.IP d +same as ^D (control-D) +.PP +.IP \fIi\|\fPz +same as typing a space except that \fIi\|\fP, if present, becomes the new +window size. Note that the window size reverts back to the default at the +end of the current file. +.PP +.IP \fIi\|\fPs +skip \fIi\|\fP lines and print a screenful of lines +.PP +.IP \fIi\|\fPf +skip \fIi\fP screenfuls and print a screenful of lines +.PP +.IP "q or Q" +quit reading the current file; go on to the next (if any) +.PP +.IP "e or q" +When the prompt --More--(Next file: +.IR file ) +is printed, this command causes zmore to exit. +.PP +.IP s +When the prompt --More--(Next file: +.IR file ) +is printed, this command causes zmore to skip the next file and continue. +.PP +.IP = +Display the current line number. +.PP +.IP \fIi\|\fP/expr +search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP +If the pattern is not found, +.I zmore +goes on to the next file (if any). +Otherwise, a screenful is displayed, starting two lines before the place +where the expression was found. +The user's erase and kill characters may be used to edit the regular +expression. +Erasing back past the first column cancels the search command. +.PP +.IP \fIi\|\fPn +search for the \fIi\|\fP-th occurrence of the last regular expression entered. +.PP +.IP !command +invoke a shell with \fIcommand\|\fP. +The character `!' in "command" are replaced with the +previous shell command. The sequence "\\!" is replaced by "!". +.PP +.IP ":q or :Q" +quit reading the current file; go on to the next (if any) +(same as q or Q). +.PP +.IP . +(dot) repeat the previous command. +.PP +The commands take effect immediately, i.e., it is not necessary to +type a carriage return. +Up to the time when the command character itself is given, +the user may hit the line kill character to cancel the numerical +argument being formed. +In addition, the user may hit the erase character to redisplay the +--More-- message. +.PP +At any time when output is being sent to the terminal, the user can +hit the quit key (normally control\-\\). +.I Zmore +will stop sending output, and will display the usual --More-- +prompt. +The user may then enter one of the above commands in the normal manner. +Unfortunately, some output is lost when this is done, due to the +fact that any characters waiting in the terminal's output queue +are flushed when the quit signal occurs. +.PP +The terminal is set to +.I noecho +mode by this program so that the output can be continuous. +What you type will thus not show on your terminal, except for the / and ! +commands. +.PP +If the standard output is not a teletype, then +.I zmore +acts just like +.I zcat, +except that a header is printed before each file. +.SH FILES +.DT +/etc/termcap Terminal data base +.SH "SEE ALSO" +more(1), gzip(1), zdiff(1), zgrep(1), znew(1), zforce(1), gzexe(1) diff --git a/tools/gzip-1.2.4/zmore.in b/tools/gzip-1.2.4/zmore.in new file mode 100755 index 00000000..0865167d --- /dev/null +++ b/tools/gzip-1.2.4/zmore.in @@ -0,0 +1,52 @@ +: +#!/bin/sh + +PATH="BINDIR:$PATH"; export PATH +if test "`echo -n a`" = "-n a"; then + # looks like a SysV system: + n1=''; n2='\c' +else + n1='-n'; n2='' +fi +oldtty=`stty -g 2>/dev/null` +if stty -cbreak 2>/dev/null; then + cb='cbreak'; ncb='-cbreak' +else + # 'stty min 1' resets eof to ^a on both SunOS and SysV! + cb='min 1 -icanon'; ncb='icanon eof ^d' +fi +if test $? -eq 0 -a -n "$oldtty"; then + trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15 +else + trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15 +fi + +if test $# = 0; then + if test -t 0; then + echo usage: zmore files... + else + gzip -cdfq | eval ${PAGER-more} + fi +else + FIRST=1 + for FILE + do + if test $FIRST -eq 0; then + echo $n1 "--More--(Next file: $FILE)$n2" + stty $cb -echo 2>/dev/null + ANS=`dd bs=1 count=1 2>/dev/null` + stty $ncb echo 2>/dev/null + echo " " + if test "$ANS" = 'e' -o "$ANS" = 'q'; then + exit + fi + fi + if test "$ANS" != 's'; then + echo "------> $FILE <------" + gzip -cdfq "$FILE" | eval ${PAGER-more} + fi + if test -t; then + FIRST=0 + fi + done +fi diff --git a/tools/gzip-1.2.4/znew.1 b/tools/gzip-1.2.4/znew.1 new file mode 100644 index 00000000..5cfb4724 --- /dev/null +++ b/tools/gzip-1.2.4/znew.1 @@ -0,0 +1,39 @@ +.TH ZNEW 1 +.SH NAME +znew \- recompress .Z files to .gz files +.SH SYNOPSIS +.B znew +[ -ftv9PK] [ name.Z ... ] +.SH DESCRIPTION +.I Znew +recompresses files from .Z (compress) format to .gz (gzip) format. +If you want to recompress a file already in gzip format, rename the file +to force a .Z extension then apply znew. +.SH OPTIONS +.TP +.B \-f +Force recompression from .Z to .gz format even if a .gz file already exists. +.TP +.B \-t +Tests the new files before deleting originals. +.TP +.B \-v +Verbose. Display the name and percentage reduction for each file compressed. +.TP +.B \-9 +Use the slowest compression method (optimal compression). +.TP +.B \-P +Use pipes for the conversion to reduce disk space usage. +.TP +.B \-K +Keep a .Z file when it is smaller than the .gz file +.SH "SEE ALSO" +gzip(1), zmore(1), zdiff(1), zgrep(1), zforce(1), gzexe(1), compress(1) +.SH BUGS +.I Znew +does not maintain the time stamp with the -P option if +.I cpmod(1) +is not available and +.I touch(1) +does not support the -r option. diff --git a/tools/gzip-1.2.4/znew.in b/tools/gzip-1.2.4/znew.in new file mode 100755 index 00000000..5b61471e --- /dev/null +++ b/tools/gzip-1.2.4/znew.in @@ -0,0 +1,146 @@ +: +#!/bin/sh + +PATH="BINDIR:$PATH"; export PATH +check=0 +pipe=0 +opt= +files= +keep=0 +res=0 +old=0 +new=0 +block=1024 +# block is the disk block size (best guess, need not be exact) + +warn="(does not preserve modes and timestamp)" +tmp=/tmp/zfoo.$$ +echo hi > $tmp.1 +echo hi > $tmp.2 +if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then + cpmod=${CPMOD-cpmod} + warn="" +fi + +if test -z "$cpmod" && ${TOUCH-touch} -r $tmp.1 $tmp.2 2>/dev/null; then + cpmod="${TOUCH-touch}" + cpmodarg="-r" + warn="(does not preserve file modes)" +fi + +# check if GZIP env. variable uses -S or --suffix +gzip -q $tmp.1 +ext=`echo $tmp.1* | sed "s|$tmp.1||"` +rm -f $tmp.[12]* +if test -z "$ext"; then + echo znew: error determining gzip extension + exit 1 +fi +if test "$ext" = ".Z"; then + echo znew: cannot use .Z as gzip extension. + exit 1 +fi + +for arg +do + case "$arg" in + -*) opt="$opt $arg"; shift;; + *) break;; + esac +done + +if test $# -eq 0; then + echo "recompress .Z files into $ext (gzip) files" + echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9KP]" file.Z... + echo " -t tests the new files before deleting originals" + echo " -v be verbose" + echo " -9 use the slowest compression method (optimal compression)" + echo " -K keep a .Z file when it is smaller than the $ext file" + echo " -P use pipes for the conversion $warn" + exit 1 +fi + +opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` +case "$opt" in + *t*) check=1; opt=`echo "$opt" | sed 's/t//g'` +esac +case "$opt" in + *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'` +esac +case "$opt" in + *P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'` +esac +if test -n "$opt"; then + opt="-$opt" +fi + +for i do + n=`echo $i | sed 's/.Z$//'` + if test ! -f "$n.Z" ; then + echo $n.Z not found + res=1; continue + fi + test $keep -eq 1 && old=`wc -c < "$n.Z"` + if test $pipe -eq 1; then + if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then + # Copy file attributes from old file to new one, if possible. + test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null + else + echo error while recompressing $n.Z + res=1; continue + fi + else + if test $check -eq 1; then + if cp -p "$n.Z" "$n.$$" 2> /dev/null || cp "$n.Z" "$n.$$"; then + : + else + echo cannot backup "$n.Z" + res=1; continue + fi + fi + if gzip -d "$n.Z"; then + : + else + test $check -eq 1 && mv "$n.$$" "$n.Z" + echo error while uncompressing $n.Z + res=1; continue + fi + if gzip $opt "$n"; then + : + else + if test $check -eq 1; then + mv "$n.$$" "$n.Z" && rm -f "$n" + echo error while recompressing $n + else + # compress $n (might be dangerous if disk full) + echo error while recompressing $n, left uncompressed + fi + res=1; continue + fi + fi + test $keep -eq 1 && new=`wc -c < "$n$ext"` + if test $keep -eq 1 -a `expr \( $old + $block - 1 \) / $block` -lt \ + `expr \( $new + $block - 1 \) / $block`; then + if test $pipe -eq 1; then + rm -f "$n$ext" + elif test $check -eq 1; then + mv "$n.$$" "$n.Z" && rm -f "$n$ext" + else + gzip -d "$n$ext" && compress "$n" && rm -f "$n$ext" + fi + echo "$n.Z smaller than $n$ext -- unchanged" + + elif test $check -eq 1; then + if gzip -t "$n$ext" ; then + rm -f "$n.$$" "$n.Z" + else + test $pipe -eq 0 && mv "$n.$$" "$n.Z" + rm -f "$n$ext" + echo error while testing $n$ext, $n.Z unchanged + res=1; continue + fi + elif test $pipe -eq 1; then + rm -f "$n.Z" + fi +done +exit $res diff --git a/tools/m2ctx.py b/tools/m2ctx.py new file mode 100755 index 00000000..8a0451f4 --- /dev/null +++ b/tools/m2ctx.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 + +import argparse +import os +import sys +import subprocess +from pathlib import Path + +script_dir = os.path.dirname(os.path.realpath(__file__)) +root_dir = os.path.abspath(os.path.join(script_dir, "..")) +src_dir = root_dir + "src/" + +# Project-specific +CPP_FLAGS = [ + "-Iinclude", + "-Iinclude/2.0L", + "-Iinclude/2.0L/PR", + "-Isrc", + "-Iver/current/build/include", + "-D_LANGUAGE_C", + "-D_FINALROM", + "-DF3DEX_GBI_2", + "-D_MIPS_SZLONG=32", + # "-DSCRIPT(...)={}", + # "-D__attribute__(...)=", + # "-D__asm__(...)=", + "-ffreestanding", +] + +def import_c_file(in_file) -> str: + in_file = os.path.relpath(in_file, root_dir) + cpp_command = ["gcc", "-E", "-P", "-dM", *CPP_FLAGS, in_file] + cpp_command2 = ["gcc", "-E", "-P", *CPP_FLAGS, in_file] + + out_text = "" + try: + out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") + out_text += subprocess.check_output(cpp_command2, cwd=root_dir, encoding="utf-8") + except subprocess.CalledProcessError: + print( + "Failed to preprocess input file, when running command:\n" + + cpp_command, + file=sys.stderr, + ) + sys.exit(1) + + if not out_text: + print("Output is empty - aborting") + sys.exit(1) + return out_text + +def main(): + parser = argparse.ArgumentParser( + description="""Create a context file which can be used for mips_to_c""" + ) + parser.add_argument( + "c_file", + help="""File from which to create context""", + ) + args = parser.parse_args() + + output = import_c_file(args.c_file) + + with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: + # Ixx: Yes I know this is hacky, but mips_to_c does not support it + # Also, is it actually 64? + f.write(output.replace("sizeof(long)", "32")) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tools/progress.py b/tools/progress.py new file mode 100644 index 00000000..356745a0 --- /dev/null +++ b/tools/progress.py @@ -0,0 +1,87 @@ +import argparse +import os +import re +import sys +import subprocess +import glob + +def get_functions(elffile, section, ending=None): + try: + result = subprocess.run(['objdump', '-x', elffile], stdout=subprocess.PIPE) + nm_lines = result.stdout.decode().split("\n") + except: + sys.stderr.write(f"Error: Could not run objdump on {elffile} - make sure that the project is built") + sys.exit(1) + + functions = {} + + for line in nm_lines: + if f"g F {section}" in line or "g F *ABS* " in line: + components = line.split() + size = int(components[4], 16) + name = components[5] + functions[name] = {"function": name, "length": size} + + return functions + +def generate_csv(functions, nonmatching_funcs, version, section): + ret = [] + ret.append("version,section,function,length,matching") + for func in functions: + length = functions[func]["length"] + if length > 0: + matching = "no" if func in nonmatching_funcs else "yes" + ret.append(f"{version},{section},{func},{length},{matching}") + return "\n".join(ret) + +def get_nonmatching_funcs(basedir, subcode): + grepstr = r'#pragma GLOBAL_ASM\(.*/\K.*(?=\.s)' + if subcode: + try: + funcs = set(subprocess.check_output(['grep', '-ohPR', grepstr, basedir + '/src/' + subcode]).decode('ascii').split()) + except subprocess.CalledProcessError as grepexc: + if grepexc.returncode != 1: + raise grepexc + funcs = set() + else: + args = ['grep', '-ohPs', '-d', 'skip', grepstr] + args.extend(glob.glob(basedir + '/src/*')) + try: + funcs = set(subprocess.check_output(args).decode('ascii').split()) + except subprocess.CalledProcessError as grepexc: + if grepexc.returncode != 1: + raise grepexc + funcs = set() + try: + funcs = funcs.union(set(subprocess.check_output(['grep', '-ohPR', grepstr, basedir + '/src/done']).decode('ascii').split())) + except subprocess.CalledProcessError as grepexc: + if grepexc.returncode != 1: + raise grepexc + return funcs + + +def main(basedir, elffile, section, ending, version, subcode): + functions = get_functions(elffile, section, ending) + section_name = section.split("_")[-1] # .code_game -> game + nonmatching_funcs = get_nonmatching_funcs(basedir, subcode) + csv = generate_csv(functions, nonmatching_funcs, version, section_name) + print(csv) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Create progress csv based on map file', + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('basedir', type=str, + help="base directory (containing src/)") + parser.add_argument('elffile', type=str, + help=".elf file to be read") + parser.add_argument('section', type=str, + help=".text section of the map") + parser.add_argument('--ending', type=str, + help="section name that marks the end of 'section'") + parser.add_argument('--version', type=str, default='us', + help="ROM version, us, eu, debug, ects") + parser.add_argument('--subcode', type=str, default=None, + help="Subcode for section to get progress of") + args = parser.parse_args() + + main(args.basedir, args.elffile, args.section, args.ending, args.version, args.subcode) \ No newline at end of file diff --git a/tools/progress_read.py b/tools/progress_read.py new file mode 100644 index 00000000..c6306da2 --- /dev/null +++ b/tools/progress_read.py @@ -0,0 +1,76 @@ +import argparse +import os +import re +import sys +import csv +import anybadge + +# Read using `mips-linux-gnu-readelf -S` +overlay_sizes = { + 'dk64_boot' : (0xE8B0 - 0x1000), + 'global_asm' : 0x149160 - # need to subtract mips3 file sizes, which haven't been migrated yet + # TODO remove these when the mips3 files are migrated!!! + (0x02C700 - 0x0166A0) - + (0x127B00 - 0x124780) - + (0x149160 - 0x145D70), + 'menu' : 0x00ef50, + 'multiplayer' : 0x002f70, + 'minecart' : 0x004b90, + 'race' : 0x00bb10, + 'bonus' : 0x009860, + 'water' : 0x0057f0, + 'arcade' : 0x00e220, + 'jetpac' : 0x007090, + 'boss' : 0x0118b0, +} + +def RGB_to_hex(RGB): + ''' [255,255,255] -> "#FFFFFF" ''' + # Components need to be integers for hex to make sense + RGB = [int(x) for x in RGB] + return "#"+"".join(["0{0:x}".format(v) if v < 16 else + "{0:x}".format(v) for v in RGB]) + +def main(csv_name, version, overlay): + with open(csv_name, mode='r') as csv_file: + csv_reader = csv.DictReader(csv_file) + line_count = 0 + total_func = 0 + incomplete_func = 0 + if overlay == 'total': + total_byte = sum(overlay_sizes.values()) + else: + total_byte = overlay_sizes[overlay] + incomplete_byte = 0 + for row in csv_reader: + if(row["version"] == version): + total_func += 1 + if row['matching'] != 'yes': + incomplete_func += 1 + incomplete_byte += int(row['length']) + done_byte = total_byte - incomplete_byte + done_func = total_func - incomplete_func + percent = ((done_byte/total_byte) * 100) + print("%s: bytes: %3.4f%% (%d/%d), nonstatic funcs: %3.4f%% (%d/%d)" % (overlay, percent, done_byte, total_byte,((done_func/total_func) *100), done_func, total_func )) + green = min(255, round(min(1, (percent / 100) * 2) * 224)) + red = min(255, round(min(1, ((100 - percent) / 100) * 2) * 224)) + color = RGB_to_hex([red, green, 0]) + if overlay == 'total': + badge = anybadge.Badge("Donkey Kong 64 (US)", "%3.4f%%" % (percent), default_color=color) + else: + badge = anybadge.Badge(overlay, "%3.4f%%" % (percent), default_color=color) + badge.write_badge('progress/progress_' + overlay + '.svg',overwrite=True) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Create progress csv based on map file', + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('csv_name', type=str, + help="csv to read") + parser.add_argument('ver_str', type=str, + help="version") + parser.add_argument('overlay', type=str, + help="overlay name") + args = parser.parse_args() + + main(args.csv_name, args.ver_str, args.overlay) diff --git a/tools/splat_inputs.py b/tools/splat_inputs.py new file mode 100755 index 00000000..e3064f85 --- /dev/null +++ b/tools/splat_inputs.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# Script to get a list of input files that are referenced by a splat file +import argparse +import sys +sys.path.append("./tools/n64splat") + +from split import * + +def main(config_path): + # Load config + with open(config_path) as f: + config = yaml.load(f.read(), Loader=yaml.SafeLoader) + + options.initialize(config, config_path, None, None) + options.set("modes", []) + options.set("verbose", False) + + all_segments = initialize_segments(config["segments"]) + + objs = "" + + for segment in all_segments: + linker_entries = segment.get_linker_entries() + for entry in linker_entries: + src_paths = entry.src_paths + for path in src_paths: + objs += str(path) + " " + + return objs + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Get objects for splat file', + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('yamls', nargs='+', help="Splat files") + args = parser.parse_args() + + obj_lists = map(main, args.yamls) + # map(print, obj_lists) + for obj_list in obj_lists: + print(obj_list) +