mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Refactor IP.BIN decoders.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
// ****************************************************************************/
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
@@ -38,21 +39,45 @@ namespace DiscImageChef.Decoders.Sega
|
||||
{
|
||||
public static class Saturn
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct IPBin
|
||||
{
|
||||
public byte[] SegaHardwareID; //16
|
||||
public byte[] maker_id; //[16 // 0x010, "SEGA ENTERPRISES"
|
||||
public byte[] product_no; //[10 // 0x020, Product number
|
||||
public byte[] product_version; //[6 // 0x02A, Product version
|
||||
public byte[] release_date; //[8 // 0x030, YYYYMMDD
|
||||
public byte[] saturn_media; //[3 // 0x038, "CD-"
|
||||
public byte[] disc_no; //[1 // 0x03B, Disc number
|
||||
public byte[] disc_no_separator; //[1 // 0x03C, '/'
|
||||
public byte[] disc_total_nos; //[1 // 0x03D, Total number of discs
|
||||
public byte[] spare_space1; //[2 // 0x03E, " "
|
||||
public byte[] region_codes; //[16 // 0x040, Region codes, space-filled
|
||||
public byte[] peripherals; //[16 // 0x050, Supported peripherals, see above
|
||||
public byte[] product_name; //[112 // 0x060, Game name, space-filled
|
||||
/// <summary>Must be "SEGA SEGASATURN "</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] SegaHardwareID;
|
||||
/// <summary>0x010, "SEGA ENTERPRISES"</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] maker_id;
|
||||
/// <summary>0x020, Product number</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
|
||||
public byte[] product_no;
|
||||
/// <summary>0x02A, Product version</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
||||
public byte[] product_version;
|
||||
/// <summary>0x030, YYYYMMDD</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] release_date;
|
||||
/// <summary>0x038, "CD-"</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public byte[] saturn_media;
|
||||
/// <summary>0x03B, Disc number</summary>
|
||||
public byte disc_no;
|
||||
/// <summary>// 0x03C, '/'</summary>
|
||||
public byte disc_no_separator;
|
||||
/// <summary>// 0x03D, Total number of discs</summary>
|
||||
public byte disc_total_nos;
|
||||
/// <summary>0x03E, " "</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] spare_space1;
|
||||
/// <summary>0x040, Region codes, space-filled</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] region_codes;
|
||||
/// <summary>0x050, Supported peripherals, see above</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] peripherals;
|
||||
/// <summary>0x060, Game name, space-filled</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 112)]
|
||||
public byte[] product_name;
|
||||
}
|
||||
|
||||
public static IPBin? DecodeIPBin(byte[] ipbin_sector)
|
||||
@@ -64,54 +89,26 @@ namespace DiscImageChef.Decoders.Sega
|
||||
return null;
|
||||
|
||||
IPBin ipbin = new IPBin();
|
||||
ipbin.SegaHardwareID = new byte[16];
|
||||
// Definitions following
|
||||
ipbin.maker_id = new byte[16]; // 0x010, "SEGA ENTERPRISES"
|
||||
ipbin.product_no = new byte[10]; // 0x020, Product number
|
||||
ipbin.product_version = new byte[6]; // 0x02A, Product version
|
||||
ipbin.release_date = new byte[8]; // 0x030, YYYYMMDD
|
||||
ipbin.saturn_media = new byte[3]; // 0x038, "CD-"
|
||||
ipbin.disc_no = new byte[1]; // 0x03B, Disc number
|
||||
ipbin.disc_no_separator = new byte[1]; // 0x03C, '/'
|
||||
ipbin.disc_total_nos = new byte[1]; // 0x03D, Total number of discs
|
||||
ipbin.spare_space1 = new byte[2]; // 0x03E, " "
|
||||
ipbin.region_codes = new byte[16]; // 0x040, Region codes, space-filled
|
||||
ipbin.peripherals = new byte[16]; // 0x050, Supported peripherals, see above
|
||||
ipbin.product_name = new byte[112]; // 0x060, Game name, space-filled
|
||||
// Reading all data
|
||||
Array.Copy(ipbin_sector, 0x010, ipbin.maker_id, 0, 16); // "SEGA ENTERPRISES"
|
||||
Array.Copy(ipbin_sector, 0x020, ipbin.product_no, 0, 10); // Product number
|
||||
Array.Copy(ipbin_sector, 0x02A, ipbin.product_version, 0, 6); // Product version
|
||||
Array.Copy(ipbin_sector, 0x030, ipbin.release_date, 0, 8); // YYYYMMDD
|
||||
Array.Copy(ipbin_sector, 0x038, ipbin.saturn_media, 0, 3); // "CD-"
|
||||
Array.Copy(ipbin_sector, 0x03B, ipbin.disc_no, 0, 1); // Disc number
|
||||
Array.Copy(ipbin_sector, 0x03C, ipbin.disc_no_separator, 0, 1); // '/'
|
||||
Array.Copy(ipbin_sector, 0x03D, ipbin.disc_total_nos, 0, 1); // Total number of discs
|
||||
Array.Copy(ipbin_sector, 0x03E, ipbin.spare_space1, 0, 2); // " "
|
||||
Array.Copy(ipbin_sector, 0x040, ipbin.region_codes, 0, 16); // Region codes, space-filled
|
||||
Array.Copy(ipbin_sector, 0x050, ipbin.peripherals, 0, 16); // Supported peripherals, see above
|
||||
Array.Copy(ipbin_sector, 0x060, ipbin.product_name, 0, 112); // Game name, space-filled
|
||||
IntPtr ptr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(ipbin_sector, 0, ptr, 512);
|
||||
ipbin = (IPBin)Marshal.PtrToStructure(ptr, typeof(IPBin));
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_no));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_version = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_version));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.release_datedate = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.saturn_media = \"{0}\"", Encoding.ASCII.GetString(ipbin.saturn_media));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no = {0}", Encoding.ASCII.GetString(ipbin.disc_no));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no_separator = \"{0}\"", Encoding.ASCII.GetString(ipbin.disc_no_separator));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_total_nos = {0}", Encoding.ASCII.GetString(ipbin.disc_total_nos));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no);
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator);
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_total_nos = {0}", (char)ipbin.disc_total_nos);
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.spare_space1 = \"{0}\"", Encoding.ASCII.GetString(ipbin.spare_space1));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(ipbin.region_codes));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(ipbin.peripherals));
|
||||
DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_name));
|
||||
|
||||
string id = Encoding.ASCII.GetString(ipbin.SegaHardwareID);
|
||||
|
||||
if(id == "SEGA SEGASATURN ")
|
||||
return ipbin;
|
||||
else
|
||||
return null;
|
||||
return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : (IPBin?)null;
|
||||
}
|
||||
|
||||
public static string Prettify(IPBin? decoded)
|
||||
@@ -135,7 +132,7 @@ namespace DiscImageChef.Decoders.Sega
|
||||
IPBinInformation.AppendFormat("Product number: {0}", Encoding.ASCII.GetString(ipbin.product_no)).AppendLine();
|
||||
IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(ipbin.product_version)).AppendLine();
|
||||
IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine();
|
||||
IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(ipbin.disc_no), Encoding.ASCII.GetString(ipbin.disc_total_nos)).AppendLine();
|
||||
IPBinInformation.AppendFormat("Disc number {0} of {1}", (char)ipbin.disc_no, (char)ipbin.disc_total_nos).AppendLine();
|
||||
|
||||
IPBinInformation.AppendFormat("Peripherals:").AppendLine();
|
||||
foreach(byte peripheral in ipbin.peripherals)
|
||||
|
||||
Reference in New Issue
Block a user