Add psp
This commit is contained in:
29
src/duskpsp/CMakeLists.txt
Normal file
29
src/duskpsp/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Libs
|
||||
find_package(pspsdk REQUIRED)
|
||||
|
||||
target_link_libraries(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
pspsdk
|
||||
)
|
||||
|
||||
# Includes
|
||||
target_include_directories(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
input.c
|
||||
main.c
|
||||
duskpsp.c
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(display)
|
||||
12
src/duskpsp/display/CMakeLists.txt
Normal file
12
src/duskpsp/display/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# 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
|
||||
42
src/duskpsp/display/render.c
Normal file
42
src/duskpsp/display/render.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
}
|
||||
10
src/duskpsp/display/render.h
Normal file
10
src/duskpsp/display/render.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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"
|
||||
11
src/duskpsp/duskpsp.c
Normal file
11
src/duskpsp/duskpsp.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "duskpsp.h"
|
||||
|
||||
PSP_MODULE_INFO("Dusk", 0, 1, 0);
|
||||
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | THREAD_ATTR_VFPU);
|
||||
13
src/duskpsp/duskpsp.h
Normal file
13
src/duskpsp/duskpsp.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspctrl.h>
|
||||
27
src/duskpsp/input.c
Normal file
27
src/duskpsp/input.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
46
src/duskpsp/main.c
Normal file
46
src/duskpsp/main.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
Reference in New Issue
Block a user