diff --git a/.github/workflows/master-build.yml b/.github/workflows/master-build.yml new file mode 100644 index 00000000..21161234 --- /dev/null +++ b/.github/workflows/master-build.yml @@ -0,0 +1,69 @@ +name: Official build + +on: + push: + branches: [ master ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: h4570/tyra + steps: + - name: Install dependencies + run: | + apt-get update + apt install -y git make wget + + - name: Set git safe directory + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + + - name: Checkout + uses: actions/checkout@v3 + + - name: Compile engine + run: | + make clean all -C engine + + - name: Compile tutorials + run: | + make clean all -C tutorials/01-hello + make clean all -C tutorials/02-sprite + make clean all -C tutorials/03-minecraft + make clean all -C tutorials/04-de_dust2 + make clean all -C tutorials/05-animation + make clean all -C tutorials/06-audio + make clean all -C tutorials/07-lighting + make clean all -C tutorials/08-skybox-debug + make clean all -C tutorials/09-manual-mode + make clean all -C tutorials/10-sprite-sheet + + - name: Compile demo + run: | + make clean all -C demo + + - name: Upload tutorials + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: tutorials-elf + path: | + tutorials/01-hello/bin + tutorials/02-sprite/bin + tutorials/03-minecraft/bin + tutorials/04-de_dust2/bin + tutorials/05-animation/bin + tutorials/06-audio/bin + tutorials/07-lighting/bin + tutorials/08-skybox-debug/bin + tutorials/09-manual-mode/bin + tutorials/10-sprite-sheet/bin + + - name: Upload demo + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: demo-elf + path: | + demo/bin \ No newline at end of file diff --git a/.github/workflows/pr-build-check.yml b/.github/workflows/pr-build-check.yml new file mode 100644 index 00000000..cadc80ef --- /dev/null +++ b/.github/workflows/pr-build-check.yml @@ -0,0 +1,73 @@ +name: PR build check + +on: + pull_request: + branches: [ master ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: h4570/tyra + steps: + - name: Install dependencies + run: | + apt-get update + apt install -y git make wget + + - name: Set git safe directory + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + + - name: Checkout + uses: actions/checkout@v3 + + - name: Compile engine + run: | + make clean all -C engine + + - name: Compile tutorials + run: | + make clean all -C tutorials/01-hello + make clean all -C tutorials/02-sprite + make clean all -C tutorials/03-minecraft + make clean all -C tutorials/04-de_dust2 + make clean all -C tutorials/05-animation + make clean all -C tutorials/06-audio + make clean all -C tutorials/07-lighting + make clean all -C tutorials/08-skybox-debug + make clean all -C tutorials/09-manual-mode + make clean all -C tutorials/10-sprite-sheet + + - name: Compile demo + run: | + make clean all -C demo + + - name: Get short SHA + id: slug + run: | + echo "SHA8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV + + - name: Get branch + id: branch + run: | + BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/refs\///g' | sed 's/\//_/g') + echo "BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV + + - name: Upload build artifacts + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: binaries-${{ env.SHA8 }}-${{ env.BRANCH }} + path: | + tutorials/01-hello/bin + tutorials/02-sprite/bin + tutorials/03-minecraft/bin + tutorials/04-de_dust2/bin + tutorials/05-animation/bin + tutorials/06-audio/bin + tutorials/07-lighting/bin + tutorials/08-skybox-debug/bin + tutorials/09-manual-mode/bin + tutorials/10-sprite-sheet/bin + demo/bin diff --git a/.github/workflows/check-format.yml b/.github/workflows/pr-format-check.yml similarity index 92% rename from .github/workflows/check-format.yml rename to .github/workflows/pr-format-check.yml index 819d623d..075e80d9 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/pr-format-check.yml @@ -1,5 +1,5 @@ #This is a modified version of the clang format check used on Open-PS2-Loader -name: CI-cpp-check +name: PR C++ format check on: push: @@ -23,6 +23,7 @@ on: jobs: check-format: + name: Check clang format runs-on: ubuntu-latest steps: diff --git a/.vscode/.gitignore b/.vscode/.gitignore index 286a4577..d27630e0 100644 --- a/.vscode/.gitignore +++ b/.vscode/.gitignore @@ -4,4 +4,4 @@ /c_cpp_properties.json /tasks.json /settings.json -ps2dev-intellisense/ +/ps2dev-intellisense diff --git a/.vscode/configurations/windows-docker/tasks.json b/.vscode/configurations/windows-docker/tasks.json index 3e94ea5a..f968c067 100644 --- a/.vscode/configurations/windows-docker/tasks.json +++ b/.vscode/configurations/windows-docker/tasks.json @@ -42,7 +42,7 @@ "options": { "cwd": "${config:buildDirectory}" }, - "command": "./run.ps1" + "command": "Start-Job { ./run.ps1 } | Receive-Job -Wait" }, { "type": "shell", diff --git a/Makefile.base b/Makefile.base index e31c0b78..653ac9aa 100644 --- a/Makefile.base +++ b/Makefile.base @@ -16,7 +16,7 @@ IRXEMBEDDEDEXT := irx-em CFLAGS += -D_EE -Wall -O3 LINKFLAGS += -O3 -Wl,-zmax-page-size=128 ASFLAGS += -O3 -LIB += -lstdc++ -ldma -lpacket2 -lgraph -ldraw -lmath3d -lpng -lz -lpad -laudsrv -lpatches -lcdvd +LIB += -lstdc++ -ldma -lpacket2 -lgraph -ldraw -lmath3d -lpng -ldebug -lz -lpad -laudsrv -lpatches -lcdvd INC += -I$(PS2DEV)/ps2sdk/ee/include -I$(PS2DEV)/ps2sdk/common/include -I$(PS2DEV)/ps2sdk/ports/include #--------------------------------------------------------------------------------- diff --git a/README.MD b/README.MD index 10a37363..ffd1e52a 100644 --- a/README.MD +++ b/README.MD @@ -7,7 +7,7 @@

- Logo + Logo

Tyra

@@ -27,15 +27,12 @@

-[![Stargazers repo roster for h4570/tyra](https://reporoster.com/stars/h4570/tyra)](https://github.com/h4570/tyra/stargazers) - ## Table of Contents * [About the project](#about-the-project) * [Description](#description) * [Tutorials](#tutorials) * [Features](#features) - * [Branches](#branches) * [Contributing](#contributing) * [Games](#games) * [License](#license) @@ -45,8 +42,8 @@ ## About the Project

- Sample code - Sample game + Sample code + Sample game

--- @@ -99,14 +96,10 @@ Decision was simple - I need to create an engine which will handle 3D file loadi * `.md2` 3D file support * `.png` Texture file support -### Branches -* `master` - stable releases - tested on PS2 & PCSX2. -* `develop` - daily builds. +## Contributing See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues). -## Contributing - Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. 1. Fork the Project @@ -148,7 +141,7 @@ Distributed under the Apache License 2.0 License. See `LICENSE` for more informa Without these guys, Tyra would not happen: * [Dr Henry Fortuna](http://ps2-edu.tensioncore.com/index.html) - for code sources, PS2 academy tutorials * Whole [PS2DEV](https://github.com/ps2dev) team, and specially to [Rick Gaiser](https://github.com/rickgaiser), [fjtrujy](https://github.com/fjtrujy) - for a lot of good tips! -* [Wellington Carvalho](https://github.com/Wellinator), [André Guilheme](https://github.com/wolfysdl) - for testing, contributing to Tyra and sharing cool ideas! +* [Wellington Carvalho](https://github.com/Wellinator), [André Guilheme](https://github.com/Wolf3s), [Matías Israelson](https://github.com/israpps) - for testing, contributing to Tyra and sharing cool ideas! * [Leonardo Ono](https://github.com/leonardo-ono) - for software renderer example (with clipping!) * [Lukasz D.K.](https://github.com/lukaszdk) - for huge archive of PS2 stuff * [Guilherme Lampert](https://github.com/glampert) - for code sources @@ -162,7 +155,7 @@ Sandro Sobczyński - sandro.sobczynski@gmail.com
- Logo + Logo [contributors-shield]: https://img.shields.io/github/contributors/h4570/tyra.svg?style=flat-square diff --git a/assets/github-splash.png b/assets/github-splash.png new file mode 100644 index 00000000..a0676e30 Binary files /dev/null and b/assets/github-splash.png differ diff --git a/assets/github-splash2.png b/assets/github-splash2.png new file mode 100644 index 00000000..2c2d9259 Binary files /dev/null and b/assets/github-splash2.png differ diff --git a/assets/showcase.gif b/assets/showcase.gif new file mode 100644 index 00000000..a90fe742 Binary files /dev/null and b/assets/showcase.gif differ diff --git a/assets/tyra_code.gif b/assets/tyra_code.gif new file mode 100644 index 00000000..6c693f7e Binary files /dev/null and b/assets/tyra_code.gif differ diff --git a/assets/vcl b/assets/vcl new file mode 100644 index 00000000..f821acef Binary files /dev/null and b/assets/vcl differ diff --git a/engine/inc/debug/debug.hpp b/engine/inc/debug/debug.hpp index 159bc518..a8d3e97a 100644 --- a/engine/inc/debug/debug.hpp +++ b/engine/inc/debug/debug.hpp @@ -20,6 +20,7 @@ #else // IF Debug #include +#include #include #include #include @@ -81,7 +82,12 @@ class TyraDebug { printf("%s", ss2.str().c_str()); } + init_scr(); for (;;) { + scr_setXY(20, 10); + scr_printf(ss1.str().c_str()); + writeAssertLinesInScreen(args...); + scr_printf(ss2.str().c_str()); } } @@ -103,6 +109,18 @@ class TyraDebug { printf("%s", ss.str().c_str()); } } + + template + static void writeAssertLinesInScreen(Arg&& arg, Args&&... args) { + std::stringstream ss; + + ss << "| " << std::forward(arg) << "\n"; + using expander = int[]; + (void)expander{ + 0, (void(ss << "| " << std::forward(args) << "\n"), 0)...}; + + scr_printf(ss.str().c_str()); + } }; #endif // NDEBUG \ No newline at end of file diff --git a/engine/inc/file/file_utils.hpp b/engine/inc/file/file_utils.hpp index dd5507d5..142856b9 100644 --- a/engine/inc/file/file_utils.hpp +++ b/engine/inc/file/file_utils.hpp @@ -11,6 +11,8 @@ #pragma once #include +#include +#include namespace Tyra { @@ -42,9 +44,9 @@ class FileUtils { private: // Argv name+path & just path - char cwd[255]; - char elfName[255]; - char elfPath[255 - 14]; + char cwd[NAME_MAX]; + char elfName[NAME_MAX]; + char elfPath[NAME_MAX - 14]; void setPathInfo(const char* path); }; diff --git a/engine/inc/irx/irx_loader.hpp b/engine/inc/irx/irx_loader.hpp index a9aa19fc..168797e6 100644 --- a/engine/inc/irx/irx_loader.hpp +++ b/engine/inc/irx/irx_loader.hpp @@ -27,6 +27,7 @@ class IrxLoader { void loadSio2man(const bool& verbose); void loadPadman(const bool& verbose); void loadLibsd(const bool& verbose); + void loadIO(const bool& verbose); void loadUsbModules(const bool& verbose); void loadAudsrv(const bool& verbose); diff --git a/engine/inc/loaders/texture/builder/texture_builder_data.hpp b/engine/inc/loaders/texture/builder/texture_builder_data.hpp index c6b515d0..c617aa45 100644 --- a/engine/inc/loaders/texture/builder/texture_builder_data.hpp +++ b/engine/inc/loaders/texture/builder/texture_builder_data.hpp @@ -33,4 +33,5 @@ class TextureBuilderData { TextureBpp clutBpp; unsigned char clutGsComponents; }; + } // namespace Tyra diff --git a/engine/inc/math/math.hpp b/engine/inc/math/math.hpp index 2aa502ab..6b8b6794 100644 --- a/engine/inc/math/math.hpp +++ b/engine/inc/math/math.hpp @@ -36,9 +36,6 @@ class Math { static int randomi(const int& min, const int& max); static bool equalf(const float& a, const float& b, const float& epsilon = 0.00001F); - - private: - Math(); }; } // namespace Tyra diff --git a/engine/src/file/file_utils.cpp b/engine/src/file/file_utils.cpp index 7277baf2..ca310750 100644 --- a/engine/src/file/file_utils.cpp +++ b/engine/src/file/file_utils.cpp @@ -12,8 +12,7 @@ #include #include #include -#include -#include + #include #include #include "file/file_utils.hpp" diff --git a/engine/src/irx/fileXio.irx-em b/engine/src/irx/fileXio.irx-em new file mode 100644 index 00000000..fbdfe297 --- /dev/null +++ b/engine/src/irx/fileXio.irx-em @@ -0,0 +1,2 @@ +$PS2SDK/iop/irx/fileXio.irx +fileXio_irx diff --git a/engine/src/irx/iomanX.irx-em b/engine/src/irx/iomanX.irx-em new file mode 100644 index 00000000..d83e4fc3 --- /dev/null +++ b/engine/src/irx/iomanX.irx-em @@ -0,0 +1,2 @@ +$PS2SDK/iop/irx/iomanX.irx +iomanX_irx diff --git a/engine/src/irx/irx_loader.cpp b/engine/src/irx/irx_loader.cpp index c36f9b85..ec7f77d0 100644 --- a/engine/src/irx/irx_loader.cpp +++ b/engine/src/irx/irx_loader.cpp @@ -20,30 +20,20 @@ #include "file/file_utils.hpp" // external IRX modules - -extern u8 sio2man_irx[]; -extern int size_sio2man_irx; - -extern u8 padman_irx[]; -extern int size_padman_irx; - -extern u8 audsrv_irx[]; -extern int size_audsrv_irx; - -extern u8 libsd_irx[]; -extern int size_libsd_irx; - -extern u8 bdm_irx[]; -extern int size_bdm_irx; - -extern u8 bdmfs_fatfs_irx[]; -extern int size_bdmfs_fatfs_irx; - -extern u8 usbd_irx[]; -extern int size_usbd_irx; - -extern u8 usbmass_bd_irx[]; -extern int size_usbmass_bd_irx; +#define EXTERN_IRX(_irx) \ + extern u8 _irx[]; \ + extern int size_##_irx + +EXTERN_IRX(sio2man_irx); +EXTERN_IRX(padman_irx); +EXTERN_IRX(audsrv_irx); +EXTERN_IRX(libsd_irx); +EXTERN_IRX(fileXio_irx); +EXTERN_IRX(iomanX_irx); +EXTERN_IRX(bdm_irx); +EXTERN_IRX(bdmfs_fatfs_irx); +EXTERN_IRX(usbd_irx); +EXTERN_IRX(usbmass_bd_irx); namespace Tyra { @@ -70,6 +60,7 @@ void IrxLoader::loadAll(const bool& withUsb, const bool& isLoggingToFile) { return; } + loadIO(!isLoggingToFile); loadSio2man(!isLoggingToFile); loadPadman(!isLoggingToFile); loadLibsd(!isLoggingToFile); @@ -116,6 +107,24 @@ void IrxLoader::loadLibsd(const bool& verbose) { if (verbose) TYRA_LOG("IRX: Libsd loaded!"); } +void IrxLoader::loadIO(const bool& verbose) { + int ret; + if (verbose) TYRA_LOG("IRX: Loading iomanX..."); + + SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, nullptr, &ret); + TYRA_ASSERT(ret >= 0, "Failed to load module: iomanX_irx"); + + if (verbose) TYRA_LOG("IRX: iomanX loaded!"); + + if (verbose) TYRA_LOG("IRX: Loading fileXio..."); + + SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, nullptr, &ret); + TYRA_ASSERT(ret >= 0, "Failed to load module: fileXio_irx"); + + if (verbose) TYRA_LOG("IRX: fileXio_irx loaded!"); + +} + void IrxLoader::loadUsbModules(const bool& verbose) { if (verbose) TYRA_LOG("IRX: Loading usb modules..."); diff --git a/template/windows-pcsx2.ps1 b/template/windows-pcsx2.ps1 index 98f87fed..6543a596 100644 --- a/template/windows-pcsx2.ps1 +++ b/template/windows-pcsx2.ps1 @@ -1,12 +1,76 @@ -$PCSX2_PATH = "${Env:ProgramFiles(x86)}/PCSX2" -$PCSX2_EXE = 'pcsx2.exe' +# ======================= +$CUSTOM_PCSX2_PATH = "" # "D:/My/Path/To/PCSX2" +# ======================= function GetTargetELFName { return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value } +function FindPCSX2Directory { + if (-not [string]::IsNullOrEmpty($CUSTOM_PCSX2_PATH)) { + return $CUSTOM_PCSX2_PATH + } + else { + # Try to find in program files + $pcsx2Path = "${Env:ProgramFiles}/PCSX2" + $pcsx2Pathx86 = "${Env:ProgramFiles(x86)}/PCSX2" + + if (Test-Path -Path $pcsx2Path) { + return $pcsx2Path + } + elseif (Test-Path -Path $pcsx2Pathx86) { + return $pcsx2Pathx86 + } + else { + throw "PCSX2 directory not found!" + return $null + } + } +} + +function IsNewQtVersionOfPCSX2 { + param ( + [string]$path + ) + + return Test-Path -Path "$path/qt.conf" +} + +function FindPCSX2Executable { + param ( + [string]$directory + ) + + $pcsx2ExePath = Join-Path -Path $directory -ChildPath 'pcsx2.exe' + $pcsx2QtExePath = Join-Path -Path $directory -ChildPath 'pcsx2-qt.exe' + + if (Test-Path -Path $pcsx2ExePath) { + return 'pcsx2.exe' + } + elseif (Test-Path -Path $pcsx2QtExePath) { + return 'pcsx2-qt.exe' + } + else { + throw "PCSX2 executable not found in: $directory!" + return $null + } +} + function RunPCSX2 { - $PCSX2_EXE_WITHOUT_EXT = (Split-Path $PCSX2_EXE -Leaf).Split('.')[0] - Stop-Process -Name $PCSX2_EXE_WITHOUT_EXT -ErrorAction 'SilentlyContinue' - Start-Process -FilePath "$PCSX2_PATH/$PCSX2_EXE" -ArgumentList "--elf=$PWD/bin/$(GetTargetELFName)" -} \ No newline at end of file + $dirPath = FindPCSX2Directory + $isNewVersion = IsNewQtVersionOfPCSX2 -path $dirPath + $executableName = FindPCSX2Executable -directory $dirPath + $executableNameWithoutExt = (Split-Path $executableName -Leaf).Split('.')[0] + $targetFileName = "$PWD/bin/$(GetTargetELFName)" + + Stop-Process -Name $executableNameWithoutExt -ErrorAction 'SilentlyContinue' + + if ($isNewVersion) { + Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "-elf", $targetFileName + } + else { # Old version of PCSX2 + Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "--elf=$targetFileName" + } +} + +RunPCSX2 \ No newline at end of file diff --git a/windows-pcsx2.ps1 b/windows-pcsx2.ps1 index 98f87fed..6543a596 100644 --- a/windows-pcsx2.ps1 +++ b/windows-pcsx2.ps1 @@ -1,12 +1,76 @@ -$PCSX2_PATH = "${Env:ProgramFiles(x86)}/PCSX2" -$PCSX2_EXE = 'pcsx2.exe' +# ======================= +$CUSTOM_PCSX2_PATH = "" # "D:/My/Path/To/PCSX2" +# ======================= function GetTargetELFName { return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value } +function FindPCSX2Directory { + if (-not [string]::IsNullOrEmpty($CUSTOM_PCSX2_PATH)) { + return $CUSTOM_PCSX2_PATH + } + else { + # Try to find in program files + $pcsx2Path = "${Env:ProgramFiles}/PCSX2" + $pcsx2Pathx86 = "${Env:ProgramFiles(x86)}/PCSX2" + + if (Test-Path -Path $pcsx2Path) { + return $pcsx2Path + } + elseif (Test-Path -Path $pcsx2Pathx86) { + return $pcsx2Pathx86 + } + else { + throw "PCSX2 directory not found!" + return $null + } + } +} + +function IsNewQtVersionOfPCSX2 { + param ( + [string]$path + ) + + return Test-Path -Path "$path/qt.conf" +} + +function FindPCSX2Executable { + param ( + [string]$directory + ) + + $pcsx2ExePath = Join-Path -Path $directory -ChildPath 'pcsx2.exe' + $pcsx2QtExePath = Join-Path -Path $directory -ChildPath 'pcsx2-qt.exe' + + if (Test-Path -Path $pcsx2ExePath) { + return 'pcsx2.exe' + } + elseif (Test-Path -Path $pcsx2QtExePath) { + return 'pcsx2-qt.exe' + } + else { + throw "PCSX2 executable not found in: $directory!" + return $null + } +} + function RunPCSX2 { - $PCSX2_EXE_WITHOUT_EXT = (Split-Path $PCSX2_EXE -Leaf).Split('.')[0] - Stop-Process -Name $PCSX2_EXE_WITHOUT_EXT -ErrorAction 'SilentlyContinue' - Start-Process -FilePath "$PCSX2_PATH/$PCSX2_EXE" -ArgumentList "--elf=$PWD/bin/$(GetTargetELFName)" -} \ No newline at end of file + $dirPath = FindPCSX2Directory + $isNewVersion = IsNewQtVersionOfPCSX2 -path $dirPath + $executableName = FindPCSX2Executable -directory $dirPath + $executableNameWithoutExt = (Split-Path $executableName -Leaf).Split('.')[0] + $targetFileName = "$PWD/bin/$(GetTargetELFName)" + + Stop-Process -Name $executableNameWithoutExt -ErrorAction 'SilentlyContinue' + + if ($isNewVersion) { + Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "-elf", $targetFileName + } + else { # Old version of PCSX2 + Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "--elf=$targetFileName" + } +} + +RunPCSX2 \ No newline at end of file