Debian Codegraph @

src/platforms/psp.cpp

raw symbols SCIP
1
2 /**
3 *
4 * @file psp.cpp
5 *
6 * Part of the OpenJazz project
7 *
8 * @par Licence:
9 * Copyright (c) 2015-2026 Carsten Teibes
10 *
11 * OpenJazz is distributed under the terms of
12 * the GNU General Public License, version 2.0
13 *
14 */
15
16 #include "psp.h"
17
18 #ifdef PSP
19
20 #include <pspsdk.h>
21 #include <pspkernel.h>
22 #include <pspthreadman.h>
23 #include <pspmoduleinfo.h>
24 #include <pspdebug.h>
25 #include <psputility.h>
26 #include <pspdisplay.h>
27 #include <stdlib.h>
28
29 // TODO: maybe remove callback and module handling alltogether,
30 // since SDL2main does it, if enabled
31
32 PSP_MODULE_INFO("OpenJazz", PSP_MODULE_USER, 0, 1);
33 //PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU); // vfpu is used in SDL afaik
34 PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
35 PSP_HEAP_SIZE_KB(-2048);
36
37 namespace {
38 bool exitRequest = false;
39
40 int exitCallback(int arg1, int arg2, void *common) {
41 exitRequest = true;
42 return 0;
43 }
44
45 int callbackThread(SceSize args, void *argp) {
46 int callbackID = sceKernelCreateCallback("Exit Callback", exitCallback, nullptr);
47 sceKernelRegisterExitCallback(callbackID);
48
49 sceKernelSleepThreadCB();
50
51 return 0;
52 }
53 }
54
55 bool PspPlatform::WantsExit() {
56 return exitRequest;
57 }
58
59 PspPlatform::PspPlatform() {
60 // debug output
61
62 pspDebugScreenInit();
63 //pspDebugInstallErrorHandler(nullptr);
64
65 int threadID = sceKernelCreateThread("Callback Update Thread", callbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
66 if(threadID >= 0) {
67 sceKernelStartThread(threadID, 0, 0);
68 }
69
70 atexit(sceKernelExitGame);
71
72 sceIoChdir("ms0:/PSP/GAME/OpenJazz");
73 }
74
75 void PspPlatform::ErrorNoDatafiles() {
76 pspDebugScreenClear();
77 pspDebugScreenSetXY(12, 0);
78 pspDebugScreenPuts("Unable to find game data files.");
79 pspDebugScreenPuts("Please put them in the same directory as this executable.");
80 pspDebugScreenPuts("\te.g. ms0:/PSP/GAME/OpenJazz");
81 sceKernelDelayThread(3000000);
82 }
83
84 #endif