Add PSP host.

This commit is contained in:
2024-06-24 08:45:12 -05:00
parent 3bc2f0d372
commit 04be82f034
49 changed files with 514 additions and 295 deletions

View File

@ -10,11 +10,46 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(DAWN_PROJECT_NAME "Dawn")
set(DAWN_PROJECT_VERSION "01.00")
# Variable Caches
set(DAWN_CACHE_TARGET "dawn-target")
# CMake tools
add_subdirectory(cmake)
# Build target
if(DEFINED ENV{DAWN_BUILD_SYSTEM})
set(DAWN_BUILD_SYSTEM $ENV{DAWN_BUILD_SYSTEM} CACHE INTERNAL ${DAWN_CACHE_TARGET})
else()
set(DAWN_BUILD_SYSTEM "linux" CACHE INTERNAL ${DAWN_CACHE_TARGET})
endif()
# Build tools specifics
if(DAWN_BUILD_SYSTEM STREQUAL "vita")
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
set(DAWN_VITA_APP_NAME "${DAWN_PROJECT_NAME}" CACHE INTERNAL ${DAWN_CACHE_TARGET})
set(DAWN_VITA_TITLEID "YWSH00001" CACHE INTERNAL ${DAWN_CACHE_TARGET})
set(DAWN_VITA_VERSION "${DAWN_PROJECT_VERSION}" CACHE INTERNAL ${DAWN_CACHE_TARGET})
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1" CACHE INTERNAL ${DAWN_CACHE_TARGET})
elseif(DAWN_BUILD_SYSTEM STREQUAL "psp")
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{PSPDEV})
set(CMAKE_TOOLCHAIN_FILE "$ENV{PSPDEV}/psp/share/pspdev.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define PSPDEV to point to your SDK path!")
endif()
endif()
include("$ENV{PSPDEV}/psp/share/pspdev.cmake" REQUIRED)
endif()
# Set Common Build Variables
set(DAWN_ROOT_DIR "${CMAKE_SOURCE_DIR}")
@ -31,8 +66,8 @@ set(DAWN_ASSETS "" CACHE INTERNAL ${DAWN_CACHE_TARGET})
set(DAWN_BUILD_BINARY ${DAWN_BUILD_DIR}/Dawn CACHE INTERNAL ${DAWN_CACHE_TARGET})
# Initialize Project First.
project(Dawn
VERSION 1.0.0
project("${DAWN_PROJECT_NAME}"
VERSION "${DAWN_PROJECT_VERSION}"
LANGUAGES C CXX
)
@ -59,4 +94,13 @@ if(DAWN_BUILD_SYSTEM STREQUAL "vita")
VERSION ${DAWN_VITA_VERSION}
NAME ${DAWN_VITA_APP_NAME}
)
elseif(DAWN_BUILD_SYSTEM STREQUAL "psp")
create_pbp_file(
TARGET ${PROJECT_NAME}
ICON_PATH NULL
BACKGROUND_PATH NULL
PREVIEW_PATH NULL
TITLE ${PROJECT_NAME}
VERSION ${DAWN_PROJECT_VERSION}
)
endif()

View File

@ -1,5 +0,0 @@
#!/bin/bash
mkdir tools
cd tools
cmake .. -DDAWN_BUILD_TARGET=target-tools
make

View File

@ -1,2 +0,0 @@
#!/bin/bash
git submodule update --init --recursive

View File

@ -1,2 +0,0 @@
#!/bin/bash
sudo apt install build-essential

View File

@ -1,38 +0,0 @@
#!/bin/bash
sudo apt-get install cmake libarchive-tools
git clone https://github.com/vitasdk/vdpm ~/vdpm
cd ~/vdpm
./bootstrap-vitasdk.sh
export PATH=$VITASDK/bin:$PATH
git clone https://github.com/vitasdk/packages.git ~/vitapackages
cd ~/vitapackages
dir_array=(
zlib
bzip2
henkaku
taihen
kubridge
openal-soft
openssl
curl
curlpp
expat
opus
opusfile
glm
kuio
vitaShaRK
libmathneon
vitaGL
SceShaccCgExt
)
curdir=$(pwd)
for d in "${dir_array[@]}";do
echo "${curdir}${d}"
cd "${curdir}/${d}"
vita-makepkg
vdpm *-arm.tar.xz
done

