Пример #1
0
void Init()
{
	if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
	{
		// AyuanX: TO BE TWEAKED
		// Now the 1500 is a pure assumption
		// We need to figure out the real frequency though

		// FYI, WII_IPC_HLE_Interface::Update is also called in WII_IPCInterface::Write32
		const int freq = 1500;
		IPC_HLE_PERIOD = GetTicksPerSecond() / (freq * VideoInterface::GetNumFields());
	}

	// System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA
	AUDIO_DMA_PERIOD = CPU_CORE_CLOCK / (AudioInterface::GetAIDSampleRate() * 4 / 32);

	// Emulated gekko <-> flipper bus speed ratio (cpu clock / flipper clock)
	CP_PERIOD = GetTicksPerSecond() / 10000;

	Common::Timer::IncreaseResolution();
	// store and convert localtime at boot to timebase ticks
	CoreTiming::SetFakeTBStartValue((u64)(CPU_CORE_CLOCK / TIMER_RATIO) * (u64)CEXIIPL::GetGCTime());
	CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());

	CoreTiming::SetFakeDecStartValue(0xFFFFFFFF);
	CoreTiming::SetFakeDecStartTicks(CoreTiming::GetTicks());

	et_Dec = CoreTiming::RegisterEvent("DecCallback", DecrementerCallback);
	et_VI = CoreTiming::RegisterEvent("VICallback", VICallback);
	et_SI = CoreTiming::RegisterEvent("SICallback", SICallback);
	if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSyncGPU)
		et_CP = CoreTiming::RegisterEvent("CPCallback", CPCallback);
	et_DSP = CoreTiming::RegisterEvent("DSPCallback", DSPCallback);
	et_AudioDMA = CoreTiming::RegisterEvent("AudioDMACallback", AudioDMACallback);
	et_IPC_HLE = CoreTiming::RegisterEvent("IPC_HLE_UpdateCallback", IPC_HLE_UpdateCallback);
	et_PatchEngine = CoreTiming::RegisterEvent("PatchEngine", PatchEngineCallback);
	et_Throttle = CoreTiming::RegisterEvent("Throttle", ThrottleCallback);

	CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine(), et_VI);
	CoreTiming::ScheduleEvent(0, et_DSP);
	CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerFrame(), et_SI);
	CoreTiming::ScheduleEvent(AUDIO_DMA_PERIOD, et_AudioDMA);
	CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeMs());
	if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSyncGPU)
		CoreTiming::ScheduleEvent(CP_PERIOD, et_CP);

	CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerFrame(), et_PatchEngine);

	if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
		CoreTiming::ScheduleEvent(IPC_HLE_PERIOD, et_IPC_HLE);
}
Пример #2
0
static void ThrottleCallback(u64 last_time, int cyclesLate)
{
	// Allow the GPU thread to sleep. Setting this flag here limits the wakeups to 1 kHz.
	GpuMaySleep();

	u32 time = Common::Timer::GetTimeMs();

	int diff = (u32)last_time - time;
	const SConfig& config = SConfig::GetInstance();
	bool frame_limiter = config.m_Framelimit && !Core::GetIsFramelimiterTempDisabled();
	u32 next_event = GetTicksPerSecond()/1000;
	if (SConfig::GetInstance().m_Framelimit > 1)
	{
		next_event = next_event * (SConfig::GetInstance().m_Framelimit - 1) * 5 / VideoInterface::TargetRefreshRate;
	}

	const int max_fallback = 40; // 40 ms for one frame on 25 fps games
	if (frame_limiter && abs(diff) > max_fallback)
	{
		DEBUG_LOG(COMMON, "system too %s, %d ms skipped", diff<0 ? "slow" : "fast", abs(diff) - max_fallback);
		last_time = time - max_fallback;
	}
	else if (frame_limiter && diff > 0)
		Common::SleepCurrentThread(diff);
	CoreTiming::ScheduleEvent(next_event - cyclesLate, et_Throttle, last_time + 1);
}
Пример #3
0
static void ThrottleCallback(u64 last_time, s64 cyclesLate)
{
  // Allow the GPU thread to sleep. Setting this flag here limits the wakeups to 1 kHz.
  Fifo::GpuMaySleep();

  u32 time = Common::Timer::GetTimeMs();

  int diff = (u32)last_time - time;
  const SConfig& config = SConfig::GetInstance();
  bool frame_limiter = config.m_EmulationSpeed > 0.0f && !Core::GetIsThrottlerTempDisabled();
  u32 next_event = GetTicksPerSecond() / 1000;
  if (frame_limiter)
  {
    if (config.m_EmulationSpeed != 1.0f)
      next_event = u32(next_event * config.m_EmulationSpeed);
    const int max_fallback = config.iTimingVariance;
    if (abs(diff) > max_fallback)
    {
      DEBUG_LOG(COMMON, "system too %s, %d ms skipped", diff < 0 ? "slow" : "fast",
                abs(diff) - max_fallback);
      last_time = time - max_fallback;
    }
    else if (diff > 0)
      Common::SleepCurrentThread(diff);
  }
  CoreTiming::ScheduleEvent(next_event - cyclesLate, et_Throttle, last_time + 1);
}
Пример #4
0
CPlayer::TCheatcode CPlayer::Update(COsGame& game, int flags, CSGMoveListItem& mli) {
   TCheatcode cheatcode;

   // time the call to GetMove()
   i8 ticksPerSecond=GetTicksPerSecond();
   i8 start=GetTicks();

   cheatcode = GetMove(game, flags, mli);

   i8 end=GetTicks();
   mli.tElapsed = (end-start)/(double)ticksPerSecond;

   return cheatcode;
}
Пример #5
0
void Init()
{
  if (SConfig::GetInstance().bWii)
  {
    // AyuanX: TO BE TWEAKED
    // Now the 1500 is a pure assumption
    // We need to figure out the real frequency though

    // FYI, WII_IPC_HLE_Interface::Update is also called in WII_IPCInterface::Write32
    const int freq = 1500;
    s_ipc_hle_period = GetTicksPerSecond() / freq;
  }

  // System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA
  s_audio_dma_period = s_cpu_core_clock / (AudioInterface::GetAIDSampleRate() * 4 / 32);

  Common::Timer::IncreaseResolution();
  // store and convert localtime at boot to timebase ticks
  if (SConfig::GetInstance().bEnableCustomRTC)
  {
    s_localtime_rtc_offset =
        Common::Timer::GetLocalTimeSinceJan1970() - SConfig::GetInstance().m_customRTCValue;
  }
  CoreTiming::SetFakeTBStartValue((u64)(s_cpu_core_clock / TIMER_RATIO) *
                                  (u64)CEXIIPL::GetGCTime());
  CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());

  CoreTiming::SetFakeDecStartValue(0xFFFFFFFF);
  CoreTiming::SetFakeDecStartTicks(CoreTiming::GetTicks());

  et_Dec = CoreTiming::RegisterEvent("DecCallback", DecrementerCallback);
  et_VI = CoreTiming::RegisterEvent("VICallback", VICallback);
  et_DSP = CoreTiming::RegisterEvent("DSPCallback", DSPCallback);
  et_AudioDMA = CoreTiming::RegisterEvent("AudioDMACallback", AudioDMACallback);
  et_IPC_HLE = CoreTiming::RegisterEvent("IPC_HLE_UpdateCallback", IPC_HLE_UpdateCallback);
  et_PatchEngine = CoreTiming::RegisterEvent("PatchEngine", PatchEngineCallback);
  et_Throttle = CoreTiming::RegisterEvent("Throttle", ThrottleCallback);

  CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine(), et_VI);
  CoreTiming::ScheduleEvent(0, et_DSP);
  CoreTiming::ScheduleEvent(s_audio_dma_period, et_AudioDMA);
  CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeMs());

  CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerField(), et_PatchEngine);

  if (SConfig::GetInstance().bWii)
    CoreTiming::ScheduleEvent(s_ipc_hle_period, et_IPC_HLE);
}
Пример #6
0
void ThrottleCallback(u64 last_time, int cyclesLate)
{
	u32 time = Common::Timer::GetTimeMs();

	int diff = (u32)last_time - time;
	bool frame_limiter = SConfig::GetInstance().m_Framelimit && SConfig::GetInstance().m_Framelimit != 2 && !Host_GetKeyState('\t');
	u32 next_event = GetTicksPerSecond()/1000;
	if (SConfig::GetInstance().m_Framelimit > 2)
	{
		next_event = next_event * (SConfig::GetInstance().m_Framelimit - 1) * 5 / VideoInterface::TargetRefreshRate;
	}

	const int max_fallback = 40; // 40 ms for one frame on 25 fps games
	if (frame_limiter && abs(diff) > max_fallback)
	{
		WARN_LOG(COMMON, "system too %s, %d ms skipped", diff<0 ? "slow" : "fast", abs(diff) - max_fallback);
		last_time = time - max_fallback;
	}
	else if (frame_limiter && diff > 0)
		Common::SleepCurrentThread(diff);
	CoreTiming::ScheduleEvent(next_event - cyclesLate, et_Throttle, last_time + 1);
}
Пример #7
0
u32 ConvertMillisecondsToTicks(u32 _Milliseconds)
{
	return GetTicksPerSecond() / 1000 * _Milliseconds;
}
Пример #8
0
void Init()
{
	if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
	{
		if (!DSP::GetDSPEmulator()->IsLLE())
			DSP_PERIOD = (int)(GetTicksPerSecond() * 0.003f);

		// AyuanX: TO BE TWEAKED
		// Now the 1500 is a pure assumption
		// We need to figure out the real frequency though

		// FIXME: does Wiimote Speaker support really require a different interval? (issue 4608)
		const int interval = SConfig::GetInstance().m_LocalCoreStartupParameter.
				bDisableWiimoteSpeaker ? 15000 : 4000;
		const int fields = SConfig::GetInstance().m_LocalCoreStartupParameter.
				bVBeam ? 2 : 1;
		IPC_HLE_PERIOD = GetTicksPerSecond() / (interval * fields);
	}
	else
	{
		if (!DSP::GetDSPEmulator()->IsLLE())
			DSP_PERIOD = (int)(GetTicksPerSecond() * 0.005f);
	}

	if (DSP::GetDSPEmulator()->IsLLE())
		DSP_PERIOD = 12000; // TO BE TWEAKED

	// This is the biggest question mark.
	AI_PERIOD = GetTicksPerSecond() / 80;

	// System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA
	AUDIO_DMA_PERIOD = CPU_CORE_CLOCK / (AudioInterface::GetAIDSampleRate() * 4 / 32);

	Common::Timer::IncreaseResolution();
	// store and convert localtime at boot to timebase ticks
	CoreTiming::SetFakeTBStartValue((u64)(CPU_CORE_CLOCK / TIMER_RATIO) * (u64)CEXIIPL::GetGCTime());
	CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());

	CoreTiming::SetFakeDecStartValue(0xFFFFFFFF);
	CoreTiming::SetFakeDecStartTicks(CoreTiming::GetTicks());

	et_Dec = CoreTiming::RegisterEvent("DecCallback", DecrementerCallback);
	et_AI = CoreTiming::RegisterEvent("AICallback", AICallback);
	et_VI = CoreTiming::RegisterEvent("VICallback", VICallback);
	et_SI = CoreTiming::RegisterEvent("SICallback", SICallback);
	et_DSP = CoreTiming::RegisterEvent("DSPCallback", DSPCallback);
	et_AudioDMA = CoreTiming::RegisterEvent("AudioDMACallback", AudioDMACallback);
	et_IPC_HLE = CoreTiming::RegisterEvent("IPC_HLE_UpdateCallback", IPC_HLE_UpdateCallback);
	et_PatchEngine = CoreTiming::RegisterEvent("PatchEngine", PatchEngineCallback);

	CoreTiming::ScheduleEvent(AI_PERIOD, et_AI);
	CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine(), et_VI);
	CoreTiming::ScheduleEvent(DSP_PERIOD, et_DSP);
	CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerFrame(), et_SI);
	CoreTiming::ScheduleEvent(AUDIO_DMA_PERIOD, et_AudioDMA);

	CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerFrame(), et_PatchEngine);

	if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
		CoreTiming::ScheduleEvent(IPC_HLE_PERIOD, et_IPC_HLE);
}