From 1148580550e16c8fa139d0dccb1328a01db7bb01 Mon Sep 17 00:00:00 2001 From: "H.M. Burger" <92937601+Onenutmcgee@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:29:23 -0600 Subject: [PATCH] Adding Demon servant overlay (#1915) --- Makefile | 14 +++++- Makefile.psx.mk | 2 +- README.md | 1 + config/check.us.sha | 1 + config/splat.us.tt_003.yaml | 45 ++++++++++++++++++ config/symbols.us.tt_003.txt | 20 ++++++++ src/servant/tt_003/demon.c | 88 ++++++++++++++++++++++++++++++++++++ tools/dups/src/main.rs | 7 +++ tools/progress.py | 1 + 9 files changed, 176 insertions(+), 3 deletions(-) create mode 100644 config/splat.us.tt_003.yaml create mode 100644 config/symbols.us.tt_003.txt create mode 100644 src/servant/tt_003/demon.c diff --git a/Makefile b/Makefile index 66aabe394..afbb0ea5e 100644 --- a/Makefile +++ b/Makefile @@ -144,7 +144,7 @@ extract: extract_$(VERSION) build: ##@ build game files build: build_$(VERSION) -build_us: main dra weapon ric cen dre mad no0 no3 np3 nz0 sel st0 wrp rwrp mar rbo3 tt_000 tt_001 tt_002 +build_us: main dra weapon ric cen dre mad no0 no3 np3 nz0 sel st0 wrp rwrp mar rbo3 tt_000 tt_001 tt_002 tt_003 build_hd: dra cen wrp tt_000 clean: ##@ clean extracted files, assets, and build artifacts git clean -fdx assets/ @@ -227,6 +227,7 @@ format-symbols: ./tools/symbols.py remove-orphans config/splat.hd.tt_000.yaml ./tools/symbols.py remove-orphans config/splat.us.tt_001.yaml ./tools/symbols.py remove-orphans config/splat.us.tt_002.yaml + ./tools/symbols.py remove-orphans config/splat.us.tt_003.yaml ./tools/symbols.py remove-orphans config/splat.us.stmad.yaml format-license: find src/ | grep -E '\.c$$|\.h$$' | grep -vE 'PsyCross|mednafen|psxsdk|3rd|saturn/lib' | python3 ./tools/lint-license.py - AGPL-3.0-or-later @@ -378,6 +379,13 @@ $(BUILD_DIR)/TT_002.BIN: $(BUILD_DIR)/tt_002_raw.bin cp $< $@ dd status=none if=/dev/zero bs=1 count=$$((40960 - $$(stat -c %s $<))) >> $@ +tt_003: $(BUILD_DIR)/TT_003.BIN +$(BUILD_DIR)/tt_003_raw.bin: $(BUILD_DIR)/tt_003.elf + $(OBJCOPY) -O binary $< $@ +$(BUILD_DIR)/TT_003.BIN: $(BUILD_DIR)/tt_003_raw.bin + cp $< $@ + dd status=none if=/dev/zero bs=1 count=$$((40960 - $$(stat -c %s $<))) >> $@ + mad_fix: stmad_dirs $$(call list_o_files,st/mad) $$(call list_o_files,st) $(LD) $(LD_FLAGS) -o $(BUILD_DIR)/stmad_fix.elf \ -Map $(BUILD_DIR)/stmad_fix.map \ @@ -489,6 +497,7 @@ force_symbols: ##@ Extract a full list of symbols from a successful build $(PYTHON) ./tools/symbols.py elf build/us/tt_000.elf > config/symbols.us.tt_000.txt $(PYTHON) ./tools/symbols.py elf build/us/tt_001.elf > config/symbols.us.tt_001.txt $(PYTHON) ./tools/symbols.py elf build/us/tt_002.elf > config/symbols.us.tt_002.txt + $(PYTHON) ./tools/symbols.py elf build/us/tt_003.elf > config/symbols.us.tt_003.txt context: ##@ create a context for decomp.me. Set the SOURCE variable prior to calling this target VERSION=$(VERSION) $(M2CTX) $(SOURCE) @@ -530,6 +539,7 @@ disk_prepare: build $(SOTNDISK) cp $(BUILD_DIR)/TT_000.BIN $(DISK_DIR)/SERVANT/TT_000.BIN cp $(BUILD_DIR)/TT_001.BIN $(DISK_DIR)/SERVANT/TT_001.BIN cp $(BUILD_DIR)/TT_002.BIN $(DISK_DIR)/SERVANT/TT_002.BIN + cp $(BUILD_DIR)/TT_003.BIN $(DISK_DIR)/SERVANT/TT_003.BIN disk: disk_prepare $(SOTNDISK) make build/sotn.$(VERSION).cue $(DISK_DIR) $(CONFIG_DIR)/disk.us.lba disk_debug: disk_prepare @@ -647,7 +657,7 @@ include tools/tools.mk .PHONY: all, clean, patch, check, build, expected .PHONY: format, ff, format-src, format-tools, format-symbols -.PHONY: main, dra, ric, cen, dre, mad, no3, np3, nz0, st0, wrp, rwrp, bomar, borbo3, tt_000, tt_001, tt_002 +.PHONY: main, dra, ric, cen, dre, mad, no3, np3, nz0, st0, wrp, rwrp, bomar, borbo3, tt_000, tt_001, tt_002, tt_003 .PHONY: %_dirs .PHONY: extract, extract_% .PHONY: update-dependencies python-dendencies diff --git a/Makefile.psx.mk b/Makefile.psx.mk index fd920d2ac..86c6f590e 100644 --- a/Makefile.psx.mk +++ b/Makefile.psx.mk @@ -11,7 +11,7 @@ PSX_RSTAGES := rwrp PSX_BOSTAGES := mar PSX_RBOSTAGES := rbo3 PSX_ALLSTAGES := $(addprefix st,$(PSX_KSTAGES)) $(addprefix st,$(PSX_RSTAGES)) $(addprefix bo,$(PSX_BOSTAGES)) $(addprefix bo,$(PSX_RBOSTAGES)) -PSX_SERVANTS := tt_000 tt_001 tt_002 +PSX_SERVANTS := tt_000 tt_001 tt_002 tt_003 PSX_US_TARGETS := main $(PSX_OVLS) $(PSX_ALLSTAGES) $(PSX_SERVANTS) PSX_HD_TARGETS := dra ric tt_000 stcen stwrp diff --git a/README.md b/README.md index 318f42916..0cd35ccd0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ This repo does not include any assets or assembly code necessary for compiling t | SERVANT/TT_000.BIN | ![code coverage TT_000.BIN](https://img.shields.io/endpoint?label=TT_000%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dtt_000) | ![decompiled functions](https://img.shields.io/endpoint?label=TT_000%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dtt_000) | Bat Familiar | SERVANT/TT_001.BIN | ![code coverage TT_001.BIN](https://img.shields.io/endpoint?label=TT_001%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dtt_001) | ![decompiled functions](https://img.shields.io/endpoint?label=TT_001%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dtt_001) | Ghost Familiar | SERVANT/TT_002.BIN | ![code coverage TT_002.BIN](https://img.shields.io/endpoint?label=TT_002%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dtt_002) | ![decompiled functions](https://img.shields.io/endpoint?label=TT_002%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dtt_002) | Faerie Familiar +| SERVANT/TT_003.BIN | ![code coverage TT_003.BIN](https://img.shields.io/endpoint?label=TT_003%20code&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Fcode%2F%3Fmode%3Dshield%26measure%3Dtt_003) | ![decompiled functions](https://img.shields.io/endpoint?label=TT_003%20funcs&url=https%3A%2F%2Fprogress.deco.mp%2Fdata%2Fsotn%2Fus%2Ffunctions%2F%3Fmode%3Dshield%26measure%3Dtt_003) | Demon Familiar Code coverage means how many bytes of code have been successfully converted from assembly into C code, while decomp function is how many functions have been successfully decompiled. diff --git a/config/check.us.sha b/config/check.us.sha index 34e2e2261..b92f4997b 100644 --- a/config/check.us.sha +++ b/config/check.us.sha @@ -29,3 +29,4 @@ c721a1d2bc6bdd9901801e792d23b5996d940b97 build/us/F_RBO3.BIN 82dd4ae1c4e3dc0fd483a49e5e4ab4fc5e25ada7 build/us/TT_000.BIN 326c9d2f9b9e2af678f5d63b30b31fba99ae75d4 build/us/TT_001.BIN 4589bb04fe475439c6d6e9b7273a8971ad859b4d build/us/TT_002.BIN +b54466dec3923d43bd08d71bec688da252153984 build/us/TT_003.BIN diff --git a/config/splat.us.tt_003.yaml b/config/splat.us.tt_003.yaml new file mode 100644 index 000000000..f7c92fb73 --- /dev/null +++ b/config/splat.us.tt_003.yaml @@ -0,0 +1,45 @@ +options: + platform: psx + basename: tt_003 + base_path: .. + build_path: build/us + target_path: disks/us/SERVANT/TT_003.BIN + asm_path: asm/us/servant/tt_003 + asset_path: assets/servant/tt_003 + src_path: src/servant/tt_003 + ld_script_path: build/us/tt_003.ld + compiler: GCC + symbol_addrs_path: + - config/symbols.us.txt + - config/symbols.us.tt_003.txt + undefined_funcs_auto_path: config/undefined_funcs_auto.us.tt_003.txt + undefined_syms_auto_path: config/undefined_syms_auto.us.tt_003.txt + find_file_boundaries: true + use_legacy_include_asm: false + migrate_rodata_to_functions: true + asm_jtbl_label_macro: jlabel + symbol_name_format: us_$VRAM + section_order: + - .data + - .rodata + - .text + - .bss + - .sbss + ld_bss_is_noload: false + disasm_unknown: true + include_macro_inc: false + disassemble_all: true +sha1: b54466dec3923d43bd08d71bec688da252153984 +segments: + - name: tt_003 + type: code + start: 0 + vram: 0x80170000 + align: 4 + subalign: 4 + subsegments: + - [0x0, data] + - [0x29DC, .rodata, demon] + - [0x2DC4, c, demon] + - [0x83C4, sbss] + - [0xA000] diff --git a/config/symbols.us.tt_003.txt b/config/symbols.us.tt_003.txt new file mode 100644 index 000000000..863760dc9 --- /dev/null +++ b/config/symbols.us.tt_003.txt @@ -0,0 +1,20 @@ +g_Events = 0x80172090; +g_PlaySfxStep = 0x801729C0; +g_EntityRanges = 0x801729C4; +g_EventQueue = 0x801729CC; +g_CurrentServant = 0x801729D0; +g_CurrentRoomX = 0x801729D4; +g_CurrentRoomY = 0x801729D8; +ServantUpdateAnim = 0x80177750; +DestroyEntity = 0x801778F8; +AccumulateTowardZero = 0x80177964; +SearchForEntityInRange = 0x8017799C; +CalculateAngleToEntity = 0x80177A1C; +GetTargetPositionWithDistanceBuffer = 0x80177A60; +CalculateDistance = 0x80177AD4; +ProcessSfxState = 0x80177B24; +ProcessEvent = 0x80177CFC; +CreateEventEntity = 0x801780D0; +IsMovementAllowed = 0x8017818C; +CheckAllEntitiesValid = 0x801782A4; +ServantUnk0 = 0x80178350; diff --git a/src/servant/tt_003/demon.c b/src/servant/tt_003/demon.c new file mode 100644 index 000000000..03f243c84 --- /dev/null +++ b/src/servant/tt_003/demon.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +#include "common.h" +#include "servant.h" +#include "sfx.h" + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80172DC4); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80172ED8); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80172EF8); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80173348); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_801737F0); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80173D14); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_801744CC); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_8017472C); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80174FD0); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_8017540C); + +void func_us_80175800(void) {} + +void func_us_80175808(void) {} + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80175810); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80175C08); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80175D20); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80176544); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80176564); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_801765A0); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80176814); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80176C1C); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_801771B0); + +INCLUDE_ASM("servant/tt_003/nonmatchings/demon", func_us_80177690); + +#ifndef VERSION_PSP +#include "../servant_update_anim.h" +#endif + +#include "../../destroy_entity.h" + +#ifndef VERSION_PSP +#include "../accumulate_toward_zero.h" +#include "../search_for_entity_in_range.h" +#endif + +#include "../calculate_angle_to_entity.h" + +#include "../get_target_position_with_distance_buffer.h" + +#ifndef VERSION_PSP +#include "../calculate_distance.h" +#include "../play_sfx.h" +#endif + +#include "../process_event.h" + +#include "../create_event_entity.h" + +#include "../is_movement_allowed.h" + +#ifndef VERSION_PSP +#include "../check_all_entities_valid.h" +#endif + +#include "../servant_unk0.h" + +INCLUDE_RODATA("servant/tt_003/nonmatchings/demon", func_us_80172A68); + +INCLUDE_RODATA("servant/tt_003/nonmatchings/demon", func_us_80172A9C); + +INCLUDE_RODATA("servant/tt_003/nonmatchings/demon", func_us_80172D50); + +INCLUDE_RODATA("servant/tt_003/nonmatchings/demon", func_us_80172DBC); diff --git a/tools/dups/src/main.rs b/tools/dups/src/main.rs index 467b678e8..9a5239e6d 100644 --- a/tools/dups/src/main.rs +++ b/tools/dups/src/main.rs @@ -286,6 +286,13 @@ fn do_dups_report(output_file: Option, threshold: f64) { include_asm: get_all_include_asm("../../src/servant/tt_002"), path_matcher: "/tt_002/".to_string(), }, + SrcAsmPair { + asm_dir: String::from("../../asm/us/servant/tt_003/matchings/"), + src_dir: String::from("../../src/servant/tt_003"), + overlay_name: String::from("TT_003"), + include_asm: get_all_include_asm("../../src/servant/tt_003"), + path_matcher: "/tt_003/".to_string(), + }, SrcAsmPair { asm_dir: String::from("../../asm/us/st/cen/matchings/"), src_dir: String::from("../../src/st/cen/"), diff --git a/tools/progress.py b/tools/progress.py index 11f0951ef..5411f5441 100755 --- a/tools/progress.py +++ b/tools/progress.py @@ -411,6 +411,7 @@ if __name__ == "__main__": progress["tt_000"] = DecompProgressStats("tt_000", "servant/tt_000") progress["tt_001"] = DecompProgressStats("tt_001", "servant/tt_001") progress["tt_002"] = DecompProgressStats("tt_002", "servant/tt_002") + progress["tt_003"] = DecompProgressStats("tt_003", "servant/tt_003") hydrate_previous_metrics(progress, args.version) progress = remove_not_existing_overlays(progress)