mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
77a8480363
Prefer the ISO9660 boot file over the bounded raw-image scan. Biohazard stores SYSTEM.CNF outside that scan, leaving fresh builds at the default SCEA response. Add raw and cooked late-file regressions with an early decoy serial. The full-profile prefix again matches the retained native baseline through 5999 returns; the independent-source frontier remains return 464.
(cherry picked from commit 82c3de13ef)
51 lines
2.2 KiB
C++
51 lines
2.2 KiB
C++
// SYSTEM.CNF beyond 16 MiB wins over unrelated early cdrom: strings.
|
|
#include "disc_identity.h"
|
|
#include <cassert>
|
|
#include <chrono>
|
|
#include <cstring>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <vector>
|
|
|
|
namespace fs=std::filesystem;
|
|
static void both32(uint8_t* p,uint32_t value) {
|
|
for(unsigned i=0;i<4;i++) {p[i]=(uint8_t)(value>>(8*i));p[7-i]=p[i];}
|
|
}
|
|
static void fixture(const fs::path& path,bool raw) {
|
|
const unsigned unit=raw?2352:2048,offset=raw?24:0;
|
|
std::ofstream file(path,std::ios::binary);
|
|
file.seekp(10000ull*unit-1);file.put(0);
|
|
if(raw) {
|
|
uint8_t sync[16]={};std::memset(sync+1,255,10);sync[15]=2;
|
|
file.seekp(0);file.write((char*)sync,sizeof sync);
|
|
}
|
|
auto write=[&](unsigned lba,const std::vector<uint8_t>& data) {
|
|
file.seekp((uint64_t)lba*unit+offset);
|
|
file.write((const char*)data.data(),data.size());
|
|
};
|
|
std::vector<uint8_t> pvd(2048);
|
|
pvd[0]=1;std::memcpy(pvd.data()+1,"CD001",5);pvd[6]=1;
|
|
auto* root=pvd.data()+156;root[0]=34;both32(root+2,20);both32(root+10,2048);
|
|
root[25]=2;root[28]=root[31]=root[32]=1;
|
|
write(16,pvd);
|
|
const std::string cnf="BOOT = cdrom:SLPS_009.98;1\r\n";
|
|
std::vector<uint8_t> directory(2048);
|
|
directory[0]=46;both32(directory.data()+2,9000);both32(directory.data()+10,(uint32_t)cnf.size());
|
|
directory[28]=directory[31]=1;directory[32]=12;
|
|
std::memcpy(directory.data()+33,"SYSTEM.CNF;1",12);write(20,directory);
|
|
write(9000,std::vector<uint8_t>(cnf.begin(),cnf.end()));
|
|
const std::string decoy="BOOT = cdrom:SLUS_999.99;1\r\n";
|
|
write(40,std::vector<uint8_t>(decoy.begin(),decoy.end()));
|
|
}
|
|
int main() {
|
|
auto root=fs::temp_directory_path()/ ("psx-disc-identity-"+std::to_string(
|
|
std::chrono::steady_clock::now().time_since_epoch().count()));
|
|
fs::create_directory(root);
|
|
for(bool raw:{false,true}) {
|
|
auto image=root/(raw?"disc.bin":"disc.iso");fixture(image,raw);
|
|
auto id=PSXRecompV4::identify_disc(image,"",0,false,false);
|
|
assert(id.opened && id.has_header && id.detected_serial=="SLPS-00998" && id.region=="NTSC-J");
|
|
}
|
|
fs::remove(root/"disc.iso");fs::remove(root/"disc.bin");fs::remove(root);
|
|
}
|