This commit is contained in:
2025-08-11 13:29:29 -05:00
parent 26ecf67472
commit e9d2f4904a
39 changed files with 569 additions and 829 deletions

View File

@@ -5,25 +5,34 @@
# Libs
find_package(pspsdk REQUIRED)
find_package(SDL2 REQUIRED)
target_link_libraries(${DUSK_TARGET_NAME}
PRIVATE
pspsdk
# pspsdk
${SDL2_LIBRARIES}
)
# Compile definitions
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
RENDER_WIDTH=480
RENDER_HEIGHT=272
RENDER_WINDOW_WIDTH_DEFAULT=480
RENDER_WINDOW_HEIGHT_DEFAULT=272
)
# Includes
target_include_directories(${DUSK_TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${SDL2_INCLUDE_DIRS}
)
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
input.c
main.c
duskpsp.c
)
# Subdirs
add_subdirectory(display)
# Subdirs

View File

@@ -1,12 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
render.c
)
# Subdirs

View File

@@ -1,42 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "render.h"
#include "input.h"
void renderInit(void) {
pspDebugScreenInit();
}
void renderDraw(void) {
sceDisplayWaitVblankStart();
pspDebugScreenSetXY(0, 2);
pspDebugScreenPrintf("Checking buttons \n");
if(inputIsDown(INPUT_BIND_UP)) {
pspDebugScreenPrintf("Up pressed\n");
}
if(inputIsDown(INPUT_BIND_DOWN)) {
pspDebugScreenPrintf("Down pressed\n");
}
if(inputIsDown(INPUT_BIND_LEFT)) {
pspDebugScreenPrintf("Left pressed\n");
}
if(inputIsDown(INPUT_BIND_RIGHT)) {
pspDebugScreenPrintf("Right pressed\n");
}
if(inputIsDown(INPUT_BIND_ACTION)) {
pspDebugScreenPrintf("Action pressed\n");
}
if(inputIsDown(INPUT_BIND_CANCEL)) {
pspDebugScreenPrintf("Cancel pressed\n");
}
}
void renderDispose(void) {
}

View File

@@ -1,10 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "duskpsp.h"
#include "display/renderbase.h"

View File

@@ -7,5 +7,5 @@
#include "duskpsp.h"
PSP_MODULE_INFO("Dusk", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | THREAD_ATTR_VFPU);
// PSP_MODULE_INFO("Dusk", 0, 1, 0);
// PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | THREAD_ATTR_VFPU);

View File

@@ -1,27 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "duskpsp.h"
#include "input.h"
uint8_t inputStateGet() {
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons == 0) return 0;
uint8_t state = 0;
if(pad.Buttons & PSP_CTRL_UP) state |= INPUT_BIND_UP;
if(pad.Buttons & PSP_CTRL_DOWN) state |= INPUT_BIND_DOWN;
if(pad.Buttons & PSP_CTRL_LEFT) state |= INPUT_BIND_LEFT;
if(pad.Buttons & PSP_CTRL_RIGHT) state |= INPUT_BIND_RIGHT;
if(pad.Buttons & PSP_CTRL_CROSS) state |= INPUT_BIND_ACTION;
if(pad.Buttons & PSP_CTRL_CIRCLE) state |= INPUT_BIND_CANCEL;
return state;
}

View File

@@ -1,46 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "display/render.h"
#include "game.h"
int_t exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int_t callback_thread(SceSize args, void *argp) {
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int_t setup_callbacks(void) {
int thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
void main(void) {
setup_callbacks();
renderInit();
gameInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
while(true) {
gameUpdate();
renderDraw();
}
gameDispose();
renderDispose();
}