BizHawk/ExternalCoreProjects/Virtu/MachineEvents.cs

167 lines
3.8 KiB
C#
Raw Normal View History

2015-02-17 22:58:25 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
2015-02-17 22:58:25 +00:00
namespace Jellyfish.Virtu
{
public enum EventCallbacks
{
FlushOutput,
FlushRow,
LeaveVBlank,
ResetVsync,
InverseText
}
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
internal sealed class MachineEvent
{
public MachineEvent(int delta, EventCallbacks type)
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
{
Delta = delta;
Type = type;
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
}
public int Delta { get; set; }
public EventCallbacks Type { get; set; }
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
}
public sealed class MachineEvents
{
private readonly Dictionary<EventCallbacks, Action> _eventDelegates = new Dictionary<EventCallbacks, Action>();
private readonly LinkedList<MachineEvent> _used = new LinkedList<MachineEvent>();
private readonly LinkedList<MachineEvent> _free = new LinkedList<MachineEvent>();
// ReSharper disable once UnusedMember.Global
public void Sync(IComponentSerializer ser)
{
if (ser.IsReader)
{
int[] usedDelta = Array.Empty<int>();
int[] usedType = Array.Empty<int>();
int[] freeDelta = Array.Empty<int>();
int[] freeType = Array.Empty<int>();
ser.Sync("UsedDelta", ref usedDelta, false);
ser.Sync("UsedType", ref usedType, false);
ser.Sync("FreeDelta", ref freeDelta, false);
ser.Sync("FreeType", ref freeType, false);
_used.Clear();
for (int i = 0; i < usedDelta.Length; i++)
{
var e = new MachineEvent(usedDelta[i], (EventCallbacks)usedType[i]);
_used.AddLast(new LinkedListNode<MachineEvent>(e));
}
_free.Clear();
for (int i = 0; i < freeDelta.Length; i++)
{
var e = new MachineEvent(freeDelta[i], (EventCallbacks)freeType[i]);
_free.AddLast(new LinkedListNode<MachineEvent>(e));
}
}
else
{
var usedDelta = _used.Select(u => u.Delta).ToArray();
var usedType = _used.Select(u => (int)u.Type).ToArray();
var freeDelta = _free.Select(f => f.Delta).ToArray();
var freeType = _free.Select(f => (int)f.Type).ToArray();
ser.Sync("UsedDelta", ref usedDelta, false);
ser.Sync("UsedType", ref usedType, false);
ser.Sync("FreeDelta", ref freeDelta, false);
ser.Sync("FreeType", ref freeType, false);
}
}
public void AddEventDelegate(EventCallbacks type, Action action)
{
_eventDelegates[type] = action;
}
public void AddEvent(int delta, EventCallbacks type)
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
{
var node = _used.First;
for (; node != null; node = node.Next)
{
if (delta < node.Value.Delta)
{
node.Value.Delta -= delta;
break;
}
if (node.Value.Delta > 0)
{
delta -= node.Value.Delta;
}
}
var newNode = _free.First;
if (newNode != null)
{
_free.RemoveFirst();
newNode.Value.Delta = delta;
newNode.Value.Type = type;
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
}
else
{
newNode = new LinkedListNode<MachineEvent>(new MachineEvent(delta, type));
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
}
if (node != null)
{
_used.AddBefore(node, newNode);
}
else
{
_used.AddLast(newNode);
}
}
public int FindEvent(EventCallbacks type)
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
{
int delta = 0;
for (var node = _used.First; node != null; node = node.Next)
{
delta += node.Value.Delta;
2015-05-18 00:14:00 +00:00
var other = node.Value.Type;
2015-05-18 00:14:00 +00:00
if (other == type)
2015-05-18 00:14:00 +00:00
{
return delta;
}
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
}
2015-05-18 00:14:00 +00:00
return 0;
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
}
2015-05-18 00:14:00 +00:00
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
// ReSharper disable once UnusedMember.Global
public void HandleEvents(int delta)
{
var node = _used.First;
node.Value.Delta -= delta;
2015-02-17 22:58:25 +00:00
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
while (node.Value.Delta <= 0)
{
_eventDelegates[node.Value.Type]();
Virtu cleanup (#1846) * virtu - tabs instead of spaces * virtu - use nooget for Newtonsoft.Json * virtu - target .net 4.8 * resharper - target C# 8 * virtu - remove unused usings * virtu - remove some unused code * virtu - cleanups * virtu - trace logging - add flags to trace logs * virtu - cleanups * virtu - misc cleanups * virtu - make some stuff internal and simplify the api some * virtu - clock down more things and simplify api more * virtu - lock api down more * virtu- simplify, breaks older savestates however * virtu - simplify more * virtu - cleanup * virtu- more cleanup * virtu - reorg some files * virtu - more cleanup * virtu - more reorg * virtu - more reorg * virtu - make more things internal instead of public * virtu - make more things internal * virtu - update dll * cleanup * virtu - reorg * virtu - remove unitialize from machine component since nothing was utilizing it * virtu - simplify api * virtu - cleanup * virtu - cleanup and lock things down * virtu - lock down and cleanup * virtu - cleanup * virtu - simplify - breaks savestates * virtu - make PeripheralCard an interface with default implementation, breaks savestates * virtu - minimize use of machine component * virtu - cleanup * virtu - start minimizing dependencies * virtu - cleanup * virtu - simplify * apple II - simplify * virtu - move some biz logic into bizhawk * virtu - git rid of MachineComponent * virtu - delete no longer needed code * virtu - reorg * move serialization logic out of virtu and into bizhawk, this was our shenanigans * virtu - some small cleanups * virtu - simplify * virtu - dependency minimization * virtu - minimize dependencies * minimize dependencies * virtu - move drivelight property into component that controls it * virtu - minimize dependencies * virtu - minimize depenencies * move some machine logic to memory class * move some initialize logic into constructor * move initialize logic to constructor * move logic from Initialize to constructor * move initialize logic to constructor, simplify api to bizhawk * dll * virtu - movie some logic back into bizhawk * virtu - move Lagged property from machine to memory component * move more biz logic from virtu to biz * virtu - slight reorg * virtu - move some reset logic to constructor * virtu - move some stuff around * virtu - declare dependencies in memory class, no more dependencies on the machine class * move slots from machine to memory class * move some properties from machine to memory * move more things into the memory class * remove Machine.cs from virtu and make an equivalent container in bizhawk * virtu - cleanup * interface the cassette class and create a biz empty cassette "implementation" * move some more dummy logic from virtu to biz and put an interface in virtu * virtu - use an interface for a dependency * virtu - interface more things * virtu - more interfacing of things * virtu - interface more things * apple II/virtu - some reorg * virtu - cleanup * virtu - remove unused usages of disk name in disk classes * virtu- cleanup and simplify api * virtu - remove unused BootDrive property * virtu - cleanup and interface more * cleanup * update virtu dll
2020-02-14 15:54:35 +00:00
RemoveEvent(node);
node = _used.First;
}
}
private void RemoveEvent(LinkedListNode<MachineEvent> node)
{
if (node.Next != null)
{
node.Next.Value.Delta += node.Value.Delta;
}
_used.Remove(node);
_free.AddFirst(node); // cache node; avoids garbage
}
}
2015-02-17 22:58:25 +00:00
}