Ejemplo n.º 1
0
void MetaFileSystem::DoState(PointerWrap &p)
{
	std::lock_guard<std::recursive_mutex> guard(lock);
	
	auto s = p.Section("MetaFileSystem", 1);
	if (!s)
		return;

	p.Do(current);

	// Save/load per-thread current directory map
	p.Do(currentDir);

	u32 n = (u32) fileSystems.size();
	p.Do(n);
	if (n != (u32) fileSystems.size())
	{
		p.SetError(p.ERROR_FAILURE);
		ERROR_LOG(FILESYS, "Savestate failure: number of filesystems doesn't match.");
		return;
	}

	for (u32 i = 0; i < n; ++i)
		fileSystems[i].system->DoState(p);
}
Ejemplo n.º 2
0
void __AudioDoState(PointerWrap &p) {
	auto s = p.Section("sceAudio", 1);
	if (!s)
		return;

	p.Do(eventAudioUpdate);
	CoreTiming::RestoreRegisterEvent(eventAudioUpdate, "AudioUpdate", &hleAudioUpdate);
	p.Do(eventHostAudioUpdate);
	CoreTiming::RestoreRegisterEvent(eventHostAudioUpdate, "AudioUpdateHost", &hleHostAudioUpdate);

	p.Do(mixFrequency);

	{
		lock_guard guard(section);
		outAudioQueue.DoState(p);
	}

	int chanCount = ARRAY_SIZE(chans);
	p.Do(chanCount);
	if (chanCount != ARRAY_SIZE(chans))
	{
		ERROR_LOG(SCEAUDIO, "Savestate failure: different number of audio channels.");
		return;
	}
	for (int i = 0; i < chanCount; ++i)
		chans[i].DoState(p);
}
Ejemplo n.º 3
0
void DoState(PointerWrap &p)
{
	auto s = p.Section("Memory", 1, 2);
	if (!s)
		return;

	if (s < 2) {
		if (!g_RemasterMode)
			g_MemorySize = RAM_NORMAL_SIZE;
		g_PSPModel = PSP_MODEL_FAT;
	} else {
		u32 oldMemorySize = g_MemorySize;
		p.Do(g_PSPModel);
		p.DoMarker("PSPModel");
		if (!g_RemasterMode) {
			g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE;
			if (oldMemorySize < g_MemorySize) {
				Shutdown();
				Init();
			}
		}
	}

	p.DoArray(GetPointer(PSP_GetKernelMemoryBase()), g_MemorySize);
	p.DoMarker("RAM");

	p.DoArray(m_pVRAM, VRAM_SIZE);
	p.DoMarker("VRAM");
	p.DoArray(m_pScratchPad, SCRATCHPAD_SIZE);
	p.DoMarker("ScratchPad");
}
Ejemplo n.º 4
0
	void SaveStart::DoState(PointerWrap &p)
	{
		auto s = p.Section("SaveStart", 1);
		if (!s)
			return;

		// Gotta do CoreTiming first since we'll restore into it.
		CoreTiming::DoState(p);

		// Memory is a bit tricky when jit is enabled, since there's emuhacks in it.
		if (MIPSComp::jit && p.mode == p.MODE_WRITE)
		{
			auto blocks = MIPSComp::jit->GetBlockCache();
			auto saved = blocks->SaveAndClearEmuHackOps();
			Memory::DoState(p);
			blocks->RestoreSavedEmuHackOps(saved);
		}
		else
			Memory::DoState(p);

		MemoryStick_DoState(p);
		currentMIPS->DoState(p);
		HLEDoState(p);
		__KernelDoState(p);
		// Kernel object destructors might close open files, so do the filesystem last.
		pspFileSystem.DoState(p);
	}
