diff --git a/.gitignore b/.gitignore index 8205663..74ba09d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ build -# psxdev_sample -toolchain/pcsx_redux +psxdev_sample toolchain/armips +toolchain/pcsx-redux +toolchain/psyq_iwyu *.exe - *.elf *.map *.cpe @@ -12,5 +12,3 @@ toolchain/armips *.dep *.o *.a - -psxdev_sample/SpinningCube/third_party diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b89b2d3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "files.associations": { + "*.rmd": "markdown", + "*.s": "armips", + "stdlib.h": "c", + "libetc.h": "c", + "libgpu.h": "c" + } +} \ No newline at end of file diff --git a/code/hello_psyqo/hello_psyqo.s b/code/hello_psyq/hello_psyq.s similarity index 100% rename from code/hello_psyqo/hello_psyqo.s rename to code/hello_psyq/hello_psyq.s diff --git a/code/hello_psyq/hookup.c b/code/hello_psyq/hookup.c new file mode 100644 index 0000000..3c55b46 --- /dev/null +++ b/code/hello_psyq/hookup.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include + +#define OTSIZE 4096 +#define SCREEN_Z 512 + +typedef struct DB { + DRAWENV draw; + DISPENV disp; + u_long ot[OTSIZE]; + POLY_F4 s[6]; +} DB; + + +int main(void) +{ + DB db[2]; + DB *cdb; + + ResetGraph(0); + InitGeom(); + + SetGraphDebug(0); + + FntLoad(960, 256); + SetDumpFnt(FntOpen(32, 32, 320, 64, 0, 512)); + + SetGeomOffset(320, 240); + SetGeomScreen(SCREEN_Z); + + SetDefDrawEnv(&db[0].draw, 0, 0, 640, 480); + SetDefDrawEnv(&db[1].draw, 0, 0, 640, 480); + SetDefDispEnv(&db[0].disp, 0, 0, 640, 480); + SetDefDispEnv(&db[1].disp, 0, 0, 640, 480); + + while (1) { + FntPrint("Code compiled using Psy-Q libraries\n\n"); + FntPrint("converted by psyq-obj-parser\n\n"); + FntPrint("PCSX-Redux project\n\n"); + FntPrint("https://bit.ly/pcsx-redux"); + + ClearImage(&cdb->draw.clip, 60, 120, 120); + + DrawSync(0); + VSync(0); + } + + return 0; +} diff --git a/code/hello_psyqo/hookup.c b/code/hello_psyqo/hookup.c deleted file mode 100644 index e69de29..0000000 diff --git a/readme.md b/readme.md index b22f60f..0141cb1 100644 --- a/readme.md +++ b/readme.md @@ -48,6 +48,8 @@ scoop install lua * Fixes psyq headers to include what they use, so changing the include order in your project doesn't break compiling. * Needed if you want to link and utilize the psyq C SDK +[Other toolchains (not used here)](https://www.psx.dev/getting-started) + ## Gallery ![clear!](./docs/assets/pcsx-redux.main_2025-08-03_18-02-08.png) diff --git a/scripts/build_psyq.ps1 b/scripts/build_psyq.ps1 index 867870f..5bc5a6a 100644 --- a/scripts/build_psyq.ps1 +++ b/scripts/build_psyq.ps1 @@ -16,9 +16,10 @@ if ((test-path $path_build) -eq $false) { # --- Toolchain Definition --- # Assumes 'mipsel-none-elf' toolchain is in your system's PATH. -$Prefix = "mipsel-none-elf" -$Compiler = "$($Prefix)-gcc" -$Objcopy = "$($Prefix)-objcopy" +$Prefix = "mipsel-none-elf" +$Compiler = "$($Prefix)-gcc" +$Assembler = $Compiler +$Objcopy = "$($Prefix)-objcopy" # --- Abstracted GCC/MIPS Flags --- @@ -76,22 +77,19 @@ $f_link_lib = "-l" # Objcopy Flags $f_objcopy_format = "-O" - - -$path_nugget = join-path $path_third_party 'nugget' -$path_psyq = join-path $path_third_party 'psyq' -$path_psyq_imyu = join-path $path_third_party 'psyq-iwyu' - -$path_nugget_common = join-path $path_nugget 'common' - +$path_pcsx_redux = join-path $path_toolchain 'pcsx-redux' +$path_nugget = join-path $path_pcsx_redux 'src/mips' +$path_nugget_common = join-path $path_nugget 'common' +$path_psyq_iwyu = join-path $path_toolchain 'psyq_iwyu' +$path_psyq_imyu_inc = join-path $path_psyq_imyu 'include' function assemble-unit { param( [string] $unit, [stirng] $link_module, [string[]]$include_paths, - [string[]]$user_compile_args + [string[]]$user_assemble_args ) - $compile_args = @( + $assemble_args = @( $f_arch_mips1, $f_arch_abi32, $f_arch_fp32, @@ -102,17 +100,22 @@ function assemble-unit { param( $f_arch_no_shared, $f_arch_no_stack_prot ) - $compile_args += $f_no_stdlib - $compile_args += $f_freestanding - $compile_args += ($f_include + $path_nugget) + $assemble_args += $f_no_stdlib + $assemble_args += $f_freestanding + $assemble_args += ($f_include + $path_nugget) - $compile_args += $user_compile_args + $assemble_args += $user_assemble_args + $assemble_args += $f_compile, $unit, ($f_output + $link_module) + write-host "Assembling '$unit' -> '$link_module'" + $assemble_args | ForEach-Object { Write-Host "`t$_" -ForegroundColor Green } + & $Assembler $assemble_args + if ($LASTEXITCODE -ne 0) { write-error "Compilation failed for $unit. Aborting."; exit 1 } } function compile-unit { param( - [string]$unit, - [string]$link_module, + [string] $unit, + [string] $link_module, [string[]]$include_paths, [string[]]$user_compile_args ) @@ -140,13 +143,17 @@ function compile-unit { param( $f_arch_no_shared, $f_arch_no_stack_prot ) - $path_psyq_imyu_inc = join-path $path_psyq_imyu 'include' $compile_args += ($f_include + $path_psyq_imyu_inc) $compile_args += ($f_include + $path_nugget) $compile_args += $user_compile_args + $compile_args += $f_compile, $unit, ($f_output + $link_module) + write-host "Compiling '$unit' -> '$link_module'" + $compile_args | ForEach-Object { Write-Host "`t$_" -ForegroundColor Green } + & $Compiler $compile_args + if ($LASTEXITCODE -ne 0) { write-error "Compilation failed for $unit. Aborting."; exit 1 } } function link-modules { param( [string] $elf, @@ -232,6 +239,13 @@ function make-binary { param( } function build-hello_psyqo { + $path_hello_psyq + + $assemble_arsg = @() + $assemble_arsg += $f_debug + $assemble_arsg += $f_optimize_none + assemble-unit + $compile_args = @() $compile_args += $f_debug $compile_args += $f_optimize_none diff --git a/scripts/update_deps.ps1 b/scripts/update_deps.ps1 index f487659..f104546 100644 --- a/scripts/update_deps.ps1 +++ b/scripts/update_deps.ps1 @@ -16,12 +16,15 @@ $misc = join-path $PSScriptRoot 'helpers/misc.ps1' $url_armips = 'https://github.com/Kingcom/armips.git' $url_pcsx_redux = 'https://github.com/grumpycoders/pcsx-redux.git' +$url_psyq_iwyu = 'https://github.com/johnbaumann/psyq_include_what_you_use.git' $path_armips = join-path $path_toolchain 'armips' $path_pcsx_redux = join-path $path_toolchain 'pcsx-redux' +$path_psyq_iwyu = join-path $path_toolchain 'psyq_iwyu' clone-gitrepo $path_armips $url_armips clone-gitrepo $path_pcsx_redux $url_pcsx_redux +clone-gitrepo $path_psyq_iwyu $url_psyq_iwyu $path_armips_build = join-path $path_armips 'build' verify-path $path_armips_build