diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2021-10-15 09:22:45 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-15 09:22:45 +0800 |
| commit | dd0f088aaa4c6bf013643be2d1d8621dbffdb000 (patch) | |
| tree | d848d6ce007d8bb9357c8b99d6a0a39ec41d244e /examples | |
| parent | 9e08d1047fa8deeb3ccb3ce9bb11d69e25a52d56 (diff) | |
| parent | eb719a424e6a16fb64209139a32c9f8a7235a929 (diff) | |
| download | psn00bsdk-dd0f088aaa4c6bf013643be2d1d8621dbffdb000.tar.gz | |
Merge pull request #38 from spicyjpeg/cmake
Full CMake support (in place of makefiles)
Diffstat (limited to 'examples')
49 files changed, 574 insertions, 1284 deletions
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 |
