コード例 #1
0
ファイル: snes.cpp プロジェクト: plasma-apps/emumaster
bool SnesEmu::init(const QString &diskPath, QString *error) {
	S9xSetSoundMute(FALSE);
	setDefaultSettings();
	S9xSetPlaybackRate();
	m_frame = QImage(512, 239, QImage::Format_RGB16);
	setVideoSrcRect(QRectF(0.0f, 0.0f, 256.0f, 224.f));
	setFrameRate(60);

	GFX.Pitch = 512 * 2;
	GFX.RealPitch = 512 * 2;
	GFX.PPL = GFX.Pitch >> 1;
	GFX.PPLx2 = GFX.Pitch;
	GFX.Screen = (u8 *)m_frame.bits();
	GFX.SubScreen = (u8 *) malloc(GFX.RealPitch * 239);
	GFX.ZBuffer = (u8 *) malloc(GFX.PPL * 239);
	GFX.SubZBuffer = (u8 *) malloc(GFX.PPL * 239);
	GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;

	if (!GFX.Screen || !GFX.SubScreen || !GFX.ZBuffer || !Memory.Init() || !S9xInitAPU() || !GFX.SubZBuffer ) {
		*error = tr("SNES emulation init failed!");
		return false;
	}
	S9xInitSound();
	if (!S9xGraphicsInit()) {
		*error = tr("SNES emulation init failed!");
		return false;
	}
	S9xReset();
	setDefaultSettings();
	*error = setDisk(diskPath);
	return error->isEmpty();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: jeremyfry/PocketSNES
static
int Run(int sound)
{
  	int skip=0, done=0, doneLast=0,aim=0,i;
	Settings.NextAPUEnabled = Settings.APUEnabled = sound;
	sal_TimerInit(Settings.FrameTime);
	done=sal_TimerRead()-1;

	if (sound) {
		/*
		Settings.SoundPlaybackRate = mMenuOptions.soundRate;
		Settings.Stereo = mMenuOptions.stereo ? TRUE : FALSE;
		*/
		Settings.SixteenBitSound=true;

		sal_AudioInit(mMenuOptions.soundRate, 16,
					mMenuOptions.stereo, Memory.ROMFramesPerSecond);

		S9xInitSound (mMenuOptions.soundRate,
					mMenuOptions.stereo, sal_AudioGetBufferSize());
		S9xSetPlaybackRate(mMenuOptions.soundRate);
		S9xSetSoundMute (FALSE);

	} else {
		S9xSetSoundMute (TRUE);
	}

  	while(!mEnterMenu) 
  	{
		for (i=0;i<10;i++)
		{
			aim=sal_TimerRead();
			if (done < aim)
			{
				done++;
				if (mMenuOptions.frameSkip == 0) //Auto
					IPPU.RenderThisFrame = (done >= aim);
				else if (IPPU.RenderThisFrame = (--skip <= 0))
					skip = mMenuOptions.frameSkip;

				//Run SNES for one glorious frame
				S9xMainLoop ();

				if (sound) {
					S9xMixSamples((uint8 *) sal_GetCurrentAudioBuffer(),
								sal_AudioGetSampleCount());
					sal_SubmitSamples();
				}
//				HandleQuickStateRequests();
			}
			if (done>=aim) break; // Up to date now
			if (mEnterMenu) break;
		}
		done=aim; // Make sure up to date
		HandleQuickStateRequests();
  	}

	if (sound)
		sal_AudioClose();

	mEnterMenu=0;
	return mEnterMenu;

}