Files
sotn-decomp/diff_settings.py
Luciano Ciccariello cc2c0cc81c Add all known DRA PS1 builds + VERSION refactor (#3817)
Something I've been wanted to do for a while. Importing all DRA builds,
with the recent TEK discovery in the equation, allowed me to get a more
concrete idea of the builds lineage.

I am putting the PR in draft for two reasons:
1. I want to collect feedback on this already big PR.
2. I am planning to make jp10, jp11, us, hk, and jp12 builds optional,
and just let the CI to always test them. Reason is I realize not
everyone has/wants these additional builds. Moreover, it would further
creep the build time.

The most interesting change is
https://github.com/Xeeynamo/sotn-decomp/blob/dec7c323d50ac22fd7511d6e1c1fdb3027ddf82a/include/version.h
, which drastically changes how versions are tested on the
pre-processor. Gone are `VERSION_US` and friends. Instead they're
replaced with `#define VER_US 19970901U`, corresponding to the greatest
creation date of each file from a given build. TEK and HD have unknown
build dates, so I gave them numbers prior to `VER_JP10`.

This allows us to document the code as follows:

```
// before
#if defined(VERSION_US) || defined(VERSION_EU) || defined(VERSION_HK) ||       \
    defined(VERSION_USPROTO) || defined(VERSION_JP10) ||                       \
    defined(VERSION_JP11) || defined(VERSION_JP12)

// after
#if VERSION >= VERSION_JP10
```

Helpers such as `IS_VER_INTL` are created to indicate all English PS1
builds, excluding the USPROTO. INTL is a short name for "International".

I took the chance to also change how we test a region with the new macro
`REGION_*`. The PSP exclusive paths are now tested with `'#if TARGET ==
TARGET_PSP`. I could've used `#if defined(TARGET_PSP)` but we may have
run to the same traps as earlier. Instead, we could create a simple
helper to do `#if IS_TARGET_PSP` but I did not want to add too many
unnecessary wrappers.

I also eliminate almost all inverted conditions. `#if !(defined(xxx) &&
defined(yyy))` and similar were far too hard to read.

`VER_NEXT` is our custom "ultimate" build with community fixes. It could
be paired with `PLATFORM_PSYZ`, which now replaces `VERSION_PC`
2026-11-07 11:49:01 +00:00

127 lines
3.9 KiB
Python

#!/usr/bin/env python3
import os
import re
def add_custom_arguments(parser):
parser.add_argument(
"--version",
default=os.getenv("VERSION") or "us",
dest="version",
help="Decide what version of the game to use (us, jp12, pspeu, etc.)",
)
parser.add_argument(
"--overlay",
default="dra",
dest="overlay",
help="Defines which overlay to use for the diff (main, dra, mad, etc.)",
)
def apply_saturn(config, args):
name = args.overlay
config["myimg"] = f"build/saturn/{name}.PRG"
config["source_directories"] = [f"src/saturn/"]
config["mapfile"] = f"build/saturn/{name.lower()}.map"
config["baseimg"] = f"disks/saturn/{name}.PRG"
config["objdump_executable"] = "sh-elf-objdump"
config["arch"] = "sh2"
def apply(config, args):
version = args.version
if version == "saturn":
apply_saturn(config, args)
return
name = re.sub(
r"^(?:st|bos?s?)/?(?=[a-z])",
"",
f"{args.overlay.upper() if version in ('us', 'jp10', 'jp11', 'jp12', 'usproto', 'eu', 'hk') else args.overlay.lower()}",
flags=re.IGNORECASE,
)
baseimgRoot = {
"us": "disks/us",
"hd": "disks/pspeu/PSP_GAME/USRDIR/res/ps/hdbin",
"pspeu": "disks/pspeu/PSP_GAME/USRDIR/res/ps/PSPBIN",
"jp10": "disks/jp10",
"jp11": "disks/jp11",
"jp12": "disks/jp12",
"usproto": "disks/usproto",
"eu": "disks/eu",
"hk": "disks/hk",
}
binaryExt = {
"us": "BIN",
"hd": "bin",
"pspeu": "bin",
"jp10": "BIN",
"jp11": "BIN",
"jp12": "BIN",
"usproto": "BIN",
"eu": "BIN",
"hk": "BIN",
}
path_prefix = ""
name_prefix = ""
if name.lower().startswith("w_"):
name = name.lower().replace("w_", "w0_")
path_prefix = "BIN" if version == "us" else ""
name_prefix = "weapon/"
config["myimg"] = os.path.join(f"build/{version}", f"{name_prefix}{name}.bin")
config["source_directories"] = [
"include",
"src/weapon",
f"asm/{version}/weapon/data",
]
else:
if name.lower() in os.listdir("src/st"):
name_prefix = "st"
path_prefix = f"ST/{name}" if version == "us" else ""
elif name.lower() in os.listdir("src/boss"):
name_prefix = "bo"
path_prefix = f"BOSS/{name}" if version == "us" else ""
elif version == "us" and name.lower() in os.listdir("src/servant"):
path_prefix = "SERVANT"
elif version == "us" and f"{name}.BIN" in os.listdir(f"disks/us/BIN"):
path_prefix = "BIN"
config["myimg"] = os.path.join(
f"build/{version}", f"{name}.{binaryExt[version]}"
)
config["source_directories"] = [
"include",
os.path.join(
"src",
name_prefix.replace("bo", "boss"),
name.lower().replace("tt_", "servant/tt_"),
),
os.path.join(
f"asm/{version}",
name_prefix.replace("bo", "boss").replace("tt_", "servant/tt_"),
name.lower().replace("tt_", "servant/tt_"),
),
]
if version == "pspeu" and not name.startswith("tt_"):
config["source_directories"].append(
os.path.join("src", name_prefix.replace("bo", "boss"), f"{name}_psp")
)
config["mapfile"] = os.path.join(
f"build/{version}", f"{name_prefix}{name.lower()}.map"
)
if version == "us":
name = re.sub(r"w0_\d{3}", "WEAPON0", name)
config["baseimg"] = os.path.join(
baseimgRoot[version],
path_prefix,
f"{name.lower() if version == 'hd' else name}.{binaryExt[version]}",
)
config["objdump_executable"] = "mipsel-linux-gnu-objdump"
config["arch"] = "mipsel:4000" if version == "pspeu" else "mipsel"