Ejemplo n.º 5
0
void DoState(PointerWrap &p)
{
	std::lock_guard<std::recursive_mutex> lk(externalEventSection);

	auto s = p.Section("CoreTiming", 1, 2);
	if (!s)
		return;

	int n = (int) event_types.size();
	p.Do(n);
	// These (should) be filled in later by the modules.
	event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT"));

	p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **) NULL);
	p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast);

	p.Do(CPU_HZ);
	p.Do(slicelength);
	p.Do(globalTimer);
	p.Do(idledCycles);

	if (s >= 2) {
		p.Do(lastGlobalTimeTicks);
		p.Do(lastGlobalTimeUs);
	} else {
		lastGlobalTimeTicks = 0;
		lastGlobalTimeUs = 0;
	}
}
Ejemplo n.º 6
0
void PSPSaveDialog::DoState(PointerWrap &p) {
	JoinIOThread();
	PSPDialog::DoState(p);

	auto s = p.Section("PSPSaveDialog", 1, 2);
	if (!s) {
		return;
	}

	p.Do(display);
	param.DoState(p);
	p.Do(request);
	// Just reset it.
	bool hasParam = param.GetPspParam() != NULL;
	p.Do(hasParam);
	if (hasParam) {
		param.SetPspParam(&request);
	}
	p.Do(requestAddr);
	p.Do(currentSelectedSave);
	p.Do(yesnoChoice);
	if (s > 2) {
		p.Do(ioThreadStatus);
	} else {
		ioThreadStatus = SAVEIO_NONE;
	}
}
Ejemplo n.º 7
0
void SavedataParam::DoState(PointerWrap &p)
{
	auto s = p.Section("SavedataParam", 1);
	if (!s)
		return;

	// pspParam is handled in PSPSaveDialog.
	p.Do(selectedSave);
	p.Do(saveDataListCount);
	p.Do(saveNameListDataCount);
	if (p.mode == p.MODE_READ)
	{
		if (saveDataList != NULL)
			delete [] saveDataList;
		if (saveDataListCount != 0)
		{
			saveDataList = new SaveFileInfo[saveDataListCount];
			p.DoArray(saveDataList, saveDataListCount);
		}
		else
			saveDataList = NULL;
	}
	else
		p.DoArray(saveDataList, saveDataListCount);
}
Ejemplo n.º 8
0
void PsmfPlayer::DoState(PointerWrap &p) {
	auto s = p.Section("PsmfPlayer", 1);
	if (!s)
		return;

	p.Do(videoCodec);
	p.Do(videoStreamNum);
	p.Do(audioCodec);
	p.Do(audioStreamNum);
	p.Do(playMode);
	p.Do(playSpeed);

	p.Do(displayBuffer);
	p.Do(displayBufferSize);
	p.Do(playbackThreadPriority);
	p.Do(psmfMaxAheadTimestamp);
	p.Do(psmfPlayerLastTimestamp);
	p.DoClass(mediaengine);
	p.Do(filehandle);
	p.Do(fileoffset);
	p.Do(readSize);
	p.Do(streamSize);

	p.Do(status);
	p.Do(psmfPlayerAvcAu);
}
Ejemplo n.º 9
0
void Psmf::DoState(PointerWrap &p) {
	auto s = p.Section("Psmf", 1);
	if (!s)
		return;

	p.Do(magic);
	p.Do(version);
	p.Do(streamOffset);
	p.Do(streamSize);
	p.Do(headerOffset);
	p.Do(streamDataTotalSize);
	p.Do(presentationStartTime);
	p.Do(presentationEndTime);
	p.Do(streamDataNextBlockSize);
	p.Do(streamDataNextInnerBlockSize);
	p.Do(numStreams);

	p.Do(currentStreamNum);
	p.Do(currentAudioStreamNum);
	p.Do(currentVideoStreamNum);

	p.Do(EPMapOffset);
	p.Do(EPMapEntriesNum);
	p.Do(videoWidth);
	p.Do(videoHeight);
	p.Do(audioChannels);
	p.Do(audioFrequency);

	p.Do(streamMap);
}
Ejemplo n.º 10
0
void __CtrlDoState(PointerWrap &p)
{
    std::lock_guard<std::recursive_mutex> guard(ctrlMutex);

    auto s = p.Section("sceCtrl", 1);
    if (!s)
        return;

    p.Do(analogEnabled);
    p.Do(ctrlLatchBufs);
    p.Do(ctrlOldButtons);

    p.DoVoid(ctrlBufs, sizeof(ctrlBufs));
    p.Do(ctrlCurrent);
    p.Do(ctrlBuf);
    p.Do(ctrlBufRead);
    p.Do(latch);

    p.Do(ctrlIdleReset);
    p.Do(ctrlIdleBack);

    p.Do(ctrlCycle);

    SceUID dv = 0;
    p.Do(waitingThreads, dv);

    p.Do(ctrlTimer);
    CoreTiming::RestoreRegisterEvent(ctrlTimer, "CtrlSampleTimer", __CtrlTimerUpdate);
}
Ejemplo n.º 11
0
void MediaEngine::DoState(PointerWrap &p){
	auto s = p.Section("MediaEngine", 1);
	if (!s)
		return;

	p.Do(m_videoStream);
	p.Do(m_audioStream);

	p.DoArray(m_mpegheader, sizeof(m_mpegheader));

	p.Do(m_ringbuffersize);

	u32 hasloadStream = m_pdata != NULL;
	p.Do(hasloadStream);
	if (hasloadStream && p.mode == p.MODE_READ)
		loadStream(m_mpegheader, 2048, m_ringbuffersize);
#ifdef USE_FFMPEG
	u32 hasopencontext = m_pFormatCtx != NULL;
#else
	u32 hasopencontext = false;
#endif
	p.Do(hasopencontext);
	if (hasopencontext && p.mode == p.MODE_READ)
		openContext();
	if (m_pdata)
		m_pdata->DoState(p);
	if (m_demux)
		m_demux->DoState(p);

	p.Do(m_videopts);
	p.Do(m_audiopts);

	p.Do(m_isVideoEnd);
	p.Do(m_noAudioData);
}
Ejemplo n.º 12
0
	void DoState(PointerWrap &p) {
	auto s = p.Section("PostPutAction", 1);
	if (!s)
		return;

		p.Do(ringAddr_);
	}
