initialize the uninitialized

This commit is contained in:
nitsuja 2012-01-02 02:20:22 -08:00
parent 81a1efab8e
commit 39613a95a8
24 changed files with 157 additions and 11 deletions

View File

@ -140,6 +140,7 @@ class VideoBackendHardware : public VideoBackend
{
void DoState(PointerWrap &p);
void RunLoop(bool enable);
bool Initialize(void *&) { InitializeShared(); return true; }
void EmuStateChange(EMUSTATE_CHANGE);
@ -165,6 +166,9 @@ class VideoBackendHardware : public VideoBackend
readFn16 Video_PERead16();
writeFn16 Video_PEWrite16();
writeFn32 Video_PEWrite32();
protected:
void InitializeShared();
};
#endif

View File

@ -346,6 +346,8 @@ void EmuThread()
DisplayMessage(cpu_info.Summarize(), 8000);
DisplayMessage(_CoreParameter.m_strFilename, 3000);
Movie::Init();
HW::Init();
if (!g_video_backend->Initialize(g_pWindowHandle))

View File

@ -133,6 +133,7 @@ void Init()
void Shutdown()
{
MoveEvents();
ClearPendingEvents();
UnregisterAllEvents();

View File

@ -153,6 +153,12 @@ void Init()
m_Volume.hex = 0;
m_SampleCounter = 0;
m_InterruptTiming = 0;
g_LastCPUTime = 0;
g_CPUCyclesPerSample = 0xFFFFFFFFFFFULL;
g_AISSampleRate = 48000;
g_AIDSampleRate = 32000;
}
void Shutdown()

View File

@ -54,6 +54,7 @@ void DoState(PointerWrap &p)
void Init()
{
ResetGatherPipe();
memset(m_gatherPipe, 0, sizeof(m_gatherPipe));
}
bool IsEmpty()

View File

@ -43,6 +43,7 @@ namespace HW
void Init()
{
CoreTiming::Init();
SystemTimers::PreInit();
State::Init();

View File

@ -246,10 +246,8 @@ void Init()
g_Channel[i].m_InHi.Hex = 0;
g_Channel[i].m_InLo.Hex = 0;
if (Movie::IsUsingPad(i))
AddDevice(SIDEVICE_GC_CONTROLLER, i);
else if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
AddDevice(SIDEVICE_NONE, i);
if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
AddDevice(Movie::IsUsingPad(i) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i);
else
AddDevice(SConfig::GetInstance().m_SIDevice[i], i);
}

View File

@ -231,12 +231,19 @@ void PatchEngineCallback(u64 userdata, int cyclesLate)
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerFrame() - cyclesLate, et_PatchEngine);
}
// split from Init to break a circular dependency between VideoInterface::Init and SystemTimers::Init
void PreInit()
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
CPU_CORE_CLOCK = 729000000u;
else
CPU_CORE_CLOCK = 486000000u;
}
void Init()
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
CPU_CORE_CLOCK = 729000000u;
if (!DSP::GetDSPEmulator()->IsLLE())
DSP_PERIOD = (int)(GetTicksPerSecond() * 0.003f);
@ -253,8 +260,6 @@ void Init()
}
else
{
CPU_CORE_CLOCK = 486000000u;
if (!DSP::GetDSPEmulator()->IsLLE())
DSP_PERIOD = (int)(GetTicksPerSecond() * 0.005f);
}

View File

