#pragma once #include #include #include #include #include "../Common/Json.h" namespace DVD { class MountDolphinSdk { bool mounted = false; uint32_t currentSeek = 0; TCHAR directory[0x1000] = { 0 }; Json DvdDataInfo; const TCHAR* DvdDataJson = _T("Data\\Json\\DolphinSdkDvdData.json"); const TCHAR* AppldrPath = _T("/HW2/boot/apploader.img"); const TCHAR* Bi2Path = _T("/X86/bin/bi2.bin"); const TCHAR* FilesRoot = _T("/dvddata"); const TCHAR* DolPath = _T("pong.dol"); // SDK contains demos only in ELF format :/ std::vector DiskId; std::vector GameName; std::vector AppldrData; std::vector Dol; std::vector Bb2Data; std::vector Bi2Data; std::vector FstData; std::vector NameTableData; uint32_t userFilesStart = 16 * 1024 * 1024; uint32_t userFilesOffset = 0; int entryCounter = 0; bool GenDiskId(); bool GenApploader(); bool GenDol(); bool GenBi2(); bool GenBb2(); void AddString(std::string str); void ParseDvdDataEntryForFst(Json::Value* entry); void WalkAndGenerateFst(Json::Value* entry); bool GenFst(); std::list &, uint32_t, size_t>> mapping; std::list> fileMapping; bool GenMap(); void WalkAndMapFiles(Json::Value* entry); bool GenFileMap(); void MapVector(std::vector& v, uint32_t offset); void MapFile(TCHAR *path, uint32_t offset); uint8_t* TranslateMemory(uint32_t offset, size_t requestedSize, size_t& maxSize); FILE* TranslateFile(uint32_t offset, size_t requestedSize, size_t& maxSize); uint32_t RoundUp32(uint32_t offset) { return (offset + 31) & ~0x1f; } uint32_t RoundUpSector(uint32_t offset) { return (offset + (DVD_SECTOR_SIZE - 1)) & ~(DVD_SECTOR_SIZE - 1); } void SwapArea(void* _addr, int sizeInBytes); public: MountDolphinSdk(const TCHAR* DolphinSDKPath); ~MountDolphinSdk(); bool Mounted() { return mounted; } void Seek(int position); bool Read(void* buffer, size_t length); int GetSeek() { return currentSeek; } TCHAR* GetDirectory() { return directory; } }; }