sotn-decomp/Makefile

520 lines
22 KiB
Makefile
Raw Normal View History

2022-02-23 18:17:18 +00:00
.SECONDEXPANSION:
2022-03-02 00:38:54 +00:00
.SECONDARY:
2022-02-23 18:17:18 +00:00
2022-01-01 17:45:41 +00:00
# Binaries
VERSION ?= us
2022-01-01 17:45:41 +00:00
MAIN := main
DRA := dra
# Compilers
CC1PSX := ./bin/cc1-psx-26
2022-01-01 17:45:41 +00:00
CROSS := mipsel-linux-gnu-
AS := $(CROSS)as
2023-04-05 18:08:14 +00:00
CC := $(CC1PSX)
2022-01-01 17:45:41 +00:00
LD := $(CROSS)ld
CPP := $(CROSS)cpp
2022-01-01 17:45:41 +00:00
OBJCOPY := $(CROSS)objcopy
CC_FLAGS += -G0 -w -O2 -funsigned-char -fpeephole -ffunction-cse -fpcc-struct-return -fcommon -fverbose-asm -msoft-float -g
CPP_FLAGS += -Iinclude -Iinclude/psxsdk -undef -Wall -fno-builtin
CPP_FLAGS += -Dmips -D__GNUC__=2 -D__OPTIMIZE__ -D__mips__ -D__mips -Dpsx -D__psx__ -D__psx -D_PSYQ -D__EXTENSIONS__ -D_MIPSEL -D_LANGUAGE_C -DLANGUAGE_C -DNO_LOGS -DHACKS -DUSE_INCLUDE_ASM
CPP_FLAGS += -D_internal_version_$(VERSION) -DSOTN_STR
LD_FLAGS := -nostdlib --no-check-sections
2022-01-01 17:45:41 +00:00
# Directories
ASM_DIR := asm/$(VERSION)
BIN_DIR := bin
2022-01-01 17:45:41 +00:00
SRC_DIR := src
ASSETS_DIR := assets
INCLUDE_DIR := include
2023-02-21 20:06:27 +00:00
BUILD_DIR := build/$(VERSION)
2023-02-21 23:25:24 +00:00
DISK_DIR := $(BUILD_DIR)/${VERSION}/disk
2022-01-01 17:45:41 +00:00
CONFIG_DIR := config
TOOLS_DIR := tools
PSXLIBS := $(addprefix lib, c c2 api etc card gpu gs gte cd snd spu)
2022-01-01 17:45:41 +00:00
# Files
PSXLIB_DIRS := $(addprefix psxsdk/, . $(PSXLIBS))
PSXLIB_DATA_DIRS := $(addprefix data/, . $(PSXLIB_DIRS))
MAIN_ASM_DIRS := $(addprefix $(ASM_DIR)/$(MAIN)/,. $(PSXLIB_DIRS) data $(PSXLIB_DATA_DIRS))
MAIN_SRC_DIRS := $(addprefix $(SRC_DIR)/$(MAIN)/,. $(PSXLIB_DIRS))
MAIN_S_FILES := $(wildcard $(addsuffix /*.s, $(MAIN_ASM_DIRS)))
MAIN_C_FILES := $(wildcard $(addsuffix /*.c, $(MAIN_SRC_DIRS)))
MAIN_O_FILES := $(patsubst %.s,%.s.o,$(MAIN_S_FILES))
MAIN_O_FILES += $(patsubst %.c,%.c.o,$(MAIN_C_FILES))
MAIN_O_FILES := $(addprefix $(BUILD_DIR)/,$(MAIN_O_FILES))
2022-01-01 17:45:41 +00:00
MAIN_TARGET := $(BUILD_DIR)/$(MAIN)
# Tooling
PYTHON := python3
SPLAT := splat split
2022-10-14 20:19:34 +00:00
ASMDIFFER_DIR := $(TOOLS_DIR)/asm-differ
ASMDIFFER_APP := $(ASMDIFFER_DIR)/diff.py
2022-10-15 10:18:32 +00:00
M2CTX_APP := $(TOOLS_DIR)/m2ctx.py
M2CTX := $(PYTHON) $(M2CTX_APP)
2022-10-15 10:45:20 +00:00
M2C_DIR := $(TOOLS_DIR)/m2c
M2C_APP := $(M2C_DIR)/m2c.py
M2C := $(PYTHON) $(M2C_APP)
M2C_ARGS := -P 4
SOTNSTR := $(PYTHON) $(TOOLS_DIR)/sotn_str/sotn_str.py process
2023-06-17 11:29:42 +00:00
MASPSX_DIR := $(TOOLS_DIR)/maspsx
MASPSX_APP := $(MASPSX_DIR)/maspsx.py
MASPSX := $(PYTHON) $(MASPSX_APP) --expand-div --aspsx-version=2.34
MASPSX_21 := $(PYTHON) $(MASPSX_APP) --expand-div --aspsx-version=2.21
GO := $(HOME)/go/bin/go
GOPATH := $(HOME)/go
SOTNDISK := $(GOPATH)/bin/sotn-disk
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
SOTNASSETS := $(GOPATH)/bin/sotn-assets
GFXSTAGE := $(PYTHON) $(TOOLS_DIR)/gfxstage.py
PNG2S := $(PYTHON) $(TOOLS_DIR)/png2s.py
ICONV := iconv --from-code=UTF-8 --to-code=Shift-JIS
DIRT_PATCHER := $(PYTHON) $(TOOLS_DIR)/dirt_patcher.py
2022-01-01 17:45:41 +00:00
2022-02-23 18:17:18 +00:00
define list_src_files
$(foreach dir,$(ASM_DIR)/$(1),$(wildcard $(dir)/**.s))
$(foreach dir,$(ASM_DIR)/$(1)/data,$(wildcard $(dir)/**.s))
$(foreach dir,$(ASM_DIR)/$(1)/psxsdk,$(wildcard $(dir)/**.s))
$(foreach dir,$(ASM_DIR)/$(1)/handwritten,$(wildcard $(dir)/**.s))
2022-02-23 18:17:18 +00:00
$(foreach dir,$(SRC_DIR)/$(1),$(wildcard $(dir)/**.c))
$(foreach dir,$(SRC_DIR)/$(1)/psxsdk,$(wildcard $(dir)/**.c))
$(foreach dir,$(ASSETS_DIR)/$(1),$(wildcard $(dir)/**))
2022-02-23 18:17:18 +00:00
endef
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
define list_st_src_files
$(foreach dir,$(ASM_DIR)/$(1),$(wildcard $(dir)/**.s))
$(foreach dir,$(ASM_DIR)/$(1)/data,$(wildcard $(dir)/**.s))
$(foreach dir,$(SRC_DIR)/$(1),$(wildcard $(dir)/**.c))
$(foreach dir,$(ASSETS_DIR)/$(1),$(wildcard $(dir)/D_8018*.bin))
endef
2022-02-23 18:17:18 +00:00
define list_o_files
$(foreach file,$(call list_src_files,$(1)),$(BUILD_DIR)/$(file).o)
endef
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
define list_st_o_files
$(foreach file,$(call list_st_src_files,$(1)),$(BUILD_DIR)/$(file).o)
endef
define list_shared_src_files
$(foreach dir,$(SRC_DIR)/$(1),$(wildcard $(dir)/*.c))
endef
define list_shared_o_files
$(foreach file,$(call list_shared_src_files,$(1)),$(BUILD_DIR)/$(file).o)
endef
2022-02-23 18:17:18 +00:00
define link
$(LD) $(LD_FLAGS) -o $(2) \
2022-02-23 18:17:18 +00:00
-Map $(BUILD_DIR)/$(1).map \
Enhance make extract on PSX (#662) Previously if either the YAML or the symbol list were changed, we were forced to either manually delete the `asm` folder of the specific overlay or to invoke `make clean`, where the latter forced us to re-extract all the overlays via `make -j extract`. That changes with this PR. How `make` works is `target: dep1 dep2` where if one of the dependencies has the last modified date greater than the target, the rule is triggered again. Previously we were extracting overlays doing `make extract_stcen`. But since every overlay extraction generates a linker script I now changed the rules to do `make build/us/stcen.ld` to extract the same overlay. As I explained above, if either the YAML or one of the related symbols changes, the linker modified date will be older and the extraction for that overlay to be trigger again. The above allowed me to stop polluting the repo root with the linker scripts as they are now moved into `build/us` or `build/hd` depending of what you're trying to build. If you do `make extract` twice in a row you will be welcomed with a `make: Nothing to be done for 'extract'.`. There are still some instances where you **might** need `make clean` beforehand, especially when modifying the `segment` section in the YAML or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I want to see if the current solution will be enough. ### Please try removing `make clean` from your workflow, once this is merged, to quickly detect possible problems with this new approach. I am also planning to make more substantial changes on our build-chain like this PR or #660 in the future. I am aiming to small incremental changes over time in case I break someone's flow or detect design flaws. I am also considering the breaking changes introduced in make 4.4, which will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a deadline to finish all the new build-chain work. --------- Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 08:26:29 +00:00
-T $(BUILD_DIR)/$(1).ld \
-T $(CONFIG_DIR)/undefined_syms.$(VERSION).txt \
-T $(CONFIG_DIR)/undefined_syms_auto.$(VERSION).$(1).txt \
-T $(CONFIG_DIR)/undefined_funcs_auto.$(VERSION).$(1).txt
2022-02-23 18:17:18 +00:00
endef
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
SOTNDISK_SOURCES := $(shell find tools/sotn-disk -name '*.go')
SOTNASSETS_SOURCES := $(shell find tools/sotn-assets -name '*.go')
CHECK_FILES := $(shell cut -d' ' -f3 config/check.$(VERSION).sha)
Enhance make extract on PSX (#662) Previously if either the YAML or the symbol list were changed, we were forced to either manually delete the `asm` folder of the specific overlay or to invoke `make clean`, where the latter forced us to re-extract all the overlays via `make -j extract`. That changes with this PR. How `make` works is `target: dep1 dep2` where if one of the dependencies has the last modified date greater than the target, the rule is triggered again. Previously we were extracting overlays doing `make extract_stcen`. But since every overlay extraction generates a linker script I now changed the rules to do `make build/us/stcen.ld` to extract the same overlay. As I explained above, if either the YAML or one of the related symbols changes, the linker modified date will be older and the extraction for that overlay to be trigger again. The above allowed me to stop polluting the repo root with the linker scripts as they are now moved into `build/us` or `build/hd` depending of what you're trying to build. If you do `make extract` twice in a row you will be welcomed with a `make: Nothing to be done for 'extract'.`. There are still some instances where you **might** need `make clean` beforehand, especially when modifying the `segment` section in the YAML or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I want to see if the current solution will be enough. ### Please try removing `make clean` from your workflow, once this is merged, to quickly detect possible problems with this new approach. I am also planning to make more substantial changes on our build-chain like this PR or #660 in the future. I am aiming to small incremental changes over time in case I break someone's flow or detect design flaws. I am also considering the breaking changes introduced in make 4.4, which will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a deadline to finish all the new build-chain work. --------- Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 08:26:29 +00:00
.PHONY: build
2022-10-26 06:41:13 +00:00
all: build check
build: build_$(VERSION)
build_us: main dra weapon ric cen dre mad no3 np3 nz0 sel st0 wrp rwrp mar tt_000
build_hd: dra $(BUILD_DIR)/WRP.BIN tt_000
2022-01-01 17:45:41 +00:00
clean:
git clean -fdx assets/
git clean -fdx asm/$(VERSION)/
git clean -fdx build/$(VERSION)/
Weapon assets and statically linked (#1470) Allow to compile weapon overlays as a single C files. The benefit is to disallow symbols to be exported by statically compile them all but the header. We would no longer need to use `OVL_EXPORT` as long as the symbols are marked as `static`. The frames data is also generated as an array of data that can be just included into their respective C files, generated by JSON files on the fly. I changed `animset` to `frameset` as the data does not represent a set of animations but rather a set of frames, where every frame has multiple sprites. The information on how the frames are played (e.g. animation) is found elsewhere. Following the full list of changes to achieve this project: * The `animset` from splat is now dummied out * The `frameset` JSON is now generated by the asset manager * The `frameset` JSON is now compiled into `src/weapon/w_0xx_y.h` * The `header.c` has been moved into `shared.h` * For simplicity I added a `#define g_Animset w_000_1`. I did not want to hack the asset manager too much to force the name to be `g_Animset` and I did not want to change all the symbols yet. * Simplified `weapon_pc.c` as we now only need the exported header * Always try to build the most up-to-date asset manager: this should avoid weird errors whenever people pull new changes As the asset manager now can accept those `config` files, now the CLI supports the following commands: * `stage extract` * `stage build` * `config extract` (NEW) * `config build` (NEW) The config structure is heavily inspired to Splat to maintain consistency and continuity.
2024-08-08 23:57:26 +00:00
git clean -fdx $(SRC_DIR)/weapon
2022-10-16 08:10:43 +00:00
git clean -fdx config/
git clean -fdx function_calls/
git clean -fdx sotn_calltree.txt
Add AGPL license (#1565) From the [public announcement](https://discord.com/channels/1079389589950705684/1079395108501331990/1276310695964835910) on Discord: > We've been progressing very far with the project and I started wondering what would be the best course of action to protect the work of existing and future contributors. I personally consider contributions to a decompilation project as creative work. Therefore it is my desire to protect this creative work from being re-claimed by other people. This is especially true in the light of the ability of modding the existing decompiled code and create derivative work. > > I talked privately with the current most active contributors. And me, @sozud , @bismurphy and @joshlory so far agreed on pushing through the AGPLv3 license for all the decompiled code in `sotn-decomp/src`, excluding any third party code and decompiled code from the PSX SDK. But I've been wanting to ask all of you if you are fine your code to be licensed and protected under the AGPLv3 terms. > > https://raw.githubusercontent.com/Xeeynamo/sotn-decomp/89686514916cabd0dd88ae0387f749a889c19e05/src/LICENSE > > I put and all the contributors, which can be accessed to the page https://github.com/Xeeynamo/sotn-decomp/graphs/contributors . Again, this will work for existing and future contributors. In the license I put my full name as I will be responsible of any legality. And I understand not every contributor wants to disclose their identity. Please give an approval to my latest PR if you do not have any objection. If not, please write here publicly. > > PS. I understand past contributors will either not see the message above or decide to ignore it. If I do not hear from anyone of the contributors for more than one week between those who did not interact with me or the server, I will still go ahead and apply the license. It is not in my intention to ignore past contributors. But I do not want contributors who have been inactive for months or years to be a blocker. Please do not mistake this as an act of malevolence. --------- Co-authored-by: Joey Murphy <tjmurphy@mit.edu>
2024-09-06 20:14:55 +00:00
format: format-src format-tools format-symbols format-license
format-src: bin/clang-format
cargo run --release --manifest-path ./tools/lints/sotn-lint/Cargo.toml ./src
@# find explainer:
@# find $(SRC_DIR) $(INCLUDE_DIR) : look in src and include
@# -type d \( -name 3rd -o -name CMakeFiles \) -prune : if an entry is both a directory and 3rd or CMakeFiles
@# ignore it and don't traverse it
@# -o \( -type f \( -name '*.h' -o -name '*.c' \) \) : or if an entry is a file and named *.h or *.c, include it
@# -print0 : print only the matching entries, delimit by NULL to
@# ensure files with characters xargs uses as delimiters are
@# properly handled
find $(SRC_DIR) $(INCLUDE_DIR) \
-type d \( -name 3rd -o -name CMakeFiles \) -prune \
-o \( -type f \( -name '*.c' -o -name '*.h' \) \) \
-print0 \
| xargs -0 -n10 -P$$(nproc) bin/clang-format -i
format-tools:
2023-07-25 17:31:49 +00:00
black tools/*.py
black tools/splat_ext/*.py
black tools/split_jpt_yaml/*.py
format-symbols:
2023-07-02 23:17:21 +00:00
VERSION=us $(PYTHON) ./tools/symbols.py sort
VERSION=hd $(PYTHON) ./tools/symbols.py sort
VERSION=pspeu $(PYTHON) ./tools/symbols.py sort
./tools/symbols.py remove-orphans config/splat.us.dra.yaml
./tools/symbols.py remove-orphans config/splat.hd.dra.yaml
./tools/symbols.py remove-orphans config/splat.us.ric.yaml
./tools/symbols.py remove-orphans config/splat.us.stcen.yaml
./tools/symbols.py remove-orphans config/splat.us.stdre.yaml
./tools/symbols.py remove-orphans config/splat.us.stno3.yaml
./tools/symbols.py remove-orphans config/splat.us.stnp3.yaml
./tools/symbols.py remove-orphans config/splat.us.stnz0.yaml
./tools/symbols.py remove-orphans config/splat.us.stsel.yaml
./tools/symbols.py remove-orphans config/splat.us.stst0.yaml
./tools/symbols.py remove-orphans config/splat.us.stwrp.yaml
./tools/symbols.py remove-orphans config/splat.hd.stwrp.yaml
./tools/symbols.py remove-orphans config/splat.us.strwrp.yaml
./tools/symbols.py remove-orphans config/splat.us.bomar.yaml
./tools/symbols.py remove-orphans config/splat.us.tt_000.yaml
./tools/symbols.py remove-orphans config/splat.hd.tt_000.yaml
./tools/symbols.py remove-orphans config/splat.us.stmad.yaml
Add AGPL license (#1565) From the [public announcement](https://discord.com/channels/1079389589950705684/1079395108501331990/1276310695964835910) on Discord: > We've been progressing very far with the project and I started wondering what would be the best course of action to protect the work of existing and future contributors. I personally consider contributions to a decompilation project as creative work. Therefore it is my desire to protect this creative work from being re-claimed by other people. This is especially true in the light of the ability of modding the existing decompiled code and create derivative work. > > I talked privately with the current most active contributors. And me, @sozud , @bismurphy and @joshlory so far agreed on pushing through the AGPLv3 license for all the decompiled code in `sotn-decomp/src`, excluding any third party code and decompiled code from the PSX SDK. But I've been wanting to ask all of you if you are fine your code to be licensed and protected under the AGPLv3 terms. > > https://raw.githubusercontent.com/Xeeynamo/sotn-decomp/89686514916cabd0dd88ae0387f749a889c19e05/src/LICENSE > > I put and all the contributors, which can be accessed to the page https://github.com/Xeeynamo/sotn-decomp/graphs/contributors . Again, this will work for existing and future contributors. In the license I put my full name as I will be responsible of any legality. And I understand not every contributor wants to disclose their identity. Please give an approval to my latest PR if you do not have any objection. If not, please write here publicly. > > PS. I understand past contributors will either not see the message above or decide to ignore it. If I do not hear from anyone of the contributors for more than one week between those who did not interact with me or the server, I will still go ahead and apply the license. It is not in my intention to ignore past contributors. But I do not want contributors who have been inactive for months or years to be a blocker. Please do not mistake this as an act of malevolence. --------- Co-authored-by: Joey Murphy <tjmurphy@mit.edu>
2024-09-06 20:14:55 +00:00
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
python3 ./tools/lint-license.py include/game.h AGPL-3.0-or-later
python3 ./tools/lint-license.py include/entity.h AGPL-3.0-or-later
python3 ./tools/lint-license.py include/items.h AGPL-3.0-or-later
python3 ./tools/lint-license.py include/lba.h AGPL-3.0-or-later
python3 ./tools/lint-license.py include/memcard.h AGPL-3.0-or-later
# fast-format
ff: MAKEFLAGS += --jobs
ff:
$(MAKE) format
patch:
$(DIRT_PATCHER) config/dirt.$(VERSION).json
check: config/check.$(VERSION).sha patch $(CHECK_FILES)
sha1sum --check $<
expected: check
mkdir -p expected/build
rm -rf expected/build/$(VERSION)
cp -r build/$(VERSION) expected/build/
2022-01-01 17:45:41 +00:00
main: $(MAIN_TARGET).exe
2022-01-01 17:45:41 +00:00
main_dirs:
$(foreach dir,$(MAIN_ASM_DIRS) $(MAIN_SRC_DIRS),$(shell mkdir -p $(BUILD_DIR)/$(dir)))
$(MAIN_TARGET).exe: $(MAIN_TARGET).elf
2022-10-16 09:31:54 +00:00
$(OBJCOPY) -O binary $< $@
$(MAIN_TARGET).elf: $(MAIN_O_FILES) $(BUILD_DIR)/main.ld $(CONFIG_DIR)/undefined_syms.$(VERSION).txt $(CONFIG_DIR)/undefined_syms_auto.$(VERSION).$(MAIN).txt
$(LD) $(LD_FLAGS) -o $@ \
2022-01-01 17:45:41 +00:00
-Map $(MAIN_TARGET).map \
Enhance make extract on PSX (#662) Previously if either the YAML or the symbol list were changed, we were forced to either manually delete the `asm` folder of the specific overlay or to invoke `make clean`, where the latter forced us to re-extract all the overlays via `make -j extract`. That changes with this PR. How `make` works is `target: dep1 dep2` where if one of the dependencies has the last modified date greater than the target, the rule is triggered again. Previously we were extracting overlays doing `make extract_stcen`. But since every overlay extraction generates a linker script I now changed the rules to do `make build/us/stcen.ld` to extract the same overlay. As I explained above, if either the YAML or one of the related symbols changes, the linker modified date will be older and the extraction for that overlay to be trigger again. The above allowed me to stop polluting the repo root with the linker scripts as they are now moved into `build/us` or `build/hd` depending of what you're trying to build. If you do `make extract` twice in a row you will be welcomed with a `make: Nothing to be done for 'extract'.`. There are still some instances where you **might** need `make clean` beforehand, especially when modifying the `segment` section in the YAML or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I want to see if the current solution will be enough. ### Please try removing `make clean` from your workflow, once this is merged, to quickly detect possible problems with this new approach. I am also planning to make more substantial changes on our build-chain like this PR or #660 in the future. I am aiming to small incremental changes over time in case I break someone's flow or detect design flaws. I am also considering the breaking changes introduced in make 4.4, which will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a deadline to finish all the new build-chain work. --------- Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 08:26:29 +00:00
-T $(BUILD_DIR)/main.ld \
2023-06-12 05:04:25 +00:00
-T $(CONFIG_DIR)/undefined_syms.$(VERSION).txt \
-T $(CONFIG_DIR)/undefined_syms_auto.$(VERSION).$(MAIN).txt
2022-01-01 17:45:41 +00:00
dra: $(BUILD_DIR)/DRA.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/DRA.BIN: $(BUILD_DIR)/$(DRA).elf
2022-01-01 17:45:41 +00:00
$(OBJCOPY) -O binary $< $@
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/$(DRA).elf: $(call list_o_files,dra)
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
echo $(call list_o_files,dra)
2022-02-23 18:17:18 +00:00
$(call link,dra,$@)
2022-01-01 17:45:41 +00:00
ric: $(BUILD_DIR)/RIC.BIN
2022-03-07 22:46:43 +00:00
$(BUILD_DIR)/RIC.BIN: $(BUILD_DIR)/ric.elf
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/ric.elf: $(call list_o_files,ric)
$(call link,ric,$@)
cen: $(BUILD_DIR)/CEN.BIN $(BUILD_DIR)/F_CEN.BIN
2022-10-28 22:46:47 +00:00
$(BUILD_DIR)/CEN.BIN: $(BUILD_DIR)/stcen.elf
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_CEN.BIN:
$(GFXSTAGE) e assets/st/cen $@
2022-10-28 22:46:47 +00:00
dre: $(BUILD_DIR)/DRE.BIN $(BUILD_DIR)/F_DRE.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/DRE.BIN: $(BUILD_DIR)/stdre.elf
2022-02-09 12:49:33 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_DRE.BIN:
$(GFXSTAGE) e assets/st/dre $@
2022-02-09 12:49:33 +00:00
mad: $(BUILD_DIR)/MAD.BIN $(BUILD_DIR)/F_MAD.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/MAD.BIN: $(BUILD_DIR)/stmad.elf
2022-01-20 22:02:05 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_MAD.BIN:
$(GFXSTAGE) e assets/st/mad $@
2022-01-20 22:02:05 +00:00
no3: $(BUILD_DIR)/NO3.BIN $(BUILD_DIR)/F_NO3.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/NO3.BIN: $(BUILD_DIR)/stno3.elf
2022-01-20 22:02:05 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_NO3.BIN:
$(GFXSTAGE) e assets/st/no3 $@
2022-01-20 22:02:05 +00:00
np3: $(BUILD_DIR)/NP3.BIN $(BUILD_DIR)/F_NP3.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/NP3.BIN: $(BUILD_DIR)/stnp3.elf
2022-02-05 17:16:17 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_NP3.BIN:
$(GFXSTAGE) e assets/st/np3 $@
2022-02-05 17:16:17 +00:00
nz0: $(BUILD_DIR)/NZ0.BIN $(BUILD_DIR)/F_NZ0.BIN
$(BUILD_DIR)/NZ0.BIN: $(BUILD_DIR)/stnz0.elf
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_NZ0.BIN:
$(GFXSTAGE) e assets/st/nz0 $@
sel: $(BUILD_DIR)/SEL.BIN
2022-12-21 16:33:15 +00:00
$(BUILD_DIR)/SEL.BIN: $(BUILD_DIR)/stsel.elf
$(OBJCOPY) -O binary $< $@
st0: $(BUILD_DIR)/ST0.BIN $(BUILD_DIR)/F_ST0.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/ST0.BIN: $(BUILD_DIR)/stst0.elf
2022-02-09 12:49:33 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_ST0.BIN:
$(GFXSTAGE) e assets/st/st0 $@
2022-02-09 12:49:33 +00:00
wrp: $(BUILD_DIR)/WRP.BIN $(BUILD_DIR)/F_WRP.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/WRP.BIN: $(BUILD_DIR)/stwrp.elf
2022-02-09 12:49:33 +00:00
$(OBJCOPY) -O binary $< $@
2023-03-10 03:59:33 +00:00
$(BUILD_DIR)/F_WRP.BIN:
$(GFXSTAGE) e assets/st/wrp $@
2022-02-09 12:49:33 +00:00
rwrp: $(BUILD_DIR)/RWRP.BIN $(BUILD_DIR)/F_RWRP.BIN
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/RWRP.BIN: $(BUILD_DIR)/strwrp.elf
2022-02-09 12:49:33 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_RWRP.BIN:
$(GFXSTAGE) e assets/st/rwrp $@
2022-02-09 12:49:33 +00:00
mar: $(BUILD_DIR)/MAR.BIN $(BUILD_DIR)/F_MAR.BIN
$(BUILD_DIR)/MAR.BIN: $(BUILD_DIR)/bomar.elf
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/F_MAR.BIN:
$(GFXSTAGE) e assets/boss/mar $@
tt_000: $(BUILD_DIR)/TT_000.BIN
$(BUILD_DIR)/tt_000_raw.bin: $(BUILD_DIR)/tt_000.elf
2023-02-08 14:03:44 +00:00
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/TT_000.BIN: $(BUILD_DIR)/tt_000_raw.bin
cp $< $@
dd status=none if=/dev/zero bs=1 count=$$((40960 - $$(stat -c %s $<))) >> $@
2023-02-08 14:03:44 +00:00
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 \
Enhance make extract on PSX (#662) Previously if either the YAML or the symbol list were changed, we were forced to either manually delete the `asm` folder of the specific overlay or to invoke `make clean`, where the latter forced us to re-extract all the overlays via `make -j extract`. That changes with this PR. How `make` works is `target: dep1 dep2` where if one of the dependencies has the last modified date greater than the target, the rule is triggered again. Previously we were extracting overlays doing `make extract_stcen`. But since every overlay extraction generates a linker script I now changed the rules to do `make build/us/stcen.ld` to extract the same overlay. As I explained above, if either the YAML or one of the related symbols changes, the linker modified date will be older and the extraction for that overlay to be trigger again. The above allowed me to stop polluting the repo root with the linker scripts as they are now moved into `build/us` or `build/hd` depending of what you're trying to build. If you do `make extract` twice in a row you will be welcomed with a `make: Nothing to be done for 'extract'.`. There are still some instances where you **might** need `make clean` beforehand, especially when modifying the `segment` section in the YAML or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I want to see if the current solution will be enough. ### Please try removing `make clean` from your workflow, once this is merged, to quickly detect possible problems with this new approach. I am also planning to make more substantial changes on our build-chain like this PR or #660 in the future. I am aiming to small incremental changes over time in case I break someone's flow or detect design flaws. I am also considering the breaking changes introduced in make 4.4, which will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a deadline to finish all the new build-chain work. --------- Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 08:26:29 +00:00
-T $(BUILD_DIR)/stmad.ld \
2023-06-12 05:04:25 +00:00
-T $(CONFIG_DIR)/undefined_syms.$(VERSION).txt \
-T $(CONFIG_DIR)/undefined_syms_auto.stmad.txt \
-T $(CONFIG_DIR)/undefined_funcs_auto.stmad.txt
$(OBJCOPY) -O binary $(BUILD_DIR)/stmad_fix.elf $(BUILD_DIR)/MAD.BIN
2022-03-05 02:45:54 +00:00
2023-02-08 14:03:44 +00:00
tt_%_dirs:
$(foreach dir,$(ASM_DIR)/servant/tt_$* $(ASM_DIR)/servant/tt_$*/data $(SRC_DIR)/servant/tt_$* $(ASSETS_DIR)/servant/tt_$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))
bo%_dirs:
$(foreach dir,$(ASM_DIR)/boss/$* $(ASM_DIR)/boss/$*/data $(ASM_DIR)/boss/$*/handwritten $(SRC_DIR)/boss/$* $(ASSETS_DIR)/boss/$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))
2022-02-23 18:17:18 +00:00
st%_dirs:
$(foreach dir,$(ASM_DIR)/st/$* $(ASM_DIR)/st/$*/data $(ASM_DIR)/st/$*/handwritten $(SRC_DIR)/st/$* $(ASSETS_DIR)/st/$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))
2022-02-23 18:17:18 +00:00
%_dirs:
$(foreach dir,$(ASM_DIR)/$* $(ASM_DIR)/$*/data $(SRC_DIR)/$* $(ASSETS_DIR)/$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))
2022-02-23 18:17:18 +00:00
$(BUILD_DIR)/tt_%.elf: $(BUILD_DIR)/tt_%.ld $$(call list_o_files,servant/tt_$$*) | tt_%_dirs
2023-02-08 14:03:44 +00:00
$(call link,tt_$*,$@)
$(BUILD_DIR)/stmad.elf: $$(call list_o_files,st/mad) $$(call list_shared_o_files,st)
$(LD) $(LD_FLAGS) -o $@ \
-Map $(BUILD_DIR)/stmad.map \
Enhance make extract on PSX (#662) Previously if either the YAML or the symbol list were changed, we were forced to either manually delete the `asm` folder of the specific overlay or to invoke `make clean`, where the latter forced us to re-extract all the overlays via `make -j extract`. That changes with this PR. How `make` works is `target: dep1 dep2` where if one of the dependencies has the last modified date greater than the target, the rule is triggered again. Previously we were extracting overlays doing `make extract_stcen`. But since every overlay extraction generates a linker script I now changed the rules to do `make build/us/stcen.ld` to extract the same overlay. As I explained above, if either the YAML or one of the related symbols changes, the linker modified date will be older and the extraction for that overlay to be trigger again. The above allowed me to stop polluting the repo root with the linker scripts as they are now moved into `build/us` or `build/hd` depending of what you're trying to build. If you do `make extract` twice in a row you will be welcomed with a `make: Nothing to be done for 'extract'.`. There are still some instances where you **might** need `make clean` beforehand, especially when modifying the `segment` section in the YAML or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I want to see if the current solution will be enough. ### Please try removing `make clean` from your workflow, once this is merged, to quickly detect possible problems with this new approach. I am also planning to make more substantial changes on our build-chain like this PR or #660 in the future. I am aiming to small incremental changes over time in case I break someone's flow or detect design flaws. I am also considering the breaking changes introduced in make 4.4, which will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a deadline to finish all the new build-chain work. --------- Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 08:26:29 +00:00
-T $(BUILD_DIR)/stmad.ld \
2023-06-12 05:04:25 +00:00
-T $(CONFIG_DIR)/undefined_syms.beta.txt \
-T $(CONFIG_DIR)/undefined_syms_auto.stmad.txt \
-T $(CONFIG_DIR)/undefined_funcs_auto.stmad.txt
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
$(BUILD_DIR)/stsel.elf: $$(call list_o_files,st/sel) $$(call list_shared_o_files,st)
$(call link,stsel,$@)
$(BUILD_DIR)/st%.elf: $$(call list_st_o_files,st/$$*) $$(call list_shared_o_files,st)
2022-02-23 18:17:18 +00:00
$(call link,st$*,$@)
$(BUILD_DIR)/bo%.elf: $$(call list_st_o_files,boss/$$*) $$(call list_shared_o_files,boss)
$(call link,bo$*,$@)
2022-02-23 18:17:18 +00:00
Enhance Makefile for WEAPON0.BIN (#466) ## What is this Required for #465 . I re-wrote how the build process works for the `BIN/WEAPON0.BIN` ~~overlay~~ file. ## A bit of a background On the PSP build I found `WEAPON0.BIN` is just a blob with `f0_000.bin`, `w0_000.bin`, `f0_001.bin` and so on concatenated as a single file. `f0` contains the graphics (or CHR) and `w0` contains the actual overlay (or PRG). The individual overlays share a great amount of functions I documented in `config/symbols.us.weapon.txt`. ## The problem Splat creates its own `weapon.ld` linker script, insisting to link all the overlays as a single binary file. While this is not technically correct, it creates a bigger problem: symbols cannot be shared. In 58 overlays there are 58 `DestroyEntity`. Other decomps are circumnavigating the issue by adding a prefix. Following the same pattern we could have `W000_DestroyEntity`, `W001_DestroyEntity` and so on. But this is not maintainable and it does not reflect our long-term vision of having shared code between overlays. ## The solution I created the dedicated linker script `weapon0.ld` to output the individual overlay `w0_000.bin` and similar. `f0_000.bin` is also created from the correspondent PNG. Once all the overlays and graphics are created I am simply concatenating them back to `WEAPON0.BIN`. This is much more efficient in terms of separation of concerns, maintainability, build speed and it also allows to use the same symbol names across overlays. Also very important, the generated individual overlays matches the structure of what is found in the PSP build. ## Side note I thought it was wise to prepare the Makefile and the linker script to also allow rebasing and compiling for WEAPON1.BIN. The generated file does not currently match and it will probably need a bit more research. I left the build infrastructure there. To compile the non-matching WEAPON1 just modify `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES)` to `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES) $(WEAPON1_FILES)`.
2023-08-14 01:03:54 +00:00
# Weapon overlays
WEAPON0_FILES := $(foreach num,$(shell seq -w 000 058),$(BUILD_DIR)/weapon/f0_$(num).bin $(BUILD_DIR)/weapon/w0_$(num).bin)
WEAPON1_FILES := $(foreach num,$(shell seq -w 000 058),$(BUILD_DIR)/weapon/f1_$(num).bin $(BUILD_DIR)/weapon/w1_$(num).bin)
WEAPON_DIRS := $(BUILD_DIR)/$(ASSETS_DIR)/weapon $(BUILD_DIR)/$(ASM_DIR)/weapon/data $(BUILD_DIR)/$(SRC_DIR)/weapon $(BUILD_DIR)/weapon
weapon: $(WEAPON_DIRS) $(BUILD_DIR)/WEAPON0.BIN
$(WEAPON_DIRS):
@mkdir -p $@
$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES)
cat $^ > $@
$(BUILD_DIR)/weapon/f%.bin: $(BUILD_DIR)/weapon/f%.elf
$(OBJCOPY) -O binary $< $@
$(BUILD_DIR)/weapon/w%.bin: $(BUILD_DIR)/weapon/w%.elf
$(OBJCOPY) -O binary $< $@
dd status=none if=/dev/zero of=$@ bs=1 seek=12287 count=1 conv=notrunc
$(ASM_DIR)/weapon/data/w_%.data.s: # create a fake empty file if all the data has been imported
touch $@
$(ASM_DIR)/weapon/data/w_%.sbss.s: # create a fake empty file if all the bss section has been imported
touch $@
Weapon assets and statically linked (#1470) Allow to compile weapon overlays as a single C files. The benefit is to disallow symbols to be exported by statically compile them all but the header. We would no longer need to use `OVL_EXPORT` as long as the symbols are marked as `static`. The frames data is also generated as an array of data that can be just included into their respective C files, generated by JSON files on the fly. I changed `animset` to `frameset` as the data does not represent a set of animations but rather a set of frames, where every frame has multiple sprites. The information on how the frames are played (e.g. animation) is found elsewhere. Following the full list of changes to achieve this project: * The `animset` from splat is now dummied out * The `frameset` JSON is now generated by the asset manager * The `frameset` JSON is now compiled into `src/weapon/w_0xx_y.h` * The `header.c` has been moved into `shared.h` * For simplicity I added a `#define g_Animset w_000_1`. I did not want to hack the asset manager too much to force the name to be `g_Animset` and I did not want to change all the symbols yet. * Simplified `weapon_pc.c` as we now only need the exported header * Always try to build the most up-to-date asset manager: this should avoid weird errors whenever people pull new changes As the asset manager now can accept those `config` files, now the CLI supports the following commands: * `stage extract` * `stage build` * `config extract` (NEW) * `config build` (NEW) The config structure is heavily inspired to Splat to maintain consistency and continuity.
2024-08-08 23:57:26 +00:00
$(BUILD_DIR)/weapon/w0_%.elf: $(BUILD_DIR)/$(SRC_DIR)/weapon/w_%.c.o $(BUILD_DIR)/$(ASM_DIR)/weapon/data/w_%.data.s.o $(BUILD_DIR)/$(ASM_DIR)/weapon/data/w_%.sbss.s.o
Enhance Makefile for WEAPON0.BIN (#466) ## What is this Required for #465 . I re-wrote how the build process works for the `BIN/WEAPON0.BIN` ~~overlay~~ file. ## A bit of a background On the PSP build I found `WEAPON0.BIN` is just a blob with `f0_000.bin`, `w0_000.bin`, `f0_001.bin` and so on concatenated as a single file. `f0` contains the graphics (or CHR) and `w0` contains the actual overlay (or PRG). The individual overlays share a great amount of functions I documented in `config/symbols.us.weapon.txt`. ## The problem Splat creates its own `weapon.ld` linker script, insisting to link all the overlays as a single binary file. While this is not technically correct, it creates a bigger problem: symbols cannot be shared. In 58 overlays there are 58 `DestroyEntity`. Other decomps are circumnavigating the issue by adding a prefix. Following the same pattern we could have `W000_DestroyEntity`, `W001_DestroyEntity` and so on. But this is not maintainable and it does not reflect our long-term vision of having shared code between overlays. ## The solution I created the dedicated linker script `weapon0.ld` to output the individual overlay `w0_000.bin` and similar. `f0_000.bin` is also created from the correspondent PNG. Once all the overlays and graphics are created I am simply concatenating them back to `WEAPON0.BIN`. This is much more efficient in terms of separation of concerns, maintainability, build speed and it also allows to use the same symbol names across overlays. Also very important, the generated individual overlays matches the structure of what is found in the PSP build. ## Side note I thought it was wise to prepare the Makefile and the linker script to also allow rebasing and compiling for WEAPON1.BIN. The generated file does not currently match and it will probably need a bit more research. I left the build infrastructure there. To compile the non-matching WEAPON1 just modify `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES)` to `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES) $(WEAPON1_FILES)`.
2023-08-14 01:03:54 +00:00
$(LD) $(LD_FLAGS) --no-check-sections -o $@ \
-Map $(BUILD_DIR)/weapon/w0_$*.map \
-T weapon0.ld \
-T $(CONFIG_DIR)/undefined_syms.$(VERSION).txt \
-T $(CONFIG_DIR)/undefined_syms_auto.$(VERSION).weapon.txt \
-T $(CONFIG_DIR)/undefined_funcs_auto.$(VERSION).weapon.txt \
$^
Weapon assets and statically linked (#1470) Allow to compile weapon overlays as a single C files. The benefit is to disallow symbols to be exported by statically compile them all but the header. We would no longer need to use `OVL_EXPORT` as long as the symbols are marked as `static`. The frames data is also generated as an array of data that can be just included into their respective C files, generated by JSON files on the fly. I changed `animset` to `frameset` as the data does not represent a set of animations but rather a set of frames, where every frame has multiple sprites. The information on how the frames are played (e.g. animation) is found elsewhere. Following the full list of changes to achieve this project: * The `animset` from splat is now dummied out * The `frameset` JSON is now generated by the asset manager * The `frameset` JSON is now compiled into `src/weapon/w_0xx_y.h` * The `header.c` has been moved into `shared.h` * For simplicity I added a `#define g_Animset w_000_1`. I did not want to hack the asset manager too much to force the name to be `g_Animset` and I did not want to change all the symbols yet. * Simplified `weapon_pc.c` as we now only need the exported header * Always try to build the most up-to-date asset manager: this should avoid weird errors whenever people pull new changes As the asset manager now can accept those `config` files, now the CLI supports the following commands: * `stage extract` * `stage build` * `config extract` (NEW) * `config build` (NEW) The config structure is heavily inspired to Splat to maintain consistency and continuity.
2024-08-08 23:57:26 +00:00
$(BUILD_DIR)/weapon/w1_%.elf: $(BUILD_DIR)/$(SRC_DIR)/weapon/w_%.c.o $(BUILD_DIR)/$(ASM_DIR)/weapon/data/w_%.data.s.o $(BUILD_DIR)/$(ASM_DIR)/weapon/data/w_%.sbss.s.o
Enhance Makefile for WEAPON0.BIN (#466) ## What is this Required for #465 . I re-wrote how the build process works for the `BIN/WEAPON0.BIN` ~~overlay~~ file. ## A bit of a background On the PSP build I found `WEAPON0.BIN` is just a blob with `f0_000.bin`, `w0_000.bin`, `f0_001.bin` and so on concatenated as a single file. `f0` contains the graphics (or CHR) and `w0` contains the actual overlay (or PRG). The individual overlays share a great amount of functions I documented in `config/symbols.us.weapon.txt`. ## The problem Splat creates its own `weapon.ld` linker script, insisting to link all the overlays as a single binary file. While this is not technically correct, it creates a bigger problem: symbols cannot be shared. In 58 overlays there are 58 `DestroyEntity`. Other decomps are circumnavigating the issue by adding a prefix. Following the same pattern we could have `W000_DestroyEntity`, `W001_DestroyEntity` and so on. But this is not maintainable and it does not reflect our long-term vision of having shared code between overlays. ## The solution I created the dedicated linker script `weapon0.ld` to output the individual overlay `w0_000.bin` and similar. `f0_000.bin` is also created from the correspondent PNG. Once all the overlays and graphics are created I am simply concatenating them back to `WEAPON0.BIN`. This is much more efficient in terms of separation of concerns, maintainability, build speed and it also allows to use the same symbol names across overlays. Also very important, the generated individual overlays matches the structure of what is found in the PSP build. ## Side note I thought it was wise to prepare the Makefile and the linker script to also allow rebasing and compiling for WEAPON1.BIN. The generated file does not currently match and it will probably need a bit more research. I left the build infrastructure there. To compile the non-matching WEAPON1 just modify `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES)` to `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES) $(WEAPON1_FILES)`.
2023-08-14 01:03:54 +00:00
$(LD) $(LD_FLAGS) --no-check-sections -o $@ \
-Map $(BUILD_DIR)/weapon/w1_$*.map \
-T weapon1.ld \
-T $(CONFIG_DIR)/undefined_syms.$(VERSION).txt \
-T $(CONFIG_DIR)/undefined_syms_auto.$(VERSION).weapon.txt \
-T $(CONFIG_DIR)/undefined_funcs_auto.$(VERSION).weapon.txt \
$^
$(BUILD_DIR)/$(SRC_DIR)/weapon/w_%.c.o: $(SRC_DIR)/weapon/w_%.c $(MASPSX_APP) $(CC1PSX) | weapon_dirs
$(CPP) $(CPP_FLAGS) -lang-c -DW_$* $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX) | $(AS) $(AS_FLAGS) -o $@
$(BUILD_DIR)/$(SRC_DIR)/weapon/w_029.c.o: $(SRC_DIR)/weapon/w_029.c $(MASPSX_APP) $(CC1PSX) | weapon_dirs
$(CPP) $(CPP_FLAGS) -lang-c -DW_029 $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) -O1 | $(MASPSX) | $(AS) $(AS_FLAGS) -o $@
$(BUILD_DIR)/weapon/f0_%.elf: $(BUILD_DIR)/$(ASSETS_DIR)/weapon/f_%.o | weapon_dirs
Enhance Makefile for WEAPON0.BIN (#466) ## What is this Required for #465 . I re-wrote how the build process works for the `BIN/WEAPON0.BIN` ~~overlay~~ file. ## A bit of a background On the PSP build I found `WEAPON0.BIN` is just a blob with `f0_000.bin`, `w0_000.bin`, `f0_001.bin` and so on concatenated as a single file. `f0` contains the graphics (or CHR) and `w0` contains the actual overlay (or PRG). The individual overlays share a great amount of functions I documented in `config/symbols.us.weapon.txt`. ## The problem Splat creates its own `weapon.ld` linker script, insisting to link all the overlays as a single binary file. While this is not technically correct, it creates a bigger problem: symbols cannot be shared. In 58 overlays there are 58 `DestroyEntity`. Other decomps are circumnavigating the issue by adding a prefix. Following the same pattern we could have `W000_DestroyEntity`, `W001_DestroyEntity` and so on. But this is not maintainable and it does not reflect our long-term vision of having shared code between overlays. ## The solution I created the dedicated linker script `weapon0.ld` to output the individual overlay `w0_000.bin` and similar. `f0_000.bin` is also created from the correspondent PNG. Once all the overlays and graphics are created I am simply concatenating them back to `WEAPON0.BIN`. This is much more efficient in terms of separation of concerns, maintainability, build speed and it also allows to use the same symbol names across overlays. Also very important, the generated individual overlays matches the structure of what is found in the PSP build. ## Side note I thought it was wise to prepare the Makefile and the linker script to also allow rebasing and compiling for WEAPON1.BIN. The generated file does not currently match and it will probably need a bit more research. I left the build infrastructure there. To compile the non-matching WEAPON1 just modify `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES)` to `$(BUILD_DIR)/WEAPON0.BIN: $(WEAPON0_FILES) $(WEAPON1_FILES)`.
2023-08-14 01:03:54 +00:00
$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/weapon/f1_%.elf: $(BUILD_DIR)/$(ASSETS_DIR)/weapon/f_%.o
$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/$(ASSETS_DIR)/weapon/%.o: $(ASSETS_DIR)/weapon/%.png
./tools/png2bin.py $< $@
extract: extract_$(VERSION)
2022-10-15 10:18:32 +00:00
ifneq (,$(filter psp%,$(VERSION)))
include Makefile.psp.mk
else
include Makefile.psx.mk
endif
include Makefile.saturn.mk
# Force to extract all the assembly code regardless if a function is already decompiled
force_extract:
mv src src_tmp
Enhance make extract on PSX (#662) Previously if either the YAML or the symbol list were changed, we were forced to either manually delete the `asm` folder of the specific overlay or to invoke `make clean`, where the latter forced us to re-extract all the overlays via `make -j extract`. That changes with this PR. How `make` works is `target: dep1 dep2` where if one of the dependencies has the last modified date greater than the target, the rule is triggered again. Previously we were extracting overlays doing `make extract_stcen`. But since every overlay extraction generates a linker script I now changed the rules to do `make build/us/stcen.ld` to extract the same overlay. As I explained above, if either the YAML or one of the related symbols changes, the linker modified date will be older and the extraction for that overlay to be trigger again. The above allowed me to stop polluting the repo root with the linker scripts as they are now moved into `build/us` or `build/hd` depending of what you're trying to build. If you do `make extract` twice in a row you will be welcomed with a `make: Nothing to be done for 'extract'.`. There are still some instances where you **might** need `make clean` beforehand, especially when modifying the `segment` section in the YAML or renaming the symbols. A `rm -rf asm/$(VERSION)/$*` can help but I want to see if the current solution will be enough. ### Please try removing `make clean` from your workflow, once this is merged, to quickly detect possible problems with this new approach. I am also planning to make more substantial changes on our build-chain like this PR or #660 in the future. I am aiming to small incremental changes over time in case I break someone's flow or detect design flaws. I am also considering the breaking changes introduced in make 4.4, which will most likely be included in Ubuntu 24.04 LTS. I set March 2024 as a deadline to finish all the new build-chain work. --------- Co-authored-by: sozud <122322823+sozud@users.noreply.github.com>
2023-10-05 08:26:29 +00:00
rm $(BUILD_DIR)/*.ld
make extract -j
rm -rf src/
mv src_tmp src
# Rewrites symbol list from a successful build
force_symbols:
$(PYTHON) ./tools/symbols.py map build/us/dra.map --no-default > config/symbols.us.dra.txt
$(PYTHON) ./tools/symbols.py map build/us/ric.map --no-default > config/symbols.us.ric.txt
$(PYTHON) ./tools/symbols.py map build/us/stcen.map --no-default > config/symbols.us.stcen.txt
$(PYTHON) ./tools/symbols.py map build/us/stdre.map --no-default > config/symbols.us.stdre.txt
$(PYTHON) ./tools/symbols.py map build/us/stno3.map --no-default > config/symbols.us.stno3.txt
$(PYTHON) ./tools/symbols.py map build/us/stnp3.map --no-default > config/symbols.us.stnp3.txt
$(PYTHON) ./tools/symbols.py map build/us/stnz0.map --no-default > config/symbols.us.stnz0.txt
$(PYTHON) ./tools/symbols.py map build/us/stsel.map --no-default > config/symbols.us.stsel.txt
$(PYTHON) ./tools/symbols.py map build/us/stst0.map --no-default > config/symbols.us.stst0.txt
$(PYTHON) ./tools/symbols.py map build/us/stwrp.map --no-default > config/symbols.us.stwrp.txt
$(PYTHON) ./tools/symbols.py map build/us/strwrp.map --no-default > config/symbols.us.strwrp.txt
$(PYTHON) ./tools/symbols.py map build/us/bomar.map --no-default > config/symbols.us.bomar.txt
$(PYTHON) ./tools/symbols.py map build/us/tt_000.map --no-default > config/symbols.us.tt_000.txt
context:
$(M2CTX) $(SOURCE)
@echo ctx.c has been updated.
extract_disk: extract_disk_$(VERSION)
Custom debugging module (#108) # What Adds a custom debug menu. It is written in C and it is meant to replace the Bat familar `SERVANT/TT_000.BIN`. Once loaded you can long-press SELECT+START to soft-reset the game and keep using the debug menu everywhere, including when playing with Richter or during the credits. One key requirement to run this is to have an emulator that emulates the 8MB of RAM. This is a key requirement to have the debug module surviving soft-resets or accessing to the in-game menu. I personally used [PCSX Redux](https://github.com/grumpycoders/pcsx-redux) to build this module. I am not sure about the compatibility with other emulators. This does **NOT** work on real hardware and it is a choice by design. The debug module is intended to test different areas of the game and help decompiling. It is not intended to be used in normal gameplay. # Build Simply invoke `make disk_debug` to create a disk image of the game in `build/` with the debug module replacing the Bat familiar. # Usage ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/15a040b6-6191-41c4-b2b8-a4a906ed59eb) On PCSX Redux go to Configuration, Emulation and tick the box `8MB`. ## Loading the module ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/65b7ccb3-800e-4b66-84f5-5703fc91babe) You need to enable the Bat Card from the menu. This will load the debug module from the disk. If you want to re-load the module you need to select another Familar Card, un-pause, pause again and select the Bat Card once more. ## The main screen ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/b528425a-ea6c-4c10-9c19-522612d0ad2a) You will know you have loaded the debug module when you see the blue rectangle on the top right. You can press R2 to cycle between the menus. Some menus will temporarily freeze the game, some not. To quickly return in-game you can either press TRIANGLE or START. To bring back the paused debug menu just press R2 once again. ## Debug Mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/12cac1ee-725b-484f-8564-89c03b6a755b) ### Stage Teleports the player to a different stage. It is not stable and it can crash often. ### Player Switches between Alucard and Richter. Currently switching from Richter to Alucard consistently crashes the game. ### No Clip Allows to freely move the player within the room and without the collisions on. Once the flag is enabled from the debug menu, pressing L2 while in-game will temporarily freeze the player movement and make it immune to collision checking. You can then press the directional buttons to slowly move the player or you can hold CROSS to move it faster. You can also use SQUARE or CIRCLE to cycle between the player frames. Press L2 again to deactivate the NoClip mode. ### Frame by frame Freezes the game outside the debug module. Press L1 to advance by 1 frame. Hold L2 to put the game in slow-motion. ### Show hitboxes ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/ea8dd918-cf37-4be1-bb87-541a66ac7f16) As shown in the image ### Show debug messages ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/5c9bc7b2-6bc7-4831-949a-bf73cdf910e8) When the debug menu is un-paused, prints on the top left all the debug messages from the game itself. ### Show collision layer ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/959ad1ab-dfe0-42fe-a8d0-65c619469280) This prints the internal collision value for every 16x16 tile on the screen. Look the CheckCollision function for more information on how each printed value is used. ### Show draw calls ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/a52970fc-bf30-430d-98e3-5fca33c9f6f7) Shows the maximum GPU resource usage since the game started. Currently only the `max` option works. The `current` option will not show anything. ### Show HBlank ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/81759019-6bf9-4cf2-b88c-aa60eaa5ddcb) Prints the current horizontal blank interrupt count. ## Entity Spawn ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/f0fdc024-4537-4c07-a80d-816d605a3583) Allows to immediately spawn new entities in the current map ### Mode There are three list of entities, each one with their own ID: DRA, Stage and RIC. The option RIC is hidden if Richter is not the current playing character. As the list of entities per stage is maintained manually, stage entities might not be available for all stages. The `Alloc` shows how many entities are reserved or actually used. Pressing the SQUARE button here will destroy all the entities within that range. ### ID Press Left or Right to cycle between the different IDs available. Some of them might crash the game immediately once spawned. Press CROSS to immediately spawn the entity. ### Params Each entity might have its own parameters. Sometimes the flag 0x8000 is used, which can be toggled with the SQUARE button. Press CROSS to immediately spawn the entity. ### Entity preview Shows the entity before spawning it. This is turned off by default as it can immediately crash by cycling through the available entity IDs. ### Place entity Pressing CROSS will allow to move the entity across the screen before placing it. Press CROSS again to place the entity and return to the previous screen. Press SQUARE to quickly place multiple entities of the same type. ## Sound player ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/9d8ad3a5-bc78-4674-abd0-94537bbfae98) There are three macro categories the sound player is split into. For what is currently known only the sounds within the Kind 3 changes based on the loaded stage. ### Stop all sounds This will also disable the SPU IRQ, effectively unlocking the frame rate. ### Load Stage Loads a different sound font than the current loaded stage. This can help to quickly preview and test SFXs from other stages without necessarily moving the player there. ### Load Servant Loads the sound font of a specific servant without necessarily equipping the Familiar Card. ## Castle flags Preview all the flags used to modify the behaviour of different parts of the two castles. ### Edit mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/b03ada2f-0fb4-4345-ad50-81209702032c) You can move the cursor with the directional buttons and flip the flag with CROSS. Press L1 or R1 to cycle between the pages. The cursor warps when reaching the border of the flag grid, allowing a faster navigation. ### View mode Allows to move between the flags more flexibly. ### Listen mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/4f9ed118-d09d-4658-ba25-5865dbebbf3c) Listens for the modified flags while playing. Every time a flag is modified the offset and its value is registered on the top left up to 4 rows. When all the rows are occupied, new values will just remove the oldest one. The last modified flag will always be displayed at the bottom. --------- Co-authored-by: Alejandro Asenjo Nitti <sonicdcer@users.noreply.github.com> Co-authored-by: sozud <sozud@users.noreply.github.com>
2023-08-10 17:55:24 +00:00
disk_prepare: build $(SOTNDISK)
mkdir -p $(DISK_DIR)
2023-02-21 23:25:24 +00:00
cp -r disks/${VERSION}/* $(DISK_DIR)
cp $(BUILD_DIR)/main.exe $(DISK_DIR)/SLUS_000.67
cp $(BUILD_DIR)/DRA.BIN $(DISK_DIR)/DRA.BIN
cp $(BUILD_DIR)/RIC.BIN $(DISK_DIR)/BIN/RIC.BIN
cp $(BUILD_DIR)/CEN.BIN $(DISK_DIR)/ST/CEN/CEN.BIN
cp $(BUILD_DIR)/F_CEN.BIN $(DISK_DIR)/ST/CEN/F_CEN.BIN
cp $(BUILD_DIR)/DRE.BIN $(DISK_DIR)/ST/DRE/DRE.BIN
cp $(BUILD_DIR)/F_DRE.BIN $(DISK_DIR)/ST/DRE/F_DRE.BIN
cp $(BUILD_DIR)/MAD.BIN $(DISK_DIR)/ST/MAD/MAD.BIN
cp $(BUILD_DIR)/F_MAD.BIN $(DISK_DIR)/ST/MAD/F_MAD.BIN
cp $(BUILD_DIR)/NO3.BIN $(DISK_DIR)/ST/NO3/NO3.BIN
cp $(BUILD_DIR)/F_NO3.BIN $(DISK_DIR)/ST/NO3/F_NO3.BIN
cp $(BUILD_DIR)/NP3.BIN $(DISK_DIR)/ST/NP3/NP3.BIN
cp $(BUILD_DIR)/F_NP3.BIN $(DISK_DIR)/ST/NP3/F_NP3.BIN
cp $(BUILD_DIR)/NZ0.BIN $(DISK_DIR)/ST/NZ0/NZ0.BIN
cp $(BUILD_DIR)/F_NZ0.BIN $(DISK_DIR)/ST/NZ0/F_NZ0.BIN
cp $(BUILD_DIR)/RWRP.BIN $(DISK_DIR)/ST/RWRP/RWRP.BIN
cp $(BUILD_DIR)/F_RWRP.BIN $(DISK_DIR)/ST/RWRP/F_RWRP.BIN
cp $(BUILD_DIR)/SEL.BIN $(DISK_DIR)/ST/SEL/SEL.BIN
cp $(BUILD_DIR)/ST0.BIN $(DISK_DIR)/ST/ST0/ST0.BIN
cp $(BUILD_DIR)/F_ST0.BIN $(DISK_DIR)/ST/ST0/F_ST0.BIN
cp $(BUILD_DIR)/WRP.BIN $(DISK_DIR)/ST/WRP/WRP.BIN
cp $(BUILD_DIR)/F_WRP.BIN $(DISK_DIR)/ST/WRP/F_WRP.BIN
cp $(BUILD_DIR)/MAR.BIN $(DISK_DIR)/BOSS/MAR/MAR.BIN
cp $(BUILD_DIR)/F_MAR.BIN $(DISK_DIR)/BOSS/MAR/F_MAR.BIN
2023-02-08 14:03:44 +00:00
cp $(BUILD_DIR)/TT_000.BIN $(DISK_DIR)/SERVANT/TT_000.BIN
Custom debugging module (#108) # What Adds a custom debug menu. It is written in C and it is meant to replace the Bat familar `SERVANT/TT_000.BIN`. Once loaded you can long-press SELECT+START to soft-reset the game and keep using the debug menu everywhere, including when playing with Richter or during the credits. One key requirement to run this is to have an emulator that emulates the 8MB of RAM. This is a key requirement to have the debug module surviving soft-resets or accessing to the in-game menu. I personally used [PCSX Redux](https://github.com/grumpycoders/pcsx-redux) to build this module. I am not sure about the compatibility with other emulators. This does **NOT** work on real hardware and it is a choice by design. The debug module is intended to test different areas of the game and help decompiling. It is not intended to be used in normal gameplay. # Build Simply invoke `make disk_debug` to create a disk image of the game in `build/` with the debug module replacing the Bat familiar. # Usage ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/15a040b6-6191-41c4-b2b8-a4a906ed59eb) On PCSX Redux go to Configuration, Emulation and tick the box `8MB`. ## Loading the module ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/65b7ccb3-800e-4b66-84f5-5703fc91babe) You need to enable the Bat Card from the menu. This will load the debug module from the disk. If you want to re-load the module you need to select another Familar Card, un-pause, pause again and select the Bat Card once more. ## The main screen ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/b528425a-ea6c-4c10-9c19-522612d0ad2a) You will know you have loaded the debug module when you see the blue rectangle on the top right. You can press R2 to cycle between the menus. Some menus will temporarily freeze the game, some not. To quickly return in-game you can either press TRIANGLE or START. To bring back the paused debug menu just press R2 once again. ## Debug Mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/12cac1ee-725b-484f-8564-89c03b6a755b) ### Stage Teleports the player to a different stage. It is not stable and it can crash often. ### Player Switches between Alucard and Richter. Currently switching from Richter to Alucard consistently crashes the game. ### No Clip Allows to freely move the player within the room and without the collisions on. Once the flag is enabled from the debug menu, pressing L2 while in-game will temporarily freeze the player movement and make it immune to collision checking. You can then press the directional buttons to slowly move the player or you can hold CROSS to move it faster. You can also use SQUARE or CIRCLE to cycle between the player frames. Press L2 again to deactivate the NoClip mode. ### Frame by frame Freezes the game outside the debug module. Press L1 to advance by 1 frame. Hold L2 to put the game in slow-motion. ### Show hitboxes ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/ea8dd918-cf37-4be1-bb87-541a66ac7f16) As shown in the image ### Show debug messages ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/5c9bc7b2-6bc7-4831-949a-bf73cdf910e8) When the debug menu is un-paused, prints on the top left all the debug messages from the game itself. ### Show collision layer ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/959ad1ab-dfe0-42fe-a8d0-65c619469280) This prints the internal collision value for every 16x16 tile on the screen. Look the CheckCollision function for more information on how each printed value is used. ### Show draw calls ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/a52970fc-bf30-430d-98e3-5fca33c9f6f7) Shows the maximum GPU resource usage since the game started. Currently only the `max` option works. The `current` option will not show anything. ### Show HBlank ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/81759019-6bf9-4cf2-b88c-aa60eaa5ddcb) Prints the current horizontal blank interrupt count. ## Entity Spawn ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/f0fdc024-4537-4c07-a80d-816d605a3583) Allows to immediately spawn new entities in the current map ### Mode There are three list of entities, each one with their own ID: DRA, Stage and RIC. The option RIC is hidden if Richter is not the current playing character. As the list of entities per stage is maintained manually, stage entities might not be available for all stages. The `Alloc` shows how many entities are reserved or actually used. Pressing the SQUARE button here will destroy all the entities within that range. ### ID Press Left or Right to cycle between the different IDs available. Some of them might crash the game immediately once spawned. Press CROSS to immediately spawn the entity. ### Params Each entity might have its own parameters. Sometimes the flag 0x8000 is used, which can be toggled with the SQUARE button. Press CROSS to immediately spawn the entity. ### Entity preview Shows the entity before spawning it. This is turned off by default as it can immediately crash by cycling through the available entity IDs. ### Place entity Pressing CROSS will allow to move the entity across the screen before placing it. Press CROSS again to place the entity and return to the previous screen. Press SQUARE to quickly place multiple entities of the same type. ## Sound player ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/9d8ad3a5-bc78-4674-abd0-94537bbfae98) There are three macro categories the sound player is split into. For what is currently known only the sounds within the Kind 3 changes based on the loaded stage. ### Stop all sounds This will also disable the SPU IRQ, effectively unlocking the frame rate. ### Load Stage Loads a different sound font than the current loaded stage. This can help to quickly preview and test SFXs from other stages without necessarily moving the player there. ### Load Servant Loads the sound font of a specific servant without necessarily equipping the Familiar Card. ## Castle flags Preview all the flags used to modify the behaviour of different parts of the two castles. ### Edit mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/b03ada2f-0fb4-4345-ad50-81209702032c) You can move the cursor with the directional buttons and flip the flag with CROSS. Press L1 or R1 to cycle between the pages. The cursor warps when reaching the border of the flag grid, allowing a faster navigation. ### View mode Allows to move between the flags more flexibly. ### Listen mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/4f9ed118-d09d-4658-ba25-5865dbebbf3c) Listens for the modified flags while playing. Every time a flag is modified the offset and its value is registered on the top left up to 4 rows. When all the rows are occupied, new values will just remove the oldest one. The last modified flag will always be displayed at the bottom. --------- Co-authored-by: Alejandro Asenjo Nitti <sonicdcer@users.noreply.github.com> Co-authored-by: sozud <sozud@users.noreply.github.com>
2023-08-10 17:55:24 +00:00
disk: disk_prepare
$(SOTNDISK) make build/sotn.$(VERSION).cue $(DISK_DIR) $(CONFIG_DIR)/disk.us.lba
disk_debug: disk_prepare
cd tools/sotn-debugmodule && make
cp $(BUILD_DIR)/../sotn-debugmodule.bin $(DISK_DIR)/SERVANT/TT_000.BIN
2023-02-21 20:06:27 +00:00
$(SOTNDISK) make build/sotn.$(VERSION).cue $(DISK_DIR) $(CONFIG_DIR)/disk.us.lba
# put this here as both PSX HD and PSP use it
extract_disk_psp%:
mkdir -p disks/psp$*
7z x -y disks/sotn.psp$*.iso -odisks/psp$*/
update-dependencies: $(ASMDIFFER_APP) $(M2CTX_APP) $(M2C_APP) $(MASPSX_APP) $(SATURN_SPLITTER_APP) $(GO) $(ALLEGREX_AS)
cd $(SATURN_SPLITTER_DIR)/rust-dis && cargo build --release
cd $(SATURN_SPLITTER_DIR)/adpcm-extract && cargo build --release
2022-10-25 20:26:35 +00:00
pip3 install -r $(TOOLS_DIR)/requirements-python.txt
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
rm $(SOTNDISK) && make $(SOTNDISK) || true
rm $(SOTNASSETS) && make $(SOTNASSETS) || true
2023-04-05 18:08:14 +00:00
git clean -fd bin/
2022-10-14 20:19:34 +00:00
Rewrite Saturn make rules (#660) ## What Enhance the existing `Makefile` to build new rules for the Saturn side of the decomp. This should allow more flexibility when adding new overlays or when tuning existing rules. ## Changes I separated part of the Saturn build process in the separate file `Makefile.saturn.mk`. I realise that naming it `saturn.mk` would have been enough, but I pre-pended `Makefile.` so it can be found right below the main `Makefile` when listing files in an alphabetic order. I plan to do the same with the psx and psp toolchain, therefore you will find `include Makefile.*.mk` in the main `Makefile`. I deleted all the game building process done with Docker. Now that we have an established way to do it natively I think it is no longer required. We can always run the entire buildchain within a Docker container instead of having `_native` and `_docker`. Now all the `_native` references are removed. `build_saturn_native` is now `build_saturn`. `check_saturn` is no longer responsible of stripping the ELF into a binary. That is now part of `build_saturn`. I removed the references to `_li.o` (e.g. `alucard_li.o`) and used `.elf` instead, which is closer to how the PSX build chain works. If `_li.o` was a better preference, please let me know. I am no longer using `./compile_dosemu.sh`. Instead I am using the new `$(DOSEMU)` to directly invoke the tool within the Makefile. I have done that to reduce the amount of dependent files. I tried minimising duplication as much as possible. We now have a list of overlays found in `SATURN_OVL_TARGETS`. Each expected output triggers a series of dependencies so seamlessly build everything. `Makefile` is smart enough to call `$(SATURN_TOOLCHAIN)` only once. If the game was already built but just one source or symbol file changed, triggering a new `build_saturn` will only compile the modified overlay. The Saturn ADPCM files are now extracted in `assets/` instead of `build/`. I think `assets/` should contain all the uncompressed and uncooked files. The list of PCM file is not hardcoded. Instead I am now using `$(wildcard disks/saturn/SD/*.PCM)`. This now means the tool tries to convert PCMs from `SDD0.PCM` to `SDF0.PCM` with no success. As the tool is silently failing I decided to leave it as I wrote it. ## Problems I rewrote everything thinking about concurrency in mind. But `make -j build_saturn` gives some unexpected output on `stdout`. I did not dig too much into it. I suspect it might be dosemu. This is not a stopper as we were not using `-j` when building the game anyway. I also noticed doing `VERSION=saturn make build` calls `mipsel-linux-gnu-ld` for `stage_02`. I suspect it is calling the rule `$(MAIN_TARGET).elf: $(MAIN_O_FILES)` and simply moving `include Makefile.*.mk` above it should fix it. But then it would cause the same problem if I split the PSX rules into their own separate file. We never used `make build` by setting the env variable `VERSION`, so this is not either a breaking change or a stopper. ## Post thoughts I am happy with what I achieved so far. I used the knowledge I accumulated when maintaining the PSX counterpart. Since I now better understand how `make` works, I was able to make some better decisions in the Saturn counterpart. For example triggering a new build when the symbol list changes is something the PSX build chain lacks of. I think in the future it would be nice to trigger `make extract` when either the YAML or the symbol list changes.
2023-10-03 20:42:08 +00:00
bin/%: bin/%.tar.gz
sha256sum --check $<.sha256
cd bin && tar -xzf ../$<
rm $<
touch $@
bin/%.tar.gz: bin/%.tar.gz.sha256
wget -O $@ https://github.com/Xeeynamo/sotn-decomp/releases/download/cc1-psx-26/$*.tar.gz
2022-10-14 20:19:34 +00:00
$(ASMDIFFER_APP):
2022-10-14 20:26:57 +00:00
git submodule init $(ASMDIFFER_DIR)
git submodule update $(ASMDIFFER_DIR)
2022-10-15 10:18:32 +00:00
$(M2CTX_APP):
curl -o $@ https://raw.githubusercontent.com/ethteck/m2ctx/main/m2ctx.py
2022-10-15 10:45:20 +00:00
$(M2C_APP):
git submodule init $(M2C_DIR)
git submodule update $(M2C_DIR)
$(PYTHON) -m pip install --upgrade pycparser
2023-06-17 11:29:42 +00:00
$(MASPSX_APP):
git submodule init $(MASPSX_DIR)
git submodule update $(MASPSX_DIR)
2022-10-26 06:41:13 +00:00
$(GO):
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
curl -L -o go1.22.4.linux-amd64.tar.gz https://go.dev/dl/go1.22.4.linux-amd64.tar.gz
tar -C $(HOME) -xzf go1.22.4.linux-amd64.tar.gz
rm go1.22.4.linux-amd64.tar.gz
$(SOTNDISK): $(GO) $(SOTNDISK_SOURCES)
cd tools/sotn-disk; $(GO) install
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
$(SOTNASSETS): $(GO) $(SOTNASSETS_SOURCES)
cd tools/sotn-assets; $(GO) install
2022-01-01 17:45:41 +00:00
# Handles assets
$(BUILD_DIR)/$(ASSETS_DIR)/%.spritesheet.json.o: $(ASSETS_DIR)/%.spritesheet.json
./tools/splat_ext/spritesheet.py encode $< $(BUILD_DIR)/$(ASSETS_DIR)/$*.s
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/$(ASSETS_DIR)/$*.o $(BUILD_DIR)/$(ASSETS_DIR)/$*.s
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
$(BUILD_DIR)/$(ASSETS_DIR)/dra/%.json.o: $(ASSETS_DIR)/dra/%.json
./tools/splat_ext/assets.py $< $(BUILD_DIR)/$(ASSETS_DIR)/dra/$*.s
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/$(ASSETS_DIR)/dra/$*.o $(BUILD_DIR)/$(ASSETS_DIR)/dra/$*.s
$(BUILD_DIR)/$(ASSETS_DIR)/ric/%.json.o: $(ASSETS_DIR)/ric/%.json
./tools/splat_ext/assets.py $< $(BUILD_DIR)/$(ASSETS_DIR)/ric/$*.s
$(AS) $(AS_FLAGS) -o $(BUILD_DIR)/$(ASSETS_DIR)/ric/$*.o $(BUILD_DIR)/$(ASSETS_DIR)/ric/$*.s
$(BUILD_DIR)/$(ASSETS_DIR)/%.bin.o: $(ASSETS_DIR)/%.bin
mkdir -p $(dir $@)
$(LD) -r -b binary -o $(BUILD_DIR)/$(ASSETS_DIR)/$*.o $<
$(BUILD_DIR)/$(ASSETS_DIR)/%.dec.o: $(ASSETS_DIR)/%.dec
# for now '.dec' files are ignored
touch $@
$(BUILD_DIR)/$(ASSETS_DIR)/%.png.o: $(ASSETS_DIR)/%.png
touch $@
2022-01-01 17:45:41 +00:00
SHELL = /bin/bash -e -o pipefail
Add tool to automatically perform symbols cross referencing (#413) I wanted to make this tool for a long time. Given the fact HD recently became more dense into DRA, people who are willing to contribute to that overlay should not have the burden of manually cross-referencing symbols as I have been doing for the past weeks. Instead of creating a tutorial I created a tool that cross-reference symbols between functions. The two functions can be either between two different revisions of the game or between two overlays. The latter is especially important to finally remove all the duplicate functions. I also took the opportunity to add some unit tests (finally!) in `tools/tests` instead of creating the dedicated folder `tools/symbols` with tools and test in it. Let me know if `tools/tests` is a pattern we want to keep following for any future tool that needs to be tested. I also added an assembly parser written in Python. As for today it lives in `tools/symbols.py`. It is barebone but it can parse the majority of assembly lines. I also added tests around it in case we want to expand it or extract the parser into its own utility. I've been thinking to ideally use it for a V2 of `find_duplicates.py` if we find the current tool to be limiting. ### Demo ``` sotn-decomp$ ./tools/symbols.py cross asm/us/dra/nonmatchings/71830/func_80112BB0.s asm/hd/dra/nonmatchings/71830/func_80112BB0.s D_80139824 = 0x801393F0; D_800ACF7C = 0x800AD040; D_800ACF7E = 0x800AD042; D_80138FC8 = 0x80138B94; D_80138FCA = 0x80138B96; ``` these symbols can be automatically copy&pasted into `symbols.hd.dra.txt` or the relevant symbol list.
2023-07-31 19:14:57 +00:00
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, tt_000
2022-02-23 18:17:18 +00:00
.PHONY: %_dirs
.PHONY: extract, extract_%
Custom debugging module (#108) # What Adds a custom debug menu. It is written in C and it is meant to replace the Bat familar `SERVANT/TT_000.BIN`. Once loaded you can long-press SELECT+START to soft-reset the game and keep using the debug menu everywhere, including when playing with Richter or during the credits. One key requirement to run this is to have an emulator that emulates the 8MB of RAM. This is a key requirement to have the debug module surviving soft-resets or accessing to the in-game menu. I personally used [PCSX Redux](https://github.com/grumpycoders/pcsx-redux) to build this module. I am not sure about the compatibility with other emulators. This does **NOT** work on real hardware and it is a choice by design. The debug module is intended to test different areas of the game and help decompiling. It is not intended to be used in normal gameplay. # Build Simply invoke `make disk_debug` to create a disk image of the game in `build/` with the debug module replacing the Bat familiar. # Usage ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/15a040b6-6191-41c4-b2b8-a4a906ed59eb) On PCSX Redux go to Configuration, Emulation and tick the box `8MB`. ## Loading the module ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/65b7ccb3-800e-4b66-84f5-5703fc91babe) You need to enable the Bat Card from the menu. This will load the debug module from the disk. If you want to re-load the module you need to select another Familar Card, un-pause, pause again and select the Bat Card once more. ## The main screen ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/b528425a-ea6c-4c10-9c19-522612d0ad2a) You will know you have loaded the debug module when you see the blue rectangle on the top right. You can press R2 to cycle between the menus. Some menus will temporarily freeze the game, some not. To quickly return in-game you can either press TRIANGLE or START. To bring back the paused debug menu just press R2 once again. ## Debug Mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/12cac1ee-725b-484f-8564-89c03b6a755b) ### Stage Teleports the player to a different stage. It is not stable and it can crash often. ### Player Switches between Alucard and Richter. Currently switching from Richter to Alucard consistently crashes the game. ### No Clip Allows to freely move the player within the room and without the collisions on. Once the flag is enabled from the debug menu, pressing L2 while in-game will temporarily freeze the player movement and make it immune to collision checking. You can then press the directional buttons to slowly move the player or you can hold CROSS to move it faster. You can also use SQUARE or CIRCLE to cycle between the player frames. Press L2 again to deactivate the NoClip mode. ### Frame by frame Freezes the game outside the debug module. Press L1 to advance by 1 frame. Hold L2 to put the game in slow-motion. ### Show hitboxes ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/ea8dd918-cf37-4be1-bb87-541a66ac7f16) As shown in the image ### Show debug messages ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/5c9bc7b2-6bc7-4831-949a-bf73cdf910e8) When the debug menu is un-paused, prints on the top left all the debug messages from the game itself. ### Show collision layer ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/959ad1ab-dfe0-42fe-a8d0-65c619469280) This prints the internal collision value for every 16x16 tile on the screen. Look the CheckCollision function for more information on how each printed value is used. ### Show draw calls ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/a52970fc-bf30-430d-98e3-5fca33c9f6f7) Shows the maximum GPU resource usage since the game started. Currently only the `max` option works. The `current` option will not show anything. ### Show HBlank ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/81759019-6bf9-4cf2-b88c-aa60eaa5ddcb) Prints the current horizontal blank interrupt count. ## Entity Spawn ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/f0fdc024-4537-4c07-a80d-816d605a3583) Allows to immediately spawn new entities in the current map ### Mode There are three list of entities, each one with their own ID: DRA, Stage and RIC. The option RIC is hidden if Richter is not the current playing character. As the list of entities per stage is maintained manually, stage entities might not be available for all stages. The `Alloc` shows how many entities are reserved or actually used. Pressing the SQUARE button here will destroy all the entities within that range. ### ID Press Left or Right to cycle between the different IDs available. Some of them might crash the game immediately once spawned. Press CROSS to immediately spawn the entity. ### Params Each entity might have its own parameters. Sometimes the flag 0x8000 is used, which can be toggled with the SQUARE button. Press CROSS to immediately spawn the entity. ### Entity preview Shows the entity before spawning it. This is turned off by default as it can immediately crash by cycling through the available entity IDs. ### Place entity Pressing CROSS will allow to move the entity across the screen before placing it. Press CROSS again to place the entity and return to the previous screen. Press SQUARE to quickly place multiple entities of the same type. ## Sound player ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/9d8ad3a5-bc78-4674-abd0-94537bbfae98) There are three macro categories the sound player is split into. For what is currently known only the sounds within the Kind 3 changes based on the loaded stage. ### Stop all sounds This will also disable the SPU IRQ, effectively unlocking the frame rate. ### Load Stage Loads a different sound font than the current loaded stage. This can help to quickly preview and test SFXs from other stages without necessarily moving the player there. ### Load Servant Loads the sound font of a specific servant without necessarily equipping the Familiar Card. ## Castle flags Preview all the flags used to modify the behaviour of different parts of the two castles. ### Edit mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/b03ada2f-0fb4-4345-ad50-81209702032c) You can move the cursor with the directional buttons and flip the flag with CROSS. Press L1 or R1 to cycle between the pages. The cursor warps when reaching the border of the flag grid, allowing a faster navigation. ### View mode Allows to move between the flags more flexibly. ### Listen mode ![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/4f9ed118-d09d-4658-ba25-5865dbebbf3c) Listens for the modified flags while playing. Every time a flag is modified the offset and its value is registered on the top left up to 4 rows. When all the rows are occupied, new values will just remove the oldest one. The last modified flag will always be displayed at the bottom. --------- Co-authored-by: Alejandro Asenjo Nitti <sonicdcer@users.noreply.github.com> Co-authored-by: sozud <sozud@users.noreply.github.com>
2023-08-10 17:55:24 +00:00
.PHONY: update-dependencies