@ -24,6 +24,7 @@ namespace SystemTimers
{
u32 GetTicksPerSecond();
void PreInit();
void Init();
void Shutdown();

View File

@ -158,6 +158,29 @@ void Preset(bool _bNTSC)
void Init()
{
m_VerticalTimingRegister.Hex = 0;
m_DisplayControlRegister.Hex = 0;
m_HTiming0.Hex = 0;
m_HTiming1.Hex = 0;
m_VBlankTimingOdd.Hex = 0;
m_VBlankTimingEven.Hex = 0;
m_BurstBlankingOdd.Hex = 0;
m_BurstBlankingEven.Hex = 0;
m_XFBInfoTop.Hex = 0;
m_XFBInfoBottom.Hex = 0;
m_3DFBInfoTop.Hex = 0;
m_3DFBInfoBottom.Hex = 0;
m_VBeamPos = 0;
m_HBeamPos = 0;
m_HorizontalStepping.Hex = 0;
m_HorizontalScaling.Hex = 0;
m_UnkAARegister = 0;
m_Clock = 0;
m_DTVStatus.Hex = 0;
m_FBWidth = 0;
m_BorderHBlank.Hex = 0;
memset(&m_FilterCoefTables, 0, sizeof(m_FilterCoefTables));
fields = Core::g_CoreStartupParameter.bVBeam ? 1 : 2;
m_DTVStatus.ntsc_j = Core::g_CoreStartupParameter.bForceNTSCJ;
@ -165,6 +188,9 @@ void Init()
for (int i = 0; i < 4; i++)
m_InterruptRegister[i].Hex = 0;
for (int i = 0; i < 2; i++)
m_LatchRegister[i].Hex = 0;
m_DisplayControlRegister.Hex = 0;
UpdateParameters();
}

View File

@ -105,6 +105,34 @@ void FrameUpdate()
g_bPolled = false;
}
// called when game is booting up, even if no movie is active,
// but potentially after BeginRecordingInput or PlayInput has been called.
void Init()
{
g_bPolled = false;
g_bFrameStep = false;
g_bFrameStop = false;
g_frameSkipCounter = g_framesToSkip;
memset(&g_padState, 0, sizeof(g_padState));
for (int i = 0; i < 8; ++i)
g_InputDisplay[i].clear();
if (!IsPlayingInput() && !IsRecordingInput())
{
g_bRecordingFromSaveState = false;
g_rerecords = 0;
g_numPads = 0;
g_currentByte = 0;
g_currentFrame = 0;
g_currentLagCount = 0;
g_currentInputCount = 0;
// we don't clear these things because otherwise we can't resume playback if we load a movie state later
//g_totalFrames = g_totalBytes = 0;
//delete tmpInput;
//tmpInput = NULL;
}
}
void InputUpdate()
{
g_currentInputCount++;
@ -813,7 +841,7 @@ bool PlayWiimote(int wiimote, u8 *data, const WiimoteEmu::ReportFeatures& rptf,
if (size != sizeInMovie)
{
PanicAlertT("Fatal desync. Aborting playback. (Error in PlayWiimote: %u != %u, byte %d.)%s", sizeInMovie, size, g_currentByte, (g_numPads & 0xF)?" Try re-creating the recording with all GameCube controllers disabled.":"");
PanicAlertT("Fatal desync. Aborting playback. (Error in PlayWiimote: %u != %u, byte %u.)%s", (u32)sizeInMovie, (u32)size, (u32)g_currentByte, (g_numPads & 0xF)?" Try re-creating the recording with all GameCube controllers disabled (in Configure > Gamecube > Device Settings).":"");
EndPlayInput(!g_bReadOnly);
return false;
}

View File

@ -105,6 +105,7 @@ struct DTMHeader {
void FrameUpdate();
void InputUpdate();
void Init();
void SetPolledDevice();

View File

@ -80,6 +80,16 @@ namespace PowerPC
jit->GetBlockCache()->ClearSafe();
}
void InstructionCache::Init()
{
memset(data, 0, sizeof(data));
memset(tags, 0, sizeof(tags));
memset(way_from_valid, 0, sizeof(way_from_valid));
memset(way_from_plru, 0, sizeof(way_from_plru));
Reset();
}
void InstructionCache::Invalidate(u32 addr)
{
if (!HID0.ICE)

View File

@ -50,9 +50,10 @@ namespace PowerPC
#endif
InstructionCache();
void Reset();
u32 ReadInstruction(u32 addr);
void Invalidate(u32 addr);
void Init();
void Reset();
};
}

View File

@ -154,6 +154,17 @@ void Init(int cpu_core)
//but still - set any useful sse options here
#endif
memset(ppcState.mojs, 0, sizeof(ppcState.mojs));
memset(ppcState.sr, 0, sizeof(ppcState.sr));
ppcState.DebugCount = 0;
ppcState.dtlb_last = 0;
ppcState.dtlb_last = 0;
memset(ppcState.dtlb_va, 0, sizeof(ppcState.dtlb_va));
memset(ppcState.dtlb_pa, 0, sizeof(ppcState.dtlb_pa));
ppcState.itlb_last = 0;
memset(ppcState.itlb_va, 0, sizeof(ppcState.itlb_va));
memset(ppcState.itlb_pa, 0, sizeof(ppcState.itlb_pa));
ResetRegisters();
PPCTables::InitTables(cpu_core);
@ -197,7 +208,7 @@ void Init(int cpu_core)
}
state = CPU_STEPPING;
ppcState.iCache.Reset();
ppcState.iCache.Init();
}
void Shutdown()

