Skip to content

Commit

Permalink
options
Browse files Browse the repository at this point in the history
  • Loading branch information
vadosnaprimer committed Jun 8, 2024
1 parent a7505e4 commit 59493ce
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 34 deletions.
14 changes: 8 additions & 6 deletions src/BizHawk.Emulation.Cores/Computers/Amiga/PUAE.ISettable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
{
public partial class PUAE : ISettable<object, PUAE.PUAESyncSettings>
{
public const int FASTMEM_AUTO = -1;

public enum MachineConfig
{
[Display(Name = "A500 OCS 1.3 512K 512K")]
[Display(Name = "A500 OCS KS1.3 512K 512K")]
A500_OCS_130_512K_512K,
[Display(Name = "A600 ECS 2.05 2M")]
[Display(Name = "A600 ECS KS2.05 2M")]
A600_ECS_205_2M,
[Display(Name = "A1200 AGA 3.1 2M 8M")]
[Display(Name = "A1200 AGA KS3.1 2M 8M")]
A1200_AGA_310_2M_8M,
[Display(Name = "A4000 AGA 3.1 2M 8M")]
[Display(Name = "A4000 AGA KS3.1 2M 8M")]
A4000_AGA_310_2M_8M,
// CD32
}
Expand Down Expand Up @@ -166,8 +168,8 @@ public class PUAESyncSettings

[DisplayName("Fast memory")]
[Description("Size in megabytes of fast-memory. -1 means Auto.")]
[Range(-1, 512)]
[DefaultValue(-1)]
[Range(FASTMEM_AUTO, 512)]
[DefaultValue(FASTMEM_AUTO)]
[TypeConverter(typeof(ConstrainedIntConverter))]
public int FastMemory { get; set; }

Expand Down
92 changes: 64 additions & 28 deletions src/BizHawk.Emulation.Cores/Computers/Amiga/PUAE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading;
using static BizHawk.Emulation.Cores.Computers.Amiga.PUAE;

Check failure on line 10 in src/BizHawk.Emulation.Cores/Computers/Amiga/PUAE.cs

View workflow job for this annotation

GitHub Actions / Build solution with analyzers

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

namespace BizHawk.Emulation.Cores.Computers.Amiga
{
Expand All @@ -21,6 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
public partial class PUAE : WaterboxCore
{
private LibPUAE _puae;
private static string _chipsetCompatible = "";

[CoreConstructor(VSystemID.Raw.Amiga)]
public PUAE(CoreLoadParameters<object, PUAESyncSettings> lp)
Expand Down Expand Up @@ -49,94 +48,131 @@ public PUAE(CoreLoadParameters<object, PUAESyncSettings> lp)
SkipCoreConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
SkipMemoryConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
});

var chipsetCompatible = "";

var filesToRemove = new List<string>();
var args = CreateArguments(_syncSettings);

_exe.AddReadonlyFile(lp.Roms[0].FileData, "romfile");
filesToRemove.Add("romfile");

var (kickstartData, kickstartInfo) = CoreComm.CoreFileProvider.GetFirmwareWithGameInfoOrThrow(
new(VSystemID.Raw.Amiga, _chipsetCompatible),
"Firmware files are usually required and may stop your game from loading");
_exe.AddReadonlyFile(kickstartData, kickstartInfo.Name);
filesToRemove.Add(kickstartInfo.Name);
args.AddRange(new List<string>
{
"-r", kickstartInfo.Name
});

ControllerDefinition = InitInput();

if (!_puae.Init(args.Count, args.ToArray()))
throw new InvalidOperationException("Core rejected the rom!");

foreach (var s in filesToRemove)
{
//_exe.RemoveReadonlyFile(s);
}

PostInit();
}

private static List<string> CreateArguments(PUAESyncSettings settings)
{

var args = new List<string>
{
"puae"
, "-0", "romfile"
};

switch(_syncSettings.MachineConfig)
switch(settings.MachineConfig)
{
case MachineConfig.A500_OCS_130_512K_512K:
chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A500);
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A500);
args.AddRange(new List<string>
{
"-s", "cpu_model=" + (int)CpuModel._68000
, "-s", "chipset=" + Chipset.OCS
, "-s", "chipset_compatible=" + chipsetCompatible
, "-s", "chipset_compatible=" + _chipsetCompatible
, "-s", "chipmem_size=" + (int)ChipMemory.KB_512
, "-s", "bogomem_size=" + (int)SlowMemory.KB_512
, "-s", "fastmem_size=0"
});
break;
case MachineConfig.A600_ECS_205_2M:
chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A600);
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A600);
args.AddRange(new List<string>
{
"-s", "cpu_model=" + (int)CpuModel._68000
, "-s", "chipset=" + Chipset.ECS
, "-s", "chipset_compatible=" + chipsetCompatible
, "-s", "chipset_compatible=" + _chipsetCompatible
, "-s", "chipmem_size=" + (int)ChipMemory.MB_2
, "-s", "bogomem_size=" + (int)SlowMemory.KB_0
, "-s", "fastmem_size=0"
});
break;
case MachineConfig.A1200_AGA_310_2M_8M:
chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A1200);
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A1200);
args.AddRange(new List<string>
{
"-s", "cpu_model=" + (int)CpuModel._68020
, "-s", "chipset=" + Chipset.AGA
, "-s", "chipset_compatible=" + chipsetCompatible
, "-s", "chipset_compatible=" + _chipsetCompatible
, "-s", "chipmem_size=" + (int)ChipMemory.MB_2
, "-s", "bogomem_size=" + (int)SlowMemory.KB_0
, "-s", "fastmem_size=8"
});
break;
case MachineConfig.A4000_AGA_310_2M_8M:
chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A4000);
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A4000);
args.AddRange(new List<string>
{
"-s", "cpu_model=" + (int)CpuModel._68040
, "-s", "fpu_model=68040"
, "-s", "mmu_model=68040"
, "-s", "chipset=" + Chipset.AGA
, "-s", "chipset_compatible=" + chipsetCompatible
, "-s", "chipset_compatible=" + _chipsetCompatible
, "-s", "chipmem_size=" + (int)ChipMemory.MB_2
, "-s", "bogomem_size=" + (int)SlowMemory.KB_0
, "-s", "fastmem_size=8"
});
break;
}

