Skip to content

Commit

Permalink
Add 2.6.3 compiler, stop.c
Browse files Browse the repository at this point in the history
  • Loading branch information
sozud committed Mar 2, 2024
1 parent fc42ca1 commit 8f3fc60
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 8 deletions.
14 changes: 14 additions & 0 deletions aspsx.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off
set arg1=%1
set arg2=%2
set arg3=%3
set arg4=%4
shift
shift
shift
shift
set COMPILER_PATH=%CD%build\%arg4%
set C_INCLUDE_PATH=%CD%include
set PSYQ_PATH=%CD%build\%arg4%
@echo on
%CD%build\%arg4%\aspsx.exe -G0 %arg3% %arg1% -o%arg2%
14 changes: 14 additions & 0 deletions aspsx_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Check if correct number of arguments are provided
if [ "$#" -ne 4 ]; then
echo "Usage: $0 input output"
exit 1
fi

# Define input and output variables with slash replacement
in=$(echo "$1" | tr '/' '\\')
out=$(echo "$2" | tr '/' '\\')

# Run the command with substituted variables
dosemu -quiet -dumb -f ./dosemurc -K . -E "aspsx.bat $in $out $3 $4"
66 changes: 64 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,72 @@ def add_lib(srcs, output_dir, lib_name, flags, folder):
variables={'LIBRARY': lib_name}
)

# original compiler missing so cobbling it together
def add_lib_263(srcs, output_dir, lib_name, flags, folder):
for src in srcs:
filename_without_extension = os.path.splitext(os.path.basename(src))[0]
obj_name = f"{output_dir}/{filename_without_extension}.obj"

# run c preprocessor
ninja.build(
f"{output_dir}/{filename_without_extension}.cpp",
'cpp_263',
inputs=[src],
variables={'FLAGS': flags, 'FOLDER': folder})

# run cc1
ninja.build(
f"{output_dir}/{filename_without_extension}.s",
'cc1_263',
inputs=[f"{output_dir}/{filename_without_extension}.cpp"],
variables={'FLAGS': flags, 'FOLDER': folder})

# convert to dos
ninja.build(
f"{output_dir}/{filename_without_extension}.d",
'unix2dos_263',
inputs=[f"{output_dir}/{filename_without_extension}.s"],
variables={'FLAGS': flags, 'FOLDER': folder})

# run aspsx
ninja.build(
f"{output_dir}/{filename_without_extension}.obj",
'aspsx_263',
inputs=[f"{output_dir}/{filename_without_extension}.d"],
variables={'FLAGS': flags, 'FOLDER': folder})

# # check it
# # this doesn't generate a file output but ninja apparently needs an output name
ninja.build(
f"{obj_name}.check",
'check',
inputs=[obj_name],
variables={'LIBRARY': lib_name})


ninja = ninja_syntax.Writer(open("build.ninja", "w"))

ninja.rule('compile',
command='sh dosemu_wrapper.sh $in $out $FLAGS $FOLDER',
description='Building $out from $in')

cpp_flags = "-undef -D__GNUC__=2 -DVERSION=35 -v -D__OPTIMIZE__ -I./src/snd -I./include -lang-c -Dmips -D__mips__ -D__mips -Dpsx -D__psx__ -D__psx -D__EXTENSIONS__ -D_MIPSEL -D__CHAR_UNSIGNED__ -D_LANGUAGE_C -DLANGUAGE_C"
ninja.rule('cpp_263',
command=f'cpp {cpp_flags} $in $out',
description='Running preprocessor on $out from $in')

ninja.rule('cc1_263',
command='./cc1-psx-26 -O2 -g0 -G0 -funsigned-char $in -o $out',
description='Running cc1 on $out from $in')

ninja.rule('aspsx_263',
command='sh aspsx_wrapper.sh $in $out dummy 3.5',
description='Running aspsx on $out from $in')

ninja.rule('unix2dos_263',
command='unix2dos -n $in $out',
description='Running unix2dos on $out from $in')

