(Partial) .nrg support

TAO support isn't complete, a lot of sanity checking isn't done yet
This commit is contained in:
CasualPokePlayer 2023-05-18 07:13:25 -07:00
parent 3d30f52e7c
commit fe79b69123
12 changed files with 1150 additions and 20 deletions

View File

@ -53,6 +53,8 @@ namespace BizHawk.Client.Common
public static readonly IReadOnlyCollection<string> ArchiveExtensions = new[] { "zip", "rar", "7z", "gz" };
public static readonly IReadOnlyCollection<string> DiscExtensions = new[] { "cue", "ccd", "cdi", "iso", "mds", "m3u", "nrg" };
public static readonly FilesystemFilter Archives = new FilesystemFilter("Archives", ArchiveExtensions);
public static readonly FilesystemFilter BizHawkMovies = new FilesystemFilter("Movie Files", new[] { MovieService.StandardMovieExtension });

View File

@ -951,10 +951,10 @@ namespace BizHawk.Client.Common
/// <remarks>TODO add and handle <see cref="FilesystemFilter.LuaScripts"/> (you can drag-and-drop scripts and there are already non-rom things in this list, so why not?)</remarks>
public static readonly FilesystemFilterSet RomFilter = new(
new FilesystemFilter("Music Files", Array.Empty<string>(), devBuildExtraExts: new[] { "psf", "minipsf", "sid", "nsf", "gbs" }),
new FilesystemFilter("Disc Images", new[] { "cue", "ccd", "cdi", "mds", "m3u" }),
new FilesystemFilter("Disc Images", FilesystemFilter.DiscExtensions),
new FilesystemFilter("NES", RomFileExtensions.NES.Concat(new[] { "nsf" }).ToList(), addArchiveExts: true),
new FilesystemFilter("Super NES", RomFileExtensions.SNES, addArchiveExts: true),
new FilesystemFilter("PlayStation", new[] { "bin", "cue", "ccd", "mds", "m3u" }),
new FilesystemFilter("PlayStation", FilesystemFilter.DiscExtensions),
new FilesystemFilter("PSX Executables (experimental)", Array.Empty<string>(), devBuildExtraExts: new[] { "exe" }),
new FilesystemFilter("PSF Playstation Sound File", new[] { "psf", "minipsf" }),
new FilesystemFilter("Nintendo 64", RomFileExtensions.N64),
@ -963,7 +963,7 @@ namespace BizHawk.Client.Common
new FilesystemFilter("Gameboy Advance", RomFileExtensions.GBA, addArchiveExts: true),
new FilesystemFilter("Nintendo DS", RomFileExtensions.NDS),
new FilesystemFilter("Master System", RomFileExtensions.SMS, addArchiveExts: true),
new FilesystemFilter("PC Engine", RomFileExtensions.PCE.Concat(new[] { "cue", "ccd", "mds" }).ToList(), addArchiveExts: true),
new FilesystemFilter("PC Engine", RomFileExtensions.PCE.Concat(FilesystemFilter.DiscExtensions).ToList(), addArchiveExts: true),
new FilesystemFilter("Atari 2600", RomFileExtensions.A26, devBuildExtraExts: new[] { "bin" }, addArchiveExts: true),
new FilesystemFilter("Atari 7800", RomFileExtensions.A78, devBuildExtraExts: new[] { "bin" }, addArchiveExts: true),
new FilesystemFilter("Atari Jaguar", RomFileExtensions.Jaguar, addArchiveExts: true),
@ -973,7 +973,7 @@ namespace BizHawk.Client.Common
new FilesystemFilter("TI-83", RomFileExtensions.TI83, addArchiveExts: true),
new FilesystemFilter("TIC-80", RomFileExtensions.TIC80, addArchiveExts: true),
FilesystemFilter.Archives,
new FilesystemFilter("Genesis", RomFileExtensions.GEN.Concat(new[] { "bin", "cue", "ccd" }).ToList(), addArchiveExts: true),
new FilesystemFilter("Genesis", RomFileExtensions.GEN.Concat(FilesystemFilter.DiscExtensions).ToList(), addArchiveExts: true),
new FilesystemFilter("SID Commodore 64 Music File", Array.Empty<string>(), devBuildExtraExts: new[] { "sid" }, devBuildAddArchiveExts: true),
new FilesystemFilter("WonderSwan", RomFileExtensions.WSWAN, addArchiveExts: true),
new FilesystemFilter("Apple II", RomFileExtensions.AppleII, addArchiveExts: true),

View File

@ -118,14 +118,14 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="richTextBox1.Text" xml:space="preserve">
<value>DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD.
DiscoHawk is part of the BizHawk project ( http://code.google.com/p/bizhawk ).
BizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments.
To use, drag a disc (.cue, .iso, .ccd) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked.
<value>DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD.
DiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk ).
BizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments.
To use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked.
This is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.)</value>
</data>
</root>

View File

@ -156,7 +156,7 @@
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(216, 33);
this.label3.TabIndex = 7;
this.label3.Text = "- Uses FFMPEG for audio decoding\r\n- Loads ISO, CUE, CCD, and CDI";
this.label3.Text = "- Uses FFMPEG for audio decoding\r\n- Loads ISO, CUE, CCD, CDI, MDS, and NRG";
//
// radioButton2
//

