Ejemplo n.º 1
0
void OSPC_Play(char *fname,int release,int vol) {
	  u16 *menu_bg;	  
		u16 *dst,*src;
    int i,j,pollcpt;    
    char str[256];    
    char *emulator[3]={"Unknown","Zsnes","Snes9x"};
    uint8 *scr;
   
    OSPC_Init();

    if (i=OSPC_Load(fname))
    {
    	sprintf(str,"Error at SPC loading, code : %d",i);
    	msgBoxLines(str,60);
    	//gp32_pause();
    	//GpAppExit();
    	return;
    }
     

	OSPC_id=OSPC_GetID666(spc_data);
	
  OSPC_sound_fd = sceAudioChReserve( -1, 1024, 0 );
  OSPC_exit=0;
  OSPC_volume=vol;
  OSPC_thread = sceKernelCreateThread( "OSPC Thread", (SceKernelThreadEntry)OSPC_PlayThread, 0x8, 256*1024, 0, 0 );    
  if (OSPC_thread<0) {
  	msgBoxLines("Cannot create OSPC playback thread",60);
  } else {
  	//init start time
		scePowerSetClockFrequency(266,266,133);
		sceKernelLibcGettimeofday( &OSPC_start_time, 0 );
  	
  	sceKernelStartThread( OSPC_thread, 0, 0 );
  	
  	if (release) return;  		  		  			
  	//init bg
  	menu_bg=(u16*)malloc_64(480*272*2);
		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;
		}
		//init fx
		fx_init();  		  			
  	for (;;) {
  		//show bg
  		OSPC_show_bg(menu_bg);
  		//show bg fx
  		fx_main(pgGetVramAddr(0,0));
  		
   		//batt infos
  		show_batteryinfo();
  		//music info
  		//draw frame
  		pgDrawFrame(14,14,20+230+5+1,75+1,12|(12<<5)|(12<<10));
  		pgDrawFrame(13,13,20+230+5+2,75+2,30|(30<<5)|(30<<10));
  		pgDrawFrame(12,12,20+230+5+3,75+3,12|(12<<5)|(12<<10));
  		pgFillBoxHalfer(15,15,20+230+5,75);
  		//
  		if (strlen(OSPC_id->gametitle)) sprintf(str,"Game : %s",OSPC_id->gametitle);
  		else sprintf(str,"Game : unknown");
  		mh_print(20,20,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->songname)) sprintf(str,"Song : %s",OSPC_id->songname);
  		else sprintf(str,"Song : unknown");  			
  		mh_print(20,30,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->dumper)) sprintf(str,"Dumper : %s",OSPC_id->dumper);
  		else sprintf(str,"Dumper : unknown");
  		mh_print(20,40,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->comments)) sprintf(str,"Comments : %s",OSPC_id->comments);
  		else sprintf(str,"Comments : unknown");
  		mh_print(20,50,(char*)str,30|(30<<5)|(30<<10));
  		
  		if (strlen(OSPC_id->author)) sprintf(str,"Author : %s",OSPC_id->author);
  		else sprintf(str,"Author : unknown");
  		mh_print(20,60,(char*)str,30|(30<<5)|(30<<10));
			//time infos
			//draw frame
			//draw frame
  		pgDrawFrame(14,94,20+65+5+1,116,8|(8<<5)|(16<<10));
  		pgDrawFrame(13,93,20+65+5+2,117,28|(28<<5)|(31<<10));
  		pgDrawFrame(12,92,20+65+5+3,118,8|(8<<5)|(16<<10));
			pgFillBoxHalfer(15,95,20+65+5,115);
			sceKernelLibcGettimeofday( &OSPC_cur_time, 0 );
			i=(OSPC_cur_time.tv_sec-OSPC_start_time.tv_sec)+(OSPC_cur_time.tv_usec-OSPC_start_time.tv_usec)/1000000;
  		sprintf(str,"%2d%c%.2d / %2d:%.2d",i/60,((i&1)?':':' '),i%60,OSPC_id->playtime/60,OSPC_id->playtime%60);
  		mh_print(20,100,(char*)str,(20)|(31<<5)|(18<<10));
  		  		
  		if (get_pad()) break;
  			
  		pgScreenFlip();
  	}
  	OSPC_exit=1;  	
  	sceKernelWaitThreadEnd( OSPC_thread, NULL );
		sceKernelDeleteThread( OSPC_thread );
		OSPC_thread=-1;
		
		free(menu_bg);
		fx_close();
  }    
  sceAudioChRelease( OSPC_sound_fd );
  OSPC_Stop();            
  OSPC_Close();    
  if (OSPC_id) free(OSPC_id);
}
Ejemplo n.º 2
0
void pgScreenFlipV()
{
	pgScreenFlip();
}
Ejemplo n.º 3
0
void InputUpdatePad(void)
{
	SceCtrlData paddata;
	static boolean bPushFlag = FALSE;
	static boolean bTogglePushFlag = FALSE;

	g_PadBit[0]=0;
	stKeyState.bRapidA = FALSE;
	stKeyState.bRapidB = FALSE;
	sceCtrlPeekBufferPositive(&paddata, 1);

	// Analog pad state
	if (paddata.Ly > UPPER_THRESHOLD) {
		paddata.Buttons |= PSP_CTRL_A_DOWN;	// DOWN(analog)
	}
	else if (paddata.Ly < LOWER_THRESHOLD) {
		paddata.Buttons |= PSP_CTRL_A_UP;	// UP(analog)
	}
	if (paddata.Lx < LOWER_THRESHOLD) {
		paddata.Buttons |= PSP_CTRL_A_LEFT; // LEFT(analog)
	}
	else if (paddata.Lx > UPPER_THRESHOLD) {
		paddata.Buttons |= PSP_CTRL_A_RIGHT; // RIGHT(analog)
	}

    // Hold
    if (paddata.Buttons & PSP_CTRL_HOLD) {
		paddata.Buttons = 0;
	}

	// for Enter Menu
	now_pad = paddata.Buttons;

	// ↑↓←→
	if((paddata.Buttons&setting.key_config[0])==setting.key_config[0] && setting.key_config[0])
		g_PadBit[0] |= NES_UP;
	if((paddata.Buttons&setting.key_config[1])==setting.key_config[1] && setting.key_config[1])
		g_PadBit[0] |= NES_DOWN;
	if((paddata.Buttons&setting.key_config[2])==setting.key_config[2] && setting.key_config[2])
		g_PadBit[0] |= NES_LEFT;
	if((paddata.Buttons&setting.key_config[3])==setting.key_config[3] && setting.key_config[3])
		g_PadBit[0] |= NES_RIGHT;

	// A、B AB連射
	if((paddata.Buttons&setting.key_config[6])==setting.key_config[6] && setting.key_config[6])
		stKeyState.bRapidA = TRUE;
	else if((paddata.Buttons&setting.key_config[4])==setting.key_config[4] && setting.key_config[4])
		g_PadBit[0] |= NES_A;
	if((paddata.Buttons&setting.key_config[7])==setting.key_config[7] && setting.key_config[7])
		stKeyState.bRapidB = TRUE;
	else if((paddata.Buttons&setting.key_config[5])==setting.key_config[5] && setting.key_config[5])
		g_PadBit[0] |= NES_B;
	if((paddata.Buttons&setting.key_config[8])==setting.key_config[8] && setting.key_config[8])
		g_PadBit[0] |= NES_SELECT;
	if((paddata.Buttons&setting.key_config[9])==setting.key_config[9] && setting.key_config[9])
		g_PadBit[0] |= NES_START;

	g_PadBit[4]=0;
	// PLAYER2 MIC
	if((paddata.Buttons&setting.key_config[11])==setting.key_config[11] && setting.key_config[11])
		g_PadBit[4] |= 0x04;

	//>>>davex
	if( screen_rotated_on){
		if(paddata.Buttons & PSP_CTRL_DOWN)  g_PadBit[0] |= NES_UP;
		if(paddata.Buttons & PSP_CTRL_UP)    g_PadBit[0] |= NES_DOWN;
		if(paddata.Buttons & PSP_CTRL_LEFT)  g_PadBit[0] |= NES_RIGHT;
		if(paddata.Buttons & PSP_CTRL_RIGHT) g_PadBit[0] |= NES_LEFT;

	}else{

		// cross
		if(paddata.Buttons & PSP_CTRL_DOWN)  g_PadBit[0] |= NES_DOWN;
		if(paddata.Buttons & PSP_CTRL_UP)    g_PadBit[0] |= NES_UP;
		if( g_mirror){
			if(paddata.Buttons & PSP_CTRL_LEFT)  g_PadBit[0] |= NES_RIGHT;
			if(paddata.Buttons & PSP_CTRL_RIGHT) g_PadBit[0] |= NES_LEFT;
		}else{
			if(paddata.Buttons & PSP_CTRL_LEFT)  g_PadBit[0] |= NES_LEFT;
			if(paddata.Buttons & PSP_CTRL_RIGHT) g_PadBit[0] |= NES_RIGHT;
		}
	}//<<<

	// Toggle モードじゃないときの処理
	if(!setting.bToggle) {
		// Speed mode
		if(setting.key_config[12] && (paddata.Buttons&setting.key_config[12])==setting.key_config[12]){
			stKeyState.nSpeedMode = EMU_SPEED_MODE1;
		}else if(setting.key_config[13] && (paddata.Buttons&setting.key_config[13])==setting.key_config[13]){
			stKeyState.nSpeedMode = EMU_SPEED_MODE2;
		}
		else {
			stKeyState.nSpeedMode = EMU_SPEED_NORMAL;
		}
	}
	else {
		// Speed mode 1(Toggle)
		if(setting.bToggle && setting.key_config[12] && (paddata.Buttons&setting.key_config[12])==setting.key_config[12]){
			if (!bTogglePushFlag) {
				if( stKeyState.nSpeedMode == EMU_SPEED_MODE1 ){
					char szTemp[128];
					stKeyState.nSpeedMode = EMU_SPEED_NORMAL;
					_strcpy(szTemp, "SPEED MODE: NORMAL");
					Scr_SetMessage(szTemp, 120, 0xFFFF);
				}else{
					char msg[256], szTemp[128];
					stKeyState.nSpeedMode = EMU_SPEED_MODE1;
					_strcpy(szTemp, "SPEED MODE: MODE 1 (");
					_itoa(setting.speedmode1, msg);
					_strcat(szTemp, msg);
					_strcat(szTemp, "fps)");
					Scr_SetMessage(szTemp, 120, 0xFFFF);
				}
				bTogglePushFlag = TRUE;
			}
			// キーをクリアすると押したとき動きが止まるのでクリアしない
			//g_PadBit[0]=0;
		}
		// Speed mode 2(Toggle)
		else if(setting.bToggle && setting.key_config[13] && (paddata.Buttons&setting.key_config[13])==setting.key_config[13]){
			if (!bTogglePushFlag) {
				if( stKeyState.nSpeedMode == EMU_SPEED_MODE2 ){
					char szTemp[128];
					stKeyState.nSpeedMode = EMU_SPEED_NORMAL;
					_strcpy(szTemp, "SPEED MODE: NORMAL");
					Scr_SetMessage(szTemp, 120, 0xFFFF);
				}else{
					char msg[256], szTemp[128];
					stKeyState.nSpeedMode = EMU_SPEED_MODE2;
					_strcpy(szTemp, "SPEED MODE: MODE 2 (");
					_itoa(setting.speedmode2, msg);
					_strcat(szTemp, msg);
					_strcat(szTemp, "fps)");
					Scr_SetMessage(szTemp, 120, 0xFFFF);
				}
				bTogglePushFlag = TRUE;
			}
			// キーをクリアすると押したとき動きが止まるのでクリアしない
			//g_PadBit[0]=0;
		}
		else {
			bTogglePushFlag = FALSE;
		}
	}

	if (1) {
		// Sound on/off
		if(setting.key_config[14] && (paddata.Buttons&setting.key_config[14])==setting.key_config[14]){
			if (!bPushFlag) {
				g_NESConfig.sound.enabled = g_NESConfig.sound.enabled ? 0: 1;
				Scr_SetMessage(g_NESConfig.sound.enabled ? "SOUND ENABLE": "SOUND DISABLE", 120, 0xFFFF);
				PSPEMU_ApplySoundConfig();
				wavout_enable=g_NESConfig.sound.enabled;
				bPushFlag = TRUE;
			}
			g_PadBit[0]=0;
		}
		// Screen size change
		else if(setting.key_config[15] && (paddata.Buttons&setting.key_config[15])==setting.key_config[15]){
			if (!bPushFlag) {
				setting.screenmode = (setting.screenmode + 1) % SCREEN_COUNT;
				char szTemp[128];
				_strcpy(szTemp, "SCREEN SIZE:");
				_strcat(szTemp, aszScreenName[setting.screenmode]);
				// 画面の掃除
				pgFillvram(0); pgScreenFlip();
				pgFillvram(0); pgScreenFlip();
				pgFillvram(0); pgScreenFlip();
				Scr_SetMessage(szTemp, 120, 0xFFFF);
				bPushFlag = TRUE;
			}
			g_PadBit[0]=0;
		}
		// Quick save
		else if(setting.key_config[16] && (paddata.Buttons&setting.key_config[16])==setting.key_config[16]){
			if (!bPushFlag) {
				PSPEMU_Freeze();
				if(PSPEMU_SaveState(StateSlot)) {
					char szTemp[128];
					_strcpy(szTemp, "State save at x");
					szTemp[sizeof("State save at x") - 2] = StateSlot+'0';
					Scr_SetMessage(szTemp, 120, 0xFFFF);
				}
				else
					Scr_SetMessage("State save Failed", 120, RGB(255, 0, 0));
				bPushFlag = TRUE;
				PSPEMU_Thaw();
			}
			g_PadBit[0]=0;
		}
		// Quick load
		else if(setting.key_config[17] && (paddata.Buttons&setting.key_config[17])==setting.key_config[17]){
			if (!bPushFlag) {
				if(PSPEMU_LoadState(StateSlot)) {
					char szTemp[128];
					_strcpy(szTemp, "State load at x");
					szTemp[sizeof("State load at x") - 2] = StateSlot+'0';
					Scr_SetMessage(szTemp, 120, 0xFFFF);
				}
				else
					Scr_SetMessage("State load Failed", 120, RGB(255, 0, 0));
				bPushFlag = TRUE;
			}
			g_PadBit[0]=0;
		}
		// Quick Slot change
		else if(setting.key_config[18] && (paddata.Buttons&setting.key_config[18])==setting.key_config[18]){
			if (!bPushFlag) {
				char szTemp[128];
				StateSlot = (StateSlot + 1) % STATE_SLOT_MAX;
				_strcpy(szTemp,"QUICK SLOT : x");
				szTemp[sizeof("QUICK SLOT : x") -2] = StateSlot+'0';
				Scr_SetMessage(szTemp, 120, 0xFFFF);
				bPushFlag = TRUE;
			}
			g_PadBit[0]=0;
		}
		//Battery Display by Smiths
		else if(setting.key_config[19] && (paddata.Buttons&setting.key_config[19])==setting.key_config[19]){
			if (!bPushFlag) {
				char szTemp[128];
				int color;
				GetBatteryInfoString(szTemp, &color);
				Scr_SetMessage(szTemp, 120, 0xFFFF);
				bPushFlag = TRUE;
			}
			// キーをクリアすると押したとき動きが止まるのでクリアしない
			// メッセージしか表示しないしねぇ
			// g_PadBit[0]=0;
		}
		// Screen shot
		else if(setting.key_config[20] && (paddata.Buttons&setting.key_config[20])==setting.key_config[20]){
			if (!bPushFlag) {
				PSPEMU_Freeze();
				if(PSPEMU_SaveScreenShot()) {
					Scr_SetMessage("Save the Screen Shot Successfully", 120, 0xFFFF);
				}
				else
					Scr_SetMessage("Save the Screen Shot Failed", 120, RGB(255, 0, 0));
				bPushFlag = TRUE;
				PSPEMU_Thaw();
			}
			g_PadBit[0]=0;
		}
		else {
			bPushFlag = FALSE;
		}
	}

//	now_sensor_x=2047-paddata.analog[PSP_CTRL_ANALOG_X]+127;
//	now_sensor_y=2047-paddata.analog[PSP_CTRL_ANALOG_Y]+127;
}
Ejemplo n.º 4
0
void pgScreenFlipV()
{
	pgWaitV();
	pgScreenFlip();
}