Ejemplo n.º 1
0
/***
 * Main entrypoint of the emulator
 */
int main()
{
    // first, initialize Vita2D
    printf("Starting CATSFC-libretro-VITA");
    vita2d_init_advanced(8 * 1024 * 1024);

    // do some setup
    setup_input();
    setup_callbacks();
    setup_audio();

    pl_psp_init("ux0:/data/CATSFC-libretro-VITA/");

    // get the game ready
    if (InitMenu())
    {
        DisplayMenu();
        TrashMenu();
    }

    // once emulation is complete, shut down and exit
    vita_cleanup();

    sceKernelExitProcess(0);
    return 0;
}
Ejemplo n.º 2
0
int main()
{
	char rom_path[PATH_MAX];

	printf("Starting NES4Vita by SMOKE");

	vita2d_init();

	while (1) {
		emu = new Nes_Emu();

		file_choose(
			"cache0:/VitaDefilerClient/Documents",
			rom_path,
			"Choose a NES ROM:",
			supported_ext
			);

		printf("Loading emulator.... %s", rom_path);
		run_emu(rom_path);

		delete emu;
	}

	vita2d_fini();
	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 3
0
static void frontend_psp_shutdown(bool unused)
{
   (void)unused;
#ifdef VITA
   sceKernelExitProcess(0);
#else
   sceKernelExitGame();
#endif
}
Ejemplo n.º 4
0
int main(int argc, const char *argv[]) {
	char *titleid = get_title_id(PACKAGE_DIR "/sce_sys/param.sfo");
	if (titleid && strcmp(titleid, "VITASHELL") == 0) {
		if (promote(PACKAGE_DIR) >= 0)
			launchAppByUriExit("VITASHELL");
	}

	return sceKernelExitProcess(0);
}
Ejemplo n.º 5
0
int main()
{
	SceCtrlData pad;
	vita2d_pgf *pgf;
	vita2d_texture *image;
	float rad = 0.0f;

	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	pgf = vita2d_load_default_pgf();

	/*
	 * Load the statically compiled image.png file.
	 */
	image = vita2d_load_PNG_buffer(&_binary_image_png_start);

	memset(&pad, 0, sizeof(pad));

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);

		if (pad.buttons & SCE_CTRL_START)
			break;

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_rectangle(20, 20, 400, 250, RGBA8(255, 0, 0, 255));
		vita2d_draw_rectangle(680, 350, 100, 150, RGBA8(0, 0, 255, 255));
		vita2d_draw_fill_circle(200, 420, 100, RGBA8(0, 255,0 ,255));

		vita2d_draw_texture_rotate(image, 940/2, 544/2, rad);

		vita2d_draw_line(500, 30, 800, 300, RGBA8(255, 0, 255, 255));

		vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0,255,0,255), 1.0f, "PGF Font sample!");

		vita2d_end_drawing();
		vita2d_swap_buffers();

		rad += 0.1f;
	}

	/*
	 * vita2d_fini() waits until the GPU has finished rendering,
	 * then we can free the assets freely.
	 */
	vita2d_fini();
	vita2d_free_texture(image);
	vita2d_free_pgf(pgf);

	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 6
0
int main()
{
	int ret;
	ret=debugNetInit(ip_server,port_server,DEBUG);
	debugNetPrintf(DEBUG,"Test debug level %d\n",ret);
	debugNetPrintf(ERROR,"Test error level %d\n",ret);
	debugNetPrintf(INFO,"Test info level %d\n",ret);	
	debugNetFinish();
	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 7
0
int main()
{
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	vita2d_pgf *pgf = vita2d_load_default_pgf();

	vita2d_texture *tex = vita2d_create_empty_texture(128, 128);
	unsigned int *tex_data = vita2d_texture_get_datap(tex);

	SceCtrlData pad;
	memset(&pad, 0, sizeof(pad));

	float rad = 0.0f;

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
		if (pad.buttons & SCE_CTRL_START) break;

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_rectangle(20, 20, 400, 250, RGBA8(255, 0, 0, 255));
		vita2d_draw_rectangle(680, 350, 100, 150, RGBA8(0, 0, 255, 255));
		vita2d_draw_fill_circle(200, 420, 100, RGBA8(0, 255,0 ,255));

		/* Fill the texture with random data */
		int i, j;
		for (i = 0; i < 128; i++) {
			for (j = 0; j < 128; j++) {
				tex_data[j + i*128] = rand();
			}
		}

		vita2d_draw_texture_rotate(tex, 940/2, 544/2, rad);

		vita2d_draw_line(500, 30, 800, 300, RGBA8(255, 0, 255, 255));

		vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0,255,0,255), 1.0f, "PGF Font sample!");

		vita2d_end_drawing();
		vita2d_swap_buffers();

		rad += 0.1f;
	}

	vita2d_fini();
	vita2d_free_texture(tex);
	vita2d_free_pgf(pgf);

	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 8
