diff --git a/README.md b/README.md index 30067061..81195317 100644 --- a/README.md +++ b/README.md @@ -77,15 +77,15 @@ cd scripts ## Building -Before building, you must split the ELF file using Splat. Run the following command to split the ELF: +The project can be compiled on Windows or Linux using `make`. It builds the executable `SCUS_971.98`. + +Before building, you must split the ELF file using Splat. This is defined in the `Makefile` as the `extract` target: ```bash -python -m splat split config/sly1.yaml +make extract ``` -This will create a new directory `splat` with the disassembled assembly code and generated C files. You can now build the project. - -The project can be compiled on Windows or Linux using `make`. It builds the executable `SCUS_971.98`. +This will create a new directory `asm` with the disassembled assembly code and generated C files. You can now build the project: ```bash make diff --git a/config/sly1.yaml b/config/sly1.yaml index fa024137..bdf60411 100644 --- a/config/sly1.yaml +++ b/config/sly1.yaml @@ -10,8 +10,8 @@ options: compiler: GCC asm_path: asm - src_path: c - build_path: build + src_path: src + build_path: bin find_file_boundaries: False disasm_unknown: True @@ -153,7 +153,7 @@ segments: - [0x83c18, asm, P2/lo] - [0x84cc8, asm, P2/light] - [0x86358, asm, P2/lookat] - - [0x86758, asm, P2/main] + - [0x86758, c, P2/main] - [0x86c18, asm, P2/mark] - [0x894c0, asm, P2/mat] @@ -243,7 +243,7 @@ segments: #- [0x, asm, P2/ub] #- [0x, asm, P2/ui] - [0xeac78, asm, P2/update] - - [0xeb408, c, P2/util] + - [0xeb408, asm, P2/util] - [0xec518, asm] #? unknown file @@ -277,12 +277,12 @@ segments: #---------------------------------------- # Rodata #---------------------------------------- - - [0x118380, rodata] + #- [0x118380, rodata] #---------------------------------------- # Data #---------------------------------------- - - [0x151580, data] + #- [0x151580, data] - [0x17C200, databin] - [0x1A20D0] diff --git a/include/common.h b/include/common.h index 28f3a4d2..a6528660 100644 --- a/include/common.h +++ b/include/common.h @@ -2,6 +2,5 @@ #define COMMON_H #include "include_asm.h" -#include #endif /* COMMON_H */ diff --git a/include/macro.inc b/include/macro.inc index f4259d38..1d894e20 100644 --- a/include/macro.inc +++ b/include/macro.inc @@ -7,4 +7,4 @@ .macro dlabel label .global \label \label: -.endm \ No newline at end of file +.endm diff --git a/include/actseg.h b/old_include/actseg.h similarity index 100% rename from include/actseg.h rename to old_include/actseg.h diff --git a/include/alarm.h b/old_include/alarm.h similarity index 100% rename from include/alarm.h rename to old_include/alarm.h diff --git a/include/alo.h b/old_include/alo.h similarity index 100% rename from include/alo.h rename to old_include/alo.h diff --git a/include/aseg.h b/old_include/aseg.h similarity index 100% rename from include/aseg.h rename to old_include/aseg.h diff --git a/include/bas.h b/old_include/bas.h similarity index 100% rename from include/bas.h rename to old_include/bas.h diff --git a/include/basic.h b/old_include/basic.h similarity index 100% rename from include/basic.h rename to old_include/basic.h diff --git a/include/bif.h b/old_include/bif.h similarity index 100% rename from include/bif.h rename to old_include/bif.h diff --git a/include/bis.h b/old_include/bis.h similarity index 100% rename from include/bis.h rename to old_include/bis.h diff --git a/include/bq.h b/old_include/bq.h similarity index 100% rename from include/bq.h rename to old_include/bq.h diff --git a/include/brx.h b/old_include/brx.h similarity index 100% rename from include/brx.h rename to old_include/brx.h diff --git a/include/cat.h b/old_include/cat.h similarity index 100% rename from include/cat.h rename to old_include/cat.h diff --git a/include/cd.h b/old_include/cd.h similarity index 100% rename from include/cd.h rename to old_include/cd.h diff --git a/include/chkpnt.h b/old_include/chkpnt.h similarity index 100% rename from include/chkpnt.h rename to old_include/chkpnt.h diff --git a/include/clock.h b/old_include/clock.h similarity index 100% rename from include/clock.h rename to old_include/clock.h diff --git a/include/cm.h b/old_include/cm.h similarity index 100% rename from include/cm.h rename to old_include/cm.h diff --git a/include/coin.h b/old_include/coin.h similarity index 100% rename from include/coin.h rename to old_include/coin.h diff --git a/old_include/common.h b/old_include/common.h new file mode 100644 index 00000000..28f3a4d2 --- /dev/null +++ b/old_include/common.h @@ -0,0 +1,7 @@ +#ifndef COMMON_H +#define COMMON_H + +#include "include_asm.h" +#include + +#endif /* COMMON_H */ diff --git a/include/dialog.h b/old_include/dialog.h similarity index 100% rename from include/dialog.h rename to old_include/dialog.h diff --git a/include/difficulty.h b/old_include/difficulty.h similarity index 100% rename from include/difficulty.h rename to old_include/difficulty.h diff --git a/include/dl.h b/old_include/dl.h similarity index 100% rename from include/dl.h rename to old_include/dl.h diff --git a/include/font.h b/old_include/font.h similarity index 100% rename from include/font.h rename to old_include/font.h diff --git a/include/frm.h b/old_include/frm.h similarity index 100% rename from include/frm.h rename to old_include/frm.h diff --git a/include/game.h b/old_include/game.h similarity index 100% rename from include/game.h rename to old_include/game.h diff --git a/include/gc.h b/old_include/gc.h similarity index 100% rename from include/gc.h rename to old_include/gc.h diff --git a/include/gs.h b/old_include/gs.h similarity index 100% rename from include/gs.h rename to old_include/gs.h diff --git a/include/joy.h b/old_include/joy.h similarity index 100% rename from include/joy.h rename to old_include/joy.h diff --git a/include/keyhole.h b/old_include/keyhole.h similarity index 100% rename from include/keyhole.h rename to old_include/keyhole.h diff --git a/include/light.h b/old_include/light.h similarity index 100% rename from include/light.h rename to old_include/light.h diff --git a/include/lo.h b/old_include/lo.h similarity index 100% rename from include/lo.h rename to old_include/lo.h diff --git a/include/main.h b/old_include/main.h similarity index 100% rename from include/main.h rename to old_include/main.h diff --git a/include/mat.h b/old_include/mat.h similarity index 100% rename from include/mat.h rename to old_include/mat.h diff --git a/include/mpeg.h b/old_include/mpeg.h similarity index 100% rename from include/mpeg.h rename to old_include/mpeg.h diff --git a/include/phasemem.h b/old_include/phasemem.h similarity index 100% rename from include/phasemem.h rename to old_include/phasemem.h diff --git a/include/prog.h b/old_include/prog.h similarity index 100% rename from include/prog.h rename to old_include/prog.h diff --git a/include/readme.txt b/old_include/readme.txt similarity index 100% rename from include/readme.txt rename to old_include/readme.txt diff --git a/include/ref.h b/old_include/ref.h similarity index 100% rename from include/ref.h rename to old_include/ref.h diff --git a/include/render.h b/old_include/render.h similarity index 100% rename from include/render.h rename to old_include/render.h diff --git a/include/screen.h b/old_include/screen.h similarity index 100% rename from include/screen.h rename to old_include/screen.h diff --git a/include/sensor.h b/old_include/sensor.h similarity index 100% rename from include/sensor.h rename to old_include/sensor.h diff --git a/include/sidebag.h b/old_include/sidebag.h similarity index 100% rename from include/sidebag.h rename to old_include/sidebag.h diff --git a/include/slotheap.h b/old_include/slotheap.h similarity index 100% rename from include/slotheap.h rename to old_include/slotheap.h diff --git a/include/so.h b/old_include/so.h similarity index 100% rename from include/so.h rename to old_include/so.h diff --git a/include/sound.h b/old_include/sound.h similarity index 100% rename from include/sound.h rename to old_include/sound.h diff --git a/include/speaker.h b/old_include/speaker.h similarity index 100% rename from include/speaker.h rename to old_include/speaker.h diff --git a/include/spliceutils.h b/old_include/spliceutils.h similarity index 100% rename from include/spliceutils.h rename to old_include/spliceutils.h diff --git a/include/sw.h b/old_include/sw.h similarity index 100% rename from include/sw.h rename to old_include/sw.h diff --git a/include/transition.h b/old_include/transition.h similarity index 100% rename from include/transition.h rename to old_include/transition.h diff --git a/include/types.h b/old_include/types.h similarity index 100% rename from include/types.h rename to old_include/types.h diff --git a/include/ui.h b/old_include/ui.h similarity index 100% rename from include/ui.h rename to old_include/ui.h diff --git a/include/update.h b/old_include/update.h similarity index 100% rename from include/update.h rename to old_include/update.h diff --git a/include/util.h b/old_include/util.h similarity index 100% rename from include/util.h rename to old_include/util.h diff --git a/include/vec.h b/old_include/vec.h similarity index 100% rename from include/vec.h rename to old_include/vec.h diff --git a/include/wipe.h b/old_include/wipe.h similarity index 100% rename from include/wipe.h rename to old_include/wipe.h diff --git a/include/wm.h b/old_include/wm.h similarity index 100% rename from include/wm.h rename to old_include/wm.h diff --git a/include/xform.h b/old_include/xform.h similarity index 100% rename from include/xform.h rename to old_include/xform.h diff --git a/include/zap.h b/old_include/zap.h similarity index 100% rename from include/zap.h rename to old_include/zap.h diff --git a/src/P2/bas.c b/old_src/P2/bas.c similarity index 100% rename from src/P2/bas.c rename to old_src/P2/bas.c diff --git a/src/P2/bis.c b/old_src/P2/bis.c similarity index 100% rename from src/P2/bis.c rename to old_src/P2/bis.c diff --git a/src/P2/brx.c b/old_src/P2/brx.c similarity index 100% rename from src/P2/brx.c rename to old_src/P2/brx.c diff --git a/src/P2/cat.c b/old_src/P2/cat.c similarity index 100% rename from src/P2/cat.c rename to old_src/P2/cat.c diff --git a/src/P2/cd.c b/old_src/P2/cd.c similarity index 100% rename from src/P2/cd.c rename to old_src/P2/cd.c diff --git a/src/P2/chkpnt.c b/old_src/P2/chkpnt.c similarity index 100% rename from src/P2/chkpnt.c rename to old_src/P2/chkpnt.c diff --git a/src/P2/clock.c b/old_src/P2/clock.c similarity index 100% rename from src/P2/clock.c rename to old_src/P2/clock.c diff --git a/src/P2/cm.c b/old_src/P2/cm.c similarity index 100% rename from src/P2/cm.c rename to old_src/P2/cm.c diff --git a/src/P2/coin.c b/old_src/P2/coin.c similarity index 100% rename from src/P2/coin.c rename to old_src/P2/coin.c diff --git a/src/P2/difficulty.c b/old_src/P2/difficulty.c similarity index 100% rename from src/P2/difficulty.c rename to old_src/P2/difficulty.c diff --git a/src/P2/font.c b/old_src/P2/font.c similarity index 100% rename from src/P2/font.c rename to old_src/P2/font.c diff --git a/src/P2/frm.c b/old_src/P2/frm.c similarity index 100% rename from src/P2/frm.c rename to old_src/P2/frm.c diff --git a/src/P2/game.c b/old_src/P2/game.c similarity index 100% rename from src/P2/game.c rename to old_src/P2/game.c diff --git a/src/P2/gs.c b/old_src/P2/gs.c similarity index 100% rename from src/P2/gs.c rename to old_src/P2/gs.c diff --git a/src/P2/joy.c b/old_src/P2/joy.c similarity index 100% rename from src/P2/joy.c rename to old_src/P2/joy.c diff --git a/old_src/P2/main.c b/old_src/P2/main.c new file mode 100644 index 00000000..340731f9 --- /dev/null +++ b/old_src/P2/main.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BUILD_TITLE "Sly Cooper" +#define BUILD_YEAR __DATE__[7], __DATE__[8], __DATE__[9], __DATE__[10] +#define COPYRIGHT "Sly 1 Decompilation Team" +#define BUILD_ID __DATE__[0], __DATE__[1], __DATE__[2], (__DATE__[4] == ' ' ? '0' : __DATE__[4]), __DATE__[5], __TIME__[0], __TIME__[1], __TIME__[3], __TIME__[4] +#define BRX_VERSION "000" + +#ifndef __BUILD_USER +#define __BUILD_USER "nobody" +#endif + +int main(int cphzArgs, char* aphzArgs[]) +{ + // __main(); // from libgcc2 + + g_chpzArgs = cphzArgs; + g_aphzArgs = aphzArgs; + + Startup(); + + while (true) + { + // Check if g_mpeg has an mpeg queued to be played + if ((g_mpeg.oid_1 != OID_Unknown) && (g_wipe.wipes != WIPES_Idle)) + { + ////FlushFrames(1); + g_mpeg.ExecuteOids(); + } + + // Check if g_transition has a pending transition + if (g_transition.m_fPending != 0) + { + ////FlushFrames(1); + g_transition.Execute(); + } + + // Check AGAIN if g_mpeg has an mpeg queued (in case two were queued back-to-back) + if ((g_mpeg.oid_2 != OID_Unknown) && (g_wipe.wipes != WIPES_Idle)) + { + ////FlushFrames(1); + g_mpeg.ExecuteOids(); + } + + // Call update functions + UpdateJoy(&g_joy); + UpdateCodes(); + ////UpdateSave(&g_save); + UpdateUi(&g_ui); + UpdateGameState(g_clock.dt); + + // Render and draw current frame + if (g_psw != NULL) + { + // Prepare to render frame + SetupCm(g_pcm); + OpenFrame(); + MarkClockTick(&g_clock); + + // This ends up calling UpdateSw down the line + void* pv = g_psw + 0x54; + if (pv != NULL) + { + ////(*pv)(g_clock.dt); + } + + // Render frame + RenderSw(g_psw, g_pcm); + RenderUi(); + + // Draw frame + DrawSw(g_psw, g_pcm); + DrawUi(); + + CloseFrame(); + } + + // Increment the global frame counter + g_cframe += 1; + } +} + +void Startup() +{ +#ifdef __DEBUG + printf("%s @ %c%c%c%c\n", BUILD_TITLE, BUILD_YEAR); + printf(" %s\n", COPYRIGHT); + printf("P2: %c%c%c%c%c.%c%c%c%c %s\n", BUILD_ID, __BUILD_USER); + printf("Brx: %s\n", BRX_VERSION); +#endif + CProg prog; + prog.Begin(); + + SetPhase(PHASE_Startup); + + /* todo game systems should be started by iterating over s_StartupSampler and + calling each function, updating the progress along the way */ + ///StartupSplice(); + StartupCodes(); + // ... + + prog.SetRemain(0); + prog.End(); + ClearPhase(PHASE_Startup); +} diff --git a/src/P2/mpeg.c b/old_src/P2/mpeg.c similarity index 100% rename from src/P2/mpeg.c rename to old_src/P2/mpeg.c diff --git a/src/P2/phasemem.c b/old_src/P2/phasemem.c similarity index 100% rename from src/P2/phasemem.c rename to old_src/P2/phasemem.c diff --git a/src/P2/prog.c b/old_src/P2/prog.c similarity index 100% rename from src/P2/prog.c rename to old_src/P2/prog.c diff --git a/src/P2/ps2t/.gitkeep b/old_src/P2/ps2t/.gitkeep similarity index 100% rename from src/P2/ps2t/.gitkeep rename to old_src/P2/ps2t/.gitkeep diff --git a/src/P2/render.c b/old_src/P2/render.c similarity index 100% rename from src/P2/render.c rename to old_src/P2/render.c diff --git a/src/P2/screen.c b/old_src/P2/screen.c similarity index 100% rename from src/P2/screen.c rename to old_src/P2/screen.c diff --git a/src/P2/sound.c b/old_src/P2/sound.c similarity index 100% rename from src/P2/sound.c rename to old_src/P2/sound.c diff --git a/src/P2/splice/.gitkeep b/old_src/P2/splice/.gitkeep similarity index 100% rename from src/P2/splice/.gitkeep rename to old_src/P2/splice/.gitkeep diff --git a/src/P2/splice/spliceutils.cpp b/old_src/P2/splice/spliceutils.cpp similarity index 100% rename from src/P2/splice/spliceutils.cpp rename to old_src/P2/splice/spliceutils.cpp diff --git a/src/P2/sw.c b/old_src/P2/sw.c similarity index 100% rename from src/P2/sw.c rename to old_src/P2/sw.c diff --git a/src/P2/temp/.gitkeep b/old_src/P2/temp/.gitkeep similarity index 100% rename from src/P2/temp/.gitkeep rename to old_src/P2/temp/.gitkeep diff --git a/src/P2/transition.c b/old_src/P2/transition.c similarity index 100% rename from src/P2/transition.c rename to old_src/P2/transition.c diff --git a/src/P2/ui.c b/old_src/P2/ui.c similarity index 100% rename from src/P2/ui.c rename to old_src/P2/ui.c diff --git a/src/P2/update.c b/old_src/P2/update.c similarity index 100% rename from src/P2/update.c rename to old_src/P2/update.c diff --git a/src/P2/util.c b/old_src/P2/util.c similarity index 88% rename from src/P2/util.c rename to old_src/P2/util.c index 86dd2750..760caed2 100644 --- a/src/P2/util.c +++ b/old_src/P2/util.c @@ -33,18 +33,18 @@ float GLimitAbs(float g, float absLimit) return g; } -INCLUDE_ASM(const s32, "P2/util", GSmooth); +//INCLUDE_ASM(const s32, "P2/util", GSmooth); -INCLUDE_ASM(const s32, "P2/util", GSmoothA); -INCLUDE_ASM(const s32, "P2/util", func_001EA720); // Part of GSmoothA +//INCLUDE_ASM(const s32, "P2/util", GSmoothA); +//INCLUDE_ASM(const s32, "P2/util", func_001EA720); // Part of GSmoothA -INCLUDE_ASM(const s32, "P2/util", RadSmooth); +//INCLUDE_ASM(const s32, "P2/util", RadSmooth); -INCLUDE_ASM(const s32, "P2/util", RadSmoothA); +//INCLUDE_ASM(const s32, "P2/util", RadSmoothA); -INCLUDE_ASM(const s32, "P2/util", PosSmooth); +//INCLUDE_ASM(const s32, "P2/util", PosSmooth); -INCLUDE_ASM(const s32, "P2/util", SmoothMatrix); +//INCLUDE_ASM(const s32, "P2/util", SmoothMatrix); int NRandInRange(int nLow, int nHigh) { @@ -118,10 +118,10 @@ int CSolveQuadratic(float a, float b, float c, float* ax) ax[1] = -bOver2a - sqrtOver2a; *ax = -bOver2a + sqrtOver2a; - return 2; // two solutions: (-b � radical) / 2a + return 2; // two solutions: (-b ± radical) / 2a } -INCLUDE_ASM(const s32, "P2/util", PrescaleClq); +//INCLUDE_ASM(const s32, "P2/util", PrescaleClq); void CalculateSinCos(float angle, float *sin, float *cos) { @@ -215,7 +215,7 @@ float GModPositive(float gDividend, float gDivisor) return result; } -INCLUDE_ASM(const s32, "P2/util", FitClq); +//INCLUDE_ASM(const s32, "P2/util", FitClq); /** * @note Matching 100% @@ -272,7 +272,8 @@ int SgnCompareG(float* pg1, float* pg2) void Force(void *) { // This function is empty. + return; } -INCLUDE_ASM(const s32, "P2/util", MinimizeRange); -INCLUDE_ASM(const s32, "P2/util", func_001EB458); +//INCLUDE_ASM(const s32, "P2/util", MinimizeRange); +//INCLUDE_ASM(const s32, "P2/util", func_001EB458); diff --git a/src/P2/vec.c b/old_src/P2/vec.c similarity index 100% rename from src/P2/vec.c rename to old_src/P2/vec.c diff --git a/src/P2/wipe.c b/old_src/P2/wipe.c similarity index 100% rename from src/P2/wipe.c rename to old_src/P2/wipe.c diff --git a/src/P2/wm.c b/old_src/P2/wm.c similarity index 100% rename from src/P2/wm.c rename to old_src/P2/wm.c diff --git a/src/P2/xform.c b/old_src/P2/xform.c similarity index 100% rename from src/P2/xform.c rename to old_src/P2/xform.c diff --git a/src/readme.txt b/old_src/readme.txt similarity index 100% rename from src/readme.txt rename to old_src/readme.txt diff --git a/src/P2/main.c b/src/P2/main.c index 340731f9..f4b3d9a3 100644 --- a/src/P2/main.c +++ b/src/P2/main.c @@ -1,122 +1,9 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "common.h" -#define BUILD_TITLE "Sly Cooper" -#define BUILD_YEAR __DATE__[7], __DATE__[8], __DATE__[9], __DATE__[10] -#define COPYRIGHT "Sly 1 Decompilation Team" -#define BUILD_ID __DATE__[0], __DATE__[1], __DATE__[2], (__DATE__[4] == ' ' ? '0' : __DATE__[4]), __DATE__[5], __TIME__[0], __TIME__[1], __TIME__[3], __TIME__[4] -#define BRX_VERSION "000" +INCLUDE_ASM(const s32, "P2/main", main); -#ifndef __BUILD_USER -#define __BUILD_USER "nobody" -#endif +INCLUDE_ASM(const s32, "P2/main", StartupVU0); -int main(int cphzArgs, char* aphzArgs[]) -{ - // __main(); // from libgcc2 +INCLUDE_ASM(const s32, "P2/main", StartupVU1); - g_chpzArgs = cphzArgs; - g_aphzArgs = aphzArgs; - - Startup(); - - while (true) - { - // Check if g_mpeg has an mpeg queued to be played - if ((g_mpeg.oid_1 != OID_Unknown) && (g_wipe.wipes != WIPES_Idle)) - { - ////FlushFrames(1); - g_mpeg.ExecuteOids(); - } - - // Check if g_transition has a pending transition - if (g_transition.m_fPending != 0) - { - ////FlushFrames(1); - g_transition.Execute(); - } - - // Check AGAIN if g_mpeg has an mpeg queued (in case two were queued back-to-back) - if ((g_mpeg.oid_2 != OID_Unknown) && (g_wipe.wipes != WIPES_Idle)) - { - ////FlushFrames(1); - g_mpeg.ExecuteOids(); - } - - // Call update functions - UpdateJoy(&g_joy); - UpdateCodes(); - ////UpdateSave(&g_save); - UpdateUi(&g_ui); - UpdateGameState(g_clock.dt); - - // Render and draw current frame - if (g_psw != NULL) - { - // Prepare to render frame - SetupCm(g_pcm); - OpenFrame(); - MarkClockTick(&g_clock); - - // This ends up calling UpdateSw down the line - void* pv = g_psw + 0x54; - if (pv != NULL) - { - ////(*pv)(g_clock.dt); - } - - // Render frame - RenderSw(g_psw, g_pcm); - RenderUi(); - - // Draw frame - DrawSw(g_psw, g_pcm); - DrawUi(); - - CloseFrame(); - } - - // Increment the global frame counter - g_cframe += 1; - } -} - -void Startup() -{ -#ifdef __DEBUG - printf("%s @ %c%c%c%c\n", BUILD_TITLE, BUILD_YEAR); - printf(" %s\n", COPYRIGHT); - printf("P2: %c%c%c%c%c.%c%c%c%c %s\n", BUILD_ID, __BUILD_USER); - printf("Brx: %s\n", BRX_VERSION); -#endif - CProg prog; - prog.Begin(); - - SetPhase(PHASE_Startup); - - /* todo game systems should be started by iterating over s_StartupSampler and - calling each function, updating the progress along the way */ - ///StartupSplice(); - StartupCodes(); - // ... - - prog.SetRemain(0); - prog.End(); - ClearPhase(PHASE_Startup); -} +INCLUDE_ASM(const s32, "P2/main", Startup);