So I've been trying to write a few basic programs to test out the development tools but I'm running into a major problem: every time I try to paste a section of an image to the screen, it just crashes the PSP. I've confirmed that if I don't try and paste anything but text to the screen or if I paste the whole image of a smaller image to the screen it works fine, but cutting out sections doesn't work.
I stripped the sourcode down to just this to try and isolate the problem, and it's still happening:
#include <stdio.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <psppower.h>
#include <png.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "graphics.h"
#include "framebuffer.h"
#ifdef __cplusplus
}
#endif
PSP_MODULE_INFO("Test Game", 0, 1, 1);
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
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 main() {
scePowerSetClockFrequency(333, 333, 166);
SetupCallbacks();
initGraphics();
Image *map = loadImage("pnglol.png");
int i = 0;
SceCtrlData pad;
char filler[10];
Color highlightColor = RGB(255, 255, 255);
Color shadowColor = RGB(55, 55, 55 );
while(1)
{
fillScreenRect( RGB(255,255,255), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
sceCtrlReadBufferPositive(&pad, 1);
//actual image size is 1000x1000
blitAlphaImageToScreen( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, map, 0, 0); //this will always crash the program
sprintf(filler, "Picture On");
printTextScreen(11, 10, filler, shadowColor);
printTextScreen(10, 10, filler, highlightColor);
flipScreen();
for( i=0; i<3; i++ ) {
sceDisplayWaitVblankStart();
}
}
return 0;
}
I'm using visual studios with the minPSPdevkit and the headers are the same ones provided in these tutorials:
http://www.psp-programming.com/tutorials/c/lesson04.htmWould really appreciate some help on this, don't really know what I can do