Skip to content

Commit 286ec86

Browse files
committed
Add unused Dreamdump execution context
1 parent e4fd644 commit 286ec86

File tree

19 files changed

+582
-3
lines changed

19 files changed

+582
-3
lines changed

CHANGELIST.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Add MPRESS to packer filters
1414
- Update RedumpLib to 1.9.1
1515
- Split path creation in OptionsLoader
16+
- Add unused Dreamdump execution context
1617

1718
### 3.6.0 (2025-11-28)
1819

MPF.CLI/Features/BaseFeature.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ public override bool Execute()
135135

136136
break;
137137

138+
// case InternalProgram.Dreamdump:
139+
// if (!File.Exists(Options.DreamdumpPath))
140+
// {
141+
// Console.Error.WriteLine("A path needs to be supplied in config.json for Dreamdump, exiting...");
142+
// return false;
143+
// }
144+
145+
// break;
146+
138147
case InternalProgram.Redumper:
139148
if (!File.Exists(Options.RedumperPath))
140149
{

MPF.CLI/Features/InteractiveFeature.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public override bool ProcessArgs(string[] args, int index)
123123
Console.WriteLine($"{InternalProgram.Redumper.ToString().ToLowerInvariant(),-15} => {InternalProgram.Redumper.LongName()}");
124124
Console.WriteLine($"{InternalProgram.DiscImageCreator.ToString().ToLowerInvariant(),-15} => {InternalProgram.DiscImageCreator.LongName()}");
125125
Console.WriteLine($"{InternalProgram.Aaru.ToString().ToLowerInvariant(),-15} => {InternalProgram.Aaru.LongName()}");
126+
// Console.WriteLine($"{InternalProgram.Dreamdump.ToString().ToLowerInvariant(),-15} => {InternalProgram.Dreamdump.LongName()}");
126127
Console.WriteLine();
127128
Console.WriteLine("Input the dumping program and press Enter:");
128129
Console.Write("> ");
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System.Collections.Generic;
2+
using MPF.ExecutionContexts.Dreamdump;
3+
using SabreTools.RedumpLib.Data;
4+
using Xunit;
5+
6+
namespace MPF.ExecutionContexts.Test
7+
{
8+
public class DreamdumpTests
9+
{
10+
#region Default Values
11+
12+
private static readonly Dictionary<string, string?> AllOptions = new()
13+
{
14+
[SettingConstants.RereadCount] = "1000",
15+
[SettingConstants.SectorOrder] = "DATA_C2_SUB",
16+
};
17+
18+
// None of these scenarios are actually supported as all are treated like GD-ROM
19+
[Theory]
20+
[InlineData(null, null, null, "filename.bin", null, "--retries=20 --image-name=\"filename\" --sector-order=DATA_C2_SUB")]
21+
[InlineData(RedumpSystem.IBMPCcompatible, MediaType.CDROM, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
22+
[InlineData(RedumpSystem.IBMPCcompatible, MediaType.DVD, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
23+
[InlineData(RedumpSystem.NintendoGameCube, MediaType.NintendoGameCubeGameDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
24+
[InlineData(RedumpSystem.NintendoWii, MediaType.NintendoWiiOpticalDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
25+
[InlineData(RedumpSystem.HDDVDVideo, MediaType.HDDVD, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
26+
[InlineData(RedumpSystem.BDVideo, MediaType.BluRay, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
27+
[InlineData(RedumpSystem.NintendoWiiU, MediaType.NintendoWiiUOpticalDisc, "/dev/sr0", "path/filename.bin", 2, "--retries=20 --image-name=\"filename\" --image-path=\"path\" --speed=2 --sector-order=DATA_C2_SUB --drive=/dev/sr0")]
28+
public void DefaultValueTest(RedumpSystem? system,
29+
MediaType? type,
30+
string? drivePath,
31+
string filename,
32+
int? driveSpeed,
33+
string? expected)
34+
{
35+
var context = new ExecutionContext(system, type, drivePath, filename, driveSpeed, AllOptions);
36+
string? actual = context.GenerateParameters();
37+
Assert.Equal(expected, actual);
38+
}
39+
40+
#endregion
41+
42+
#region Default
43+
44+
[Theory]
45+
[InlineData("--force-qtoc --train --retries=20 --image-name=image --image-path=path --read-offset=0 --read-at-once=0 --speed=8 --sector-order=so --drive=/dev/sr0")]
46+
public void DiscTest(string parameters)
47+
{
48+
string? expected = "--force-qtoc --train --retries=20 --image-name=\"image\" --image-path=\"path\" --read-offset=0 --read-at-once=0 --speed=8 --sector-order=so --drive=/dev/sr0";
49+
var context = new ExecutionContext(parameters);
50+
string? actual = context.GenerateParameters();
51+
Assert.Equal(expected, actual);
52+
Assert.True(context.IsDumpingCommand());
53+
}
54+
55+
[Theory]
56+
[InlineData("--image-name=\"image name.bin\" --image-path=\"directory name\"")]
57+
public void SpacesTest(string parameters)
58+
{
59+
string? expected = "--image-name=\"image name.bin\" --image-path=\"directory name\"";
60+
var context = new ExecutionContext(parameters);
61+
string? actual = context.GenerateParameters();
62+
Assert.Equal(expected, actual);
63+
Assert.True(context.IsDumpingCommand());
64+
}
65+
66+
#endregion
67+
}
68+
}

MPF.ExecutionContexts/BaseExecutionContext.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,28 @@ internal static int GetInt32Setting(Dictionary<string, string?> settings, string
294294
return defaultValue;
295295
}
296296

297+
/// <summary>
298+
/// Get an UInt8 setting from a settings, dictionary
299+
/// </summary>
300+
/// <param name="settings">Dictionary representing the settings</param>
301+
/// <param name="key">Setting key to get a value for</param>
302+
/// <param name="defaultValue">Default value to return if no value is found</param>
303+
/// <returns>Setting value if possible, default value otherwise</returns>
304+
internal static byte GetUInt8Setting(Dictionary<string, string?> settings, string key, byte defaultValue)
305+
{
306+
if (settings.ContainsKey(key))
307+
{
308+
if (byte.TryParse(settings[key], out byte value))
309+
return value;
310+
else
311+
return defaultValue;
312+
}
313+
else
314+
{
315+
return defaultValue;
316+
}
317+
}
318+
297319
#endregion
298320

299321
#region Parameter Parsing
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MPF.ExecutionContexts.Dreamdump
2+
{
3+
/// <summary>
4+
/// Top-level commands for Dreamdump
5+
/// </summary>
6+
public static class CommandStrings
7+
{
8+
public const string NONE = "";
9+
}
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace MPF.ExecutionContexts.Dreamdump
2+
{
3+
/// <summary>
4+
/// Drive sector order option
5+
/// </summary>
6+
public enum SectorOrder
7+
{
8+
NONE = 0,
9+
10+
DATA_C2,
11+
DATA_SUB,
12+
DATA_C2_SUB,
13+
DATA_SUB_C2,
14+
}
15+
}

0 commit comments

Comments
 (0)