Skip to content

Commit d61300a

Browse files
authored
Command line support (#28)
* Introduce command-line argument parsing with `System.CommandLine` * More command line options * Refactor initialization * Add support for custom ROM file handling and enhance command-line options. * Add AY stereo mode command-line options. * Extend command-line options to support Time Machine and Resume. * Update README
1 parent 8aad09d commit d61300a

20 files changed

+658
-80
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,42 @@ dotnet build -c Release
7272
dotnet run --project ./src/Spectron
7373
```
7474

75+
### Command line options
76+
Command lines allow overriding most of the default options and loading specified file.
77+
```
78+
Options:
79+
-?, -h, --help Show help and usage information
80+
--version Show version information
81+
-f, --file Specifies the file to load. This can be any supported file type: TAP | TZX | Z80 | SNA |
82+
SZX | POK | ZIP
83+
-ts, --tape-load-speed <Accelerated|Instant|Normal> Specifies the tape loading speed
84+
-c, --computer <Spectrum128K|Spectrum16K|Spectrum48K> Specifies the computer to emulate
85+
-r, --rom <BrendanAlford|BusySoft|Custom|GoshWonderful|Harston|Original|Retroleum> Specifies the ROM to load
86+
-rf, --rom-file Specifies the custom ROM file
87+
-j, --joystick <Cursor|Fuller|Kempston|None|Sinclair1|Sinclair2> Specifies the emulated joystick type
88+
-m, --mouse <Kempston|None> Specifies the emulated mouse type
89+
-t, --theme <Dark|Light> Specifies the application theme
90+
-b, --border <Full|Large|Medium|None|Small> Specifies the border size
91+
-m, --mute Mutes the audio playback [default: False]
92+
--ay Enables AY sound emulation
93+
--no-ay Disables AY sound emulation
94+
--ay-mode <Mono|StereoABC|StereoACB> Specifies AY mono or stereo mode
95+
--zx-printer Enables ZX Printer emulation
96+
--no-zx-printer Disables ZX Printer emulation
97+
--ula-plus Enables ULA+ emulation
98+
--no-ula-plus Disables ULA+ emulation
99+
--divmmc Enables divMMC emulation, --divmmc-image is required
100+
--no-divmmc Disables divMMC emulation
101+
--divmmc-image Specifies the SD card image to use with divMMC
102+
--divmmc-readonly Specifies the SD card image is readonly, SD card writes will be cached in-memory only
103+
--divmmc-writable Specifies the SD card image is writable, SD card writes will persisted
104+
--time-machine Enables Time Machine
105+
--no-time-machine Disables Time Machine
106+
--resume Resume emulator state assuming there is a previously saved state
107+
--no-resume Do not resume emulator state
108+
109+
```
110+
75111
## Testing and compatibility
76112
- [x] Passes floatspy v0.33 (RAMSOFT) floating bus test in both 48k and 128k mode
77113
- [x] Passes HALT2INT v3 (Mark Woodmass) test in both 48k and 128k mode

Spectron.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:Boolean x:Key="/Default/CodeEditing/SuppressNullableWarningFix/Enabled/@EntryValue">False</s:Boolean>
3+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ABC/@EntryIndexedValue">ABC</s:String>
4+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ACB/@EntryIndexedValue">ACB</s:String>
35
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AF/@EntryIndexedValue">AF</s:String>
46
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AY/@EntryIndexedValue">AY</s:String>
57
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BC/@EntryIndexedValue">BC</s:String>

src/Spectron.Emulation/Devices/Audio/AudioManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ internal AudioBuffer EndFrame()
150150
sample = MonoMix(sample, Ay.ChannelA.Samples[i], Ay.ChannelB.Samples[i], Ay.ChannelC.Samples[i]);
151151
break;
152152

153-
case StereoMode.StereoAbc:
153+
case StereoMode.StereoABC:
154154
(sampleL, sampleR) = StereoMix(sample, Ay.ChannelA.Samples[i], Ay.ChannelB.Samples[i], Ay.ChannelC.Samples[i]);
155155
break;
156156

157-
case StereoMode.StereoAcb:
157+
case StereoMode.StereoACB:
158158
(sampleL, sampleR) = StereoMix(sample, Ay.ChannelA.Samples[i], Ay.ChannelC.Samples[i], Ay.ChannelB.Samples[i]);
159159
break;
160160
}

src/Spectron.Emulation/Devices/Audio/StereoMode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public enum StereoMode
44
{
55
Mono,
66

7-
StereoAbc,
7+
StereoABC,
88

9-
StereoAcb,
9+
StereoACB,
1010
}

src/Spectron.Emulation/Extensions/ArrayExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace OldBit.Spectron.Emulation.Extensions;
44

5-
internal static class ArrayExtensions
5+
public static class ArrayExtensions
66
{
77
[return: NotNullIfNotNull(nameof(first))]
88
[return: NotNullIfNotNull(nameof(second))]
9-
internal static T[]? Concatenate<T>(this T[]? first, T[]? second)
9+
public static T[]? Concatenate<T>(this T[]? first, T[]? second)
1010
{
1111
if (first is null)
1212
{
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using OldBit.Spectron.Emulation;
2+
using OldBit.Spectron.Emulation.Devices.Audio;
3+
using OldBit.Spectron.Emulation.Devices.Joystick;
4+
using OldBit.Spectron.Emulation.Devices.Mouse;
5+
using OldBit.Spectron.Emulation.Rom;
6+
using OldBit.Spectron.Emulation.Tape;
7+
using OldBit.Spectron.Screen;
8+
using OldBit.Spectron.Theming;
9+
10+
namespace OldBit.Spectron.CommandLine;
11+
12+
public record CommandLineArgs(
13+
string? FilePath,
14+
TapeSpeed? TapeLoadSpeed,
15+
ComputerType? ComputerType,
16+
RomType? RomType,
17+
string[]? CustomRomFiles,
18+
JoystickType? JoystickType,
19+
MouseType? MouseType,
20+
bool IsAudioMuted,
21+
bool? IsAyEnabled,
22+
StereoMode? AyStereoMode,
23+
bool? IsDivMmcEnabled,
24+
string? DivMmcImageFile,
25+
bool? IsDivMmcReadOnly,
26+
bool? IsZxPrinterEnabled,
27+
bool? IsUlaPlusEnabled,
28+
bool? IsTimeMachineEnabled,
29+
bool? IsResumeEnabled,
30+
BorderSize? BorderSize,
31+
Theme? Theme);

0 commit comments

Comments
 (0)