Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"${workspaceFolder}/src/PowerPC_EABI_Support/include/PowerPC_EABI_Support/MSL_C/MSL_Common",
"${workspaceFolder}/src/PowerPC_EABI_Support/include/PowerPC_EABI_Support/MSL_C++/MSL_Common/Include",
"${workspaceFolder}/include/inline",
"${workspaceFolder}/src/bink/include",
"${workspaceFolder}/src/bink/src",
"${workspaceFolder}/src/dolphin/include",
"${workspaceFolder}/src/dolphin/src",
"${workspaceFolder}/include/rwsdk",
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
"gxget.h": "c",
"gxverify.h": "c",
"card.h": "c",
"__start.h": "c"
"__start.h": "c",
"macros.h": "c",
"ngcsnd.h": "c"
},
// Disable C/C++ IntelliSense, use clangd instead
"C_Cpp.intelliSenseEngine": "default",
Expand Down
55 changes: 46 additions & 9 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
type=Path,
help="path to sjiswrap.exe (optional)",
)
parser.add_argument(
"--ninja",
metavar="BINARY",
type=Path,
help="path to ninja binary (optional)",
)
parser.add_argument(
"--verbose",
action="store_true",
Expand All @@ -113,6 +119,13 @@
action="store_true",
help="builds equivalent (but non-matching) or modded objects",
)
parser.add_argument(
"--warn",
dest="warn",
type=str,
choices=["all", "off", "error"],
help="how to handle warnings",
)
parser.add_argument(
"--no-progress",
dest="progress",
Expand All @@ -134,6 +147,7 @@
config.generate_map = args.map
config.non_matching = args.non_matching
config.sjiswrap_path = args.sjiswrap
config.ninja_path = args.ninja
config.progress = args.progress
if not is_windows():
config.wrapper = args.wrapper
Expand All @@ -143,14 +157,13 @@

# Tool versions
config.binutils_tag = "2.42-1"
config.compilers_tag = "20240706"
config.dtk_tag = "v1.4.1"
config.objdiff_tag = "v3.3.1"
config.sjiswrap_tag = "v1.2.0"
config.wibo_tag = "0.6.11"
config.compilers_tag = "20250812"
config.dtk_tag = "v1.7.0"
config.objdiff_tag = "v3.4.1"
config.sjiswrap_tag = "v1.2.2"
config.wibo_tag = "1.0.0-beta.5"

# Project
config.shift_jis = False
config.config_path = Path("config") / config.version / "config.yml"
config.check_sha_path = Path("config") / config.version / "build.sha1"
config.asflags = [
Expand All @@ -159,7 +172,6 @@
"-I include",
f"-I build/{config.version}/include",
f"--defsym BUILD_VERSION={version_num}",
f"--defsym VERSION_={config.version}",
]
config.ldflags = [
"-fp hardware",
Expand Down Expand Up @@ -204,6 +216,7 @@
"-i src/dolphin/include",
"-i src/dolphin/src",
"-i src",
"-i src/bink/include",
f"-i build/{config.version}/include",
f"-DBUILD_VERSION={version_num}",
f"-DVERSION_{config.version}",
Expand All @@ -216,6 +229,14 @@
else:
cflags_base.append("-DNDEBUG=1")

# Warning flags
if args.warn == "all":
cflags_base.append("-W all")
elif args.warn == "off":
cflags_base.append("-W off")
elif args.warn == "error":
cflags_base.append("-W error")

# Metrowerks library flags
cflags_runtime = [
*cflags_base,
Expand Down Expand Up @@ -250,6 +271,22 @@
"-use_lmw_stmw on"
]

# Bink was compiled with ProDG
cflags_bink = [
"-O3",
"-mcpu=750",
"-fno-exceptions",
"-Wno-inline",
"-nostdinc",
"-I src/dolphin/src",
"-I include",
"-I src/dolphin/include",
"-I src/bink/include",
"-D__GEKKO__",
"-I src/PowerPC_EABI_Support/include",
"-G4",
]

# Renderware library flags
cflags_renderware = [
*cflags_base,
Expand Down Expand Up @@ -598,8 +635,8 @@ def MatchingFor(*versions):
},
{
"lib": "binkngc",
"mw_version": "GC/1.3.2",
"cflags": cflags_runtime,
"mw_version": "ProDG/3.5",
"cflags": cflags_bink,
"progress_category": "bink",
"objects": [
Object(NonMatching, "bink/src/sdk/decode/ngc/binkngc.c"),
Expand Down
8 changes: 8 additions & 0 deletions src/bink/include/binkngc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef BINKNGC_H
#define BINKNGC_H

#include "dolphin/os/OSAlloc.h"

void radfree(void* ptr);

#endif
6 changes: 6 additions & 0 deletions src/bink/include/ngcsnd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef NGCSND_H
#define NGCSND_H

#include "ax/__ax.h"

#endif
8 changes: 8 additions & 0 deletions src/bink/include/popmal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef POPMAL_H
#define POPMAL_H

#include "types.h"

u32 popmalloctotal();

#endif
Empty file added src/bink/shared/time/radcb.c
Empty file.
Empty file added src/bink/src/sdk/bitplane.c
Empty file.
Empty file added src/bink/src/sdk/dct.c
Empty file.
Empty file.
Empty file.
Empty file.
44 changes: 44 additions & 0 deletions src/bink/src/sdk/decode/ngc/binkngc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "binkngc.h"

u32 usermalloc = NULL;
u32 userfree = NULL;
u32 userarammalloc = NULL;
u32 useraramfree = NULL;

void RADSetMemory(u32 alloc, u32 free)
{
usermalloc = alloc;
userfree = free;
}

void radfree(void* ptr)
{
u8* ptrU8 = (u8*)ptr;
u32* ptrU32 = (u32*)ptr;

void (*customFree)(void*);
if (ptr)
{
if ((ptrU8[-2]) == 3)
{
customFree = (u32)(ptrU32[-2]);
customFree(ptrU8 - ptrU8[-1]);
}
else
{
OSFreeToHeap((void*)__OSCurrHeap, ptrU8 - ptrU8[-1]);
}
}
}

void radaudiofree()
{
if (useraramfree != NULL)
{
}
}

// undefined4 *
void ReadTimeBase(u32* ptr)
{
}
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions src/bink/src/sdk/decode/ngc/ngcsnd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "ngcsnd.h"

void Close()
{
NGC_SoundShutdown();
}

void BinkOpenNGCSound()
{
// return Open;
}
Empty file.
Empty file added src/bink/src/sdk/decode/yuv.cpp
Empty file.
Empty file added src/bink/src/sdk/fft.c
Empty file.
9 changes: 9 additions & 0 deletions src/bink/src/sdk/popmal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "popmal.h"

static u32 pushtot = 0;
static u32 pushcur = 0;

u32 popmalloctotal()
{
return pushtot;
}
Empty file added src/bink/src/sdk/varbits.c
Empty file.
28 changes: 18 additions & 10 deletions tools/download_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ def sjiswrap_url(tag: str) -> str:


def wibo_url(tag: str) -> str:
repo = "https://github.com/decompals/wibo"
return f"{repo}/releases/download/{tag}/wibo"
uname = platform.uname()
arch = uname.machine.lower()
system = uname.system.lower()
if system == "darwin":
arch = "macos"

def ok_url(tag: str) -> str:
repo = "https://github.com/bfbbdecomp/OK"
return f"{repo}/releases/download/{tag}/OK-linux-x86_64"
repo = "https://github.com/decompals/wibo"
return f"{repo}/releases/download/{tag}/wibo-{arch}"


TOOLS: Dict[str, Callable[[str], str]] = {
Expand All @@ -93,9 +95,9 @@ def ok_url(tag: str) -> str:
"objdiff-cli": objdiff_cli_url,
"sjiswrap": sjiswrap_url,
"wibo": wibo_url,
"OK": ok_url
}


def download(url, response, output) -> None:
if url.endswith(".zip"):
data = io.BytesIO(response.read())
Expand All @@ -112,6 +114,7 @@ def download(url, response, output) -> None:
st = os.stat(output)
os.chmod(output, st.st_mode | stat.S_IEXEC)


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("tool", help="Tool name")
Expand All @@ -133,12 +136,17 @@ def main() -> None:
try:
import certifi
import ssl
except:
print("\"certifi\" module not found. Please install it using \"python -m pip install certifi\".")
except ImportError:
print(
'"certifi" module not found. Please install it using "python -m pip install certifi".'
)
return

with urllib.request.urlopen(req, context=ssl.create_default_context(cafile=certifi.where())) as response:

with urllib.request.urlopen(
req, context=ssl.create_default_context(cafile=certifi.where())
) as response:
download(url, response, output)


if __name__ == "__main__":
main()
31 changes: 29 additions & 2 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,17 @@ def write_cargo_rule():
###
compiler_path = compilers / "$mw_version"

# NGCCC
ngccc = compiler_path / "ngccc.exe"
if is_windows():
ngccc_cmd = f"cmd /c \"set SN_NGC_PATH={os.path.abspath(compiler_path)}&& {ngccc} $cflags -c -o $out $in\""
else:
ngccc_cmd = f"env SN_NGC_PATH={os.path.abspath(compiler_path)} {wrapper_cmd}{ngccc} $cflags -c -o $out $in"
ngccc_implicit: List[Optional[Path]] = [
compilers_implicit or ngccc,
wrapper_implicit,
]

# MWCC
mwcc = compiler_path / "mwcceppc.exe"
mwcc_cmd = f"{wrapper_cmd}{mwcc} $cflags -MMD -c $in -o $basedir"
Expand Down Expand Up @@ -663,6 +674,16 @@ def write_cargo_rule():
)
n.newline()

n.comment("ProDG build")
n.rule(
name="prodg",
command=ngccc_cmd,
description="ProDG $out",
depfile="$basefile.d",
deps="gcc",
)
n.newline()

n.comment("MWCC build (with UTF-8 to Shift JIS wrapper)")
n.rule(
name="mwcc_sjis",
Expand Down Expand Up @@ -877,12 +898,18 @@ def c_build(obj: Object, src_path: Path) -> Optional[Path]:
cflags_str = make_flags_str(all_cflags)
used_compiler_versions.add(obj.options["mw_version"])


# Add MWCC build rule
fakerule = "mwcc_sjis" if obj.options["shift_jis"] else "mwcc"
fakeimplicit = mwcc_sjis_implicit if obj.options["shift_jis"] else mwcc_implicit
if ("prodg" in obj.options["mw_version"].lower()):
fakerule = "prodg"
fakeimplicit = ngccc_implicit
lib_name = obj.options["lib"]
n.comment(f"{obj.name}: {lib_name} (linked {obj.completed})")
n.build(
outputs=obj.src_obj_path,
rule="mwcc_sjis" if obj.options["shift_jis"] else "mwcc",
rule=fakerule,
inputs=src_path,
variables={
"mw_version": Path(obj.options["mw_version"]),
Expand All @@ -891,7 +918,7 @@ def c_build(obj: Object, src_path: Path) -> Optional[Path]:
"basefile": obj.src_obj_path.with_suffix(""),
},
implicit=(
mwcc_sjis_implicit if obj.options["shift_jis"] else mwcc_implicit
fakeimplicit
),
order_only="pre-compile",
)
Expand Down
Loading