How have i set my main.c file up wrong or what do i need to add?
Code: Select all
#include <oslib/oslib.h>
#include <psploadexec_kernel.h>
#include <psploadexec_kernel.h>
#include <systemctrl.h>
#include <stdio.h>
#include <stdlib.h>
PSP_MODULE_INFO("PSPWindows", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
void RunPBP(char* file){
struct SceKernelLoadExecVSHParam param;
char argp[256];
int  args;
strcpy(argp, file);
args = strlen(file)+1;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = args;
param.argp = argp;
param.key = NULL;
param.vshmain_args_size = 0;
param.vshmain_args = NULL;
sctrlKernelLoadExecVSHMs2(file,¶m);
}
//declaration of the pointers of our images
OSL_IMAGE *background, *sprite, *taskbar, *startmenu, *item1;
int collision(int x0, int y0, int x1, int y1, int w0, int h0, int w1, int h1)
{
	int hit = 0;
	
	if(x0+w0 > x1 && x0 < x1+w1 && y0+h0 > y1 && y0 < y1+h1)hit = 1;
	
	return hit;
}
//Main
int main(){
//Set item starting positions
	int item1X = 0;
	int item1Y = 0;
	int item2X = 50;
	int item2Y = 70;
	int item3X = 50;
	int item3Y = 90;
	//Set sprites starting position
		int spriteX;
		int spriteY;
	
	//Initialization of the Oslib library
	oslInit(0);
	//Initialization of the graphics mode
	oslInitGfx(OSL_PF_8888, 1);
	//loads our images into memory
	background = oslLoadImageFile("background.png", OSL_IN_RAM, OSL_PF_5551);
	taskbar = oslLoadImageFile("taskbar.png", OSL_IN_RAM, OSL_PF_5551);
	startmenu = oslLoadImageFile("startmenu.png", OSL_IN_RAM, OSL_PF_5551);
	sprite = oslLoadImageFile("sprite.png", OSL_IN_RAM, OSL_PF_5551);
	item1 = oslLoadImageFile("internet.png", OSL_IN_RAM, OSL_PF_5551);
	//Verification that all files are present
	if (!background || !sprite)
		oslFatalError("It is impossible to load one or more of the images that are required in this program. Please make sure you have all the files required in the eboot folder");
	
	//Main while loop
	while (!osl_quit)
	{
		//To be able to draw on the screen
		oslStartDrawing();
		
		//initiate the PSP's buttons
		oslReadKeys();
		if (osl_keys->pressed.start)
			oslDrawImage(startmenu);
		//Sprite movement
		if (osl_keys->analogX > 50) sprite->x += 2;
		if (osl_keys->analogX < -50) sprite->x -= 2;
		if (osl_keys->analogY > 50) sprite->y += 2;
		if (osl_keys->analogY < -50) sprite->y -= 2;
		
		//Draw the images to the screen
		oslDrawImage(background);
		oslDrawImage(taskbar);
		oslReadKeys();
		if (osl_keys->held.start)
			oslDrawImage(startmenu);
		oslDrawImage(item1);
		oslReadKeys();
		if(osl_keys->held.cross)//If cross is pressed
		{
			if(collision(spriteX, spriteY, item1X, item1Y, 50, 50, 50, 50) && !(collision(spriteX, spriteY, item2X, item2Y, 50, 50, 50, 50)) && !(collision(spriteX, spriteY, item3X, item3Y, 50, 50, 50, 50)))//If the sprite is on the first item and not on the other two
			{
				RunPBP("ms0:/PSP/GAME/GTH/EBOOT.PBP");
			}
			if(collision(spriteX, spriteY, item2X, item2Y, 50, 50, 50, 50) && !(collision(spriteX, spriteY, item1X, item1Y, 50, 50, 50, 50)) && !(collision(spriteX, spriteY, item3X, item3Y, 50, 50, 50, 50)))//If the sprite is on the second item and not on the other two
			{
				//Set the items X & Y to the sprites
				item2X = spriteX;
				item2Y = spriteY;
			}
			if(collision(spriteX, spriteY, item3X, item3Y, 50, 50, 50, 50) && !(collision(spriteX, spriteY, item1X, item1Y, 50, 50, 50, 50)) && !(collision(spriteX, spriteY, item2X, item2Y, 50, 50, 50, 50)))//If the sprite is on the third item and not on the other two
			{
				//Set the items X & Y to the sprite's
				item3X = spriteX;
				item3Y = spriteY;
			}
		}
		
	    	oslDrawImage(sprite);
		//Ends drawing mode
		oslEndDrawing();
		//Synchronizes the screen 
		oslSyncFrame();	
	}
	
	//Terminate the program
	oslEndGfx();
	oslQuit();
	return 0;
}