Пример #1
1
extern "C" int main(int argc, char *argv[]) {
	// Let's not bother debugging to the display, since we'll just mess it up anyway.
	HAS_DISPLAY = 0;

	sceDisplaySetMode(0, 480, 272);
	sceDisplaySetFrameBuf(0, 0, 0, 1);
	sceDisplaySetFrameBuf(0, 0, 0, 0);

	checkpointNext("While off:");
	sceDisplayWaitVblankStart();
	testStateScenarios();

	sceDisplaySetFrameBuf((void *)0x04000000, 512, 3, 1);
	sceDisplaySetFrameBuf((void *)0x04000000, 512, 3, 0);

	checkpointNext("While on:");
	sceDisplayWaitVblankStart();
	testStateScenarios();

	sceDisplaySetFrameBuf(0, 0, 0, 1);
	checkpointNext("Latched off");
	testIsState("  Latched off");

	return 0;
}
Пример #2
0
extern "C" int main(int argc, char *argv[]) {
	checkpointNext("sceDisplayAdjustAccumulatedHcount:");
	testAdjustHcount("  -1", -1);
	testAdjustHcount("  INT_MIN", 0x80000000);
	testAdjustHcount("  INT_MAX", 0x7FFFFFFF);
	testAdjustHcount("  0", 0);

	checkpointNext("sceDisplayGetAccumulatedHcount:");
	testAdjustHcount("  Adjust to INT_MAX", 0x7FFFFFFF);
	int wrappedH = sceDisplayGetAccumulatedHcount();
	if (wrappedH < 5) {
		checkpoint("  Wrapped around to 0: OK");
	} else {
		checkpoint("  Wrapped around to 0: Failed %d", wrappedH);
	}

	// Okay, let's gather some statistics.
	int minH = 1000;
	int maxH = 0;
	int maxStrideH = 0;
	int lastH = 0;
	
	sceDisplayWaitVblankStart();
	sceDisplayAdjustAccumulatedHcount(0x7FFFFFFF);
	for (int i = 0; i < 60; ++i) {
		sceDisplayWaitVblankStart();
		int h = sceDisplayGetCurrentHcount();
		int totalH = sceDisplayGetAccumulatedHcount();

		if (h < minH) {
			minH = h;
		}
		if (totalH - lastH > maxStrideH) {
			maxStrideH = totalH - lastH;
		}
		lastH = totalH;

		while (sceDisplayIsVblank()) {
			h = sceDisplayGetCurrentHcount();
			if (h > maxH) {
				maxH = h;
			}
		}
	}
	int avgH = sceDisplayGetAccumulatedHcount() / 60;

	checkpointNext("sceDisplayGetCurrentHcount:");

	// Generally, 1, 14, 286, 286.
	checkpoint("  (NOTE: not always consistent, use a few runs to get common numbers.)");
	checkpoint("  Lowest: %d", minH);
	checkpoint("  Highest (in vblank): %d", maxH);
	checkpoint("  Highest stride: %d", maxStrideH);
	checkpoint("  Average: %d", avgH);

	return 0;
}
Пример #3
0
int waitbutton(int mask) {
    SceCtrlData paddata;
    do {
        sceDisplayWaitVblankStart();
        sceCtrlReadBufferPositive(&paddata, 1);
    } while((paddata.Buttons & mask));
    do {
        sceDisplayWaitVblankStart();
        sceCtrlReadBufferPositive(&paddata, 1);
    } while(!(paddata.Buttons & mask));
    return paddata.Buttons;
}
Пример #4
0
void loadTheme()
{
	int i, bytesRead;

	SceUID fp;
	fp = sceIoOpen("ms0:/lockdown.thm", PSP_O_RDONLY, 0777);

	if (fp < 0)
	{
		fp = sceIoOpen("flash0:/lockdown.thm", PSP_O_RDONLY, 0777);

		if (fp < 0)
		{
			printTextScreen(0, 0, "Error loading flash0:/lockdown.thm.", RGB(255, 0, 0));
			printTextScreen(0, 8, "Place theme at ms0:/lockdown.thm to load from memory stick.", RGB(255, 0, 0));
			sceDisplayWaitVblankStart();
			flipScreen();
			sceKernelSleepThread();
		}
	}

	for (i = 0; i < NUMFILES; i++)
	{
		bytesRead = sceIoRead(fp, &images[i].hdr, sizeof(imagehdr));
		if (bytesRead != sizeof(imagehdr))
		{
			printTextScreen(0, 0, "Unexpected end of header.", RGB(255, 0, 0));
			sceDisplayWaitVblankStart();
			flipScreen();
			sceKernelSleepThread();
		}
		images[i].blockid = sceKernelAllocPartitionMemory(2, "block", 0, (sizeof(unsigned char) * images[i].hdr.size), NULL);
		if (images[i].blockid < 0)
		{
			printTextScreen(0, 0, "Memory allocation error.", RGB(255, 0, 0));
			sceDisplayWaitVblankStart();
			flipScreen();
			sceKernelSleepThread();
		}
		images[i].data = (unsigned char*) sceKernelGetBlockHeadAddr(images[i].blockid);
		bytesRead = sceIoRead(fp, images[i].data, images[i].hdr.size);
		if (bytesRead != images[i].hdr.size)
		{
			printTextScreen(0, 0, "Unexpected end of data.", RGB(255, 0, 0));
			sceDisplayWaitVblankStart();
			flipScreen();
			sceKernelSleepThread();
		}
	}

	sceIoClose(fp);
}
Пример #5
0
//mappa
void mappa(){
	 int y;
	 int x;
	 int xtile;
	 int ytile;
	 
	 for(y=0;y<34;y++){
		 for(x=0;x<60;x++){
			 ytile=floor(mappe[0][0][y][x][0] / tilesetw);
			 xtile=mappe[0][0][y][x][0]-((ytile)*tilesetw);
			 blitImageToImage(xtile*16 ,ytile*16,unita , unita, tile, x*unita, y*unita,terra);
			  
			 if( mappe[0][0][y][x][1] > 1){
				 ytile=floor(mappe[0][0][y][x][1] / tilesetw);
				 xtile=mappe[0][0][y][x][1]-((ytile)*tilesetw);
				 blitAlphaImageToImage(xtile*16 ,ytile*16,unita , unita, tile, x*unita, y*unita,terra);
			 }
			 if( mappe[0][0][y][x][2] > 1){
				 ytile=floor(mappe[0][0][y][x][2] / tilesetw);
				 xtile=mappe[0][0][y][x][2]-((ytile)*tilesetw);
				 blitAlphaImageToImage(xtile*16 ,ytile*16,unita , unita, tile, x*unita, y*unita,terra);
			 }
	 	 }
	 }
	  sceDisplayWaitVblankStart();
}
Пример #6
0
void vidgu_init()
{

	g_pBlitBuff = (unsigned short *)(0x40000000 | (unsigned int)&g_BlitBuff);

	sceGuInit();

	// setup
	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_5650,(void*)0,512);
	sceGuDispBuffer(480,272,(void*)0x88000,512);
	sceGuDepthBuffer((void*)0x110000,512);
	sceGuOffset(2048 - (480/2),2048 - (272/2));
	sceGuViewport(2048,2048,480,272);
	sceGuDepthRange(0xc350,0x2710);
	sceGuScissor(0,0,480,272);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
	sceGuFinish();
	sceGuSync(0,0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(1);

}
Пример #7
0
static void psp_free(void *data)
{
   psp1_video_t *psp = (psp1_video_t*)data;

   if(!(psp) || !(psp->main_dList))
      return;

   sceDisplayWaitVblankStart();
   sceGuDisplay(GU_FALSE);
   sceGuTerm();

   if (psp->main_dList)
      free(psp->main_dList);
   if (psp->frame_dList)
      free(psp->frame_dList);
   if (psp->frame_coords)
      free(TO_CACHED_PTR(psp->frame_coords));
   if (psp->menu.frame_coords)
      free(TO_CACHED_PTR(psp->menu.frame_coords));
   if (psp->menu.dList)
      free(psp->menu.dList);
   if (psp->menu.frame)
      free(psp->menu.frame);

   free(data);

   sceKernelDisableSubIntr(PSP_VBLANK_INT, 0);
   sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT,0);
}
Пример #8
0
void setupGu(void)
{
	sceGuInit();

	sceGuStart(GU_DIRECT, list);
	sceGuDrawBuffer(GU_PSM_8888, 0, BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
	sceGuDepthBuffer((void*)0x110000, BUF_WIDTH);

	sceGuOffset(0, 0);

	sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);

	sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
	sceGuEnable(GU_BLEND);

	//sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
	//sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR, GU_NEAREST);
	//sceGuTexWrap(GU_REPEAT, GU_REPEAT);

	sceGuClearColor(0);
	sceGuClearDepth(0);
	sceGuClearStencil(0);

	sceGuFinish();
	sceGuSync(0, 0);
	
	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);
}
Пример #9
0
void psp_init(void)
{
	SceUID thid;
	char buff[128], *r;

	/* fw 1.5 sometimes returns 8002032c, although getcwd works */
	r = getcwd(buff, sizeof(buff));
	if (r) sceIoChdir(buff);

	main_thread_id = sceKernelGetThreadId();

	lprintf("running on %08x kernel\n", sceKernelDevkitVersion()),
	lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id,
		sceKernelGetThreadCurrentPriority());

	thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, NULL);
	if (thid >= 0)
	{
		sceKernelStartThread(thid, 0, 0);
	}

	/* video */
	sceDisplaySetMode(0, 480, 272);
	sceDisplaySetFrameBuf(VRAM_FB1, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
	current_screen = 1;
	psp_screen = VRAM_FB0;

	/* gu */
	sceGuInit();

	sceGuStart(GU_DIRECT, guCmdList);
	sceGuDrawBuffer(GU_PSM_5650, (void *)VRAMOFFS_FB0, 512);
	sceGuDispBuffer(480, 272, (void *)VRAMOFFS_FB1, 512); // don't care
	sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
	sceGuDepthBuffer((void *)VRAMOFFS_DEPTH, 512);
	sceGuOffset(2048 - (480 / 2), 2048 - (272 / 2));
	sceGuViewport(2048, 2048, 480, 272);
	sceGuDepthRange(0xc350, 0x2710);
	sceGuScissor(0, 0, 480, 272);
	sceGuEnable(GU_SCISSOR_TEST);

	sceGuDepthMask(0xffff);
	sceGuDisable(GU_DEPTH_TEST);

	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
	sceGuAmbientColor(0xffffffff);
	sceGuColor(0xffffffff);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);


	/* input */
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}
Пример #10
0
void vidgu_render_nostretch(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
{
	int start, end;

	sceGuStart(GU_DIRECT,list);
	sceGuTexMode(GU_PSM_5650,0,0,0); // 16-bit RGBA
	sceGuTexImage(0,512,512,512,g_pBlitBuff); // setup texture as a 256x256 texture
	//sceKernelDcacheWritebackAll();
	sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA); // don't get influenced by any vertex colors
	sceGuTexFilter(GU_NEAREST,GU_NEAREST); // point-filtered sampling
	for (start = sx, end = sx+sw; start < end; start += SLICE_SIZE, dx += SLICE_SIZE)
	{
		struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
		int width = (start + SLICE_SIZE) < end ? SLICE_SIZE : end-start;

		vertices[0].u = start; vertices[0].v = sy;
		vertices[0].color = 0;
		vertices[0].x = dx; vertices[0].y = dy; vertices[0].z = 0;

		vertices[1].u = start + width; vertices[1].v = sy + sh;
		vertices[1].color = 0;
		vertices[1].x = dx + width; vertices[1].y = dy + sh; vertices[1].z = 0;

		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_5650|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
	}
	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuSwapBuffers();
	//sceGuSwapBuffers();
}
Пример #11
0
int main(void)
{
	int i;

	pspDebugScreenInit();
	SetupCallbacks();

	/* Clear the existing profile regs */
	pspDebugProfilerClear();
	/* Enable profiling */
	pspDebugProfilerEnable();

	for(i = 0; i < 600; i++)
	{
		pspDebugScreenSetXY(0, 0);
		/* Print profile information to the screen */
		pspDebugProfilerPrint();
		sceDisplayWaitVblankStart();
	}

	/* Let's bug out */
	sceKernelExitDeleteThread(0);

	return 0;
}
Пример #12
0
void _gInit()
{
  // Init & setup GU
  sceGuInit();
  sceGuStart(GU_DIRECT,list);

  sceGuDrawBuffer(GU_PSM_8888,(void*)FRAMEBUFFER_SIZE,PSP_LINE_SIZE);
  sceGuDispBuffer(G_SCR_W,G_SCR_H,(void*)0,PSP_LINE_SIZE);
  sceGuDepthBuffer((void*)(FRAMEBUFFER_SIZE*2),PSP_LINE_SIZE);
  sceGuOffset(2048-(G_SCR_W/2),2048-(G_SCR_H/2));
  sceGuViewport(2048,2048,G_SCR_W,G_SCR_H);

  gResetScissor();
  sceGuDepthRange(65535,0);
  sceGuClearDepth(65535);
  sceGuAlphaFunc(GU_GREATER,0,0xff);
  sceGuDepthFunc(GU_LEQUAL);
  sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
  sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA);
  sceGuTexFilter(GU_LINEAR,GU_LINEAR);
  sceGuShadeModel(GU_FLAT);

  sceGuDisable(GU_CULL_FACE);
  sceGuDisable(GU_CLIP_PLANES);
  sceGuDisable(GU_DITHER);
  sceGuEnable(GU_ALPHA_TEST);
  sceGuEnable(GU_SCISSOR_TEST);

  sceGuFinish();
  sceGuSync(0,0);
  sceDisplayWaitVblankStart();
  sceGuDisplay(GU_TRUE);

  init = G_TRUE;
}
Пример #13
0
static int pmp_show_thread(SceSize input_length, void *input)
	{
	volatile struct pmp_play_struct *p = *((void **) input);


	unsigned int current_buffer_number = 0;


	while (p->return_request == 0)
		{
		if (pmp_wait(p, p->semaphore_can_show, "pmp_show_thread: sceKernelWaitSema failed on semaphore_can_show") == 0)
			{
			break;
			}


		sceDisplayWaitVblankStart();
		sceDisplaySetFrameBuf(p->decoder.output_frame_buffers[current_buffer_number].video_frame, p->decoder.output_texture_width, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_IMMEDIATE);


		if (sceKernelSignalSema(p->semaphore_show_done, 1) < 0)
			{
			p->return_result  = "pmp_show_thread: sceKernelSignalSema failed on semaphore_show_done";
			p->return_request = 1;
			break;
			}


		current_buffer_number = (current_buffer_number + 1) % p->decoder.number_of_frame_buffers;
		}


	return(0);
	}