0
int main()
{
    sceIoRemove("ux0:/id.dat");

    SceUID id;
    id = sceIoOpen("ux0:/id.dat", SCE_O_WRONLY|SCE_O_CREAT, 0777);

    sceIoWrite(id, NULL, 0x0);

	sceKernelExitProcess(0);

    return 0;
}
Ejemplo n.º 9
0
/***
 * Initializes our keybinding to handle input later on.
 */
void setup_input()
{
	pad = (SceCtrlData*)malloc(sizeof(SceCtrlData));
	keymap = (uint32_t*)malloc(sizeof(uint32_t) * 12);

	sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);

    if (!pad || !keymap)
    {
        printf("Unable to allocate memory for input data. Bailing.");
        sceKernelExitProcess(0);
    }
}
Ejemplo n.º 10
0
int launchAppByUriExit(char *titleid) {
	char uri[32];
	sprintf(uri, "psgm:play?titleid=%s", titleid);

	sceKernelDelayThread(10000);
	sceAppMgrLaunchAppByUri(0xFFFFF, uri);
	sceKernelDelayThread(10000);
	sceAppMgrLaunchAppByUri(0xFFFFF, uri);

	sceKernelExitProcess(0);

	return 0;
}
Ejemplo n.º 11
0
int main()
{
    char rom_path[PATH_MAX];

    printf("\nRealBoy %s\n", "0.2.2");

    sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);

    vita2d_init();
    vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

    while (1) {
        strcpy(current_dir, "ux0:");

        int ret = file_choose(
                      current_dir,
                      rom_path,
                      "Choose a GB/GB Color/Super GB ROM:",
                      supported_ext
                  );

        if (ret == -1)
            break;

        if ( (rom_file = fopen(rom_path, "r")) == NULL) {
            printf("\nError opening %s\n", rom_path);
            continue;
        }

        file_path = strndup(rom_path, 256);

        if (rom_file != NULL)	{
            init_conf();
            int ret_val; // value returned from emulation
            /* Start Virtual Machine */
            ret_val = start_vm();
            /* Error returned if file not valid */
            if (ret_val == -1) {
                printf("File %s not a gb binary\n\n", rom_path);
            }
        }

        free(file_path);
    }

    vita2d_fini();

    sceKernelExitProcess(0);
    return 0;
}
Ejemplo n.º 12
0
int main() {
	SceCtrlData pad;
	vita2d_pgf *pgf;
	vita2d_texture *image;
	float rad = 0.0f;
  
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
  
	pgf = vita2d_load_default_pgf();
  
	image = vita2d_load_PNG_buffer(&_binary_image_png_start);
  
	memset(&pad, 0, sizeof(pad));
  
	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
	
		if (pad.buttons & SCE_CTRL_START)
			break;
	
		vita2d_start_drawing();
		vita2d_clear_screen();
	
		vita2d_draw_texture_rotate(image, 940/2, 544/2, rad);
	
		vita2d_pgf_draw_text(pgf, 50, 50, RGBA8(255,255,255,255), 1.0f, "ミクのおっぱい柔かぁい。柔軟剤使ったのか?");
	
		vita2d_end_drawing();
		vita2d_swap_buffers();
	
		rad += 0.1f;
	}
  
	vita2d_fini();
	vita2d_free_texture(image);
	vita2d_free_pgf(pgf);
  
	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 13