var (kickstartData, kickstartInfo) = CoreComm.CoreFileProvider.GetFirmwareWithGameInfoOrThrow(
new(VSystemID.Raw.Amiga, chipsetCompatible),
"Firmware files are usually required and may stop your game from loading");
_exe.AddReadonlyFile(kickstartData, kickstartInfo.Name);
filesToRemove.Add(kickstartInfo.Name);
args.AddRange(new List<string>
if (settings.CpuModel != CpuModel.Auto)
{
"-r", kickstartInfo.Name
});
args.AddRange(new List<string> { "-s", "cpu_model=" + (int)settings.CpuModel });
}

ControllerDefinition = InitInput();
if (settings.Chipset != Chipset.Auto)
{
args.AddRange(new List<string> { "-s", "chipset=" + (int)settings.Chipset });
}

if (!_puae.Init(args.Count, args.ToArray()))
throw new InvalidOperationException("Core rejected the rom!");
if (settings.ChipsetCompatible != ChipsetCompatible.Auto)
{
args.AddRange(new List<string> { "-s", "chipset_compatible="
+ Enum.GetName(typeof(ChipsetCompatible), settings.ChipsetCompatible) });
}

foreach (var s in filesToRemove)
if (settings.ChipMemory != ChipMemory.Auto)
{
//_exe.RemoveReadonlyFile(s);
args.AddRange(new List<string> { "-s", "chipmem_size=" + (int)settings.ChipMemory });
}

PostInit();
if (settings.SlowMemory != SlowMemory.Auto)
{
args.AddRange(new List<string> { "-s", "bogomem_size=" + (int)settings.SlowMemory });
}

if (settings.FastMemory != FASTMEM_AUTO)
{
args.AddRange(new List<string> { "-s", "fastmem_size=" + (int)settings.FastMemory });

Check failure on line 172 in src/BizHawk.Emulation.Cores/Computers/Amiga/PUAE.cs

View workflow job for this annotation

GitHub Actions / Build solution with analyzers

Cast is redundant. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0004)
}

return args;
}

private static ControllerDefinition InitInput()
Expand Down

0 comments on commit 59493ce

Please sign in to comment.