Exemple #1
0
void Red3dPrintFPS(float font_size, int x, int y, u32 fg_color, u32 bg_color)
{
	
	if(FPS_Setup == 0)
	{
		sceRtcGetCurrentTick(&last_tick);
		tick_res = sceRtcGetTickResolution();
		FPS_Setup = 1;
	}
	
	frame_count++;
	
	u64 curr_tick;
	sceRtcGetCurrentTick(&curr_tick);
	
	if((curr_tick-last_tick) >= tick_res)
	{
		curr_fps = 1.0f / curr_ms;
		sprintf(fps_buf, "Framerate: %d.%03d",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f)); // debug
		Red3dPrintf(fps_buf, font_size, x, y, fg_color, bg_color);
		curr_ms = (((curr_tick-last_tick)) / (float)tick_res) / frame_count;
		frame_count = 0;
		sceRtcGetCurrentTick(&last_tick);
	}
	else
	{
		sprintf(fps_buf, "Framerate: %d.%03d",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f)); // debug
		Red3dPrintf(fps_buf, font_size, x, y, fg_color, bg_color);
	}
	
}
Exemple #2
0
void pspCtrlSetPollingMode(int mode)
{
  /* If autorepeat is being shut off, wait until it's "safe" */
  if (PollingMode == PSP_CTRL_AUTOREPEAT)
  {
    int i;
    SceCtrlData p;
    u64 tick;
    int wait;

    do
    {
      wait = 0;

      if (!sceCtrlPeekBufferPositive(&p, 1))
        break;

      /* Get current tick count */
      sceRtcGetCurrentTick(&tick);

      /* If at least one button is being held, wait until */
      /* next autorepeat interval, or until it's released */
      for (i = 0; i < PSP_CTRL_BUTTONS; i++)
        if (tick < PushTime[i] && (p.Buttons & ButtonMap[i]))
          { wait = 1; break; }
    }
    while (wait);
  }

  PollingMode = mode;

  /* If autorepeat is being turned on, initialize autorepeat data */
  if (mode == PSP_CTRL_AUTOREPEAT)
  {
    SceCtrlData p;
    int i;
    u64 tick;
    u32 tick_res;

    /* Poll the controls */
    if (sceCtrlPeekBufferPositive(&p, 1))
    {
      /* Get current tick count */
      sceRtcGetCurrentTick(&tick);
      tick_res = sceRtcGetTickResolution();

      /* Check each button */
      for (i = 0; i < PSP_CTRL_BUTTONS; i++)
        PushTime[i] = (p.Buttons & ButtonMap[i]) ? tick + PSP_CTRL_DELAY * (tick_res / 1000) : 0;
    }
  }
}
Exemple #3
0
/**
* Check that getCurrentTick works fine.
*
* @TODO: Currently sceKernelDelayThread only work with ms.
*        It should check that work with microseconds precission.
*/
void checkGetCurrentTick() {
	u64 tick0, tick1;
	int microseconds = 2 * 1000; // 2ms

	printf("Checking sceRtcGetCurrentTick\n");

	sceRtcGetCurrentTick(&tick0);
	{
		sceKernelDelayThread(microseconds);
	}
	sceRtcGetCurrentTick(&tick1);

	printf("%d\n", (tick1 - tick0) >= microseconds);
}
Exemple #4
0
void timer_update() {
	u64 tcurr;
	sceRtcGetCurrentTick(&tcurr);
	int curr = (int)((tcurr-timer_t0)/10000);
	while(timer_curr<curr)
		timer_tick();
}
Exemple #5
0
void updateDrawFPS()
{
    u64 fpsTickNow;
    u64 TickDelta;

    frames++;
    totalfps++;

    sceRtcGetCurrentTick( &fpsTickNow );

    TickDelta = fpsTickNow - fpsTickLast;
    if (TickDelta >= tickResolution)
    {
        fpsTickLast = fpsTickNow;
        totalseconds++;

        // fps from last "second"
        lastfps = frames;

        // average for entire program running time
        averagefps = totalfps / totalseconds;

        // fps from last second, or from last call to this function, which ever gives the lower fps
        lastfpskip = (u64)(frames * tickResolution) / TickDelta;

        pspDebugScreenSetOffset( (int)fbp0 );
        pspDebugScreenSetXY( 0, 32 );
        printf("FPS last:%05d/%05d ave:%05d \n", lastfps, lastfpskip, averagefps);
        printf("delta ticks: %lld", TickDelta);

        frames = 0;
    }
}
Exemple #6
0
double CTimer::GetDeltaTime( void )
{
	sceRtcGetCurrentTick( &timeNow );
	double dt = ( timeNow - timeLastAsk ) / ((float) tickResolution );
	timeLastAsk = timeNow;
 
	return dt;
}
Exemple #7
0
uint32 PspRtc::getMicros() {
	uint32 ticks[2];

	sceRtcGetCurrentTick((u64 *)ticks);
	ticks[0] -= _startMicros;

	return ticks[0];
}
Exemple #8
0
// returns number of milliseconds since game started
int JGE::GetTime(void)
{

	u64 curr;
	sceRtcGetCurrentTick(&curr);
 
	return (int)(curr / mTickFrequency);
}
Exemple #9
0
void PspRtc::init() {						// init our starting ticks
	uint32 ticks[2];
	sceRtcGetCurrentTick((u64 *)ticks);

	_startMillis = ticks[0]/1000;
	_startMicros = ticks[0];
	//_lastMillis = ticks[0]/1000;	//debug - only when we don't subtract startMillis
}
//#Gets the time since the last call measured in seconds
float getDeltaTime()
{
    sceRtcGetCurrentTick( &timeNow );
    float dt = ( timeNow - timeLastAsk ) / ((float) tickResolution );
    timeLastAsk = timeNow;

    return dt;
}
Exemple #11
0
int		Sys_Milliseconds (void)
{
	u64 ticks = 0;
	u64 ms;

	sceRtcGetCurrentTick(&ticks);

	ms = (ticks - first_ticks) / ticks_per_ms;

	return ms;
}
UInt64 SystemInfo::GetCpuCycles()
{
    UInt64 ticks;
    int res = sceRtcGetCurrentTick(&ticks);
    GD_ASSERT(res == 0);

    res = sceRtcTickAddYears (&ticks,&ticks,-2000);
    GD_ASSERT(res == 0);

    return ticks;
}
Exemple #13
0
void testControllerTimmings() {
	u64 tick0, tick1;
	int n;
	SceCtrlData pad_data;
	SceCtrlLatch latch;
	
	// Test sceCtrlReadBufferPositive
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlReadBufferPositive(&pad_data, 1);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 > 5000));

	// Test sceCtrlReadLatch
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlReadLatch(&latch);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 > 5000));

	// Test sceCtrlPeekBufferPositive
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlPeekBufferPositive(&pad_data, 1);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 < 5000));

	// Test sceCtrlPeekLatch
	/*
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlPeekLatch(&pad_data, 1);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 < 5000));
	*/
}
Exemple #14
0
/* psp_timer_thread:
 *  This PSP thread measures the elapsed time.
 */