Пример #14
0
void MasterGuRenderer::guInit() {
	DEBUG_ENTER_FUNC();

	sceGuInit();
	sceGuStart(0, _displayList);

	guProgramDisplayBufferSizes();

	sceGuOffset(2048 - (PSP_SCREEN_WIDTH / 2), 2048 - (PSP_SCREEN_HEIGHT / 2));
	sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
	sceGuDepthRange(0xC350, 0x2710);
	sceGuDisable(GU_DEPTH_TEST);	// We'll use depth buffer area
	sceGuDepthMask(GU_TRUE);		// Prevent writes to depth buffer
	sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);

	sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(1);
}
Пример #15
0
static void testStateScenarios() {
	sceDisplayWaitVblankStart();
	testIsState("  After start");

	sceKernelDelayThread(1000);
	testIsState("  After vblank end");

	// Poll for sync after vblank start.
	sceDisplayWaitVblankStart();
	s64 start = sceKernelGetSystemTimeWide();
	s64 end = start + 1000;
	bool sawVsync = false;
	bool vblankTimingGood = true;
	while (sceKernelGetSystemTimeWide() < end) {
		int vsyncResult = sceDisplayIsVsync();
		if (vsyncResult) {
			testIsState("  During vsync");
			sawVsync = true;

			int untilVsync = (int)(sceKernelGetSystemTimeWide() - start);
			int untilVblankEnd = 0;
			while (sceKernelGetSystemTimeWide() < end) {
				if (!sceDisplayIsVblank()) {
					untilVblankEnd = (int)(sceKernelGetSystemTimeWide() - start);
					break;
				}
			}

			if (untilVsync < 500 || untilVsync > 700) {
				checkpoint("  Vsync did not occur when expected (should be around 631.5us from vblank start)");
				vblankTimingGood = false;
			}
			if (untilVblankEnd < 600 || untilVblankEnd > 800) {
				checkpoint("  Vblank did not take as long as expected (should be around 731.5us from vblank start)");
				vblankTimingGood = false;
			}

			break;
		}
	}

	if (!sawVsync) {
		checkpoint("  Never received vsync");
	} else if (vblankTimingGood) {
		checkpoint("  Vblank timing checked out");
	}
}
Пример #16
0
void GraphicsWaitVSync()
{
#if defined(_WIN32)
	Sleep(15);
#elif defined(PLATFORM_PSP2)
	sceDisplayWaitVblankStart();
#endif
}
Пример #17
0
void resume_vsh_thread(void)
{
	resume_thread("music_player");
	resume_thread("audio_buffer");
	resume_thread("movie_player");
	sceDisplayWaitVblankStart();
	resume_thread("SCE_VSH_GRAPHICS");
}
Пример #18
0
void suspend_vsh_thread(void)
{
	sceDisplayWaitVblankStart();
	suspend_thread("SCE_VSH_GRAPHICS");
	suspend_thread("movie_player");
	suspend_thread("audio_buffer");
	suspend_thread("music_player");
}
Пример #19
0
void psp_video_flip(int wait_vsync)
{
	if (wait_vsync) sceDisplayWaitVblankStart();
	sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565,
		wait_vsync ? PSP_DISPLAY_SETBUF_IMMEDIATE : PSP_DISPLAY_SETBUF_NEXTFRAME);
	current_screen ^= 1;
	psp_screen = current_screen ? VRAM_FB0 : VRAM_FB1;
}
Пример #20
0
void App_Render(void)
{
	DrawScene();
	DebugScreen();
			
	sceDisplayWaitVblankStart();	
	fbp0 = sceGuSwapBuffers();
}
Пример #21
0
int netDialog()
{
	int done = 0;

   	pspUtilityNetconfData data;

	memset(&data, 0, sizeof(data));
	data.base.size = sizeof(data);
	data.base.language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
	data.base.buttonSwap = PSP_UTILITY_ACCEPT_CROSS;
	data.base.graphicsThread = 17;
	data.base.accessThread = 19;
	data.base.fontThread = 18;
	data.base.soundThread = 16;
	data.action = PSP_NETCONF_ACTION_CONNECTAP;
	
	struct pspUtilityNetconfAdhoc adhocparam;
	memset(&adhocparam, 0, sizeof(adhocparam));
	data.adhocparam = &adhocparam;

	sceUtilityNetconfInitStart(&data);
	
	while(running)
	{
		guStart();
		clearScreen(0xff554433);
		guEnd();

		switch(sceUtilityNetconfGetStatus())
		{
			case PSP_UTILITY_DIALOG_NONE:
				break;

			case PSP_UTILITY_DIALOG_VISIBLE:
				sceUtilityNetconfUpdate(1);
				break;

			case PSP_UTILITY_DIALOG_QUIT:
				sceUtilityNetconfShutdownStart();
				break;
				
			case PSP_UTILITY_DIALOG_FINISHED:
				done = 1;
				break;

			default:
				break;
		}

		sceDisplayWaitVblankStart();
		flipScreen();

		if(done)
			break;
	}
	
	return 1;
}
Пример #22
0
void Red3dFlipGuBuffer()
{
	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	framebuffer = sceGuSwapBuffers();
	dispBufferNumber ^= 1;
	Red3dSetupScreen();
}
Пример #23
0
static int messagebubble(int buttonif, const char *message)
{
    sceDisplayWaitVblankStart();
    sceKernelDelayThread(100 * 1000);
    ShowMessageDialog(message, buttonif);
    sceKernelDelayThread(300 * 1000);
    sceUtilityMsgDialogShutdownStart();
    return 1;
}
Пример #24
0
void MFRenderer_EndFramePlatformSpecific()
{
	MFCALLSTACK;

	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuSwapBuffers();
}
Пример #25
0
void gFlip(bool use_vsync)
{
  if (scissor) gResetScissor();

  sceGuFinish();
  sceGuSync(0,0);
  if (use_vsync) sceDisplayWaitVblankStart();
  sceGuSwapBuffers();

  start = G_FALSE;
}
Пример #26
0
void debugIssueMessage(char* msg, int frames) {
	int i = 0;

	pspDebugScreenInit();
	while (i < frames) {
		sceDisplayWaitVblankStart();
		pspDebugScreenSetXY(0, 0);
		printf("%s", msg);
		i++;
	}
}
Пример #27
0
void do_menu(void)
{
	SceCtrlData pad;
	int selected = 0;
	unsigned int lastbut = TRIGGER;
	unsigned int curr = 0;

	redraw_menu(selected);
	while(1)
	{
		sceCtrlPeekBufferPositive(&pad, 1);

		curr = pad.Buttons & ~lastbut;
		
		if(curr & PSP_CTRL_UP)
		{
			if(selected > 0)
			{
				selected--;
			}
			else if(selected == 0)
			{
				selected = opt_count-1;
			}
			redraw_menu(selected);
		}
		if(curr & PSP_CTRL_DOWN)
		{
			if(selected < (opt_count-1))
			{
				selected++;
			}
			else if(selected == (opt_count-1))
			{
				selected = 0;
			}
			redraw_menu(selected);
		}
		if(curr & PSP_CTRL_CIRCLE)
		{
			options[selected].do_option();
		}
		else if(curr & PSP_CTRL_CROSS)
		{
			return;
		}
		lastbut = pad.Buttons;
		if(sceDisplayWaitVblankStart() < 0)
		{
			sceKernelExitDeleteThread(0);
		}
	}
}
Пример #28
0
void *psp_showPage(image *framebuffer, int tyres) {

	//perhaps:
	//sync at the top, instead of the bottom,
	//so that the framerendering can go on while the engine
	//proceeds instead of having to wait in showpage

	//sceGuSync(0,0);

	//swap the R and B bitfields, goddammit
	/*int w = framebuffer->width;
	int p = framebuffer->pitch;
	int h = framebuffer->height;
	unsigned short *buf = (unsigned short *)framebuffer->data;
	for(int y=0;y<h;y++) {
		for(int x=0;x<w;x++)
			buf[x] = (buf[x]<<11)|(buf[x]>>11)|(buf[x]&0x07E0);
		buf += p;
	}*/

	//make sure the software buffer is flushed
	sceKernelDcacheWritebackAll();

	//sceGuStart(GU_DIRECT,list);

	//// clear screen
	////sceGuClearColor(0xff000000);
	////sceGuClear(GU_COLOR_BUFFER_BIT);

	//sceGuTexMode(GU_PSM_5650,0,0,0);
	//sceGuTexImage(0,framebuffer->pitch,tyres,framebuffer->pitch,framebuffer->data);
	//sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);
	//sceGuTexFilter(GU_NEAREST,GU_NEAREST);
	//sceGuTexScale(1.0f/(float)framebuffer->pitch,1.0f/(float)tyres);
	//sceGuTexOffset(0.0f,0.0f);

	//psp_renderSprite(0,
	//	(480-framebuffer->width)/2,
	//	(272-framebuffer->height)/2,
	//	framebuffer->width,framebuffer->height);

	//sceGuFinish();
	//sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	void *backBuffer = sceGuSwapBuffers();
	//sceGuSync(0,0);
	return backBuffer;

	//sceDisplayWaitVblankStart();

}
Пример #29
0
void vidgu_render(int sx, int sy, int sw,int sh,int dx, int dy, int dw,int dh)
{
	unsigned int j,cx,cy;
	struct Vertex* vertices;

	cx=(480-dw)/2;
	cy=(272-dh)/2;

	sceGuStart(GU_DIRECT,list);
	sceGuTexMode(GU_PSM_5650,0,0,0); // 16-bit RGBA
	sceGuTexImage(0,512,512,512,g_pBlitBuff); // setup texture as a 256x256 texture
	//sceKernelDcacheWritebackAll();
	sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA); // don't get influenced by any vertex colors
	sceGuTexFilter(GU_LINEAR,GU_LINEAR); // point-filtered sampling

	int		start, end;
	float	ustart = (float)sx;
	float	ustep = (float)sw / (float)(dw / SLICE_SIZE);

	// blit maximizing the use of the texture-cache

	for (start = sx, end = sx+dw; start < end; start += SLICE_SIZE, dx += SLICE_SIZE)
	{
		struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
		int width = (start + SLICE_SIZE) < end ? SLICE_SIZE : end-start;

		vertices[0].u = ustart; 
		vertices[0].v = (float)sy;
		vertices[0].color = 0;
		vertices[0].x = dx; 
		vertices[0].y = dy; 
		vertices[0].z = 0;

		vertices[1].u = ustart + ustep; 
		vertices[1].v = (float)(sy + sh);
		vertices[1].color = 0;
		vertices[1].x = dx + width; 
		vertices[1].y = dy + dh; 
		vertices[1].z = 0;

		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_5650|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);

		ustart += ustep;
	}


	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuSwapBuffers(); 
}
Пример #30
0
void S9xSceGUPutImage (int snes_width, int snes_height)
{
#ifndef SCEGU_DOUBLE_BUFFERED
  if (PSP_Settings.bVSync)
    sceDisplayWaitVblankStart ();
#endif

  const int tex_res = (PSP_Settings.bSupportHiRes ? 512 : 256);

  switch (PSP_Settings.iScreenSize)
  {
    case SCR_SIZE_FIT:
    {
      // Most games run at 224 lines, but some have 239
      const int y_res   = IPPU.RenderedScreenHeight;
      // 60 pixels on either side (4:3)...
      const int x_scale = (PSP_Settings.bSupportHiRes ? 720 : 360);
      const int y_scale = (PSP_Settings.bSupportHiRes ? (y_res == 239 ? 584 : 624) :
                                                        (y_res == 239 ? 292 : 312));
      S9xSceGURenderTex ((char *)GFX.Screen, tex_res, tex_res,
                                                  60, 0,
                                             x_scale, y_scale,
                                                 360, 272);
    } break;
    case SCR_SIZE_FULL:
    case SCR_SIZE_FULLFIT:
    {
      // Most games run at 224 lines, but some have 239
      const int y_res   = IPPU.RenderedScreenHeight;
      const int x_scale = (PSP_Settings.bSupportHiRes ? 960 : 480);
      const int y_scale = (PSP_Settings.bSupportHiRes ? (y_res == 239 ? 584 : 624) :
                                                        (y_res == 239 ? 292 : 312));
      S9xSceGURenderTex ((char *)GFX.Screen, tex_res, tex_res,
                                             0,       0,
                                             x_scale, y_scale,
                                             480,     272);
    } break;
    case SCR_SIZE_X1:
    default:
    {
      const int y_res    = IPPU.RenderedScreenHeight;
      const int x_res    = IPPU.RenderedScreenWidth;
      const int xy_scale = (PSP_Settings.bSupportHiRes ? 512 : 256);
      S9xSceGURenderTex ((char *)GFX.Screen, tex_res, tex_res,
                                             (480 / 2) - (  256 / 2),
                                             (272 / 2) - (y_res / 2),
                                      xy_scale, xy_scale,
                                         x_res, y_res);
    } break;
  }
}