1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-16 01:54:38 +02:00

#15 PSP remove tabs

This commit is contained in:
XProger
2018-01-31 17:06:32 +03:00
parent 1fb18ab819
commit 603e8219f7

View File

@@ -4,7 +4,6 @@
#include <pspkernel.h> #include <pspkernel.h>
#include <pspdisplay.h> #include <pspdisplay.h>
//#include <pspdebug.h>
#include <pspctrl.h> #include <pspctrl.h>
#include <psprtc.h> #include <psprtc.h>
#include <pspaudiolib.h> #include <pspaudiolib.h>
@@ -14,38 +13,35 @@ PSP_MODULE_INFO("OpenLara", 0, 1, 1);
PSP_HEAP_SIZE_KB(20480); PSP_HEAP_SIZE_KB(20480);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU); PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU);
//#define printf pspDebugScreenPrintf
//#define printf Kprintf
#include "game.h" #include "game.h"
#define BUF_WIDTH (512) #define BUF_WIDTH (512)
#define SCR_WIDTH (480) #define SCR_WIDTH (480)
#define SCR_HEIGHT (272) #define SCR_HEIGHT (272)
int exitCallback(int arg1, int arg2, void *common) { int exitCallback(int arg1, int arg2, void *common) {
Core::quit(); Core::quit();
return 0; return 0;
} }
int callbackThread(SceSize args, void *argp) { int callbackThread(SceSize args, void *argp) {
int cbid = sceKernelCreateCallback("Exit Callback", exitCallback, NULL); int cbid = sceKernelCreateCallback("Exit Callback", exitCallback, NULL);
sceKernelRegisterExitCallback(cbid); sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB(); sceKernelSleepThreadCB();
return 0; return 0;
} }
int setupCallbacks(void) { int setupCallbacks(void) {
int thid = sceKernelCreateThread("update_thread", callbackThread, 0x11, 0xFA0, 0, 0); int thid = sceKernelCreateThread("update_thread", callbackThread, 0x11, 0xFA0, 0, 0);
sceKernelStartThread(thid, 0, 0); sceKernelStartThread(thid, 0, 0);
return thid; return thid;
} }
int osStartTime = 0; int osStartTime = 0;
int osTimerFreq; int osTimerFreq;
int osGetTime() { int osGetTime() {
u64 time; u64 time;
sceRtcGetCurrentTick(&time); sceRtcGetCurrentTick(&time);
return int(time * 1000 / osTimerFreq - osStartTime); return int(time * 1000 / osTimerFreq - osStartTime);
} }
@@ -76,7 +72,7 @@ void joyInit() {
void joyUpdate() { void joyUpdate() {
SceCtrlData pad; SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1); sceCtrlReadBufferPositive(&pad, 1);
Input::setDown(ikJoyA, (pad.Buttons & PSP_CTRL_CROSS)); Input::setDown(ikJoyA, (pad.Buttons & PSP_CTRL_CROSS));
Input::setDown(ikJoyB, (pad.Buttons & PSP_CTRL_CIRCLE)); Input::setDown(ikJoyB, (pad.Buttons & PSP_CTRL_CIRCLE));
Input::setDown(ikJoyX, (pad.Buttons & PSP_CTRL_SQUARE)); Input::setDown(ikJoyX, (pad.Buttons & PSP_CTRL_SQUARE));
@@ -85,13 +81,13 @@ void joyUpdate() {
Input::setDown(ikJoyRB, (pad.Buttons & PSP_CTRL_RTRIGGER)); Input::setDown(ikJoyRB, (pad.Buttons & PSP_CTRL_RTRIGGER));
Input::setDown(ikJoyStart, (pad.Buttons & PSP_CTRL_START)); Input::setDown(ikJoyStart, (pad.Buttons & PSP_CTRL_START));
Input::setDown(ikJoySelect, (pad.Buttons & PSP_CTRL_SELECT)); Input::setDown(ikJoySelect, (pad.Buttons & PSP_CTRL_SELECT));
int pov = joyGetPOV( ((pad.Buttons & PSP_CTRL_UP) != 0) | int pov = joyGetPOV( ((pad.Buttons & PSP_CTRL_UP) != 0) |
(((pad.Buttons & PSP_CTRL_DOWN) != 0) << 1) | (((pad.Buttons & PSP_CTRL_DOWN) != 0) << 1) |
(((pad.Buttons & PSP_CTRL_LEFT) != 0) << 2) | (((pad.Buttons & PSP_CTRL_LEFT) != 0) << 2) |
(((pad.Buttons & PSP_CTRL_RIGHT) != 0) << 3)); (((pad.Buttons & PSP_CTRL_RIGHT) != 0) << 3));
Input::setPos(ikJoyPOV, vec2(float(pov), 0.0f)); Input::setPos(ikJoyPOV, vec2(float(pov), 0.0f));
vec2 stick = vec2(float(pad.Lx), float(pad.Ly)) / 128.0f - 1.0f; vec2 stick = vec2(float(pad.Lx), float(pad.Ly)) / 128.0f - 1.0f;
if (fabsf(stick.x) < 0.2f && fabsf(stick.y) < 0.2f) if (fabsf(stick.x) < 0.2f && fabsf(stick.y) < 0.2f)
stick = vec2(0.0f); stick = vec2(0.0f);
@@ -103,27 +99,26 @@ void sndFill(void* buf, unsigned int length, void *userdata) {
} }
void sndInit() { void sndInit() {
pspAudioInit(); pspAudioInit();
pspAudioSetChannelCallback(0, sndFill, NULL); pspAudioSetChannelCallback(0, sndFill, NULL);
} }
char Stream::cacheDir[255]; char Stream::cacheDir[255];
char Stream::contentDir[255]; char Stream::contentDir[255];
int main() { int main() {
//pspDebugScreenInit(); setupCallbacks();
setupCallbacks();
sceGuInit(); sceGuInit();
Core::beginCmdBuf(); Core::beginCmdBuf();
sceGuDrawBuffer(GU_PSM_5650, (void*)0, BUF_WIDTH);
sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)(BUF_WIDTH * SCR_HEIGHT * 2), BUF_WIDTH);
sceGuDepthBuffer((void*)(BUF_WIDTH * SCR_HEIGHT * 2 * 2), BUF_WIDTH);
sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT); sceGuDrawBuffer(GU_PSM_5650, (void*)0, BUF_WIDTH);
sceGuEnable(GU_SCISSOR_TEST); sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)(BUF_WIDTH * SCR_HEIGHT * 2), BUF_WIDTH);
sceGuDepthBuffer((void*)(BUF_WIDTH * SCR_HEIGHT * 2 * 2), BUF_WIDTH);
sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
sceGuEnable(GU_SCISSOR_TEST);
sndInit(); sndInit();
joyInit(); joyInit();
@@ -135,15 +130,12 @@ int main() {
Core::submitCmdBuf(); Core::submitCmdBuf();
sceDisplayWaitVblankStart(); sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE); sceGuDisplay(GU_TRUE);
Core::curBackBuffer = 0; Core::curBackBuffer = 0;
while (!Core::isQuit) {
//pspDebugScreenSetOffset((int)frameOffset);
//pspDebugScreenSetXY(0, 0);
while (!Core::isQuit) {
Core::beginCmdBuf(); Core::beginCmdBuf();
joyUpdate(); joyUpdate();
@@ -151,15 +143,15 @@ int main() {
Game::render(); Game::render();
Core::submitCmdBuf(); Core::submitCmdBuf();
//sceDisplayWaitVblankStart(); //sceDisplayWaitVblankStart();
Core::curBackBuffer = sceGuSwapBuffers(); Core::curBackBuffer = sceGuSwapBuffers();
} }
Game::deinit(); Game::deinit();
sceGuTerm(); sceGuTerm();
sceKernelExitGame(); sceKernelExitGame();
return 0; return 0;
} }