CDVD/BIOS/NVM: When creating a blank NVM file, write a dummy value to the ILink area. This is read by Age of Empires 2 and fails to load if it doesn't exist.

This should work with all BIOS versions, please make sure you delete your NVM first then run the emulator to generate it.  Of course if you have an NVM file from your PS2, you shouldn't need this :)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5722 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
refraction@gmail.com 2013-08-19 21:13:21 +00:00
parent 690432de30
commit cc13ac321d
1 changed files with 20 additions and 13 deletions

View File

@ -118,6 +118,18 @@ static void cdvdGetMechaVer(u8* ver)
fclose(fd);
}
NVMLayout* getNvmLayout()
{
NVMLayout* nvmLayout = NULL;
if(nvmlayouts[1].biosVer <= BiosVersion)
nvmLayout = &nvmlayouts[1];
else
nvmLayout = &nvmlayouts[0];
return nvmLayout;
}
// Throws Exception::CannotCreateStream if the file cannot be opened for reading, or cannot
// be created for some reason.
FILE* _cdvdOpenNVM()
@ -136,6 +148,14 @@ FILE* _cdvdOpenNVM()
throw Exception::CannotCreateStream(fname);
for (int i=0; i<1024; i++) fputc(0, fd);
//Write NVM ILink area with dummy data (Age of Empires 2)
NVMLayout* nvmLayout = getNvmLayout();
u8 ILinkID_Data[8] = { 0x00, 0xAC, 0xFF, 0xFF, 0xFF, 0xFF, 0xB9, 0x86 };
fseek(fd, *(s32*)(((u8*)nvmLayout)+offsetof(NVMLayout, ilinkId)), SEEK_SET);
fwrite(ILinkID_Data, 1, 8, fd);
}
return fd;
}
@ -160,19 +180,6 @@ static void cdvdWriteNVM(const u8 *src, int offset, int bytes) {
fclose(fd);
}
NVMLayout* getNvmLayout()
{
NVMLayout* nvmLayout = NULL;
s32 nvmIdx;
for(nvmIdx=0; nvmIdx<NVM_FORMAT_MAX; nvmIdx++)
{
if(nvmlayouts[nvmIdx].biosVer <= BiosVersion)
nvmLayout = &nvmlayouts[nvmIdx];
}
return nvmLayout;
}
void getNvmData(u8* buffer, s32 offset, s32 size, s32 fmtOffset)
{
// find the correct bios version