#include #include //#define debugMod(module, str) {printf("i[%-10s] ", module); printf(str); printf("\n");} //#define debugMod1(module, str, v1) {printf("i[%-10s] ", module); printf(str, v1); printf("\n");} //#define debugMod2(module, str, v1, v2) {printf("i[%-10s] ", module); printf(str, v1, v2); printf("\n");} //#define debugMod3(module, str, v1, v2, v3) {printf("i[%-10s] ", module); printf(str, v1, v2, v3); printf("\n");} //#define debugMod4(module, str, v1, v2, v3, v4) {printf("i[%-10s] ", module); printf(str, v1, v2, v3, v4); printf("\n");} //#define debugMod5(module, str, v1, v2, v3, v4, v5) {printf("i[%-10s] ", module); printf(str, v1, v2, v3, v4, v5); printf("\n");} #define PLATFORM DESKTOP #include "../../Debug.h" #include "MBR.h" #include "fat32/FS.h" #include "AccessHelper.h" #include #include //class Simu { // FILE* f; //public: // Simu(const char* image) { // f = fopen(image, "rw"); // if (!f) {throw std::runtime_error("failed to open");} // } // uint32_t readSingleBlock(LBA512 addr, uint8_t* dst) { // Log::addInfo("SD", "read512(%d*512)", addr); // fseek(f, addr*512, SEEK_SET); // return fread(dst, 512, 1, f) * 512; // } // uint32_t writeSingleBlock(LBA512 addr, const uint8_t* src) { // Log::addInfo("SD", "write512(%d*512)", addr); // fseek(f, addr*512, SEEK_SET); // return fwrite(src, 512, 1, f) * 512; // } //}; class Simu { uint8_t* data; public: Simu(const char* image) { FILE* f = fopen(image, "rw"); if (!f) {throw std::runtime_error("failed to open");} fseek(f, 0L, SEEK_END); size_t size = ftell(f); fseek(f, 0L, SEEK_SET); data = (uint8_t*) malloc(size); fread(data, size, 1, f); fclose(f); } uint32_t readBlock(LBA512 addr, uint8_t* dst) { Log::addInfo("SD", "read512(%d*512)", addr); memcpy(dst, data+addr*512, 512); return 512; } uint32_t writeBlock(LBA512 addr, const uint8_t* src) { Log::addInfo("SD", "write512(%d*512)", addr); memcpy(data+addr*512, src, 512); return 512; } }; #include //#define logInfo(fmt, ...) std::string s = fmt::format(FMT_STRING(fmt), __VA_ARGS__); #include "/apps/ESP8266lib/data/formats/avi/Demuxer.h" int main(int argc, char** argv) { { // ffmpeg -i '/mnt/ssss/anime/Toaru Majutsu no Index/[Eclipse] Toaru Majutsu no Index - 07 (1280x720 h264) [0255D83A].mkv' -r 15 -ss 30 -vf scale=480x320 -c:v mjpeg -c:a mp3 -ar 44100 /tmp/ram/1.avi Simu simu("/tmp/ram/1.avi"); AccessHelper ah(simu); AVI::Demuxer demux(ah); bool valid = demux.isValid(); std::cout << valid << std::endl; return 0; } //logInfo("{:s}", "I am not a number") //std::string s = fmt::format(FMT_STRING("{:s}"), "I am not a number"); //std::string s = fmt::format(FMT_STRING("{:s}"), "I am not a number"); ::testing::InitGoogleTest(&argc, argv); ::testing::GTEST_FLAG(filter) = "*TestCreate*"; return RUN_ALL_TESTS(); // diff /tmp/ram/TETRIS.GB /apps/workspace/gbemu/tests/tetris.gb Simu simu("/tmp/ram/1.dat"); AccessHelper ah(simu); MBR> mbr(ah); if (mbr.isPresent() && mbr.isValid()) { for (int i = 0; i < 4; ++i) { std::cout << (int) mbr.getPartition(i).getType() << " - " << mbr.getPartition(i).getFirstSector() << " - " << mbr.getPartition(i).getNumSectors() << std::endl; } using FAT32FS = FAT32::FS>; FAT32FS fat(ah, mbr.getPartition(0).getFirstSector() * 512); FAT32FS::DirIterator dir = fat.getRoot(); while(false) { FAT32::DirHandle h = dir.nextUsable(); if (!h.isValid()) {break;} if (1==0) { FAT32FS::File f = fat.open(h); if (1==0) { uint8_t* bufff = (uint8_t*) malloc(1024*1024); uint32_t read = f.read(f.getSize(), bufff); std::string name = f.getName(); std::ofstream out("/tmp/ram/" + name); out.write((char*)bufff, read); out.close(); free(bufff); break; } } } // //FAT32::DirEntryAt root = fat.getRoot().cur(); // FAT32FS::File file = fat.getOrCreateFile("tmp1.txt"); // uint8_t src[128]; // file.write(128, src); // diff /tmp/ram/TETRIS.GB /apps/workspace/gbemu/tests/tetris.gb // diff /tmp/ram/KIRBY1.GB /apps/workspace/gbemu/tests/Kirby\'s\ Dream\ Land\ \(USA\,\ Europe\).gb } }