コード例 #1
0
ファイル: main.cpp プロジェクト: jeremyfry/PocketSNES
bool8_32 S9xInitUpdate ()
{
	if(mInMenu) return (TRUE);
	if(mMenuOptions.fullScreen)	GFX.Screen = (uint8 *) sal_VideoGetBuffer();
	else				GFX.Screen = (uint8 *) sal_VideoGetBuffer()+(320-SNES_WIDTH)+((240-SNES_HEIGHT)*320);

	return (TRUE);
}
コード例 #2
0
ファイル: menu.cpp プロジェクト: DavidKnight247/PocketSNES
static s32 SaveStateSelect(s32 mode)
{
	s8 text[128];
	s32 action=11;
	s32 saveno=0;
	u32 keys=0;
	u16 *pixTo,*pixFrom;

	if(mRomName[0]==0)
	{
		// no rom loaded
		// display error message and exit
		return(0);
	}
	// Allow the emulator to back out of loading a saved state for previewing.
	SaveStateTemp();
	ScanSaveStates(mRomName);
	sal_InputIgnore();

	while (action!=0&&action!=100)
	{
		keys=sal_InputPollRepeat();

		if(keys&SAL_INPUT_UP) {saveno--; action=1;}
		if(keys&SAL_INPUT_DOWN) {saveno++; action=1;}
		if(saveno<-1) saveno=9;
		if(saveno>9) saveno=-1;
	      
		if(keys&INP_BUTTON_MENU_CANCEL) action=0; // exit
		else if((keys&INP_BUTTON_MENU_SELECT)&&(saveno==-1)) action=0; // exit
		else if((keys&INP_BUTTON_MENU_SELECT)&&(mode==0)&&((action==2)||(action==5))) action=6;  // pre-save mode
		else if((keys&INP_BUTTON_MENU_SELECT)&&(mode==1)&&(action==5)) action=8;  // pre-load mode
		else if((keys&INP_BUTTON_MENU_SELECT)&&(mode==2)&&(action==5))
		{
			if(MenuMessageBox("Are you sure you want to delete","this save?","",MENU_MESSAGE_BOX_MODE_YESNO)==SAL_OK) action=13;  //delete slot with no preview
		}
		else if((keys&INP_BUTTON_MENU_PREVIEW_SAVESTATE)&&(action==12)) action=3;  // preview slot mode
		else if((keys&INP_BUTTON_MENU_SELECT)&&(mode==1)&&(action==12)) action=8;  //load slot with no preview
		else if((keys&INP_BUTTON_MENU_SELECT)&&(mode==0)&&(action==12)) action=6;  //save slot with no preview
		else if((keys&INP_BUTTON_MENU_SELECT)&&(mode==2)&&(action==12))
		{
			if(MenuMessageBox("Are you sure you want to delete","this save?","",MENU_MESSAGE_BOX_MODE_YESNO)==SAL_OK) action=13;  //delete slot with no preview
		}

		PrintTitle("Save States");
		sal_VideoPrint(36,4,"UP/DOWN to choose a slot",SAL_RGB(31,8,8));
      
		if(saveno==-1) 
		{
			if(action!=10&&action!=0) 
			{
				action=10;
			}
		}
		else
		{
			sal_VideoDrawRect(0, 16, 262, 16, SAL_RGB(22,0,0));
			sprintf(text,"SLOT %d",saveno);
			sal_VideoPrint(107,20,text,SAL_RGB(31,31,31));
		}
      
		switch(action)
		{
			case 1:
				//sal_VideoPrint(112,145-36,14,"Checking....",(unsigned short)SAL_RGB(31,31,31));
				break;
			case 2:
				sal_VideoPrint(115,145-36,"FREE",SAL_RGB(31,31,31));
				break;
			case 3:
				sal_VideoPrint(75,145-36,"Previewing...",SAL_RGB(31,31,31));
				break;
			case 4:
				sal_VideoPrint(59,145-36,"Previewing failed",SAL_RGB(31,8,8));
				break;
			case 5: 
			{
				u32 DestWidth = 205, DestHeight = 154;
				sal_VideoBitmapScale(0, 0, SNES_WIDTH, SNES_HEIGHT, DestWidth, DestHeight, SAL_SCREEN_WIDTH - DestWidth, &mTempFb[0], (u16*)sal_VideoGetBuffer()+(SAL_SCREEN_WIDTH*(((202 + 16) - DestHeight)/2))+((262 - DestWidth)/2));

				sal_VideoDrawRect(0, 186, 262, 16, SAL_RGB(22,0,0));

				if(mode==1) sal_VideoPrint((262-(strlen(MENU_TEXT_LOAD_SAVESTATE)<<3))>>1,190,MENU_TEXT_LOAD_SAVESTATE,SAL_RGB(31,31,31));
				else if(mode==0) sal_VideoPrint((262-(strlen(MENU_TEXT_OVERWRITE_SAVESTATE)<<3))>>1,190,MENU_TEXT_OVERWRITE_SAVESTATE,SAL_RGB(31,31,31));
				else if(mode==2) sal_VideoPrint((262-(strlen(MENU_TEXT_DELETE_SAVESTATE)<<3))>>1,190,MENU_TEXT_DELETE_SAVESTATE,SAL_RGB(31,31,31));
				break;
			}
			case 6:
				sal_VideoPrint(95,145-36,"Saving...",SAL_RGB(31,31,31));
				break;
			case 7:
				sal_VideoPrint(95,145-36,"Saving failed",SAL_RGB(31,8,8));
				break;
			case 8:
				sal_VideoPrint(87,145-36,"Loading...",SAL_RGB(31,31,31));
				break;
			case 9:
				sal_VideoPrint(87,145-36,"Loading failed",SAL_RGB(31,8,8));
				break;
			case 10:	
				PrintBar(145-36-4);
				sal_VideoPrint(75,145-36,"Return to menu",SAL_RGB(31,31,31));
				break;
			case 12:
				sal_VideoPrint(95,145-36,"Slot used",SAL_RGB(31,31,31));
				sal_VideoPrint((262-(strlen(MENU_TEXT_PREVIEW_SAVESTATE)<<3))>>1,165,MENU_TEXT_PREVIEW_SAVESTATE,SAL_RGB(31,31,31));
				if(mode==1) sal_VideoPrint((262-(strlen(MENU_TEXT_LOAD_SAVESTATE)<<3))>>1,175,MENU_TEXT_LOAD_SAVESTATE,SAL_RGB(31,31,31));
				else if(mode==0) sal_VideoPrint((262-(strlen(MENU_TEXT_OVERWRITE_SAVESTATE)<<3))>>1,175,MENU_TEXT_OVERWRITE_SAVESTATE,SAL_RGB(31,31,31));
コード例 #3
0
ファイル: main.cpp プロジェクト: DavidKnight247/PocketSNES
    bool8_32 S9xDeinitUpdate (int Width, int Height, bool8_32)
    {
        if(mInMenu) return TRUE;

        // After returning from the menu, clear the background of 3 frames.
        // This prevents remnants of the menu from appearing.
        if (mFramesCleared < 3)
        {
            sal_VideoClear(0);
            mFramesCleared++;
        }

        // If the height changed from 224 to 239, or from 239 to 224,
        // possibly change the resolution.
        bool PAL = !!(Memory.FillRAM[0x2133] & 4);
        if (PAL != LastPAL)
        {
            sal_VideoSetPAL(mMenuOptions.fullScreen, PAL);
            LastPAL = PAL;
        }

        switch (mMenuOptions.fullScreen)
        {
        case 0: /* No scaling */
        case 3: /* Hardware scaling */
        {
            u32 h = PAL ? SNES_HEIGHT_EXTENDED : SNES_HEIGHT;
            u32 y, pitch = sal_VideoGetPitch();
            u8 *src = (u8*) IntermediateScreen, *dst = (u8*) sal_VideoGetBuffer()
                      + ((sal_VideoGetWidth() - SNES_WIDTH) / 2) * sizeof(u16)
                      + ((sal_VideoGetHeight() - h) / 2) * pitch;
            for (y = 0; y < h; y++)
            {
                memcpy(dst, src, SNES_WIDTH * sizeof(u16));
                src += SNES_WIDTH * sizeof(u16);
                dst += pitch;
            }
            break;
        }

        case 1: /* Fast software scaling */
            if (PAL) {
                upscale_256x240_to_320x240((uint32_t*) sal_VideoGetBuffer(), (uint32_t*) IntermediateScreen, SNES_WIDTH);
            } else {
                upscale_p((uint32_t*) sal_VideoGetBuffer(), (uint32_t*) IntermediateScreen, SNES_WIDTH);
            }
            break;

        case 2: /* Smooth software scaling */
            if (PAL) {
                upscale_256x240_to_320x240_bilinearish((uint32_t*) sal_VideoGetBuffer() + 160, (uint32_t*) IntermediateScreen, SNES_WIDTH);
            } else {
                upscale_256x224_to_320x240_bilinearish((uint32_t*) sal_VideoGetBuffer() + 160, (uint32_t*) IntermediateScreen, SNES_WIDTH);
            }
            break;
        }

        u32 newTimer;
        if (mMenuOptions.showFps)
        {
            mFps++;
            newTimer=sal_TimerRead();
            if(newTimer-mLastTimer>Memory.ROMFramesPerSecond)
            {
                mLastTimer=newTimer;
                sprintf(mFpsDisplay,"%2d/%2d", mFps, Memory.ROMFramesPerSecond);
                mFps=0;
            }

            sal_VideoDrawRect(0,0,5*8,8,SAL_RGB(0,0,0));
            sal_VideoPrint(0,0,mFpsDisplay,SAL_RGB(31,31,31));
        }

        if(mVolumeDisplayTimer>0)
        {
            sal_VideoDrawRect(100,0,8*8,8,SAL_RGB(0,0,0));
            sal_VideoPrint(100,0,mVolumeDisplay,SAL_RGB(31,31,31));
        }

        if(mQuickStateTimer>0)
        {
            sal_VideoDrawRect(200,0,8*8,8,SAL_RGB(0,0,0));
            sal_VideoPrint(200,0,mQuickStateDisplay,SAL_RGB(31,31,31));
        }

        sal_VideoFlip(0);
    }
コード例 #4
0
ファイル: main.cpp プロジェクト: jeremyfry/PocketSNES
int SnesInit()
{
	ZeroMemory (&Settings, sizeof (Settings));

	Settings.JoystickEnabled = FALSE;
	Settings.SoundPlaybackRate = 44100;
	Settings.Stereo = TRUE;
	Settings.SoundBufferSize = 0;
	Settings.CyclesPercentage = 100;
	Settings.DisableSoundEcho = FALSE;
	Settings.APUEnabled = TRUE;
	Settings.H_Max = SNES_CYCLES_PER_SCANLINE;
	Settings.SkipFrames = AUTO_FRAMERATE;
	Settings.Shutdown = Settings.ShutdownMaster = TRUE;
	Settings.FrameTimePAL = 20000;
	Settings.FrameTimeNTSC = 16667;
	Settings.FrameTime = Settings.FrameTimeNTSC;
	Settings.DisableSampleCaching = FALSE;
	Settings.DisableMasterVolume = TRUE;
	Settings.Mouse = FALSE;
	Settings.SuperScope = FALSE;
	Settings.MultiPlayer5 = FALSE;
	//	Settings.ControllerOption = SNES_MULTIPLAYER5;
	Settings.ControllerOption = 0;

	Settings.InterpolatedSound = TRUE;
	Settings.StarfoxHack = TRUE;
	
	Settings.ForceTransparency = FALSE;
	Settings.Transparency = TRUE;
	Settings.SixteenBit = TRUE;
	
	Settings.SupportHiRes = FALSE;
	Settings.NetPlay = FALSE;
	Settings.ServerName [0] = 0;
	Settings.AutoSaveDelay = 30;
	Settings.ApplyCheats = TRUE;
	Settings.TurboMode = FALSE;
	Settings.TurboSkipFrames = 15;
	Settings.ThreadSound = FALSE;
	Settings.SoundSync = FALSE;
	//Settings.NoPatch = true;		

	Settings.SuperFX = TRUE;
	Settings.DSP1Master = TRUE;
	Settings.SA1 = TRUE;
	Settings.C4 = TRUE;
	Settings.SDD1 = TRUE;

	GFX.Pitch = 320 * 2;
	GFX.RealPitch = 320 * 2;
	GFX.Screen = (uint8 *) sal_VideoGetBuffer();
	
	GFX.SubScreen = (uint8 *)malloc(GFX.RealPitch * 480 * 2); 
	GFX.ZBuffer =  (uint8 *)malloc(GFX.RealPitch * 480 * 2); 
	GFX.SubZBuffer = (uint8 *)malloc(GFX.RealPitch * 480 * 2);
	GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;
	GFX.PPL = GFX.Pitch >> 1;
	GFX.PPLx2 = GFX.Pitch;
	GFX.ZPitch = GFX.Pitch >> 1;
	
	if (Settings.ForceNoTransparency)
         Settings.Transparency = FALSE;

	if (Settings.Transparency)
         Settings.SixteenBit = TRUE;

	Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;

	if (!Memory.Init () || !S9xInitAPU())
	{
		S9xMessage (0,0,"Failed to init memory");
		return SAL_ERROR;
	}

	//S9xInitSound ();
	
	//S9xSetRenderPixelFormat (RGB565);
	S9xSetSoundMute (TRUE);

	if (!S9xGraphicsInit ())
	{
         	S9xMessage (0,0,"Failed to init graphics");
		return SAL_ERROR;
	}

	return SAL_OK;
}