static int psp_timer_thread()
{
   uint64_t old_tick, new_tick;
   int interval;
   long delay;

   sceRtcGetCurrentTick(&old_tick);

   while (psp_timer_on) {
      /* Calculate actual time elapsed. */
      sceRtcGetCurrentTick(&new_tick);
      interval = PSPTIMER_TO_TIMER(new_tick - old_tick);
      old_tick = new_tick;

      /* Handle a tick and rest. */
      delay = _handle_timer_tick(interval);
      sceKernelDelayThreadCB(TIMER_TO_USEC(delay));
   }
   
   sceKernelExitThread(0);

   return 0;
}
Exemple #15
0
void PspSpeedTests::tickSpeed() {
	uint32 ticksPerSecond = sceRtcGetTickResolution();
	PSP_INFO_PRINT("ticksPerSecond[%d]\n", ticksPerSecond);

	uint32 currentTicks1[2];
	uint32 currentTicks2[2];

	sceRtcGetCurrentTick((u64 *)currentTicks1);
	sceRtcGetCurrentTick((u64 *)currentTicks2);
	PSP_INFO_PRINT("current tick[%x %x][%u %u]\n", currentTicks1[0], currentTicks1[1], currentTicks1[0], currentTicks1[1]);
	PSP_INFO_PRINT("current tick[%x %x][%u %u]\n", currentTicks2[0], currentTicks2[1], currentTicks2[0], currentTicks2[1]);

	pspTime time;
	sceRtcSetTick(&time, (u64 *)currentTicks2);
	PSP_INFO_PRINT("current tick in time, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time.year, time.month, time.day, time.hour, time.minutes, time.seconds, time.microseconds);

	pspTime time1;
	pspTime time2;
	sceRtcGetCurrentClockLocalTime(&time1);
	sceRtcGetCurrentClockLocalTime(&time2);
	PSP_INFO_PRINT("time1, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time1.year, time1.month, time1.day, time1.hour, time1.minutes, time1.seconds, time1.microseconds);
	PSP_INFO_PRINT("time2, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time2.year, time2.month, time2.day, time2.hour, time2.minutes, time2.seconds, time2.microseconds);
}
Exemple #16
0
void FPS( void )
{
	fps++;
	sceRtcGetCurrentTick( &fpsTickNow );
	
	if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f )
	{
		fpsTickLast = fpsTickNow;
		sprintf( fpsDisplay, "FPS: %i", fps );
		fps = 0;
	}
	pspDebugScreenSetOffset( (int)fbp0 );
	pspDebugScreenSetXY( 0, 0 );
	pspDebugScreenPrintf( fpsDisplay );
}
Exemple #17
0
void pspVideoInit()
{

  vita2d_init_advanced(10*1024*1024);
  vita2d_set_vblank_wait(0);
  /* Compute VBlank frequency */
  uint64_t t[2];
  int i;
  for (i = 0; i < 2; i++)
  {
    sceDisplayWaitVblankStart();
    sceRtcGetCurrentTick(&t[i]);
  }
  VBlankFreq = round(1.00 / ((double)(t[1] - t[0])
    * (1.00 / (double)sceRtcGetTickResolution())));

}
static int lua_showFPS(lua_State *L)
{
    int argc = lua_gettop(L);
    if (argc > 0)
    {
        return luaL_error(L, "System.getFPS() takes no arguments");
    }
    fps +=1;
    sceRtcGetCurrentTick( &timeNowFPS );

    if( ((timeNowFPS - timeLastFPS)/((float)tickResolution)) >= 1.0f )
    {
        timeLastFPS = timeNowFPS;
    }
    lua_pushnumber(L,fps);
    fps = 0;
    return 0;
}
Exemple #19
0
void JGE::Init()
{

#ifdef DEBUG_PRINT	
	mDebug = true;
#else
	mDebug = false;
#endif

	if (mDebug)
		pspDebugScreenInit();	// do this so that we can use pspDebugScreenPrintf
	
	strcpy(mDebuggingMsg, "");

	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
	
	JRenderer::GetInstance();
	JFileSystem::GetInstance();
	JSoundSystem::GetInstance();

	mDone = false;
	mPaused = false;
	mCriticalAssert = false;
	mClicked = false;

	//InitSfx();

	//Create();
	
//	mCurrMS = 1.0f;
//	mFPSSlice = 0;

	//struct timeval tp;
	//gettimeofday(&tp, NULL);
	//mTimeBase = tp.tv_sec;

	//mLastTime = GetTime();

	
	mTickFrequency = sceRtcGetTickResolution();
	sceRtcGetCurrentTick(&mLastTime); 
}
Exemple #20
0
void JGE::Run()
{

	u64 curr;

	while (!mDone)
	{
		if (!mPaused)
		{
			sceRtcGetCurrentTick(&curr);
			
			
			mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f; 
			mLastTime = curr;
			
			sceCtrlPeekBufferPositive(&mCtrlPad, 1);	// using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive
														// because sceCtrlReadBufferPositive waits for vsync internally
		
			Update();

			mClicked = false;

			Render();

			if (mDebug)
			{
				if (strlen(mDebuggingMsg)>0)
				{
					pspDebugScreenSetXY(0, 0);
					pspDebugScreenPrintf(mDebuggingMsg);
				}
			}

			mOldButtons = mCtrlPad.Buttons;
		


		}

	}
	
}
Exemple #21
0
void DebugScreen( void )
{
	fps++;
	sceRtcGetCurrentTick( &fpsTickNow );
	
	if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f )
	{
		fpsTickLast = fpsTickNow;
		sprintf( fpsDisplay, "FPS: %i", fps );
		fps = 0;
	}
	pspDebugScreenSetOffset( (int)fbp0 );
	pspDebugScreenSetXY( 0, 0 );
	pspDebugScreenPrintf( fpsDisplay );
	
	
	pspDebugScreenSetXY( 0, 1 );
	pspDebugScreenPrintf( "%f", timerTest.getSeconds() );
	
	pspDebugScreenSetXY( 0, 2 );
	pspDebugScreenPrintf( "%f %f %f %d", myScene.cam->position.x, myScene.cam->position.y, myScene.cam->position.z, myScene.cam->type);
}
Exemple #22
0
// Note that after we fill up 32 bits ie 50 days we'll loop back to 0, which may cause
// unpredictable results
uint32 PspRtc::getMillis(bool skipRecord) {
	uint32 ticks[2];

	sceRtcGetCurrentTick((u64 *)ticks);		// can introduce weird thread delays

	uint32 millis = ticks[0]/1000;
	millis -= _startMillis;					// get ms since start of program

	if ((int)_lastMillis - (int)millis > MS_LOOP_CHECK) {		// we must have looped around
		if (_looped == false) {					// check to make sure threads do this once
			_looped = true;
			_milliOffset += MS_LOOP_AROUND;		// add the needed offset
			PSP_DEBUG_PRINT("looping around. last ms[%d], curr ms[%d]\n", _lastMillis, millis);
		}
	} else {
		_looped = false;
	}

	_lastMillis = millis;

	return millis + _milliOffset;
}
Exemple #23
0
static void filter_repeats(SceCtrlData *pad)
{
  SceCtrlData p = *pad;
  int i;
  uint64_t tick;
  uint32_t tick_res;

  /* Get current tick count */
  sceRtcGetCurrentTick(&tick);
  tick_res = sceRtcGetTickResolution();

  /* Check each button */
  for (i = 0; i < _button_map[i]; i++)
  {
    if (p.buttons & _button_map[i])
    {
      if (!_push_time[i] || tick >= _push_time[i])
      {
        /* Button was pushed for the first time, or time to repeat */
        pad->buttons |= _button_map[i];
        /* Compute next press time */
        _push_time[i] = tick + ((_push_time[i]) ? PL_VK_THRESHOLD : PL_VK_DELAY)
          * (tick_res / 1000);
      }
      else
      {
        /* No need to repeat yet */
        pad->buttons &= ~_button_map[i];
      }
    }
    else
    {
      /* Button was released */
      pad->buttons &= ~_button_map[i];
      _push_time[i] = 0;
    }
  }
}
Exemple #24
0
void DisplayFPS()
{
    uint64_t currentTick = 0;

    int result = sceRtcGetCurrentTick(&currentTick);
    if (result != 0)
    {
        printf("sceRtcGetCurrentTick : 0x%x\n", currentTick);
    }

    uint64_t difference = currentTick - lastTick;
    lastTick = currentTick;

    int fps = sceRtcGetTickResolution() / (int) difference;
    fpsTimes[fpsIndex] = fps;

    if (++fpsIndex == FPS_TIMES_COUNT)
    {
        fpsIndex = 0;
    }

    fps = 0;

    int i;
    for (i = 0; i < FPS_TIMES_COUNT; ++i)
    {
        fps += fpsTimes[i];
    }

    fps /= FPS_TIMES_COUNT;

    PSP2_Video_FillScreen(SCREEN_W * 200);

    sprintf(fpstext, "FPS: %d", fps);
    mh_print(5, 5, fpstext, RGBA8(0, 255, 0, 255), 0, 0);

}
Exemple #25
0
static bool psp_frame(void *data, const void *frame,
      unsigned width, unsigned height, unsigned pitch, const char *msg)
{
   static char fps_txt[128], fps_text_buf[128];
   psp1_video_t *psp = (psp1_video_t*)data;

#ifdef DISPLAY_FPS
   static uint64_t currentTick,lastTick;
   static float fps=0.0;
   static int frames;
#endif

   if (!width || !height)
      return false;

   if (((uint32_t)frame&0x04000000) || (frame == RETRO_HW_FRAME_BUFFER_VALID))
      psp->hw_render = true;
   else if (frame)
      psp->hw_render = false;

   if (!psp->hw_render)
      sceGuSync(0, 0); /* let the core decide when to sync when HW_RENDER */

   pspDebugScreenSetBase(psp->draw_buffer);

   pspDebugScreenSetXY(0,0);

   video_monitor_get_fps(fps_txt, sizeof(fps_txt),
         g_settings.fps_show ? fps_text_buf : NULL,
         g_settings.fps_show ? sizeof(fps_text_buf) : 0);

   if(g_settings.fps_show)
   {
      pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
      pspDebugScreenPuts(fps_text_buf);
      pspDebugScreenSetXY(0,1);
   }

   if (msg)
      pspDebugScreenPuts(msg);

   if ((psp->vsync)&&(psp->vblank_not_reached))
      sceDisplayWaitVblankStart();

   psp->vblank_not_reached = true;

#ifdef DISPLAY_FPS
   frames++;
   sceRtcGetCurrentTick(&currentTick);
   uint32_t diff = currentTick - lastTick;
   if(diff > 1000000)
   {
      fps = (float)frames * 1000000.0 / diff;
      lastTick = currentTick;
      frames = 0;
   }

   pspDebugScreenSetXY(0,0);
   pspDebugScreenPrintf("%f", fps);
#endif

   psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
   g_extern.frame_count++;


   RARCH_PERFORMANCE_INIT(psp_frame_run);
   RARCH_PERFORMANCE_START(psp_frame_run);

   if (psp->should_resize)
      psp_update_viewport(psp);

   psp_set_tex_coords(psp->frame_coords, width, height);

   sceGuStart(GU_DIRECT, psp->main_dList);

   sceGuTexFilter(psp->tex_filter, psp->tex_filter);
   sceGuClear(GU_COLOR_BUFFER_BIT);

   /* frame in VRAM ? texture/palette was 
    * set in core so draw directly */
   if (psp->hw_render) 
      sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
            GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
            (void*)(psp->frame_coords));
   else
   {
      if (frame)
      {
         sceKernelDcacheWritebackRange(frame,pitch * height);
         sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2,
               0, width, height, pitch >> psp->bpp_log2,
               (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture);
      }
      sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture);
      sceGuCallList(psp->frame_dList);
   }

   sceGuFinish();

   RARCH_PERFORMANCE_STOP(psp_frame_run);

   if(psp->menu.active)
   {
      sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage));
      sceGuSync(0, 0);
   }

   return true;
}
Exemple #26
0
// Main function
int main(int argc, char **argv)
{
	int battimeout = 0;
	char fpstxt[16];

	// Open debug files
	PokeDebugFOut = fopen("dbg_stdout.txt", "w");
	PokeDebugFErr = fopen("dbg_stderr.txt", "w");

	// Init video
	PokeDPrint(POKEMSG_OUT, "%s\n\n", AppName);
	PokeMini_InitDirs(argv[0], NULL);
	CommandLineInit();
	CommandLine.low_battery = 2;	// PSP can report battery status
	CommandLineConfFile("pokemini.cfg", "pokemini_psp.cfg", CustomConf);
	JoystickSetup("PSP", 0, 30000, PSP_KeysNames, 16, PSP_KeysMapping);

	// PSP Init and set screen
	PSP_Init();
	setup_screen();

	// Create emulator and load test roms
	PokeDPrint(POKEMSG_OUT, "Starting emulator...\n");
	PokeMini_Create(POKEMINI_GENSOUND | POKEMINI_AUTOBATT, 0);

	// Setup palette and LCD mode
	PokeMini_VideoPalette_Init(PokeMini_RGB16, 1);
	PokeMini_VideoPalette_Index(CommandLine.palette, CommandLine.custompal, CommandLine.lcdcontrast, CommandLine.lcdbright);
	PokeMini_ApplyChanges();

	// Load stuff
	PokeMini_UseDefaultCallbacks();
	if (!PokeMini_LoadFromCommandLines("Using FreeBIOS", "EEPROM data will be discarded!")) {
		UI_Status = UI_STATUS_MENU;
	}

	// Enable sound & init UI
	PokeDPrint(POKEMSG_OUT, "Running emulator...\n");
	UIMenu_Init();
	enablesound(CommandLine.sound);
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

	// Emulator's loop
	u64 tickcurr;
	u64 fpsticknext,fpstickres = (u64)sceRtcGetTickResolution();
	u64 frmticknext, frmtickres = (u64)sceRtcGetTickResolution() / 36;
	sceRtcGetCurrentTick(&tickcurr);
	fpsticknext = tickcurr + fpstickres;
	frmticknext = tickcurr + frmtickres;
	int fps = 72, fpscnt = 0;
	strcpy(fpstxt, "");
	while (emurunning) {
		// Emulate 2 frames
		PokeMini_EmulateFrame();
		PokeMini_EmulateFrame();
		if (RequireSoundSync) {
			while (MinxAudio_SyncWithAudio()) sceKernelDelayThread(1000);
		} else {
			do {
				sceRtcGetCurrentTick(&tickcurr);
				sceKernelDelayThread(1000);
			} while (tickcurr < frmticknext);
			frmticknext = tickcurr + frmtickres;	// Aprox 36 times per sec
		}

		// Screen rendering
		PSP_ClearDraw();
		if (PokeMini_Rumbling) {
			PokeMini_VideoBlit((uint16_t *)PSP_DrawVideo + pm_offset + PokeMini_GenRumbleOffset(512), 512);
		} else {
			PokeMini_VideoBlit((uint16_t *)PSP_DrawVideo + pm_offset, 512);
		}
		LCDDirty = 0;

		// Display FPS counter
		if (clc_displayfps) {
			sceRtcGetCurrentTick(&tickcurr);
			if (tickcurr >= fpsticknext) {
				fpsticknext = tickcurr + fpstickres;
				fps = fpscnt;
				fpscnt = 0;
				sprintf(fpstxt, "%i FPS", fps);
			} else fpscnt++;
			UIDraw_String_16((uint16_t *)PSP_DrawVideo, 512, 4, 4, 10, fpstxt, UI_Font1_Pal16);
		}

		// Handle keys
		HandleKeys();

		// Menu
		if (UI_Status == UI_STATUS_MENU) menuloop();

		// Wait VSync & Render (72 Hz)
		PSP_Flip();

		// Check battery
		if (battimeout <= 0) {
			PokeMini_LowPower(scePowerIsLowBattery());
			battimeout = 600;
		} else battimeout--;
	}

	// Stop sound & free UI
	enablesound(0);
	UIMenu_Destroy();

	// Save Stuff
	PokeMini_SaveFromCommandLines(1);

	// Terminate...
	PokeDPrint(POKEMSG_OUT, "Shutdown emulator...\n");
	PokeMini_VideoPalette_Free();
	PokeMini_Destroy();

	// Close debug files
	fclose(PokeDebugFOut);
	fclose(PokeDebugFErr);

	// PSP Quit
	PSP_Quit();

	return 0;
}
u64 GetNowHiPerformanceCount()
{
	u64 tick;
	if(sceRtcGetCurrentTick(&tick) != 0)return 0;
	return tick;
}
static u64 psp_ticker(void)
{
	u64 current_ticks;
	sceRtcGetCurrentTick(&current_ticks);
	return (current_ticks);
}
Exemple #29
0
int main(int argc, char** argv)
{
	sceRtcGetCurrentTick( &fpsTickLast );
	tickResolution = sceRtcGetTickResolution();
	
	Gamepad gamepad;
	
	App_Initialize();
	
	timerTest.start();
	
	float nextUpdate = 0;
	
	while(1)
	{
		
		timerTest.update();
		(*mySceneMotion).evaluate(timerTest.getSeconds());

		App_Render();

		if(gamepad.Poll())
		{
			if(gamepad.ButtonDown(PSP_CTRL_TRIANGLE))
			{
				timerTest.paused(true);
			}
			
			if(gamepad.ButtonDown(PSP_CTRL_SQUARE))
			{
				timerTest.paused(false);
			}

			if(timerTest.paused())
			{
				if(fabs(gamepad.AnalogX()) > 0.1)
				{
					if(gamepad.ButtonDown(PSP_CTRL_RTRIGGER))
					{
						if(timerTest.getSeconds() - 0.5f > 0 || gamepad.AnalogX() > 0)	timerTest.setSeconds(timerTest.getSeconds() + (gamepad.AnalogX() * 0.5));
					}
					else
					{
						if(timerTest.getSeconds() - 0.1f > 0 || gamepad.AnalogX() > 0)	timerTest.setSeconds(timerTest.getSeconds() + (gamepad.AnalogX() * 0.1));
					}
				}
			}
						
			if(gamepad.ButtonDown(PSP_CTRL_LEFT))
			{
				if(gamepad.ButtonDown(PSP_CTRL_RTRIGGER))
				{
					if(timerTest.getSeconds() - 0.1f > 0)	timerTest.setSeconds(timerTest.getSeconds() - 0.1);
				}
				else
				{
					if(timerTest.getSeconds() - 0.01f > 0)	timerTest.setSeconds(timerTest.getSeconds() - 0.01);
				}
			}
			
			if(gamepad.ButtonDown(PSP_CTRL_RIGHT))
			{
				if(gamepad.ButtonDown(PSP_CTRL_RTRIGGER))
				{
					timerTest.setSeconds(timerTest.getSeconds() + 0.1);
				}
				else
				{
					timerTest.setSeconds(timerTest.getSeconds() + 0.01);
				}
			}
		}		
	}

	App_Shutdown();

	return 0;
}
Exemple #30
0
int main(int argc, char **argv)
{
    SceCtrlData pad;
    int oldButtons = 0;
    int useVblank = 1;

    pspDebugScreenInit();
    if (argc > 0) {
        printf("Bootpath: %s\n", argv[0]);
    }

    printf("Triangle - Exit\n");
    printf("Square - Toggle vblank (60 fps limit)\n");
    printf("\n");

    SetupCallbacks();

    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

    sceRtcGetCurrentTick( &fpsTickLast );
    tickResolution = sceRtcGetTickResolution();

    printGetDayOfWeek();
    printf("\n");

    printGetDaysInMonth();
    printf("\n");

    printSetTick();
    printf("\n");

    printGetTick();
    printf("\n");

    printf("sceRtcGetTickResolution: %d", (int)tickResolution);

    while(!done)
    {
        sceCtrlPeekBufferPositive(&pad, 1);
        int buttonDown = (oldButtons ^ pad.Buttons) & pad.Buttons;

        if (buttonDown & PSP_CTRL_SQUARE)
        {
            useVblank ^= 1;
        }

        if (buttonDown & PSP_CTRL_TRIANGLE)
            done = 1;

        oldButtons = pad.Buttons;

        updateDrawFPS();

        if (useVblank)
            sceDisplayWaitVblankStart();
        fbp0 = sceGuSwapBuffers();
    }

    sceKernelExitGame();    // Quits Application
    return 0;
}