main.c
Code: Select all
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudiolib.h>
#include <pspaudio.h>
#include <psppower.h>
#include <stdio.h>
#include <pspgu.h>
// #include <math.h>
// #include <string.h>
#include "main.h"
#include "graphics.h"
#include "mp3player.h"
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("deathcore", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback() {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int 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 id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int SetupMenuBG(){
char buff[200];
Image* menu;
pspDebugScreenInit();
sprintf(buff, "menu.png");
menu = loadImage(buff);
if(!menu)
{
pspDebugScreenClear();
printf("error upon displaying image\n");
printf("Autoexiting...");
sceKernelSleepThread();
}
else
{
sceDisplayWaitVblankStart();
blitImageToScreen(0, 0, 480, 272, menu, 0, 0);
flipScreen();
sceKernelSleepThread();
}
return 0;
}
int Music_player(char* fileName)
{
MP3_Init(1);
MP3_Load(fileName);
MP3_Play();
return *fileName;
}
int main(){
SceCtrlData pad;
pspDebugScreenInit();
initGraphics();
SetupCallbacks;
SetupMenuBG();
pspAudioInit();
Music_player("menu.mp3");
pspDebugScreenSetXY(25, 0);
pspDebugScreenSetTextColor(0xFF9900); // orange or red-orange
printf("<--DeathCore_V1.0 By Rangu2057-->");
pspDebugScreenSetXY(25, 5);
printf("New Game");
pspDebugScreenSetXY(25, 8);
printf("Load Save");
pspDebugScreenSetXY(25, 11);
printf("Options");
pspDebugScreenSetXY(25, 14);
printf("Credits");
int current = 0;
return current;
switch (current) {
case 0:
pspDebugScreenSetXY(20, 5);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 1:
pspDebugScreenSetXY(20, 8);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 2:
pspDebugScreenSetXY(20, 11);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
case 3:
pspDebugScreenSetXY(20, 14);
pspDebugScreenSetTextColor(0x28AE7B); // emerald
printf("]--->");
}
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_DOWN)
{
current += 1;
}
if(pad.Buttons & PSP_CTRL_UP)
{
current -= 1;
}
if(pad.Buttons & PSP_CTRL_HOME)
{
sceKernelExitGame();
}
}
}