mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
First round of cleanup for DolphinLib additions
This commit is contained in:
30
SabreTools.Data.Extensions/NintendoDiscExtensions.cs
Normal file
30
SabreTools.Data.Extensions/NintendoDiscExtensions.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using SabreTools.Data.Models.NintendoDisc;
|
||||
|
||||
namespace SabreTools.Data.Extensions
|
||||
{
|
||||
// TODO: Write tests for these
|
||||
public static class NintendoDiscExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the platform associated with a disc header
|
||||
/// </summary>
|
||||
public static Platform GetPlatform(this DiscHeader header)
|
||||
{
|
||||
if (header.WiiMagic == Constants.WiiMagicWord)
|
||||
return Platform.Wii;
|
||||
else if (header.GCMagic == Constants.GCMagicWord)
|
||||
return Platform.GameCube;
|
||||
else if (header.GameId is not null && header.GameId.Length >= 1 && IsGameCubeTitleType(header.GameId[0]))
|
||||
return Platform.GameCube;
|
||||
else
|
||||
return Platform.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the GameId first character is a known GameCube title type prefix.
|
||||
/// Used as a fallback when the GC magic word is absent from the disc image.
|
||||
/// </summary>
|
||||
public static bool IsGameCubeTitleType(this char c)
|
||||
=> c == 'G' || c == 'D' || c == 'R';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user