Exemplo n.º 1
0
void OSPC_show_bg(u16 *menu_bg){
	u16 *src,*dst;
	int i;
	static int cpt_lowbat=0;
	
	if (!((cpt_lowbat++)&63)) {
		int oldvalue=os9x_lowbat;
		os9x_lowbat=scePowerIsLowBattery();
		if (oldvalue!=os9x_lowbat) {
			u16 *src,*dst;
			int i;
			dst=menu_bg;
			show_background(bg_img_mul,(os9x_lowbat?0x600000:0));	
			for (i=0;i<272;i++) {
				src = (u16*)pgGetVramAddr(0,i);						
				memcpy(dst,src,480*2);
				dst+=480;
			}
		}
	}
		
	src=menu_bg;
	for (i=0;i<272;i++) {
		dst = (u16*)pgGetVramAddr(0,i);						
		memcpy(dst,src,480*2);
		src+=480;
	}
		
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
static int lua_powerIsLowBattery(lua_State *L)
{
    if (lua_gettop(L) != 0) return luaL_error(L, "System.powerIsLowBattery() takes no arguments");
    lua_pushboolean(L, scePowerIsLowBattery());
    return 1;
}