From 585f35b29e3d41f30cf26ca0572176e164b44a15 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Fri, 23 Dec 2016 20:07:12 -0500 Subject: [PATCH] Intellivision implement BackTab calls Correct timing for background drawing, not sure if any game uses it though --- .../Intellivision/Intellivision.IEmulator.cs | 15 ++- .../Intellivision/Intellivision.IStatable.cs | 127 +++++++++--------- .../Consoles/Intellivision/STIC.cs | 4 +- 3 files changed, 77 insertions(+), 69 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs index ec50fccdf8..cf97a03a13 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs @@ -25,11 +25,12 @@ namespace BizHawk.Emulation.Cores.Intellivision _psg.sample_count = 0; _frame++; + stic_row = -1; // read the controller state here for now get_controller_state(); // this timer tracks cycles stolen by the STIC during the visible part of the frame, quite a large number of them actually - int delay_cycles = 0; + int delay_cycles = 600; int delay_timer = -1; _cpu.PendingCycles = (14934 - 3791 + _cpu.GetPendingCycles()); @@ -53,13 +54,19 @@ namespace BizHawk.Emulation.Cores.Intellivision } } - if (delay_cycles>= 800 && _stic.active_display) + if (delay_cycles>= 750 && _stic.active_display) { delay_cycles = -1; delay_timer = 110; _stic.ToggleSr2(); + if (stic_row >= 0) + { + _stic.in_vb_2 = true; + _stic.Background(stic_row); + _stic.in_vb_2 = false; + } + stic_row++; } - Connect(); } @@ -69,7 +76,6 @@ namespace BizHawk.Emulation.Cores.Intellivision if (_stic.active_display) { - _stic.Background(); _stic.Mobs(); } @@ -100,6 +106,7 @@ namespace BizHawk.Emulation.Cores.Intellivision } private int _frame; + private int stic_row; public int Frame { get { return _frame; } } public string SystemId diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs index 0ac1cd7fed..5ec188d6e4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs @@ -1,56 +1,57 @@ -using System.IO; - -using BizHawk.Common; -using BizHawk.Emulation.Common; - - -namespace BizHawk.Emulation.Cores.Intellivision -{ - public partial class Intellivision : IStatable - { - public bool BinarySaveStatesPreferred - { - get { return true; } - } - - public void SaveStateText(TextWriter writer) - { - SyncState(Serializer.CreateTextWriter(writer)); - } - - public void LoadStateText(TextReader reader) - { - SyncState(Serializer.CreateTextReader(reader)); - SetupMemoryDomains(); // resync the memory domains - } - - public void SaveStateBinary(BinaryWriter bw) - { - SyncState(Serializer.CreateBinaryWriter(bw)); - } - - public void LoadStateBinary(BinaryReader br) - { - SyncState(Serializer.CreateBinaryReader(br)); - SetupMemoryDomains(); // resync the memory domains - } - - public byte[] SaveStateBinary() - { - MemoryStream ms = new MemoryStream(); - BinaryWriter bw = new BinaryWriter(ms); - SaveStateBinary(bw); - bw.Flush(); - return ms.ToArray(); - } - - private void SyncState(Serializer ser) - { - int version = 1; - ser.BeginSection("Intellivision"); - ser.Sync("version", ref version); - ser.Sync("Frame", ref _frame); - +using System.IO; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + + +namespace BizHawk.Emulation.Cores.Intellivision +{ + public partial class Intellivision : IStatable + { + public bool BinarySaveStatesPreferred + { + get { return true; } + } + + public void SaveStateText(TextWriter writer) + { + SyncState(Serializer.CreateTextWriter(writer)); + } + + public void LoadStateText(TextReader reader) + { + SyncState(Serializer.CreateTextReader(reader)); + SetupMemoryDomains(); // resync the memory domains + } + + public void SaveStateBinary(BinaryWriter bw) + { + SyncState(Serializer.CreateBinaryWriter(bw)); + } + + public void LoadStateBinary(BinaryReader br) + { + SyncState(Serializer.CreateBinaryReader(br)); + SetupMemoryDomains(); // resync the memory domains + } + + public byte[] SaveStateBinary() + { + MemoryStream ms = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(ms); + SaveStateBinary(bw); + bw.Flush(); + return ms.ToArray(); + } + + private void SyncState(Serializer ser) + { + int version = 1; + ser.BeginSection("Intellivision"); + ser.Sync("version", ref version); + ser.Sync("Frame", ref _frame); + ser.Sync("stic_row", ref stic_row); + ser.Sync("ScratchpadRam", ref ScratchpadRam, false); ser.Sync("SystemRam", ref SystemRam, false); ser.Sync("ExecutiveRom", ref ExecutiveRom, false); @@ -59,13 +60,13 @@ namespace BizHawk.Emulation.Cores.Intellivision - _cpu.SyncState(ser); - _stic.SyncState(ser); - _psg.SyncState(ser); - _cart.SyncState(ser); - ControllerDeck.SyncState(ser); - - ser.EndSection(); - } - } -} + _cpu.SyncState(ser); + _stic.SyncState(ser); + _psg.SyncState(ser); + _cart.SyncState(ser); + ControllerDeck.SyncState(ser); + + ser.EndSection(); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs index f16d6ff4a4..08b7a83d12 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs @@ -319,7 +319,7 @@ namespace BizHawk.Emulation.Cores.Intellivision throw new ArgumentException("Specified color does not exist."); } - public void Background() + public void Background(int input_row) { // here we will also need to apply the 'delay' register values. // this shifts the background portion of the screen relative to the mobs @@ -328,7 +328,7 @@ namespace BizHawk.Emulation.Cores.Intellivision ColorSP = 0x0028; // The background is a 20x12 grid of "cards". - for (int card_row = 0; card_row < 12; card_row++) + for (int card_row = input_row; card_row < (input_row+1); card_row++) { for (int card_col = 0; card_col < 20; card_col++) {