commit 401fce7918a3904e89a108932439c73205ca5e66 Author: Rui Barbosa Date: Thu Jun 11 00:49:08 2026 +0100 Move tyra-linux template into its own repo diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..ce4cc1b --- /dev/null +++ b/.clang-format @@ -0,0 +1,40 @@ +# Use the Google style in this project. +BasedOnStyle: Google + +# Some folks prefer to write "int& foo" while others prefer "int &foo". The +# Google Style Guide only asks for consistency within a project, we chose +# "int& foo" for this project: +DerivePointerAlignment: false +PointerAlignment: Left + +SortIncludes: false + +IncludeBlocks: Merge +IncludeCategories: +# Matches common headers first, but sorts them after project includes +- Regex: '^\"google/cloud/internal/disable_deprecation_warnings.inc\"$' + Priority: -1 +- Regex: '^\"google/cloud/(internal/|grpc_utils/|testing_util/|[^/]+\.h)' + Priority: 1000 +- Regex: '^\"google/cloud/' # project includes should sort first + Priority: 500 +- Regex: '^\"' + Priority: 1500 +- Regex: '^' + Priority: 5000 + +# Format raw string literals with a `pb` or `proto` tag as proto. +RawStringFormats: +- Language: TextProto + Delimiters: + - 'pb' + - 'proto' + BasedOnStyle: Google + +CommentPragmas: '(@copydoc)' \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b63d312 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +*.elf +.git/ +.vscode/ +docs/ +tools/ \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9103071 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Ignore all differences in line endings +* -crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5fc9f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# --- + +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.vsm + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app +*.erl +*.elf diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 0000000..dae89fb --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1,6 @@ +*.log + +# Configuration files +/c_cpp_properties.json +/tasks.json +/settings.json diff --git a/.vscode/configurations/linux-docker/c_cpp_properties.json b/.vscode/configurations/linux-docker/c_cpp_properties.json new file mode 100644 index 0000000..9c65761 --- /dev/null +++ b/.vscode/configurations/linux-docker/c_cpp_properties.json @@ -0,0 +1,41 @@ +{ + "configurations": [ + { + "name": "Docker PS2SDK (Linux)", + "includePath": [ + "${workspaceFolder}/**", + "~/ps2dev-intellisense/ps2sdk/common/include/**", + "~/ps2dev-intellisense/ps2sdk/ee/include/**", + "~/ps2dev-intellisense/ps2sdk/iop/include/**", + "~/ps2dev-intellisense/ps2sdk/ports/include/**", + "~/ps2dev-intellisense/ee/include/**", + "~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include/**", + "~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include-fixed/**", + "~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/install-tools/include/**", + "~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/plugin/include/**", + "~/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/include/**", + "~/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/sys-include/**", + "~/ps2dev-intellisense/gsKit/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/install-tools/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/plugin/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include-fixed/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/install-tools/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/plugin/include/**", + "~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include-fixed/**" + ], + "defines": [ + "_EE", + "_IOP", + "__SPU__", + "INTELLISENSE" + ], + "cppStandard": "c++20", + "compilerPath": "", // Should be empty + "intelliSenseMode": "linux-gcc-x86", + "configurationProvider": "ms-vscode.cpptools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/configurations/linux-docker/settings.json b/.vscode/configurations/linux-docker/settings.json new file mode 100644 index 0000000..85108a6 --- /dev/null +++ b/.vscode/configurations/linux-docker/settings.json @@ -0,0 +1,14 @@ +{ + "buildDirectory": "./", + "C_Cpp.default.intelliSenseMode": "gcc-x86", + "files.associations": { + "*.vcl": "asm-collection", + "*.i": "asm-collection", + "*.vsm": "asm-collection", + "*.vclpp": "asm-collection", + "*.hpp": "cpp", + "*.cpp": "cpp", + "*.h": "c", + "*.c": "c" + } +} \ No newline at end of file diff --git a/.vscode/configurations/linux-docker/tasks.json b/.vscode/configurations/linux-docker/tasks.json new file mode 100644 index 0000000..e1038b0 --- /dev/null +++ b/.vscode/configurations/linux-docker/tasks.json @@ -0,0 +1,130 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build & run", + "dependsOrder": "sequence", + "dependsOn": [ + "1. Copy source code to docker volume", + "2. Compile via docker container", + "3. Copy binaries to host", + "4. Run PCSX2" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "type": "shell", + "label": "1. Copy source code to docker volume", + "command": "docker exec -t tyra-game-compiler sh -c 'rsync -ac --delete --exclude=\".git\" --exclude=\".vscode\" --exclude=\"*obj*/**\" --exclude=\"*bin*/**\" /host/ /src/'" + }, + { + "type": "shell", + "label": "2. Compile via docker container", + "command": "docker exec -t tyra-game-compiler sh -c 'cd ${config:buildDirectory} && make'", + "problemMatcher": { + "base": "$gcc", + "fileLocation": [ + "autoDetect" + ] + } + }, + { + "type": "shell", + "label": "3. Copy binaries to host", + "command": "docker exec -t tyra-game-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"*bin*/**\" --exclude=\"*\" /src/ /host/'" + }, + { + "type": "shell", + "label": "4. Run PCSX2", + "options": { + "cwd": "${config:buildDirectory}" + }, + "command": "./run.ps1" + }, + { + "type": "shell", + "label": "Convert WAV to ADPCM", + "dependsOn": [ + "1. Copy source code to docker volume" + ], + "command": "docker exec -t tyra-game-compiler sh -c 'adpenc ${input:wav2adpcmSource} ${input:wav2adpcmTarget} && rsync -zac /src/${input:wav2adpcmTarget} /host/${input:wav2adpcmTarget}'" + }, + { + "type": "shell", + "label": "Cleanup", + "command": "docker exec -t tyra-game-compiler sh -c 'rm -rf /src/*'" + }, + { + "type": "shell", + "label": "Update Tyra", + "command": "docker exec -t tyra-game-compiler sh -c 'rm -rf /tyra && mkdir -p /tyra && git clone https://github.com/h4570/tyra.git /tyra && cd /tyra && git checkout ${input:tyraBranch} && cd engine && make'" + }, + { + "type": "shell", + "label": "Send to PS2", + "command": "docker exec -t tyra-game-compiler sh -c 'cd ${config:buildDirectory}/bin && killall -v ps2client || true && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} execee host:$(find . -maxdepth 1 -type f -name \"*.elf\")'" + }, + { + "type": "shell", + "label": "Open PS2 output logger", + "command": "docker stop ps2-logs || true && docker run -t --rm --name=ps2-logs -p ${input:local2Ip}:18194:18194/udp h4570/tyra sh -c 'ps2client -h ${input:ps2Ip} listen'", + "runOptions": { + "instanceLimit": 1 + }, + "presentation": { + "reveal": "always", + "panel": "new" + } + }, + { + "type": "shell", + "label": "Start docker container", + "command": "docker compose up -d" + }, + { + "type": "shell", + "label": "Stop docker container", + "command": "docker compose down" + }, + { + "type": "shell", + "label": "[Debug] Copy obj directory to host", + "command": "docker exec -t tyra-game-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"obj/**\" --exclude=\"*\" /src/ /host/'" + } + ], + "inputs": [ + { + "id": "wav2adpcmSource", + "description": "Source file path (ex. ):", + "default": "res/sound.wav", + "type": "promptString" + }, + { + "id": "wav2adpcmTarget", + "description": "Target file path (ex. ):", + "default": "res/sound.adpcm", + "type": "promptString" + }, + { + "id": "ps2Ip", + "description": "PS2link ip address:", + "default": "192.168.1.200", + "type": "promptString" + }, + { + "id": "local2Ip", + "description": "Local ip address:", + "default": "192.168.1.245", + "type": "promptString" + }, + { + "id": "tyraBranch", + "description": "Tyra branch:", + "default": "master", + "type": "promptString" + } + ] +} \ No newline at end of file diff --git a/.vscode/configurations/windows-docker/c_cpp_properties.json b/.vscode/configurations/windows-docker/c_cpp_properties.json new file mode 100644 index 0000000..0aeba68 --- /dev/null +++ b/.vscode/configurations/windows-docker/c_cpp_properties.json @@ -0,0 +1,42 @@ +{ + "configurations": [ + { + "name": "Docker PS2SDK", + "includePath": [ + "${workspaceFolder}/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/tyra/inc/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/common/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/ee/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/iop/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/ports/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include-fixed/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/install-tools/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/plugin/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/sys-include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/gsKit/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/install-tools/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/plugin/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include-fixed/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/install-tools/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/plugin/include/**", + "C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include-fixed/**" + ], + "defines": [ + "_EE", + "_IOP", + "__SPU__", + "INTELLISENSE" + ], + "cppStandard": "c++20", + "compilerPath": "", // Should be empty + "intelliSenseMode": "linux-gcc-x86", + "configurationProvider": "ms-vscode.cpptools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/configurations/windows-docker/settings.json b/.vscode/configurations/windows-docker/settings.json new file mode 100644 index 0000000..f5f4d52 --- /dev/null +++ b/.vscode/configurations/windows-docker/settings.json @@ -0,0 +1,14 @@ +{ + "buildDirectory": "./", + "C_Cpp.default.intelliSenseMode": "gcc-x86", + "files.associations": { + "*.vcl": "asm-collection", + "*.i": "asm-collection", + "*.vsm": "asm-collection", + "*.vclpp": "asm-collection", + "*.hpp": "cpp", + "*.cpp": "cpp", + "*.h": "c", + "*.c": "c" + } +} \ No newline at end of file diff --git a/.vscode/configurations/windows-docker/tasks.json b/.vscode/configurations/windows-docker/tasks.json new file mode 100644 index 0000000..18e713a --- /dev/null +++ b/.vscode/configurations/windows-docker/tasks.json @@ -0,0 +1,130 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build & run", + "dependsOrder": "sequence", + "dependsOn": [ + "1. Copy source code to docker volume", + "2. Compile via docker container", + "3. Copy binaries to host", + "4. Run PCSX2" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "type": "shell", + "label": "1. Copy source code to docker volume", + "command": "docker exec -t tyra-game-compiler sh -c 'rsync -ac --delete --exclude=\".git\" --exclude=\".vscode\" --exclude=\"*obj*/**\" --exclude=\"*bin*/**\" /host/ /src/'" + }, + { + "type": "shell", + "label": "2. Compile via docker container", + "command": "docker exec -t tyra-game-compiler sh -c 'cd ${config:buildDirectory} && make'", + "problemMatcher": { + "base": "$gcc", + "fileLocation": [ + "autoDetect" + ] + } + }, + { + "type": "shell", + "label": "3. Copy binaries to host", + "command": "docker exec -t tyra-game-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"*bin*/**\" --exclude=\"*\" /src/ /host/'" + }, + { + "type": "shell", + "label": "4. Run PCSX2", + "options": { + "cwd": "${config:buildDirectory}" + }, + "command": "./run.ps1" + }, + { + "type": "shell", + "label": "Convert WAV to ADPCM", + "dependsOn": [ + "1. Copy source code to docker volume" + ], + "command": "docker exec -t tyra-game-compiler sh -c 'adpenc ${input:wav2adpcmSource} ${input:wav2adpcmTarget} && rsync -zac /src/${input:wav2adpcmTarget} /host/${input:wav2adpcmTarget}'" + }, + { + "type": "shell", + "label": "Cleanup", + "command": "docker exec -t tyra-game-compiler sh -c 'rm -rf /src/*'" + }, + { + "type": "shell", + "label": "Update Tyra", + "command": "docker exec -t tyra-game-compiler sh -c 'rm -rf /tyra && mkdir -p /tyra && git clone https://github.com/h4570/tyra.git /tyra && cd /tyra && git checkout ${input:tyraBranch} && cd engine && make'" + }, + { + "type": "shell", + "label": "Send to PS2", + "command": "docker exec -t tyra-game-compiler sh -c 'cd ${config:buildDirectory}/bin && killall -v ps2client || $true && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} execee host:$(find . -maxdepth 1 -type f -name \"*.elf\")'" + }, + { + "type": "shell", + "label": "Open PS2 output logger", + "command": "docker stop ps2-logs || $true && docker run -t --rm --name=ps2-logs -p ${input:local2Ip}:18194:18194/udp h4570/tyra sh -c 'ps2client -h ${input:ps2Ip} listen'", + "runOptions": { + "instanceLimit": 1 + }, + "presentation": { + "reveal": "always", + "panel": "new" + } + }, + { + "type": "shell", + "label": "Start docker container", + "command": "docker compose up -d" + }, + { + "type": "shell", + "label": "Stop docker container", + "command": "docker compose down" + }, + { + "type": "shell", + "label": "[Debug] Copy obj directory to host", + "command": "docker exec -t tyra-game-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"obj/**\" --exclude=\"*\" /src/ /host/'" + } + ], + "inputs": [ + { + "id": "wav2adpcmSource", + "description": "Source file path (ex. ):", + "default": "res/sound.wav", + "type": "promptString" + }, + { + "id": "wav2adpcmTarget", + "description": "Target file path (ex. ):", + "default": "res/sound.adpcm", + "type": "promptString" + }, + { + "id": "ps2Ip", + "description": "PS2link ip address:", + "default": "192.168.1.200", + "type": "promptString" + }, + { + "id": "local2Ip", + "description": "Local ip address:", + "default": "192.168.1.245", + "type": "promptString" + }, + { + "id": "tyraBranch", + "description": "Tyra branch:", + "default": "master", + "type": "promptString" + } + ] +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..e1776e9 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "ms-vscode.cpptools-extension-pack", + "ryzngard.vscode-header-source", + "maziac.asm-code-lens", + "dmnsgn.vscode-wavefront", + "spmeesseman.vscode-taskexplorer" + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..09e5223 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# syntax=docker/dockerfile:1 +FROM h4570/tyra + +RUN apt-get update +RUN apt-get install git -y + +WORKDIR /src +CMD ["/bin/bash"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..24c9a97 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +TARGET := racer.elf +ENGINEDIR := /tyra/engine + +#The Directories, Source, Includes, Objects, Binary and Resources +SRCDIR := src +INCDIR := inc +BUILDDIR := obj +TARGETDIR := bin +RESDIR := res +SRCEXT := cpp +VSMEXT := vsm +VCLEXT := vcl +VCLPPEXT := vclpp +DEPEXT := d +OBJEXT := o + +#Flags, Libraries and Includes +CFLAGS := +LIB := -ltyra +LIBDIRS := -L$(ENGINEDIR)/bin +INC := -I$(INCDIR) -I$(ENGINEDIR)/inc +INCDEP := -I$(INCDIR) -I$(ENGINEDIR)/inc + +include /tyra/Makefile.base + +clean-engine: + cd $(ENGINEDIR) && $(MAKE) cleaner + +build-engine: + cd $(ENGINEDIR) && $(MAKE) + +build-release-engine: + cd $(ENGINEDIR) && $(MAKE) release \ No newline at end of file diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..44c5ea8 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..56ce57a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3.9" +volumes: + tyra-game-volume: +services: + compiler: + environment: + TERM: xterm-256color + network_mode: host + build: + context: ./ + dockerfile: Dockerfile + tty: true + container_name: tyra-game-compiler + volumes: + - tyra-game-volume:/src + - ./:/host diff --git a/inc/racer_game.hpp b/inc/racer_game.hpp new file mode 100644 index 0000000..01436c6 --- /dev/null +++ b/inc/racer_game.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace Racer { + +class RacerGame : public Tyra::Game { + public: + RacerGame(Tyra::Engine* engine); + ~RacerGame(); + + void init(); + void loop(); + + private: + Tyra::Engine* engine; +}; + +} // namespace Racer diff --git a/linux-pcsx2.sh b/linux-pcsx2.sh new file mode 100755 index 0000000..3324589 --- /dev/null +++ b/linux-pcsx2.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# ======================= +CUSTOM_PCSX2_PATH="" # e.g. "/usr/bin/pcsx2" or "flatpak run net.pcsx2.PCSX2" +# ======================= + +get_target_elf_name() { + if [ -f "./Makefile" ]; then + grep -oP '\S+\.elf' Makefile | head -n 1 + else + echo "" + fi +} + +find_pcsx2() { + if [ -n "$CUSTOM_PCSX2_PATH" ]; then + echo "$CUSTOM_PCSX2_PATH" + return 0 + fi + + # Check flatpak + if command -v flatpak >/dev/null 2>&1 && flatpak list | grep -q "net.pcsx2.PCSX2"; then + echo "flatpak run net.pcsx2.PCSX2" + return 0 + fi + + # Check if pcsx2-qt is in PATH + if command -v pcsx2-qt >/dev/null 2>&1; then + echo "pcsx2-qt" + return 0 + fi + + # Check if pcsx2 is in PATH + if command -v pcsx2 >/dev/null 2>&1; then + echo "pcsx2" + return 0 + fi + + echo "Error: PCSX2 not found! Please install it, put it in PATH, or specify CUSTOM_PCSX2_PATH in this script." >&2 + exit 1 +} + +run_pcsx2() { + local pcsx2_cmd + pcsx2_cmd=$(find_pcsx2) + + local elf_name + elf_name=$(get_target_elf_name) + if [ -z "$elf_name" ]; then + echo "Error: Could not find target ELF name in Makefile!" >&2 + exit 1 + fi + + local target_file + target_file="$(pwd)/bin/$elf_name" + + if [ ! -f "$target_file" ]; then + echo "Error: ELF file not found at $target_file. Did you build the project?" >&2 + exit 1 + fi + + # Kill existing PCSX2 instances + if [[ "$pcsx2_cmd" == *"flatpak"* ]]; then + pkill -f "net.pcsx2.PCSX2" >/dev/null 2>&1 || true + pkill -f "pcsx2-qt" >/dev/null 2>&1 || true + else + local bin_name + bin_name=$(basename "$pcsx2_cmd") + pkill "$bin_name" >/dev/null 2>&1 || true + fi + + echo "Running PCSX2: $pcsx2_cmd -elf $target_file" + + # Run PCSX2 in the background + $pcsx2_cmd -elf "$target_file" & +} + +run_pcsx2 diff --git a/obj/.gitignore b/obj/.gitignore new file mode 100644 index 0000000..44c5ea8 --- /dev/null +++ b/obj/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/res/.gitignore b/res/.gitignore new file mode 100644 index 0000000..44c5ea8 --- /dev/null +++ b/res/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/run.ps1 b/run.ps1 new file mode 100644 index 0000000..b2f7754 --- /dev/null +++ b/run.ps1 @@ -0,0 +1,4 @@ +$ConfigFile = Join-Path $PSScriptRoot './windows-pcsx2.ps1' +. $ConfigFile + +RunPCSX2 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..6e8e2db --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +cd "$SCRIPT_DIR" || exit 1 +./linux-pcsx2.sh diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b9d8bde --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,10 @@ +#include +#include "racer_game.hpp" + +int main() { + Tyra::Engine engine; + Racer::RacerGame game(&engine); + engine.run(&game); + SleepThread(); + return 0; +} diff --git a/src/racer_game.cpp b/src/racer_game.cpp new file mode 100644 index 0000000..a004e61 --- /dev/null +++ b/src/racer_game.cpp @@ -0,0 +1,14 @@ +#include "racer_game.hpp" + +namespace Racer { + +using namespace Tyra; + +RacerGame::RacerGame(Engine* t_engine) { engine = t_engine; } +RacerGame::~RacerGame() {} + +void RacerGame::init() { TYRA_LOG("Hello!"); } + +void RacerGame::loop() { TYRA_LOG("Loop!"); } + +} // namespace Racer diff --git a/windows-pcsx2.ps1 b/windows-pcsx2.ps1 new file mode 100644 index 0000000..6543a59 --- /dev/null +++ b/windows-pcsx2.ps1 @@ -0,0 +1,76 @@ +# ======================= +$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 { + $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