Ejemplo n.º 13
0
void __UtilityDoState(PointerWrap &p) {
	auto s = p.Section("sceUtility", 1, 2);
	if (!s) {
		return;
	}

	p.Do(currentDialogType);
	p.Do(currentDialogActive);
	saveDialog.DoState(p);
	msgDialog.DoState(p);
	oskDialog.DoState(p);
	netDialog.DoState(p);
	screenshotDialog.DoState(p);
	gamedataInstallDialog.DoState(p);

	if (s >= 2) {
		p.Do(currentlyLoadedModules);
	} else {
		std::set<int> oldModules;
		p.Do(oldModules);
		for (auto it = oldModules.begin(), end = oldModules.end(); it != end; ++it) {
			currentlyLoadedModules[*it] = 0;
		}
	}
}
Ejemplo n.º 14
0
	void DoState(PointerWrap &p) {
		auto s = p.Section("MpegContext", 1);
		if (!s)
			return;

		p.DoArray(mpegheader, 2048);
		p.Do(defaultFrameWidth);
		p.Do(videoFrameCount);
		p.Do(audioFrameCount);
		p.Do(endOfAudioReached);
		p.Do(endOfVideoReached);
		p.Do(videoPixelMode);
		p.Do(mpegMagic);
		p.Do(mpegVersion);
		p.Do(mpegRawVersion);
		p.Do(mpegOffset);
		p.Do(mpegStreamSize);
		p.Do(mpegFirstTimestamp);
		p.Do(mpegLastTimestamp);
		p.Do(mpegFirstDate);
		p.Do(mpegLastDate);
		p.Do(mpegRingbufferAddr);
		p.DoArray(esBuffers, NUM_ES_BUFFERS);
		p.Do(avc);
		p.Do(avcRegistered);
		p.Do(atracRegistered);
		p.Do(pcmRegistered);
		p.Do(dataRegistered);
		p.Do(ignoreAtrac);
		p.Do(ignorePcm);
		p.Do(ignoreAvc);
		p.Do(isAnalyzed);
		p.Do<u32, StreamInfo>(streamMap);
		p.DoClass(mediaengine);
	}