View File

@ -5,7 +5,6 @@ using System.Windows.Forms;
using System.IO;
using BizHawk.Common.PathExtensions;
using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.DiscSystem;
namespace BizHawk.Client.DiscoHawk
@ -104,7 +103,7 @@ namespace BizHawk.Client.DiscoHawk
foreach (var str in files)
{
var ext = Path.GetExtension(str) ?? string.Empty;
if(!ext.In(".CUE", ".ISO", ".CCD", ".CDI", ".MDS"))
if (!Disc.IsValidExtension(ext))
{
return new();
}

View File

@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private readonly string[] _nonArchive = { ".ISO", ".CUE", ".CCD" };
private readonly string[] _nonArchive = { ".ISO", ".CUE", ".CCD", ".CDI", ".MDS", ".NRG" };
private void LoadCdl(string filename, string archive = null)
{

View File

@ -42,6 +42,8 @@ using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
using BizHawk.Emulation.Cores.Sony.PSX;
using BizHawk.Emulation.DiscSystem;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Client.EmuHawk.CoreExtensions;
using BizHawk.Client.EmuHawk.CustomControls;
@ -3880,7 +3882,7 @@ namespace BizHawk.Client.EmuHawk
var ext = Path.GetExtension(xmlGame.AssetFullPaths[xg])?.ToLowerInvariant();
var (filename, data) = xmlGame.Assets[xg];
if (ext is ".cue" or ".ccd" or ".cdi" or ".toc" or ".mds")
if (Disc.IsValidExtension(ext))
{
xSw.WriteLine(Path.GetFileNameWithoutExtension(filename));
xSw.WriteLine("SHA1:N/A");

View File

@ -122,6 +122,6 @@ namespace BizHawk.Emulation.DiscSystem
{}
public static bool IsValidExtension(string extension)
=> extension.ToLowerInvariant() is ".ccd" or ".cdi" or ".cue" or ".iso" or ".mds";
=> extension.ToLowerInvariant() is ".ccd" or ".cdi" or ".cue" or ".iso" or ".toc" or ".mds" or ".nrg";
}
}

View File

@ -97,7 +97,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
//it's a little unclear whether we should go for a whitelist or a blacklist here.
//there's similar numbers of cases either way.
//perhaps we could code both (and prefer choices from the whitelist)
if (ext is ".cue" or ".sbi" or ".ccd" or ".sub")
if (ext is not ".iso" && (Disc.IsValidExtension(ext) || ext is ".sbi" or ".sub"))
continue;
//continuing the bad plan: forbid archives (always a wrong choice, not supported anyway)

File diff suppressed because it is too large Load Diff

View File

@ -205,9 +205,14 @@ namespace BizHawk.Emulation.DiscSystem
//TODO try it both ways and check the disc type to use whichever one succeeds in identifying a disc type
LoadCue(cueDirPath: dir, cueContent: GenerateCue(binFilename: file, binFilePath: IN_FromPath));
break;
case ".toc":
throw new NotSupportedException(".TOC not supported yet");
case ".mds":
OUT_Disc = MDS_Format.LoadMDSToDisc(IN_FromPath, IN_DiscMountPolicy);
break;
case ".nrg":
OUT_Disc = NRG_Format.LoadNRGToDisc(IN_FromPath, IN_DiscMountPolicy);
break;
}
// set up the lowest level synth provider

View File

@ -27,8 +27,23 @@ namespace BizHawk.Emulation.DiscSystem
/// <summary>
/// encapsulates a 2 digit BCD number as used various places in the CD specs
/// </summary>
public struct BCD2
public struct BCD2 : IEquatable<BCD2>
{
public bool Equals(BCD2 other)
{
return BCDValue == other.BCDValue;
}
public override bool Equals(object obj)
{
return obj is BCD2 other && Equals(other);
}
public override int GetHashCode()
{
return BCDValue.GetHashCode();
}
/// <summary>
/// The raw BCD value. you can't do math on this number! but you may be asked to supply it to a game program.
/// The largest number it can logically contain is 99
@ -67,6 +82,13 @@ namespace BizHawk.Emulation.DiscSystem
public override string ToString()
=> BCDValue.ToString("X2");
public static bool operator ==(BCD2 lhs, BCD2 rhs) => lhs.BCDValue == rhs.BCDValue;
public static bool operator !=(BCD2 lhs, BCD2 rhs) => lhs.BCDValue != rhs.BCDValue;
public static bool operator <(BCD2 lhs, BCD2 rhs) => lhs.BCDValue < rhs.BCDValue;
public static bool operator >(BCD2 lhs, BCD2 rhs) => lhs.BCDValue > rhs.BCDValue;
public static bool operator <=(BCD2 lhs, BCD2 rhs) => lhs.BCDValue <= rhs.BCDValue;
public static bool operator >=(BCD2 lhs, BCD2 rhs) => lhs.BCDValue >= rhs.BCDValue;
}
public static class MSF