View File

@ -109,6 +109,8 @@ void Init()
m_CPCtrlReg.Hex = 0;
m_CPClearReg.Hex = 0;
m_bboxleft = 0;
m_bboxtop = 0;
m_bboxright = 640;
@ -130,6 +132,11 @@ void Init()
interruptFinishWaiting = false;
interruptTokenWaiting = false;
bProcessFifoToLoWatermark = false;
bProcessFifoAllDistance = false;
isPossibleWaitingSetDrawDone = false;
OnOverflow = false;
et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
}

View File

@ -171,6 +171,18 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32
static volatile u32 s_doStateRequested = false;
void VideoBackendHardware::InitializeShared()
{
VideoCommon_Init();
s_swapRequested = 0;
s_efbAccessRequested = 0;
s_FifoShuttingDown = 0;
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
memset(&s_accessEFBArgs, 0, sizeof(s_accessEFBArgs));
s_AccessEFBResult = 0;
}
static volatile struct
{
unsigned char **ptr;

View File

@ -155,6 +155,16 @@ void SetFinish_OnMainThread(u64 userdata, int cyclesLate);
void Init()
{
m_Control.Hex = 0;
m_ZConf.Hex = 0;
m_AlphaConf.Hex = 0;
m_DstAlphaConf.Hex = 0;
m_AlphaModeConf.Hex = 0;
m_AlphaRead.Hex = 0;
g_bSignalTokenInterrupt = false;
g_bSignalFinishInterrupt = false;
interruptSetToken = false;
interruptSetFinish = false;
et_SetTokenOnMainThread = CoreTiming::RegisterEvent("SetToken", SetToken_OnMainThread);
et_SetFinishOnMainThread = CoreTiming::RegisterEvent("SetFinish", SetFinish_OnMainThread);

View File

@ -150,6 +150,12 @@ void VertexShaderManager::Init()
memset(&xfregs, 0, sizeof(xfregs));
memset(xfmem, 0, sizeof(xfmem));
ResetView();
// TODO: should these go inside ResetView()?
Matrix44::LoadIdentity(s_viewportCorrection);
memset(g_fProjectionMatrix, 0, sizeof(g_fProjectionMatrix));
for (int i = 0; i < 4; ++i)
g_fProjectionMatrix[i*5] = 1.0f;
}
void VertexShaderManager::Shutdown()

View File

@ -60,3 +60,14 @@ void VideoCommon_RunLoop(bool enable)
{
EmulatorState(enable);
}
void VideoCommon_Init()
{
memset(arraybases, 0, sizeof(arraybases));
memset(arraystrides, 0, sizeof(arraystrides));
memset(&MatrixIndexA, 0, sizeof(MatrixIndexA));
memset(&MatrixIndexB, 0, sizeof(MatrixIndexB));
memset(&g_VtxDesc, 0, sizeof(g_VtxDesc));
memset(g_VtxAttr, 0, sizeof(g_VtxAttr));
memset(texMem, 0, TMEM_SIZE);
}

View File

@ -23,5 +23,6 @@
void VideoCommon_DoState(PointerWrap &p);
void VideoCommon_RunLoop(bool enable);
void VideoCommon_Init();
#endif // _VIDEOSTATE_H

View File

@ -150,6 +150,7 @@ void VideoBackend::ShowConfig(void *_hParent)
bool VideoBackend::Initialize(void *&window_handle)
{
InitializeShared();
InitBackendInfo();
frameCount = 0;

View File

@ -132,6 +132,7 @@ void VideoBackend::ShowConfig(void* parent)
bool VideoBackend::Initialize(void *&window_handle)
{
InitializeShared();
InitBackendInfo();
frameCount = 0;

View File

@ -155,6 +155,7 @@ void VideoBackend::ShowConfig(void *_hParent)
bool VideoBackend::Initialize(void *&window_handle)
{
InitializeShared();
InitBackendInfo();
frameCount = 0;