Ejemplo n.º 15
0
void __AACDoState(PointerWrap &p) {
	auto s = p.Section("sceAAC", 0, 1);
	if (!s)
		return;

	p.Do(aacMap);
}
Ejemplo n.º 16
0
void AuCtx::DoState(PointerWrap &p) {
	auto s = p.Section("AuContext", 0, 1);
	if (!s)
		return;

	p.Do(startPos);
	p.Do(endPos);
	p.Do(AuBuf);
	p.Do(AuBufSize);
	p.Do(PCMBuf);
	p.Do(PCMBufSize);
	p.Do(freq);
	p.Do(SumDecodedSamples);
	p.Do(LoopNum);
	p.Do(Channels);
	p.Do(MaxOutputSample);
	p.Do(readPos);
	p.Do(audioType);
	p.Do(BitRate);
	p.Do(SamplingRate);
	p.Do(askedReadSize);
	int dummy = 0;
	p.Do(dummy);
	p.Do(FrameNum);

	if (p.mode == p.MODE_READ) {
		decoder = new SimpleAudio(audioType);
		AuBufAvailable = 0; // reset to read from file at position readPos
	}
}
Ejemplo n.º 17
0
void __VaudioDoState(PointerWrap &p) {
	auto s = p.Section("sceVaudio", 1);
	if (!s)
		return;

	p.Do(vaudioReserved);
}
Ejemplo n.º 18
0
void MetaFileSystem::DoState(PointerWrap &p)
{
	lock_guard guard(lock);
	
	auto s = p.Section("MetaFileSystem", 1);
	if (!s)
		return;

	p.Do(current);

	// Save/load per-thread current directory map
	p.Do(currentDir);

	u32 n = (u32) fileSystems.size();
	p.Do(n);
	bool skipPfat0 = false;
	if (n != (u32) fileSystems.size())
	{
		if (n == (u32) fileSystems.size() - 1) {
			skipPfat0 = true;
		} else {
			p.SetError(p.ERROR_FAILURE);
			ERROR_LOG(FILESYS, "Savestate failure: number of filesystems doesn't match.");
			return;
		}
	}

	for (u32 i = 0; i < n; ++i) {
		if (!skipPfat0 || fileSystems[i].prefix != "pfat0:") {
			fileSystems[i].system->DoState(p);
		}
	}
}
Ejemplo n.º 19
0
void __AudioDoState(PointerWrap &p) {
	auto s = p.Section("sceAudio", 1);
	if (!s)
		return;

	p.Do(eventAudioUpdate);
	CoreTiming::RestoreRegisterEvent(eventAudioUpdate, "AudioUpdate", &hleAudioUpdate);
	p.Do(eventHostAudioUpdate);
	CoreTiming::RestoreRegisterEvent(eventHostAudioUpdate, "AudioUpdateHost", &hleHostAudioUpdate);

	p.Do(mixFrequency);

	if (s >= 2) {
		resampler.DoState(p);
	} else {
		// Only to preserve the previous file format. Might cause a slight audio glitch on upgrades?
		FixedSizeQueue<s16, 512 * 16> outAudioQueue;
		outAudioQueue.DoState(p);

		resampler.Clear();
	}

	int chanCount = ARRAY_SIZE(chans);
	p.Do(chanCount);
	if (chanCount != ARRAY_SIZE(chans))
	{
		ERROR_LOG(SCEAUDIO, "Savestate failure: different number of audio channels.");
		return;
	}
	for (int i = 0; i < chanCount; ++i)
		chans[i].DoState(p);

	__AudioCPUMHzChange();
}
Ejemplo n.º 20
0
void ISOFileSystem::DoState(PointerWrap &p)
{
	auto s = p.Section("ISOFileSystem", 1);
	if (!s)
		return;

	int n = (int) entries.size();
	p.Do(n);

	if (p.mode == p.MODE_READ)
	{
		entries.clear();
		for (int i = 0; i < n; ++i)
		{
			u32 fd = 0;
			OpenFileEntry of;

			p.Do(fd);
			p.Do(of.seekPos);
			p.Do(of.isRawSector);
			p.Do(of.isBlockSectorMode);
			p.Do(of.sectorStart);
			p.Do(of.openSize);

			bool hasFile = false;
			p.Do(hasFile);
			if (hasFile) {
				std::string path;
				p.Do(path);
				of.file = GetFromPath(path);
			} else {
				of.file = NULL;
			}

			entries[fd] = of;
		}
	}
	else
	{
		for (EntryMap::iterator it = entries.begin(), end = entries.end(); it != end; ++it)
		{
			OpenFileEntry &of = it->second;
			p.Do(it->first);
			p.Do(of.seekPos);
			p.Do(of.isRawSector);
			p.Do(of.isBlockSectorMode);
			p.Do(of.sectorStart);
			p.Do(of.openSize);

			bool hasFile = of.file != NULL;
			p.Do(hasFile);
			if (hasFile) {
				std::string path = "";
				path = EntryFullPath(of.file);
				p.Do(path);
			}
		}
	}
}
Ejemplo n.º 21
0
	void DoState(PointerWrap &p) {
		auto s = p.Section("PsmfStream", 1);
		if (!s)
			return;

		p.Do(type);
		p.Do(channel);
	}
