From 565bafd25eafdb833b6d53bf2976eb748d100178 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sun, 30 Jun 2019 08:07:54 -0400 Subject: [PATCH] vectrex: fix display bug and add some brightness --- .../Consoles/GCE/Vectrex/HW_Registers.cs | 20 ++++++++- .../Consoles/GCE/Vectrex/PPU.cs | 45 ++++++++++++++----- .../GCE/Vectrex/VectrexHawk.IEmulator.cs | 8 ++-- .../Consoles/GCE/Vectrex/VectrexHawk.cs | 6 +++ 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs index af63e78079..50de9f755a 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs @@ -186,7 +186,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex } else { - if (sel1) { ppu.bright = portA_ret; ppu.bright_int = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); } + if (sel1) + { + ppu.bright = (byte)((portA_ret & 0x7F) << 1); + ppu.bright_int_1 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); + ppu.bright = (byte)(portA_ret & 0x7F); + ppu.bright_int_2 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); + ppu.bright = (byte)(portA_ret & 0x3F); + ppu.bright_int_3 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); + } else { ppu.y_vel = (byte)(portA_ret ^ 0x80); } } } @@ -217,7 +225,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex } else { - if (sel1) { ppu.bright = portA_ret; ppu.bright_int = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); } + if (sel1) + { + ppu.bright = (byte)((portA_ret & 0x7F) << 1); + ppu.bright_int_1 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); + ppu.bright = (byte)(portA_ret & 0x7F); + ppu.bright_int_2 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); + ppu.bright = (byte)(portA_ret & 0x3F); + ppu.bright_int_3 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); + } else { ppu.y_vel = (byte)(portA_ret ^ 0x80); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs index e6185c58d6..089739b7e7 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public double x_pos, y_pos; public int skip; - public uint bright_int; + public uint bright_int_1, bright_int_2, bright_int_3; public static uint br = 0xFFFFFFFF; @@ -33,17 +33,38 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex skip--; } - if (x_pos > 255) { x_pos = 255; } - if (x_pos < 0) { x_pos = 0; } - if (y_pos > 383) { y_pos = 383; } - if (y_pos < 0) { y_pos = 0; } + if (x_pos > 257) { x_pos = 257; } + if (x_pos < 2) { x_pos = 2; } + if (y_pos > 385) { y_pos = 385; } + if (y_pos < 2) { y_pos = 2; } - if (!blank_sig) { Core._vidbuffer[(int)(Math.Round(x_pos) + 256 * Math.Round(y_pos))] = (int)(br & bright_int); } + } else if (zero_sig) { - x_pos = 128; - y_pos = 192; + x_pos = 128 + 2; + y_pos = 192 + 2; + } + + if (!blank_sig) + { + + Core._vidbuffer[(int)(Math.Round(x_pos) + 260 * Math.Round(y_pos))] |= (int)(br & bright_int_1); + + Core._vidbuffer[(int)(Math.Round(x_pos) + 1 + 260 * Math.Round(y_pos))] |= (int)(br & bright_int_2); + Core._vidbuffer[(int)(Math.Round(x_pos) - 1 + 260 * Math.Round(y_pos))] |= (int)(br & bright_int_2); + Core._vidbuffer[(int)(Math.Round(x_pos) + 260 * (Math.Round(y_pos) + 1))] |= (int)(br & bright_int_2); + Core._vidbuffer[(int)(Math.Round(x_pos) + 260 * (Math.Round(y_pos) - 1))] |= (int)(br & bright_int_2); + + Core._vidbuffer[(int)(Math.Round(x_pos) + 2 + 260 * Math.Round(y_pos))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) - 2 + 260 * Math.Round(y_pos))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) + 260 * (Math.Round(y_pos) + 2))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) + 260 * (Math.Round(y_pos) - 2))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) + 1 + 260 * (Math.Round(y_pos) + 1))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) + 1 + 260 * (Math.Round(y_pos) - 1))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) - 1 + 260 * (Math.Round(y_pos) + 1))] |= (int)(br & bright_int_3); + Core._vidbuffer[(int)(Math.Round(x_pos) - 1 + 260 * (Math.Round(y_pos) - 1))] |= (int)(br & bright_int_3); + } } @@ -54,8 +75,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex ramp_sig = false; vec_scale = x_vel = y_vel = bright = 0; - x_pos = 128; - y_pos = 192; + x_pos = 128 + 2; + y_pos = 192 + 2; } public void SyncState(Serializer ser) @@ -73,7 +94,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex ser.Sync(nameof(y_pos), ref y_pos); ser.Sync(nameof(skip), ref skip); - ser.Sync(nameof(bright_int), ref bright_int); + ser.Sync(nameof(bright_int_1), ref bright_int_1); + ser.Sync(nameof(bright_int_2), ref bright_int_2); + ser.Sync(nameof(bright_int_3), ref bright_int_3); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs index 463da3fe91..4a3d10da24 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs @@ -97,10 +97,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex return _vidbuffer; } - public int VirtualWidth => 256; - public int VirtualHeight => 384; - public int BufferWidth => 256; - public int BufferHeight => 384; + public int VirtualWidth => 256 + 4; + public int VirtualHeight => 384 + 4; + public int BufferWidth => 256 + 4; + public int BufferHeight => 384 + 4; public int BackgroundColor => unchecked((int)0xFF000000); public int VsyncNumerator => _frameHz; public int VsyncDenominator => 1; diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs index 12e98eb23f..aef975dfbb 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs @@ -100,6 +100,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex } } + // RAM appears to power up to either random values or 0xFF, otherwise all the asteroids in minestorm are on the same side if RAM[0x7E]=0 + for (int i = 0; i < RAM.Length; i++) + { + RAM[i] = 0xFF; + } + Setup_Mapper(); _frameHz = 50;