Skip to content

Commit 85bcd06

Browse files
committed
uh
0 parents  commit 85bcd06

41 files changed

Lines changed: 9092 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build-linux:
11+
name: Linux (GCC)
12+
runs-on: ubuntu-24.04
13+
strategy:
14+
matrix:
15+
build_type: [Release, Debug]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y cmake g++ pkg-config libgl-dev libvulkan-dev zlib1g-dev
23+
24+
- name: Configure
25+
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
26+
27+
- name: Build
28+
run: cmake --build build -j$(nproc)
29+
30+
- name: Verify binary
31+
run: test -f build/YAPS1
32+
33+
build-linux-clang:
34+
name: Linux (Clang)
35+
runs-on: ubuntu-24.04
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Install dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y cmake clang pkg-config libgl-dev libvulkan-dev zlib1g-dev
43+
44+
- name: Configure
45+
run: CC=clang CXX=clang++ cmake -B build -DCMAKE_BUILD_TYPE=Release
46+
47+
- name: Build
48+
run: cmake --build build -j$(nproc)
49+
50+
build-windows:
51+
name: Windows (MSVC)
52+
runs-on: windows-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Configure
57+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
58+
59+
- name: Build
60+
run: cmake --build build --config Release
61+
62+
- name: Verify binary
63+
run: Test-Path build/Release/YAPS1.exe
64+
65+
build-macos:
66+
name: macOS (Clang)
67+
runs-on: macos-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Configure
72+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
73+
74+
- name: Build
75+
run: cmake --build build -j$(sysctl -n hw.ncpu)

.github/workflows/release.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Build & Release (${{ matrix.os }}, ${{ matrix.asset_suffix }})
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-24.04
21+
artifact_name: YAPS1
22+
asset_suffix: linux-x86_64
23+
cc: gcc
24+
cxx: g++
25+
26+
- os: ubuntu-24.04
27+
artifact_name: YAPS1
28+
asset_suffix: linux-x86_64-clang
29+
cc: clang
30+
cxx: clang++
31+
32+
- os: windows-latest
33+
artifact_name: YAPS1.exe
34+
asset_suffix: windows-x86_64
35+
36+
- os: macos-latest
37+
artifact_name: YAPS1
38+
asset_suffix: macos-arm64
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Install Linux dependencies
44+
if: runner.os == 'Linux'
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y cmake pkg-config libgl-dev libvulkan-dev zlib1g-dev
48+
49+
- name: Configure (Linux)
50+
if: runner.os == 'Linux'
51+
run: |
52+
CC=${{ matrix.cc }} \
53+
CXX=${{ matrix.cxx }} \
54+
cmake -B build -DCMAKE_BUILD_TYPE=Release
55+
56+
- name: Configure (Windows)
57+
if: runner.os == 'Windows'
58+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
59+
60+
- name: Configure (macOS)
61+
if: runner.os == 'macOS'
62+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
63+
64+
- name: Build
65+
shell: bash
66+
run: |
67+
if [ "${{ runner.os }}" = "Windows" ]; then
68+
cmake --build build --config Release
69+
else
70+
cmake --build build --config Release -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
71+
fi
72+
73+
- name: Locate binary
74+
id: bin
75+
shell: bash
76+
run: |
77+
if [ "${{ runner.os }}" = "Windows" ]; then
78+
BINARY="build/Release/YAPS1.exe"
79+
else
80+
BINARY="build/YAPS1"
81+
fi
82+
83+
echo "path=$BINARY" >> "$GITHUB_OUTPUT"
84+
85+
if [ ! -f "$BINARY" ]; then
86+
echo "Binary not found: $BINARY"
87+
find build -type f
88+
exit 1
89+
fi
90+
91+
- name: Package (Linux)
92+
if: runner.os == 'Linux'
93+
run: |
94+
cp "${{ steps.bin.outputs.path }}" "YAPS1-${{ matrix.asset_suffix }}"
95+
strip -s "YAPS1-${{ matrix.asset_suffix }}"
96+
tar czf "YAPS1-${{ matrix.asset_suffix }}.tar.gz" "YAPS1-${{ matrix.asset_suffix }}"
97+
98+
- name: Package (macOS)
99+
if: runner.os == 'macOS'
100+
run: |
101+
cp "${{ steps.bin.outputs.path }}" "YAPS1-${{ matrix.asset_suffix }}"
102+
strip "YAPS1-${{ matrix.asset_suffix }}"
103+
tar czf "YAPS1-${{ matrix.asset_suffix }}.tar.gz" "YAPS1-${{ matrix.asset_suffix }}"
104+
105+
- name: Package (Windows)
106+
if: runner.os == 'Windows'
107+
shell: pwsh
108+
run: |
109+
Compress-Archive `
110+
-Path "build/Release/YAPS1.exe" `
111+
-DestinationPath "YAPS1-${{ matrix.asset_suffix }}.zip"
112+
113+
- name: Upload artifact
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: YAPS1-${{ matrix.asset_suffix }}
117+
path: |
118+
YAPS1-${{ matrix.asset_suffix }}.tar.gz
119+
YAPS1-${{ matrix.asset_suffix }}.zip
120+
if-no-files-found: ignore
121+
122+
- name: Create GitHub Release
123+
uses: softprops/action-gh-release@v2
124+
with:
125+
files: |
126+
YAPS1-${{ matrix.asset_suffix }}.tar.gz
127+
YAPS1-${{ matrix.asset_suffix }}.zip
128+
generate_release_notes: true

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Build
2+
build/
3+
cmake-build-*/
4+
out/
5+
*.o
6+
*.obj
7+
*.exe
8+
*.out
9+
*.app
10+
11+
# IDE
12+
.vs/
13+
.vscode/
14+
.idea/
15+
*.sln
16+
*.vcxproj*
17+
*.swp
18+
*.swo
19+
*~
20+
21+
# OS
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Project
26+
*.mcd
27+
*.bin
28+
*.cue
29+
*.iso
30+
*.img
31+
config.toml
32+
33+
# Release archives
34+
*.zip
35+
*.tar.gz
36+
*.7z

