Skip to content

Commit

Permalink
P04 1M to P05 now we know
Browse files Browse the repository at this point in the history
  • Loading branch information
antus committed Apr 27, 2023
1 parent 89afe72 commit c8c25ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
32 changes: 19 additions & 13 deletions Apps/PcmLibrary/Misc/FileValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@ public uint GetOsidFromImage()
osid += image[0x7FFFC - offset] << 8;
osid += image[0x7FFFD - offset] << 0;
break;

case 1024 * 1024:
osid += image[0xFFFFA] << 24;
osid += image[0xFFFFB] << 16;
osid += image[0xFFFFC] << 8;
osid += image[0xFFFFD] << 0;
break;
}
break;

case PcmType.P05:
osid += image[0xFFFFA] << 24;
osid += image[0xFFFFB] << 16;
osid += image[0xFFFFC] << 8;
osid += image[0xFFFFD] << 0;
break;

case PcmType.P08:
osid += image[0x8000] << 24;
osid += image[0x8001] << 16;
Expand Down Expand Up @@ -239,6 +239,11 @@ private bool ValidateChecksums()
segments = 0;
break;

case PcmType.P05:
tableAddress = 0x0;
segments = 0;
break;

case PcmType.P10:
tableAddress = 0x546;
segments = 5;
Expand All @@ -260,6 +265,7 @@ private bool ValidateChecksums()
switch (type)
{
case PcmType.P04:
case PcmType.P05:
this.logger.AddUserMessage("\tStart\tEnd\tStored\t\tNeeded\t\tVerdict\tSegment Name");
success &= ValidateRangeP04(true);
break;
Expand Down Expand Up @@ -429,11 +435,11 @@ private PcmType ValidateSignatures()
}
}

// P04 512Kb
this.logger.AddDebugMessage("Trying P04 1Mb");
// P05 1Mb
this.logger.AddDebugMessage("Trying P05 1Mb");
if ((image[0xFFFFE] == 0xA5) && (image[0xFFFFF] == 0x5A))
{
return PcmType.P04;
return PcmType.P05;
}

this.logger.AddDebugMessage("Trying P12 1Mb");
Expand Down Expand Up @@ -592,7 +598,7 @@ private bool ValidateRangeP12(UInt32 segment, UInt32 offset, UInt32 index, UInt3
}

/// <summary>
/// Validate a range for P04. Support 256, 512, 1024K images
/// Validate a range for P04 and P05. Support 256, 512, 1024K images
/// Early 512KB bins dont have a param block. This code is called with skipparamblock=true
/// If the first attempt fails it is re-entrant with skipparamblock=false to try again
/// </summary>
Expand All @@ -605,7 +611,7 @@ private bool ValidateRangeP04(bool skipparamblock)
UInt32 sumaddr = 0;

// Thanks Joukoy for Universal Patcher and the idea to use a pattern search for the P04 sum address.
// Working for all tested 1024K
// Working for all tested 1024K (P05)
if (image.Length == 1024 * 1024)
{
for (UInt32 i = start; i < end; i++)
Expand Down Expand Up @@ -698,7 +704,7 @@ private bool ValidateRangeP04(bool skipparamblock)
address += 0x4; // Some 98 have a different sig and dont include the osid
}
break;
case 1024 * 1024:
case 1024 * 1024: // P05
if (address == 0x4000)
{
address += 0xC000;
Expand Down
1 change: 1 addition & 0 deletions Apps/PcmLibrary/Misc/PcmInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum PcmType
Undefined = 0, // required for failed osid test on binary file
P01_P59,
P04,
P05,
P08,
P10,
P12,
Expand Down

0 comments on commit c8c25ff

Please sign in to comment.