Ejemplo n.º 22
0
	void DoState(PointerWrap &p) {
		auto s = p.Section("WaitVBlankInfo", 1);
		if (!s)
			return;

		p.Do(threadID);
		p.Do(vcountUnblock);
	}
Ejemplo n.º 23
0
	void DoState(PointerWrap &p)
	{
		auto s = p.Section("InterruptState", 1);
		if (!s)
			return;

		p.Do(savedCpu);
	}
Ejemplo n.º 24
0
void __PsmfDoState(PointerWrap &p)
{
	auto s = p.Section("scePsmf", 1);
	if (!s)
		return;

	p.Do(psmfMap);
}
Ejemplo n.º 25
0
void __JpegDoState(PointerWrap &p) {
	auto s = p.Section("sceJpeg", 1);
	if (!s)
		return;

	p.Do(mjpegWidth);
	p.Do(mjpegHeight);
}
Ejemplo n.º 26
0
	virtual void DoState(PointerWrap &p)
	{
		auto s = p.Section("Alarm", 1);
		if (!s)
			return;

		p.Do(alm);
	}
Ejemplo n.º 27
0
void __KernelTimeDoState(PointerWrap &p)
{
	auto s = p.Section("sceKernelTime", 1);
	if (!s)
		return;

	p.Do(start_time);
}
Ejemplo n.º 28
0
void Jit::DoState(PointerWrap &p)
{
	auto s = p.Section("Jit", 1);
	if (!s)
		return;

	p.Do(js.startDefaultPrefix);
}
Ejemplo n.º 29
0
void __UsbDoState(PointerWrap &p)
{
	auto s = p.Section("sceUsb", 1);
	if (!s)
		return;

	p.Do(usbActivated);
}
Ejemplo n.º 30
0
void GPUStateCache::DoState(PointerWrap &p) {
	auto s = p.Section("GPUStateCache", 0, 2);
	if (!s) {
		// Old state, this was not versioned.
		GPUStateCache_v0 old;
		p.Do(old);

		vertexAddr = old.vertexAddr;
		indexAddr = old.indexAddr;
		offsetAddr = old.offsetAddr;
		textureChanged = TEXCHANGE_UPDATED;
		textureFullAlpha = old.textureFullAlpha;
		vertexFullAlpha = old.vertexFullAlpha;
		framebufChanged = old.framebufChanged;
		skipDrawReason = old.skipDrawReason;
		uv = old.uv;
		flipTexture = old.flipTexture;
	} else {
		p.Do(vertexAddr);
		p.Do(indexAddr);
		p.Do(offsetAddr);

		p.Do(textureChanged);
		p.Do(textureFullAlpha);
		p.Do(vertexFullAlpha);
		p.Do(framebufChanged);

		p.Do(skipDrawReason);

		p.Do(uv);
		p.Do(flipTexture);
	}

	if (s < 2) {
		float l12[12];
		float l4[4];
		p.Do(l12);  // lightpos
		p.Do(l12);  // lightdir
		p.Do(l12);  // lightattr
		p.Do(l12);  // lightcol0
		p.Do(l12);  // lightcol1
		p.Do(l12);  // lightcol2
		p.Do(l4);    // lightangle
		p.Do(l4);  // lightspot
	}

	p.Do(morphWeights);

	p.Do(curTextureWidth);
	p.Do(curTextureHeight);
	p.Do(actualTextureHeight);

	p.Do(vpWidth);
	p.Do(vpHeight);

	p.Do(curRTWidth);
	p.Do(curRTHeight);
}