From f39319fd121d39b7121198d892f411b8e33ff6d7 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Fri, 3 Apr 2020 16:56:22 -0400 Subject: [PATCH] O2Hawk: bug fixes and add reset button --- .../Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs | 5 +++++ .../Consoles/Magnavox/Odyssey2/O2Hawk.cs | 9 ++++++++- .../Magnavox/Odyssey2/O2HawkControllerDeck.cs | 2 +- .../Consoles/Magnavox/Odyssey2/PPU.cs | 14 +++++++++++--- .../Consoles/Nintendo/GBHawk/Timer.cs | 2 +- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs index 04ccc5bd21..f13a4ebcc3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs @@ -34,6 +34,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk HardReset(); } + if (controller.IsPressed("Reset")) + { + SoftReset(); + } + _islag = true; do_frame(controller); diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs index 3ba5ca80a7..06ef1f45fa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs @@ -95,6 +95,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); SetupMemoryDomains(); + cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); + HardReset(); // set up differences between PAL and NTSC systems @@ -131,7 +133,12 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk ppu.Reset(); - cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); + cpu.Reset(); + } + + public void SoftReset() + { + cpu.Reset(); } private void ExecFetch(ushort addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs index 8f486e3cb1..a2043fe5e2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs @@ -38,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk "Q", "S", "D", "F", "G", "H", "J", "K", "A", "Z", "X", "C", "V", "B", "M", "PERIOD", "-", "*", "/", "=", "YES", "NO", "CLR", "ENT", - "Power" + "Reset","Power" }) .ToList() }; diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs index 79e2b902dc..2453c22601 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs @@ -157,6 +157,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk A5_latch = (byte)(cycle - HBL_CNT); } else { VDC_status |= 0x2; } + + if (VDC_ctrl.Bit(2)) { Console.WriteLine("sound INT"); } } else if (addr == 0xA1) { @@ -740,7 +742,13 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk Grid_H = new byte[18]; Grid_V = new byte[10]; - AudioReset(); + VDC_ctrl = VDC_status = VDC_collision = VDC_color = grid_fill_col = 0; + Pixel_Stat = A4_latch = A5_latch = 0; + bg_brightness = grid_brightness = grid_fill = LY = cycle = 0; + VBL = HBL = lum_en = false; + + + AudioReset(); } public void set_region(bool pal_flag) @@ -821,8 +829,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 00, // \ 0x3B 0x00, 0x00, 0x18, 0x10, 0x10, 0xFF, 0x7E, 00, // (boat 1) 0x3C 0x00, 0x03, 0x63, 0xFF, 0xFF, 0x18, 0x08, 00, // (plane) 0x3D - 0x00, 0x00, 0x00, 0x01, 0x38, 0xFF, 0x7E, 00, // (boat 2) 0x3E - 0x00, 0x00, 0x00, 0x05, 0x6E, 0xFF, 0x7E, 00 // (boat 3) 0x3F + 0x00, 0x00, 0x00, 0x10, 0x38, 0xFF, 0x7E, 00, // (boat 2) 0x3E + 0x00, 0x00, 0x00, 0x06, 0x6E, 0xFF, 0x7E, 00 // (boat 3) 0x3F }; public static readonly uint[] Color_Palette_SPR = diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs index 65fdc112d8..163c2c5cb0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs @@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk state = false; reload_block = false; next_free_cycle = 0; - } + } public void SyncState(Serializer ser) {