Compare commits
163 Commits
bb7db57bda
...
editor
| Author | SHA1 | Date | |
|---|---|---|---|
| 888918face | |||
| 0885da8d44 | |||
| 8af961c6d3 | |||
| ef5febdde3 | |||
| 6d7fbd3926 | |||
| 2680d373d8 | |||
| 2b2ddb3cf2 | |||
| 85ff95296b | |||
| 314a2de41a | |||
| 26fafab47a | |||
| e56ff20e2d | |||
| 55d44f229d | |||
| 1c5e50cc4d | |||
| ea898da6c2 | |||
| dbb7e9f53c | |||
| cbb68a399d | |||
| 0e794f28b1 | |||
| 87d2d9123e | |||
| 6823a4ddb5 | |||
| 20a7c70081 | |||
| 9caa33b3bb | |||
| 2d7e61460a | |||
| a4b7fb3f44 | |||
| 70056cf4ca | |||
| 5f4ab71ade | |||
| f3adb3257b | |||
| 438edda7fd | |||
| d5b0441e6f | |||
| 9ba0ceb000 | |||
| 9474a68995 | |||
| 09c35f0aa6 | |||
| a2113442cb | |||
| d91808487f | |||
| 933949cc19 | |||
| 407620387d | |||
| 98947dea26 | |||
| ebff7af9b5 | |||
| b23c4b83ae | |||
| c0cff40628 | |||
| 97513e354c | |||
| c277ae7aff | |||
| e1835e6282 | |||
| 5ac21db997 | |||
| ca0e9fc3b2 | |||
| 66ebcb1608 | |||
| ff92a78dda | |||
| 7356286fe0 | |||
| 54e8e68f86 | |||
| d21cd7f78b | |||
| 1d7516982a | |||
| c77a11442c | |||
| 5bd43a4643 | |||
| 9b87dfa1a9 | |||
| 2e3173ea40 | |||
| 68eac7cf83 | |||
| 6709505630 | |||
| af6e962a5d | |||
| 18e6bdabaa | |||
| 9743942eae | |||
| 23062137a8 | |||
| 46f7fb5ccd | |||
| 9c90c49a6b | |||
| 4517b63557 | |||
| 58c239f4b4 | |||
| cc8845ba3e | |||
| 6b69ce2901 | |||
| 55300ed21c | |||
| 7346dd4339 | |||
| 2caf3b92ce | |||
| af2cd72a1f | |||
| 3d455ec1f8 | |||
| 15982d7735 | |||
| 5ae3542bd9 | |||
| b1b02ae24b | |||
| f0964e2c92 | |||
| e9661d2998 | |||
| ea6468f2a9 | |||
| a2b38d3b83 | |||
| d67ef02941 | |||
| 549ebe25d8 | |||
| 9a98348582 | |||
| c5f5b025a6 | |||
| 23eaffa3a7 | |||
| c161809248 | |||
| 4bf26dc818 | |||
| 5dd22fad6c | |||
| 2c3fdf7803 | |||
| e984b9f5d7 | |||
| a3c2e37b17 | |||
| edf1b5a0a3 | |||
| 8efdf59ebd | |||
| 5c4537b2fa | |||
| 71e6079054 | |||
| dd048d9b0d | |||
| 93074d653e | |||
| 9139c4350a | |||
| 38ce768168 | |||
| 82b3dc576c | |||
| 2167889f48 | |||
| e9b02c2acf | |||
| 9ee446431b | |||
| df106e3988 | |||
| d0a057e0ee | |||
| 8b49902bf6 | |||
| 71c1e56564 | |||
| 1b12e67de2 | |||
| 291bb4bb81 | |||
| 342ddb19f8 | |||
| 9c9d2d548e | |||
| d7a0bb4509 | |||
| 2b1a3323a8 | |||
| 99d030003c | |||
| 92a753560b | |||
| af9904c892 | |||
| e5e8c49f6c | |||
| b37e5f45ca | |||
| e1f08b07aa | |||
| 073ee8dca9 | |||
| a26e51cf46 | |||
| dfed732825 | |||
| 87aa70c6d2 | |||
| aa2979ffe7 | |||
| 236e16aa6d | |||
| 184bb970e6 | |||
| bd54469891 | |||
| 2f5dccc3ef | |||
| 592edb90a0 | |||
| 3db7e6b1b9 | |||
| 13c4df0d85 | |||
| ef25fb09da | |||
| 03cf4a9efe | |||
| 53dd36efdd | |||
| ad9e841a42 | |||
| 14f3f464c7 | |||
| cbe51cc8d0 | |||
| efaa3f6eea | |||
| 52cce9a3b0 | |||
| b7b390311e | |||
| c1eeddd14b | |||
| 1a7a55dfc3 | |||
| fe5927ea6a | |||
| 119c794ad7 | |||
| e2076b2c1c | |||
| 5208c5148e | |||
| d80660b097 | |||
| b916d0278b | |||
| d51e13e620 | |||
| 40ad4326ef | |||
| b8afc1684a | |||
| 8348b31ac8 | |||
| 411f2dbcce | |||
| ee89c08160 | |||
| 357607a89f | |||
| 8d6dc2df44 | |||
| 5207582ab3 | |||
| 71768e6154 | |||
| ecbe235523 | |||
| afef079d1e | |||
| df17696c69 | |||
| 065bf0908f | |||
| 5b6755e9cf | |||
| b08482acf1 | |||
| 80c9c1d389 |
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
docker build -t myapp:latest -f ./.ci/dolphin/Dockerfile .
|
||||
docker run -v ./:/gamecube myapp:latest /bin/bash -c ' \
|
||||
export PATH="$DEVKITPPC/bin:$PATH" && \
|
||||
echo "Inside Docker container:" && \
|
||||
ls -l && \
|
||||
echo "Current directory:" && \
|
||||
realpath . && \
|
||||
echo "Listing /:" && \
|
||||
ls / && \
|
||||
echo "Changing to /gamecube" && \
|
||||
cd /gamecube && \
|
||||
echo "Contents of /gamecube:" && \
|
||||
ls -l && \
|
||||
rm -rf build-gamecube && \
|
||||
mkdir -p build-gamecube && \
|
||||
cmake -S. -Bbuild-gamecube -DDUSK_TARGET_SYSTEM=gamecube -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/GameCube.cmake" && \
|
||||
cd build-gamecube && \
|
||||
make VERBOSE=1
|
||||
'
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
docker build -t myapp:latest -f .ci/dolphin/Dockerfile .
|
||||
docker run -v ./:/workdir myapp:latest /bin/bash -c ' \
|
||||
export PATH="$DEVKITPPC/bin:$PATH" && \
|
||||
cd /workdir && \
|
||||
rm -rf build-wii && \
|
||||
mkdir -p build-wii && \
|
||||
cmake -S. -Bbuild-wii -DDUSK_TARGET_SYSTEM=wii -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake" && \
|
||||
cd build-wii && \
|
||||
make VERBOSE=1 && \
|
||||
mv ./Dusk.dol ./boot.dol
|
||||
'
|
||||
# docker run -it -v ./:/workdir myapp:latest /bin/bash
|
||||
@@ -1,147 +0,0 @@
|
||||
name: Build Dusk
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-gamecube:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)
|
||||
# Add Docker's official GPG key:
|
||||
sudo apt update
|
||||
sudo apt install ca-certificates curl
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
|
||||
# Add the repository to Apt sources:
|
||||
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
|
||||
Types: deb
|
||||
URIs: https://download.docker.com/linux/ubuntu
|
||||
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
|
||||
Components: stable
|
||||
Signed-By: /etc/apt/keyrings/docker.asc
|
||||
EOF
|
||||
|
||||
sudo apt update --yes
|
||||
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin --yes
|
||||
- name: Build GameCube
|
||||
run: |
|
||||
echo "ls -l ."
|
||||
ls -l
|
||||
echo "Current directory:"
|
||||
realpath .
|
||||
echo "ls /"
|
||||
ls /
|
||||
echo "Run GameCube build script"
|
||||
.ci/dolphin/build-gamecube.sh
|
||||
- name: Copy gamecube
|
||||
run: |
|
||||
mkdir -p build/gitea/Gamecube/Dusk
|
||||
mv build/Dusk.dol build/gitea/Gamecube/Dusk/Dusk.dol
|
||||
mv build/dusk.dsk build/gitea/Gamecube/Dusk/dusk.dsk
|
||||
- name: Upload GameCube Binary
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dusk-gamecube
|
||||
path: build/gitea/Gamecube
|
||||
if-no-files-found: error
|
||||
|
||||
# build-wii:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Checkout repository
|
||||
# uses: actions/checkout@v5
|
||||
# - name: Install dependencies
|
||||
# run: |
|
||||
# apt-get update
|
||||
# apt-get install -y docker.io
|
||||
# - name: Build Wii
|
||||
# run: |
|
||||
# ./.ci/dolphin/build-wii.sh
|
||||
# - name: Copy wii
|
||||
# run: |
|
||||
# mkdir -p build/gitea/Wii/apps/Dusk
|
||||
# mv build/Dusk.dol build/gitea/Wii/apps/Dusk/boot.dol
|
||||
# mv build/dusk.dsk build/gitea/Wii/apps/Dusk/dusk.dsk
|
||||
# - name: Upload Wii Binary
|
||||
# uses: actions/upload-artifact@v3
|
||||
# with:
|
||||
# name: dusk-wii
|
||||
# path: build/gitea/Wii
|
||||
# if-no-files-found: error
|
||||
|
||||
run-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 python3-opengl liblua5.3-dev
|
||||
- name: Configure CMake for tests
|
||||
run: cmake -S . -B build -DDUSK_BUILD_TESTS=ON -DDUSK_TARGET_SYSTEM=linux
|
||||
- name: Build tests
|
||||
run: cmake --build build -- -j$(nproc)
|
||||
- name: Run tests
|
||||
run: ctest --output-on-failure --test-dir build
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 python3-opengl liblua5.3-dev
|
||||
- name: Configure CMake
|
||||
run: cmake -S . -B build -DDUSK_TARGET_SYSTEM=linux
|
||||
- name: Build
|
||||
run: cmake --build build -- -j$(nproc)
|
||||
- name: List build output
|
||||
run: ls -lh build
|
||||
- name: Upload Linux binary
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dusk-linux
|
||||
path: build/Dusk
|
||||
if-no-files-found: error
|
||||
|
||||
build-psp:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 python3-opengl liblua5.3-dev
|
||||
- name: Configure CMake
|
||||
run: cmake -S . -B build -DDUSK_TARGET_SYSTEM=psp -DENABLE_TESTS=OFF
|
||||
- name: Build
|
||||
run: cmake --build build -- -j$(nproc)
|
||||
- name: Move EBOOT.PBP to Dusk subfolder
|
||||
run: |
|
||||
mkdir -p build/gitea/Dusk
|
||||
mv build/EBOOT.PBP build/gitea/Dusk/EBOOT.PBP
|
||||
- name: List build output
|
||||
run: ls -lh build/gitea/Dusk
|
||||
- name: Upload PSP binary
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dusk-psp
|
||||
path: build/gitea/
|
||||
if-no-files-found: error
|
||||
117
.github/workflows/build.yml
vendored
Normal file
117
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
name: Build Dusk
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
run-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-docker-action@v5
|
||||
- name: Run tests in Docker
|
||||
run: ./scripts/test-linux-docker.sh
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-docker-action@v5
|
||||
- name: Build Linux
|
||||
run: ./scripts/build-linux-docker.sh
|
||||
- name: Upload Linux binary
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dusk-linux
|
||||
path: build-linux/Dusk
|
||||
if-no-files-found: error
|
||||
|
||||
build-psp:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-docker-action@v5
|
||||
- name: Build psp
|
||||
run: ./scripts/build-psp-docker.sh
|
||||
- name: Move EBOOT.PBP to Dusk subfolder
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk/PSP/GAME/Dusk
|
||||
cp build-psp/EBOOT.PBP ./git-artifcats/Dusk/PSP/GAME/Dusk/EBOOT.PBP
|
||||
- name: Upload psp binary
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dusk-psp
|
||||
path: ./git-artifcats/Dusk
|
||||
if-no-files-found: error
|
||||
|
||||
build-knulli:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-docker-action@v5
|
||||
- name: Build knulli
|
||||
run: ./scripts/build-knulli-docker.sh
|
||||
- name: Move output to Dusk subfolder
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk
|
||||
cp -r build-knulli/dusk ./git-artifcats/Dusk
|
||||
- name: Upload knulli binary
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dusk-knulli
|
||||
path: ./git-artifcats/Dusk
|
||||
if-no-files-found: error
|
||||
|
||||
build-gamecube:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-docker-action@v5
|
||||
- name: Build GameCube
|
||||
run: ./scripts/build-gamecube-docker.sh
|
||||
- name: Copy output files.
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk
|
||||
cp build-gamecube/Dusk.dol ./git-artifcats/Dusk/Dusk.dol
|
||||
cp build-gamecube/dusk.dsk ./git-artifcats/Dusk/dusk.dsk
|
||||
- name: Upload GameCube binary
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dusk-gamecube
|
||||
path: ./git-artifcats/Dusk
|
||||
if-no-files-found: error
|
||||
|
||||
build-wii:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up Docker
|
||||
uses: docker/setup-docker-action@v5
|
||||
- name: Build Wii
|
||||
run: ./scripts/build-wii-docker.sh
|
||||
- name: Copy output files.
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
||||
cp build-wii/Dusk.dol ./git-artifcats/Dusk/apps/Dusk/boot.dol
|
||||
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
||||
cp docker/dolphin/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
||||
- name: Upload Wii binary
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dusk-wii
|
||||
path: ./git-artifcats/Dusk
|
||||
if-no-files-found: error
|
||||
195
CMakeLists.txt
195
CMakeLists.txt
@@ -10,7 +10,7 @@ set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
option(ENABLE_TESTS "Enable tests" OFF)
|
||||
option(DUSK_BUILD_TESTS "Enable tests" OFF)
|
||||
|
||||
# Prep cache
|
||||
set(DUSK_CACHE_TARGET "dusk-target")
|
||||
@@ -30,184 +30,85 @@ set(DUSK_BUILD_BINARY ${DUSK_BUILD_DIR}/Dusk CACHE INTERNAL ${DUSK_CACHE_TARGET}
|
||||
set(DUSK_ASSETS "" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_LIBRARY_TARGET_NAME "DuskCore" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_BINARY_TARGET_NAME "Dusk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
|
||||
# Create directories
|
||||
file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR})
|
||||
|
||||
# Find packages
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
# Set target system
|
||||
# message(FATAL_ERROR "DISABLED FOR NOW2 ${DUSK_TARGET_SYSTEM}")
|
||||
set(DUSK_ASSETS_ZIP "${DUSK_BUILD_DIR}/dusk.dsk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
|
||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
||||
set(DUSK_TARGET_SYSTEM "linux")
|
||||
# set(DUSK_TARGET_SYSTEM "psp")
|
||||
endif()
|
||||
|
||||
# Toolchains
|
||||
if(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
||||
find_package(pspsdk REQUIRED)
|
||||
endif()
|
||||
# Create directories
|
||||
file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR})
|
||||
file(MAKE_DIRECTORY ${DUSK_TEMP_DIR})
|
||||
file(MAKE_DIRECTORY ${DUSK_BUILT_ASSETS_DIR})
|
||||
|
||||
if(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii")
|
||||
# Override to make library and binary be the same.
|
||||
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_LIBRARY_TARGET_NAME}.elf" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
endif()
|
||||
# Required build packages
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
# Init Project.
|
||||
project(${DUSK_LIBRARY_TARGET_NAME}
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C CXX
|
||||
LANGUAGES C
|
||||
)
|
||||
|
||||
# Either, create library and binary separately (used for tests), or make them
|
||||
# one in the same so all code is in the binary.
|
||||
if(ENABLE_TESTS)
|
||||
# one in the same so all code is in the binary only.
|
||||
# Binary Executable
|
||||
add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/dusk/null.c)
|
||||
|
||||
if(DUSK_BUILD_TESTS)
|
||||
# MainLibrary
|
||||
add_library(${DUSK_LIBRARY_TARGET_NAME} STATIC)
|
||||
|
||||
# Binary Executable
|
||||
add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/null.c)
|
||||
|
||||
# Link library to binary
|
||||
target_link_libraries(${DUSK_BINARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
${DUSK_LIBRARY_TARGET_NAME}
|
||||
)
|
||||
else()
|
||||
set(DUSK_BINARY_TARGET_NAME "${DUSK_LIBRARY_TARGET_NAME}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/null.c)
|
||||
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
endif()
|
||||
|
||||
# Definitions
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
DUSK_TARGET_SYSTEM="${DUSK_TARGET_SYSTEM}"
|
||||
)
|
||||
|
||||
# Toolchains
|
||||
include(cmake/targets/${DUSK_TARGET_SYSTEM}.cmake)
|
||||
|
||||
# Add tools
|
||||
add_subdirectory(tools)
|
||||
|
||||
# Assets
|
||||
add_subdirectory(assets)
|
||||
|
||||
# Add libraries
|
||||
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
SDL2
|
||||
pthread
|
||||
OpenGL::GL
|
||||
GL
|
||||
m
|
||||
)
|
||||
|
||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
${SDL2_LIBRARIES}
|
||||
SDL2
|
||||
pthread
|
||||
OpenGL::GL
|
||||
zip
|
||||
bz2
|
||||
z
|
||||
mbedtls
|
||||
mbedcrypto
|
||||
lzma
|
||||
m
|
||||
)
|
||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
${SDL2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
||||
configure_file(opengl.pc.in opengl.pc @ONLY)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(zip IMPORTED_TARGET libzip)
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DOLPHIN
|
||||
)
|
||||
|
||||
# Custom flags for cglm
|
||||
set(CGLM_SHARED OFF CACHE BOOL "Build cglm shared" FORCE)
|
||||
set(CGLM_STATIC ON CACHE BOOL "Build cglm static" FORCE)
|
||||
find_package(cglm REQUIRED)
|
||||
|
||||
# Compile lua
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
liblua
|
||||
URL https://www.lua.org/ftp/lua-5.5.0.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(liblua)
|
||||
set(LUA_SRC_DIR "${liblua_SOURCE_DIR}/src")
|
||||
set(LUA_C_FILES
|
||||
lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c ldebug.c
|
||||
ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c
|
||||
loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c
|
||||
lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c
|
||||
)
|
||||
list(TRANSFORM LUA_C_FILES PREPEND "${LUA_SRC_DIR}/")
|
||||
add_library(liblua STATIC ${LUA_C_FILES})
|
||||
target_include_directories(liblua PUBLIC "${LUA_SRC_DIR}")
|
||||
target_compile_definitions(liblua PRIVATE LUA_USE_C89)
|
||||
add_library(lua::lua ALIAS liblua)
|
||||
set(Lua_FOUND TRUE CACHE BOOL "Lua found" FORCE)
|
||||
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
cglm
|
||||
liblua
|
||||
m
|
||||
fat
|
||||
PkgConfig::zip
|
||||
)
|
||||
endif()
|
||||
|
||||
# Force turn tests off for now
|
||||
set(ENABLE_TESTS OFF CACHE BOOL "Enable tests" FORCE)
|
||||
|
||||
# Add code
|
||||
add_subdirectory(${DUSK_SOURCES_DIR})
|
||||
|
||||
# Handle tests
|
||||
if(ENABLE_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
# Build assets
|
||||
dusk_run_python(
|
||||
DUSK_ASSETS_BUILT
|
||||
tools.asset.bundle
|
||||
--assets ${DUSK_ASSETS_DIR}
|
||||
--output-assets ${DUSK_BUILT_ASSETS_DIR}
|
||||
--output-file ${DUSK_BUILD_DIR}/dusk.dsk
|
||||
--headers-dir ${DUSK_GENERATED_HEADERS_DIR}
|
||||
--input ${DUSK_ASSETS}
|
||||
# Include generated headers from tools.
|
||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
${DUSK_GENERATED_HEADERS_DIR}
|
||||
)
|
||||
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT)
|
||||
|
||||
# Add main code
|
||||
add_subdirectory(${DUSK_SOURCES_DIR})
|
||||
|
||||
# Include generated headers
|
||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
${DUSK_GENERATED_HEADERS_DIR}
|
||||
)
|
||||
|
||||
# Postbuild
|
||||
if(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
||||
create_pbp_file(
|
||||
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
||||
ICON_PATH NULL
|
||||
BACKGROUND_PATH NULL
|
||||
PREVIEW_PATH NULL
|
||||
TITLE "${DUSK_BINARY_TARGET_NAME}"
|
||||
PSAR_PATH ${DUSK_BUILD_DIR}/dusk.dsk
|
||||
VERSION 01.00
|
||||
)
|
||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii")
|
||||
set(DUSK_BINARY_TARGET_NAME_DOL "${DUSK_BUILD_DIR}/Dusk.dol")
|
||||
add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD
|
||||
COMMAND elf2dol
|
||||
"$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>"
|
||||
"${DUSK_BINARY_TARGET_NAME_DOL}"
|
||||
COMMENT "Generating ${DUSK_BINARY_TARGET_NAME_DOL} from ${DUSK_BINARY_TARGET_NAME}"
|
||||
)
|
||||
# Handle tests
|
||||
if(DUSK_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
# Build assets
|
||||
file(GLOB_RECURSE DUSK_ASSET_FILES CONFIGURE_DEPENDS "${DUSK_ASSETS_DIR}/*")
|
||||
add_custom_command(
|
||||
OUTPUT "${DUSK_ASSETS_ZIP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${DUSK_ASSETS_DIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -f "${DUSK_ASSETS_ZIP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${DUSK_ASSETS_ZIP}" --format=zip -- .
|
||||
WORKING_DIRECTORY "${DUSK_ASSETS_DIR}"
|
||||
DEPENDS ${DUSK_ASSET_FILES}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(DUSK_ASSETS_BUILT DEPENDS "${DUSK_ASSETS_ZIP}")
|
||||
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT)
|
||||
|
||||
@@ -35,10 +35,24 @@ def processPalettizedImage(asset):
|
||||
imagePalette = extractPaletteFromImage(image)
|
||||
|
||||
# Find palette that contains every color
|
||||
for palette in palettes:
|
||||
if all(color in palette['pixels'] for color in imagePalette):
|
||||
palette = None
|
||||
for p in palettes:
|
||||
hasAllColors = True
|
||||
for color in imagePalette:
|
||||
for palColor in p['pixels']:
|
||||
if color[0] == palColor[0] and color[1] == palColor[1] and color[2] == palColor[2] and color[3] == palColor[3]:
|
||||
break
|
||||
elif color[3] == 0 and palColor[3] == 0:
|
||||
break
|
||||
else:
|
||||
print('Pallete {} does not contain color #{}'.format(p['paletteName'], '{:02x}{:02x}{:02x}{:02x}'.format(color[0], color[1], color[2], color[3])))
|
||||
hasAllColors = False
|
||||
break
|
||||
if hasAllColors:
|
||||
palette = p
|
||||
break
|
||||
else:
|
||||
|
||||
if palette is None:
|
||||
palette = palettes[0] # Just to avoid reference error
|
||||
print(f"No matching palette found for {assetPath}!")
|
||||
# Find which pixel is missing
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
from PIL import Image
|
||||
import datetime
|
||||
@@ -78,6 +79,7 @@ def processPalette(asset):
|
||||
|
||||
def processPaletteList():
|
||||
data = f"// Auto-generated palette list\n"
|
||||
print(f"Generating palette list with {len(palettes)} palettes.")
|
||||
for palette in palettes:
|
||||
data += f"#include \"{palette['headerFile']}\"\n"
|
||||
data += f"\n"
|
||||
@@ -126,6 +126,7 @@ def processTileset(asset):
|
||||
data += f"#pragma once\n"
|
||||
data += f"#include \"display/tileset/tileset.h\"\n\n"
|
||||
data += f"static const tileset_t TILESET_{tilesetNameUpper} = {{\n"
|
||||
data += f" .name = {json.dumps(tilesetName)},\n"
|
||||
data += f" .tileWidth = {tilesetData['tileWidth']},\n"
|
||||
data += f" .tileHeight = {tilesetData['tileHeight']},\n"
|
||||
data += f" .tileCount = {tilesetData['columns'] * tilesetData['rows']},\n"
|
||||
47
archive/assetpalette.c
Normal file
47
archive/assetpalette.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "assetpalette.h"
|
||||
#include "asset/assettype.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
errorret_t assetPaletteLoad(assetentire_t entire) {
|
||||
assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
||||
assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
||||
|
||||
assetpalette_t *assetData = (assetpalette_t *)entire.data;
|
||||
palette_t *palette = (palette_t *)entire.output;
|
||||
|
||||
// Read header and version (first 4 bytes)
|
||||
if(
|
||||
assetData->header[0] != 'D' ||
|
||||
assetData->header[1] != 'P' ||
|
||||
assetData->header[2] != 'F'
|
||||
) {
|
||||
errorThrow("Invalid palette header");
|
||||
}
|
||||
|
||||
// Version (can only be 1 atm)
|
||||
if(assetData->version != 0x01) {
|
||||
errorThrow("Unsupported palette version");
|
||||
}
|
||||
|
||||
// Check color count.
|
||||
if(
|
||||
assetData->colorCount == 0 ||
|
||||
assetData->colorCount > PALETTE_COLOR_COUNT_MAX
|
||||
) {
|
||||
errorThrow("Invalid palette color count");
|
||||
}
|
||||
|
||||
paletteInit(
|
||||
palette,
|
||||
assetData->colorCount,
|
||||
assetData->colors
|
||||
);
|
||||
errorOk();
|
||||
}
|
||||
30
archive/assetpalette.h
Normal file
30
archive/assetpalette.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
#include "display/texture/palette.h"
|
||||
|
||||
typedef struct assetentire_s assetentire_t;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct {
|
||||
char_t header[3];
|
||||
uint8_t version;
|
||||
|
||||
uint8_t colorCount;
|
||||
color_t colors[PALETTE_COLOR_COUNT_MAX];
|
||||
} assetpalette_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* Loads a palette from the given data pointer into the output palette.
|
||||
*
|
||||
* @param entire Data received from the asset loader system.
|
||||
* @return An error code.
|
||||
*/
|
||||
errorret_t assetPaletteLoad(assetentire_t entire);
|
||||
@@ -156,7 +156,7 @@ class Map:
|
||||
newTopLeftChunkY = y // CHUNK_HEIGHT - (MAP_HEIGHT // 2)
|
||||
newTopLeftChunkZ = z // CHUNK_DEPTH - (MAP_DEPTH // 2)
|
||||
|
||||
if (newTopLeftChunkX != self.topLeftX or
|
||||
if(newTopLeftChunkX != self.topLeftX or
|
||||
newTopLeftChunkY != self.topLeftY or
|
||||
newTopLeftChunkZ != self.topLeftZ):
|
||||
|
||||
@@ -166,7 +166,7 @@ class Map:
|
||||
chunkWorldX = chunk.x
|
||||
chunkWorldY = chunk.y
|
||||
chunkWorldZ = chunk.z
|
||||
if (chunkWorldX < newTopLeftChunkX or
|
||||
if(chunkWorldX < newTopLeftChunkX or
|
||||
chunkWorldX >= newTopLeftChunkX + MAP_WIDTH or
|
||||
chunkWorldY < newTopLeftChunkY or
|
||||
chunkWorldY >= newTopLeftChunkY + MAP_HEIGHT or
|
||||
@@ -22,13 +22,13 @@ int moduleMapLoad(lua_State *L) {
|
||||
// Potentially provide up to 3 params
|
||||
chunkpos_t initial = { .x = 0, .y = 0, .z = 0 };
|
||||
if(lua_isnumber(L, 2)) {
|
||||
initial.x = (chunkunit_t)luaL_checkinteger(L, 2);
|
||||
initial.x = (chunkunit_t)lua_tonumber(L, 2);
|
||||
}
|
||||
if(lua_isnumber(L, 3)) {
|
||||
initial.y = (chunkunit_t)luaL_checkinteger(L, 3);
|
||||
initial.y = (chunkunit_t)lua_tonumber(L, 3);
|
||||
}
|
||||
if(lua_isnumber(L, 4)) {
|
||||
initial.z = (chunkunit_t)luaL_checkinteger(L, 4);
|
||||
initial.z = (chunkunit_t)lua_tonumber(L, 4);
|
||||
}
|
||||
|
||||
// Load the map.
|
||||
|
||||
12
archive/platform/CMakeLists.txt
Normal file
12
archive/platform/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
sdl2.c
|
||||
psp.c
|
||||
dolphin.c
|
||||
)
|
||||
92
archive/platform/dolphin.c
Normal file
92
archive/platform/dolphin.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "dolphin.h"
|
||||
|
||||
void displayInitDolphin(void) {
|
||||
VIDEO_Init();
|
||||
DISPLAY.screenMode = VIDEO_GetPreferredMode(NULL);
|
||||
DISPLAY.frameBuffer[0] = MEM_K0_TO_K1(
|
||||
SYS_AllocateFramebuffer(DISPLAY.screenMode)
|
||||
);
|
||||
DISPLAY.frameBuffer[1] = MEM_K0_TO_K1(
|
||||
SYS_AllocateFramebuffer(DISPLAY.screenMode)
|
||||
);
|
||||
VIDEO_Configure(DISPLAY.screenMode);
|
||||
|
||||
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
|
||||
// VIDEO_SetPostRetraceCallback(copy_buffers);
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
|
||||
DISPLAY.fifoBuffer = memalign(32, DISPLAY_FIFO_SIZE);
|
||||
memoryZero(DISPLAY.fifoBuffer, DISPLAY_FIFO_SIZE);
|
||||
|
||||
GX_Init(DISPLAY.fifoBuffer, DISPLAY_FIFO_SIZE);
|
||||
|
||||
// This seems to be mostly related to interlacing vs progressive
|
||||
GX_SetViewport(
|
||||
0, 0,
|
||||
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight,
|
||||
0, 1
|
||||
);
|
||||
float_t yscale = GX_GetYScaleFactor(
|
||||
DISPLAY.screenMode->efbHeight, DISPLAY.screenMode->xfbHeight
|
||||
);
|
||||
uint32_t xfbHeight = GX_SetDispCopyYScale(yscale);
|
||||
GX_SetScissor(
|
||||
0, 0,
|
||||
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight
|
||||
);
|
||||
GX_SetDispCopySrc(
|
||||
0, 0,
|
||||
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight
|
||||
);
|
||||
GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth, xfbHeight);
|
||||
GX_SetCopyFilter(
|
||||
DISPLAY.screenMode->aa,
|
||||
DISPLAY.screenMode->sample_pattern,
|
||||
GX_TRUE,
|
||||
DISPLAY.screenMode->vfilter
|
||||
);
|
||||
GX_SetFieldMode(
|
||||
DISPLAY.screenMode->field_rendering,
|
||||
(
|
||||
(DISPLAY.screenMode->viHeight == 2 * DISPLAY.screenMode->xfbHeight) ?
|
||||
GX_ENABLE :
|
||||
GX_DISABLE
|
||||
)
|
||||
);
|
||||
|
||||
// Setup cull modes
|
||||
GX_SetCullMode(GX_CULL_NONE);
|
||||
GX_SetZMode(GX_FALSE, GX_ALWAYS, GX_FALSE);
|
||||
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
|
||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||
|
||||
GX_ClearVtxDesc();
|
||||
GX_SetVtxDesc(GX_VA_POS, GX_INDEX16);
|
||||
GX_SetVtxDesc(GX_VA_CLR0, GX_INDEX16);
|
||||
GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16);
|
||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_U8, 0);
|
||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
||||
}
|
||||
|
||||
void displayDolphinSwap(void) {
|
||||
GX_DrawDone();
|
||||
|
||||
DISPLAY.whichFrameBuffer ^= 1;
|
||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate(GX_TRUE);
|
||||
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
|
||||
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
27
archive/platform/dolphin.h
Normal file
27
archive/platform/dolphin.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
#include "display/displaydefs.h"
|
||||
|
||||
typedef struct {
|
||||
void *frameBuffer[2];// Double-Bufferred
|
||||
int whichFrameBuffer;
|
||||
GXRModeObj *screenMode;
|
||||
void *fifoBuffer;
|
||||
} displaydolphin_t;
|
||||
|
||||
/**
|
||||
* Initializes the display for Dolphin.
|
||||
*/
|
||||
void displayDolphinInit(void);
|
||||
|
||||
/**
|
||||
* Swaps the back buffer to the front for Dolphin.
|
||||
*/
|
||||
void displayDolphinSwap(void);
|
||||
12
archive/platform/psp.c
Normal file
12
archive/platform/psp.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "psp.h"
|
||||
|
||||
void displayInitPSP(void) {
|
||||
DISPLAY.usingShaderedPalettes = false;
|
||||
}
|
||||
13
archive/platform/psp.h
Normal file
13
archive/platform/psp.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Initializes the display for PSP.
|
||||
*/
|
||||
void displayInitPSP(void);
|
||||
32
archive/platform/sdl2.c
Normal file
32
archive/platform/sdl2.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "sdl2.h"
|
||||
|
||||
void displaySDL2Update(void) {
|
||||
}
|
||||
|
||||
void displaySDL2Swap(void) {
|
||||
SDL_GL_SwapWindow(DISPLAY.window);
|
||||
|
||||
GLenum err;
|
||||
while((err = glGetError()) != GL_NO_ERROR) {
|
||||
debugPrint("GL Error: %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
void displaySDL2Dispose(void) {
|
||||
if(DISPLAY.glContext) {
|
||||
SDL_GL_DeleteContext(DISPLAY.glContext);
|
||||
DISPLAY.glContext = NULL;
|
||||
}
|
||||
if(DISPLAY.window) {
|
||||
SDL_DestroyWindow(DISPLAY.window);
|
||||
DISPLAY.window = NULL;
|
||||
}
|
||||
SDL_Quit();
|
||||
}
|
||||
35
archive/platform/sdl2.h
Normal file
35
archive/platform/sdl2.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
typedef struct {
|
||||
SDL_Window *window;
|
||||
SDL_GLContext glContext;
|
||||
bool_t usingShaderedPalettes;
|
||||
} displaysdl2_t;
|
||||
|
||||
/**
|
||||
* Initializes the display for SDL2.
|
||||
*/
|
||||
void displaySDL2Init(void);
|
||||
|
||||
/**
|
||||
* Updates the display for SDL2.
|
||||
*/
|
||||
void displaySDL2Update(void);
|
||||
|
||||
/**
|
||||
* Swaps the display buffers for SDL2.
|
||||
*/
|
||||
void displaySDL2Swap(void);
|
||||
|
||||
/**
|
||||
* Disposes of the display for SDL2.
|
||||
*/
|
||||
void displaySDL2Dispose(void);
|
||||
@@ -12,10 +12,9 @@
|
||||
|
||||
int scriptFuncEntityAdd(lua_State *L) {
|
||||
assertNotNull(L, "Lua state cannot be NULL");
|
||||
assertTrue(lua_isnumber(L, 1), "Expected integer entity type");
|
||||
|
||||
assertTrue(lua_isinteger(L, 1), "Expected integer entity type");
|
||||
|
||||
lua_Integer entityType = luaL_checkinteger(L, 1);
|
||||
entitytype_t entityType = (entitytype_t)luaL_checknumber(L, 1);
|
||||
assertTrue(
|
||||
entityType >= ENTITY_TYPE_NULL && entityType < ENTITY_TYPE_COUNT,
|
||||
"Invalid entity type passed to scriptFuncEntityAdd"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Game assets directory")
|
||||
|
||||
# Palette asset needs to be added before any images.
|
||||
add_subdirectory(palette)
|
||||
|
||||
# Languages need to be added before anything that uses text.
|
||||
add_subdirectory(locale)
|
||||
|
||||
# Rest, order doesn't matter
|
||||
add_asset(SCRIPT init.lua)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(entity)
|
||||
add_subdirectory(map)
|
||||
add_subdirectory(ui)
|
||||
add_subdirectory(scene)
|
||||
@@ -1,6 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(TILESET entities.tsx)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 336 B |
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.2" name="entities" tilewidth="16" tileheight="16" tilecount="64" columns="8">
|
||||
<image source="entities.png" width="128" height="128"/>
|
||||
</tileset>
|
||||
@@ -1,10 +1,10 @@
|
||||
module('platform')
|
||||
module('input')
|
||||
module('platform')
|
||||
module('scene')
|
||||
module('locale')
|
||||
|
||||
-- Default Input bindings.
|
||||
if PLATFORM == "psp" then
|
||||
if PSP then
|
||||
inputBind("up", INPUT_ACTION_UP)
|
||||
inputBind("down", INPUT_ACTION_DOWN)
|
||||
inputBind("left", INPUT_ACTION_LEFT)
|
||||
@@ -17,21 +17,20 @@ if PLATFORM == "psp" then
|
||||
inputBind("lstick_left", INPUT_ACTION_LEFT)
|
||||
inputBind("lstick_right", INPUT_ACTION_RIGHT)
|
||||
|
||||
elseif PLATFORM == "gamecube" then
|
||||
-- inputBind("start", INPUT_ACTION_RAGEQUIT)
|
||||
-- inputBind("dpad_up", INPUT_ACTION_UP)
|
||||
-- inputBind("dpad_down", INPUT_ACTION_DOWN)
|
||||
-- inputBind("dpad_left", INPUT_ACTION_LEFT)
|
||||
-- inputBind("dpad_right", INPUT_ACTION_RIGHT)
|
||||
-- inputBind("button_b", INPUT_ACTION_CANCEL)
|
||||
-- inputBind("button_a", INPUT_ACTION_ACCEPT)
|
||||
-- inputBind("button_start", INPUT_ACTION_RAGEQUIT)
|
||||
-- inputBind("lstick_up", INPUT_ACTION_UP)
|
||||
-- inputBind("lstick_down", INPUT_ACTION_DOWN)
|
||||
-- inputBind("lstick_left", INPUT_ACTION_LEFT)
|
||||
-- inputBind("lstick_right", INPUT_ACTION_RIGHT)
|
||||
elseif DOLPHIN then
|
||||
inputBind("up", INPUT_ACTION_UP)
|
||||
inputBind("down", INPUT_ACTION_DOWN)
|
||||
inputBind("left", INPUT_ACTION_LEFT)
|
||||
inputBind("right", INPUT_ACTION_RIGHT)
|
||||
inputBind("b", INPUT_ACTION_CANCEL)
|
||||
inputBind("a", INPUT_ACTION_ACCEPT)
|
||||
inputBind("z", INPUT_ACTION_RAGEQUIT)
|
||||
inputBind("lstick_up", INPUT_ACTION_UP)
|
||||
inputBind("lstick_down", INPUT_ACTION_DOWN)
|
||||
inputBind("lstick_left", INPUT_ACTION_LEFT)
|
||||
inputBind("lstick_right", INPUT_ACTION_RIGHT)
|
||||
|
||||
else
|
||||
elseif LINUX then
|
||||
if INPUT_KEYBOARD then
|
||||
inputBind("w", INPUT_ACTION_UP)
|
||||
inputBind("s", INPUT_ACTION_DOWN)
|
||||
@@ -49,8 +48,31 @@ else
|
||||
inputBind("q", INPUT_ACTION_CANCEL)
|
||||
|
||||
inputBind("escape", INPUT_ACTION_RAGEQUIT)
|
||||
end
|
||||
end
|
||||
|
||||
if INPUT_GAMEPAD then
|
||||
inputBind("gamepad_up", INPUT_ACTION_UP)
|
||||
inputBind("gamepad_down", INPUT_ACTION_DOWN)
|
||||
inputBind("gamepad_left", INPUT_ACTION_LEFT)
|
||||
inputBind("gamepad_right", INPUT_ACTION_RIGHT)
|
||||
|
||||
inputBind("gamepad_a", INPUT_ACTION_ACCEPT)
|
||||
inputBind("gamepad_b", INPUT_ACTION_CANCEL)
|
||||
inputBind("gamepad_back", INPUT_ACTION_RAGEQUIT)
|
||||
|
||||
inputBind("gamepad_lstick_up", INPUT_ACTION_UP)
|
||||
inputBind("gamepad_lstick_down", INPUT_ACTION_DOWN)
|
||||
inputBind("gamepad_lstick_left", INPUT_ACTION_LEFT)
|
||||
inputBind("gamepad_lstick_right", INPUT_ACTION_RIGHT)
|
||||
end
|
||||
|
||||
if INPUT_POINTER then
|
||||
inputBind("mouse_x", INPUT_ACTION_POINTERX)
|
||||
inputBind("mouse_y", INPUT_ACTION_POINTERY)
|
||||
end
|
||||
|
||||
else
|
||||
print("Unknown platform, no default input bindings set.")
|
||||
end
|
||||
|
||||
-- localeSet(DUSK_LOCALE_EN_US)
|
||||
sceneSet('scene/initial.dsf')
|
||||
sceneSet('scene/minesweeper.lua')
|
||||
@@ -1,6 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(LANGUAGE en_US.po)
|
||||
@@ -7,9 +7,3 @@ msgstr ""
|
||||
|
||||
msgid "ui.test"
|
||||
msgstr "Hello this is a test."
|
||||
|
||||
msgid "map.test"
|
||||
msgstr "This is a map test."
|
||||
|
||||
msgid "test.test2"
|
||||
msgstr "This is another test."
|
||||
|
||||
BIN
assets/main_palette.dpf
Normal file
BIN
assets/main_palette.dpf
Normal file
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(PALETTE palette0.png)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 241 B |
Binary file not shown.
@@ -1,66 +0,0 @@
|
||||
module('spritebatch')
|
||||
module('camera')
|
||||
module('color')
|
||||
-- module('ui')
|
||||
module('text')
|
||||
module('screen')
|
||||
module('time')
|
||||
module('map')
|
||||
module('glm')
|
||||
|
||||
screenSetBackground(colorLime())
|
||||
mapCamera = cameraCreate()
|
||||
text = "Hello, Dusk!"
|
||||
|
||||
x = -35
|
||||
y = 0
|
||||
|
||||
function sceneDispose()
|
||||
end
|
||||
function sceneUpdate()
|
||||
end
|
||||
function sceneRender()
|
||||
mapCamera.position = vec3(50, 50, 50)
|
||||
cameraPushMatrix(mapCamera)
|
||||
|
||||
textDraw(x, y, text, colorBlue())
|
||||
|
||||
spriteBatchFlush()
|
||||
cameraPopMatrix()
|
||||
end
|
||||
|
||||
|
||||
-- screenSetBackground(colorBlack())
|
||||
-- mapLoad('map/testmap/testmap.dmf')
|
||||
-- camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC)
|
||||
-- mapCamera = cameraCreate()
|
||||
|
||||
-- text = "Hello World"
|
||||
|
||||
-- function sceneDispose()
|
||||
-- end
|
||||
|
||||
-- function sceneUpdate()
|
||||
-- end
|
||||
|
||||
-- function sceneRender()
|
||||
-- -- Map Test
|
||||
-- mapCamera.position = vec3(300, 300, 300)
|
||||
-- cameraPushMatrix(mapCamera)
|
||||
-- mapRender()
|
||||
-- cameraPopMatrix()
|
||||
|
||||
-- -- UI Test
|
||||
-- cameraPushMatrix(camera)
|
||||
-- camera.bottom = screenGetHeight()
|
||||
-- camera.right = screenGetWidth()
|
||||
|
||||
-- width, height = textMeasure(text)
|
||||
-- x = (screenGetWidth() - width)
|
||||
-- x = math.sin(TIME.time * 2) * (x / 2) + (x / 2)
|
||||
-- y = (screenGetHeight() - height) / 2
|
||||
-- y = math.cos(TIME.time * 3) * (y) + (y)
|
||||
-- textDraw(x, y, text, colorMagenta())
|
||||
|
||||
-- cameraPopMatrix()
|
||||
-- end
|
||||
264
assets/scene/minesweeper.lua
Normal file
264
assets/scene/minesweeper.lua
Normal file
@@ -0,0 +1,264 @@
|
||||
module('spritebatch')
|
||||
module('camera')
|
||||
module('color')
|
||||
module('ui')
|
||||
module('screen')
|
||||
module('time')
|
||||
module('glm')
|
||||
module('text')
|
||||
module('tileset')
|
||||
module('texture')
|
||||
module('input')
|
||||
module('shader')
|
||||
|
||||
CELL_STATE_DEFAULT = 0
|
||||
CELL_STATE_HOVER = 1
|
||||
CELL_STATE_DOWN = 2
|
||||
CELL_STATE_DISABLED = 3
|
||||
|
||||
screenSetBackground(colorCornflowerBlue())
|
||||
camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC)
|
||||
|
||||
-- tilesetUi = tilesetGetByName("ui")
|
||||
-- textureUi = textureLoad(tilesetUi.texture)
|
||||
|
||||
-- tilesetBorder = tilesetGetByName("border")
|
||||
-- textureBorder = textureLoad(tilesetBorder.texture)
|
||||
|
||||
-- textureGrid = textureLoad("minesweeper/grid_bg.dpi")
|
||||
|
||||
-- tilesetCell = tilesetGetByName("cell")
|
||||
-- textureCell = textureLoad(tilesetCell.texture)
|
||||
-- cellSliceDefault = tilesetPositionGetUV(tilesetCell, 3, 5)
|
||||
-- cellSliceHover = tilesetPositionGetUV(tilesetCell, 3, 4)
|
||||
-- cellSliceDown = tilesetPositionGetUV(tilesetCell, 3, 6)
|
||||
-- cellSliceDisabled = tilesetPositionGetUV(tilesetCell, 3, 7)
|
||||
|
||||
-- sweepwerCols = 10
|
||||
-- sweeperRows = 14
|
||||
|
||||
-- mouseX = -1
|
||||
-- mouseY = -1
|
||||
-- centerX = 0
|
||||
-- centerY = 0
|
||||
-- boardWidth = sweepwerCols * tilesetCell.tileWidth
|
||||
-- boardHeight = sweeperRows * tilesetCell.tileHeight
|
||||
|
||||
-- i = 0
|
||||
-- cells = {}
|
||||
-- for y = 1, sweeperRows do
|
||||
-- for x = 1, sweepwerCols do
|
||||
-- cells[i] = CELL_STATE_DEFAULT
|
||||
-- i = i + 1
|
||||
-- end
|
||||
-- end
|
||||
|
||||
function cellDraw(x, y, type)
|
||||
local slice = cellSliceDefault
|
||||
if type == CELL_STATE_HOVER then
|
||||
slice = cellSliceHover
|
||||
elseif type == CELL_STATE_DOWN then
|
||||
slice = cellSliceDown
|
||||
elseif type == CELL_STATE_DISABLED then
|
||||
slice = cellSliceDisabled
|
||||
end
|
||||
|
||||
spriteBatchPush(
|
||||
x, y,
|
||||
x + tilesetCell.tileWidth, y + tilesetCell.tileHeight,
|
||||
colorWhite(),
|
||||
slice.u0, slice.v0,
|
||||
slice.u1, slice.v1
|
||||
)
|
||||
end
|
||||
|
||||
function backgroundDraw()
|
||||
local t = (TIME.time / 40) % 1
|
||||
local scaleX = screenGetWidth() / textureGrid.width
|
||||
local scaleY = screenGetHeight() / textureGrid.height
|
||||
local u0 = t * scaleX
|
||||
local v0 = t * scaleY
|
||||
local u1 = scaleX + u0
|
||||
local v1 = scaleY + v0
|
||||
|
||||
spriteBatchPush(textureGrid,
|
||||
0, 0,
|
||||
screenGetWidth(), screenGetHeight(),
|
||||
colorWhite(),
|
||||
u0, v0,
|
||||
u1, v1
|
||||
)
|
||||
end
|
||||
|
||||
function borderDraw(x, y, innerWidth, innerHeight)
|
||||
-- Top Left
|
||||
local uv = tilesetPositionGetUV(tilesetBorder, 0, 0)
|
||||
spriteBatchPush(textureBorder,
|
||||
x - tilesetBorder.tileWidth, y - tilesetBorder.tileWidth,
|
||||
x, y,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Top Right
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 10, 0)
|
||||
spriteBatchPush(textureBorder,
|
||||
x + innerWidth, y - tilesetBorder.tileHeight,
|
||||
x + innerWidth + tilesetBorder.tileWidth, y,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Bottom Left
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 0, 10)
|
||||
spriteBatchPush(textureBorder,
|
||||
x - tilesetBorder.tileWidth, y + innerHeight,
|
||||
x, y + innerHeight + tilesetBorder.tileHeight,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Bottom Right
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 10, 10)
|
||||
spriteBatchPush(textureBorder,
|
||||
x + innerWidth, y + innerHeight,
|
||||
x + innerWidth + tilesetBorder.tileWidth, y + innerHeight + tilesetBorder.tileHeight,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Top
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 1, 0)
|
||||
spriteBatchPush(textureBorder,
|
||||
x, y - tilesetBorder.tileHeight,
|
||||
x + innerWidth, y,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Bottom
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 1, 10)
|
||||
spriteBatchPush(textureBorder,
|
||||
x, y + innerHeight,
|
||||
x + innerWidth, y + innerHeight + tilesetBorder.tileHeight,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Left
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 0, 1)
|
||||
spriteBatchPush(textureBorder,
|
||||
x - tilesetBorder.tileWidth, y,
|
||||
x, y + innerHeight,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
|
||||
-- Right
|
||||
uv = tilesetPositionGetUV(tilesetBorder, 10, 1)
|
||||
spriteBatchPush(textureBorder,
|
||||
x + innerWidth, y,
|
||||
x + innerWidth + tilesetBorder.tileWidth, y + innerHeight,
|
||||
colorWhite(),
|
||||
uv.u0, uv.v0,
|
||||
uv.u1, uv.v1
|
||||
)
|
||||
end
|
||||
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
function sceneDispose()
|
||||
end
|
||||
|
||||
function sceneUpdate()
|
||||
x = x + inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT)
|
||||
y = y + inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN)
|
||||
end
|
||||
|
||||
function sceneRender()
|
||||
-- Update camera
|
||||
camera.bottom = 0
|
||||
camera.top = screenGetHeight()
|
||||
camera.right = screenGetWidth()
|
||||
|
||||
shaderBind(SHADER_UNLIT)
|
||||
proj = cameraGetProjectionMatrix(camera)
|
||||
shaderSetMatrix(SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj)
|
||||
view = cameraGetViewMatrix(camera)
|
||||
shaderSetMatrix(SHADER_UNLIT, SHADER_UNLIT_VIEW, view)
|
||||
|
||||
shaderSetTexture(SHADER_UNLIT, SHADER_UNLIT_TEXTURE, nil)
|
||||
spriteBatchPush(
|
||||
x, y,
|
||||
x + 32, y + 32,
|
||||
colorWhite()
|
||||
)
|
||||
spriteBatchFlush()
|
||||
|
||||
textDraw(10, 10, "Hello World\nHow are you?", colorRed())
|
||||
spriteBatchFlush()
|
||||
|
||||
-- Update mouse position
|
||||
-- if INPUT_POINTER then
|
||||
-- mouseX = inputGetValue(INPUT_ACTION_POINTERX) * screenGetWidth()
|
||||
-- mouseY = inputGetValue(INPUT_ACTION_POINTERY) * screenGetHeight()
|
||||
|
||||
-- -- Draw cursor
|
||||
-- spriteBatchPush(
|
||||
-- nil,
|
||||
-- mouseX - 2, mouseY - 2,
|
||||
-- mouseX + 2, mouseY + 2,
|
||||
-- colorRed(),
|
||||
-- 0, 0,
|
||||
-- 1, 1
|
||||
-- )
|
||||
-- end
|
||||
|
||||
|
||||
-- textDraw(10, 10, "Hello World")
|
||||
|
||||
-- centerX = math.floor(screenGetWidth() / 2)
|
||||
-- centerY = math.floor(screenGetHeight() / 2)
|
||||
|
||||
-- Draw elements
|
||||
-- backgroundDraw()
|
||||
-- borderDraw(
|
||||
-- centerX - (boardWidth / 2), centerY - (boardHeight / 2),
|
||||
-- boardWidth, boardHeight
|
||||
-- )
|
||||
|
||||
-- i = 0
|
||||
-- -- Foreach cell
|
||||
-- local offX = centerX - (boardWidth / 2)
|
||||
-- local offY = centerY - (boardHeight / 2)
|
||||
-- for y = 0, sweeperRows - 1 do
|
||||
-- for x = 0, sweepwerCols - 1 do
|
||||
-- i = y * sweepwerCols + x
|
||||
|
||||
-- -- Hovered
|
||||
-- if
|
||||
-- cells[i] == CELL_STATE_DEFAULT and
|
||||
-- mouseX >= x * tilesetCell.tileWidth + offX and mouseX < (x + 1) * tilesetCell.tileWidth + offX and
|
||||
-- mouseY >= y * tilesetCell.tileHeight + offY and mouseY < (y + 1) * tilesetCell.tileHeight + offY
|
||||
-- then
|
||||
-- cells[i] = CELL_STATE_HOVER
|
||||
-- else
|
||||
-- cells[i] = CELL_STATE_DEFAULT
|
||||
-- end
|
||||
|
||||
-- cellDraw(
|
||||
-- x * tilesetCell.tileWidth + offX,
|
||||
-- y * tilesetCell.tileHeight + offY,
|
||||
-- cells[i]
|
||||
-- )
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 758 B |
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.2" name="prarie" tilewidth="16" tileheight="16" tilecount="21" columns="7">
|
||||
<image source="prarie.png" width="112" height="48"/>
|
||||
</tileset>
|
||||
@@ -1,7 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(TILESET minogram.png type=ALPHA tileWidth=6 tileHeight=10 columns=16 rows=6)# Fixes PSP rendering
|
||||
# add_asset(TILESET minogram.png type=PALETTIZED tileWidth=6 tileHeight=10 columns=16 rows=6)# Fixes PSP rendering
|
||||
BIN
assets/ui/minogram.dtf
Normal file
BIN
assets/ui/minogram.dtf
Normal file
Binary file not shown.
BIN
assets/ui/minogram.dtx
Normal file
BIN
assets/ui/minogram.dtx
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -4,9 +4,9 @@
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
cglm
|
||||
# GIT_REPOSITORY https://git.wish.moe/YourWishes/cglm.git
|
||||
GIT_REPOSITORY https://github.com/recp/cglm.git
|
||||
GIT_TAG v0.9.6
|
||||
)
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
if(NOT TARGET pspsdk)
|
||||
message(STATUS "Looking for PSPSDK...")
|
||||
|
||||
set(PSPSDK_FOUND FALSE CACHE INTERNAL "PSPSDK found")
|
||||
set(PSPSDK_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/_pspsdk")
|
||||
set(PSPSDK_SEARCH_ROOTS
|
||||
"${PSPSDK_ROOT}"
|
||||
"$ENV{PSPDEV}"
|
||||
"$ENV{HOME}/pspdev"
|
||||
"/usr/local/pspdev"
|
||||
"/opt/pspdev"
|
||||
"/usr/pspdev"
|
||||
"${PSPSDK_DOWNLOAD_DIR}/pspdev"
|
||||
)
|
||||
|
||||
foreach(root IN LISTS PSPSDK_SEARCH_ROOTS)
|
||||
list(APPEND PSPSDK_BIN_HINTS "${root}/bin")
|
||||
list(APPEND PSPSDK_INCLUDE_HINTS "${root}/include")
|
||||
list(APPEND PSPSDK_LIB_HINTS "${root}/lib")
|
||||
endforeach()
|
||||
|
||||
# Find PSP GCC
|
||||
find_program(PSPSDK_PSP_GCC NAMES psp-gcc HINTS ${PSPSDK_BIN_HINTS})
|
||||
|
||||
# If we did not find it, download it.
|
||||
if(NOT PSPSDK_PSP_GCC)
|
||||
message(STATUS "psp-gcc not found in system paths. Downloading PSPSDK tarball...")
|
||||
file(DOWNLOAD
|
||||
"https://github.com/pspdev/pspdev/releases/download/v20260101/pspdev-ubuntu-latest-x86_64.tar.gz"
|
||||
"${CMAKE_BINARY_DIR}/pspsdk.tar.gz"
|
||||
EXPECTED_HASH SHA256=68fb6063323e695a43415a151b3dd9ded61d00605f02d20146cc6933c11830f8
|
||||
SHOW_PROGRESS
|
||||
)
|
||||
|
||||
# Make output dir
|
||||
file(MAKE_DIRECTORY "${PSPSDK_DOWNLOAD_DIR}")
|
||||
|
||||
# Extract the tarball
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E tar xzf "${CMAKE_BINARY_DIR}/pspsdk.tar.gz"
|
||||
WORKING_DIRECTORY
|
||||
"${PSPSDK_DOWNLOAD_DIR}"
|
||||
RESULT_VARIABLE
|
||||
tar_result
|
||||
)
|
||||
if(NOT tar_result EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to extract PSPSDK tarball")
|
||||
endif()
|
||||
|
||||
# Retry discovery with extracted fallback
|
||||
find_program(PSPSDK_PSP_GCC NAMES psp-gcc HINTS ${PSPSDK_BIN_HINTS})
|
||||
endif()
|
||||
|
||||
if(PSPSDK_PSP_GCC)
|
||||
get_filename_component(PSPSDK_BIN_ROOT "${PSPSDK_PSP_GCC}" DIRECTORY)
|
||||
get_filename_component(PSPSDK_ROOT "${PSPSDK_BIN_ROOT}" DIRECTORY)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
set(ENV{PSPDEV} "${PSPSDK_ROOT}")
|
||||
set(CMAKE_TOOLCHAIN_FILE "${PSPSDK_ROOT}/psp/share/pspdev.cmake")
|
||||
set(BUILD_PRX ON CACHE BOOL "Build PRX modules")
|
||||
|
||||
include("${PSPSDK_ROOT}/psp/share/pspdev.cmake")
|
||||
set(CMAKE_C_COMPILER ${PSPSDK_BIN_ROOT}/psp-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${PSPSDK_BIN_ROOT}/psp-g++)
|
||||
|
||||
if(NOT DEFINED PSP)
|
||||
message(FATAL_ERROR "PSP environment variable is not set correctly.")
|
||||
endif()
|
||||
|
||||
add_library(pspsdk INTERFACE IMPORTED)
|
||||
set_target_properties(pspsdk PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PSPSDK_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_DIRECTORIES "${PSPSDK_LIB_DIR}"
|
||||
)
|
||||
target_include_directories(pspsdk
|
||||
INTERFACE
|
||||
${PSPDEV}/psp/include
|
||||
${PSPDEV}/psp/sdk/include
|
||||
)
|
||||
target_link_directories(pspsdk
|
||||
INTERFACE
|
||||
${PSPDEV}/lib
|
||||
${PSPDEV}/psp/lib
|
||||
${PSPDEV}/psp/sdk/lib
|
||||
)
|
||||
target_link_libraries(pspsdk INTERFACE
|
||||
pspdebug
|
||||
pspdisplay
|
||||
pspge
|
||||
pspctrl
|
||||
pspgu
|
||||
pspaudio
|
||||
pspaudiolib
|
||||
psputility
|
||||
pspvfpu
|
||||
pspvram
|
||||
psphprm
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
61
cmake/targets/dolphin.cmake
Normal file
61
cmake/targets/dolphin.cmake
Normal file
@@ -0,0 +1,61 @@
|
||||
# Target definitions
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_DOLPHIN
|
||||
DUSK_INPUT_GAMEPAD
|
||||
DUSK_DISPLAY_WIDTH=640
|
||||
DUSK_DISPLAY_HEIGHT=480
|
||||
)
|
||||
|
||||
# Custom compiler flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
||||
|
||||
# Need PkgConfig
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(zip IMPORTED_TARGET libzip)
|
||||
|
||||
# Disable all warnings
|
||||
target_compile_options(${DUSK_LIBRARY_TARGET_NAME} PRIVATE -w)
|
||||
|
||||
# Custom flags for cglm
|
||||
set(CGLM_SHARED OFF CACHE BOOL "Build cglm shared" FORCE)
|
||||
set(CGLM_STATIC ON CACHE BOOL "Build cglm static" FORCE)
|
||||
find_package(cglm REQUIRED)
|
||||
|
||||
# Compile lua
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
liblua
|
||||
URL https://www.lua.org/ftp/lua-5.5.0.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(liblua)
|
||||
set(LUA_SRC_DIR "${liblua_SOURCE_DIR}/src")
|
||||
set(LUA_C_FILES
|
||||
lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c ldebug.c
|
||||
ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c
|
||||
loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c
|
||||
lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c
|
||||
)
|
||||
list(TRANSFORM LUA_C_FILES PREPEND "${LUA_SRC_DIR}/")
|
||||
add_library(liblua STATIC ${LUA_C_FILES})
|
||||
target_include_directories(liblua PUBLIC "${LUA_SRC_DIR}")
|
||||
target_compile_definitions(liblua PRIVATE LUA_USE_C89)
|
||||
add_library(lua::lua ALIAS liblua)
|
||||
set(Lua_FOUND TRUE CACHE BOOL "Lua found" FORCE)
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
cglm
|
||||
liblua
|
||||
m
|
||||
fat
|
||||
PkgConfig::zip
|
||||
)
|
||||
|
||||
# Postbuild
|
||||
set(DUSK_BINARY_TARGET_NAME_DOL "${DUSK_BUILD_DIR}/Dusk.dol")
|
||||
add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD
|
||||
COMMAND elf2dol
|
||||
"$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>"
|
||||
"${DUSK_BINARY_TARGET_NAME_DOL}"
|
||||
COMMENT "Generating ${DUSK_BINARY_TARGET_NAME_DOL} from ${DUSK_BINARY_TARGET_NAME}"
|
||||
)
|
||||
5
cmake/targets/gamecube.cmake
Normal file
5
cmake/targets/gamecube.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
include(cmake/targets/dolphin.cmake)
|
||||
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_GAMECUBE
|
||||
)
|
||||
45
cmake/targets/knulli.cmake
Normal file
45
cmake/targets/knulli.cmake
Normal file
@@ -0,0 +1,45 @@
|
||||
# Find link platform-specific libraries
|
||||
set(OpenGL_GL_PREFERENCE LEGACY)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_library(EGL_LIB EGL REQUIRED)
|
||||
find_library(GL_LIB GL REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
# Setup endianess at compile time to optimize.
|
||||
include(TestBigEndian)
|
||||
test_big_endian(IS_BIG_ENDIAN)
|
||||
if(IS_BIG_ENDIAN)
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_PLATFORM_ENDIAN_BIG
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||
)
|
||||
endif()
|
||||
|
||||
# Link required libraries.
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
SDL2
|
||||
pthread
|
||||
OpenGL::GLES2
|
||||
${GL_LIB}
|
||||
${EGL_LIB}
|
||||
m
|
||||
)
|
||||
|
||||
# Define platform-specific macros.
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_SDL2
|
||||
DUSK_OPENGL
|
||||
DUSK_OPENGL_ES
|
||||
DUSK_LINUX
|
||||
DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
DUSK_DISPLAY_WIDTH_DEFAULT=640
|
||||
DUSK_DISPLAY_HEIGHT_DEFAULT=480
|
||||
DUSK_DISPLAY_SCREEN_HEIGHT=240
|
||||
DUSK_INPUT_KEYBOARD
|
||||
DUSK_INPUT_POINTER
|
||||
DUSK_INPUT_GAMEPAD
|
||||
DUSK_TIME_DYNAMIC
|
||||
)
|
||||
41
cmake/targets/linux.cmake
Normal file
41
cmake/targets/linux.cmake
Normal file
@@ -0,0 +1,41 @@
|
||||
# Find link platform-specific libraries
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
# Setup endianess at compile time to optimize.
|
||||
include(TestBigEndian)
|
||||
test_big_endian(IS_BIG_ENDIAN)
|
||||
if(IS_BIG_ENDIAN)
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_PLATFORM_ENDIAN_BIG
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||
)
|
||||
endif()
|
||||
|
||||
# Link required libraries.
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
SDL2
|
||||
pthread
|
||||
OpenGL::GL
|
||||
GL
|
||||
m
|
||||
)
|
||||
|
||||
# Define platform-specific macros.
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_SDL2
|
||||
DUSK_OPENGL
|
||||
# DUSK_OPENGL_LEGACY
|
||||
DUSK_LINUX
|
||||
DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
DUSK_DISPLAY_WIDTH_DEFAULT=640
|
||||
DUSK_DISPLAY_HEIGHT_DEFAULT=480
|
||||
DUSK_DISPLAY_SCREEN_HEIGHT=240
|
||||
DUSK_INPUT_KEYBOARD
|
||||
DUSK_INPUT_POINTER
|
||||
DUSK_INPUT_GAMEPAD
|
||||
DUSK_TIME_DYNAMIC
|
||||
)
|
||||
53
cmake/targets/psp.cmake
Normal file
53
cmake/targets/psp.cmake
Normal file
@@ -0,0 +1,53 @@
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
${SDL2_LIBRARIES}
|
||||
SDL2
|
||||
pthread
|
||||
OpenGL::GL
|
||||
zip
|
||||
bz2
|
||||
z
|
||||
mbedtls
|
||||
mbedcrypto
|
||||
lzma
|
||||
m
|
||||
|
||||
pspdebug
|
||||
pspdisplay
|
||||
pspge
|
||||
pspctrl
|
||||
pspgu
|
||||
pspaudio
|
||||
pspaudiolib
|
||||
psputility
|
||||
pspvfpu
|
||||
pspvram
|
||||
psphprm
|
||||
)
|
||||
|
||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
${SDL2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_SDL2
|
||||
DUSK_OPENGL
|
||||
DUSK_PSP
|
||||
DUSK_INPUT_GAMEPAD
|
||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||
DUSK_OPENGL_LEGACY
|
||||
DUSK_DISPLAY_WIDTH=480
|
||||
DUSK_DISPLAY_HEIGHT=272
|
||||
)
|
||||
|
||||
# Postbuild, create .pbp file for PSP.
|
||||
create_pbp_file(
|
||||
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
||||
ICON_PATH NULL
|
||||
BACKGROUND_PATH NULL
|
||||
PREVIEW_PATH NULL
|
||||
TITLE "${DUSK_BINARY_TARGET_NAME}"
|
||||
PSAR_PATH ${DUSK_ASSETS_ZIP}
|
||||
VERSION 01.00
|
||||
)
|
||||
5
cmake/targets/wii.cmake
Normal file
5
cmake/targets/wii.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
include(cmake/targets/dolphin.cmake)
|
||||
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_WII
|
||||
)
|
||||
29
cmake/toolchains/aarch64-linux-gnu.cmake
Normal file
29
cmake/toolchains/aarch64-linux-gnu.cmake
Normal file
@@ -0,0 +1,29 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
||||
set(CMAKE_ASM_COMPILER aarch64-linux-gnu-gcc)
|
||||
|
||||
set(CMAKE_SYSROOT /)
|
||||
set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu)
|
||||
set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH
|
||||
/usr/aarch64-linux-gnu
|
||||
/usr/lib/aarch64-linux-gnu
|
||||
/usr/include/aarch64-linux-gnu
|
||||
)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig")
|
||||
set(ENV{PKG_CONFIG_PATH} "/usr/lib/aarch64-linux-gnu/pkgconfig")
|
||||
|
||||
set(CMAKE_PREFIX_PATH "/usr/aarch64-linux-gnu;/usr/lib/aarch64-linux-gnu")
|
||||
|
||||
# Optional: helps some Find modules
|
||||
set(SDL2_DIR "/usr/lib/aarch64-linux-gnu/cmake/SDL2" CACHE PATH "")
|
||||
@@ -1,5 +1,6 @@
|
||||
FROM devkitpro/devkitppc
|
||||
|
||||
WORKDIR /workdir
|
||||
RUN apt update && \
|
||||
apt install -y python3 python3-pip python3-polib python3-pil python3-dotenv python3-pyqt5 python3-opengl && \
|
||||
dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip
|
||||
dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip
|
||||
VOLUME ["/workdir"]
|
||||
10
docker/dolphin/meta.xml
Normal file
10
docker/dolphin/meta.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<app version="1">
|
||||
<name>Dusk</name>
|
||||
<version>1.00</version>
|
||||
<release_date></release_date>
|
||||
<coder>YouWish</coder>
|
||||
<short_description>Dusk game</short_description>
|
||||
<long_description>No description yet.</long_description>
|
||||
<ahb_access/>
|
||||
</app>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user