0
int main(int argc, char** argv)
{
	init();

	bool forcedmg = false;
	bool nosound = false;

	if (theGearboyCore->LoadROM(ROM_PATH, forcedmg)) {
		theGearboyCore->EnableSound(!nosound);
		theGearboyCore->LoadRam();

		while (running) {
			update();
		}

		theGearboyCore->SaveRam();
	}

	end();

	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 14
0
Archivo: main.c Proyecto: barooney/pkg
int main()
{
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	vita2d_pgf *pgf = vita2d_load_default_pgf();

	SceCtrlData pad;
	memset(&pad, 0, sizeof(pad));

        vu_rectangle *r = vu_rectangle_new();
        vu_rectangle_set_color(r, (vec4){0xFF, 0x00, 0x00, 0xFF});
        vu_rectangle_resize(r, (vec2){200, 200});

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);

		if (pad.buttons & SCE_CTRL_START)
			break;

		vita2d_start_drawing();
		vita2d_clear_screen();

                vu_rectangle_render(r);

		vita2d_pgf_draw_text(pgf, 20, 30, RGBA8(0xFF,0xFF,0xFF,0xFF), 1.0f, "PS Vita Package Manager");

		vita2d_end_drawing();
		vita2d_swap_buffers();
	}

	vita2d_free_pgf(pgf);
	//vita2d_fini(); crashes

	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[]) {
	printf("Hello, world!\n");
	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 16
0
/***
 * Initializes the audio buffers and a callback thread for each channel.
 */
int setup_audio()
{
    int i, j, failed;

    stop_audio = 0;

    for (i = 0; i < AUDIO_CHANNELS; i++)
    {
        audio_status[i].Handle = -1;
        audio_status[i].ThreadHandle = -1;
        audio_status[i].LeftVolume = PSP_AUDIO_MAX_VOLUME;
        audio_status[i].RightVolume = PSP_AUDIO_MAX_VOLUME;
        audio_status[i].Callback = NULL;
        audio_status[i].Userdata = NULL;

        for (j = 0; j < 2; j++)
        {
            audio_buffer[i][j] = NULL;
            audio_buffer_samples[i][j] = 0;
        }
    }

    /* Initialize buffers */
    for (i = 0; i < AUDIO_CHANNELS; i++)
    {
        for (j = 0; j < 2; j++)
        {
            if (!(audio_buffer[i][j] = (short*)malloc(AUDIO_SAMPLE_COUNT * sizeof(PspStereoSample))))
            {
                printf("Couldn't initialize audio buffer for channel %i, bailing.", i);
                free_buffers();
                sceKernelExitProcess(0);

                return 0;
            }

            audio_buffer_samples[i][j] = AUDIO_SAMPLE_COUNT;
        }
    }

    /* Initialize channels */
    for (i = 0, failed = 0; i < AUDIO_CHANNELS; i++)
    {
        audio_status[i].Handle = sceAudioOutOpenPort(SCE_AUDIO_OUT_PORT_TYPE_VOICE, AUDIO_SAMPLE_COUNT, AUDIO_OUTPUT_RATE, SCE_AUDIO_OUT_MODE_STEREO);

        if (audio_status[i].Handle < 0)
        {
            failed = 1;
            break;
        }
    }

    if (failed)
    {
        for (i = 0; i < AUDIO_CHANNELS; i++)
        {
            if (audio_status[i].Handle != -1)
            {
                sceAudioOutReleasePort(audio_status[i].Handle);
                audio_status[i].Handle = -1;
            }
        }

        printf("Couldn't open audio port for the device, bailing.");
        free_buffers();
        sceKernelExitProcess(0);

        return 0;
    }

    char label[16];
    strcpy(label, "audiotX");

    for (i = 0; i < AUDIO_CHANNELS; i++)
    {
        label[6] = '0' + i;
        audio_status[i].ThreadHandle =
            sceKernelCreateThread(label, (void*)&audio_channel_thread, 0x10000100, 0x10000,
                0, 0, NULL);

        if (audio_status[i].ThreadHandle < 0)
        {
            audio_status[i].ThreadHandle = -1;
            failed = 1;
            break;
        }

        if (sceKernelStartThread(audio_status[i].ThreadHandle, sizeof(i), &i) != 0)
        {
            failed = 1;
            break;
        }
    }

    if (failed)
    {
        stop_audio = 1;

        for (i = 0; i < AUDIO_CHANNELS; i++)
        {
            if (audio_status[i].ThreadHandle != -1)
            {
                sceKernelDeleteThread(audio_status[i].ThreadHandle);
            }

            audio_status[i].ThreadHandle = -1;
        }


        printf("Couldn't initialize audio callback thread. Bailing.");
        sceKernelExitProcess(0);

        return 0;
    }

    // initialize the buffer our libretro audio callback will fill with data as it's available
    retro_audio_callback_buffer = (int16_t*)malloc(sizeof(int16_t) * AUDIO_SAMPLE_COUNT * 4);

    if (!retro_audio_callback_buffer)
    {
        printf("Couldn't initialize retro_audio_callback_buffer. Bailing.");
        sceKernelExitProcess(0);
    }

    curr_buffer_frames = 0;

    // setup our callbacks
    set_audio_channel_callback(0, audio_callback, 0);

    // initialize the audio buffer mutex
    audio_mutex = sceKernelCreateMutex("AudioMutex", 0, 1, 0);

    return AUDIO_SAMPLE_COUNT;
}
Ejemplo n.º 17
0
int main()
{
	char vita_ip[16];
	unsigned short int vita_port = 0;
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
	clr_color = 0x000000FF;
	vita2d_texture* texture_splash = vita2d_load_JPEG_buffer(splash, size_splash);
	vita2d_start_drawing();
	vita2d_draw_texture(texture_splash, 0, 0);
	vita2d_end_drawing();
	vita2d_swap_buffers();
	sceKernelDelayThread(4000000);
	vita2d_start_drawing();
	vita2d_clear_screen();
	vita2d_end_drawing();
	vita2d_swap_buffers();
	vita2d_free_texture(texture_splash);
	SceCtrlData pad;
	SceCtrlData oldpad;
	while (1) {
		
		// Load main script
		SceUID id = sceIoDopen("cache0:/lpp");
		SceIoDirent entry;
		memset(&entry, 0, sizeof(SceIoDirent));
		while (sceIoDread(id, &entry) > 0){
			script_files++;
			memset(&entry, 0, sizeof(SceIoDirent));
		}
		sceIoDclose(id);
		if (script_files>1) errMsg = runScript((const char*)main_menu, true);
		else{
			SceUID main_file = sceIoOpen("cache0:/lpp/index.lua", PSP2_O_RDONLY, 0777);
			if (main_file < 0) errMsg = "index.lua not found.";
			else{
				SceOff size = sceIoLseek(main_file, 0, SEEK_END);
				if (size < 1) errMsg = "Invalid main script.";
				else{
					sceIoLseek(main_file, 0, SEEK_SET);
					script = (unsigned char*)malloc(size + 1);
					sceIoRead(main_file, script, size);
					script[size] = 0;
					sceIoClose(main_file);
					errMsg = runScript((const char*)script, true);
					free(script);
				}
			}
		}
		
		if (errMsg != NULL){
			if (strstr(errMsg, "lpp_shutdown")) break;
			else{
				int restore = 0;
				bool s = true;
				while (restore == 0){
					vita2d_start_drawing();
					vita2d_clear_screen();
					font_draw_string(10, 10, RGBA8(255, 255, 255, 255), "An error occurred:");
					font_draw_string(10, 30, RGBA8(255, 255, 255, 255), errMsg);
					font_draw_string(10, 70, RGBA8(255, 255, 255, 255), "Press X to restart.");
					font_draw_string(10, 90, RGBA8(255, 255, 255, 255), "Press O to enable/disable FTP.");
					if (vita_port != 0){
						font_draw_stringf(10, 150, RGBA8(255, 255, 255, 255), "PSVITA listening on IP %s , Port %u", vita_ip, vita_port);
					}
					vita2d_end_drawing();
					vita2d_swap_buffers();
					if (s){
						sceKernelDelayThread(800000);
						s = false;
					}
					sceCtrlPeekBufferPositive(0, &pad, 1);
					if (pad.buttons & PSP2_CTRL_CROSS) {
						errMsg = NULL;
						restore = 1;
						if (vita_port != 0){
							ftp_fini();
							vita_port = 0;
						}
						sceKernelDelayThread(800000);
					}else if ((pad.buttons & PSP2_CTRL_CIRCLE) && (!(oldpad.buttons & PSP2_CTRL_CIRCLE))){
						if (vita_port == 0) ftp_init(vita_ip, &vita_port);
						else{
							ftp_fini();
							vita_port = 0;
						}
					}
					oldpad = pad;
				}
			}
		}
	}

	vita2d_fini();
	sceKernelExitProcess(0);
	return 0;
}
Ejemplo n.º 18
0
int main()
{
    lua_State *lua = luaL_newstate();
    lua_atpanic(lua, panic);

    // Net init
    sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
    SceNetInitParam netInitParam;
    int size = 1024 * 512;
    netInitParam.memory = malloc(size);
    netInitParam.size = size;
    netInitParam.flags = 0;
    sceNetInit(&netInitParam);

    sceSysmoduleLoadModule(SCE_SYSMODULE_HTTP);
#ifdef DEBUGGER_IP
    debugNetInit(DEBUGGER_IP, DEBUGGER_PORT, DEBUG);
#endif
    sceHttpInit(1024 * 50);

    // Init libs
    debugf("Init libs....\n");
    debugf("vita2d...\n");
    vita2d_init();
    debugf("physfs\n");
    PHYSFS_init(NULL);
    debugf("lualibs\n");
    luaL_openlibs(lua);
    debugf("ffi\n");
    open_ffi(lua);

    lua_pushcfunction(lua, print);
    lua_setglobal(lua, "print");

    /*
    // Display splash
    unsigned int goal = 2*60;
    unsigned int counter = 0;
    vita2d_texture *tex = vita2d_load_PNG_buffer(splash_data);
    SceCtrlData pad;
    memset(&pad, 0, sizeof(pad));
    for (;;) {
        ++counter;
        if (counter >= goal)
            break;
        sceCtrlPeekBufferPositive(0, &pad, 1);
        if (pad.buttons & SCE_CTRL_ANY)
            break;
        vita2d_start_drawing();
        vita2d_clear_screen();
        vita2d_draw_texture(tex, 0, 0);
        vita2d_end_drawing();
        vita2d_swap_buffers();
    }
    */

    debugf("[Lua] Loading app0:/lib/init.lua ...\n");
    if(luaL_loadfile(lua, "app0:/lib/init.lua") == 0)
    {
        if(lua_pcall(lua, 0, 0, 0) != 0)
        {
            debugf("[Lua] init error: %s\n", lua_tostring(lua, -1));
            lua_pop(lua, 1);
        }
    }

    /*debugf("[Lua] Loading app0:/boot.lua ...\n");
    if(luaL_loadfile(lua, "app0:/boot.lua") == 0)
    {
        if(lua_pcall(lua, 0, 0, 0) != 0)
        {
            debugf("[Lua] bootscript err: %s\n", lua_tostring(lua, -1));
            lua_pop(lua, 1);
        }
    }
    else
    {
    debugf("[Lua] bootscript load err: %s\n", lua_tostring(lua, -1));
        lua_pop(lua, 1);
    }*/

    debugf("Deinit. Goodbye.\n");
    sceHttpTerm();
    PHYSFS_deinit();
    vita2d_fini();
    //vita2d_free_texture(tex);

    sceKernelExitProcess(0);
    return 0;
}
Ejemplo n.º 19
0
int panic(lua_State *l)
{
    debugf("Lua paniced with '%s!'\n", lua_tostring(l, -1));
    sceKernelExitProcess(0);
    return 0;
}
Ejemplo n.º 20
0
int main()
{
	init_video();

	/* Enable analog stick */
	sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);

	/* Enable front touchscreen */
	sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, 1);

	/* FPS counting */
	SceUInt64 cur_micros = 0, delta_micros = 0, last_micros = 0;
	uint32_t frames = 0;
	float fps = 0.0f;

	/* Square variables */
	int w = 60;
	int h = 60;
	int x = SCREEN_W/2 - w/2;
	int y = SCREEN_H/2 - h/2;
	int speed = 2;
	uint32_t color = RGBA8(255, 0, 0, 255);

	/* Input variables */
	SceCtrlData pad;
	SceTouchData touch;
	signed char lx, ly, rx, ry;

	while (1) {
		clear_screen();

		/* Read controls and touchscreen */
		sceCtrlPeekBufferPositive(0, &pad, 1);
		sceTouchPeek(0, &touch, 1);

		if (pad.buttons & SCE_CTRL_START) {
			break;
		}

		font_draw_string(10, 10, RGBA8(0, 0, 255, 255), "PSVita sample by xerpi!");
		font_draw_stringf(SCREEN_W - 160, 10, RGBA8(0, 255, 0, 255), "FPS: %.2f", fps);
		font_draw_stringf(10, 30, RGBA8(255, 0, 0, 255),
			"(%3d, %3d) size: (%d, %d) speed: %d\n", x, y, w, h, speed);

		/* Move the rectangle */
		if (pad.buttons & SCE_CTRL_UP) {
			y -= speed;
		} else 	if (pad.buttons & SCE_CTRL_DOWN) {
			y += speed;
		}
		if (pad.buttons & SCE_CTRL_LEFT) {
			x -= speed;
		} else 	if (pad.buttons & SCE_CTRL_RIGHT) {
			x += speed;
		}

		if (pad.buttons & SCE_CTRL_LTRIGGER) {
			speed--;
			if (speed < 0) speed = 0;
		} else 	if (pad.buttons & SCE_CTRL_RTRIGGER) {
			speed++;
			if (speed > 100) speed = 100;
		}

		if (pad.buttons & SCE_CTRL_CROSS) {
			color = RGBA8(rand()%255, rand()%255, rand()%255, 255);
		}

		/* Update joystick values */
		lx = (signed char)pad.lx - 128;
		ly = (signed char)pad.ly - 128;
		rx = (signed char)pad.rx - 128;
		ry = (signed char)pad.ry - 128;

		/* Move using the left yoystick */
		if (abs(lx) > 50) {
			x += speed * lx/50.0f;
		}
		if (abs(ly) > 50) {
			y += speed * ly/50.0f;
		}

		/* Resize using the right yoystick */
		if (abs(rx) > 50) {
			w += rx/15.0f;
			if (w < 5) {
				w = 5;
			} else if (w > SCREEN_W) {
				w = SCREEN_W;
			}
		}
		if (abs(ry) > 50) {
			h += ry/15.0f;
			if (h < 5) {
				h = 5;
			} if (h > SCREEN_H) {
				h = SCREEN_H;
			}
		}

		/* Move using the touchscreen! */
		if (touch.reportNum > 0) {
			/* Front touchscreen: 1920x1088 */
			x = lerp(touch.report[0].x, 1920, SCREEN_W) - w/2;
			y = lerp(touch.report[0].y, 1088, SCREEN_H) - h/2;
		}

		/* Check left and right collisions */
		if (x < 0) {
			x = 0;
		} else if ((x + w) > SCREEN_W) {
			x = SCREEN_W - w;
		}

		/* Check top and bottom collisions */
		if (y < 0) {
			y = 0;
		} else if ((y + h) > SCREEN_H) {
			y = SCREEN_H - h;
		}

		/* Draw the rectangle */
		draw_rectangle(x, y, w, h, color);

		/* Draw a circle */
		draw_circle(SCREEN_W / 2, SCREEN_H / 2, 50, RGBA8(0,0,255,255));

		/* Calculate FPS */
		cur_micros = sceKernelGetProcessTimeWide();

		if (cur_micros >= (last_micros + 1000000)) {
			delta_micros = cur_micros - last_micros;
			last_micros = cur_micros;
			fps = (frames/(double)delta_micros)*1000000.0f;
			frames = 0;
		}

		swap_buffers();
		sceDisplayWaitVblankStart();
		frames++;
	}

	end_video();
	sceKernelExitProcess(0);
	return 0;
}