mega-cd.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. struct MegaCD : CompactDisc {
  2. auto name() -> string override { return "Mega CD"; }
  3. auto manifestSector() const -> uint override { return 0; }
  4. auto manifest(vector<uint8_t> sector, string location) -> string override;
  5. };
  6. auto MegaCD::manifest(vector<uint8_t> sector, string location) -> string {
  7. if(memory::compare(sector.data(), "SEGADISCSYSTEM ", 16)) return {};
  8. vector<string> regions;
  9. string region = slice((const char*)(sector.data() + 0x1f0), 0, 16).trimRight(" ");
  10. if(!regions) {
  11. if(region == "JAPAN" ) regions.append("NTSC-J");
  12. if(region == "EUROPE") regions.append("PAL");
  13. }
  14. if(!regions) {
  15. if(region.find("J")) regions.append("NTSC-J");
  16. if(region.find("U")) regions.append("NTSC-U");
  17. if(region.find("E")) regions.append("PAL");
  18. if(region.find("W")) regions.append("NTSC-J", "NTSC-U", "PAL");
  19. }
  20. if(!regions && region.size() == 1) {
  21. uint8_t field = region.hex();
  22. if(field & 0x01) regions.append("NTSC-J");
  23. if(field & 0x04) regions.append("NTSC-U");
  24. if(field & 0x08) regions.append("PAL");
  25. }
  26. if(!regions) {
  27. regions.append("NTSC-J");
  28. }
  29. string s;
  30. s += "game\n";
  31. s +={" name: ", Media::name(location), "\n"};
  32. s +={" label: ", Media::name(location), "\n"};
  33. s +={" region: ", regions.merge(", "), "\n"};
  34. return s;
  35. }