MCPcopy Create free account
hub / github.com/clementgallet/libTAS / queuePageLoad

Method queuePageLoad

src/library/checkpoint/SaveStateLoading.cpp:221–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void SaveStateLoading::queuePageLoad(char* addr)
222{
223 // MYASSERT(addr + 4096 == current_addr);
224
225 if (current_flag == Area::FULL_PAGE) {
226 if (queued_size > 0) {
227 if ((next_pfd_offset - 4096) == queued_offset + queued_size &&
228 addr == queued_addr + queued_size) {
229 queued_size += 4096;
230 return;
231 } else {
232 lseek(pfd, queued_offset, SEEK_SET);
233 Utils::readAll(pfd, queued_addr, queued_size);
234 }
235 }
236 queued_offset = (next_pfd_offset - 4096);
237 queued_addr = addr;
238 queued_size = 4096;
239 }
240 else if (current_flag == Area::COMPRESSED_PAGE) {
241 char compressed[LZ4_COMPRESSBOUND(4096)];
242 if (!validateCompressedLength()) {
243 memset(addr, 0, 4096);
244 return;
245 }
246 Utils::readAll(pfd, compressed, compressed_length);
247
248 if (Global::shared_config.savestate_settings & SharedConfig::SS_INCREMENTAL) {
249 /* For incremental savestates, block compression is independant */
250 int ret = LZ4_decompress_safe(compressed, addr, compressed_length, 4096);
251 if (ret != 4096) {
252 LOG(LL_ERROR, LCF_CHECKPOINT, "LZ4_decompress_safe failed with return code %d", ret);
253 memset(addr, 0, 4096);
254 }
255 }
256 else {
257 int ret = LZ4_decompress_safe_continue(&lz4s, compressed, addr, compressed_length, 4096);
258 if (ret != 4096) {
259 LOG(LL_ERROR, LCF_CHECKPOINT, "LZ4_decompress_safe_continue failed with return code %d", ret);
260 memset(addr, 0, 4096);
261 }
262 }
263 }
264}
265
266bool SaveStateLoading::debugIsMatchingPage(char* addr)
267{

Callers 2

readAnAreaFunction · 0.80
readASavefileFunction · 0.80

Calls 2

LZ4_decompress_safeFunction · 0.85

Tested by

no test coverage detected