📄 main.cpp
字号:
//-------------------------------------------------------------------------------------
//
// This is part of MarioDemo, a platformer demo for JGE++
//
// Copyright (C) 2006 James Hui (a.k.a. Dr.Watson)
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
// Place, Suite 330, Boston, MA 02111-1307 USA
//
// Bugs and comments can be forwarded to jhkhui@yahoo.com.
//
//-------------------------------------------------------------------------------------
#include <pspkernel.h>#include <pspdisplay.h>#include <pspdebug.h>
#include <psppower.h>
#include "../../JGE/include/JGE.h"
#include "../src/GameApp.h"
#ifndef JGEApp_Title
#define JGEApp_Title "JGE Demo"
#endif
// app name and version numberPSP_MODULE_INFO(JGEApp_Title, 0x1000, 1, 1);// optionalPSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);GameApp *game = NULL;JGE *engine = NULL;
//------------------------------------------------------------------------------------------------
// Exit callbackint exit_callback(int arg1, int arg2, void *common){
if (engine != NULL) engine->End();
return 0;}//------------------------------------------------------------------------------------------------
// Callback threadint CallbackThread(SceSize args, void *argp){ int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0;}//------------------------------------------------------------------------------------------------
// Sets up the callback thread and returns its thread idint SetupCallbacks(void){ int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid;}
//------------------------------------------------------------------------------------------------
// Custom exception handler
void MyExceptionHandler(PspDebugRegBlock *regs)
{
pspDebugScreenInit();
pspDebugScreenSetBackColor(0x00FF0000);
pspDebugScreenSetTextColor(0xFFFFFFFF);
pspDebugScreenClear();
pspDebugScreenPrintf("I regret to inform you your psp has just crashed\n");
pspDebugScreenPrintf("Please contact Sony technical support for further information\n\n");
pspDebugScreenPrintf("Exception Details:\n");
pspDebugDumpException(regs);
pspDebugScreenPrintf("\nBlame the 3rd party software, it cannot possibly be our fault!\n");
sceKernelExitGame();
}
//------------------------------------------------------------------------------------------------
// Sort of hack to install exception handler under USER THREAD
__attribute__((constructor)) void handlerInit()
{
pspKernelSetKernelPC();
pspDebugInstallErrorHandler(MyExceptionHandler);
}
//------------------------------------------------------------------------------------------------
// The main loopint main(){
scePowerSetClockFrequency(333, 333, 166);
SetupCallbacks();
engine = JGECreate();
//engine->Init(0);
game = new GameApp(engine);
game->Create();
engine->SetApp(game);
engine->Run();
game->Destroy();
delete game;
game = NULL;
JGERelease();
sceKernelExitGame();
return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -