Fixes to includes

This commit is contained in:
2026-07-31 20:20:06 -05:00
committed by Timothy O'Barr
parent a6cfff7acc
commit 575f9910dc
6 changed files with 70 additions and 28 deletions
+8 -20
View File
@@ -62,7 +62,7 @@ TOOLS_DIR = ROOT / "tools"
CROSS = "mips-ps2-decompals-" CROSS = "mips-ps2-decompals-"
COMPILER = "mwcps2-3.0b52-030722" COMPILER = "mwcps2-3.0b52-030722"
COMPILER_FLAGS = "-O3,p -sym on -str readonly" COMPILER_FLAGS = "-O3,p -sym on -str readonly -cwd source"
PLATFORM = "x86_64" # @todo get this from makefile PLATFORM = "x86_64" # @todo get this from makefile
# PLATFORM = "macos" # PLATFORM = "macos"
@@ -216,16 +216,18 @@ def build_stuff(
# Rules # Rules
ld_args = "-map -sym on,elf -noinhibit-exec -main _start -o $out $lcf $objects" ld_args = "-map -sym on,elf -noinhibit-exec -main _start -o $out $lcf $objects"
rel_root = Path(os.path.relpath(ROOT, config_dir))
ld = Path("..", (Path("tools") / "cc" / COMPILER / "mwldps2.exe")) ld = Path("..", (Path("tools") / "cc" / COMPILER / "mwldps2.exe"))
cpp = Path("..", (Path("tools") / "cc" / COMPILER / "mwccps2.exe")) cpp = Path("tools") / "cc" / COMPILER / "mwccps2.exe"
print({cpp})
print({common_includes})
ninja.rule( ninja.rule(
"as", "as",
description="as $in", description="as $in",
# NOTE: Japanese strings are EUC-JP encoded!! command=f"{CROSS}as -no-pad-sections -EL -march=5900 -mabi=eabi -I{src_path.parent / 'include'} -o $out",
# We need to convert them from (-f) UTF-8 to (-t) EUC-JP while compiling,
# otherwise Japanese strings will be compiled wrong!
command=f"{CROSS}as -no-pad-sections -EL -march=5900 -mabi=eabi -mno-branch-relocs -I{src_path.parent / 'include'} -Iinclude -o $out $in",
) )
ninja.rule( ninja.rule(
@@ -234,8 +236,6 @@ def build_stuff(
command=( command=(
f"s_in=$$(echo $in.S | sed 's,^[^/]*/[^/]*/,cc-src/,') && " # .............. 1) remove ../../ from path + prefix with cc-src/ + suffix with .S and store it into s_in var: ../src/file.c -> s_in=cc-src/src/file.c.S f"s_in=$$(echo $in.S | sed 's,^[^/]*/[^/]*/,cc-src/,') && " # .............. 1) remove ../../ from path + prefix with cc-src/ + suffix with .S and store it into s_in var: ../src/file.c -> s_in=cc-src/src/file.c.S
f'mkdir -p $$(dirname "$$s_in") && ' # ..................................... 2) create directory from s_in var: s_in=cc-src/src/path/to/file.c.S -> mkdir -p cc-src/src/path/to/ f'mkdir -p $$(dirname "$$s_in") && ' # ..................................... 2) create directory from s_in var: s_in=cc-src/src/path/to/file.c.S -> mkdir -p cc-src/src/path/to/
f"{game_compile_cmd.replace(' -c ', ' -S ')} $in -o $$s_in && " # .......... 3) replace -c with -S in gcc command to generate intermediate assembly file instead of object
f"python3 {ROOT}/tools/python/fix_asm_matching.py {language} $$s_in && " # . 4) fix assembly file using known patterns with tools/python/fix_asm_matching.py
f"{game_compile_cmd} $$s_in -o $out && " # ................................. 5) compile assembly file into object f"{game_compile_cmd} $$s_in -o $out && " # ................................. 5) compile assembly file into object
f"{ld}strip $out -N dummy-symbol-name" # ................................ 6) strip 'dummy-symbol-name' from object f"{ld}strip $out -N dummy-symbol-name" # ................................ 6) strip 'dummy-symbol-name' from object
), ),
@@ -247,18 +247,6 @@ def build_stuff(
command=f"{game_compile_cmd} $in -o $out && {ld}strip $out -N dummy-symbol-name", command=f"{game_compile_cmd} $in -o $out && {ld}strip $out -N dummy-symbol-name",
) )
ninja.rule(
"cc-eucjp",
description="convert source to EUC-JP encoding and compile same as 'cc'",
command=(
f"eucjp_in=$$(echo $in.eucjp.c | sed 's,^[^/]*/[^/]*/,cc-src/,') && " # . 1) remove ../../ from path + prefix with cc-src/ + suffix with .eucjp.c and store it into eucjp_in var: ../src/file.c -> eucjp_in=cc-src/src/file.c.eucjp.c
f'mkdir -p $$(dirname "$$eucjp_in") && ' # .............................. 2) create directory from eucjp_in var: s_in=cc-src/src/path/to/file.c.eucjp.c -> mkdir -p cc-src/src/path/to/
#f"iconv -o $$eucjp_in -f=UTF-8 -t=EUC-JP $in && " # ..................... 3) convert source file to EUC-JP (save converted source to cc-src/src/file.c.eucjp.c)
f'{game_compile_cmd} -I$$(dirname "$in") $$eucjp_in -o $out && ' # ...... 4) compile converted source file into object (also add original source directory as include path to allow relative imports)
f"{CROSS}strip $out -N dummy-symbol-name" # ............................. 5) strip 'dummy-symbol-name' from object
),
)
#ninja.rule( #ninja.rule(
# "libcc", # "libcc",
# description="cc $in", # description="cc $in",
+4 -4
View File
@@ -22,8 +22,8 @@ typedef struct {
void *gpReg; void *gpReg;
int initPriority; int initPriority;
int currentPriority; int currentPriority;
u_int attr; unsigned int attr;
u_int option; unsigned int option;
int waitType; int waitType;
int waitId; int waitId;
int wakeupCount; int wakeupCount;
@@ -34,8 +34,8 @@ typedef struct {
int maxCount; int maxCount;
int initCount; int initCount;
int numWaitThreads; int numWaitThreads;
u_int attr; unsigned int attr;
u_int option; unsigned int option;
} SemaParam; } SemaParam;
extern void *_gp; extern void *_gp;
+2
View File
@@ -3,5 +3,7 @@
void InitFadeControl(); void InitFadeControl();
void SetFadeMng(unsigned char Type, signed int * Col, signed int Timer, void (* lpMidFunc)(), void (* lpEndFunc)(), signed int OutEnd, signed int StartIn);
#endif // FADE_H #endif // FADE_H
+44 -3
View File
@@ -1,10 +1,51 @@
#ifndef GAME_H #ifndef GAME_H
#define GAME_H #define GAME_H
int GameLoop(); extern struct {
// Members
unsigned int SystemCounter; // offset 0x0, size 0x4
unsigned char ControlMode; // offset 0x4, size 0x1
unsigned char GameMode; // offset 0x5, size 0x1
unsigned char GameModePrev; // offset 0x6, size 0x1
unsigned char DebugMode; // offset 0x7, size 0x1
unsigned char StopMode; // offset 0x8, size 0x1
unsigned char sceneNo; // offset 0x9, size 0x1
unsigned char padport; // offset 0xA, size 0x1
unsigned char ShadowTest; // offset 0xB, size 0x1
unsigned char DepthTest; // offset 0xC, size 0x1
unsigned char ScriptMode; // offset 0xD, size 0x1
unsigned char DizzyTest; // offset 0xE, size 0x1
unsigned char Pause; // offset 0xF, size 0x1
unsigned char EnePause; // offset 0x10, size 0x1
unsigned char EnemyOff; // offset 0x11, size 0x1
unsigned char FadedTest; // offset 0x12, size 0x1
unsigned char PeepMask; // offset 0x13, size 0x1
unsigned char PlayerId; // offset 0x14, size 0x1
unsigned char PadVib; // offset 0x15, size 0x1
unsigned char KeyConfType; // offset 0x16, size 0x1
unsigned char EneSearchOff; // offset 0x17, size 0x1
unsigned char GameLevel; // offset 0x18, size 0x1
unsigned char StartEquip; // offset 0x19, size 0x1
unsigned char PenanceMode; // offset 0x1A, size 0x1
unsigned char NineHitNum; // offset 0x1B, size 0x1
unsigned char NegaPosi; // offset 0x1C, size 0x1
unsigned char LoadStart; // offset 0x1D, size 0x1
char Brightness; // offset 0x1E, size 0x1
unsigned char GlareId; // offset 0x1F, size 0x1
unsigned char MyAllAttack; // offset 0x20, size 0x1
unsigned char DebugMenuOn; // offset 0x21, size 0x1
unsigned char Sugoroku; // offset 0x22, size 0x1
unsigned char TutorialOff; // offset 0x23, size 0x1
float AmbRate; // offset 0x24, size 0x4
unsigned char ClearCount[3]; // offset 0x28, size 0x3
unsigned char ExtraClear; // offset 0x2B, size 0x1
unsigned char VoiceLanguage; // offset 0x2C, size 0x1
unsigned char LastLanguage; // offset 0x2D, size 0x1
unsigned char unused[2]; // offset 0x2E, size 0x2
} GameSt; // size: 0x30, address: 0x3A5E10
int GameLoop();
void InitGameData(); void InitGameData();
void InitGameDataAfterLoad(); void InitGameDataAfterLoad();
#endif // GAME_H #endif // GAME_H
+6
View File
@@ -12,8 +12,14 @@
#include "Title.h" #include "Title.h"
#include "common.h" #include "common.h"
#include "ee/eekernel.h" #include "ee/eekernel.h"
#include "ee/registers.h"
#include "sce/libcdvd.h"
#include "typedefs.h" #include "typedefs.h"
int gTime;
int GoToEndingFlag;
int GoToTitleFlag;
void SetGoToEndingFade(void) { void SetGoToEndingFade(void) {
SetFadeMng(1, (sceVu0IVECTOR){0}, 30, NULL, SetGoToEndingFlag, 0, 0); SetFadeMng(1, (sceVu0IVECTOR){0}, 30, NULL, SetGoToEndingFlag, 0, 0);
SND_RemoveSound(); SND_RemoveSound();
+5
View File
@@ -1,6 +1,11 @@
#ifndef MAIN_H #ifndef MAIN_H
#define MAIN_H #define MAIN_H
extern int gTime;
extern int GoToEndingFlag;
extern int GoToTitleFlag;
void SetGoToEndingFade(); void SetGoToEndingFade();
int CheckGoToEndingFlag(); int CheckGoToEndingFlag();
void SetGoToEndingFlag(); void SetGoToEndingFlag();