From 2ae9de98effb0cd1bc8de81c37e56bee876cee26 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Fri, 21 Jul 2017 19:32:50 -0400 Subject: [PATCH] A7800Hawk: Updates and Bug Fixes -Fix save states -Fix sync settings -Controller Support / improvements --- .../Atari/A7800Hawk/A7800Hawk.IStatable.cs | 1 + .../Consoles/Atari/A7800Hawk/A7800Hawk.cs | 5 +- .../Atari/A7800Hawk/A7800HawkControllers.cs | 67 +++++++++++++++++++ .../Consoles/Atari/A7800Hawk/Maria.cs | 2 +- .../Consoles/Atari/A7800Hawk/MemoryMap.cs | 9 ++- 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs index 36b9fa3455..55b92185c4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs @@ -51,6 +51,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk tia.SyncState(ser); maria.SyncState(ser); m6532.SyncState(ser); + mapper.SyncState(ser); ser.BeginSection("Atari7800"); ser.Sync("core", ref core, false); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs index 005bb59f94..0996293d93 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public M6532 m6532; public TIA tia; - public A7800Hawk(CoreComm comm, GameInfo game, byte[] rom, string gameDbFn) + public A7800Hawk(CoreComm comm, GameInfo game, byte[] rom, string gameDbFn, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); @@ -72,6 +72,9 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk CoreComm = comm; + _settings = (A7800Settings)settings ?? new A7800Settings(); + _syncSettings = (A7800SyncSettings)syncSettings ?? new A7800SyncSettings(); + _controllerDeck = new A7800HawkControllerDeck(_syncSettings.Port1, _syncSettings.Port2); byte[] highscoreBios = comm.CoreFileProvider.GetFirmware("A78", "Bios_HSC", false, "Some functions may not work without the high score BIOS."); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs index 6db22121c6..93b79d2246 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs @@ -108,6 +108,73 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return result; } + public byte ReadFire2x(IController c) + { + return 0; // only applicable for 2 button mode + } + + public ControllerDefinition Definition { get; } + + + public void SyncState(Serializer ser) + { + // Nothing todo, I think + } + + private static readonly string[] BaseDefinition = + { + "U", "D", "L", "R", "Fire" + }; + + private static byte[] HandControllerButtons = + { + 0x0, // UP + 0x0, // Down + 0x0, // Left + 0x0, // Right + }; + } + + [DisplayName("ProLine Controller")] + public class ProLineController : IPort + { + public ProLineController(int portNum) + { + PortNum = portNum; + Definition = new ControllerDefinition + { + BoolButtons = BaseDefinition + .Select(b => "P" + PortNum + " " + b) + .ToList() + }; + } + + public int PortNum { get; } + + public byte Read(IController c) + { + byte result = 0xF; + for (int i = 0; i < 4; i++) + { + if (c.IsPressed(Definition.BoolButtons[i])) + { + result -= (byte)(1 << i); + } + } + + if (PortNum == 1) + { + result = (byte)(result << 4); + } + + return result; + } + + public byte ReadFire(IController c) + { + return 0x80; + } + public byte ReadFire2x(IController c) { byte result = 0; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs index 9e9ca302ea..50f9a71d8c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs @@ -218,7 +218,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (cycle == 453 && !sl_DMA_complete && do_dma && (DMA_phase == DMA_GRAPHICS || DMA_phase == DMA_HEADER)) { overrun_dma = true; - //Console.WriteLine(scanline); + Console.WriteLine(scanline); if (current_DLL_offset == 0) { DMA_phase = DMA_SHUTDOWN_LAST; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs index 164391b25f..f8229d38c5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs @@ -124,7 +124,14 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (temp == 4) // WSYNC cpu.RDY = false; - + /* + for (int i = 0; i < 0x20; i++) + { + Console.Write(Maria_regs[i]); + Console.Write(" "); + } + Console.WriteLine(maria.scanline); + */ } else {