Пример #1
0
void run_fba_emulator(const char *fn)
{
	char build_version[] = "Finalburn Alpha Plus for Pi  ("__DATE__")";

	// process rom path and name
	char romname[MAX_PATH];
	if (BurnCacheInit(fn, romname))
		goto finish;

	if(config_options.option_showfps)
		bShowFPS=true;

	BurnLibInit();
	
	// find rom by name
	for (nBurnDrvSelect=0; nBurnDrvSelect<nBurnDrvCount; nBurnDrvSelect++)
		if ( strcasecmp(romname, BurnDrvGetTextA(DRV_NAME)) == 0 )
			break;
	if (nBurnDrvSelect >= nBurnDrvCount) {
		// unsupport rom ...
		nBurnDrvSelect = ~0U;
		logoutput ("rom not supported!\n");
		printf ("rom not supported!\n");
		goto finish;
	}
	
	logoutput("Attempt to initialise '%s'\n", BurnDrvGetTextA(DRV_FULLNAME));
	
	memset (titlefb, 0, 320*240*2);
	DrawString (build_version, (uint16*)&titlefb, 10, 20, 320);
	DrawString ("Based on FinalBurnAlpha", (uint16*)&titlefb, 10, 35, 320);
	DrawString ("Now loading ... ", (uint16 *)&titlefb, 10, 105, 320);	
	show_rom_loading_text("Open Zip", 0, 0);
	memcpy (VideoBuffer, titlefb, 320*240*2); 
	pi_video_flip();
	 	
	InpInit();
	InpDIP();
	
	VideoInit();

	if (DrvInit(nBurnDrvSelect, false) != 0) {
		logoutput ("Driver initialisation failed! Likely causes are:\n- Corrupt/Missing ROM(s)\n- I/O Error\n- Memory error\n\n");
		printf ("Driver initialisation failed! Likely causes are:\n- Corrupt/Missing ROM(s)\n- I/O Error\n- Memory error\n\n");
		goto finish;
	}

	RunReset();

	frame_count = 0;
	GameLooping = true;

	EZX_StartTicks();

	logoutput ("Lets go!\n");
	logflush();

	if (config_options.option_sound_enable)
	{
		int timer = 0, tick=0, i=0, fps = 0;
		bool bRenderFrame;

		if (SndOpen() == 0)
		{		
			while (GameLooping)
			{
					if (bShowFPS)
					{
						timer = EZX_GetTicks();
						if(timer-tick>1000000)
						{
							fps = nFramesRendered;
							nFramesRendered = 0;
							tick = timer;
						}
					}
					//We need to render more audio:  
		
					bRenderFrame=true; // Render last frame
					RunOneFrame(bRenderFrame,fps);

					update_audio_stream(pBurnSoundOut);
					pi_process_events();
			}
		}
	}
	else
	{
		int now, done=0, timer = 0, ticks=0, tick=0, i=0, fps = 0;
		unsigned int frame_limit = nBurnFPS/100, frametime = 100000000/nBurnFPS;
		
		while (GameLooping)
		{
			timer = EZX_GetTicks()/frametime;;
			if(timer-tick>frame_limit && bShowFPS)
			{
				fps = nFramesRendered;
				nFramesRendered = 0;
				tick = timer;
			}
			now = timer;
			ticks=now-done;
			if(ticks<1) continue;
			if(ticks>10) ticks=10;
			for (i=0; i<ticks-1; i++)
			{
				RunOneFrame(false,fps);	
			} 
			if(ticks>=1)
			{
				RunOneFrame(true,fps);	
			}
			
			done = now;
		}
	}
	
	logoutput ("Finished emulating\n");
	
finish:
	logoutput("---- Shutdown Finalburn Alpha plus ----\n\n");
	DrvExit();
	BurnLibExit();

	if (config_options.option_sound_enable)
		SndExit();
	VideoExit();
	InpExit();
	BurnCacheExit();
}
Пример #2
0
static void process_key( int key, int down, int repeat )
{
    if ( !down ) return ;
    switch( nGameStage ) {
    /* ---------------------------- Main Menu ---------------------------- */
    case 1:
        //ui_mainmenu_select
        switch( key ) {
        case PSP_CTRL_UP:
            if (ui_mainmenu_select <= 0) break;
            ui_mainmenu_select--;
            draw_ui_main();
            break;
        case PSP_CTRL_DOWN:
            if (ui_mainmenu_select >=9 ) break;
            ui_mainmenu_select++;
            draw_ui_main();
            break;

        case PSP_CTRL_LEFT:
            switch(ui_mainmenu_select) {
            case 7:
                if ( cpu_speeds_select > 0 ) {
                    cpu_speeds_select--;
                    draw_ui_main();
                }
                break;
            }
            break;
        case PSP_CTRL_RIGHT:
            switch(ui_mainmenu_select) {
            case 7:
                if ( cpu_speeds_select < 3 ) {
                    cpu_speeds_select++;
                    draw_ui_main();
                }
                break;
            }
            break;

        case PSP_CTRL_CIRCLE:
            switch( ui_mainmenu_select ) {
            case 0:
                nGameStage = 2;
                strcpy(ui_current_path, szAppRomPath);
                //ui_current_path[strlen(ui_current_path)-1] = 0;
                draw_ui_browse(true);
                break;
            case 8: // Return to Game
                if ( nPrevGame < nBurnDrvCount ) {
                    scePowerSetClockFrequency(
                        cpu_speeds[cpu_speeds_select].cpu,
                        cpu_speeds[cpu_speeds_select].cpu,
                        cpu_speeds[cpu_speeds_select].bus );
                    nGameStage = 0;
                }
                break;
            case 9:	// Exit
                bGameRunning = 0;
                break;

            }
            break;
        }
        break;
    /* ---------------------------- Rom Browse ---------------------------- */
    case 2:
        switch( key ) {
        case PSP_CTRL_UP:
            if (find_rom_select == 0) break;
            if (find_rom_top >= find_rom_select) find_rom_top--;
            find_rom_select--;
            draw_ui_browse(false);
            break;
        case PSP_CTRL_DOWN:
            if ((find_rom_select+1) >= find_rom_count) break;
            find_rom_select++;
            if ((find_rom_top + find_rom_list_cnt) <= find_rom_select) find_rom_top++;
            draw_ui_browse(false);
            break;
        case PSP_CTRL_CIRCLE:
            switch( getRomsFileStat(find_rom_select) ) {
            case -1:	// directry
            {   // printf("change dir %s\n", getRomsFileName(find_rom_select) );
                char * pn = getRomsFileName(find_rom_select);
                if ( strcmp("..", pn) ) {
                    strcat(ui_current_path, getRomsFileName(find_rom_select));
                    strcat(ui_current_path, "/");
                } else {
                    if (strlen(strstr(ui_current_path, ":/")) == 2) break;	// "ROOT:/"
                    for(int l = strlen(ui_current_path)-1; l>1; l-- ) {
                        ui_current_path[l] = 0;
                        if (ui_current_path[l-1] == '/') break;
                    }
                }
                //printf("change dir to %s\n", ui_current_path );
                find_rom_count = 0;
                find_rom_select = 0;
                find_rom_top = 0;
                draw_ui_browse(true);
            }
            break;
            default: // rom zip file
            {
                nBurnDrvSelect = (unsigned int)getRomsFileStat( find_rom_select );
                if (nBurnDrvSelect <= nBurnDrvCount && BurnDrvIsWorking() ) {

                    if ( DrvInit( nBurnDrvSelect, false ) == 0 ) {

                        BurnRecalcPal();
                        InpInit();
                        InpDIP();

                        scePowerSetClockFrequency(
                            cpu_speeds[cpu_speeds_select].cpu,
                            cpu_speeds[cpu_speeds_select].cpu,
                            cpu_speeds[cpu_speeds_select].bus );
                        nGameStage = 0;

                    } else
                        nBurnDrvSelect = ~0U;

                } else
                    nBurnDrvSelect = ~0U;

                nPrevGame = nBurnDrvSelect;

                //if (nBurnDrvSelect == ~0U) {
                //	bprintf(0, "unkown rom %s", getRomsFileName(find_rom_select));
                //}
            }



            }
            break;
        case PSP_CTRL_CROSS:	// cancel
            nGameStage = 1;
            draw_ui_main();
            break;
        }
        break;
    /* ---------------------------- DIP Setting ---------------------------- */
    case 3:

        break;

    }
}