void GetNextBlock(File::IOFile& in, u8* buffer) { u64 CurrentOffset = m_BlockCount * m_BlockSize; u64 i = CurrentOffset / CLUSTER_SIZE; if (m_isScrubbing && m_FreeTable[i]) { DEBUG_LOG(DISCIO, "Freeing 0x%016llx", CurrentOffset); std::fill(buffer, buffer + m_BlockSize, 0xFF); in.Seek(m_BlockSize, SEEK_CUR); } else { DEBUG_LOG(DISCIO, "Used 0x%016llx", CurrentOffset); in.ReadBytes(buffer, m_BlockSize); } m_BlockCount++; }
BootExecutableReader::BootExecutableReader(File::IOFile file) { file.Seek(0, SEEK_SET); m_bytes.resize(file.GetSize()); file.ReadBytes(m_bytes.data(), m_bytes.size()); }
std::unique_ptr<FifoDataFile> FifoDataFile::Load(const std::string& filename, bool flagsOnly) { File::IOFile file; file.Open(filename, "rb"); if (!file) return nullptr; FileHeader header; file.ReadBytes(&header, sizeof(header)); if (header.fileId != FILE_ID || header.min_loader_version > VERSION_NUMBER) { file.Close(); return nullptr; } auto dataFile = std::make_unique<FifoDataFile>(); dataFile->m_Flags = header.flags; dataFile->m_Version = header.file_version; if (flagsOnly) { file.Close(); return dataFile; } u32 size = std::min<u32>(BP_MEM_SIZE, header.bpMemSize); file.Seek(header.bpMemOffset, SEEK_SET); file.ReadArray(dataFile->m_BPMem, size); size = std::min<u32>(CP_MEM_SIZE, header.cpMemSize); file.Seek(header.cpMemOffset, SEEK_SET); file.ReadArray(dataFile->m_CPMem, size); size = std::min<u32>(XF_MEM_SIZE, header.xfMemSize); file.Seek(header.xfMemOffset, SEEK_SET); file.ReadArray(dataFile->m_XFMem, size); size = std::min<u32>(XF_REGS_SIZE, header.xfRegsSize); file.Seek(header.xfRegsOffset, SEEK_SET); file.ReadArray(dataFile->m_XFRegs, size); // Texture memory saving was added in version 4. std::memset(dataFile->m_TexMem, 0, TEX_MEM_SIZE); if (dataFile->m_Version >= 4) { size = std::min<u32>(TEX_MEM_SIZE, header.texMemSize); file.Seek(header.texMemOffset, SEEK_SET); file.ReadArray(dataFile->m_TexMem, size); } // Read frames for (u32 i = 0; i < header.frameCount; ++i) { u64 frameOffset = header.frameListOffset + (i * sizeof(FileFrameInfo)); file.Seek(frameOffset, SEEK_SET); FileFrameInfo srcFrame; file.ReadBytes(&srcFrame, sizeof(FileFrameInfo)); FifoFrameInfo dstFrame; dstFrame.fifoData.resize(srcFrame.fifoDataSize); dstFrame.fifoStart = srcFrame.fifoStart; dstFrame.fifoEnd = srcFrame.fifoEnd; file.Seek(srcFrame.fifoDataOffset, SEEK_SET); file.ReadBytes(dstFrame.fifoData.data(), srcFrame.fifoDataSize); ReadMemoryUpdates(srcFrame.memoryUpdatesOffset, srcFrame.numMemoryUpdates, dstFrame.memoryUpdates, file); dataFile->AddFrame(dstFrame); } file.Close(); return dataFile; }
int SyncTrace() { if (bWriteTrace) { tracefile.WriteBytes(&PowerPC::ppcState, stateSize); tracefile.Flush(); return 1; } if (bReadTrace) { PowerPC::PowerPCState state; if (!tracefile.ReadBytes(&state, stateSize)) return 1; bool difference = false; for (int i=0; i<32; i++) { if (PowerPC::ppcState.gpr[i] != state.gpr[i]) { DEBUG_LOG(POWERPC, "DIFFERENCE - r%i (local %08x, remote %08x)", i, PowerPC::ppcState.gpr[i], state.gpr[i]); difference = true; } } /* for (int i=0; i<32; i++) { for (int j=0; j<2; j++) { if (PowerPC::ppcState.ps[i][j] != state.ps[i][j]) { LOG(GEKKO, "DIFFERENCE - ps%i_%i (local %f, remote %f)", i, j, PowerPC::ppcState.ps[i][j], state.ps[i][j]); difference = true; } } }*/ /* if (GetCR() != state.cr) { LOG(GEKKO, "DIFFERENCE - CR (local %08x, remote %08x)", PowerPC::ppcState.cr, state.cr); difference = true; } if (PowerPC::ppcState.pc != state.pc) { LOG(GEKKO, "DIFFERENCE - PC (local %08x, remote %08x)", PowerPC::ppcState.pc, state.pc); difference = true; } if (PowerPC::ppcState.npc != state.npc) { LOG(GEKKO, "DIFFERENCE - NPC (local %08x, remote %08x)", PowerPC::ppcState.npc, state.npc); difference = true; } if (PowerPC::ppcState.msr != state.msr) { LOG(GEKKO, "DIFFERENCE - MSR (local %08x, remote %08x)", PowerPC::ppcState.msr, state.msr); difference = true; } if (PowerPC::ppcState.fpscr != state.fpscr) { LOG(GEKKO, "DIFFERENCE - FPSCR (local %08x, remote %08x)", PowerPC::ppcState.fpscr, state.fpscr); difference = true; } */ if (difference) { Host_UpdateLogDisplay(); //Also show drec compare window here //CDynaViewDlg::Show(true); //CDynaViewDlg::ViewAddr(m_BlockStart); //CDynaViewDlg::Show(true); //PanicAlert("Hang on"); //Sleep(INFINITE); return 0; } else { return 1; //LOG(GEKKO, "No difference!"); } } return 1; }
FifoDataFile *FifoDataFile::Load(const std::string &filename, bool flagsOnly) { File::IOFile file; file.Open(filename, "rb"); if (!file) return nullptr; FileHeader header; file.ReadBytes(&header, sizeof(header)); if (header.fileId != FILE_ID || header.min_loader_version > VERSION_NUMBER) { file.Close(); return nullptr; } FifoDataFile* dataFile = new FifoDataFile; dataFile->m_Flags = header.flags; if (flagsOnly) { file.Close(); return dataFile; } u32 size = std::min((u32)BP_MEM_SIZE, header.bpMemSize); file.Seek(header.bpMemOffset, SEEK_SET); file.ReadArray(dataFile->m_BPMem, size); size = std::min((u32)CP_MEM_SIZE, header.cpMemSize); file.Seek(header.cpMemOffset, SEEK_SET); file.ReadArray(dataFile->m_CPMem, size); size = std::min((u32)XF_MEM_SIZE, header.xfMemSize); file.Seek(header.xfMemOffset, SEEK_SET); file.ReadArray(dataFile->m_XFMem, size); size = std::min((u32)XF_REGS_SIZE, header.xfRegsSize); file.Seek(header.xfRegsOffset, SEEK_SET); file.ReadArray(dataFile->m_XFRegs, size); // Read frames for (u32 i = 0; i < header.frameCount; ++i) { u64 frameOffset = header.frameListOffset + (i * sizeof(FileFrameInfo)); file.Seek(frameOffset, SEEK_SET); FileFrameInfo srcFrame; file.ReadBytes(&srcFrame, sizeof(FileFrameInfo)); FifoFrameInfo dstFrame; dstFrame.fifoData = new u8[srcFrame.fifoDataSize]; dstFrame.fifoDataSize = srcFrame.fifoDataSize; dstFrame.fifoStart = srcFrame.fifoStart; dstFrame.fifoEnd = srcFrame.fifoEnd; file.Seek(srcFrame.fifoDataOffset, SEEK_SET); file.ReadBytes(dstFrame.fifoData, srcFrame.fifoDataSize); ReadMemoryUpdates(srcFrame.memoryUpdatesOffset, srcFrame.numMemoryUpdates, dstFrame.memoryUpdates, file); dataFile->AddFrame(dstFrame); } file.Close(); return dataFile; }