aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2021-10-15 09:22:45 +0800
committerGitHub <noreply@github.com>2021-10-15 09:22:45 +0800
commitdd0f088aaa4c6bf013643be2d1d8621dbffdb000 (patch)
treed848d6ce007d8bb9357c8b99d6a0a39ec41d244e
parent9e08d1047fa8deeb3ccb3ce9bb11d69e25a52d56 (diff)
parenteb719a424e6a16fb64209139a32c9f8a7235a929 (diff)
downloadpsn00bsdk-dd0f088aaa4c6bf013643be2d1d8621dbffdb000.tar.gz
Merge pull request #38 from spicyjpeg/cmake
Full CMake support (in place of makefiles)
-rw-r--r--.gitignore10
-rw-r--r--CMakeLists.txt182
-rw-r--r--INSTALL.md108
-rw-r--r--README.md103
-rw-r--r--changelog.txt44
-rw-r--r--cpack/convert_images.sh45
-rw-r--r--cpack/description.txt27
-rw-r--r--cpack/fakeroot_fix.cmake32
-rw-r--r--cpack/icon.icobin0 -> 194619 bytes
-rw-r--r--cpack/icon.svg164
-rw-r--r--cpack/nsis_banner.bmpbin0 -> 42622 bytes
-rw-r--r--cpack/nsis_banner.svg162
-rw-r--r--cpack/nsis_header.bmpbin0 -> 4220 bytes
-rw-r--r--cpack/nsis_header.svg66
-rw-r--r--cpack/uninstall.icobin0 -> 194619 bytes
-rw-r--r--cpack/uninstall.svg164
-rw-r--r--cpack/welcome.txt3
-rw-r--r--doc/cmake_reference.md207
-rw-r--r--doc/dev notes.txt65
-rw-r--r--examples/CMakeLists.txt25
-rw-r--r--examples/beginner/cppdemo/CMakeLists.txt22
-rw-r--r--examples/beginner/cppdemo/makefile65
-rw-r--r--examples/beginner/hello/CMakeLists.txt22
-rw-r--r--examples/beginner/hello/makefile65
-rw-r--r--examples/cdrom/cdbrowse/CMakeLists.txt27
-rw-r--r--examples/cdrom/cdbrowse/iso.xml12
-rw-r--r--examples/cdrom/cdbrowse/makefile65
-rw-r--r--examples/cdrom/cdxa/CMakeLists.txt29
-rw-r--r--examples/cdrom/cdxa/iso.xml14
-rw-r--r--examples/cdrom/cdxa/makefile65
-rw-r--r--examples/demos/n00bdemo/CMakeLists.txt50
-rw-r--r--examples/demos/n00bdemo/data.h4
-rw-r--r--examples/demos/n00bdemo/data.s.template (renamed from examples/demos/n00bdemo/data.s)8
-rw-r--r--examples/demos/n00bdemo/data.xml49
-rw-r--r--examples/demos/n00bdemo/data.xml.template49
-rw-r--r--examples/demos/n00bdemo/logo.c2
-rw-r--r--examples/demos/n00bdemo/main.c10
-rw-r--r--examples/demos/n00bdemo/makefile65
-rw-r--r--examples/graphics/balls/CMakeLists.txt22
-rw-r--r--examples/graphics/balls/makefile65
-rw-r--r--examples/graphics/billboard/CMakeLists.txt28
-rw-r--r--examples/graphics/billboard/makefile65
-rw-r--r--examples/graphics/billboard/tim.s.template (renamed from examples/graphics/billboard/tim.s)3
-rw-r--r--examples/graphics/fpscam/CMakeLists.txt22
-rw-r--r--examples/graphics/fpscam/makefile65
-rw-r--r--examples/graphics/gte/CMakeLists.txt22
-rw-r--r--examples/graphics/gte/makefile65
-rw-r--r--examples/graphics/hdtv/CMakeLists.txt22
-rw-r--r--examples/graphics/hdtv/makefile65
-rw-r--r--examples/graphics/render2tex/CMakeLists.txt28
-rw-r--r--examples/graphics/render2tex/makefile65
-rw-r--r--examples/graphics/render2tex/texture.s.template (renamed from examples/graphics/render2tex/texture.s)3
-rw-r--r--examples/graphics/rgb24/CMakeLists.txt28
-rw-r--r--examples/graphics/rgb24/makefile65
-rw-r--r--examples/graphics/rgb24/tim.s.template (renamed from examples/graphics/rgb24/tim.s)3
-rw-r--r--examples/makefile34
-rw-r--r--examples/system/childexec/CMakeLists.txt41
-rw-r--r--examples/system/childexec/child_exe.s.template (renamed from examples/system/childexec/child_exe.s)2
-rw-r--r--examples/system/childexec/makefile93
-rw-r--r--examples/system/console/CMakeLists.txt22
-rw-r--r--examples/system/console/makefile65
-rw-r--r--examples/system/dynlink/CMakeLists.txt32
-rw-r--r--examples/system/dynlink/iso.xml16
-rw-r--r--examples/system/dynlink/makefile95
-rw-r--r--examples/system/timer/CMakeLists.txt22
-rw-r--r--examples/system/timer/makefile65
-rw-r--r--examples/system/tty/CMakeLists.txt22
-rw-r--r--examples/system/tty/makefile65
-rw-r--r--libpsn00b/CMakeLists.txt69
-rw-r--r--libpsn00b/cmake/internal_setup.cmake161
-rw-r--r--libpsn00b/cmake/sdk.cmake89
-rw-r--r--libpsn00b/cmake/virtual_targets.cmake109
-rw-r--r--libpsn00b/include/dlfcn.h2
-rw-r--r--libpsn00b/include/lzp/lzp.h223
-rw-r--r--libpsn00b/include/lzp/lzqlp.h31
-rw-r--r--libpsn00b/libc/makefile61
-rw-r--r--libpsn00b/lzp/bit.c2
-rw-r--r--libpsn00b/lzp/bit.h2
-rw-r--r--libpsn00b/lzp/compress.c10
-rw-r--r--libpsn00b/lzp/crc.c12
-rw-r--r--libpsn00b/lzp/lzp.c32
-rw-r--r--libpsn00b/lzp/lzp.h18
-rw-r--r--libpsn00b/lzp/lzqlp.h23
-rw-r--r--libpsn00b/lzp/makefile59
-rw-r--r--libpsn00b/lzp/qlp.c24
-rw-r--r--libpsn00b/makefile23
-rw-r--r--libpsn00b/psxapi/makefile61
-rw-r--r--libpsn00b/psxcd/makefile59
-rw-r--r--libpsn00b/psxetc/dl.c2
-rw-r--r--libpsn00b/psxetc/makefile59
-rw-r--r--libpsn00b/psxgpu/makefile59
-rw-r--r--libpsn00b/psxgte/makefile59
-rw-r--r--libpsn00b/psxsio/makefile59
-rw-r--r--libpsn00b/psxspu/makefile59
-rw-r--r--libpsn00b/readme.txt2
-rw-r--r--psn00bsdk-setup.mk121
-rw-r--r--template/CMakeLists.txt28
-rw-r--r--template/iso.xml23
-rw-r--r--template/makefile69
-rw-r--r--toolchain.txt42
-rw-r--r--tools/CMakeLists.txt76
-rw-r--r--tools/lzpack/filelist.h7
-rw-r--r--tools/lzpack/lzp/makefile30
-rw-r--r--tools/lzpack/main.cpp34
-rw-r--r--tools/lzpack/makefile46
-rw-r--r--tools/makefile12
-rw-r--r--tools/smxlink/main.cpp4
-rw-r--r--tools/smxlink/makefile45
-rw-r--r--tools/smxlink/timreader.cpp4
-rw-r--r--tools/util/elf2cpe.c4
-rw-r--r--tools/util/elf2x.c9
-rw-r--r--tools/util/makefile20
112 files changed, 2791 insertions, 2392 deletions
diff --git a/.gitignore b/.gitignore
index bf1de1f..71a3cea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,21 @@
.svn
+.vscode
+.DS_Store
build
bin
old
scrap
*.a
*.o
+*.obj
*.elf
+*.so
*.exe
+*.map
+*.dll
*.lzp
*.qlp
*.iso
-*.rom \ No newline at end of file
+*.rom
+*.code-workspace
+CMakeUserPresets.json
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..fa04b71
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,182 @@
+# PSn00bSDK main build script
+# (C) 2021 spicyjpeg - MPL licensed
+
+# NOTE: CMake doesn't support using multiple toolchains in a single project,
+# so we can't use add_subdirectory() to build both the libraries and tools. A
+# workaround is to use ExternalProject_Add() to launch multiple independent
+# CMake instances, creating what's known as a "superbuild".
+
+cmake_minimum_required(VERSION 3.21)
+include(ExternalProject)
+
+project(
+ PSn00bSDK
+ LANGUAGES NONE
+ # IMPORTANT TODO: set a version number
+ VERSION 0.1.0
+ DESCRIPTION "Open source PlayStation 1 SDK"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+# Including this without initializing at least one language throws a warning and
+# there's no way to mute it.
+include(GNUInstallDirs)
+
+# These are passed through to libpsn00b and the examples (they are defined in
+# the toolchain file).
+set(
+ PSN00BSDK_TC $ENV{PSN00BSDK_TC}
+ CACHE PATH "Path to the GCC toolchain's installation directory"
+)
+set(
+ PSN00BSDK_TARGET mipsel-unknown-elf
+ CACHE STRING "GCC toolchain target triplet"
+)
+
+set(
+ SKIP_DOWNLOAD OFF
+ CACHE BOOL "Skip downloading and building tinyxml2 and mkpsxiso"
+)
+set(
+ SKIP_EXAMPLES OFF
+ CACHE BOOL "Skip building SDK examples (not required for installation)"
+)
+
+# Forward some important variables to mkpsxiso and to the subprojects (they are
+# not inherited automatically as they are not environment variables). This also
+# sets all subprojects to "install" everything to a temporary directory in the
+# build tree, so they don't actually get installed until "cmake --install" is
+# invoked (ExternalProject_Add() runs the subprojects' install step at build
+# time).
+set(
+ SUBPROJECT_ARGS
+ -DPSN00BSDK_TC:PATH=${PSN00BSDK_TC}
+ -DPSN00BSDK_TARGET:STRING=${PSN00BSDK_TARGET}
+ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE}
+ -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/install_tree
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+)
+set(
+ EXAMPLES_ARGS
+ -DPSN00BSDK_TC:PATH=${PSN00BSDK_TC}
+ -DPSN00BSDK_TARGET:STRING=${PSN00BSDK_TARGET}
+ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${PROJECT_BINARY_DIR}/install_tree/${CMAKE_INSTALL_LIBDIR}/libpsn00b/cmake/sdk.cmake
+ -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/examples
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+)
+
+## External dependencies
+
+if(NOT SKIP_DOWNLOAD)
+ list(APPEND SUBPROJECT_ARGS -Dtinyxml2_ROOT:PATH=${PROJECT_BINARY_DIR}/install_temp)
+
+ ExternalProject_Add(
+ tinyxml2
+ GIT_REPOSITORY "https://github.com/leethomason/tinyxml2"
+ CMAKE_CACHE_ARGS
+ -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/install_temp
+ -DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>
+ INSTALL_DIR install_temp
+ )
+ ExternalProject_Add(
+ mkpsxiso
+ # IMPORTANT TODO: migrate to Lameguy64/mkpsxiso once PR #18 is merged
+ GIT_REPOSITORY "https://github.com/spicyjpeg/mkpsxiso"
+ GIT_TAG cmake
+ #GIT_REPOSITORY "https://github.com/Lameguy64/mkpsxiso"
+ CMAKE_CACHE_ARGS ${SUBPROJECT_ARGS}
+ INSTALL_DIR install_tree
+ DEPENDS tinyxml2
+ )
+else()
+ list(APPEND SUBPROJECT_ARGS -Dtinyxml2_ROOT:PATH=${tinyxml2_ROOT})
+
+ # Create dummy targets so CMake doesn't throw missing dependency errors.
+ add_library(tinyxml2 INTERFACE)
+ add_library(mkpsxiso INTERFACE)
+endif()
+
+## Subprojects
+
+ExternalProject_Add(
+ libpsn00b
+ SOURCE_DIR ${PROJECT_SOURCE_DIR}/libpsn00b
+ CMAKE_CACHE_ARGS ${SUBPROJECT_ARGS}
+ INSTALL_DIR install_tree
+)
+ExternalProject_Add(
+ tools
+ SOURCE_DIR ${PROJECT_SOURCE_DIR}/tools
+ CMAKE_CACHE_ARGS ${SUBPROJECT_ARGS}
+ INSTALL_DIR install_tree
+ DEPENDS tinyxml2
+)
+ExternalProject_Add(
+ examples
+ SOURCE_DIR ${PROJECT_SOURCE_DIR}/examples
+ CMAKE_CACHE_ARGS ${EXAMPLES_ARGS}
+ INSTALL_DIR install_tree
+ DEPENDS libpsn00b tools mkpsxiso
+ EXCLUDE_FROM_ALL ${SKIP_EXAMPLES}
+)
+
+# Install all files in the temporary installation tree, as well as static files
+# from the source tree, when "cmake --install" is invoked.
+install(
+ DIRECTORY ${PROJECT_BINARY_DIR}/install_tree/ # THE TRAILING SLASH IS IMPORTANT
+ DESTINATION .
+ USE_SOURCE_PERMISSIONS
+)
+install(
+ DIRECTORY doc template
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/psn00bsdk
+)
+
+## CPack configuration
+
+if(WIN32)
+ set(CPACK_GENERATOR ZIP NSIS)
+elseif(APPLE)
+ # TODO: add a macOS installer and related options
+ set(CPACK_GENERATOR ZIP)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(CPACK_GENERATOR ZIP DEB RPM)
+else()
+ set(CPACK_GENERATOR ZIP)
+endif()
+
+set(CPACK_PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/cpack)
+set(CPACK_PACKAGE_NAME PSn00bSDK)
+set(CPACK_PACKAGE_VENDOR Lameguy64)
+set(CPACK_PACKAGE_CONTACT Lameguy64)
+set(CPACK_PACKAGE_ICON ${PROJECT_SOURCE_DIR}/cpack/icon.ico)
+set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/cpack/description.txt)
+set(CPACK_RESOURCE_FILE_WELCOME ${PROJECT_SOURCE_DIR}/cpack/welcome.txt)
+set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md)
+set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE.md)
+set(CPACK_PRE_BUILD_SCRIPTS ${PROJECT_SOURCE_DIR}/cpack/fakeroot_fix.cmake)
+
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.28), cmake (>= 3.21), gcc-mipsel-unknown-elf")
+set(CPACK_DEBIAN_PACKAGE_SUGGESTS "git")
+set(CPACK_DEBIAN_PACKAGE_SECTION devel)
+set(CPACK_RPM_PACKAGE_REQUIRES "cmake >= 3.21, gcc-mipsel-unknown-elf")
+set(CPACK_RPM_PACKAGE_SUGGESTS "git")
+#set(CPACK_RPM_PACKAGE_RELOCATABLE ON)
+
+set(CPACK_NSIS_MUI_ICON ${PROJECT_SOURCE_DIR}/cpack/icon.ico)
+set(CPACK_NSIS_MUI_UNIICON ${PROJECT_SOURCE_DIR}/cpack/uninstall.ico)
+set(CPACK_NSIS_MUI_HEADERIMAGE ${PROJECT_SOURCE_DIR}/cpack/nsis_header.bmp)
+set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP ${PROJECT_SOURCE_DIR}/cpack/nsis_banner.bmp)
+set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP ${PROJECT_SOURCE_DIR}/cpack/nsis_banner.bmp)
+set(CPACK_NSIS_BRANDING_TEXT "PSn00bSDK - Meido-Tek Productions")
+set(CPACK_NSIS_URL_INFO_ABOUT "${PROJECT_HOMEPAGE_URL}")
+set(CPACK_NSIS_MODIFY_PATH ON)
+set(
+ CPACK_NSIS_MENU_LINKS
+ "${PROJECT_HOMEPAGE_URL}" "About PSn00bSDK"
+ "https://github.com/Lameguy64/PSn00bSDK" "GitHub repo"
+)
+
+# This will generate a CPack configuration file and add a "package" target to
+# launch CPack.
+include(CPack)
diff --git a/INSTALL.md b/INSTALL.md
new file mode 100644
index 0000000..6547c2b
--- /dev/null
+++ b/INSTALL.md
@@ -0,0 +1,108 @@
+
+# Getting started with PSn00bSDK
+
+## Building and installing
+
+The instructions below are for Windows and Linux. Building on macOS hasn't been
+tested but should work.
+
+1. Install a host C compiler toolchain if you don't already have one (this is
+ required to build the tools). You can use MSVC or MinGW on Windows, or
+ install the `build-essential` package provided by most Linux distros.
+
+2. Install Git and CMake. Note that some Linux distros ship relatively old
+ versions of CMake, so make sure you have at least CMake 3.21. You will also
+ need [Ninja](https://ninja-build.org) (it is a single executable, you have to
+ copy it to any directory listed in the `PATH` environment variable) on
+ Windows as there is no preinstalled build system; on Linux you can use `make`
+ instead, but Ninja is still recommended.
+
+3. Build and install a GCC toolchain for `mipsel-unknown-elf`. As GCC is
+ notoriously hard to compile under Windows, you may download a precompiled
+ version from [Lameguy64's website](http://lameguy64.net?page=psn00bsdk) and
+ and extract it into Program Files instead. See [toolchain.txt](toolchain.txt)
+ for details on compiling GCC.
+
+4. If you chose a non-standard install location for the toolchain, set the
+ `PSN00BSDK_TC` environment variable to point to the toolchain's root
+ directory. This step is unnecessary if you installed/extracted the toolchain
+ into any of these directories:
+
+ - `C:\Program Files\mipsel-unknown-elf`
+ - `C:\Program Files (x86)\mipsel-unknown-elf`
+ - `C:\mipsel-unknown-elf`
+ - `/usr/local/mipsel-unknown-elf`
+ - `/usr/mipsel-unknown-elf`
+ - `/opt/mipsel-unknown-elf`
+
+5. Clone/download the PSn00bSDK repo and run the following commands:
+
+ ```bash
+ cmake -S . -B ./build -G Ninja --install-prefix INSTALL_PATH
+ cmake --build ./build
+ cmake --install ./build
+ ```
+
+ Replace `INSTALL_PATH` with the directory you want PSn00bSDK to be installed
+ to (default is `C:\Program Files\PSn00bSDK` or `/usr/local`), and remove
+ `-G Ninja` if you want to use `make` instead (not recommended). The following
+ subdirectories will be created:
+
+ - `INSTALL_PATH/bin`
+ - `INSTALL_PATH/lib/libpsn00b`
+ - `INSTALL_PATH/share/psn00bsdk`
+
+6. Set the `PSN00BSDK_LIBS` environment variable to
+ `INSTALL_PATH/lib/libpsn00b` and add `INSTALL_PATH/bin` to `PATH`.
+
+Although not strictly required, you'll probably want to install a PS1 emulator
+with debugging capabilities such as [no$psx](https://problemkaputt.de/psx.htm)
+(Windows only) or [pcsx-redux](https://github.com/grumpycoders/pcsx-redux).
+**Avoid ePSXe and anything based on MAME** as they are inaccurate.
+
+## Building installer packages
+
+CPack can be used to build NSIS-based installers, DEB/RPM packages and zipped
+releases. Note that currently none of the built packages include the toolchain,
+thus their usefulness is limited. Distributing prebuilt releases is discouraged
+anyway since PSn00bSDK is still far from being feature-complete.
+
+1. Follow steps 1-4 above to set up the toolchain, then install NSIS on Windows
+ or `dpkg` and `rpm` on Linux.
+
+2. Run the following commands from the PSn00bSDK directory:
+
+ ```bash
+ cmake -S . -B ./build -G Ninja
+ cmake --build ./build -t package
+ ```
+
+ All built packages will be copied to the `build/cpack` folder.
+
+## Creating a project
+
+1. Copy the contents of `INSTALL_PATH/share/psn00bsdk/template` (or the
+ `template` folder within the repo) to your new project's root directory.
+
+2. Configure and build the template by running:
+
+ ```bash
+ cmake -S . -B ./build -G Ninja
+ cmake --build ./build
+ cmake --install ./build
+ ```
+
+ If you did everything correctly there should be a `template.bin` CD image in
+ the `build` folder. Test it in an emulator to ensure it works.
+
+Note that, even though the template relies on the `PSN00BSDK_LIBS` environment
+variable to locate the SDK by default, you can also specify the path directly
+on the CMake command line by adding
+`-DCMAKE_TOOLCHAIN_FILE=INSTALL_PATH/lib/libpsn00b/cmake/sdk.cmake` (replace
+`INSTALL_PATH` as usual) to the first command.
+
+The toolchain script defines a few CMake macros to create PS1 executables, DLLs
+and CD images. See the [reference](doc/cmake_reference.md) for details.
+
+-----------------------------------------
+_Last updated on 2021-09-26 by spicyjpeg_
diff --git a/README.md b/README.md
index 7b794c7..1b56143 100644
--- a/README.md
+++ b/README.md
@@ -79,102 +79,14 @@ As of August 16, 2021
## Obtaining PSn00bSDK
+PSn00bSDK has switched to a CMake-based build and installation system. See
+[INSTALL.md](INSTALL.md) for details.
+
Because PSn00bSDK is updated semi-regularly due to this project being in
a work-in-progress state, it is better to obtain this SDK from source and
building it yourself in the long run. Pre-compiled packages for Debian and
-Msys2 are being planned however.
-
-A precompiled copy of the GCC 7.4.0 toolchain for Windows is available
-in the PSn00bSDK page of Lameguy64's website
-( http://lameguy64.net/?page=psn00bsdk ). This should make building PSn00bSDK
-under Windows a bit easier, as the GCC toolchain is quite difficult to
-compile correctly under Windows than it is on Linux and BSDs.
-
-
-## Building the SDK
-
-You may set one of the following variables either with set/export or on the
-make command line, to specify various parameters in building PSn00bSDK and
-projects made with it as you see fit.
-
-* ``PSN00BSDK_TC`` specifies the base directory of the GCC toolchain to
- build PSn00bSDK with, otherwise the makefile assumes you have the path to
- the toolchain binaries in one of your PATH directories. Alternatively,
- ``GCC_BASE`` can be specified in place of ``PSN00BSDK_TC``. If not
- specified psn00bsdk-setup.mk assumes the toolchain is at
- C:\mipsel-unknown-elf in Win32 or /usr/local/mipsel-unknown-elf in Linux.
-* ``GCC_VERSION`` specifies the GCC version number. This is only used for
- building the libc library. If not defined, it will be auto-detected by
- searching ``PSN00BSDK_TC`` or ``GCC_BASE`` for a valid GCC installation.
-* ``PSN00BSDK_LIBS`` specifies the target directory you wish to install
- the compiled libpsn00b libraries to. If not defined, compiled
- libraries are consolidated to the libpsn00b directory and
- psn00bsdk-setup.mk assumes the SDK libraries are at ../psn00bsdk/libpsn00b.
-
-
-### Windows:
-1. Download the following:
- * MSys2 (32-bit or 64-bit version whichever you prefer)
- * GCC 7.4.0 for mipsel-unknown-elf (download from Lameguy64's website at
- http://lameguy64.net?page=psn00bsdk if you rather not build it yourself)
-2. Install MSys2, update packages (with pacman -Syu) then install the
- following packages:
- * git
- * make
- * mingw-w64-i686-gcc (32-bit) or mingw-w64-x86_64-gcc (64-bit)
- You may need to close and reopen MSys2 for the PATH environment in the
- shell to update for MinGW.
- * mingw-w64-i686-tinyxml2 (32-bit) or mingw-w64-x86_64-tinyxml2 (64-bit)
- Used by lzpack and smxlink.
-3. Extract GCC 7.4.0 for mipsel-unknown-elf to the root of your C drive.
-4. Edit `mipsel-unknown-elf/mipsel-unknown-elf/lib/ldscripts/elf32elmip.x`
- and append definitions to the .text definition as explained in
- toolchain.txt.
-5. Add `export PATH=$PATH:/c/mipsel-unknown-elf/bin` to your `.bash_profile`
- file in MSys2. Test if `mipsel-unknown-elf-gcc` can be called from any
- directory in the terminal after reloading the MSys2 shell for the change
- to take effect.
-6. Clone from PSn00bSDK source with
- `git clone https://github.com/lameguy64/psn00bsdk`
- Clone it in the root of your C drive or in any location you prefer.
-7. Enter the tools directory in PSn00bSDK and run `make` to build all tools,
- then run `make install` to consolidate all tools to a single bin
- directory. Add this directory to your PATH variable by adding
- `export=$PATH:<path to SDK>/tools/bin` in your .bash_profile. Reload
- the MSys2 shell for the changes to take effect, then enter `elf2x` if
- the tools can be executed from any directory.
-8. Enter libpsn00b directory and run `make` to build all libpsn00b libraries,
- then `make install` to consolidate the libraries to either the parent
- directory or the directory specified by ``PSN00BSDK_LIBS``.
-6. Compile the example programs by running `make` from the examples
- directory to test the SDK.
-
-If you prefer to do things in the Command Prompt, you can add the paths
-c:\msys64\usr\bin, c:\msys64\mingw64\bin (mingw32 for 32-bit),
-c:\mipsel-unknown-elf\bin and c:\psn00bsdk\tools\bin (paths may vary
-depending on where you've installed/extracted them) to your system's
-PATH environment variable. This way, you can invoke make and compile
-programs with PSn00bSDK within the Command Prompt.
-
-
-### Linux and Unix-likes:
-1. Install gcc, make, texinfo, git and development packages of mpfr, mpc,
- gmp, isl and tinyxml2 libraries for your distro.
-2. Build and install the GNU GCC toolchain targeting mipsel-unknown-elf
- (see toolchain.txt for details). Export a variable named `PSN00BSDK_TC`
- containing a path to the installed toolchain's base directory if
- you've installed the toolchain in a location other than /usr/local.
-3. Clone from PSn00bSDK source with
- `git clone https://github.com/lameguy64/psn00bsdk`
-4. Enter tools directory and run `make`, then `make install` to consolidate
- the tools to the bin directory. Add this directory to your PATH variable
- and make sure `elf2x` and other tools are accessible from any directory.
-5. Enter the libpsn00b directory and run `make`. Then, run `make install`
- to consolidate the libraries to the libpsn00b parent directory, or the
- directory specified by ``PSN00BSDK_LIBS``.
-6. Compile the example programs by running `make` from the examples
- directory to test the SDK.
-
+Msys2 are being planned however (it is already possible to build installers,
+DEB and RPM packages through CPack so it's only a matter of time).
## Examples
@@ -207,11 +119,6 @@ for the PlayStation. The tutorials should still apply to PSn00bSDK.
* Pad and memory card libraries that don't use the BIOS routines.
-* Switching to, or adding support for a build system that's easier to use with
- IDEs and/or under Windows, which would also make asset conversion pipelines
- easier to manage. CMake might be a good option here but more discussion is
- needed.
-
## Usage terms
PSn00bSDK falls under the terms and conditions of the Mozilla Public
diff --git a/changelog.txt b/changelog.txt
index a21bc9b..7f141f6 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -2,6 +2,7 @@ PSn00bSDK changelog
Items that are lower in the log are more recently implemented.
+
10-06-2021 by Lameguy64:
* psxspu: Fixed register typo in SpyKeyOn causing unpredictable instability.
@@ -9,7 +10,48 @@ Items that are lower in the log are more recently implemented.
* psxspu: Fixed bug where SpuKeyOn does not set the key-on bits for voices 16 to 23.
* examples: Added vagsample SPU example.
-
+
+
+09-27-2021 by spicyjpeg:
+
+* liblzp, tools: Fixed tools not building on MSVC and cleaned up LZP API
+ declarations (replaced meaningless void* pointers with proper types).
+
+* libpsn00b: Added missing PSN00BSDK_VERSION CMake variable.
+
+* examples: Fixed childexec (parent.exe) example crashing due to the child
+ executable not being relocated in the new build script. Patched n00bdemo to
+ suppress liblzp pointer type warnings.
+
+* Fixed another MSVC linker error when building tinyxml2 automatically, as well
+ as various toolchain/compiler test errors sometimes thrown by CMake. Updated
+ INSTALL.md with more details.
+
+
+09-13-2021 by spicyjpeg:
+
+* Migrated libpsn00b, tools, examples and template to CMake, added a top-level
+ CMakeLists.txt and the libpsn00b/cmake directory for CMake setup scripts, got
+ rid of the old makefiles and installation method.
+
+* Updated docs to match the new build system, moved installation instructions
+ to INSTALL.md and added doc/cmake_reference.md describing the SDK's CMake
+ API and variables.
+
+* mkpsxiso: Added rules to automatically download, build and install mkpsxiso
+ (as well as its dependencies) as part of the SDK.
+
+* cpack: Added initial CPack support and created the cpack directory containing
+ branding assets for installers built through CPack. A shell script is
+ provided to regenerate the assets from their source SVGs.
+
+* liblzp: Copied library headers to libpsn00b/include/lzp.
+
+* psxetc: Fixed a random typo in a javadoc comment (those should be eventually
+ rewritten into proper documentation anyway).
+
+* Added CMake, VS Code and DLL related entries to .gitignore.
+
08-16-2021 by spicyjpeg:
diff --git a/cpack/convert_images.sh b/cpack/convert_images.sh
new file mode 100644
index 0000000..3816dec
--- /dev/null
+++ b/cpack/convert_images.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# This script generates Windows bitmaps from the SVGs in this directory. The
+# bitmaps are displayed by the NSIS installers generated using CPack. Inkscape
+# and ImageMagick must be installed for this script to work.
+
+INDEXED_SIZES=(16 24 32 48)
+RGB_ONLY_SIZES=(64 96 128 256)
+DITHER_OPTIONS="-dither riemersma"
+OUTPUT_OPTIONS="+compress -strip"
+
+svg_to_bitmap() {
+ inkscape -z -e rgb.png $1
+
+ # There seems to be no way to tell ImageMagick to generate an 8-bit indexed
+ # BMP directly, so the image has to be converted to indexed PNG first. NSIS
+ # seems to reject all BMP versions other than "bmp3".
+ convert $DITHER_OPTIONS -colors 256 +remap rgb.png png8:i8.png
+ convert i8.png $OUTPUT_OPTIONS bmp3:$2
+ rm -f rgb.png i8.png
+}
+
+# https://stackoverflow.com/a/52636645
+svg_to_icon() {
+ for size in ${INDEXED_SIZES[@]} ${RGB_ONLY_SIZES[@]}; do
+ inkscape -z -e $size.png -w $size -h $size $1
+ done
+
+ # Windows expects some of the smaller sizes to be available in 4- and 8-bit
+ # indexed color formats, as well as RGB.
+ for size in ${INDEXED_SIZES[@]}; do
+ convert $DITHER_OPTIONS -colors 256 +remap $size.png png8:$size-i8.png
+ convert $DITHER_OPTIONS -colors 16 +remap $size.png png8:$size-i4.png
+ done
+
+ icons="${INDEXED_SIZES[@]/%/.png} ${INDEXED_SIZES[@]/%/-i8.png} ${INDEXED_SIZES[@]/%/-i4.png} ${RGB_ONLY_SIZES[@]/%/.png}"
+ convert $icons $OUTPUT_OPTIONS $2
+ rm -f $icons
+}
+
+rm -f *.ico *.bmp
+
+svg_to_icon icon.svg icon.ico
+svg_to_icon uninstall.svg uninstall.ico
+svg_to_bitmap nsis_banner.svg nsis_banner.bmp
+svg_to_bitmap nsis_header.svg nsis_header.bmp
diff --git a/cpack/description.txt b/cpack/description.txt
new file mode 100644
index 0000000..240b7d1
--- /dev/null
+++ b/cpack/description.txt
@@ -0,0 +1,27 @@
+PSn00bSDK is a 100% free and open source SDK project for the original Sony
+PlayStation for developing homebrew applications and games for the console
+100% freely. This SDK can be used for freeware, commercial, and open source
+homebrew projects.
+
+The SDK is composed mainly of libraries (libpsn00b) and some utilities that
+provide a basic framework for developing software for the PlayStation
+hardware, the compiler is separate (GCC) and should be acquired from GNU.
+The library API is intentionally written to resemble the library API of the
+official libraries as closely as possible. This design decision is not only
+for familiarity reasons to experienced programmers, but also so that existing
+sample code and tutorials would still apply to this SDK, as well as making
+the process of porting over existing homebrew originally made with official
+SDKs easier with minimal modification, provided it doesn't use libgs.
+
+PSn00bSDK is currently a work in progress and cannot really be considered
+production ready, but what is currently implemented should be enough to
+produce some interesting homebrew with the SDK, especially with its extensive
+support for the GPU and GTE hardware. There's no reason not to fully support
+hardware features of a target platform when said hardware features have been
+fully documented for years (nocash's PSX specs document in this case).
+
+Most of libpsn00b is written mostly in MIPS assembly, moreso functions that
+interface with the hardware. Many of the standard C functions are implemented
+in custom MIPS assembly instead of equivalents found in the BIOS ROM, for both
+stability (the BIOS libc implementation of the PlayStation is actually buggy)
+and performance reasons.
diff --git a/cpack/fakeroot_fix.cmake b/cpack/fakeroot_fix.cmake
new file mode 100644
index 0000000..e34baa0
--- /dev/null
+++ b/cpack/fakeroot_fix.cmake
@@ -0,0 +1,32 @@
+# This script works around a bug in CPack's DEB/RPM generator, which causes
+# files installed by subprojects (not by the main CMake script) to end up in
+# packages alongside the "real" installation directory. It probably happens due
+# to CMake running under fakeroot (when invoked by CPack to prepare the files
+# to be packaged) and referencing absolute paths, which would explain why the
+# entire build directory tree is replicated inside the packages. What this
+# script does is simply finding and deleting all directories that do not match
+# the installation prefix before CPack generates the package.
+
+cmake_minimum_required(VERSION 3.21)
+
+set(_prefix ${CPACK_TEMPORARY_INSTALL_DIRECTORY}${CPACK_PACKAGING_INSTALL_PREFIX})
+
+file(
+ GLOB_RECURSE _entries
+ LIST_DIRECTORIES ON
+ ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/*
+)
+
+foreach(_entry IN LISTS _entries)
+ # Skip the entry if it (or its parent directory) has already been deleted.
+ if(NOT EXISTS ${_entry})
+ continue()
+ endif()
+
+ # Delete anything whose path doesn't start with the expected prefix.
+ string(FIND ${_entry} ${_prefix} _index)
+ if(NOT _index EQUAL 0)
+ message(NOTICE "Deleting unneeded entry from package: ${_entry}")
+ file(REMOVE_RECURSE ${_entry})
+ endif()
+endforeach()
diff --git a/cpack/icon.ico b/cpack/icon.ico
new file mode 100644
index 0000000..6759d23
--- /dev/null
+++ b/cpack/icon.ico
Binary files differ
diff --git a/cpack/icon.svg b/cpack/icon.svg
new file mode 100644
index 0000000..70d400d
--- /dev/null
+++ b/cpack/icon.svg
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ id="svg8"
+ version="1.1"
+ viewBox="0 0 512 512"
+ height="512"
+ width="512">
+ <title
+ id="title884">PSn00bSDK icon</title>
+ <defs
+ id="defs2">
+ <linearGradient
+ id="linearGradient880">
+ <stop
+ id="stop876"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1" />
+ <stop
+ style="stop-color:#100f0e;stop-opacity:1"
+ offset="0.34999999"
+ id="stop898" />
+ <stop
+ style="stop-color:#20181a;stop-opacity:1"
+ offset="0.58333331"
+ id="stop890" />
+ <stop
+ id="stop892"
+ offset="0.75"
+ style="stop-color:#301e25;stop-opacity:1" />
+ <stop
+ style="stop-color:#412030;stop-opacity:1"
+ offset="0.86666667"
+ id="stop886" />
+ <stop
+ id="stop894"
+ offset="0.91666669"
+ style="stop-color:#511e3d;stop-opacity:1" />
+ <stop
+ id="stop888"
+ offset="0.94999999"
+ style="stop-color:#60184e;stop-opacity:1" />
+ <stop
+ style="stop-color:#720d66;stop-opacity:1"
+ offset="0.98333335"
+ id="stop896" />
+ <stop
+ id="stop878"
+ offset="1"
+ style="stop-color:#800080;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ y2="16"
+ x2="496"
+ y1="496"
+ x1="16"
+ id="linearGradient882"
+ xlink:href="#linearGradient880" />
+ <filter
+ id="filter1534"
+ style="color-interpolation-filters:sRGB;">
+ <feFlood
+ id="feFlood1524"
+ result="flood"
+ flood-color="rgb(0,0,0)"
+ flood-opacity="0.701961" />
+ <feComposite
+ id="feComposite1526"
+ result="composite1"
+ operator="in"
+ in2="SourceGraphic"
+ in="flood" />
+ <feGaussianBlur
+ id="feGaussianBlur1528"
+ result="blur"
+ stdDeviation="0.5"
+ in="composite1" />
+ <feOffset
+ id="feOffset1530"
+ result="offset"
+ dy="3.5"
+ dx="4" />
+ <feComposite
+ id="feComposite1532"
+ result="composite2"
+ operator="over"
+ in2="offset"
+ in="SourceGraphic" />
+ </filter>
+ </defs>
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>PSn00bSDK icon</dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1">
+ <rect
+ ry="64"
+ rx="64"
+ y="0"
+ x="0"
+ height="512"
+ width="512"
+ id="rect860"
+ style="opacity:0.998;fill:url(#linearGradient882);fill-opacity:1;stroke-width:2" />
+ <g
+ style="fill:#ffffff;fill-opacity:1;filter:url(#filter1534)"
+ id="layer1-5"
+ transform="matrix(3.779521,0,0,3.779521,16.000484,-786.51733)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 57.179711,259.17821 v 17.18692 h 5.773631 c -0.396902,-2.52219 -1.516281,-11.47627 2.677532,-11.43765 4.154274,0.0381 2.825972,8.818 2.338686,11.43765 h 5.726019 c 0,-2.5475 0.612565,-10.89684 -1.883577,-14.15061 -2.122953,-2.76729 -7.048341,-2.41673 -9.502018,-1.00656 v -2.02975 z"
+ id="path5596" />
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 82.828855,255.71895 c -10.353164,0.25013 -10.721078,21.06797 0.714234,20.66283 10.000569,-0.35432 8.896917,-20.89502 -0.714234,-20.66283 z m -1.383056,5.71268 c -1.165387,3.71776 1.988956,7.56732 5.10259,5.73157 0,0 -0.09008,3.35969 -2.71075,4.0174 -5.560412,1.39549 -6.092866,-7.18149 -2.39184,-9.74897 z"
+ id="path5600" />
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 114.82523,255.43876 -6.43139,1.1339 0.7563,19.49459 4.79365,0.0898 0.0665,-1.56688 c 0,0 0.84813,1.16403 3.59108,1.45064 9.30033,0.97173 8.87091,-14.3259 1.34541,-14.73418 -2.83582,-0.15386 -4.43043,1.4041 -4.43043,1.4041 z m 2.46382,10.23949 c 3.64531,-0.38951 4.6306,5.87108 0.65,6.49892 -3.75349,0.59205 -4.99839,-6.03428 -0.65,-6.49892 z"
+ id="path5612" />
+ <g
+ aria-label="SDK"
+ transform="matrix(0.56695433,0,0,0.56695433,-141.8248,-64.336976)"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:42.6667px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none"
+ id="flowRoot5618">
+ <path
+ d="m 351.00651,635.98438 v -8.70834 h 20.60417 v -3.45833 h -11 q -5.72917,0 -7.5625,-1.27083 -1.83334,-1.27084 -1.83334,-4.52084 v -7.64583 q 0,-3.33333 2.16667,-4.79167 2.1875,-1.47916 7.22917,-1.47916 h 18.72916 v 8.625 h -18.39583 v 3.54166 h 13.22917 q 3.66666,0 5.39583,1.5 1.72917,1.5 1.72917,4.6875 v 7.8125 q 0,2.66667 -1.85417,4.1875 -1.85417,1.52084 -5.14583,1.52084 z"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ id="path24" />
+ <path
+ d="m 394.81901,627.27604 h 11.35417 v -14.54166 h -11.35417 z m -9.9375,8.70834 v -31.875 h 23.6875 q 3.6875,0 5.77083,2.27083 2.08334,2.25 2.08334,6.3125 v 14.5 q 0,4.33333 -2.04167,6.5625 -2.04167,2.22917 -6.02083,2.22917 z"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ id="path26" />
+ <path
+ d="m 420.13152,635.98438 v -31.875 h 9.77083 v 12.20833 h 2.3125 l 9,-12.20833 h 11.72917 l -12.10417,15.66666 12.79167,16.20834 h -12.375 l -9.04167,-12.16667 h -2.3125 v 12.16667 z"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ id="path28" />
+ </g>
+ <path
+ id="path908"
+ d="m 99.804384,255.71668 c -10.133001,-0.0773 -10.593527,20.63351 0.262436,20.66506 10.26945,0.0298 9.09211,-20.59369 -0.262436,-20.66506 z m 0.556956,15.46392 c -0.008,9.6e-4 -0.0138,0.002 -0.021,0.004 2.35422,-2.63067 -1.289504,-8.16996 -4.519013,-6.33394 0,0 1.131029,-4.35205 4.012975,-4.09159 4.446218,0.40182 4.327948,9.1393 0.527048,10.42125 z"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path914"
+ d="m 26.876314,267.84943 c -0.07198,3.84917 -0.663735,8.22997 -3.673281,10.94853 -2.089478,1.66049 -4.851082,0.94991 -7.306542,1.10553 H 11.04198 v -3.42363 c 2.156559,-0.0653 4.33832,0.13885 6.477279,-0.11786 2.536377,-0.98515 3.091955,-4.09776 3.4593,-6.48869 0.300636,-3.36989 0.07856,-7.12599 -2.014955,-9.92767 -1.357242,-1.62658 -3.597582,-0.93352 -5.431053,-1.08326 H 8.6169014 v 37.37473 H 2.4115531 v -40.79837 c 5.9979405,0.0129 11.9968419,-0.0238 17.9941699,0.0171 3.625596,0.34104 5.274335,4.24515 5.941221,7.34963 0.369793,1.65348 0.52937,3.01218 0.52937,5.04391 z m 26.781736,16.11965 c -0.08017,3.9379 -0.873268,8.36119 -3.922921,11.12682 -2.089008,1.69992 -4.872113,0.98781 -7.342206,1.14121 H 31.547042 v -3.42363 c 4.070829,-0.0292 8.14743,0.0592 12.21455,-0.0456 2.781143,-0.57546 3.669767,-3.80823 4.021548,-6.25301 0.166648,-2.54728 0.292442,-5.57249 -1.565266,-7.57307 -2.159164,-1.74308 -5.042366,-1.02412 -7.593577,-1.17799 -2.19456,0.14293 -4.637761,-0.23372 -5.967246,-2.20664 -3.132732,-4.47482 -3.210319,-10.62153 -1.220061,-15.57718 0.94516,-2.55433 3.288885,-4.87136 6.197494,-4.54117 h 12.956554 v 3.42364 c -3.583967,0.0246 -7.172385,-0.0503 -10.753483,0.039 -2.74647,0.48591 -3.651617,3.67317 -3.835713,6.07941 -0.145669,2.69978 0.298311,6.06194 2.828236,7.58171 1.744887,0.64676 3.664647,0.23375 5.491578,0.35107 3.519412,0 4.7894,-0.0107 6.359655,1.56024 2.176061,2.17605 2.976739,6.12884 2.976739,9.49523 z"
+ style="font-style:normal;font-weight:normal;font-size:33.286px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.742977" />
+ </g>
+ </g>
+</svg>
diff --git a/cpack/nsis_banner.bmp b/cpack/nsis_banner.bmp
new file mode 100644
index 0000000..831c8f9
--- /dev/null
+++ b/cpack/nsis_banner.bmp
Binary files differ
diff --git a/cpack/nsis_banner.svg b/cpack/nsis_banner.svg
new file mode 100644
index 0000000..499bb94
--- /dev/null
+++ b/cpack/nsis_banner.svg
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ width="164"
+ height="314"
+ viewBox="0 0 164 314"
+ version="1.1"
+ id="svg8">
+ <title
+ id="title884">PSn00bSDK installer banner</title>
+ <defs
+ id="defs2">
+ <linearGradient
+ id="linearGradient880">
+ <stop
+ style="stop-color:#000000;stop-opacity:1"
+ offset="0"
+ id="stop876" />
+ <stop
+ id="stop898"
+ offset="0.34999999"
+ style="stop-color:#100f0e;stop-opacity:1" />
+ <stop
+ id="stop890"
+ offset="0.58333331"
+ style="stop-color:#20181a;stop-opacity:1" />
+ <stop
+ style="stop-color:#301e25;stop-opacity:1"
+ offset="0.75"
+ id="stop892" />
+ <stop
+ id="stop886"
+ offset="0.86666667"
+ style="stop-color:#412030;stop-opacity:1" />
+ <stop
+ style="stop-color:#511e3d;stop-opacity:1"
+ offset="0.91666669"
+ id="stop894" />
+ <stop
+ style="stop-color:#60184e;stop-opacity:1"
+ offset="0.94999999"
+ id="stop888" />
+ <stop
+ id="stop896"
+ offset="0.98333335"
+ style="stop-color:#720d66;stop-opacity:1" />
+ <stop
+ style="stop-color:#800080;stop-opacity:1"
+ offset="1"
+ id="stop878" />
+ </linearGradient>
+ <linearGradient
+ xlink:href="#linearGradient880"
+ id="linearGradient882"
+ x1="0"
+ y1="314"
+ x2="164"
+ y2="0"
+ gradientUnits="userSpaceOnUse" />
+ <filter
+ style="color-interpolation-filters:sRGB"
+ id="filter1534">
+ <feFlood
+ flood-opacity="0.701961"
+ flood-color="rgb(0,0,0)"
+ result="flood"
+ id="feFlood1524" />
+ <feComposite
+ in="flood"
+ in2="SourceGraphic"
+ operator="in"
+ result="composite1"
+ id="feComposite1526" />
+ <feGaussianBlur
+ in="composite1"
+ stdDeviation="0.5"
+ result="blur"
+ id="feGaussianBlur1528" />
+ <feOffset
+ dx="4"
+ dy="3.5"
+ result="offset"
+ id="feOffset1530" />
+ <feComposite
+ in="SourceGraphic"
+ in2="offset"
+ operator="over"
+ result="composite2"
+ id="feComposite1532" />
+ </filter>
+ </defs>
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>PSn00bSDK installer banner</dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1">
+ <rect
+ style="opacity:0.998;fill:url(#linearGradient882);fill-opacity:1;stroke-width:2"
+ id="rect860"
+ width="164"
+ height="314"
+ x="0"
+ y="0" />
+ <g
+ transform="matrix(0,-1.9077179,1.9077179,0,-416.37176,307.29252)"
+ id="layer1-5"
+ style="fill:#ffffff;fill-opacity:1;filter:url(#filter1534)">
+ <path
+ id="path5596"
+ d="m 57.179711,259.17821 v 17.18692 h 5.773631 c -0.396902,-2.52219 -1.516281,-11.47627 2.677532,-11.43765 4.154274,0.0381 2.825972,8.818 2.338686,11.43765 h 5.726019 c 0,-2.5475 0.612565,-10.89684 -1.883577,-14.15061 -2.122953,-2.76729 -7.048341,-2.41673 -9.502018,-1.00656 v -2.02975 z"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path5600"
+ d="m 82.828855,255.71895 c -10.353164,0.25013 -10.721078,21.06797 0.714234,20.66283 10.000569,-0.35432 8.896917,-20.89502 -0.714234,-20.66283 z m -1.383056,5.71268 c -1.165387,3.71776 1.988956,7.56732 5.10259,5.73157 0,0 -0.09008,3.35969 -2.71075,4.0174 -5.560412,1.39549 -6.092866,-7.18149 -2.39184,-9.74897 z"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path5612"
+ d="m 114.82523,255.43876 -6.43139,1.1339 0.7563,19.49459 4.79365,0.0898 0.0665,-1.56688 c 0,0 0.84813,1.16403 3.59108,1.45064 9.30033,0.97173 8.87091,-14.3259 1.34541,-14.73418 -2.83582,-0.15386 -4.43043,1.4041 -4.43043,1.4041 z m 2.46382,10.23949 c 3.64531,-0.38951 4.6306,5.87108 0.65,6.49892 -3.75349,0.59205 -4.99839,-6.03428 -0.65,-6.49892 z"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <g
+ id="flowRoot5618"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:42.6667px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none"
+ transform="matrix(0.56695433,0,0,0.56695433,-141.8248,-64.336976)"
+ aria-label="SDK">
+ <path
+ id="path24"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ d="m 351.00651,635.98438 v -8.70834 h 20.60417 v -3.45833 h -11 q -5.72917,0 -7.5625,-1.27083 -1.83334,-1.27084 -1.83334,-4.52084 v -7.64583 q 0,-3.33333 2.16667,-4.79167 2.1875,-1.47916 7.22917,-1.47916 h 18.72916 v 8.625 h -18.39583 v 3.54166 h 13.22917 q 3.66666,0 5.39583,1.5 1.72917,1.5 1.72917,4.6875 v 7.8125 q 0,2.66667 -1.85417,4.1875 -1.85417,1.52084 -5.14583,1.52084 z" />
+ <path
+ id="path26"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ d="m 394.81901,627.27604 h 11.35417 v -14.54166 h -11.35417 z m -9.9375,8.70834 v -31.875 h 23.6875 q 3.6875,0 5.77083,2.27083 2.08334,2.25 2.08334,6.3125 v 14.5 q 0,4.33333 -2.04167,6.5625 -2.04167,2.22917 -6.02083,2.22917 z" />
+ <path
+ id="path28"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ d="m 420.13152,635.98438 v -31.875 h 9.77083 v 12.20833 h 2.3125 l 9,-12.20833 h 11.72917 l -12.10417,15.66666 12.79167,16.20834 h -12.375 l -9.04167,-12.16667 h -2.3125 v 12.16667 z" />
+ </g>
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 99.804384,255.71668 c -10.133001,-0.0773 -10.593527,20.63351 0.262436,20.66506 10.26945,0.0298 9.09211,-20.59369 -0.262436,-20.66506 z m 0.556956,15.46392 c -0.008,9.6e-4 -0.0138,0.002 -0.021,0.004 2.35422,-2.63067 -1.289504,-8.16996 -4.519013,-6.33394 0,0 1.131029,-4.35205 4.012975,-4.09159 4.446218,0.40182 4.327948,9.1393 0.527048,10.42125 z"
+ id="path908" />
+ <path
+ style="font-style:normal;font-weight:normal;font-size:33.286px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.742977"
+ d="m 26.876314,267.84943 c -0.07198,3.84917 -0.663735,8.22997 -3.673281,10.94853 -2.089478,1.66049 -4.851082,0.94991 -7.306542,1.10553 H 11.04198 v -3.42363 c 2.156559,-0.0653 4.33832,0.13885 6.477279,-0.11786 2.536377,-0.98515 3.091955,-4.09776 3.4593,-6.48869 0.300636,-3.36989 0.07856,-7.12599 -2.014955,-9.92767 -1.357242,-1.62658 -3.597582,-0.93352 -5.431053,-1.08326 H 8.6169014 v 37.37473 H 2.4115531 v -40.79837 c 5.9979405,0.0129 11.9968419,-0.0238 17.9941699,0.0171 3.625596,0.34104 5.274335,4.24515 5.941221,7.34963 0.369793,1.65348 0.52937,3.01218 0.52937,5.04391 z m 26.781736,16.11965 c -0.08017,3.9379 -0.873268,8.36119 -3.922921,11.12682 -2.089008,1.69992 -4.872113,0.98781 -7.342206,1.14121 H 31.547042 v -3.42363 c 4.070829,-0.0292 8.14743,0.0592 12.21455,-0.0456 2.781143,-0.57546 3.669767,-3.80823 4.021548,-6.25301 0.166648,-2.54728 0.292442,-5.57249 -1.565266,-7.57307 -2.159164,-1.74308 -5.042366,-1.02412 -7.593577,-1.17799 -2.19456,0.14293 -4.637761,-0.23372 -5.967246,-2.20664 -3.132732,-4.47482 -3.210319,-10.62153 -1.220061,-15.57718 0.94516,-2.55433 3.288885,-4.87136 6.197494,-4.54117 h 12.956554 v 3.42364 c -3.583967,0.0246 -7.172385,-0.0503 -10.753483,0.039 -2.74647,0.48591 -3.651617,3.67317 -3.835713,6.07941 -0.145669,2.69978 0.298311,6.06194 2.828236,7.58171 1.744887,0.64676 3.664647,0.23375 5.491578,0.35107 3.519412,0 4.7894,-0.0107 6.359655,1.56024 2.176061,2.17605 2.976739,6.12884 2.976739,9.49523 z"
+ id="path914" />
+ </g>
+ </g>
+</svg>
diff --git a/cpack/nsis_header.bmp b/cpack/nsis_header.bmp
new file mode 100644
index 0000000..d677e8c
--- /dev/null
+++ b/cpack/nsis_header.bmp
Binary files differ
diff --git a/cpack/nsis_header.svg b/cpack/nsis_header.svg
new file mode 100644
index 0000000..19ae01a
--- /dev/null
+++ b/cpack/nsis_header.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ id="svg4999"
+ version="1.1"
+ viewBox="0 0 150 57"
+ height="57"
+ width="150">
+ <title
+ id="title4511">PSn00bSDK installer header</title>
+ <defs
+ id="defs4993" />
+ <rect
+ y="0"
+ x="0"
+ height="57"
+ width="150"
+ id="rect844"
+ style="opacity:0.998;fill:#ffffff;stroke-width:2;fill-opacity:1" />
+ <g
+ transform="translate(0,-254.66652)"
+ id="layer1">
+ <path
+ id="path5596"
+ d="m 68.679157,266.51141 v 17.18692 h 5.773631 c -0.396902,-2.52219 -1.516281,-11.47627 2.677532,-11.43765 4.154274,0.0381 2.825972,8.818 2.338686,11.43765 h 5.726019 c 0,-2.5475 0.612565,-10.89684 -1.883577,-14.15061 -2.122953,-2.76729 -7.048341,-2.41673 -9.502018,-1.00656 v -2.02975 z"
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path5600"
+ d="m 94.328301,263.05215 c -10.353164,0.25013 -10.721078,21.06797 0.714234,20.66283 10.000575,-0.35432 8.896925,-20.89502 -0.714234,-20.66283 z m -1.383056,5.71268 c -1.165387,3.71776 1.988956,7.56732 5.10259,5.73157 0,0 -0.09008,3.35969 -2.71075,4.0174 -5.560412,1.39549 -6.092866,-7.18149 -2.39184,-9.74897 z"
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path5612"
+ d="m 126.32468,262.77196 -6.43139,1.1339 0.7563,19.49459 4.79365,0.0898 0.0665,-1.56688 c 0,0 0.84813,1.16403 3.59108,1.45064 9.30033,0.97173 8.87091,-14.3259 1.34541,-14.73418 -2.83582,-0.15386 -4.43043,1.4041 -4.43043,1.4041 z m 2.46382,10.23949 c 3.64531,-0.38951 4.6306,5.87108 0.65,6.49892 -3.75349,0.59205 -4.99839,-6.03428 -0.65,-6.49892 z"
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <g
+ id="flowRoot5618"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:42.6667px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
+ transform="matrix(0.56695433,0,0,0.56695433,-130.32535,-57.003778)"
+ aria-label="SDK">
+ <path
+ id="path24"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold'"
+ d="m 351.00651,635.98438 v -8.70834 h 20.60417 v -3.45833 h -11 q -5.72917,0 -7.5625,-1.27083 -1.83334,-1.27084 -1.83334,-4.52084 v -7.64583 q 0,-3.33333 2.16667,-4.79167 2.1875,-1.47916 7.22917,-1.47916 h 18.72916 v 8.625 h -18.39583 v 3.54166 h 13.22917 q 3.66666,0 5.39583,1.5 1.72917,1.5 1.72917,4.6875 v 7.8125 q 0,2.66667 -1.85417,4.1875 -1.85417,1.52084 -5.14583,1.52084 z" />
+ <path
+ id="path26"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold'"
+ d="m 394.81901,627.27604 h 11.35417 v -14.54166 h -11.35417 z m -9.9375,8.70834 v -31.875 h 23.6875 q 3.6875,0 5.77083,2.27083 2.08334,2.25 2.08334,6.3125 v 14.5 q 0,4.33333 -2.04167,6.5625 -2.04167,2.22917 -6.02083,2.22917 z" />
+ <path
+ id="path28"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold'"
+ d="m 420.13152,635.98438 v -31.875 h 9.77083 v 12.20833 h 2.3125 l 9,-12.20833 h 11.72917 l -12.10417,15.66666 12.79167,16.20834 h -12.375 l -9.04167,-12.16667 h -2.3125 v 12.16667 z" />
+ </g>
+ <path
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 111.30383,263.04988 c -10.133,-0.0773 -10.59352,20.63351 0.26244,20.66506 10.26945,0.0298 9.09211,-20.59369 -0.26244,-20.66506 z m 0.55696,15.46392 c -0.008,9.6e-4 -0.0138,0.002 -0.021,0.004 2.35422,-2.63067 -1.2895,-8.16996 -4.51901,-6.33394 0,0 1.13103,-4.35205 4.01297,-4.09159 4.44622,0.40182 4.32795,9.1393 0.52705,10.42125 z"
+ id="path908" />
+ <path
+ style="font-style:normal;font-weight:normal;font-size:33.286px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.742977"
+ d="m 38.37576,275.18263 c -0.07198,3.84917 -0.663735,8.22997 -3.673281,10.94853 -2.089478,1.66049 -4.851082,0.94991 -7.306542,1.10553 h -4.854511 v -3.42363 c 2.156559,-0.0653 4.33832,0.13885 6.477279,-0.11786 2.536377,-0.98515 3.091955,-4.09776 3.4593,-6.48869 0.300636,-3.36989 0.07856,-7.12599 -2.014955,-9.92767 -1.357242,-1.62658 -3.597582,-0.93352 -5.431053,-1.08326 h -4.915649 v 37.37473 H 13.911 v -40.79837 c 5.99794,0.0129 11.996841,-0.0238 17.994169,0.0171 3.625596,0.34104 5.274335,4.24515 5.941221,7.34963 0.369793,1.65348 0.52937,3.01218 0.52937,5.04391 z m 26.781736,16.11965 c -0.08017,3.9379 -0.873268,8.36119 -3.922921,11.12682 -2.089008,1.69992 -4.872113,0.98781 -7.342206,1.14121 H 43.046488 v -3.42363 c 4.070829,-0.0292 8.14743,0.0592 12.21455,-0.0456 2.781143,-0.57546 3.669767,-3.80823 4.021548,-6.25301 0.166648,-2.54728 0.292442,-5.57249 -1.565266,-7.57307 -2.159164,-1.74308 -5.042366,-1.02412 -7.593577,-1.17799 -2.19456,0.14293 -4.637761,-0.23372 -5.967246,-2.20664 -3.132732,-4.47482 -3.210319,-10.62153 -1.220061,-15.57718 0.94516,-2.55433 3.288885,-4.87136 6.197494,-4.54117 h 12.956554 v 3.42364 c -3.583967,0.0246 -7.172385,-0.0503 -10.753483,0.039 -2.74647,0.48591 -3.651617,3.67317 -3.835713,6.07941 -0.145669,2.69978 0.298311,6.06194 2.828236,7.58171 1.744887,0.64676 3.664647,0.23375 5.491578,0.35107 3.519412,0 4.7894,-0.0107 6.359655,1.56024 2.176061,2.17605 2.976739,6.12884 2.976739,9.49523 z"
+ id="path914" />
+ </g>
+</svg>
diff --git a/cpack/uninstall.ico b/cpack/uninstall.ico
new file mode 100644
index 0000000..6759d23
--- /dev/null
+++ b/cpack/uninstall.ico
Binary files differ
diff --git a/cpack/uninstall.svg b/cpack/uninstall.svg
new file mode 100644
index 0000000..70d400d
--- /dev/null
+++ b/cpack/uninstall.svg
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ id="svg8"
+ version="1.1"
+ viewBox="0 0 512 512"
+ height="512"
+ width="512">
+ <title
+ id="title884">PSn00bSDK icon</title>
+ <defs
+ id="defs2">
+ <linearGradient
+ id="linearGradient880">
+ <stop
+ id="stop876"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1" />
+ <stop
+ style="stop-color:#100f0e;stop-opacity:1"
+ offset="0.34999999"
+ id="stop898" />
+ <stop
+ style="stop-color:#20181a;stop-opacity:1"
+ offset="0.58333331"
+ id="stop890" />
+ <stop
+ id="stop892"
+ offset="0.75"
+ style="stop-color:#301e25;stop-opacity:1" />
+ <stop
+ style="stop-color:#412030;stop-opacity:1"
+ offset="0.86666667"
+ id="stop886" />
+ <stop
+ id="stop894"
+ offset="0.91666669"
+ style="stop-color:#511e3d;stop-opacity:1" />
+ <stop
+ id="stop888"
+ offset="0.94999999"
+ style="stop-color:#60184e;stop-opacity:1" />
+ <stop
+ style="stop-color:#720d66;stop-opacity:1"
+ offset="0.98333335"
+ id="stop896" />
+ <stop
+ id="stop878"
+ offset="1"
+ style="stop-color:#800080;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ y2="16"
+ x2="496"
+ y1="496"
+ x1="16"
+ id="linearGradient882"
+ xlink:href="#linearGradient880" />
+ <filter
+ id="filter1534"
+ style="color-interpolation-filters:sRGB;">
+ <feFlood
+ id="feFlood1524"
+ result="flood"
+ flood-color="rgb(0,0,0)"
+ flood-opacity="0.701961" />
+ <feComposite
+ id="feComposite1526"
+ result="composite1"
+ operator="in"
+ in2="SourceGraphic"
+ in="flood" />
+ <feGaussianBlur
+ id="feGaussianBlur1528"
+ result="blur"
+ stdDeviation="0.5"
+ in="composite1" />
+ <feOffset
+ id="feOffset1530"
+ result="offset"
+ dy="3.5"
+ dx="4" />
+ <feComposite
+ id="feComposite1532"
+ result="composite2"
+ operator="over"
+ in2="offset"
+ in="SourceGraphic" />
+ </filter>
+ </defs>
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>PSn00bSDK icon</dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1">
+ <rect
+ ry="64"
+ rx="64"
+ y="0"
+ x="0"
+ height="512"
+ width="512"
+ id="rect860"
+ style="opacity:0.998;fill:url(#linearGradient882);fill-opacity:1;stroke-width:2" />
+ <g
+ style="fill:#ffffff;fill-opacity:1;filter:url(#filter1534)"
+ id="layer1-5"
+ transform="matrix(3.779521,0,0,3.779521,16.000484,-786.51733)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 57.179711,259.17821 v 17.18692 h 5.773631 c -0.396902,-2.52219 -1.516281,-11.47627 2.677532,-11.43765 4.154274,0.0381 2.825972,8.818 2.338686,11.43765 h 5.726019 c 0,-2.5475 0.612565,-10.89684 -1.883577,-14.15061 -2.122953,-2.76729 -7.048341,-2.41673 -9.502018,-1.00656 v -2.02975 z"
+ id="path5596" />
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 82.828855,255.71895 c -10.353164,0.25013 -10.721078,21.06797 0.714234,20.66283 10.000569,-0.35432 8.896917,-20.89502 -0.714234,-20.66283 z m -1.383056,5.71268 c -1.165387,3.71776 1.988956,7.56732 5.10259,5.73157 0,0 -0.09008,3.35969 -2.71075,4.0174 -5.560412,1.39549 -6.092866,-7.18149 -2.39184,-9.74897 z"
+ id="path5600" />
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 114.82523,255.43876 -6.43139,1.1339 0.7563,19.49459 4.79365,0.0898 0.0665,-1.56688 c 0,0 0.84813,1.16403 3.59108,1.45064 9.30033,0.97173 8.87091,-14.3259 1.34541,-14.73418 -2.83582,-0.15386 -4.43043,1.4041 -4.43043,1.4041 z m 2.46382,10.23949 c 3.64531,-0.38951 4.6306,5.87108 0.65,6.49892 -3.75349,0.59205 -4.99839,-6.03428 -0.65,-6.49892 z"
+ id="path5612" />
+ <g
+ aria-label="SDK"
+ transform="matrix(0.56695433,0,0,0.56695433,-141.8248,-64.336976)"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:42.6667px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none"
+ id="flowRoot5618">
+ <path
+ d="m 351.00651,635.98438 v -8.70834 h 20.60417 v -3.45833 h -11 q -5.72917,0 -7.5625,-1.27083 -1.83334,-1.27084 -1.83334,-4.52084 v -7.64583 q 0,-3.33333 2.16667,-4.79167 2.1875,-1.47916 7.22917,-1.47916 h 18.72916 v 8.625 h -18.39583 v 3.54166 h 13.22917 q 3.66666,0 5.39583,1.5 1.72917,1.5 1.72917,4.6875 v 7.8125 q 0,2.66667 -1.85417,4.1875 -1.85417,1.52084 -5.14583,1.52084 z"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ id="path24" />
+ <path
+ d="m 394.81901,627.27604 h 11.35417 v -14.54166 h -11.35417 z m -9.9375,8.70834 v -31.875 h 23.6875 q 3.6875,0 5.77083,2.27083 2.08334,2.25 2.08334,6.3125 v 14.5 q 0,4.33333 -2.04167,6.5625 -2.04167,2.22917 -6.02083,2.22917 z"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ id="path26" />
+ <path
+ d="m 420.13152,635.98438 v -31.875 h 9.77083 v 12.20833 h 2.3125 l 9,-12.20833 h 11.72917 l -12.10417,15.66666 12.79167,16.20834 h -12.375 l -9.04167,-12.16667 h -2.3125 v 12.16667 z"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Bolt Bd BT';-inkscape-font-specification:'Bolt Bd BT Bold';fill:#ffffff;fill-opacity:1"
+ id="path28" />
+ </g>
+ <path
+ id="path908"
+ d="m 99.804384,255.71668 c -10.133001,-0.0773 -10.593527,20.63351 0.262436,20.66506 10.26945,0.0298 9.09211,-20.59369 -0.262436,-20.66506 z m 0.556956,15.46392 c -0.008,9.6e-4 -0.0138,0.002 -0.021,0.004 2.35422,-2.63067 -1.289504,-8.16996 -4.519013,-6.33394 0,0 1.131029,-4.35205 4.012975,-4.09159 4.446218,0.40182 4.327948,9.1393 0.527048,10.42125 z"
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.973493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path914"
+ d="m 26.876314,267.84943 c -0.07198,3.84917 -0.663735,8.22997 -3.673281,10.94853 -2.089478,1.66049 -4.851082,0.94991 -7.306542,1.10553 H 11.04198 v -3.42363 c 2.156559,-0.0653 4.33832,0.13885 6.477279,-0.11786 2.536377,-0.98515 3.091955,-4.09776 3.4593,-6.48869 0.300636,-3.36989 0.07856,-7.12599 -2.014955,-9.92767 -1.357242,-1.62658 -3.597582,-0.93352 -5.431053,-1.08326 H 8.6169014 v 37.37473 H 2.4115531 v -40.79837 c 5.9979405,0.0129 11.9968419,-0.0238 17.9941699,0.0171 3.625596,0.34104 5.274335,4.24515 5.941221,7.34963 0.369793,1.65348 0.52937,3.01218 0.52937,5.04391 z m 26.781736,16.11965 c -0.08017,3.9379 -0.873268,8.36119 -3.922921,11.12682 -2.089008,1.69992 -4.872113,0.98781 -7.342206,1.14121 H 31.547042 v -3.42363 c 4.070829,-0.0292 8.14743,0.0592 12.21455,-0.0456 2.781143,-0.57546 3.669767,-3.80823 4.021548,-6.25301 0.166648,-2.54728 0.292442,-5.57249 -1.565266,-7.57307 -2.159164,-1.74308 -5.042366,-1.02412 -7.593577,-1.17799 -2.19456,0.14293 -4.637761,-0.23372 -5.967246,-2.20664 -3.132732,-4.47482 -3.210319,-10.62153 -1.220061,-15.57718 0.94516,-2.55433 3.288885,-4.87136 6.197494,-4.54117 h 12.956554 v 3.42364 c -3.583967,0.0246 -7.172385,-0.0503 -10.753483,0.039 -2.74647,0.48591 -3.651617,3.67317 -3.835713,6.07941 -0.145669,2.69978 0.298311,6.06194 2.828236,7.58171 1.744887,0.64676 3.664647,0.23375 5.491578,0.35107 3.519412,0 4.7894,-0.0107 6.359655,1.56024 2.176061,2.17605 2.976739,6.12884 2.976739,9.49523 z"
+ style="font-style:normal;font-weight:normal;font-size:33.286px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.742977" />
+ </g>
+ </g>
+</svg>
diff --git a/cpack/welcome.txt b/cpack/welcome.txt
new file mode 100644
index 0000000..e024336
--- /dev/null
+++ b/cpack/welcome.txt
@@ -0,0 +1,3 @@
+This installer will set up PSn00bSDK, including prebuilt libraries, CMake scripts as well as several command-line utilities for PlayStation 1 homebrew development.
+
+NOTE: CMake and the GCC toolchain must be installed separately.
diff --git a/doc/cmake_reference.md b/doc/cmake_reference.md
new file mode 100644
index 0000000..3b586ab
--- /dev/null
+++ b/doc/cmake_reference.md
@@ -0,0 +1,207 @@
+
+# PSn00bSDK CMake reference
+
+## Setup
+
+The only requirement to use the SDK in CMake is to set the
+`CMAKE_TOOLCHAIN_FILE` variable to `INSTALL_PATH/lib/libpsn00b/cmake/sdk.cmake`
+(where `INSTALL_PATH` is the install prefix PSn00bSDK is installed to). This
+can be done on the command line (`-DCMAKE_TOOLCHAIN_FILE=...`), in
+`CMakeLists.txt` (before calling `project()`) or using a
+[preset](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html).
+
+It's recommended to put this snippet in `CMakeLists.txt` to automatically set
+the toolchain file according to the `PSN00BSDK_LIBS` environment variable:
+
+```cmake
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+```
+
+See the [template](../template/CMakeLists.txt) for an example CMake script
+showing how to build a simple project.
+
+## Targets
+
+These targets are defined when using PSn00bSDK. There is no need to explicitly
+link against any of these, as the helper commands (see below) handle linking
+behind the scenes. To avoid conflicts, however, no target should be given any
+of these names.
+
+- `c`, `psxgpu`, `psxgte`, `psxspu`, `psxcd`, `psxsio`, `psxetc`, `psxapi`, `lzp`
+- `psn00bsdk_common`, `psn00bsdk_object_lib`
+- `psn00bsdk_static_exe`
+- `psn00bsdk_dynamic_exe`
+- `psn00bsdk_static_lib`
+- `psn00bsdk_shared_lib`, `psn00bsdk_module_lib`
+
+## Commands
+
+- `psn00bsdk_add_executable(<name> <STATIC|DYNAMIC> [EXCLUDE_FROM_ALL] [sources...])`
+
+ A wrapper around `add_executable()` to create PS1 executables. Three files
+ will be generated for each call to this function:
+
+ - `<name>.elf` (regular ELF executable)
+ - `<name>.exe` (executable converted to the format expected by the PS1)
+ - `<name>.map` (symbol map file for dynamic linking/introspection)
+
+ The `.exe` and `.map` extensions can be customized by overriding
+ `PSN00BSDK_EXECUTABLE_SUFFIX` and `PSN00BSDK_SYMBOL_MAP_SUFFIX` prior to
+ creating the executable.
+
+ The second argument (mandatory) specifies whether the executable is going to
+ load DLLs at runtime. If set to `STATIC`, $gp-relative addressing (i.e.
+ reusing the $gp register normally used for DLL addressing) will be enabled,
+ slightly reducing executable size and RAM usage but breaking compatibility
+ with the dynamic linker.
+
+- `psn00bsdk_add_library(<name> <STATIC|OBJECT|SHARED|MODULE> [EXCLUDE_FROM_ALL] [sources...])`
+
+ Wraps `add_library()` to create static libraries or dynamically-linked
+ libraries (DLLs).
+
+ The second argument (mandatory, unlike `add_library()`) specifies the type of
+ library to create. `STATIC` will create a static library named `lib<name>.a`.
+ `SHARED` and `MODULE` will compile a DLL, producing the following files (note
+ that there is no `lib` prefix for DLLs):
+
+ - `<name>.so` (regular ELF shared library)
+ - `<name>.dll` (raw binary with some ELF headers prepended)
+
+ As with executables, the `.dll` extension can be customized by setting
+ `PSN00BSDK_SHARED_LIBRARY_SUFFIX`.
+
+- `psn00bsdk_add_cd_image(<name> <image name> <config file> [...])`
+
+ Creates a new target that will build a CD image using `mkpsxiso`.
+
+ The first argument is the name of the target to create; next up is the name
+ of the generated image file (`<image name>.bin` + `<image name>.cue`). The
+ third argument is the path to the XML file passed to `mkpsxiso`.
+
+ The XML file is "configured" by CMake, i.e. any `${var}` or `@var@`
+ expressions are replaced with the values of the respective variables. In
+ particular `${CD_IMAGE_NAME}` is replaced with the second argument passed to
+ `psn00bsdk_add_cd_image()`; the file must properly set the output file names
+ like this:
+
+ ```xml
+ <?xml version="1.0" encoding="utf-8"?>
+ <iso_project
+ image_name="${CD_IMAGE_NAME}.bin"
+ cue_sheet="${CD_IMAGE_NAME}.cue"
+ >
+ ```
+
+ Any additional argument is passed through to the underlying call to
+ `add_custom_target()`, so most of the options supported by
+ `add_custom_target()` are also supported here.
+
+## Definitions
+
+When compiling executables and libraries using the above commands the following
+preprocessor macros are automatically `#define`'d:
+
+- `PLAYSTATION`
+
+ Always set to 1. Can be used to implement different options or code paths for
+ libraries, so they can target both the host and PS1 (as it won't be defined
+ when compiling outside of the SDK).
+
+- `DEBUG`
+
+ Defined and set to 1 in a debug configuration, i.e. when the
+ `CMAKE_BUILD_TYPE` variable is set to `Debug`. This value is used by the
+ PSn00bSDK libraries, and should be used in executables, to enable additional
+ debug logging.
+
+ Note that the default CMake configuration is usually debug, so it's
+ recommended to specify `-DCMAKE_BUILD_TYPE=Release` to get rid of the logging
+ overhead in release builds and reduce executable size.
+
+## Cached settings
+
+These variables are stored in CMake's cache and can be edited by the project's
+build script, from the CMake command line when configuring the project
+(`-Dname=value`) or using an editor such as the CMake GUI.
+
+- `PSN00BSDK_TARGET` (`STRING`)
+
+ The GCC toolchain's target triplet. PSn00bSDK assumes the toolchain targets
+ `mipsel-unknown-elf` by default, however this can be changed to e.g. use a
+ MIPS toolchain that was compiled for a slightly-different-but-equivalent
+ target.
+
+ The following GCC target triplets have been confirmed to work with PSn00bSDK:
+
+ - `mipsel-unknown-elf`
+ - `mipsel-none-elf`
+
+- `PSN00BSDK_TC` (`PATH`)
+
+ Path to the GCC toolchain's installation prefix/directory. By default this is
+ initialized to the value of the `PSN00BSDK_TC` environment variable (if set).
+ Note that modifying the environment variable after the project has been
+ configured will *NOT* update this cache entry unless the project's cache is
+ cleared manually.
+
+ If not set, CMake will attempt to find the toolchain in the `PATH`
+ environment variable and store its path in this variable (so the search does
+ not have to be repeated).
+
+ **IMPORTANT**: if the toolchain's target is not `mipsel-unknown-elf`,
+ `PSN00BSDK_TARGET` must be set regardless of whether or not `PSN00BSDK_TC` is
+ also set.
+
+- `PSN00BSDK_LIBGCC` (`FILEPATH`)
+
+ Path to the `libgcc.a` library bundled with the GCC toolchain. The contents
+ of this library are merged into `libc` when building the SDK, so this
+ variable is only actually needed when compiling `libpsn00b`. Setting this
+ variable manually usually isn't necessary as CMake will locate `libgcc.a`
+ automatically after finding the toolchain.
+
+## Internal settings
+
+These settings are not stored in CMake's cache and can only be set from within
+the build script.
+
+- `PSN00BSDK_LIBRARIES`
+
+ List of libraries to link all created targets against. By default this
+ includes all PSn00bSDK libraries.
+
+- `PSN00BSDK_EXECUTABLE_SUFFIX`, `PSN00BSDK_SHARED_LIBRARY_SUFFIX`,
+ `PSN00BSDK_SYMBOL_MAP_SUFFIX`
+
+ File extensions to use for generated PS1 files. The default values are
+ `.exe`, `.dll` and `.map` respectively. Note that file names and extensions
+ can be changed anyway when building a CD image.
+
+## Read-only variables
+
+- `PSN00BSDK_VERSION`
+
+ The SDK's version number (`major.minor.patch`).
+
+- `PSN00BSDK_TOOLS`, `PSN00BSDK_INCLUDE`, `PSN00BSDK_LDSCRIPTS`
+
+ Lists of paths used internally. Should not be set, manipulated or overridden
+ by scripts.
+
+- `TOOLCHAIN_NM`
+
+ Path to the `nm` executable used to generate symbol maps. Although not used
+ internally by CMake, this program is part of the GCC toolchain.
+
+- `ELF2X`, `ELF2CPE`, `MKPSXISO`, `LZPACK`, `SMXLINK`
+
+ Paths to the PSn00bSDK tools' executables. As no functions are currently
+ provided for building assets, `LZPACK` and `SMXLINK` can be used with
+ `add_custom_command()`/`add_custom_target()` to convert models and generate
+ LZP archives as part of the build pipeline.
+
+-----------------------------------------
+_Last updated on 2021-09-27 by spicyjpeg_
diff --git a/doc/dev notes.txt b/doc/dev notes.txt
index 47aa2df..8fd8d7f 100644
--- a/doc/dev notes.txt
+++ b/doc/dev notes.txt
@@ -92,3 +92,68 @@ power operator, not xor):
* If you are overriding any of the memory allocation functions, DO NOT ENABLE
LINK-TIME OPTIMIZATION. GCC has a long-standing bug with LTO and weak functions
written in assembly, also LTO hasn't been tested at all yet.
+
+Obscure CMake issues and related stuff:
+
+* Toolchain files are loaded "early" according to the CMake docs. What this
+means in practice is that a lot of commands, such as find_*(), won't work
+properly in a toolchain script as they rely on variables initialized by the
+project() command. The poorly documented solution to this is to move such
+commands to a separate file and set CMAKE_PROJECT_INCLUDE to point to it, so
+project() will execute it immediately after initialization.
+
+* After executing the toolchain file, CMake generates and attempts to build
+several dummy projects to test the compiler. Each of these projects re-includes
+the toolchain script (which is why you'll see commands executed multiple times)
+and uses the same variable values as the main project, however CMake will *NOT*
+pass custom variables through by default. If your toolchain script has options
+that can be set via custom variables (like PSN00BSDK_TC and PSN00BSDK_PREFIX in
+PSn00bSDK), you'll have to set CMAKE_TRY_COMPILE_PLATFORM_VARIABLES to a list
+of variable names to be exported to generated dummy projects.
+
+* There is no way to use multiple toolchains (PS1 + host) in a single project,
+even if you use add_subdirectory() to execute multiple project files (which,
+confusingly, adds their targets to the parent project rather than treating them
+as separate projects). Thankfully though CMake provides support for automating
+the build process of independent CMake projects via the ExternalProject module.
+Which brings me to the next issue...
+
+* If you run CPack on a "superbuild" project (i.e. a project that calls
+ExternalProject_Add() to configure, compile and install subprojects at build
+time), you'll likely run into a weird issue with CPack bundling folders from
+your build directory into DEB and RPM packages. This is caused by the DEB/RPM
+generators running "cmake --install" in a chroot/fakeroot to prepare the files
+to be packaged, which seems to interfere with absolute paths in the project
+cache or something like that (?). The only workaround I know of is to use
+CPACK_PRE_BUILD_SCRIPTS to trigger a custom script that deletes anything other
+than the actual files to be packaged (see cpack/fakeroot_fix.cmake).
+
+* Depending on how you find external dependencies (find_package(), vcpkg,
+pkg-config...), CMake may end up outputting an executable that relies on a DLL
+installed system-wide. To correctly install the DLL alongside the executable
+you have to specify a regex as follows:
+
+ install(
+ TARGETS my_executable
+ RUNTIME_DEPENDENCIES
+ PRE_EXCLUDE_REGEXES ".*"
+ PRE_INCLUDE_REGEXES "tinyxml2"
+ )
+
+CMake will scan the executable at install time and copy all the required DLLs
+that match the second regex. If no regex is specified CMake will also copy OS
+DLLs like libc or msvcrt, which usually isn't the desired behavior.
+
+* Using interface targets to set include directories can be finicky. Not only
+do you have to use generator expressions to conditionally use different paths
+depending on whether the targets are installed, but CMake can get confused on
+which options to pass to the compiler. I spent hours trying to get CMake to use
+-I rather than -isystem for include directories (for some reason GCC would
+ignore -isystem completely). I eventually gave up and just set the include
+directories manually for each target, and for some reason CMake actually
+started passing -I instead of -isystem to GCC.
+
+* Not a CMake/CPack bug per se, but NSIS is picky about the banner and header
+images shown in generated installers. They must be Windows BMP version 3 files
+with no alpha channel, no compression and no metadata. They can either be
+24-bit RGB or indexed, though it's common to use indexed colors to save space.
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..7cd7e98
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,25 @@
+# PSn00bSDK examples build script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+project(
+ PSn00bSDK-examples
+ LANGUAGES NONE
+ DESCRIPTION "PSn00bSDK examples"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(
+ GLOB_RECURSE _examples
+ ${PROJECT_SOURCE_DIR}/CMakeLists.txt
+)
+
+foreach(_script IN LISTS _examples)
+ cmake_path(GET _script PARENT_PATH _dir)
+ if(_dir STREQUAL PROJECT_SOURCE_DIR)
+ continue()
+ endif()
+
+ add_subdirectory(${_dir})
+endforeach()
diff --git a/examples/beginner/cppdemo/CMakeLists.txt b/examples/beginner/cppdemo/CMakeLists.txt
new file mode 100644
index 0000000..83f0f0a
--- /dev/null
+++ b/examples/beginner/cppdemo/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ cppdemo
+ LANGUAGES CXX
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK basic C++ example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.cpp)
+psn00bsdk_add_executable(cppdemo STATIC ${_sources})
+#psn00bsdk_add_cd_image(cppdemo_iso cppdemo iso.xml DEPENDS cppdemo)
+
+install(FILES ${PROJECT_BINARY_DIR}/cppdemo.exe DESTINATION .)
diff --git a/examples/beginner/cppdemo/makefile b/examples/beginner/cppdemo/makefile
deleted file mode 100644
index 630a280..0000000
--- a/examples/beginner/cppdemo/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = cppdemo
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/beginner/hello/CMakeLists.txt b/examples/beginner/hello/CMakeLists.txt
new file mode 100644
index 0000000..40e30b0
--- /dev/null
+++ b/examples/beginner/hello/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ hello
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK hello world example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(hello STATIC ${_sources})
+#psn00bsdk_add_cd_image(hello_iso hello iso.xml DEPENDS hello)
+
+install(FILES ${PROJECT_BINARY_DIR}/hello.exe DESTINATION .)
diff --git a/examples/beginner/hello/makefile b/examples/beginner/hello/makefile
deleted file mode 100644
index e4bed20..0000000
--- a/examples/beginner/hello/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = hello
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/cdrom/cdbrowse/CMakeLists.txt b/examples/cdrom/cdbrowse/CMakeLists.txt
new file mode 100644
index 0000000..6eb4cbb
--- /dev/null
+++ b/examples/cdrom/cdbrowse/CMakeLists.txt
@@ -0,0 +1,27 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ cdbrowse
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK CD file browser example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(cdbrowse STATIC ${_sources})
+psn00bsdk_add_cd_image(cdbrowse_iso cdbrowse iso.xml DEPENDS cdbrowse)
+
+install(
+ FILES
+ ${PROJECT_BINARY_DIR}/cdbrowse.bin
+ ${PROJECT_BINARY_DIR}/cdbrowse.cue
+ DESTINATION .
+)
diff --git a/examples/cdrom/cdbrowse/iso.xml b/examples/cdrom/cdbrowse/iso.xml
index 5d8963d..5ffca18 100644
--- a/examples/cdrom/cdbrowse/iso.xml
+++ b/examples/cdrom/cdbrowse/iso.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<iso_project
- image_name="build/cdbrowse.bin"
- cue_sheet="build/cdbrowse.cue"
+ image_name="${CD_IMAGE_NAME}.bin"
+ cue_sheet="${CD_IMAGE_NAME}.cue"
>
<track type="data">
<identifiers
@@ -9,15 +9,15 @@
volume ="CDBROWSE"
volume_set ="CDBROWSE"
publisher ="MEIDOTEK"
- data_preparer ="PSN00BSDK BUILD SCRIPT"
+ data_preparer ="PSN00BSDK ${PSN00BSDK_VERSION}"
application ="PLAYSTATION"
copyright ="README.TXT;1"
/>
<directory_tree>
- <file name="SYSTEM.CNF" type="data" source="system.cnf" />
- <file name="CDBROWSE.EXE" type="data" source="build/cdbrowse.exe" />
- <file name="CDBROWSE.MAP" type="data" source="build/cdbrowse.map" />
+ <file name="SYSTEM.CNF" type="data" source="${PROJECT_SOURCE_DIR}/system.cnf" />
+ <file name="CDBROWSE.EXE" type="data" source="cdbrowse.exe" />
+ <file name="CDBROWSE.MAP" type="data" source="cdbrowse.map" />
<dir name="DIRA">
<dir name="DIRAA">
diff --git a/examples/cdrom/cdbrowse/makefile b/examples/cdrom/cdbrowse/makefile
deleted file mode 100644
index 954408b..0000000
--- a/examples/cdrom/cdbrowse/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = cdbrowse
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: iso
-#all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/cdrom/cdxa/CMakeLists.txt b/examples/cdrom/cdxa/CMakeLists.txt
new file mode 100644
index 0000000..b0c8d90
--- /dev/null
+++ b/examples/cdrom/cdxa/CMakeLists.txt
@@ -0,0 +1,29 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ cdxa
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK CD-XA playback example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+# TODO: add rules to actually generate a valid .XA file
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(cdxa STATIC ${_sources})
+#psn00bsdk_add_cd_image(cdxa_iso cdxa iso.xml DEPENDS cdxa)
+
+install(
+ FILES
+ #${PROJECT_BINARY_DIR}/cdxa.bin
+ #${PROJECT_BINARY_DIR}/cdxa.cue
+ ${PROJECT_BINARY_DIR}/cdxa.exe
+ DESTINATION .
+)
diff --git a/examples/cdrom/cdxa/iso.xml b/examples/cdrom/cdxa/iso.xml
index 9a6a206..b98a16f 100644
--- a/examples/cdrom/cdxa/iso.xml
+++ b/examples/cdrom/cdxa/iso.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<iso_project
- image_name="build/cdxa.bin"
- cue_sheet="build/cdxa.cue"
+ image_name="${CD_IMAGE_NAME}.bin"
+ cue_sheet="${CD_IMAGE_NAME}.cue"
>
<track type="data">
<identifiers
@@ -9,18 +9,18 @@
volume ="CDXA"
volume_set ="CDXA"
publisher ="MEIDOTEK"
- data_preparer ="PSN00BSDK BUILD SCRIPT"
+ data_preparer ="PSN00BSDK ${PSN00BSDK_VERSION}"
application ="PLAYSTATION"
copyright ="README.TXT;1"
/>
<directory_tree>
- <file name="SYSTEM.CNF" type="data" source="system.cnf" />
- <file name="CDXA.EXE" type="data" source="build/cdxa.exe" />
- <file name="CDXA.MAP" type="data" source="build/cdxa.map" />
+ <file name="SYSTEM.CNF" type="data" source="${PROJECT_SOURCE_DIR}/system.cnf" />
+ <file name="CDXA.EXE" type="data" source="cdxa.exe" />
+ <file name="CDXA.MAP" type="data" source="cdxa.map" />
<!-- CD-XA file, you'll have to provide your own to make this example work -->
- <file name="XASAMPLE.XA" type="mixed" source="xasample.xa"/>
+ <file name="XASAMPLE.XA" type="mixed" source="${PROJECT_SOURCE_DIR}/xasample.xa"/>
<dummy sectors="1024"/>
</directory_tree>
diff --git a/examples/cdrom/cdxa/makefile b/examples/cdrom/cdxa/makefile
deleted file mode 100644
index b1627f7..0000000
--- a/examples/cdrom/cdxa/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = cdxa
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/demos/n00bdemo/CMakeLists.txt b/examples/demos/n00bdemo/CMakeLists.txt
new file mode 100644
index 0000000..0b51beb
--- /dev/null
+++ b/examples/demos/n00bdemo/CMakeLists.txt
@@ -0,0 +1,50 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ n00bdemo
+ LANGUAGES C ASM
+ VERSION 1.0.0
+ DESCRIPTION "n00bdemo (PSn00bSDK demo)"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+set(DATA_DIR ${PROJECT_SOURCE_DIR}/data)
+
+configure_file(data.s.template data.s)
+configure_file(data.xml.template data.xml)
+
+# Add a build step to pack assets into a single .LZP file. This archive is then
+# embedded into the binary through data.s, which is in turn generated from
+# data.s.template. Note that, since we specify dependencies, CMake can detect
+# when source assets are edited and rebuild the archive automatically.
+file(GLOB _assets ${DATA_DIR}/*.tim ${DATA_DIR}/*.smd)
+add_custom_command(
+ COMMAND ${LZPACK} -y data.xml
+ OUTPUT data.lzp
+ BYPRODUCTS textures.qlp
+ DEPENDS ${_assets}
+ COMMENT "Building LZP archive"
+)
+
+file(GLOB _sources *.s *.c)
+psn00bsdk_add_executable(
+ n00bdemo STATIC
+ ${_sources}
+ ${PROJECT_BINARY_DIR}/data.s
+)
+target_include_directories(n00bdemo PRIVATE ${PROJECT_SOURCE_DIR})
+#psn00bsdk_add_cd_image(n00bdemo_iso n00bdemo iso.xml DEPENDS n00bdemo)
+
+# Ensure data.lzp is built before the executable. Due to CMake's limitations we
+# actually have to wrap it in a dummy target.
+add_custom_target(n00bdemo_data DEPENDS data.lzp)
+add_dependencies(n00bdemo n00bdemo_data)
+
+install(FILES ${PROJECT_BINARY_DIR}/n00bdemo.exe DESTINATION .)
diff --git a/examples/demos/n00bdemo/data.h b/examples/demos/n00bdemo/data.h
index 3be0e3d..9e64ea1 100644
--- a/examples/demos/n00bdemo/data.h
+++ b/examples/demos/n00bdemo/data.h
@@ -1,7 +1,9 @@
#ifndef _DATA_H
#define _DATA_H
-extern unsigned char lz_resources[];
+extern unsigned char _lz_resources[];
+
+#define lz_resources ((const LZP_HEAD*) _lz_resources)
/*extern unsigned char smd_mtekdisk[];
extern unsigned char smd_mtektext[];
diff --git a/examples/demos/n00bdemo/data.s b/examples/demos/n00bdemo/data.s.template
index f3b2a83..9fbef2e 100644
--- a/examples/demos/n00bdemo/data.s
+++ b/examples/demos/n00bdemo/data.s.template
@@ -1,9 +1,9 @@
.section .data
-.global lz_resources
-.type lz_resources, @object
-lz_resources:
- .incbin "build/data.lzp"
+.global _lz_resources
+.type _lz_resources, @object
+_lz_resources:
+ .incbin "${PROJECT_BINARY_DIR}/data.lzp"
#.global smd_mtekdisk
#.type smd_mtekdisk, @object
diff --git a/examples/demos/n00bdemo/data.xml b/examples/demos/n00bdemo/data.xml
deleted file mode 100644
index 6761f16..0000000
--- a/examples/demos/n00bdemo/data.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<lzp_project>
-
- <create packname="build/textures.qlp" format="qlp">
-
- <file alias="petscum">data/petscum16c.tim</file>
- <file alias="bungirl">data/bungirl.tim</file>
-
- <!-- These are for the timerift background -->
- <file alias="clocktex">data/clktower.tim</file>
- <file alias="riftbldg1">data/riftbld1.tim</file>
- <file alias="riftbldg2">data/riftbld2.tim</file>
- <file alias="hatkid">data/hatkid.tim</file>
-
- <file alias="celmap">data/celmapi.tim</file>
-
- <file alias="lamelotl">data/lamelotl16c.tim</file>
- <file alias="n00blogo">data/n00blogo-pixel.tim</file>
- <file alias="font">data/font.tim</file>
-
- </create>
-
- <create packname="build/data.lzp" format="lzp">
-
- <!-- intro assets -->
- <file alias="mtekdisk">data/mtekdisk.smd</file>
- <file alias="mtektext">data/mtektext.smd</file>
- <file alias="starsprite">data/star.smd</file>
- <file alias="psn00blogo">data/psn00blogo.smd</file>
- <file alias="n00blogo">data/logo.smd</file>
-
- <!-- lighting demo assets -->
- <file alias="lightworld">data/petscum.smd</file>
- <file alias="lightbulb">data/bulb.smd</file>
-
- <!-- Hi-res bungirl demo assets -->
- <file alias="bungirl">data/bungirl.smd</file>
-
- <file alias="starmask">data/star_mask.smd</file>
- <file alias="timerift">data/timerift.smd</file>
- <file alias="rbowshade">data/rbowshade.smd</file>
-
- <file alias="hatkid">data/hatkid.smd</file>
-
- <!-- Global textures -->
- <file alias="textures">build/textures.qlp</file>
-
- </create>
-
-</lzp_project> \ No newline at end of file
diff --git a/examples/demos/n00bdemo/data.xml.template b/examples/demos/n00bdemo/data.xml.template
new file mode 100644
index 0000000..057d6a6
--- /dev/null
+++ b/examples/demos/n00bdemo/data.xml.template
@@ -0,0 +1,49 @@
+<lzp_project>
+
+ <create packname="textures.qlp" format="qlp">
+
+ <file alias="petscum">${DATA_DIR}/petscum16c.tim</file>
+ <file alias="bungirl">${DATA_DIR}/bungirl.tim</file>
+
+ <!-- These are for the timerift background -->
+ <file alias="clocktex">${DATA_DIR}/clktower.tim</file>
+ <file alias="riftbldg1">${DATA_DIR}/riftbld1.tim</file>
+ <file alias="riftbldg2">${DATA_DIR}/riftbld2.tim</file>
+ <file alias="hatkid">${DATA_DIR}/hatkid.tim</file>
+
+ <file alias="celmap">${DATA_DIR}/celmapi.tim</file>
+
+ <file alias="lamelotl">${DATA_DIR}/lamelotl16c.tim</file>
+ <file alias="n00blogo">${DATA_DIR}/n00blogo-pixel.tim</file>
+ <file alias="font">${DATA_DIR}/font.tim</file>
+
+ </create>
+
+ <create packname="data.lzp" format="lzp">
+
+ <!-- intro assets -->
+ <file alias="mtekdisk">${DATA_DIR}/mtekdisk.smd</file>
+ <file alias="mtektext">${DATA_DIR}/mtektext.smd</file>
+ <file alias="starsprite">${DATA_DIR}/star.smd</file>
+ <file alias="psn00blogo">${DATA_DIR}/psn00blogo.smd</file>
+ <file alias="n00blogo">${DATA_DIR}/logo.smd</file>
+
+ <!-- lighting demo assets -->
+ <file alias="lightworld">${DATA_DIR}/petscum.smd</file>
+ <file alias="lightbulb">${DATA_DIR}/bulb.smd</file>
+
+ <!-- Hi-res bungirl demo assets -->
+ <file alias="bungirl">${DATA_DIR}/bungirl.smd</file>
+
+ <file alias="starmask">${DATA_DIR}/star_mask.smd</file>
+ <file alias="timerift">${DATA_DIR}/timerift.smd</file>
+ <file alias="rbowshade">${DATA_DIR}/rbowshade.smd</file>
+
+ <file alias="hatkid">${DATA_DIR}/hatkid.smd</file>
+
+ <!-- Global textures -->
+ <file alias="textures">textures.qlp</file>
+
+ </create>
+
+</lzp_project> \ No newline at end of file
diff --git a/examples/demos/n00bdemo/logo.c b/examples/demos/n00bdemo/logo.c
index 2cebf6b..d10b5b4 100644
--- a/examples/demos/n00bdemo/logo.c
+++ b/examples/demos/n00bdemo/logo.c
@@ -7,7 +7,7 @@
#include <inline_c.h>
#include "malloc.h"
#include "smd.h"
-#include "lzp.h"
+#include <lzp/lzp.h>
#include "disp.h"
#include "data.h"
diff --git a/examples/demos/n00bdemo/main.c b/examples/demos/n00bdemo/main.c
index 623d8cc..ba21d88 100644
--- a/examples/demos/n00bdemo/main.c
+++ b/examples/demos/n00bdemo/main.c
@@ -29,8 +29,8 @@
#include <psxspu.h>
#include <inline_c.h>
#include <string.h>
-#include <lzp.h>
-#include <lzqlp.h>
+#include <lzp/lzp.h>
+#include <lzp/lzqlp.h>
#include "malloc.h"
#include "smd.h"
@@ -85,11 +85,12 @@ void loadTextures() {
Unpack textures from an embedded LZP archive and upload them to VRAM.
*/
int i;
- int *tex_buff,*ttim,j;
+ int *ttim,j;
+ QLP_HEAD *tex_buff;
TIM_IMAGE tim;
i = lzpSearchFile( "textures", lz_resources );
- tex_buff = (int*)malloc( lzpFileSize( lz_resources, i ) );
+ tex_buff = (QLP_HEAD*)malloc( lzpFileSize( lz_resources, i ) );
lzpUnpackFile( tex_buff, lz_resources, i );
@@ -148,6 +149,7 @@ void loadTextures() {
font_tpage = getTPage( 0, 1, tim.prect->x, tim.prect->y )|0x200;
font_clut = getClut( tim.crect->x, tim.crect->y );
+ free( tex_buff );
}
void unpackModels() {
diff --git a/examples/demos/n00bdemo/makefile b/examples/demos/n00bdemo/makefile
deleted file mode 100644
index 9206e09..0000000
--- a/examples/demos/n00bdemo/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = demo
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS += -llzp
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET)
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- $(LZPACK) data.xml
- touch data.s
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s resources
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/balls/CMakeLists.txt b/examples/graphics/balls/CMakeLists.txt
new file mode 100644
index 0000000..b063425
--- /dev/null
+++ b/examples/graphics/balls/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ balls
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK sprites example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(balls STATIC ${_sources})
+#psn00bsdk_add_cd_image(balls_iso balls iso.xml DEPENDS balls)
+
+install(FILES ${PROJECT_BINARY_DIR}/balls.exe DESTINATION .)
diff --git a/examples/graphics/balls/makefile b/examples/graphics/balls/makefile
deleted file mode 100644
index 44d3d71..0000000
--- a/examples/graphics/balls/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = balls
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/billboard/CMakeLists.txt b/examples/graphics/billboard/CMakeLists.txt
new file mode 100644
index 0000000..bf73297
--- /dev/null
+++ b/examples/graphics/billboard/CMakeLists.txt
@@ -0,0 +1,28 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ billboard
+ LANGUAGES C ASM
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK billboard sprite example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+configure_file(tim.s.template tim.s)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(
+ billboard STATIC
+ ${_sources}
+ ${PROJECT_BINARY_DIR}/tim.s
+)
+#psn00bsdk_add_cd_image(billboard_iso billboard iso.xml DEPENDS billboard)
+
+install(FILES ${PROJECT_BINARY_DIR}/billboard.exe DESTINATION .)
diff --git a/examples/graphics/billboard/makefile b/examples/graphics/billboard/makefile
deleted file mode 100644
index 462e73c..0000000
--- a/examples/graphics/billboard/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = billboard
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/billboard/tim.s b/examples/graphics/billboard/tim.s.template
index 1fa8d69..fbe7522 100644
--- a/examples/graphics/billboard/tim.s
+++ b/examples/graphics/billboard/tim.s.template
@@ -3,5 +3,4 @@
.global tim_image
.type tim_image, @object
tim_image:
- .incbin "texture64.tim"
- \ No newline at end of file
+ .incbin "${PROJECT_SOURCE_DIR}/texture64.tim"
diff --git a/examples/graphics/fpscam/CMakeLists.txt b/examples/graphics/fpscam/CMakeLists.txt
new file mode 100644
index 0000000..8fa66f2
--- /dev/null
+++ b/examples/graphics/fpscam/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ hello
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK 3D camera controls example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(fpscam STATIC ${_sources})
+#psn00bsdk_add_cd_image(fpscam_iso fpscam iso.xml DEPENDS fpscam)
+
+install(FILES ${PROJECT_BINARY_DIR}/fpscam.exe DESTINATION .)
diff --git a/examples/graphics/fpscam/makefile b/examples/graphics/fpscam/makefile
deleted file mode 100644
index 2ddb7fd..0000000
--- a/examples/graphics/fpscam/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = fpscam
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/gte/CMakeLists.txt b/examples/graphics/gte/CMakeLists.txt
new file mode 100644
index 0000000..3cdf2ff
--- /dev/null
+++ b/examples/graphics/gte/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ hello
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK GTE 3D cube example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(gte STATIC ${_sources})
+#psn00bsdk_add_cd_image(gte_iso gte iso.xml DEPENDS gte)
+
+install(FILES ${PROJECT_BINARY_DIR}/gte.exe DESTINATION .)
diff --git a/examples/graphics/gte/makefile b/examples/graphics/gte/makefile
deleted file mode 100644
index f44e72b..0000000
--- a/examples/graphics/gte/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = gte
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/hdtv/CMakeLists.txt b/examples/graphics/hdtv/CMakeLists.txt
new file mode 100644
index 0000000..98a0b3f
--- /dev/null
+++ b/examples/graphics/hdtv/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ hdtv
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK HDTV widescreen example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(hdtv STATIC ${_sources})
+#psn00bsdk_add_cd_image(hdtv_iso hdtv iso.xml DEPENDS hdtv)
+
+install(FILES ${PROJECT_BINARY_DIR}/hdtv.exe DESTINATION .)
diff --git a/examples/graphics/hdtv/makefile b/examples/graphics/hdtv/makefile
deleted file mode 100644
index 6659c98..0000000
--- a/examples/graphics/hdtv/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = hdtv
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/render2tex/CMakeLists.txt b/examples/graphics/render2tex/CMakeLists.txt
new file mode 100644
index 0000000..42a063b
--- /dev/null
+++ b/examples/graphics/render2tex/CMakeLists.txt
@@ -0,0 +1,28 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ render2tex
+ LANGUAGES C ASM
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK render-to-texture example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+configure_file(texture.s.template texture.s)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(
+ render2tex STATIC
+ ${_sources}
+ ${PROJECT_BINARY_DIR}/texture.s
+)
+#psn00bsdk_add_cd_image(render2tex_iso render2tex iso.xml DEPENDS render2tex)
+
+install(FILES ${PROJECT_BINARY_DIR}/render2tex.exe DESTINATION .)
diff --git a/examples/graphics/render2tex/makefile b/examples/graphics/render2tex/makefile
deleted file mode 100644
index bb0ef3c..0000000
--- a/examples/graphics/render2tex/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = render2tex
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/render2tex/texture.s b/examples/graphics/render2tex/texture.s.template
index e786dce..8b09ad8 100644
--- a/examples/graphics/render2tex/texture.s
+++ b/examples/graphics/render2tex/texture.s.template
@@ -5,5 +5,4 @@
.global tim_blendpattern
.type tim_blendpattern, @object
tim_blendpattern:
- .incbin "blendpattern-16c.tim"
- \ No newline at end of file
+ .incbin "${PROJECT_SOURCE_DIR}/blendpattern-16c.tim"
diff --git a/examples/graphics/rgb24/CMakeLists.txt b/examples/graphics/rgb24/CMakeLists.txt
new file mode 100644
index 0000000..c66ae69
--- /dev/null
+++ b/examples/graphics/rgb24/CMakeLists.txt
@@ -0,0 +1,28 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ rgb24
+ LANGUAGES C ASM
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK 24-bit RGB display example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+configure_file(tim.s.template tim.s)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(
+ rgb24 STATIC
+ ${_sources}
+ ${PROJECT_BINARY_DIR}/tim.s
+)
+#psn00bsdk_add_cd_image(rgb24_iso rgb24 iso.xml DEPENDS rgb24)
+
+install(FILES ${PROJECT_BINARY_DIR}/rgb24.exe DESTINATION .)
diff --git a/examples/graphics/rgb24/makefile b/examples/graphics/rgb24/makefile
deleted file mode 100644
index 9fa35ec..0000000
--- a/examples/graphics/rgb24/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = rgb24
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/graphics/rgb24/tim.s b/examples/graphics/rgb24/tim.s.template
index a4432d9..9fb1fb6 100644
--- a/examples/graphics/rgb24/tim.s
+++ b/examples/graphics/rgb24/tim.s.template
@@ -3,5 +3,4 @@
.global tim_image
.type tim_image, @object
tim_image:
- .incbin "bunpattern.tim"
- \ No newline at end of file
+ .incbin "${PROJECT_SOURCE_DIR}/bunpattern.tim"
diff --git a/examples/makefile b/examples/makefile
deleted file mode 100644
index bdc62ce..0000000
--- a/examples/makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# Run using make (Linux) or gmake (BSD)
-# Part of the PSn00bSDK Project
-# 2019-2020 Lameguy64 / Meido-Tek Productions
-
-TOPTARGETS = all clean
-
-# Beginner examples
-DIRS = beginner/hello beginner/cppdemo
-
-# Graphics examples
-DIRS += graphics/balls graphics/billboard graphics/fpscam \
- graphics/gte graphics/hdtv graphics/render2tex \
- graphics/rgb24
-
-# System related examples
-DIRS += system/childexec system/console system/dynlink \
- system/timer system/tty
-
-# Low-level examples
-DIRS +=
-
-# CD-ROM examples
-DIRS += cdrom/cdbrowse cdrom/cdxa
-
-# Demos
-DIRS += demos/n00bdemo
-
-$(TOPTARGETS): $(DIRS)
-$(DIRS):
- @$(MAKE) -C $@ $(MAKECMDGOALS)
-
-clean: $(DIRS)
-
-.PHONY: $(TOPTARGETS) $(DIRS)
diff --git a/examples/system/childexec/CMakeLists.txt b/examples/system/childexec/CMakeLists.txt
new file mode 100644
index 0000000..c9983c4
--- /dev/null
+++ b/examples/system/childexec/CMakeLists.txt
@@ -0,0 +1,41 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ childexec
+ LANGUAGES C ASM
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK child process example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+configure_file(child_exe.s.template child_exe.s)
+
+file(GLOB _sources *.c)
+file(GLOB _child_sources child/*.c)
+psn00bsdk_add_executable(
+ parent STATIC
+ ${_sources}
+ ${PROJECT_BINARY_DIR}/child_exe.s
+)
+psn00bsdk_add_executable(child STATIC ${_child_sources})
+#psn00bsdk_add_cd_image(childexec_iso childexec iso.xml DEPENDS parent)
+
+# Relocate the child executable to a non-default address to prevent it from
+# overlapping with the main one at 0x80010000.
+# NOTE: child executables are not position-independent and can't be relocated
+# at runtime. If you need your code to be relocatable (e.g. to load it into a
+# dynamically-allocated buffer), consider using a DLL instead.
+target_link_options(child PRIVATE -Ttext=0x80030000)
+
+# Make sure the child executable is built before the parent (so it can be
+# embedded via child_exe.s).
+add_dependencies(parent child)
+
+install(FILES ${PROJECT_BINARY_DIR}/parent.exe DESTINATION .)
diff --git a/examples/system/childexec/child_exe.s b/examples/system/childexec/child_exe.s.template
index 66bd0e2..f76bb3d 100644
--- a/examples/system/childexec/child_exe.s
+++ b/examples/system/childexec/child_exe.s.template
@@ -3,4 +3,4 @@
.global child_exe # Insert spoopypasta
.type child_exe, @object
child_exe:
- .incbin "build/child/child.exe" \ No newline at end of file
+ .incbin "${PROJECT_BINARY_DIR}/child.exe"
diff --git a/examples/system/childexec/makefile b/examples/system/childexec/makefile
deleted file mode 100644
index e801739..0000000
--- a/examples/system/childexec/makefile
+++ /dev/null
@@ -1,93 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-#TARGET = childexec
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES_PARENT = $(notdir $(wildcard *.c))
-CPPFILES_PARENT = $(notdir $(wildcard *.cpp))
-AFILES_PARENT = $(notdir $(wildcard *.s))
-
-CFILES_CHILD = $(notdir $(wildcard child/*.c))
-CPPFILES_CHILD = $(notdir $(wildcard child/*.cpp))
-AFILES_CHILD = $(notdir $(wildcard child/*.s))
-
-# Create names for object files
-OFILES_PARENT = $(addprefix build/,$(CFILES_PARENT:.c=.o)) \
- $(addprefix build/,$(CPPFILES_PARENT:.cpp=.o)) \
- $(addprefix build/,$(AFILES_PARENT:.s=.o))
-OFILES_CHILD = $(addprefix build/child/,$(CFILES_CHILD:.c=.o)) \
- $(addprefix build/child/,$(CPPFILES_CHILD:.cpp=.o)) \
- $(addprefix build/child/,$(AFILES_CHILD:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-# Relocate the child executable to 0x30000
-LDFLAGS_CHILD = -Ttext=0x80030000
-
-## Build rules
-
-#all: iso
-all: build/child/child build/parent
-
-iso: build/child/child build/parent resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/child/child: $(OFILES_CHILD)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LDFLAGS_CHILD) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/parent: $(OFILES_PARENT)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/child/%.o: child/%.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/child/%.o: child/%.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/child/%.o: child/%.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/system/console/CMakeLists.txt b/examples/system/console/CMakeLists.txt
new file mode 100644
index 0000000..acae08f
--- /dev/null
+++ b/examples/system/console/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ console
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK stdio console example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(console STATIC ${_sources})
+#psn00bsdk_add_cd_image(console_iso console iso.xml DEPENDS console)
+
+install(FILES ${PROJECT_BINARY_DIR}/console.exe DESTINATION .)
diff --git a/examples/system/console/makefile b/examples/system/console/makefile
deleted file mode 100644
index addf02a..0000000
--- a/examples/system/console/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = console
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/system/dynlink/CMakeLists.txt b/examples/system/dynlink/CMakeLists.txt
new file mode 100644
index 0000000..3af5d4b
--- /dev/null
+++ b/examples/system/dynlink/CMakeLists.txt
@@ -0,0 +1,32 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ dynlink
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK dynamic linker example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(dynlink_main DYNAMIC ${_sources})
+psn00bsdk_add_library (dynlink_cube SHARED library/cube.c)
+psn00bsdk_add_library (dynlink_balls SHARED library/balls.c)
+psn00bsdk_add_cd_image(
+ dynlink_iso dynlink iso.xml
+ DEPENDS dynlink_main dynlink_cube dynlink_balls
+)
+
+install(
+ FILES
+ ${PROJECT_BINARY_DIR}/dynlink.bin
+ ${PROJECT_BINARY_DIR}/dynlink.cue
+ DESTINATION .
+)
diff --git a/examples/system/dynlink/iso.xml b/examples/system/dynlink/iso.xml
index 76cc8fc..8f40510 100644
--- a/examples/system/dynlink/iso.xml
+++ b/examples/system/dynlink/iso.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<iso_project
- image_name="build/dynlink.bin"
- cue_sheet="build/dynlink.cue"
+ image_name="${CD_IMAGE_NAME}.bin"
+ cue_sheet="${CD_IMAGE_NAME}.cue"
>
<track type="data">
<identifiers
@@ -9,18 +9,18 @@
volume ="DYNLINK"
volume_set ="DYNLINK"
publisher ="MEIDOTEK"
- data_preparer ="PSN00BSDK BUILD SCRIPT"
+ data_preparer ="PSN00BSDK ${PSN00BSDK_VERSION}"
application ="PLAYSTATION"
copyright ="README.TXT;1"
/>
<directory_tree>
- <file name="SYSTEM.CNF" type="data" source="system.cnf" />
- <file name="MAIN.EXE" type="data" source="build/main.exe" />
- <file name="MAIN.MAP" type="data" source="build/main.map" />
+ <file name="SYSTEM.CNF" type="data" source="${PROJECT_SOURCE_DIR}/system.cnf" />
+ <file name="MAIN.EXE" type="data" source="dynlink_main.exe" />
+ <file name="MAIN.MAP" type="data" source="dynlink_main.map" />
- <file name="CUBE.DLL" type="data" source="build/library/cube.dll" />
- <file name="BALLS.DLL" type="data" source="build/library/balls.dll" />
+ <file name="CUBE.DLL" type="data" source="dynlink_cube.dll" />
+ <file name="BALLS.DLL" type="data" source="dynlink_balls.dll" />
<dummy sectors="1024"/>
</directory_tree>
diff --git a/examples/system/dynlink/makefile b/examples/system/dynlink/makefile
deleted file mode 100644
index b3fb298..0000000
--- a/examples/system/dynlink/makefile
+++ /dev/null
@@ -1,95 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-#TARGET = dynlink
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES_MAIN = $(notdir $(wildcard *.c))
-CPPFILES_MAIN = $(notdir $(wildcard *.cpp))
-AFILES_MAIN = $(notdir $(wildcard *.s))
-
-CFILES_DLL = $(notdir $(wildcard library/*.c))
-CPPFILES_DLL = $(notdir $(wildcard library/*.cpp))
-AFILES_DLL = $(notdir $(wildcard library/*.s))
-
-# Create names for object files
-OFILES_MAIN = $(addprefix build/,$(CFILES_MAIN:.c=.o)) \
- $(addprefix build/,$(CPPFILES_MAIN:.cpp=.o)) \
- $(addprefix build/,$(AFILES_MAIN:.s=.o))
-OFILES_CUBE = build/library/cube.o
-OFILES_BALLS = build/library/balls.o
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: iso
-#all: build/library/cube build/library/balls build/main
-
-iso: build/library/cube build/library/balls build/main resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/library/cube: $(OFILES_CUBE)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_DLL) $^ -o $@
- #$(NM) -f posix -l -n $@ >$@.map
- $(OBJCOPY) -O binary $@ $@.dll
-
-build/library/balls: $(OFILES_BALLS)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_DLL) $^ -o $@
- #$(NM) -f posix -l -n $@ >$@.map
- $(OBJCOPY) -O binary $@ $@.dll
-
-build/main: $(OFILES_MAIN)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXEDYN) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/library/%.o: library/%.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_DLL) $(INCLUDE) -c $< -o $@
-
-build/library/%.o: library/%.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_DLL) $(INCLUDE) -c $< -o $@
-
-build/library/%.o: library/%.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_DLL) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXEDYN) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXEDYN) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXEDYN) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/system/timer/CMakeLists.txt b/examples/system/timer/CMakeLists.txt
new file mode 100644
index 0000000..189bf87
--- /dev/null
+++ b/examples/system/timer/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ timer
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK hardware timer example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(timer STATIC ${_sources})
+#psn00bsdk_add_cd_image(timer_iso timer iso.xml DEPENDS timer)
+
+install(FILES ${PROJECT_BINARY_DIR}/timer.exe DESTINATION .)
diff --git a/examples/system/timer/makefile b/examples/system/timer/makefile
deleted file mode 100644
index c418af4..0000000
--- a/examples/system/timer/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = timer
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/examples/system/tty/CMakeLists.txt b/examples/system/tty/CMakeLists.txt
new file mode 100644
index 0000000..024ccd4
--- /dev/null
+++ b/examples/system/tty/CMakeLists.txt
@@ -0,0 +1,22 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ tty
+ LANGUAGES C
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK stdio terminal example"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+file(GLOB _sources *.c)
+psn00bsdk_add_executable(tty STATIC ${_sources})
+#psn00bsdk_add_cd_image(tty_iso tty iso.xml DEPENDS tty)
+
+install(FILES ${PROJECT_BINARY_DIR}/tty.exe DESTINATION .)
diff --git a/examples/system/tty/makefile b/examples/system/tty/makefile
deleted file mode 100644
index 381aa41..0000000
--- a/examples/system/tty/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ../../../libpsn00b
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = tty
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-#all: iso
-all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/libpsn00b/CMakeLists.txt b/libpsn00b/CMakeLists.txt
new file mode 100644
index 0000000..52914d3
--- /dev/null
+++ b/libpsn00b/CMakeLists.txt
@@ -0,0 +1,69 @@
+# libpsn00b build script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+# ${PROJECT_SOURCE_DIR} is not available until project() is called.
+set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/sdk.cmake)
+
+project(
+ libpsn00b
+ LANGUAGES C CXX ASM
+ DESCRIPTION "PSn00bSDK libraries"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+if(NOT DEFINED PSN00BSDK_LIBGCC)
+ message(FATAL_ERROR "Failed to obtain information about the GCC toolchain. Check your toolchain settings.")
+elseif(PSN00BSDK_LIBGCC STREQUAL "PSN00BSDK_LIBGCC-NOTFOUND")
+ message(FATAL_ERROR "Failed to find libgcc in the GCC toolchain's files. Check your toolchain settings, or set the path to libgcc using -DPSN00BSDK_LIBGCC.")
+endif()
+
+## Libraries
+
+foreach(_library IN LISTS PSN00BSDK_LIBRARIES)
+ # libc needs special handling due to the different directory name.
+ if(${_library} STREQUAL "c")
+ set(_path ${PROJECT_SOURCE_DIR}/libc)
+ else()
+ set(_path ${PROJECT_SOURCE_DIR}/${_library})
+ endif()
+
+ file(
+ GLOB_RECURSE _sources
+ ${_path}/*.s
+ ${_path}/*.c
+ ${_path}/*.cpp
+ ${_path}/*.cxx
+ )
+
+ psn00bsdk_add_library(${_library} STATIC ${_sources})
+endforeach()
+
+# Extract libgcc's contents and merge them into libc after building.
+add_custom_command(
+ TARGET c POST_BUILD
+ COMMAND ${CMAKE_AR} x ${PSN00BSDK_LIBGCC}
+ COMMAND ${CMAKE_AR} rsuU $<TARGET_FILE:c> *.o
+ COMMENT "Merging libgcc contents into SDK libc"
+)
+
+## Installation
+
+install(
+ TARGETS ${PSN00BSDK_LIBRARIES} ${PSN00BSDK_VIRTUAL_TARGETS}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b
+ EXPORT libpsn00b
+)
+install(
+ DIRECTORY cmake include ldscripts
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b
+)
+
+# Generate an import script, which will be used by the setup script to find the
+# libraries.
+install(
+ EXPORT libpsn00b
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpsn00b/cmake
+ #EXPORT_LINK_INTERFACE_LIBRARIES
+)
diff --git a/libpsn00b/cmake/internal_setup.cmake b/libpsn00b/cmake/internal_setup.cmake
new file mode 100644
index 0000000..e3d4be7
--- /dev/null
+++ b/libpsn00b/cmake/internal_setup.cmake
@@ -0,0 +1,161 @@
+# PSn00bSDK internal setup script for CMake
+# (C) 2021 spicyjpeg - MPL licensed
+
+# This script is included automatically when using the toolchain file and
+# defines helper functions.
+
+cmake_minimum_required(VERSION 3.21)
+include(GNUInstallDirs)
+
+# IMPORTANT TODO: set a version number
+set(PSN00BSDK_VERSION 0.1.0)
+
+## Settings (can be overridden by projects)
+
+set(PSN00BSDK_EXECUTABLE_SUFFIX ".exe")
+set(PSN00BSDK_SHARED_LIBRARY_SUFFIX ".dll")
+set(PSN00BSDK_SYMBOL_MAP_SUFFIX ".map")
+
+## SDK libraries
+
+# DON'T CHANGE THE ORDER or you'll break the libraries' internal dependencies.
+set(PSN00BSDK_LIBRARIES psxgpu psxgte psxspu psxcd psxsio psxetc psxapi lzp c)
+
+include(${CMAKE_CURRENT_LIST_DIR}/libpsn00b.cmake OPTIONAL)
+if(NOT TARGET psn00bsdk_common)
+ include(${CMAKE_CURRENT_LIST_DIR}/virtual_targets.cmake)
+endif()
+
+# Use the toolchain path to find libgcc (used to build libpsn00b). Of course
+# different installers, packages and distros have different opinions when it
+# comes to deciding where to install toolchains, so we have to bruteforce
+# multiple combinations of paths.
+if(CMAKE_C_COMPILER_VERSION)
+ string(REGEX MATCH "^([0-9]+)\." _dummy ${CMAKE_C_COMPILER_VERSION})
+
+ find_library(
+ PSN00BSDK_LIBGCC gcc
+ HINTS
+ ${PSN00BSDK_TC}/lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION}
+ ${PSN00BSDK_TC}/lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1}
+ ${PSN00BSDK_TC}/lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION}
+ ${PSN00BSDK_TC}/lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1}
+ ${PSN00BSDK_TC}/../lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION}
+ ${PSN00BSDK_TC}/../lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1}
+ ${PSN00BSDK_TC}/../lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION}
+ ${PSN00BSDK_TC}/../lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1}
+ NO_DEFAULT_PATH
+ DOC "Path to libgcc (bundled with the GCC toolchain)"
+ )
+endif()
+
+## Tools
+
+set(
+ PSN00BSDK_TOOLS
+ ${CMAKE_CURRENT_LIST_DIR}/../../../${CMAKE_INSTALL_BINDIR}
+ ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
+)
+
+find_program(ELF2X elf2x HINTS ${PSN00BSDK_TOOLS})
+find_program(ELF2CPE elf2cpe HINTS ${PSN00BSDK_TOOLS})
+find_program(SMXLINK elf2x HINTS ${PSN00BSDK_TOOLS})
+find_program(LZPACK lzpack HINTS ${PSN00BSDK_TOOLS})
+find_program(MKPSXISO mkpsxiso HINTS ${PSN00BSDK_TOOLS})
+
+## Helper functions for executables
+
+set(PSN00BSDK_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/../include)
+set(PSN00BSDK_LDSCRIPTS ${CMAKE_CURRENT_LIST_DIR}/../ldscripts)
+
+# psn00bsdk_add_executable(
+# <target name> <STATIC|DYNAMIC>
+# [EXCLUDE_FROM_ALL]
+# <sources> ...
+# )
+function(psn00bsdk_add_executable name type)
+ string(TOLOWER ${type} _type)
+ if(NOT ${_type} MATCHES "^(static|dynamic)$")
+ message(FATAL_ERROR "Invalid executable type: ${type} (must be STATIC or DYNAMIC)")
+ endif()
+
+ add_executable (${name} ${ARGN})
+ target_link_libraries(${name} psn00bsdk_${_type}_exe)
+ set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX ".elf")
+ target_link_options (${name} PRIVATE -T${PSN00BSDK_LDSCRIPTS}/exe.ld)
+
+ target_include_directories(${name} PRIVATE ${PSN00BSDK_INCLUDE})
+
+ # Add post-build steps to generate the .exe and symbol map once the
+ # executable is built. CMake 3.21 added support for target-dependent
+ # generator expressions (catchy name lol) in add_custom_command(), so I'm
+ # making heavy use of those here.
+ add_custom_command(
+ TARGET ${name} POST_BUILD
+ COMMAND ${ELF2X} -q ${name}.elf ${name}${PSN00BSDK_EXECUTABLE_SUFFIX}
+ COMMAND ${TOOLCHAIN_NM} -f posix -l -n ${name}.elf $<ANGLE-R>${name}${PSN00BSDK_SYMBOL_MAP_SUFFIX}
+ BYPRODUCTS ${name}${PSN00BSDK_EXECUTABLE_SUFFIX} ${name}${PSN00BSDK_SYMBOL_MAP_SUFFIX}
+ )
+endfunction()
+
+# psn00bsdk_add_library(
+# <target name> <STATIC|SHARED|MODULE>
+# [EXCLUDE_FROM_ALL]
+# <sources> ...
+# )
+# Note that SHARED and MODULE have the same meaning (both will create a DLL).
+# SDK libraries are NOT statically linked in by default; if you need to link
+# something, use target_link_libraries() manually.
+function(psn00bsdk_add_library name type)
+ string(TOUPPER ${type} _type_upper)
+ string(TOLOWER ${type} _type)
+ if(NOT ${_type} MATCHES "^(static|object|shared|module)$")
+ message(FATAL_ERROR "Invalid library type: ${type} (must be STATIC, OBJECT, SHARED or MODULE)")
+ endif()
+
+ add_library (${name} ${_type_upper} ${ARGN})
+ target_link_libraries(${name} psn00bsdk_${_type}_lib)
+
+ target_include_directories(${name} PRIVATE ${PSN00BSDK_INCLUDE})
+
+ if(${_type} MATCHES "^(shared|module)$")
+ set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX ".so")
+ target_link_options (${name} PRIVATE -T${PSN00BSDK_LDSCRIPTS}/dll.ld)
+
+ # Add a post-build step to dump the DLL's raw contents into a new file
+ # separate from the built ELF.
+ add_custom_command(
+ TARGET ${name} POST_BUILD
+ COMMAND ${CMAKE_OBJCOPY} -O binary ${name}.so ${name}${PSN00BSDK_SHARED_LIBRARY_SUFFIX}
+ BYPRODUCTS ${name}${PSN00BSDK_SHARED_LIBRARY_SUFFIX}
+ )
+ else()
+ set_target_properties(${name} PROPERTIES PREFIX "lib" SUFFIX ".a")
+
+ # Remove virtual target dependencies to make sure linking against the
+ # library does not also propagate static library flags.
+ set_target_properties(${name} PROPERTIES INTERFACE_LINK_LIBRARIES "")
+ endif()
+endfunction()
+
+# psn00bsdk_add_cd_image(
+# <target name>
+# <image file name>
+# <mkpsxiso config template>
+# [DEPENDS <dependencies> ...]
+# [additional options passed to add_custom_target()]
+# )
+function(psn00bsdk_add_cd_image name image_name config_file)
+ set(CD_IMAGE_NAME ${image_name})
+ configure_file(${config_file} _gen_${config_file})
+
+ add_custom_target(
+ ${name} ALL
+ COMMAND ${MKPSXISO} -y -q _gen_${config_file}
+ BYPRODUCTS ${image_name}.bin ${image_name}.cue
+ COMMENT "Building CD image ${image_name}"
+ ${ARGN}
+ )
+endfunction()
+
+## Helper functions for assets (TODO)
diff --git a/libpsn00b/cmake/sdk.cmake b/libpsn00b/cmake/sdk.cmake
new file mode 100644
index 0000000..4c2f330
--- /dev/null
+++ b/libpsn00b/cmake/sdk.cmake
@@ -0,0 +1,89 @@
+# PSn00bSDK toolchain setup file for CMake
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+set(
+ PSN00BSDK_TC $ENV{PSN00BSDK_TC}
+ CACHE PATH "Path to the GCC toolchain's installation directory"
+)
+set(
+ PSN00BSDK_TARGET mipsel-unknown-elf
+ CACHE STRING "GCC toolchain target triplet"
+)
+
+## CMake configuration
+
+set(CMAKE_SYSTEM_NAME PlayStation)
+set(CMAKE_SYSTEM_PROCESSOR mipsel)
+
+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)
+
+# Tell CMake not to run the linker when compiling test programs, and to pass
+# toolchain settings to the generated test projects. This dodges missing C++
+# standard library errors.
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES PSN00BSDK_TC PSN00BSDK_TARGET)
+
+## Toolchain path setup
+
+# Attempt to find GCC using a list of common installation locations.
+# PSN00BSDK_TC can be left unset if the toolchain can be found in any of these
+# or in the PATH environment variable.
+find_program(
+ _gcc ${PSN00BSDK_TARGET}-gcc
+ HINTS
+ ${PSN00BSDK_TC}/bin
+ ${PSN00BSDK_TC}/../bin
+ # Same as ${CMAKE_INSTALL_PREFIX}/${PSN00BSDK_TARGET}/bin
+ ${CMAKE_CURRENT_LIST_DIR}/../../../${PSN00BSDK_TARGET}/bin
+ PATHS
+ "C:/Program Files/${PSN00BSDK_TARGET}/bin"
+ "C:/Program Files (x86)/${PSN00BSDK_TARGET}/bin"
+ "C:/${PSN00BSDK_TARGET}/bin"
+ /opt/${PSN00BSDK_TARGET}/bin
+ /usr/local/${PSN00BSDK_TARGET}/bin
+ /usr/${PSN00BSDK_TARGET}/bin
+ NO_CACHE REQUIRED
+)
+cmake_path(GET _gcc PARENT_PATH _bin)
+cmake_path(GET _bin PARENT_PATH _toolchain)
+
+# Overwrite the empty cache entry, so it won't have to be found again.
+if(NOT IS_DIRECTORY PSN00BSDK_TC)
+ set(
+ PSN00BSDK_TC ${_toolchain}
+ CACHE PATH "Path to the GCC toolchain's installation directory"
+ FORCE
+ )
+endif()
+
+## Toolchain executables
+
+# ${CMAKE_EXECUTABLE_SUFFIX} seems not to work in toolchain scripts, so we
+# can't rely on it to determine the host OS extension for executables. The best
+# workaround I found is to extract the extension from the path returned by
+# find_program() using a regex.
+set(_prefix ${_bin}/${PSN00BSDK_TARGET})
+string(REGEX MATCH ".+-gcc(.*)$" _dummy ${_gcc})
+
+set(CMAKE_ASM_COMPILER ${_prefix}-gcc${CMAKE_MATCH_1})
+set(CMAKE_C_COMPILER ${_prefix}-gcc${CMAKE_MATCH_1})
+set(CMAKE_CXX_COMPILER ${_prefix}-g++${CMAKE_MATCH_1})
+set(CMAKE_AR ${_prefix}-ar${CMAKE_MATCH_1})
+set(CMAKE_LINKER ${_prefix}-ld${CMAKE_MATCH_1})
+set(CMAKE_RANLIB ${_prefix}-ranlib${CMAKE_MATCH_1})
+set(CMAKE_OBJCOPY ${_prefix}-objcopy${CMAKE_MATCH_1})
+set(CMAKE_SIZE ${_prefix}-size${CMAKE_MATCH_1})
+set(CMAKE_STRIP ${_prefix}-strip${CMAKE_MATCH_1})
+set(TOOLCHAIN_NM ${_prefix}-nm${CMAKE_MATCH_1})
+
+## SDK setup
+
+# We can't set up the SDK here as the find_*() functions may fail if they are
+# called before project(). We can however set a script to be executed right
+# after project() is invoked.
+set(CMAKE_PROJECT_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/internal_setup.cmake)
diff --git a/libpsn00b/cmake/virtual_targets.cmake b/libpsn00b/cmake/virtual_targets.cmake
new file mode 100644
index 0000000..df1df79
--- /dev/null
+++ b/libpsn00b/cmake/virtual_targets.cmake
@@ -0,0 +1,109 @@
+# libpsn00b interface targets
+# (C) 2021 spicyjpeg - MPL licensed
+
+# This script creates several "virtual" targets (psn00bsdk_*) that set include
+# directories and compiler flags when a target is linked against them. These
+# all end up in the autogenerated libpsn00b setup script after installation,
+# so this file is only included when building libpsn00b.
+
+# The following targets are currently defined:
+# - psn00bsdk_common
+# - psn00bsdk_object_lib (same as psn00bsdk_common)
+# - psn00bsdk_static_exe
+# - psn00bsdk_dynamic_exe
+# - psn00bsdk_static_lib
+# - psn00bsdk_shared_lib
+# - psn00bsdk_module_lib (same as psn00bsdk_shared_lib)
+
+include(GNUInstallDirs)
+
+set(PSN00BSDK_VIRTUAL_TARGETS "")
+
+macro(_add_interface_target name)
+ add_library(${name} INTERFACE)
+ list(APPEND PSN00BSDK_VIRTUAL_TARGETS ${name})
+
+ target_compile_options(
+ ${name} INTERFACE
+ ${_aflags}
+ $<$<COMPILE_LANGUAGE:C,CXX>:${_cflags}>
+ $<$<COMPILE_LANGUAGE:CXX>:${_cxxflags}>
+ )
+ target_link_options (${name} INTERFACE ${_ldflags})
+ target_link_libraries(${name} INTERFACE ${ARGN})
+endmacro()
+
+macro(_add_alias_target name)
+ #add_library(${name} ALIAS ${ARGN})
+ add_library(${name} INTERFACE)
+ list(APPEND PSN00BSDK_VIRTUAL_TARGETS ${name})
+
+ target_link_libraries(${name} INTERFACE ${ARGN})
+endmacro()
+
+# Options common to all target types:
+# - Define PLAYSTATION=1 and set include directories
+# - Optimize for MIPS R3000
+# - Inject zero checks into division operations (will throw breaks)
+# - All standard libraries (including libgcc) disabled
+# - Put all symbols into separate sections when building
+# - C++ features that require runtime support disabled
+# - Unused section stripping enabled
+set(_aflags -msoft-float -march=r3000 -mtune=r3000 -mabi=32)
+set(_cflags -mdivide-breaks -O2 -ffreestanding -fno-builtin -nostdlib -fdata-sections -ffunction-sections -fsigned-char -fno-strict-overflow -fdiagnostics-color=always)
+set(_cxxflags -fno-exceptions -fno-rtti -fno-unwind-tables -fno-threadsafe-statics -fno-use-cxa-atexit)
+set(_ldflags -nostdlib -Wl,-gc-sections)
+
+_add_interface_target(psn00bsdk_common)
+_add_alias_target (psn00bsdk_object_lib psn00bsdk_common)
+
+target_compile_definitions(
+ psn00bsdk_common INTERFACE
+ PLAYSTATION=1
+ $<$<CONFIG:DEBUG>:DEBUG=1>
+)
+
+# Options for executables without support for dynamic linking:
+# - Position-independent code disabled
+# - GP-relative addressing enabled only for local symbols
+# - ABI-compatible calls disabled (incompatible with GP-relative addr)
+set(_aflags -G8)
+set(_cflags -mno-abicalls -mgpopt -mno-extern-sdata)
+set(_cxxflags)
+set(_ldflags -G8 -static)
+
+_add_interface_target(psn00bsdk_static_exe psn00bsdk_common ${PSN00BSDK_LIBRARIES})
+
+# Options for executables with support for dynamic linking:
+# - Position-independent code disabled
+# - GP-relative addressing disabled
+# - ABI-compatible calls disabled (must be performed manually)
+set(_aflags -G0)
+set(_cflags -mno-abicalls -mno-gpopt)
+set(_cxxflags)
+set(_ldflags -G0 -static)
+
+_add_interface_target(psn00bsdk_dynamic_exe psn00bsdk_common ${PSN00BSDK_LIBRARIES})
+
+# Options for static libraries:
+# - GP-relative addressing disabled
+# - ABI-compatible calls disabled
+# - Local stripping enabled
+set(_aflags -G0 -Wa,--strip-local-absolute)
+set(_cflags -mno-abicalls -mno-gpopt)
+set(_cxxflags)
+set(_ldflags)
+
+_add_interface_target(psn00bsdk_static_lib psn00bsdk_common)
+
+# Options for dynamically-loaded libraries:
+# - Position-independent code enabled
+# - GP-relative addressing disabled (incompatible with ABI calls)
+# - ABI-compatible calls enabled
+set(_aflags -G0)
+set(_cflags -mabicalls -mshared -mno-gpopt -fPIC)
+set(_cxxflags)
+set(_ldflags -G0 -shared)
+
+_add_interface_target(psn00bsdk_shared_lib psn00bsdk_common)
+_add_alias_target (psn00bsdk_module_lib psn00bsdk_shared_lib)
diff --git a/libpsn00b/include/dlfcn.h b/libpsn00b/include/dlfcn.h
index 5fdd343..0c51821 100644
--- a/libpsn00b/include/dlfcn.h
+++ b/libpsn00b/include/dlfcn.h
@@ -119,7 +119,7 @@ void DL_SetResolveCallback(void *(*callback)(DLL *, const char *));
*
* The third argument specifies when symbols in the DLL should be resolved.
* Setting it to RTLD_LAZY defers resolution of undefined functions to when
- * they are first called, while RTLD_DEFAULT forces all symbols to be resolved
+ * they are first called, while RTLD_NOW forces all symbols to be resolved
* immediately. If a custom resolver has been set via DL_SetResolveCallback(),
* it will be called for each symbol to resolve.
*
diff --git a/libpsn00b/include/lzp/lzp.h b/libpsn00b/include/lzp/lzp.h
new file mode 100644
index 0000000..cfeeb72
--- /dev/null
+++ b/libpsn00b/include/lzp/lzp.h
@@ -0,0 +1,223 @@
+/*! \file lzp.h
+ * \brief Main library header
+ */
+
+/*! \mainpage
+ * \version 0.20b
+ * \author John Wilbert 'Lameguy64' Villamor
+ *
+ * \section creditsSection Credits
+ * - LZ77 data compression/decompression routines based from Ilya Muravyov's
+ * crush.cpp released under public domain. Refined and ported to C by Lameguy64.
+ * - CRC calculation routines based from Lammert Bies' lib_crc routines.
+ *
+ */
+
+#ifndef _LZPACK_H
+#define _LZPACK_H
+
+#include <sys/types.h>
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+/*! \addtogroup crcBaseRemainders CRC Base Remainder Values
+ * @{
+ */
+//! Initial remainder value for lzCRC16()
+#define LZP_CRC16_REMAINDER 0x0000
+//! Initial remainder value for lzCRC32()
+#define LZP_CRC32_REMAINDER 0xFFFFFFFF
+/*! @} */
+
+
+/*! \addtogroup compLevels Compression Levels
+ * \brief Compression levels for the lzCompress() function.
+ * @{
+ */
+//! Minimal (but fast) compression
+#define LZP_COMPRESS_FAST 0
+//! Normal compression level
+#define LZP_COMPRESS_NORMAL 1
+//! Maximum compression level
+#define LZP_COMPRESS_MAX 2
+/*! @} */
+
+
+/*! \addtogroup libraryErrorCodes Library Error Codes
+ * @{
+ */
+//! No error
+#define LZP_ERR_NONE 0
+//! Decompression error
+#define LZP_ERR_DECOMPRESS -1
+//! Not a valid LZP/QLP/PCK archive
+#define LZP_ERR_INVALID_PACK -2
+//! File not found
+#define LZP_ERR_NOTFOUND -3
+//! CRC check mismatch (data corruption)
+#define LZP_ERR_CRC_MISMATCH -4
+/*! @} */
+
+
+//! Header structure of an LZP format archive file
+typedef struct {
+
+ //! File ID (must always be 'LZP')
+ char id[3];
+ //! File count
+ u_char numFiles;
+
+} LZP_HEAD;
+
+//! File entry structure for an LZP format archive file
+typedef struct {
+
+ //! File name
+ char fileName[16];
+ //! CRC32 checksum of file
+ u_int crc;
+ //! Original size of file in bytes
+ u_int fileSize;
+ //! Compressed size of file
+ u_int packedSize;
+ //! File data offset
+ u_int offset;
+
+} LZP_FILE;
+
+
+// Function prototypes
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*! \addtogroup compressFuncs Data Compression and Decompression Functions
+ * \brief Functions to compress and decompress data.
+ * @{
+ */
+
+/*! Compress a block of data.
+ *
+ * \details This function compresses a specified block of data in LZ77 encoding.
+ * Depending on the size of the input data and speed of the computer, compression
+ * may take a while to complete.
+ *
+ * \param[out] *outBuff Pointer to buffer to store compressed data.
+ * \param[in] *inBuff Pointer to data to compress.
+ * \param[in] inSize Size of data to compress in bytes.
+ * \param[in] level Compression level (see \ref compLevels).
+ *
+ * \returns The size of the compressed data in bytes.
+ */
+int lzCompress(void* outBuff, const void* inBuff, int inSize, int level);
+
+/*! Decompress a compressed block of data.
+ *
+ * \details Decompressed a compressed block of data produced by lzCompress(). It cannot
+ * return the decompressed size of the data ahead of time so you must preserve the decompressed
+ * size of the data yourself.
+ *
+ * \note The decompression algorithm used in this function is completely independent
+ * of the compression settings set by lzSetHashSizes() before compressing the data with
+ * lzCompress().
+ *
+ * \param[out] *outBuff Pointer to buffer to store decompressed data.
+ * \param[in] *inBuff Pointer to compressed data to decompress.
+ * \param[in] inSize Compressed data size in bytes.
+ *
+ * \returns Size of decompressed data in bytes or LZP_ERR_DECOMPRESS if a
+ * decompression error occurred.
+ */
+int lzDecompress(void* outBuff, const void* inBuff, int inSize);
+
+int lzDecompressLen(void* outBuff, int outSize, const void* inBuff, int inSize);
+
+/*! Sets the sizes of hash tables for data compression.
+ *
+ * \param[in] window Sliding window size.
+ * \param[in] hash1 Hash table 1 size.
+ * \param[in] hash2 Hash table 2 size.
+ */
+void lzSetHashSizes(int window, int hash1, int hash2);
+
+/*! Reset the sizes of hash tables to their defaults.
+ */
+void lzResetHashSizes();
+
+/*! @} */
+
+
+/*! \addtogroup crcFuncs CRC Hashing Functions
+ * \brief Functions to calculate CRC hashes of data.
+ * @{
+ */
+
+/*! Calculates a CRC16 hash of the specified buffer.
+ *
+ * \param[in] *buff Pointer to buffer to calculate a hash of.
+ * \param[in] bytes Size of buffer in bytes.
+ * \param[in] crc CRC remainder (use LZP_CRC16_REMAINDER).
+ *
+ * \returns CRC16 hash of specified buffer.
+ */
+unsigned short lzCRC16(const void* buff, int bytes, unsigned short crc);
+
+/*! Calculates a CRC32 hash of the specified buffer.
+ *
+ * \param[in] *buff Pointer to buffer to calculate a hash of.
+ * \param[in] bytes Size of buffer in bytes.
+ * \param[in] crc CRC remainder (use LZP_CRC16_REMAINDER).
+ *
+ * \returns CRC32 hash of specified buffer.
+ */
+unsigned int lzCRC32(const void* buff, int bytes, unsigned int crc);
+
+/*! @} */
+
+
+/*! \addtogroup lzpFunctions LZP Archive Handling Routines
+ * \brief Functions to index and unpack files from LZP archives.
+ * @{
+ */
+
+/*! Searches for a file by name in an LZP archive and returns a file entry number.
+ *
+ * \param[in] *fileName String of file to search (must be less than 13 characters).
+ * \param[in] *lzpack Pointer to LZP archive file.
+ *
+ * \returns File index of found file or one of \ref libraryErrorCodes if an error occurred.
+ */
+int lzpSearchFile(const char* fileName, const LZP_HEAD* lzpack);
+
+int lzpFileSize(const LZP_HEAD* lzpack, int fileNum);
+
+/*! Get a pointer to a file entry inside of an LZP archive.
+ *
+ * \param[in] *lzpack Pointer to LZP archive file.
+ * \param[in] fileNum File number to get an entry of (you may use lzpSearchFile()).
+ *
+ * \returns A pointer to an LZP_FILE struct or NULL if an error occurred.
+ */
+const LZP_FILE* lzpFileEntry(const LZP_HEAD* lzpack, int fileNum);
+
+/*! Unpacks a file from an LZP archive to the specified memory buffer.
+ *
+ * \param[in] *buff Pointer to buffer to store unpacked file.
+ * \param[in] *lzpack Pointer to LZP archive file.
+ * \param[in] fileNum File entry number of file to extract (you may use lzpSearchFile()).
+ *
+ * \returns Size of decompressed file in bytes or one of \ref libraryErrorCodes if an error occurred.
+ */
+int lzpUnpackFile(void* buff, const LZP_HEAD* lzpack, int fileNum);
+
+/*! @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LZPACK_H
diff --git a/libpsn00b/include/lzp/lzqlp.h b/libpsn00b/include/lzp/lzqlp.h
new file mode 100644
index 0000000..5b70b40
--- /dev/null
+++ b/libpsn00b/include/lzp/lzqlp.h
@@ -0,0 +1,31 @@
+#ifndef _QLP_H
+#define _QLP_H
+
+#include <sys/types.h>
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+#define PACK_ERR_NONE 0
+#define PACK_ERR_INVALID -1
+#define PACK_ERR_NOTFOUND -2
+#define PACK_ERR_INCOMPLETE -3
+#define PACK_ERR_READ_FAULT -4
+
+typedef struct {
+ char id[3];
+ u_char numfiles;
+} QLP_HEAD;
+
+typedef struct {
+ char name[16];
+ u_int size;
+ u_int offs;
+} QLP_FILE;
+
+int qlpFileCount(const QLP_HEAD* qlpfile);
+const QLP_FILE* qlpFileEntry(int index, const QLP_HEAD* qlpfile);
+const void* qlpFileAddr(int index, const QLP_HEAD* qlpfile);
+int qlpFindFile(char* fileName, const QLP_HEAD* qlpfile);
+
+#endif // _QLP_H \ No newline at end of file
diff --git a/libpsn00b/libc/makefile b/libpsn00b/libc/makefile
deleted file mode 100644
index bb3a687..0000000
--- a/libpsn00b/libc/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libc.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- # "Import" libgcc's contents
- cp $(GCC_BASE)/lib/gcc/$(PREFIX)/$(GCC_VERSION)/libgcc.a ./$@
- $(AR) rs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/lzp/bit.c b/libpsn00b/lzp/bit.c
index aefa45d..9678357 100644
--- a/libpsn00b/lzp/bit.c
+++ b/libpsn00b/lzp/bit.c
@@ -3,7 +3,7 @@
// Bit I/O
//
-unsigned char* inPtr = 0;
+const unsigned char* inPtr = 0;
int inBytes = 0;
unsigned char* outPtr = 0;
int outBytes = 0;
diff --git a/libpsn00b/lzp/bit.h b/libpsn00b/lzp/bit.h
index ff71025..321160a 100644
--- a/libpsn00b/lzp/bit.h
+++ b/libpsn00b/lzp/bit.h
@@ -1,7 +1,7 @@
#ifndef _LZP_BIT_H
#define _LZP_BIT_H
-extern unsigned char* inPtr;
+extern const unsigned char* inPtr;
extern int inBytes;
extern unsigned char* outPtr;
extern int outBytes;
diff --git a/libpsn00b/lzp/compress.c b/libpsn00b/lzp/compress.c
index 5f2b78c..5969dd6 100644
--- a/libpsn00b/lzp/compress.c
+++ b/libpsn00b/lzp/compress.c
@@ -107,7 +107,7 @@ int get_penalty(int a, int b) {
}
-int lzCompress(void* outBuff, void* inBuff, int inSize, int level) {
+int lzCompress(void* outBuff, const void* inBuff, int inSize, int level) {
#if LZP_USE_MALLOC == FALSE
int head[HASH1_SIZE+HASH2_SIZE];
@@ -347,7 +347,7 @@ void lzResetHashSizes() {
#endif // LZP_NO_COMPRESS
-int lzDecompress(void* outBuff, void* inBuff, int inSize) {
+int lzDecompress(void* outBuff, const void* inBuff, int inSize) {
int p=0;
int len;
@@ -355,7 +355,7 @@ int lzDecompress(void* outBuff, void* inBuff, int inSize) {
int s;
int windowSize;
- inPtr = (unsigned char*)inBuff;
+ inPtr = (const unsigned char*)inBuff;
outPtr = (unsigned char*)outBuff;
inBytes = 0;
outBytes = 0;
@@ -408,7 +408,7 @@ int lzDecompress(void* outBuff, void* inBuff, int inSize) {
}
-int lzDecompressLen(void* outBuff, int outSize, void* inBuff, int inSize) {
+int lzDecompressLen(void* outBuff, int outSize, const void* inBuff, int inSize) {
int p=0;
int len;
@@ -416,7 +416,7 @@ int lzDecompressLen(void* outBuff, int outSize, void* inBuff, int inSize) {
int s;
int windowSize;
- inPtr = (unsigned char*)inBuff;
+ inPtr = (const unsigned char*)inBuff;
outPtr = (unsigned char*)outBuff;
inBytes = 0;
outBytes = 0;
diff --git a/libpsn00b/lzp/crc.c b/libpsn00b/lzp/crc.c
index c5ab702..3c1ae57 100644
--- a/libpsn00b/lzp/crc.c
+++ b/libpsn00b/lzp/crc.c
@@ -49,7 +49,7 @@ void initTable32(unsigned int* table) {
}
-unsigned short lzCRC16(void* buff, int bytes, unsigned short crc) {
+unsigned short lzCRC16(const void* buff, int bytes, unsigned short crc) {
int i;
unsigned short tmp, short_c;
@@ -59,7 +59,7 @@ unsigned short lzCRC16(void* buff, int bytes, unsigned short crc) {
for(i=0; i<bytes; i++) {
- short_c = 0x00ff & (unsigned short)((unsigned char*)buff)[i];
+ short_c = 0x00ff & (unsigned short)((const unsigned char*)buff)[i];
tmp = crc ^ short_c;
crc = (crc >> 8) ^ crcTable[tmp&0xff];
@@ -70,12 +70,12 @@ unsigned short lzCRC16(void* buff, int bytes, unsigned short crc) {
}
-unsigned int lzCRC32(void* buff, int bytes, unsigned int crc) {
+unsigned int lzCRC32(const void* buff, int bytes, unsigned int crc) {
int i;
- unsigned char* byteBuff = (unsigned char*)buff;
- unsigned int byte;
- unsigned int crcTable[256];
+ const unsigned char* byteBuff = (const unsigned char*)buff;
+ unsigned int byte;
+ unsigned int crcTable[256];
initTable32(crcTable);
diff --git a/libpsn00b/lzp/lzp.c b/libpsn00b/lzp/lzp.c
index 1f4fea4..9f2da48 100644
--- a/libpsn00b/lzp/lzp.c
+++ b/libpsn00b/lzp/lzp.c
@@ -17,7 +17,7 @@ static char* lcase(char* text) {
}
-int lzpSearchFile(const char* fileName, void* lzpack) {
+int lzpSearchFile(const char* fileName, const LZP_HEAD* lzpack) {
int i;
char searchName[16];
@@ -27,8 +27,8 @@ int lzpSearchFile(const char* fileName, void* lzpack) {
strcpy(searchName, fileName);
lcase(searchName);
- fileEntry = (LZP_FILE*)(lzpack+4);
- for(i=0; i<((LZP_HEAD*)lzpack)->numFiles; i++) {
+ fileEntry = (LZP_FILE*)(((const char*)lzpack)+sizeof(LZP_HEAD));
+ for(i=0; i<(lzpack->numFiles); i++) {
strcpy(compareName, fileEntry[i].fileName);
lcase(compareName);
@@ -42,44 +42,44 @@ int lzpSearchFile(const char* fileName, void* lzpack) {
}
-LZP_FILE* lzpFileEntry(void* lzpack, int fileNum) {
+const LZP_FILE* lzpFileEntry(const LZP_HEAD* lzpack, int fileNum) {
- if (strncmp("LZP", ((LZP_HEAD*)lzpack)->id, 3) != 0)
+ if (strncmp("LZP", lzpack->id, 3) != 0)
return(NULL);
- if ((fileNum < 0) || (fileNum > (((LZP_HEAD*)lzpack)->numFiles-1)))
+ if ((fileNum < 0) || (fileNum > (lzpack->numFiles-1)))
return(NULL);
- return(&((LZP_FILE*)(lzpack+4))[fileNum]);
+ return &((LZP_FILE*)(((const char*)lzpack)+sizeof(LZP_HEAD)))[fileNum];
}
-int lzpFileSize(void* lzpack, int fileNum) {
+int lzpFileSize(const LZP_HEAD* lzpack, int fileNum) {
- if (strncmp("LZP", ((LZP_HEAD*)lzpack)->id, 3) != 0)
+ if (strncmp("LZP", lzpack->id, 3) != 0)
return 0;
- if ((fileNum < 0) || (fileNum > (((LZP_HEAD*)lzpack)->numFiles-1)))
+ if ((fileNum < 0) || (fileNum > (lzpack->numFiles-1)))
return 0;
- return ((LZP_FILE*)(lzpack+4))[fileNum].fileSize;
+ return ((LZP_FILE*)(((const char*)lzpack)+sizeof(LZP_HEAD)))[fileNum].fileSize;
}
-int lzpUnpackFile(void* buff, void* lzpack, int fileNum) {
+int lzpUnpackFile(void* buff, const LZP_HEAD* lzpack, int fileNum) {
- LZP_FILE* fileEntry = &((LZP_FILE*)(lzpack+4))[fileNum];
+ LZP_FILE* fileEntry = &((LZP_FILE*)(((const char*)lzpack)+sizeof(LZP_HEAD)))[fileNum];
int unpackedSize;
// Check ID header
- if (strncmp("LZP", ((LZP_HEAD*)lzpack)->id, 3) != 0)
+ if (strncmp("LZP", lzpack->id, 3) != 0)
return(LZP_ERR_INVALID_PACK);
// Do a CRC16 check of the compressed data's integrity
- if (lzCRC32(lzpack+fileEntry->offset, fileEntry->packedSize, LZP_CRC32_REMAINDER) != fileEntry->crc)
+ if (lzCRC32(((const char*)lzpack)+fileEntry->offset, fileEntry->packedSize, LZP_CRC32_REMAINDER) != fileEntry->crc)
return(LZP_ERR_CRC_MISMATCH);
// Decompress data to the specified address
- unpackedSize = lzDecompress(buff, lzpack+fileEntry->offset, fileEntry->packedSize);
+ unpackedSize = lzDecompress(buff, ((const char*)lzpack)+fileEntry->offset, fileEntry->packedSize);
if (unpackedSize < 0)
return(unpackedSize);
diff --git a/libpsn00b/lzp/lzp.h b/libpsn00b/lzp/lzp.h
index ffd7933..cfeeb72 100644
--- a/libpsn00b/lzp/lzp.h
+++ b/libpsn00b/lzp/lzp.h
@@ -111,7 +111,7 @@ extern "C" {
*
* \returns The size of the compressed data in bytes.
*/
-int lzCompress(void* outBuff, void* inBuff, int inSize, int level);
+int lzCompress(void* outBuff, const void* inBuff, int inSize, int level);
/*! Decompress a compressed block of data.
*
@@ -130,9 +130,9 @@ int lzCompress(void* outBuff, void* inBuff, int inSize, int level);
* \returns Size of decompressed data in bytes or LZP_ERR_DECOMPRESS if a
* decompression error occurred.
*/
-int lzDecompress(void* outBuff, void* inBuff, int inSize);
+int lzDecompress(void* outBuff, const void* inBuff, int inSize);
-int lzDecompressLen(void* outBuff, int outSize, void* inBuff, int inSize);
+int lzDecompressLen(void* outBuff, int outSize, const void* inBuff, int inSize);
/*! Sets the sizes of hash tables for data compression.
*
@@ -162,7 +162,7 @@ void lzResetHashSizes();
*
* \returns CRC16 hash of specified buffer.
*/
-unsigned short lzCRC16(void* buff, int bytes, unsigned short crc);
+unsigned short lzCRC16(const void* buff, int bytes, unsigned short crc);
/*! Calculates a CRC32 hash of the specified buffer.
*
@@ -172,7 +172,7 @@ unsigned short lzCRC16(void* buff, int bytes, unsigned short crc);
*
* \returns CRC32 hash of specified buffer.
*/
-unsigned int lzCRC32(void* buff, int bytes, unsigned int crc);
+unsigned int lzCRC32(const void* buff, int bytes, unsigned int crc);
/*! @} */
@@ -189,9 +189,9 @@ unsigned int lzCRC32(void* buff, int bytes, unsigned int crc);
*
* \returns File index of found file or one of \ref libraryErrorCodes if an error occurred.
*/
-int lzpSearchFile(const char* fileName, void* lzpack);
+int lzpSearchFile(const char* fileName, const LZP_HEAD* lzpack);
-int lzpFileSize(void* lzpack, int fileNum);
+int lzpFileSize(const LZP_HEAD* lzpack, int fileNum);
/*! Get a pointer to a file entry inside of an LZP archive.
*
@@ -200,7 +200,7 @@ int lzpFileSize(void* lzpack, int fileNum);
*
* \returns A pointer to an LZP_FILE struct or NULL if an error occurred.
*/
-LZP_FILE* lzpFileEntry(void* lzpack, int fileNum);
+const LZP_FILE* lzpFileEntry(const LZP_HEAD* lzpack, int fileNum);
/*! Unpacks a file from an LZP archive to the specified memory buffer.
*
@@ -210,7 +210,7 @@ LZP_FILE* lzpFileEntry(void* lzpack, int fileNum);
*
* \returns Size of decompressed file in bytes or one of \ref libraryErrorCodes if an error occurred.
*/
-int lzpUnpackFile(void* buff, void* lzpack, int fileNum);
+int lzpUnpackFile(void* buff, const LZP_HEAD* lzpack, int fileNum);
/*! @} */
diff --git a/libpsn00b/lzp/lzqlp.h b/libpsn00b/lzp/lzqlp.h
index fae6438..5b70b40 100644
--- a/libpsn00b/lzp/lzqlp.h
+++ b/libpsn00b/lzp/lzqlp.h
@@ -1,6 +1,11 @@
#ifndef _QLP_H
#define _QLP_H
+#include <sys/types.h>
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
#define PACK_ERR_NONE 0
#define PACK_ERR_INVALID -1
#define PACK_ERR_NOTFOUND -2
@@ -8,19 +13,19 @@
#define PACK_ERR_READ_FAULT -4
typedef struct {
- char id[3];
- unsigned char numfiles;
+ char id[3];
+ u_char numfiles;
} QLP_HEAD;
typedef struct {
- char name[16];
- unsigned int size;
- unsigned int offs;
+ char name[16];
+ u_int size;
+ u_int offs;
} QLP_FILE;
-int qlpFileCount(void* qlpfile);
-QLP_FILE* qlpFileEntry(int index, void* qlpfile);
-void* qlpFileAddr(int index, void* qlpfile);
-int qlpFindFile(char* fileName, void* qlpfile);
+int qlpFileCount(const QLP_HEAD* qlpfile);
+const QLP_FILE* qlpFileEntry(int index, const QLP_HEAD* qlpfile);
+const void* qlpFileAddr(int index, const QLP_HEAD* qlpfile);
+int qlpFindFile(char* fileName, const QLP_HEAD* qlpfile);
#endif // _QLP_H \ No newline at end of file
diff --git a/libpsn00b/lzp/makefile b/libpsn00b/lzp/makefile
deleted file mode 100644
index 02654ed..0000000
--- a/libpsn00b/lzp/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = liblzp.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/lzp/qlp.c b/libpsn00b/lzp/qlp.c
index 3be8356..e54f99f 100644
--- a/libpsn00b/lzp/qlp.c
+++ b/libpsn00b/lzp/qlp.c
@@ -14,34 +14,34 @@ static char* lcase(char* str) {
}
-int qlpFileCount(void* qlpfile) {
+int qlpFileCount(const QLP_HEAD* qlpfile) {
- if (strncmp(((QLP_HEAD*)qlpfile)->id, "QLP", 3) != 0)
+ if (strncmp(qlpfile->id, "QLP", 3) != 0)
return(PACK_ERR_INVALID);
- return(((QLP_HEAD*)qlpfile)->numfiles);
+ return(qlpfile->numfiles);
}
-QLP_FILE* qlpFileEntry(int index, void* qlpfile) {
+const QLP_FILE* qlpFileEntry(int index, const QLP_HEAD* qlpfile) {
- if (strncmp(((QLP_HEAD*)qlpfile)->id, "QLP", 3) != 0)
+ if (strncmp(qlpfile->id, "QLP", 3) != 0)
return(NULL);
- if (index > ((QLP_HEAD*)qlpfile)->numfiles)
+ if (index > qlpfile->numfiles)
return(NULL);
- return(&((QLP_FILE*)(qlpfile+4))[index]);
+ return(&((QLP_FILE*)(((const char*)qlpfile)+sizeof(QLP_HEAD)))[index]);
}
-void* qlpFileAddr(int index, void* qlpfile) {
+const void* qlpFileAddr(int index, const QLP_HEAD* qlpfile) {
- return( qlpfile+((QLP_FILE*)(qlpfile+4))[index].offs );
+ return( ((const char*)qlpfile)+((QLP_FILE*)(((const char*)qlpfile)+sizeof(QLP_HEAD)))[index].offs );
}
-int qlpFindFile(char* fileName, void* qlpfile) {
+int qlpFindFile(char* fileName, const QLP_HEAD* qlpfile) {
int i;
char nameBuff[2][16];
@@ -49,9 +49,9 @@ int qlpFindFile(char* fileName, void* qlpfile) {
strcpy(nameBuff[0], fileName);
lcase(nameBuff[0]);
- for(i=0; i<((QLP_HEAD*)qlpfile)->numfiles; i++) {
+ for(i=0; i<(qlpfile->numfiles); i++) {
- strcpy(nameBuff[1], ((QLP_FILE*)(qlpfile+4))[i].name);
+ strcpy(nameBuff[1], ((QLP_FILE*)(((const char*)qlpfile)+sizeof(QLP_HEAD)))[i].name);
lcase(nameBuff[1]);
if (strcmp(nameBuff[0], nameBuff[1]) == 0)
diff --git a/libpsn00b/makefile b/libpsn00b/makefile
deleted file mode 100644
index c2cf62f..0000000
--- a/libpsn00b/makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# Run using make (Linux) or gmake (BSD)
-# Part of the PSn00bSDK Project
-# 2019 - 2020 Lameguy64 / Meido-Tek Productions
-
-TOPTARGETS = all clean
-
-LIBS = libc psxgpu psxapi psxgte psxcd psxetc psxsio psxspu lzp
-
-$(TOPTARGETS): $(LIBS)
-
-install: $(LIBS)
-ifdef PSN00BSDK_LIBS
-ifneq ($(CURDIR),$(PSN00BSDK_LIBS)) # needs a better method
- cp -R include $(PSN00BSDK_LIBS)/include
-endif
-endif
-
-clean: $(LIBS)
-
-$(LIBS):
- @$(MAKE) -C $@ $(MAKECMDGOALS)
-
-.PHONY: $(TOPTARGETS) $(LIBS)
diff --git a/libpsn00b/psxapi/makefile b/libpsn00b/psxapi/makefile
deleted file mode 100644
index f300e5f..0000000
--- a/libpsn00b/psxapi/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxapi.a
-
-## Files
-
-SOURCES = stdio fs sys
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
-CXXFILES= $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cxx))
-AFILES = $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/psxcd/makefile b/libpsn00b/psxcd/makefile
deleted file mode 100644
index ee9b958..0000000
--- a/libpsn00b/psxcd/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxcd.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/psxetc/dl.c b/libpsn00b/psxetc/dl.c
index 1485183..e405efc 100644
--- a/libpsn00b/psxetc/dl.c
+++ b/libpsn00b/psxetc/dl.c
@@ -35,7 +35,7 @@
/* Compile options */
// Uncomment before building to enable debug logging (via printf()).
-#define DEBUG
+//#define DEBUG
// Comment before building to disable functions that rely on BIOS file APIs,
// i.e. DL_LoadSymbolMap() and dlopen().
diff --git a/libpsn00b/psxetc/makefile b/libpsn00b/psxetc/makefile
deleted file mode 100644
index 84bb64b..0000000
--- a/libpsn00b/psxetc/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxetc.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/psxgpu/makefile b/libpsn00b/psxgpu/makefile
deleted file mode 100644
index adcb7fa..0000000
--- a/libpsn00b/psxgpu/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxgpu.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/psxgte/makefile b/libpsn00b/psxgte/makefile
deleted file mode 100644
index e60ff1e..0000000
--- a/libpsn00b/psxgte/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxgte.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/psxsio/makefile b/libpsn00b/psxsio/makefile
deleted file mode 100644
index c9dcade..0000000
--- a/libpsn00b/psxsio/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxsio.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/psxspu/makefile b/libpsn00b/psxspu/makefile
deleted file mode 100644
index 5710f39..0000000
--- a/libpsn00b/psxspu/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# PSn00bSDK library makefile
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-PSN00BSDK_LIBS ?= ..
-
-include ../../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = libpsxspu.a
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CXXFILES= $(notdir $(wildcard *.cxx))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CXXFILES:.cxx=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: build/$(TARGET)
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(AR) crs $@ $(OFILES)
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cxx
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
-
-install:
-ifneq ($(PSN00BSDK_LIBS), "..")
- @mkdir -p $(PSN00BSDK_LIBS)
-endif
- cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
-clean:
- rm -rf build
diff --git a/libpsn00b/readme.txt b/libpsn00b/readme.txt
index 940746c..9f6ebc6 100644
--- a/libpsn00b/readme.txt
+++ b/libpsn00b/readme.txt
@@ -49,7 +49,7 @@ Brief summary of libraries:
must be covered in the changelog.txt file.
-Compiling:
+Compiling (OUTDATED):
To compile the LibPSn00b libraries, you will first need a working GCC
toolchain which you can either build yourself as described in the
diff --git a/psn00bsdk-setup.mk b/psn00bsdk-setup.mk
deleted file mode 100644
index 8417358..0000000
--- a/psn00bsdk-setup.mk
+++ /dev/null
@@ -1,121 +0,0 @@
-# PSn00bSDK project setup file
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-#
-# This file does not depend on any other files (besides paths specified via
-# environment variables) and may be copied for use with your projects. See the
-# template directory for a makefile template.
-
-#PREFIX ?= mipsel-none-elf
-PREFIX ?= mipsel-unknown-elf
-
-## Path setup
-
-# PSn00bSDK library/include path setup
-ifndef PSN00BSDK_LIBS
- # Default assumes PSn00bSDK is in the same parent dir as this project
- LIBDIRS = -L../libpsn00b
- INCLUDE = -I../libpsn00b/include -I../libpsn00b/lzp
- LDBASE = ../libpsn00b/ldscripts
-else
- LIBDIRS = -L$(PSN00BSDK_LIBS)
- INCLUDE = -I$(PSN00BSDK_LIBS)/include -I$(PSN00BSDK_LIBS)/lzp
- LDBASE = ${PSN00BSDK_LIBS}/ldscripts
-endif
-
-# PSn00bSDK toolchain path setup
-ifndef PSN00BSDK_TC
- # Default assumes GCC toolchain is in root of C drive or /usr/local
- ifeq "$(OS)" "Windows_NT"
- GCC_BASE ?= /c/$(PREFIX)
- GCC_BIN ?=
- else
- GCC_BASE ?= /usr/local/$(PREFIX)
- GCC_BIN ?=
- endif
-else
- GCC_BASE ?= $(PSN00BSDK_TC)
- GCC_BIN ?= $(PSN00BSDK_TC)/bin/
-endif
-
-# Autodetect GCC version by folder name (ugly but it works, lol)
-#GCC_VERSION ?= 7.4.0
-GCC_VERSION ?= $(word 1, $(notdir $(wildcard $(GCC_BASE)/lib/gcc/$(PREFIX)/*)))
-
-# PSn00bSDK tools path setup (TODO)
-PSN00BSDK_BIN ?=
-
-## Commands
-
-# GCC toolchain
-CC = $(GCC_BIN)$(PREFIX)-gcc
-CXX = $(GCC_BIN)$(PREFIX)-g++
-AS = $(GCC_BIN)$(PREFIX)-as
-AR = $(GCC_BIN)$(PREFIX)-ar
-LD = $(GCC_BIN)$(PREFIX)-ld
-RANLIB = $(GCC_BIN)$(PREFIX)-ranlib
-OBJCOPY = $(GCC_BIN)$(PREFIX)-objcopy
-NM = $(GCC_BIN)$(PREFIX)-nm
-
-# PSn00bSDK tools + mkpsxiso
-ELF2X = $(PSN00BSDK_BIN)elf2x
-LZPACK = $(PSN00BSDK_BIN)lzpack
-SMXLINK = $(PSN00BSDK_BIN)smxlink
-MKPSXISO = $(PSN00BSDK_BIN)mkpsxiso
-
-## Flags
-
-# SDK libraries (IMPORTANT: don't change the order)
-LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxcd -lpsxsio -lpsxetc -lpsxapi -lc
-
-# Common options:
-# - Debugging symbols enabled
-# - Wrap each symbol in a separate section
-# - Optimize for R3000, no FPU, 32-bit ABI
-# - Division by zero causes break opcodes to be executed
-# - C standard library (including libgcc) disabled
-# - C++ features that rely on runtime support disabled
-AFLAGS = -g -msoft-float -march=r3000 -mtune=r3000 -mabi=32
-CFLAGS = $(AFLAGS) -mdivide-breaks -O2 -ffreestanding -fno-builtin -nostdlib \
- -fdata-sections -ffunction-sections -fsigned-char -fno-strict-overflow
-CPPFLAGS= $(CFLAGS) -fno-exceptions -fno-rtti -fno-unwind-tables \
- -fno-threadsafe-statics -fno-use-cxa-atexit
-LDFLAGS = -nostdlib
-
-# Options for static libraries (and SDK libraries):
-# - GP-relative addressing disabled
-# - ABI-compatible calls disabled
-# - Local stripping enabled
-AFLAGS_LIB = $(AFLAGS) -G0 -Wa,--strip-local-absolute
-CFLAGS_LIB = $(CFLAGS) -G0 -mno-abicalls -mno-gpopt
-CPPFLAGS_LIB = $(CPPFLAGS) -G0 -mno-abicalls -mno-gpopt
-
-# Options for executables without support for dynamic linking:
-# - Position-independent code disabled
-# - GP-relative addressing enabled only for local symbols
-# - ABI-compatible calls disabled (incompatible with GP-relative addressing)
-# - Unused section stripping enabled
-AFLAGS_EXE = $(AFLAGS) -G8
-CFLAGS_EXE = $(CFLAGS) -G8 -mno-abicalls -mgpopt -mno-extern-sdata
-CPPFLAGS_EXE = $(CPPFLAGS) -G8 -mno-abicalls -mgpopt -mno-extern-sdata
-LDFLAGS_EXE = $(LDFLAGS) -G8 -static -T$(LDBASE)/exe.ld -gc-sections
-
-# Options for executables with support for dynamic linking:
-# - Position-independent code disabled
-# - GP-relative addressing disabled
-# - ABI-compatible calls disabled (must be done manually)
-# - Unused section stripping enabled
-AFLAGS_EXEDYN = $(AFLAGS) -G0
-CFLAGS_EXEDYN = $(CFLAGS) -G0 -mno-abicalls -mno-gpopt
-CPPFLAGS_EXEDYN = $(CPPFLAGS) -G0 -mno-abicalls -mno-gpopt
-LDFLAGS_EXEDYN = $(LDFLAGS) -G0 -static -T$(LDBASE)/exe.ld -gc-sections
-
-# Options for dynamically-loaded libraries:
-# - Position-independent code enabled
-# - GP-relative addressing disabled (incompatible with ABI calls)
-# - ABI-compatible calls enabled
-# - Unused section stripping not available
-AFLAGS_DLL = $(AFLAGS) -G0
-CFLAGS_DLL = $(CFLAGS) -G0 -mabicalls -mshared -mno-gpopt -fPIC
-CPPFLAGS_DLL = $(CPPFLAGS) -G0 -mabicalls -mshared -mno-gpopt -fPIC
-LDFLAGS_DLL = $(LDFLAGS) -G0 -shared -T$(LDBASE)/dll.ld
diff --git a/template/CMakeLists.txt b/template/CMakeLists.txt
new file mode 100644
index 0000000..c2d0d9d
--- /dev/null
+++ b/template/CMakeLists.txt
@@ -0,0 +1,28 @@
+# PSn00bSDK example CMake script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+# CMAKE_TOOLCHAIN_FILE must be set to point to cmake/sdk.cmake in the PSn00bSDK
+# installation directory *before* calling project(). You don't have to hardcode
+# the path in your CMakeLists.txt as you can set it from the command line when
+# configuring (-DCMAKE_TOOLCHAIN_FILE=...) or using CMake presets.
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{PSN00BSDK_LIBS})
+ set(CMAKE_TOOLCHAIN_FILE $ENV{PSN00BSDK_LIBS}/cmake/sdk.cmake)
+endif()
+
+project(
+ PSn00bSDK-template
+ LANGUAGES C CXX ASM
+ VERSION 1.0.0
+ DESCRIPTION "PSn00bSDK template"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+psn00bsdk_add_executable(template STATIC main.c)
+psn00bsdk_add_cd_image(
+ iso # Target name
+ template # Output file name (= template.bin + template.cue)
+ iso.xml # Path to config file
+ DEPENDS template
+)
diff --git a/template/iso.xml b/template/iso.xml
index ba2b29d..477c636 100644
--- a/template/iso.xml
+++ b/template/iso.xml
@@ -1,23 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
+<!--
+ This file is processed by CMake and used by mkpsxiso to build the CD image.
+
+ NOTE: all paths are relative to the build directory; if you want to include
+ a file from the source tree, you'll have to prepend its path with
+ ${PROJECT_SOURCE_DIR}.
+-->
<iso_project
- image_name="build/template.bin"
- cue_sheet="build/template.cue"
+ image_name="${CD_IMAGE_NAME}.bin"
+ cue_sheet="${CD_IMAGE_NAME}.cue"
>
<track type="data">
<identifiers
system ="PLAYSTATION"
- volume ="PSN00BSDK"
- volume_set ="PSN00BSDK"
+ volume ="PSN00BSDK_TEMPLATE"
+ volume_set ="PSN00BSDK_TEMPLATE"
publisher ="MEIDOTEK"
- data_preparer ="PSN00BSDK BUILD SCRIPT"
+ data_preparer ="PSN00BSDK ${PSN00BSDK_VERSION}"
application ="PLAYSTATION"
copyright ="README.TXT;1"
/>
<directory_tree>
- <file name="SYSTEM.CNF" type="data" source="system.cnf" />
- <file name="TEMPLATE.EXE" type="data" source="build/template.exe" />
- <file name="TEMPLATE.MAP" type="data" source="build/template.map" />
+ <file name="SYSTEM.CNF" type="data" source="${PROJECT_SOURCE_DIR}/system.cnf" />
+ <file name="TEMPLATE.EXE" type="data" source="template.exe" />
+ <file name="TEMPLATE.MAP" type="data" source="template.map" />
<dummy sectors="1024"/>
</directory_tree>
diff --git a/template/makefile b/template/makefile
deleted file mode 100644
index 707a8d7..0000000
--- a/template/makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-# PSn00bSDK makefile template
-# Part of the PSn00bSDK Project
-# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-
-## Settings
-
-# You can edit these here or pass them as environment variables.
-#PREFIX =
-#GCC_VERSION =
-#PSN00BSDK_TC =
-#PSN00BSDK_LIBS =
-
-# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's
-# root folder (it only depends on environment variables).
-include ../psn00bsdk-setup.mk
-
-# Project target name
-TARGET = template
-
-## Files
-
-# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES= $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
-
-# Create names for object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
-
-# Project specific includes and libraries
-# (use -I for include dirs, -L for library dirs, -l for static libraries)
-INCLUDE +=
-LIBDIRS +=
-LIBS +=
-
-## Build rules
-
-all: iso
-#all: build/$(TARGET)
-
-iso: build/$(TARGET) resources
- $(MKPSXISO) -y -q iso.xml
-
-resources:
- # Add commands to build/convert your assets here
- #$(LZPACK) data.xml
-
-build/$(TARGET): $(OFILES)
- @mkdir -p $(dir $@)
- $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
- $(NM) -f posix -l -n $@ >$@.map
- $(ELF2X) -q $@ $@.exe
-
-build/%.o: %.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-build/%.o: %.s
- @mkdir -p $(dir $@)
- $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -rf build
diff --git a/toolchain.txt b/toolchain.txt
index e67cfe1..d34d54b 100644
--- a/toolchain.txt
+++ b/toolchain.txt
@@ -20,12 +20,8 @@ the libgcc.a library from it to the Windows build.
Make sure the following packages are installed prior to building:
* make
-* texinfo
-* mpfr (development libs, if your distro offers it in a separate package)
-* isl (development libs, if your distro offers it in a separate package)
-* gmp (development libs, if your distro offers it in a separate package)
-* mpc (development libs, if your distro offers it in a separate package)
-* build-essential or build-essentials, if you don't have GCC installed yet.
+* build-essential or build-essentials, if you don't have GCC installed yet
+ (a host toolchain is required to build the rest of the SDK anyway).
Building binutils:
@@ -38,16 +34,17 @@ mipsel-unknown-elf.
wish to use with PSn00bSDK. The reference version that PSn00bSDK is tested
with most is 2.31.
-* Extract the contents of the archive, preferably in a directory named gcc.
+* Extract the contents of the archive, preferably in a directory named
+ "toolchain" (or whatever).
-* Create a directory named binutils-build inside the gcc directory. Do not
- create it inside the binutils directory with the source files.
+* Create a directory named binutils-build inside the toolchain directory. Do
+ not create it inside the binutils directory with the source files.
* Enter the binutils-build directory and configure binutils from there
with the following command line:
../binutils-<version>/configure --prefix=/usr/local/mipsel-unknown-elf \
---target=mipsel-unknown-elf --with-float=soft
+--target=mipsel-unknown-elf --disable-docs --disable-nls --with-float=soft
Replace <version> with the version of binutils you wish to use. You may also
want to change the prefix argument to a path you prefer to have the toolchain
@@ -73,17 +70,23 @@ longer so it's going to take a longer while to build this.
wish to use with PSn00bSDK. The reference version that PSn00bSDK is tested
with most is 7.4.0.
-* Extract it to the same gcc directory you extracted binutils in.
+* Extract it to the same toolchain directory you extracted binutils in.
-* Create a directory named gcc-build inside the gcc directory.
+* Enter the extracted "gcc-<version>" folder and run the following command
+ from there to download the required dependencies:
+
+./contrib/download_prerequisites
+
+* Go back and create a directory named gcc-build inside the toolchain
+ directory.
* Enter the gcc-build directory and configure gcc from there with the
following command line:
-../gcc-<version>/configure --disable-nls --disable-libada --disable-libssp \
---disable-libquadmath --disable-libstdc++-v3 --target=mipsel-unknown-elf \
---prefix=/usr/local/mipsel-unknown-elf --with-float=soft \
---enable-languages=c,c++ --with-gnu-as --with-gnu-ld
+../gcc-<version>/configure --prefix=/usr/local/mipsel-unknown-elf \
+--target=mipsel-unknown-elf --disable-docs --disable-nls --disable-libada \
+--disable-libssp --disable-libquadmath --disable-libstdc++-v3 \
+--with-float=soft --enable-languages=c,c++ --with-gnu-as --with-gnu-ld
Replace <version> with the version of gcc you downloaded. The prefix path
must match to what you've specified for binutils earlier, if you've decided
@@ -109,9 +112,10 @@ through System Properties.
Note regarding C++ support:
-C++ support in PSn00bSDK only goes as far as basic classes, namespaces and
-the ability to dynamically create and delete class objects at any point of
-the program. The required dependencies are supplied by libc of libpsn00b.
+C++ support in PSn00bSDK, besides compile-time features like constexpr, only
+goes as far as basic classes, namespaces and the ability to dynamically create
+and delete class objects at any point of the program. The required dependencies
+are supplied by libc of libpsn00b.
Standard C++ libraries are not implemented and likely never going to be
implemented due to bloat concerns that it may introduce. Besides, the official
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644
index 0000000..dd90109
--- /dev/null
+++ b/tools/CMakeLists.txt
@@ -0,0 +1,76 @@
+# PSn00bSDK tools build script
+# (C) 2021 spicyjpeg - MPL licensed
+
+cmake_minimum_required(VERSION 3.21)
+
+project(
+ PSn00bSDK-tools
+ LANGUAGES C CXX
+ DESCRIPTION "PSn00bSDK command-line tools"
+ HOMEPAGE_URL "http://lameguy64.net/?page=psn00bsdk"
+)
+
+include(GNUInstallDirs)
+
+## External dependencies
+
+# Let CMake attempt to find tinyxml2 on its own first. This avoids invoking
+# pkg-config where it might not be installed, and allows usage of package
+# managers like vcpkg. The path to tinyxml2 can also be specified manually by
+# passing -Dtinyxml2_ROOT.
+find_package(tinyxml2 CONFIG)
+
+if(NOT tinyxml2_FOUND)
+ find_package(PkgConfig REQUIRED)
+ pkg_search_module(_tinyxml2 REQUIRED IMPORTED_TARGET tinyxml2)
+
+ add_library(tinyxml2::tinyxml2 ALIAS PkgConfig::_tinyxml2)
+endif()
+
+## Internal dependencies
+
+# Build liblzp using sources from the libpsn00b tree. Hacky but it works.
+set(LIBPSN00B_PATH ${PROJECT_SOURCE_DIR}/../libpsn00b)
+file(
+ GLOB _sources
+ ${LIBPSN00B_PATH}/lzp/*.c
+ #${LIBPSN00B_PATH}/lzp/*.cpp
+)
+
+add_library(lzp STATIC ${_sources})
+target_include_directories(
+ lzp PUBLIC
+ lzpack/lzp
+ ${LIBPSN00B_PATH}/include/lzp
+)
+
+## Executables
+
+# This is required in order to properly link against tinyxml2 under MSVC.
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 11)
+
+add_executable(elf2x util/elf2x.c)
+add_executable(elf2cpe util/elf2cpe.c)
+add_executable(smxlink smxlink/main.cpp smxlink/timreader.cpp)
+add_executable(lzpack lzpack/main.cpp lzpack/filelist.cpp)
+target_link_libraries(smxlink tinyxml2::tinyxml2)
+target_link_libraries(lzpack tinyxml2::tinyxml2 lzp)
+
+## Installation
+
+# Install the executables alongside the tinyxml2 DLL (if any) and copy the
+# Blender SMX export plugin to the data directory (for manual installation).
+install(
+ TARGETS elf2x elf2cpe smxlink lzpack
+ RUNTIME_DEPENDENCIES
+ PRE_EXCLUDE_REGEXES ".*"
+ PRE_INCLUDE_REGEXES "tinyxml2"
+)
+install(
+ DIRECTORY plugin
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/psn00bsdk
+)
+
+include(InstallRequiredSystemLibraries)
diff --git a/tools/lzpack/filelist.h b/tools/lzpack/filelist.h
index 5351335..f6ad478 100644
--- a/tools/lzpack/filelist.h
+++ b/tools/lzpack/filelist.h
@@ -4,9 +4,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
#include <limits.h>
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
#ifndef MAX_PATH
#define MAX_PATH PATH_MAX
#endif
diff --git a/tools/lzpack/lzp/makefile b/tools/lzpack/lzp/makefile
deleted file mode 100644
index 83da67d..0000000
--- a/tools/lzpack/lzp/makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-# This LZP library builds off the lzp sources in libpsn00b/lzp. The only
-# difference is this is built with compression enabled specified in the
-# lzconfig.h file and the library is built for the host platform.
-
-TARGET = liblzp.a
-
-CFILES = $(wildcard ../../../libpsn00b/lzp/*.c)
-OFILES = $(addprefix build/, $(notdir $(CFILES:.c=.o)))
-
-INCLUDE = -I../include -I.
-
-CFLAGS = -g -O2
-
-CC = $(PREFIX)gcc
-AR = $(PREFIX)ar
-RANLIB = $(PREFIX)ranlib
-
-all: $(TARGET)
-
-$(TARGET): $(OFILES)
- $(AR) cr $(TARGET) $(OFILES)
- $(RANLIB) $(TARGET)
-
-# Dunno if there's a better way to do this but it works at least
-build/%.o: ../../../libpsn00b/lzp/%.c
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
-
-clean:
- rm -Rf build $(TARGET) \ No newline at end of file
diff --git a/tools/lzpack/main.cpp b/tools/lzpack/main.cpp
index 801cdd1..506b76c 100644
--- a/tools/lzpack/main.cpp
+++ b/tools/lzpack/main.cpp
@@ -1,8 +1,8 @@
#include <stdio.h>
#include <tinyxml2.h>
-#include "lzp/lzconfig.h"
-#include "lzp/lzp.h"
+#include "lzconfig.h"
+#include "lzp.h"
#include "filelist.h"
@@ -151,11 +151,10 @@ int main(int argc, const char* argv[]) {
int CreateLZPfile(const char* packFile, FileListClass* fileList) {
FILE* packp;
- LZP_FILE entry[fileList->EntryCount()];
+ LZP_FILE* entry=new LZP_FILE[fileList->EntryCount()];
int overallSize=0;
int overallPackedSize=0;
-
packp = fopen(packFile, "wb");
fseek(packp, sizeof(LZP_HEAD)+(sizeof(LZP_FILE)*fileList->EntryCount()), SEEK_SET);
@@ -179,6 +178,7 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) {
printf("ERROR: Entry '%s' has more than 15 characters.\n", name);
fclose(packp);
unlink(packFile);
+ delete[] entry;
return(0);
@@ -199,13 +199,13 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) {
int fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
- void* fileBuff = malloc(fileSize);
+ char* fileBuff = new char[fileSize];
fread(fileBuff, fileSize, 1, fp);
fclose(fp);
- void* compBuff = malloc(fileSize+16384);
+ char* compBuff = new char[fileSize+16384];
int compSize = lzCompress(compBuff, fileBuff, fileSize, 2);
@@ -216,8 +216,8 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) {
fwrite(compBuff, compSize, 1, packp);
- free(compBuff);
- free(fileBuff);
+ delete[] compBuff;
+ delete[] fileBuff;
printf("Ok. (%.02f%%)\n", 100.f*((float)compSize/fileSize));
@@ -238,7 +238,7 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) {
fwrite(entry, sizeof(LZP_FILE), fileList->EntryCount(), packp);
fclose(packp);
-
+ delete[] entry;
printf("Packed %d file(s) totaling %d bytes (%.02f%% compression ratio).\n",
fileList->EntryCount(),
@@ -255,7 +255,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) {
FILE* packp;
QLP_HEAD head;
- QLP_FILE fileEntry[fileList->EntryCount()];
+ QLP_FILE* fileEntry=new QLP_FILE[fileList->EntryCount()];
strncpy(head.id, "QLP", 3);
head.numFiles = fileList->EntryCount();
@@ -285,6 +285,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) {
printf("ERROR: Entry '%s' has more than 15 characters.\n", name);
fclose(packp);
unlink(packFile);
+ delete[] fileEntry;
return(0);
@@ -315,7 +316,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) {
FILE* fp = fopen(fileList->Entry(i)->fileName, "rb");
int bytesCopied = 0;
- void* copyBuff = malloc(BUFF_SIZE);
+ char* copyBuff = new char[BUFF_SIZE];
while(!feof(fp)) {
@@ -327,7 +328,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) {
}
- free(copyBuff);
+ delete[] copyBuff;
fclose(fp);
fileEntry[i].fileSize = bytesCopied;
@@ -344,6 +345,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) {
fwrite(fileEntry, sizeof(QLP_FILE), head.numFiles, packp);
fclose(packp);
+ delete[] fileEntry;
return(true);
@@ -402,7 +404,7 @@ int CreatePCKfile(const char* packFile, FileListClass* fileList) {
}
FILE* fp = fopen(fileList->Entry(i)->fileName, "rb");
- void* buff = malloc(BUFF_SIZE);
+ char* buff = new char[BUFF_SIZE];
int bytesTotal = 0;
@@ -415,18 +417,18 @@ int CreatePCKfile(const char* packFile, FileListClass* fileList) {
}
fclose(fp);
- free(buff);
+ delete[] buff;
toc.file[i].size = bytesTotal;
if ((2048*((ftell(packp)+2047)/2048)) != ftell(packp)) {
int pad = (2048*(((ftell(packp)%2048)+2047)/2048))-(ftell(packp)%2048);
- char padding[pad];
+ char* padding = new char[pad];
memset(padding, 0x00, pad);
fwrite(padding, pad, 1, packp);
-
+ delete[] padding;
}
printf("Done.\n");
diff --git a/tools/lzpack/makefile b/tools/lzpack/makefile
deleted file mode 100644
index e11f5c7..0000000
--- a/tools/lzpack/makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-TARGET := lzpack
-
-CPPFILES = main.cpp filelist.cpp
-CFLAGS = -O2
-LDFLAGS = -s
-
-LIBS = -ltinyxml2 -llzp
-
-CC = gcc
-CXX = g++
-
-OFILES = $(addprefix build/,$(CPPFILES:.cpp=.o))
-
-ifeq "$(OS)" "Windows_NT"
-
-# Config for Windows
-INCLUDE = -I/c/tinyxml2
-LIBDIRS = -L/c/tinyxml2
-TARGET := $(TARGET).exe
-
-else
-
-# Config for anything else that isn't Linux
-
-endif
-
-INCLUDE += -I../../libpsn00b
-LIBDIRS += -Llzp
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@
-
-all: $(OFILES)
- $(MAKE) -C lzp
- $(CXX) $(CFLAGS) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(LIBS) -o $(TARGET)
-
-install:
- mkdir -p ../bin
- cp $(TARGET) ../bin/$(TARGET)
-
-clean:
- $(MAKE) -C lzp clean
- rm -Rf build $(TARGET)
-
-cleanall: clean
diff --git a/tools/makefile b/tools/makefile
deleted file mode 100644
index aec452c..0000000
--- a/tools/makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-TOPTARGETS = all install clean
-
-TOOLDIRS = lzpack smxlink util
-
-$(TOPTARGETS): $(TOOLDIRS)
-$(TOOLDIRS):
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-clean: $(LIBDIRS)
- rm -Rf bin
-
-.PHONY: $(TOPTARGETS) $(TOOLDIRS)
diff --git a/tools/smxlink/main.cpp b/tools/smxlink/main.cpp
index 8072274..d58f36a 100644
--- a/tools/smxlink/main.cpp
+++ b/tools/smxlink/main.cpp
@@ -15,6 +15,10 @@
//#include <windef.h>
#include "timreader.h"
+#ifdef WIN32
+#define strcasecmp _stricmp
+#endif
+
#define VERSION "0.25b"
namespace param
diff --git a/tools/smxlink/makefile b/tools/smxlink/makefile
deleted file mode 100644
index ff759b1..0000000
--- a/tools/smxlink/makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-TARGET := smxlink
-
-CPPFILES = main.cpp timreader.cpp
-CFLAGS = -O2
-LDFLAGS = -s
-
-INCLUDE =
-LIBDIRS =
-LIBS = -ltinyxml2
-
-CC = gcc
-CXX = g++
-
-OFILES = $(addprefix build/,$(CPPFILES:.cpp=.o))
-
-ifeq "$(OS)" "Windows_NT"
-
-# Config for Windows (comment out if in msys2)
-INCLUDE = -I/c/tinyxml2
-LIBDIRS = -L/c/tinyxml2
-
-TARGET := $(TARGET).exe
-
-else
-
-# Config for anything else that isn't Windows
-EXE_SUFFIX =
-
-endif
-
-build/%.o: %.cpp
- @mkdir -p $(dir $@)
- $(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@
-
-all: $(OFILES)
- $(CXX) $(CFLAGS) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(LIBS) -o $(TARGET)
-
-install:
- mkdir -p ../bin
- cp $(TARGET) ../bin/$(TARGET)
-
-clean:
- rm -Rf build $(TARGET)
-
-cleanall: clean
diff --git a/tools/smxlink/timreader.cpp b/tools/smxlink/timreader.cpp
index a8fba94..5116f52 100644
--- a/tools/smxlink/timreader.cpp
+++ b/tools/smxlink/timreader.cpp
@@ -2,6 +2,10 @@
#include <string.h>
#include "timreader.h"
+#ifdef WIN32
+#define strcasecmp _stricmp
+#endif
+
int GetTimCoords(const char* fileName, TIM_COORDS *coords) {
FILE* fp = fopen(fileName, "rb");
diff --git a/tools/util/elf2cpe.c b/tools/util/elf2cpe.c
index 4379f4a..46b0a37 100644
--- a/tools/util/elf2cpe.c
+++ b/tools/util/elf2cpe.c
@@ -3,6 +3,10 @@
#include <malloc.h>
#include "elf.h"
+#ifdef WIN32
+#define strcasecmp _stricmp
+#endif
+
#define MAX_prg_entry_count 128
#ifndef false
diff --git a/tools/util/elf2x.c b/tools/util/elf2x.c
index 26ec9a3..9a7c126 100644
--- a/tools/util/elf2x.c
+++ b/tools/util/elf2x.c
@@ -6,6 +6,10 @@
#include <string.h>
#include "elf.h"
+#ifdef WIN32
+#define strcasecmp _stricmp
+#endif
+
#define MAX_prg_entry_count 128
#define true (1)
#define false (0)
@@ -233,9 +237,12 @@ int main(int argc, char** argv) {
exe.params.t_size = exe_tsize;
exe.params.pc0 = head.prg_entry_addr;
+ // Some later PAL BIOS versions seem to actually verify the license string
+ // in the executable (despite what the nocash docs claim) and display the
+ // dreaded "insert PlayStation CD-ROM" screen if it's not valid.
strncpy( exe.header, "PS-X EXE", 8 );
strcpy( exe.license,
- "Not Licensed or Endorsed by Sony Computer Entertainment Inc." );
+ "Sony Computer Entertainment Inc. for Europe area" );
strcpy( exe.pad2, "Built using GCC and PSn00bSDK libraries" );
diff --git a/tools/util/makefile b/tools/util/makefile
deleted file mode 100644
index fe7aed5..0000000
--- a/tools/util/makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CFLAGS = -O2 -s
-
-CC = gcc
-
-ifeq "$(OS)" "Windows_NT"
-EXE_SUFFIX = .exe
-else
-EXE_SUFFIX =
-endif
-
-all:
- $(CC) $(CFLAGS) elf2x.c -o elf2x$(EXE_SUFFIX)
- $(CC) $(CFLAGS) elf2cpe.c -o elf2cpe$(EXE_SUFFIX)
-
-install:
- mkdir -p ../bin
- cp elf2x$(EXE_SUFFIX) ../bin/elf2x$(EXE_SUFFIX)
-
-clean:
- rm -f elf2x$(EXE_SUFFIX)