3
ci/psp/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM pspdev/pspdev
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN psp-pacman -Sy pspgl glm

14
ci/psp/docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
services:
dawn-psp:
build: .
volumes:
- ./../../:/Dawn
working_dir: /Dawn
command:
- /bin/bash
- -c
- |
mkdir -p ./build/psp
cd ./build/psp
psp-cmake ../.. -DDAWN_BUILD_SYSTEM=psp -DCMAKE_BUILD_TYPE=Debug
make

View File

@ -1,10 +0,0 @@
#!/bin/bash
mkdir -p vita/build
cd vita/build
if [ ! -d "src" ]
then
cmake ../.. -DDAWN_BUILD_TARGET=target-helloworld-vita -DCMAKE_BUILD_TYPE=Debug
fi
make
cp ./src/dawnvita/*.vpk ../
cd ../..

View File

@ -0,0 +1,15 @@
services:
dawn-vita:
image: gnuton/vitasdk-docker
volumes:
- ./../../:/Dawn
working_dir: /Dawn
command:
- /bin/bash
- -c
- |
rm -rf ./build/vita
mkdir -p ./build/vita
cd ./build/vita
cmake ../.. -DDAWN_BUILD_SYSTEM=vita -DCMAKE_BUILD_TYPE=Debug
make

View File

@ -1 +0,0 @@
add_subdirectory(targets)

View File

@ -1,7 +0,0 @@
if(DEFINED ENV{DAWN_BUILD_SYSTEM})
set(DAWN_BUILD_SYSTEM $ENV{DAWN_BUILD_SYSTEM} CACHE INTERNAL ${DAWN_CACHE_TARGET})
else()
set(DAWN_BUILD_SYSTEM "linux" CACHE INTERNAL ${DAWN_CACHE_TARGET})
endif()
add_subdirectory(${DAWN_BUILD_SYSTEM})

View File

@ -1,18 +0,0 @@
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
set(DAWN_VITA_APP_NAME "Hello World" CACHE INTERNAL ${DAWN_CACHE_TARGET})
# Unique ID must be exactly 9 characters. Recommended: XXXXYYYYY where X =
# unique string of developer and Y = a unique number for this app
set(DAWN_VITA_TITLEID "VSDK00006" CACHE INTERNAL ${DAWN_CACHE_TARGET})
# Optional version string to show in LiveArea's more info screen
set(DAWN_VITA_VERSION "01.00" CACHE INTERNAL ${DAWN_CACHE_TARGET})
# Optional. You can specify more param.sfo flags this way.
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1" CACHE INTERNAL ${DAWN_CACHE_TARGET})

View File

@ -24,5 +24,8 @@ if(DAWN_BUILD_SYSTEM STREQUAL "linux")
elseif(DAWN_BUILD_SYSTEM STREQUAL "vita")
add_subdirectory(glm)
elseif(DAWN_BUILD_SYSTEM STREQUAL "psp")
add_subdirectory(glm)
endif()

View File

@ -9,9 +9,16 @@ if(DAWN_BUILD_SYSTEM STREQUAL "linux")
add_subdirectory(dawnglfw)
add_subdirectory(dawnlinux)
add_subdirectory(dawnopengl)
add_subdirectory(dawnrpg)
elseif(DAWN_BUILD_SYSTEM STREQUAL "vita")
add_subdirectory(dawn)
add_subdirectory(dawnvita)
add_subdirectory(dawnopengl)
elseif(DAWN_BUILD_SYSTEM STREQUAL "psp")
set(DAWN_OPENGL_SHADERS FALSE CACHE INTERNAL "${DAWN_CACHE_TARGET}")
set(DAWN_OPENGL_FRAMEBUFFERS FALSE CACHE INTERNAL "${DAWN_CACHE_TARGET}")
set(DAWN_OPENGL_MIPMAPS FALSE CACHE INTERNAL "${DAWN_CACHE_TARGET}")
add_subdirectory(dawn)
add_subdirectory(dawnpsp)
else()
message(FATAL_ERROR "Unknown build system: ${DAWN_BUILD_SYSTEM}")
endif()

View File

@ -6,7 +6,6 @@
# Libraries
target_link_libraries(${DAWN_TARGET_NAME}
PUBLIC
glm
)
# Includes
@ -22,7 +21,6 @@ target_sources(${DAWN_TARGET_NAME}
)
# Subdirs
add_subdirectory(display)
add_subdirectory(error)
add_subdirectory(game)
add_subdirectory(locale)

View File

@ -25,10 +25,10 @@
#include <cstring>
#include <float.h>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/matrix_decompose.hpp>
// #define GLM_ENABLE_EXPERIMENTAL
// #include <glm/glm.hpp>
// #include <glm/gtc/type_ptr.hpp>
// #include <glm/gtx/matrix_decompose.hpp>
typedef char char_t;
typedef char8_t u8char_t;

View File

@ -8,64 +8,16 @@
using namespace Dawn;
Game::Game() :
renderManager()
{
}
std::shared_ptr<Scene> Game::getCurrentScene() {
return currentScene;
}
void Game::setCurrentScene(std::shared_ptr<Scene> scene) {
currentScene = scene;
Game::Game() {
}
void Game::init() {
renderManager.init(*this);
this->shader = std::make_shared<SimpleTexturedShader>();
this->shader->init();
this->shader->bind();
this->mesh = std::make_shared<Mesh>();
this->mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
QuadMesh::buffer(this->mesh, glm::vec4(-0.5f, -0.5f, 0.5f, 0.5f), glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), 0, 0);
}
void Game::update() {
renderManager.update(*this);
glm::mat4 view = glm::lookAt(
glm::vec3(3, 3, 3),
glm::vec3(0, 0, 0),
glm::vec3(0, 1, 0)
);
glm::mat4 proj = glm::perspective(
glm::radians(45.0f),
800.0f / 600.0f,
0.1f,
100.0f
);
glm::mat4 model = glm::mat4(1.0f);
this->shader->bind();
this->shader->setData(SimpleTexturedShaderData {
.projection = proj,
.view = view,
.model = model,
.color = COLOR_WHITE,
.hasTexture = false,
.texture = 0
});
this->shader->upload();
this->mesh->draw(MeshDrawMode::TRIANGLES, 0, QUAD_INDICE_COUNT);
}
Game::~Game() {
shader = nullptr;
mesh = nullptr;
}

View File

@ -5,23 +5,14 @@
#pragma once
#include "dawn.hpp"
#include "display/RenderManager.hpp"
#include "display/mesh/QuadMesh.hpp"
#include "display/shader/SimpleTexturedShader.hpp"
#include "world/Map.hpp"
namespace Dawn {
class Scene;
class Game {
private:
std::shared_ptr<Scene> currentScene;
std::shared_ptr<Mesh> mesh;
std::shared_ptr<SimpleTexturedShader> shader;
std::shared_ptr<Map> map;
public:
RenderManager renderManager;
/**
* Constructs a new instance of Game, the class majorily responsible for
* handling all internal dawn functions outside of platform-centric things
@ -29,20 +20,6 @@ namespace Dawn {
*/
Game();
/**
* Gets the current scene.
*
* @return The current scene.
*/
std::shared_ptr<Scene> getCurrentScene();
/**
* Sets the current scene to the provided scene.
*
* @param scene The scene to set as the current scene.
*/
void setCurrentScene(std::shared_ptr<Scene> scene);
/**
* Initializes the game and all sub managers used by game.
*/

