From 8a600436973651192b8587d69e528f1f1406bd44 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 22 Feb 2020 11:42:50 -0600 Subject: [PATCH] a7800 - misc simplifications, remove mapperBase peek/poke methods since they weren't being used and did not differ from read/write on any mapper --- .../Consoles/Atari/A7800Hawk/M6532.cs | 4 +- .../Atari/A7800Hawk/Mappers/MapperBase.cs | 18 +----- .../Atari/A7800Hawk/Mappers/MapperDefault.cs | 9 +-- .../Atari/A7800Hawk/Mappers/MapperF18.cs | 9 +-- .../A7800Hawk/Mappers/MapperFractalus.cs | 12 +--- .../Atari/A7800Hawk/Mappers/MapperRampage.cs | 12 +--- .../Atari/A7800Hawk/Mappers/MapperSG.cs | 9 +-- .../Atari/A7800Hawk/Mappers/MapperSGE.cs | 9 +-- .../Consoles/Atari/A7800Hawk/Maria.cs | 30 +++------- .../Consoles/Atari/A7800Hawk/Pokey.cs | 18 ++---- .../Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs | 56 +++++++------------ .../Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs | 6 +- .../A7800Hawk/TIA_Sound/Tia.SyncState.cs | 2 +- BizHawk.sln.DotSettings | 5 ++ 14 files changed, 54 insertions(+), 145 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs index cd9e3a54b5..b01b16c5c3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Emulates the M6532 RIOT Chip - public class M6532 + public sealed class M6532 { public A7800Hawk Core { get; set; } @@ -224,7 +224,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { PrescalerCount--; - if ((PrescalerCount == 0) || Overflowed) + if (PrescalerCount == 0 || Overflowed) { Value--; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs index 5254436347..86d14235c1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs @@ -7,30 +7,14 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public A7800Hawk Core { get; set; } public int mask; - public virtual byte ReadMemory(ushort addr) - { - return 0; - } - - public virtual byte PeekMemory(ushort addr) - { - return 0; - } + public virtual byte ReadMemory(ushort addr) => 0; public virtual void WriteMemory(ushort addr, byte value) { } - public virtual void PokeMemory(ushort addr, byte value) - { - } - public virtual void SyncState(Serializer ser) { } - - public virtual void Dispose() - { - } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs index c7ef358745..461433fefb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Default mapper with no bank switching // Just need to keep track of high score bios stuff - public class MapperDefault : MapperBase + public sealed class MapperDefault : MapperBase { public override byte ReadMemory(ushort addr) { @@ -50,8 +50,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return 0x00; } - public override byte PeekMemory(ushort addr) => ReadMemory(addr); - public override void WriteMemory(ushort addr, byte value) { if (addr >= 0x1000 && addr < 0x1800) @@ -82,10 +80,5 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk // cartridge and other OPSYS } } - - public override void PokeMemory(ushort addr, byte value) - { - WriteMemory(addr, value); - } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs index ebe43b1141..5d751c7b19 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs @@ -4,7 +4,7 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Mapper only used by F-18 Hornet - public class MapperF18 : MapperBase + public sealed class MapperF18 : MapperBase { private byte _bank; @@ -50,8 +50,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return Core._rom[tempAddr + _bank * 0x4000]; } - public override byte PeekMemory(ushort addr) => ReadMemory(addr); - public override void WriteMemory(ushort addr, byte value) { if (addr >= 0x1000 && addr < 0x1800) @@ -84,11 +82,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } } - public override void PokeMemory(ushort addr, byte value) - { - WriteMemory(addr, value); - } - public override void SyncState(Serializer ser) { ser.Sync("Bank", ref _bank); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs index 2ca019e123..e0045e887d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs @@ -4,7 +4,7 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Rescue on Fractalus has unique RAM mapping - public class MapperFractalus : MapperBase + public sealed class MapperFractalus : MapperBase { private byte[] RAM = new byte[0x800]; @@ -55,11 +55,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return 0x00; } - public override byte PeekMemory(ushort addr) - { - return ReadMemory(addr); - } - public override void WriteMemory(ushort addr, byte value) { if (addr >= 0x1000 && addr < 0x1800) @@ -93,11 +88,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } } - public override void PokeMemory(ushort addr, byte value) - { - WriteMemory(addr, value); - } - public override void SyncState(Serializer ser) { ser.Sync(nameof(RAM), ref RAM, false); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs index a2e02c2096..f549d643c4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs @@ -4,7 +4,7 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Mapper only used by Rampage and Double Dragon - public class MapperRampage : MapperBase + public sealed class MapperRampage : MapperBase { private byte _bank; @@ -75,11 +75,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return Core._rom[7 * 0x4000 + tempAddr]; } - public override byte PeekMemory(ushort addr) - { - return ReadMemory(addr); - } - public override void WriteMemory(ushort addr, byte value) { if (addr >= 0x1000 && addr < 0x1800) @@ -111,11 +106,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } } - public override void PokeMemory(ushort addr, byte value) - { - WriteMemory(addr, value); - } - public override void SyncState(Serializer ser) { ser.Sync("Bank", ref _bank); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs index e19b13e991..96e0ffc0bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs @@ -4,7 +4,7 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Default Bank Switching Mapper used by most games - public class MapperSG : MapperBase + public sealed class MapperSG : MapperBase { private byte _bank; private byte[] RAM = new byte[0x4000]; @@ -96,8 +96,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return 0xFF; } - public override byte PeekMemory(ushort addr) => ReadMemory(addr); - public override void WriteMemory(ushort addr, byte value) { if (addr >= 0x1000 && addr < 0x1800) @@ -144,11 +142,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } } - public override void PokeMemory(ushort addr, byte value) - { - WriteMemory(addr, value); - } - public override void SyncState(Serializer ser) { ser.Sync("Bank", ref _bank); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs index 1479b4fee4..040c5908d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs @@ -5,7 +5,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Super Game mapper but with extra ROM at the start of the file // Have to add 1 to bank number to get correct bank value - public class MapperSGE : MapperBase + public sealed class MapperSGE : MapperBase { private byte _bank; @@ -70,8 +70,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return Core._rom[tempAddr]; } - public override byte PeekMemory(ushort addr) => ReadMemory(addr); - public override void WriteMemory(ushort addr, byte value) { if (addr >= 0x1000 && addr < 0x1800) @@ -111,11 +109,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk } } - public override void PokeMemory(ushort addr, byte value) - { - WriteMemory(addr, value); - } - public override void SyncState(Serializer ser) { ser.Sync("Bank", ref _bank); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs index a82b2583cb..30521daa96 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs @@ -5,7 +5,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Emulates the Atari 7800 Maria graphics chip - public class Maria + public sealed class Maria { public A7800Hawk Core { get; set; } @@ -192,16 +192,11 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (cycle == 453 && !sl_DMA_complete && do_dma && (DMA_phase == DMA_GRAPHICS || DMA_phase == DMA_HEADER)) { - if (current_DLL_offset == 0) - { - DMA_phase = DMA_SHUTDOWN_LAST; - } - else - { - DMA_phase = DMA_SHUTDOWN_OTHER; - } + DMA_phase = current_DLL_offset == 0 + ? DMA_SHUTDOWN_LAST + : DMA_SHUTDOWN_OTHER; - DMA_phase_counter = 0; + DMA_phase_counter = 0; } Core.RunCPUCycle(); @@ -296,15 +291,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk Core.tia._hsyncCnt = 0; Core.cpu.RDY = true; - // swap sacnline buffers - if (GFX_index == 1) - { - GFX_index = 0; - } - else - { - GFX_index = 1; - } + // swap scanline buffers + GFX_index = GFX_index == 1 ? 0 : 1; } } } @@ -377,7 +365,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk GFX_Objects[header_counter].addr |= (ushort)(temp << 8); header_pointer++; temp = ReadMemory((ushort)(current_DLL_addr + header_pointer)); - int temp_w = (temp & 0x1F); // this is the 2's complement of width (for reasons that escape me) + int temp_w = temp & 0x1F; // this is the 2's complement of width (for reasons that escape me) if (temp_w == 0) { @@ -591,7 +579,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk Core.cpu_resume_pending = true; sl_DMA_complete = true; - // on the last line of a zone, we load up the disply list list for the next zone. + // on the last line of a zone, we load up the display list list for the next zone. display_zone_counter++; ushort temp_addr = (ushort)(display_zone_pointer + 3 * display_zone_counter); byte temp = ReadMemory(temp_addr); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs index 164910b879..808218d161 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs @@ -3,7 +3,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { - // emualtes pokey sound chip + // emulates pokey sound chip // note: A7800 implementation is used only for sound // potentiometers, keyboard, and IRQs are not used in this context /* @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk * The registers are write only, except for the RNG none of the things that would return reads are connected * for now return FF */ - public class Pokey + public sealed class Pokey { public A7800Hawk Core { get; set; } @@ -37,11 +37,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public bool[] clock_ch = new bool[4]; public int bit_xor; - public Pokey() - { - - } - public int sample() { LocalAudioCycles = 0; @@ -138,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk inc_ch[2]++; if (Regs[8].Bit(0)) { - if (inc_ch[2] >= 114) { inc_ch[2] = 0; clock_ch[2] = true; } + if (inc_ch[2] >= 114) { inc_ch[2] = 0; clock_ch[2] = true; } } else { @@ -150,7 +145,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { if (clock_ch[0]) { - clock_ch[1] = true; + clock_ch[1] = true; } } else @@ -159,7 +154,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (Regs[8].Bit(0)) { if (inc_ch[1] >= 114) { inc_ch[1] = 0; clock_ch[1] = true; } - } else { @@ -179,7 +173,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk inc_ch[3]++; if (Regs[8].Bit(0)) { - if (inc_ch[3] >= 114) { inc_ch[3] = 0; clock_ch[3] = true; } + if (inc_ch[3] >= 114) { inc_ch[3] = 0; clock_ch[3] = true; } } else { @@ -273,7 +267,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk //if (ch_src[i]) //{ ch_out[i] = poly4.Bit(3); - //} + //} } else if ((Regs[i * 2 + 1] & 0xF0) == 0xE0) { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs index 5c63494a5b..6b0ef44c04 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs @@ -1,7 +1,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Emulates the TIA - public partial class TIA + public sealed partial class TIA { public A7800Hawk Core { get; set; } @@ -94,10 +94,8 @@ Core._isLag = false; return (byte)(Core.p1_fire_2x & 0x80); } - else - { - return 0; - } + + return 0; } if (maskedAddr == 0x09) // INPT1 @@ -107,10 +105,8 @@ Core._isLag = false; return (byte)((Core.p1_fire_2x & 0x40)<<1); } - else - { - return 0; - } + + return 0; } if (maskedAddr == 0x0A) // INPT2 @@ -120,10 +116,8 @@ Core._isLag = false; return (byte)(Core.p2_fire_2x & 0x80); } - else - { - return 0; - } + + return 0; } if (maskedAddr == 0x0B) // INPT3 @@ -133,10 +127,8 @@ Core._isLag = false; return (byte)((Core.p2_fire_2x & 0x40)<<1); } - else - { - return 0; - } + + return 0; } if (maskedAddr == 0x0C) // INPT4 @@ -149,19 +141,16 @@ { return Core.p1_fire; } - else - { - return Core.lg_1_trigger_hit; - } + + return Core.lg_1_trigger_hit; } - else if ((Core.m6532._outputB & 0x04) != 0 || (Core.m6532._ddRb & 0x04) != 0x04) + + if ((Core.m6532._outputB & 0x04) != 0 || (Core.m6532._ddRb & 0x04) != 0x04) { return Core.p1_fire; } - else - { - return 0x80; - } + + return 0x80; } if (maskedAddr == 0x0D) // INPT5 @@ -173,19 +162,16 @@ { return Core.p2_fire; } - else - { - return Core.lg_2_trigger_hit; - } + + return Core.lg_2_trigger_hit; } - else if ((Core.m6532._outputB & 0x10) != 0 || (Core.m6532._ddRb & 0x10) != 0x10) + + if ((Core.m6532._outputB & 0x10) != 0 || (Core.m6532._ddRb & 0x10) != 0x10) { return Core.p2_fire; } - else - { - return 0x80; - } + + return 0x80; } return 0; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs index 796235db25..bab1c44f73 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { - public partial class TIA + public sealed partial class TIA { public class Audio { @@ -137,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk One5(); Run4(); on = Run1(); - break; + break; case 0x06: case 0x0a: Run5(); @@ -153,7 +153,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk case 0x07: case 0x09: on = Run5(); - break; + break; case 0x08: on = Run9(); break; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs index bdac1a9b3b..0f46521dad 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { - public partial class TIA + public sealed partial class TIA { public void SyncState(Serializer ser) { diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index a08ea811cc..e2932cf327 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -235,8 +235,10 @@ True True True + True True True + True True True True @@ -364,6 +366,7 @@ True True True + True True True True @@ -384,6 +387,7 @@ True True True + True True True True @@ -423,6 +427,7 @@ True True True + True True True True