ninja.rule(
'check',
command='./tools/psy-q-splitter/splitter/target/release/splitter diff_obj_with_lib $LIBRARY $in',
Expand Down Expand Up @@ -122,6 +182,7 @@ def build_35():
'src/snd/sstable.c',
'src/snd/sstick.c',
'src/snd/ssvol.c',
'src/snd/stop.c',
'src/snd/tempo.c',
'src/snd/ut_gpa.c',
'src/snd/ut_gva.c',
Expand All @@ -145,7 +206,7 @@ def build_35():
'src/snd/vs_vtc.c',
]

add_lib(snd_srcs, "build/3.5/snd", "./psy-q/3.5/PSX/LIB/LIBSND.LIB", "-DVERSION=35", "3.5")
add_lib_263(snd_srcs, "build/3.5/snd", "./psy-q/3.5/PSX/LIB/LIBSND.LIB", "-DVERSION=35", "3.5")

spu_srcs = [
'src/spu/s_cb.c',
Expand All @@ -170,7 +231,7 @@ def build_35():
'src/spu/sr_gaks.c',
]

add_lib(spu_srcs, "build/3.5/spu", "./psy-q/3.5/PSX/LIB/LIBSPU.LIB", "-DVERSION=35", "3.5")
add_lib_263(spu_srcs, "build/3.5/spu", "./psy-q/3.5/PSX/LIB/LIBSPU.LIB", "-DVERSION=35", "3.5")

def build_36():
snd_srcs = [
Expand Down Expand Up @@ -249,4 +310,5 @@ def build_36():
build_35()
build_36()


ninja.close()
15 changes: 9 additions & 6 deletions prep_35.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
mkdir -p build/3.5
# put toolchain together
cp -r ./psy-q/3.3/PSYQ/* build/3.5
cp -r ./psy-q/cc_2.60/* build/3.5
# replace aspsx with newer one
cp psy-q/3.5/PSYQ/ASPSX.EXE build/3.5
mkdir -p build/3.5
# put toolchain together
cp -r ./psy-q/3.3/PSYQ/* build/3.5

wget -O https://github.com/Xeeynamo/sotn-decomp/releases/download/cc1-psx-26/cc1-psx-26.tar.gz
tar -xvf cc1-psx-26.tar.gz -C build/3.5
cp -r ./psy-q/cc_2.60/* build/3.5
# replace aspsx with newer one
cp psy-q/3.5/PSYQ/ASPSX.EXE build/3.5
46 changes: 46 additions & 0 deletions src/snd/stop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "libsnd_i.h"

void _SsSndStop(s16 arg0, s16 arg1)
{
int i;
struct SeqStruct *score;
score = &_ss_score[arg0][arg1];
_ss_score[arg0][arg1].unk90 &= ~1;
_ss_score[arg0][arg1].unk90 &= ~2;
_ss_score[arg0][arg1].unk90 &= ~8;
_ss_score[arg0][arg1].unk90 |= 4;
SpuVmSeqKeyOff(arg1 << 8 | arg0);
score->unk2b = 0;
score->unk80 = 0;
score->unk27 = 0;
score->unk13 = 0;
score->unk14 = 0;
score->unk29 = 0;
score->unk15 = 0;
score->unk16 = 0;
score->unk2a = 0;
score->channel = 0;
score->unk48 = 0;
score->unk27 = 0;
score->unk28 = 0;
score->unk10 = 0;
score->unk11 = 0;
score->delta_value = score->unk7c;
score->unk8c = score->unk84;
score->unk70 = score->unk72;
score->read_pos = score->next_sep_pos;
score->loop_pos = score->next_sep_pos;
for (i = 0; i < 16; i++)
{
score->programs[i] = i;
score->panpot[i] = 0x40;
score->vol[i] = 127;
}

score->unk78 = 0x7F;
score->unk7A = 0x7F;
}

void SsSeqStop(s16 arg0) { _SsSndStop(arg0, 0); }

void SsSepStop(s16 arg0, s16 arg1) { _SsSndStop(arg0, arg1); }

0 comments on commit 8f3fc60

Please sign in to comment.