View File

@ -4,10 +4,19 @@
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/Scene.hpp"
#include "dawn.hpp"
namespace Dawn {
class RPGScene : public Scene {
class Map {
public:
/**
* Creates Map object.
*/
Map();
/**
* Destroys Map object.
*/
~Map();
};
}

View File

@ -95,7 +95,8 @@ DawnGLFWInitResult DawnGLFWHost::init(
this->game = std::make_shared<Game>();
this->game->init();
auto backBuffer = this->game->renderManager.getBackBufferRenderTarget();
// Backbuffer
backBuffer = std::make_shared<BackBuffer>();
backBuffer->setSize((float_t)fbWidth, (float_t)fbHeight);
// Set up callbacks
@ -108,8 +109,7 @@ DawnGLFWInitResult DawnGLFWHost::init(
if(host == nullptr) return;
host->windowWidth = width;
host->windowHeight = height;
auto backBuffer = host->game->renderManager.getBackBufferRenderTarget();
backBuffer->setSize((float_t)width, (float_t)height);
host->backBuffer->setSize((float_t)width, (float_t)height);
});
return DawnGLFWInitResult::SUCCESS;
@ -140,6 +140,7 @@ void DawnGLFWHost::start() {
}
DawnGLFWHost::~DawnGLFWHost() {
this->backBuffer = nullptr;
this->game = nullptr;
// Terminate GLFW

View File

@ -8,6 +8,7 @@
#include "dawn.hpp"
#include <GLFW/glfw3.h>
#include "game/Game.hpp"
#include "display/BackBuffer.hpp"
#define DAWN_GLFW_WIDTH_DEFAULT 800
#define DAWN_GLFW_HEIGHT_DEFAULT 600
@ -26,6 +27,7 @@ namespace Dawn {
GLFWwindow *window;
int32_t windowWidth, windowHeight;
std::shared_ptr<Game> game;
std::shared_ptr<BackBuffer> backBuffer;
public:
/**
@ -38,6 +40,7 @@ namespace Dawn {
*
* @param argc The number of arguments.
* @param argv The arguments.
* @return The result of the initialization.
*/
DawnGLFWInitResult init(const int32_t argc, const char_t **argv);

View File

@ -12,8 +12,15 @@ using namespace Dawn;
int32_t main(const int32_t argc, const char_t **argv) {
std::shared_ptr<DawnGLFWHost> host = std::make_shared<DawnGLFWHost>();
host->init(argc, argv);
auto result = host->init(argc, argv);
if(result != DawnGLFWInitResult::SUCCESS) {
return (int32_t)result;
}
host->start();
host = nullptr;
return 0;
}

View File

@ -3,6 +3,20 @@
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Setup options
if(NOT DEFINED DAWN_OPENGL_SHADERS)
set(DAWN_OPENGL_SHADERS TRUE CACHE INTERNAL "${DAWN_CACHE_TARGET}")
endif()
if(NOT DEFINED DAWN_OPENGL_FRAMEBUFFERS)
set(DAWN_OPENGL_FRAMEBUFFERS TRUE CACHE INTERNAL "${DAWN_CACHE_TARGET}")
endif()
if(NOT DEFINED DAWN_OPENGL_MIPMAPS)
set(DAWN_OPENGL_MIPMAPS TRUE CACHE INTERNAL "${DAWN_CACHE_TARGET}")
endif()
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC

View File

@ -61,8 +61,10 @@ void BackBuffer::clear(const int32_t clearFlags) {
}
void BackBuffer::bind() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
assertNoGLError();
#if DAWN_OPENGL_FRAMEBUFFERS
glBindFramebuffer(GL_FRAMEBUFFER, 0);
assertNoGLError();
#endif
glViewport(0, 0, (GLsizei)this->width, (GLsizei)this->height);
assertNoGLError();
}

View File

@ -6,11 +6,15 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
Color.cpp
BackBuffer.cpp
Texture.cpp
RenderManager.cpp
)
# Subdirs
add_subdirectory(mesh)
add_subdirectory(shader)
# add_subdirectory(mesh)
if(DAWN_OPENGL_SHADERS EQUAL TRUE)
message(FATAL_ERROR "DAWN_OPENGL_SHADERS: ${DAWN_OPENGL_SHADERS}")
add_subdirectory(shader)
endif()

View File

@ -8,9 +8,7 @@
using namespace Dawn;
RenderManager::RenderManager() :
shaderManager()
{
RenderManager::RenderManager() {
}
void RenderManager::init(const Game &game) {

View File

@ -6,9 +6,12 @@
#pragma once
#include "dawn.hpp"
#include "display/RenderTarget.hpp"
#include "display/shader/ShaderManager.hpp"
#include "display/BackBuffer.hpp"
#if DAWN_OPENGL_SHADERS
#include "display/shader/ShaderManager.hpp"
#endif
namespace Dawn {
class Game;
@ -17,7 +20,9 @@ namespace Dawn {
std::shared_ptr<BackBuffer> backBuffer = nullptr;
public:
ShaderManager shaderManager;
#if DAWN_OPENGL_SHADERS
ShaderManager shaderManager;
#endif
/**
* Creates a render manager.

View File

@ -42,7 +42,7 @@ void Texture::setSize(
this->id = -1;
}
int32_t maxSize;
GLint maxSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
assertTrue(width > 0 && width <= maxSize, "Width is out of bounds!");
assertTrue(height > 0 && height <= maxSize, "Height is out of bounds!");
@ -64,26 +64,7 @@ void Texture::setSize(
void Texture::updateTextureProperties() {
auto setWrapMode = [](GLenum axis, enum TextureWrapMode wm) {
switch(wm) {
case TextureWrapMode::REPEAT:
glTexParameteri(GL_TEXTURE_2D, axis, GL_REPEAT);
break;
case TextureWrapMode::MIRRORED_REPEAT:
glTexParameteri(GL_TEXTURE_2D, axis, GL_MIRRORED_REPEAT);
break;
case TextureWrapMode::CLAMP_TO_EDGE:
glTexParameteri(GL_TEXTURE_2D, axis, GL_CLAMP_TO_EDGE);
break;
case TextureWrapMode::CLAMP_TO_BORDER:
glTexParameteri(GL_TEXTURE_2D, axis, GL_CLAMP_TO_BORDER);
break;
default:
assertUnreachable("Unknown wrap mode!");
}
glTexParameteri(GL_TEXTURE_2D, axis, (GLint)wm);
assertNoGLError();
};
@ -124,28 +105,7 @@ void Texture::updateTextureProperties() {
void Texture::bufferRaw(const void *data) {
assertTrue(this->id != -1, "Texture is not ready!");
GLenum format;
switch(this->format) {
case TextureFormat::R:
format = GL_RED;
break;
case TextureFormat::RG:
format = GL_RG;
break;
case TextureFormat::RGB:
format = GL_RGB;
break;
case TextureFormat::RGBA:
format = GL_RGBA;
break;
default:
assertUnreachable("Unknown texture format!");
}
GLenum format = (GLenum)this->format;
GLenum dataFormat;
switch(this->dataFormat) {
case TextureDataFormat::UNSIGNED_BYTE:
@ -168,8 +128,11 @@ void Texture::bufferRaw(const void *data) {
0, format, dataFormat, data
);
assertNoGLError();
glGenerateMipmap(GL_TEXTURE_2D);
assertNoGLError();
#if DAWN_OPENGL_MIPMAPS
glGenerateMipmap(GL_TEXTURE_2D);
assertNoGLError();
#endif
}
void Texture::buffer(const struct ColorU8 pixels[]) {

View File

@ -13,17 +13,21 @@ namespace Dawn {
typedef GLuint textureslot_t;
enum class TextureFormat {
R = 1,
RG = 2,
RGB = 3,
RGBA = 4
R = GL_RED,
#ifdef GL_RG
RG = GL_RG,
#endif
RGB = GL_RGB,
RGBA = GL_RGBA
};
enum class TextureWrapMode {
REPEAT = 0,
MIRRORED_REPEAT = 1,
CLAMP_TO_EDGE = 2,
CLAMP_TO_BORDER = 3
REPEAT = GL_REPEAT,
MIRRORED_REPEAT = GL_MIRRORED_REPEAT,
CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
#ifdef GL_CLAMP_TO_BORDER
CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER
#endif
};
enum class TextureFilterMode {

View File

@ -40,9 +40,11 @@ void assertNotGLErrorCheck(const char *file, int32_t line) {
error += "\nOUT_OF_MEMORY";
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
error += "\nINVALID_FRAMEBUFFER_OPERATION";
break;
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION
case GL_INVALID_FRAMEBUFFER_OPERATION:
error += "\nINVALID_FRAMEBUFFER_OPERATION";
break;
#endif
default:
error += "\nUNKNOWN GL ERROR ERROR";

View File

@ -26,9 +26,11 @@ void errorCheckOpenGL() {
buffer << "INVALID_OPERATION" << std::endl;
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
buffer << "INVALID_FRAMEBUFFER_OPERATION" << std::endl;
break;
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION
case GL_INVALID_FRAMEBUFFER_OPERATION:
buffer << "INVALID_FRAMEBUFFER_OPERATION" << std::endl;
break;
#endif
case GL_OUT_OF_MEMORY:
buffer << "OUT_OF_MEMORY" << std::endl;

View File

@ -1,21 +1,37 @@
# Copyright (c) 2024 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Libraries
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
)
# Subdirs
add_subdirectory(scene)
# Copyright (c) 2024 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Libraries
target_link_libraries(${DAWN_TARGET_NAME}
PUBLIC
m
c
psputility
pspdebug
pspge
pspdisplay
pspctrl
pspsdk
pspuser
psprtc
pspvfpu
GL
)
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
main.cpp
)
# Subdirs
add_subdirectory(error)
add_subdirectory(host)

View File

@ -6,5 +6,5 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
RPGScene.cpp
error.cpp
)

View File

@ -0,0 +1,31 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "error/error.hpp"
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
void errorMessageBox(const std::u8string &message) {
// c8string to cstring
std::string messageStr = (
message.length() > 0 ?
std::string(message.cbegin(), message.cend()) :
std::string()
);
// Print Hello World! on a debug screen on a loop
pspDebugScreenInit();
while(1) {
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf(messageStr.c_str());
sceDisplayWaitVblankStart();
}
}
void errorLog(const std::string &message) {
std::cerr << message << std::endl;
}

View File

@ -1,10 +1,10 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
Color.cpp
# Copyright (c) 2024 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
DawnPSPHost.cpp
)

View File

@ -0,0 +1,27 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnPSPHost.hpp"
#include "error/error.hpp"
using namespace Dawn;
DawnPSPHost::DawnPSPHost() {
}
DawnPSPHostResult DawnPSPHost::init() {
return DawnPSPHostResult::SUCCESS;
}
void DawnPSPHost::start() {
while(this->shouldGameRun) {
// Do stuff
}
}
DawnPSPHost::~DawnPSPHost() {
}

View File

@ -0,0 +1,43 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "game/Game.hpp"
namespace Dawn {
enum class DawnPSPHostResult {
SUCCESS = 0,
};
class DawnPSPHost {
private:
std::shared_ptr<Game> game;
public:
bool_t shouldGameRun = true;
/**
* Creates a new PSP Host.
*/
DawnPSPHost();
/**
* Initializes the PSP Host.
*
* @return The result of the initialization.
*/
DawnPSPHostResult init();
/**
* Starts the PSP Host, called after the PSP Host has been initialized.
*/
void start();
/**
* Destroys the PSP Host.
*/
~DawnPSPHost();
};
}

52
src/dawnpsp/main.cpp Normal file
View File

@ -0,0 +1,52 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "main.hpp"
#include "host/DawnPSPHost.hpp"
using namespace Dawn;
std::shared_ptr<DawnPSPHost> host;
int callbackOnExit(int arg1, int arg2, void *common) {
sceKernelExitGame();
host->shouldGameRun = false;
host = nullptr;
return 0;
}
int callbackThread(SceSize args, void *argp) {
int cbid = sceKernelCreateCallback("Exit Callback", callbackOnExit, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int main(void) {
// Setup PSP Callbacks
int thid = sceKernelCreateThread(
"update_thread",
callbackThread,
0x11,
0xFA0,
0,
0
);
if(thid >= 0) sceKernelStartThread(thid, 0, 0);
//
host = std::make_shared<DawnPSPHost>();
auto ret = host->init();
if(ret != DawnPSPHostResult::SUCCESS) {
host = nullptr;
return (int)ret;
}
host->start();
host = nullptr;
return 0;
}

21
src/dawnpsp/main.hpp Normal file
View File

@ -0,0 +1,21 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawn.hpp"
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
PSP_MODULE_INFO("Controller", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
/**
* Main entry to the program.
*
* @return The exit code of the program.
*/
int main(void);

View File

@ -1,8 +0,0 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "RPGScene.hpp"
using namespace Dawn;

View File

@ -9,24 +9,25 @@ target_link_libraries(${DAWN_TARGET_NAME}
m
stdc++
vitaGL
# mathneon
# vitashark
mathneon
vitashark
# kubridge_stub
# SceAppMgr_stub
SceAppMgr_stub
# SceAudio_stub
# SceCtrl_stub
# SceCommonDialog_stub
# SceDisplay_stub
# SceKernelDmacMgr_stub
# SceGxm_stub
# SceShaccCg_stub
SceCommonDialog_stub
SceDisplay_stub
SceKernelDmacMgr_stub
SceGxm_stub
SceShaccCg_stub
# SceSysmodule_stub
# ScePower_stub
# SceTouch_stub
# SceVshBridge_stub
# SceIofilemgr_stub
# SceShaccCgExt
# libtaihen_stub.a
SceShaccCgExt
# ScePvf_stub
libtaihen_stub.a
)
# Includes

View File

@ -0,0 +1,38 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnVitaHost.hpp"
using namespace Dawn;
DawnVitaHost::DawnVitaHost() {
}
DawnVitaInitResult DawnVitaHost::init() {
return DawnVitaInitResult::SUCCESS;
}
void DawnVitaHost::start() {
std::stringstream output;
std::vector<std::string> hello = { "Hello" };
hello.push_back(",");
hello.push_back(" C++ ");
hello.push_back("world!");
for (auto &s : hello) {
// std::cout does't work ATM :(
output << s;
}
output << std::endl;
psvDebugScreenInit();
printf("%s\n", output.str().c_str());
sceKernelDelayThread(3*1000000); // Wait for 3 seconds
sceKernelExitProcess(0);
}
DawnVitaHost::~DawnVitaHost() {
}

View File

@ -0,0 +1,42 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnopengl.hpp"
#include "dawn.hpp"
namespace Dawn {
enum class DawnVitaInitResult {
SUCCESS = 0,
FAILURE = 1
};
class DawnVitaHost {
private:
public:
/**
* Creates a new Vita Host.
*/
DawnVitaHost();
/**
* Initializes the Vita Host.
*
* @return The result of the initialization.
*/
DawnVitaInitResult init();
/**
* Starts the Vita Host, called after the Vita Host has been initialized.
*/
void start();
/**
* Destroys the Vita Host.
*/
~DawnVitaHost();
};
}

View File

@ -4,9 +4,21 @@
// https://opensource.org/licenses/MIT
#include "main.hpp"
#include "host/DawnVitaHost.hpp"
using namespace Dawn;
GLfloat alpha_ref = 0.0f;
int32_t main(void) {
std::shared_ptr<DawnVitaHost> host = std::make_shared<DawnVitaHost>();
auto result = host->init();
if(result != DawnVitaInitResult::SUCCESS) {
return (int32_t)result;
}
host->start();
host = nullptr;
int32_t main(const int32_t argc, const char_t **argv) {
return 0;
}

View File

@ -55,7 +55,7 @@ for foldername, subfolders, filenames in os.walk(args.input):
continue
# No, add it
print(f"Archiving asset {filename}...")
# print(f"Archiving asset {filename}...")
archive.add(absolute_path, arcname=relative_path)
# Close the archive