From aaa8622956fbaf8414ffafec6edeeac4c27c76dd Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 9 Nov 2025 14:54:33 -0600 Subject: [PATCH] Fixed PSP rendering --- CMakeLists.txt | 1 + assets/ui/CMakeLists.txt | 2 +- cmake/modules/Findpspsdk.cmake | 2 +- src/asset/asset.h | 7 +++++++ src/display/camera.c | 6 +++++- src/display/screen.c | 3 +++ src/display/texture.c | 1 + src/input/input.c | 8 ++++---- src/main.c | 6 ++++++ src/ui/ui.c | 1 - test.txt | 1 + 11 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 test.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index aeff1a0..a938acc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,7 @@ if(DUSK_TARGET_SYSTEM STREQUAL "psp") BACKGROUND_PATH NULL PREVIEW_PATH NULL TITLE "${DUSK_TARGET_NAME}" + PSAR_PATH ${DUSK_BUILD_DIR}/dusk.dsk VERSION 01.00 ) endif() \ No newline at end of file diff --git a/assets/ui/CMakeLists.txt b/assets/ui/CMakeLists.txt index ffe622f..22dbf0a 100644 --- a/assets/ui/CMakeLists.txt +++ b/assets/ui/CMakeLists.txt @@ -3,4 +3,4 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -add_asset(TILESET minogram.png type=ALPHA tileWidth=6 tileHeight=10 columns=16 rows=6) \ No newline at end of file +add_asset(TILESET minogram.png type=PALETTIZED tileWidth=6 tileHeight=10 columns=16 rows=6)# Fixes PSP rendering \ No newline at end of file diff --git a/cmake/modules/Findpspsdk.cmake b/cmake/modules/Findpspsdk.cmake index 9ac7f3a..25591cd 100644 --- a/cmake/modules/Findpspsdk.cmake +++ b/cmake/modules/Findpspsdk.cmake @@ -31,7 +31,7 @@ if(NOT TARGET pspsdk) if(NOT PSPSDK_PSP_GCC) message(STATUS "psp-gcc not found in system paths. Downloading PSPSDK tarball...") file(DOWNLOAD - "https://github.com/pspdev/pspdev/releases/tag/v20251101/download/pspdev-ubuntu-latest-x86_64.tar.gz" + "https://github.com/pspdev/pspdev/releases/download/v20251101/pspdev-ubuntu-latest-x86_64.tar.gz" "${CMAKE_BINARY_DIR}/pspsdk.tar.gz" EXPECTED_HASH SHA256=8f8abc2a3008ec1e97c6ba706152a45e4f031c8d10db2102c3c68ce24fa6fcaf SHOW_PROGRESS diff --git a/src/asset/asset.h b/src/asset/asset.h index c5368ea..7b760d2 100644 --- a/src/asset/asset.h +++ b/src/asset/asset.h @@ -10,6 +10,13 @@ #include "assettype.h" #if ASSET_TYPE == wad + #if PSP + typedef struct { + uint8_t signature[4]; + uint16_t version[2]; + unsigned int offset[8]; + } assetpbp_t; + #endif #else #error "Unsupported ASSET_TYPE" #endif diff --git a/src/display/camera.c b/src/display/camera.c index 306540d..2d9877e 100644 --- a/src/display/camera.c +++ b/src/display/camera.c @@ -52,6 +52,11 @@ void cameraPushMatrix(camera_t *camera) { switch(camera->projType) { case CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC: + assertTrue( + camera->orthographic.right != camera->orthographic.left && + camera->orthographic.top != camera->orthographic.bottom, + "Invalid orthographic projection parameters" + ); glm_ortho( camera->orthographic.left, camera->orthographic.right, @@ -117,7 +122,6 @@ void cameraPushMatrix(camera_t *camera) { glm_vec3_copy(camera->lookatPixelPerfect.target, position); glm_vec3_add(position, camera->lookatPixelPerfect.offset, position); position[2] += z; - glm_lookat( position, camera->lookatPixelPerfect.target, diff --git a/src/display/screen.c b/src/display/screen.c index 5410066..a04dd1b 100644 --- a/src/display/screen.c +++ b/src/display/screen.c @@ -41,6 +41,9 @@ void screenInit() { SCREEN.frameBufferMeshVertices ); #endif + + // Init screen to backbuffer mode by default + screenBind(); } void screenBind() { diff --git a/src/display/texture.c b/src/display/texture.c index 0f4dc26..63f24d7 100644 --- a/src/display/texture.c +++ b/src/display/texture.c @@ -170,6 +170,7 @@ void textureBind(const texture_t *texture) { #if DISPLAY_SDL2 glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture->id); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); #endif TEXTURE_BOUND = texture; } diff --git a/src/input/input.c b/src/input/input.c index 1a77f97..329eb79 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -52,10 +52,10 @@ void inputInit(void) { inputBind(inputButtonGetByName("right"), INPUT_ACTION_RIGHT); inputBind(inputButtonGetByName("circle"), INPUT_ACTION_CANCEL); inputBind(inputButtonGetByName("cross"), INPUT_ACTION_ACCEPT); - inputBind(inputButtonGetByName("lstick_negative_y"), INPUT_ACTION_UP); - inputBind(inputButtonGetByName("lstick_positive_y"), INPUT_ACTION_DOWN); - inputBind(inputButtonGetByName("lstick_negative_x"), INPUT_ACTION_LEFT); - inputBind(inputButtonGetByName("lstick_positive_x"), INPUT_ACTION_RIGHT); + // inputBind(inputButtonGetByName("lstick_negative_y"), INPUT_ACTION_UP); + // inputBind(inputButtonGetByName("lstick_positive_y"), INPUT_ACTION_DOWN); + // inputBind(inputButtonGetByName("lstick_negative_x"), INPUT_ACTION_LEFT); + // inputBind(inputButtonGetByName("lstick_positive_x"), INPUT_ACTION_RIGHT); #endif #endif #endif diff --git a/src/main.c b/src/main.c index 51025ae..2d463cd 100644 --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,12 @@ #include "input/input.h" int main(int argc, char **argv) { + // Write out launch args + printf("Launching Dusk with %d args:\n", argc); + for(int i = 0; i < argc; i++) { + printf(" Arg %d: %s\n", i, argv[i]); + } + errorret_t ret; // Init engine diff --git a/src/ui/ui.c b/src/ui/ui.c index 44c9aa0..0f2a1f2 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -44,7 +44,6 @@ void uiRender(void) { uiFPSRender(UI.fontTileset, &UI.fontTexture); uiTextboxRender(); } - cameraPopMatrix(); } diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..45a66e1 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +PSAR_HERE \ No newline at end of file