コード例 #1
0
ファイル: SMS.c プロジェクト: wally4000/code
int MenuPlusAction(int action, void* param)			{
	switch (action)			{
		case MA_LOADROM:
			if (systemInit)
			{
				machine_poweroff();
			}

			strcpy(menuConfig.file.filename, (char*)param);

			if(load_rom(menuConfig.file.filename) == 0) 
			{
				return 0;
			}

			if(systemInit)
			{
				if (gblMachineType == EM_SMS)			{
					sms_init();
					render_init();
					system_poweron();
				}
			}

			gblNewGame = 1;
			menuPlusTerminated = 1;
			menuConfig.video.pause = 0;
			break;
	}
	return 1;
}
コード例 #2
0
ファイル: main.c プロジェクト: DavisDev/MasterBoyRebulild
int main(int argc, char *argp[]){
	// Init More Stuff...
	
	// Initialize Osl
	oslInit(3); // Based on Onelua xD
	
	// Init Crls Functions..
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
	
	// Init Configs Stuff.
	InitConfig();
	memcpy(menuConfigDefault, &menuConfig, sizeof(menuConfig)); //Sauvegarde pour plus tard
	
	// Init Stuff GU "Video"
	oslInitGfx(OSL_PF_8888, 1);// OSL_PF_5650 Aqui estaba esto.. Cambiado a 8888	
	oslInitConsole();
	oslStartDrawing();
	VideoGuScreenClear();// Check If really its vital
	/* Añadido
	oslIntraFontInit(INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8);
	OSL_FONT * oneFont = oslLoadFontFile("flash0:/font/jpn0.pgf");
	oslIntraFontSetStyle(oneFont, 0.7, RGB(255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);
	oslSetFont(oneFont);
	*/
	//Main screen: in VRAM for speed
	Screen.scrBuffer = oslGetUncachedPtr(oslVramMgrAllocBlock(SCR_BUFFER_SIZE));
	Screen.pal = oslGetUncachedPtr(oslVramMgrAllocBlock(256*2));
	//Sub screen: in RAM for mem sparing
	ScreenTemp.scrBuffer = oslGetUncachedPtr(malloc(SCR_BUFFER_SIZE));
	ScreenTemp.pal = NULL;
	bitmap.data   = (unsigned char*)Screen.scrBuffer;
	/* Term of stuff gu */
	
	// Init More Vars..
	u32 nFrame, nDrawnFrames, skip=0, framerate;
	int nbRenderedFramesPerSec, nbVirtualFramesPerSec = 0, lastVCount = 0;
	int frameskip = 0;

	memset(&bitmap, 0, sizeof(bitmap_t));
	bitmap.width  = 256;
	bitmap.height = 192;
	bitmap.depth  = menuConfig.video.renderDepth;
	bitmap.pitch  = 256 * menuConfig.video.renderDepth / 8;

	menuConfig.file.filename[0] = '\0';

	sms.save = 1;

	// Display the menu to load up the ROM
	//	displayMenu();
	menuIsInGame = 0;

	//menuPlusShowMenu();
	MenuPlusAction(MA_LOADROM, "ms0:/Poke_Oro.gbc");

	//Bidouille pour détecter les choses qui ont changé
	MenuOptionsConfigure(-1);
	MenuOptionsConfigure(0);

	VideoGuScreenClear();

	//Système
	SmsInit();
	nFrame = nDrawnFrames = 0;
	menuConfig.video.turbo = menuConfig.video.pause = 0;
	nbRenderedFramesPerSec = 0;
	gblFramerate = gblVirtualFramerate = 0;
	menuUpdateRender = 0;

	//Système
	if (gblMachineType == EM_SMS)
		system_poweron();

	while(1){ // Principal Cycle
		//Pal support
		if (menuConfig.video.country == 1)
			framerate = 50;
		else
			framerate = 60;
		oslSetFramerate(framerate);

		if (menuUpdateRender)
			nDrawnFrames = 0, menuUpdateRender = 0;

		if (gblMachineType == EM_SMS)
			ControlsUpdate();
		else if (gblMachineType == EM_GBC){
			gbe_refresh();
			gbe_updatePad();
		}

		if (osl_quit)
			break;

		//Framerate
		if (menuConfig.video.cpuTime == 2){
			int vcount = osl_vblCount;
			if (!skip)
				nbRenderedFramesPerSec++;
			nbVirtualFramesPerSec++;
			if (vcount / framerate > lastVCount / framerate)			{
				gblFramerate = nbRenderedFramesPerSec;
				gblVirtualFramerate = nbVirtualFramesPerSec;
				nbRenderedFramesPerSec = 0;
				nbVirtualFramesPerSec = 0;
			}
			lastVCount = vcount;
		}

		if (!menuConfig.video.pause){
			if (gblMachineType == EM_SMS){
				system_frame(skip);
				if (menuConfig.sound.turboSound /*== 2*/ || !menuConfig.video.turbo){
					//On peut commencer à jouer le son: tout est initialisé (sinon il faut attendre)
					soundPause = 0;
					if (!menuConfig.sound.perfectSynchro){
						SoundUpdate();
					}
				}
			}
			else if (gblMachineType == EM_GBC){
				//Run one GB frame
				gb_doFrame(skip);
				soundPause = 0;
				if (menuConfig.sound.turboSound /*== 2*/ || !menuConfig.video.turbo)		{
					soundPause = 0;
					if (!menuConfig.sound.perfectSynchro)			{
						snd_render_orig(snd.output, snd.sample_count);
						SoundUpdate();
					}
				}
			}
		}

		if (!skip && menuConfig.video.syncMode == 0){
			//if (gblMachineType == EM_SMS)
			VideoGuUpdate(nDrawnFrames, menuConfig.video.render);
			frameReady = 1;
			nDrawnFrames++;
		}
		oslDrawString(10,10,"Mod By Davis");
		//vsyncAdd = 0;
		//redo:
		if (menuConfig.video.turbo){
			if (!skip){
				oslEndDrawing();
				oslSwapBuffers();
			}
			skip = nFrame % (menuConfig.video.turboSkip + 1);
		}
		else{
			int vsync = 4 /*+ vsyncAdd*/;
			if (menuConfig.video.vsync == 2)
				vsync |= 1;
			/*else if (menuConfig.video.vsync == 1)
				vsync |= 8;*/

			/*if (autoFskip && !skip)
				tmp = oslMeanBenchmarkTestEx(OSL_BENCH_END, 0);*/

			skip = oslSyncFrameEx(oslMinMax(frameskip+1, menuConfig.video.frameskip, menuConfig.video.frameskipMax), menuConfig.video.frameskipMax, vsync);

			/*if (autoFskip && !skip)		{
				//Store the CPU usage (in percent)
				cpuTime = tmp * 6 / 1000;
				oslBenchmarkTest(OSL_BENCH_START);
			}*/
		}

		/*if (autoFskip){
			if (!skip){
				cpuTime = oslMeanBenchmarkTestEx(OSL_BENCH_GET_LAST, 0) * 6 / 1000;
				oslMeanBenchmarkTestEx(OSL_BENCH_START, 0);
				targetFrameskip = skippedFrames;
				skippedFrames = 0;
			}
			else{
				skippedFrames++;
			}
		}*/
		if (!skip && menuConfig.video.syncMode == 1)			{
			//if (gblMachineType == EM_SMS)
			VideoGuUpdate(nDrawnFrames, menuConfig.video.render);
			frameReady = 1;
			nDrawnFrames++;
		}

		nFrame++;
		//Pal
		/*if (menuConfig.video.country == 1 && nFrame % 6 == 0)		{
			if (!skip)
				vsyncAdd = 16;
			goto redo;
		}*/
		//In game, menu not currently shown - WARNING: DONT MOVE THIS, THE MESSAGEBOX CODE RELIES ON menuIsInGame == 2 TO KNOW IF THE GAME IS CURRENTLY RUNNING (or menuIsInGame == 1 = menu is shown)
		menuIsInGame = 2;

		if (menuDisplaySpecialMessage)
			MenuSpecialMessageDisplay();
	} // End Of While
	SmsTerm();
	//SmsEmulate();
	// End Emulate
	SaveMyPlacesFile();
	sceKernelExitGame();

    return 0;
}