CMakeLists.txt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
project(YAPS1 VERSION 1.2.0 LANGUAGES CXX)
3+
4+
set(CMAKE_CXX_STANDARD 23)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
8+
# ---- Compiler options ----
9+
if(MSVC)
10+
add_compile_options(/W4 /WX /utf-8 /permissive-)
11+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX)
12+
else()
13+
add_compile_options(-Wall -Wextra -Wpedantic -fsanitize=address,undefined -g)
14+
add_link_options(-fsanitize=address,undefined)
15+
endif()
16+
17+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE)
18+
add_compile_definitions(__cpp_concepts=202002L)
19+
endif()
20+
21+
# ---- Dependencies (bundled) ----
22+
include(FetchContent)
23+
24+
# fmt — for formatted logging
25+
FetchContent_Declare(
26+
fmt
27+
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
28+
GIT_TAG 10.2.1
29+
)
30+
FetchContent_GetProperties(fmt)
31+
if(NOT fmt_POPULATED)
32+
FetchContent_Populate(fmt)
33+
34+
# Patch fmt/core.h and fmt/base.h to disable consteval on Apple Clang 21+
35+
foreach(FMT_HEADER "${fmt_SOURCE_DIR}/include/fmt/core.h" "${fmt_SOURCE_DIR}/include/fmt/base.h")
36+
if(EXISTS "${FMT_HEADER}")
37+
file(READ "${FMT_HEADER}" FMT_CONTENT)
38+
string(REPLACE "#ifndef FMT_CONSTEVAL" "#if defined(__APPLE__)\n# define FMT_CONSTEVAL\n#endif\n#ifndef FMT_CONSTEVAL" FMT_CONTENT_PATCHED "${FMT_CONTENT}")
39+
file(WRITE "${FMT_HEADER}" "${FMT_CONTENT_PATCHED}")
40+
endif()
41+
endforeach()
42+
43+
add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL)
44+
endif()
45+
46+
# SDL3
47+
set(SDL_TESTS OFF CACHE BOOL "" FORCE)
48+
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
49+
set(SDL_STATIC ON CACHE BOOL "" FORCE)
50+
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
51+
set(SDL_X11 OFF CACHE BOOL "" FORCE)
52+
set(SDL_WAYLAND OFF CACHE BOOL "" FORCE)
53+
set(SDL_UNIX_CONSOLE_BUILD ON CACHE BOOL "" FORCE)
54+
55+
FetchContent_Declare(
56+
SDL3
57+
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
58+
GIT_TAG release-3.2.0
59+
CMAKE_ARGS -DSDL_TESTS=OFF -DSDL_TEST_LIBRARY=OFF -DSDL_STATIC=ON -DSDL_SHARED=OFF -DSDL_X11=OFF -DSDL_WAYLAND=OFF -DSDL_UNIX_CONSOLE_BUILD=ON
60+
)
61+
FetchContent_MakeAvailable(SDL3)
62+
63+
# ---- Vulkan (optional) ----
64+
find_package(Vulkan QUIET)
65+
if(Vulkan_FOUND)
66+
add_compile_definitions(YAPS1_HAS_VULKAN)
67+
message(STATUS "Vulkan found — Vulkan renderer will be available")
68+
else()
69+
message(STATUS "Vulkan NOT found — software renderer only")
70+
endif()
71+
72+
# ---- Project source files ----
73+
file(GLOB_RECURSE YAPS1_SOURCES
74+
src/*.cpp
75+
src/*.h
76+
)
77+
78+
add_executable(YAPS1 ${YAPS1_SOURCES})
79+
80+
target_include_directories(YAPS1 PRIVATE
81+
${CMAKE_CURRENT_SOURCE_DIR}/src
82+
${CMAKE_CURRENT_SOURCE_DIR}
83+
)
84+
85+
# Link SDL3 and fmt-header-only
86+
target_link_libraries(YAPS1 PRIVATE SDL3::SDL3 fmt::fmt-header-only)
87+
88+
# Link threading library on non-Windows
89+
if(NOT WIN32)
90+
find_package(Threads REQUIRED)
91+
target_link_libraries(YAPS1 PRIVATE Threads::Threads)
92+
endif()
93+
94+
# Link Vulkan if available
95+
if(Vulkan_FOUND)
96+
target_link_libraries(YAPS1 PRIVATE Vulkan::Vulkan)
97+
endif()
98+
99+
# Zlib (for compressed save states and CHD support)
100+
find_package(ZLIB QUIET)
101+
if(ZLIB_FOUND)
102+
target_link_libraries(YAPS1 PRIVATE ZLIB::ZLIB)
103+
target_compile_definitions(YAPS1 PUBLIC YAPS1_HAS_ZLIB)
104+
message(STATUS "Zlib found — CHD support and compressed save states enabled")
105+
else()
106+
message(STATUS "Zlib NOT found — CHD support will be unavailable")
107+
endif()
108+
109+
# ---- Install ----
110+
install(TARGETS YAPS1 RUNTIME DESTINATION bin)
111+
112+
# ---- Tests ----
113+
enable_testing()
114+
115+
add_executable(test_emulator
116+
tests/test_emulator.cpp
117+
src/cpu/cpu.cpp
118+
src/cpu/cop0.cpp
119+
)
120+
121+
target_include_directories(test_emulator PRIVATE
122+
${CMAKE_CURRENT_SOURCE_DIR}/src
123+
${CMAKE_CURRENT_SOURCE_DIR}
124+
)
125+
126+
target_link_libraries(test_emulator PRIVATE fmt::fmt-header-only)
127+
128+
add_test(NAME test_emulator COMMAND test_emulator)
129+
130+
# ---- Default config / mapping files ----
131+
# These are copied on first run by the emulator if they don't exist.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Aarvsn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)