Spaces -> tabs, fix mixed newlines.

This commit is contained in:
J.D. Purcell 2019-11-03 20:55:38 -05:00
parent 2750a420ef
commit fec63fb66a
86 changed files with 4209 additions and 4209 deletions

View File

@ -99,11 +99,11 @@ namespace BizHawk.Client.ApiHawk
case "WSWAN": case "WSWAN":
return CoreSystem.WonderSwan; return CoreSystem.WonderSwan;
case "ZXSpectrum": case "ZXSpectrum":
return CoreSystem.ZXSpectrum; return CoreSystem.ZXSpectrum;
case "AmstradCPC": case "AmstradCPC":
return CoreSystem.AmstradCPC; return CoreSystem.AmstradCPC;
case "GGL": case "GGL":
return CoreSystem.GGL; return CoreSystem.GGL;
@ -229,11 +229,11 @@ namespace BizHawk.Client.ApiHawk
case CoreSystem.WonderSwan: case CoreSystem.WonderSwan:
return "WSWAN"; return "WSWAN";
case CoreSystem.ZXSpectrum: case CoreSystem.ZXSpectrum:
return "ZXSpectrum"; return "ZXSpectrum";
case CoreSystem.AmstradCPC: case CoreSystem.AmstradCPC:
return "AmstradCPC"; return "AmstradCPC";
default: default:
throw new IndexOutOfRangeException($"{value.ToString()} is missing in convert list"); throw new IndexOutOfRangeException($"{value.ToString()} is missing in convert list");

View File

@ -31,8 +31,8 @@
VirtualBoy, VirtualBoy,
Vectrex, Vectrex,
NeoGeoPocket, NeoGeoPocket,
ZXSpectrum, ZXSpectrum,
AmstradCPC, AmstradCPC,
GGL, GGL,
GB3x, GB3x,
GB4x, GB4x,

View File

@ -126,35 +126,35 @@ namespace BizHawk.Client.Common
public Dictionary<string, RealFirmwareFile> Dict { get; } = new Dictionary<string, RealFirmwareFile>(); public Dictionary<string, RealFirmwareFile> Dict { get; } = new Dictionary<string, RealFirmwareFile>();
} }
/// <summary> /// <summary>
/// Test to determine whether the supplied firmware file matches something in the firmware database /// Test to determine whether the supplied firmware file matches something in the firmware database
/// </summary> /// </summary>
public bool CanFileBeImported(string f) public bool CanFileBeImported(string f)
{ {
try try
{ {
var fi = new FileInfo(f); var fi = new FileInfo(f);
if (!fi.Exists) if (!fi.Exists)
return false; return false;
// weed out filesizes first to reduce the unnecessary overhead of a hashing operation // weed out filesizes first to reduce the unnecessary overhead of a hashing operation
if (FirmwareDatabase.FirmwareFiles.Where(a => a.Size == fi.Length).FirstOrDefault() == null) if (FirmwareDatabase.FirmwareFiles.Where(a => a.Size == fi.Length).FirstOrDefault() == null)
return false; return false;
// check the hash // check the hash
using (var reader = new RealFirmwareReader()) using (var reader = new RealFirmwareReader())
{ {
reader.Read(fi); reader.Read(fi);
if (FirmwareDatabase.FirmwareFiles.Where(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash).FirstOrDefault() != null) if (FirmwareDatabase.FirmwareFiles.Where(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash).FirstOrDefault() != null)
return true; return true;
} }
} }
catch { } catch { }
return false; return false;
} }
public void DoScanAndResolve() public void DoScanAndResolve()
{ {
// build a list of file sizes. Only those will be checked during scanning // build a list of file sizes. Only those will be checked during scanning
HashSet<long> sizes = new HashSet<long>(); HashSet<long> sizes = new HashSet<long>();

View File

@ -156,10 +156,10 @@ namespace BizHawk.Client.Common
return SystemInfo.Vectrex; return SystemInfo.Vectrex;
case "NGP": case "NGP":
return SystemInfo.NeoGeoPocket; return SystemInfo.NeoGeoPocket;
case "ZXSpectrum": case "ZXSpectrum":
return SystemInfo.ZXSpectrum; return SystemInfo.ZXSpectrum;
case "AmstradCPC": case "AmstradCPC":
return SystemInfo.AmstradCPC; return SystemInfo.AmstradCPC;
case "ChannelF": case "ChannelF":
return SystemInfo.ChannelF; return SystemInfo.ChannelF;
} }

View File

@ -66,14 +66,14 @@ namespace BizHawk.Client.Common
{ {
RomData = FileData; RomData = FileData;
} }
else if (file.Extension == ".DSK" || file.Extension == ".TAP" || file.Extension == ".TZX" || else if (file.Extension == ".DSK" || file.Extension == ".TAP" || file.Extension == ".TZX" ||
file.Extension == ".PZX" || file.Extension == ".CSW" || file.Extension == ".WAV" || file.Extension == ".CDT") file.Extension == ".PZX" || file.Extension == ".CSW" || file.Extension == ".WAV" || file.Extension == ".CDT")
{ {
// these are not roms. unforunately if treated as such there are certain edge-cases // these are not roms. unforunately if treated as such there are certain edge-cases
// where a header offset is detected. This should mitigate this issue until a cleaner solution is found // where a header offset is detected. This should mitigate this issue until a cleaner solution is found
// (-Asnivor) // (-Asnivor)
RomData = FileData; RomData = FileData;
} }
else else
{ {
// if there was a header offset, read the whole file into FileData and then copy it into RomData (this is unfortunate, in case RomData isnt needed) // if there was a header offset, read the whole file into FileData and then copy it into RomData (this is unfortunate, in case RomData isnt needed)

View File

@ -529,9 +529,9 @@ namespace BizHawk.Client.Common
// try to use our wizard methods // try to use our wizard methods
game = new GameInfo { Name = Path.GetFileNameWithoutExtension(file.Name), Hash = discHash }; game = new GameInfo { Name = Path.GetFileNameWithoutExtension(file.Name), Hash = discHash };
var dt = new DiscIdentifier(disc).DetectDiscType(); var dt = new DiscIdentifier(disc).DetectDiscType();
switch (dt) switch (dt)
{ {
case DiscType.SegaSaturn: case DiscType.SegaSaturn:
game.System = "SAT"; game.System = "SAT";
@ -549,21 +549,21 @@ namespace BizHawk.Client.Common
case DiscType.PCFX: case DiscType.PCFX:
game.System = "PCFX"; game.System = "PCFX";
break; break;
case DiscType.TurboCD: case DiscType.TurboCD:
game.System = "PCECD"; game.System = "PCECD";
break; break;
case DiscType.Amiga: case DiscType.Amiga:
case DiscType.CDi: case DiscType.CDi:
case DiscType.Dreamcast: case DiscType.Dreamcast:
case DiscType.GameCube: case DiscType.GameCube:
case DiscType.NeoGeoCD: case DiscType.NeoGeoCD:
case DiscType.Panasonic3DO: case DiscType.Panasonic3DO:
case DiscType.Playdia: case DiscType.Playdia:
case DiscType.Wii: case DiscType.Wii:
// no supported emulator core for these (yet) // no supported emulator core for these (yet)
game.System = dt.ToString(); game.System = dt.ToString();
throw new NoAvailableCoreException(dt.ToString()); throw new NoAvailableCoreException(dt.ToString());
case DiscType.AudioDisc: case DiscType.AudioDisc:
case DiscType.UnknownCDFS: case DiscType.UnknownCDFS:
@ -574,7 +574,7 @@ namespace BizHawk.Client.Common
} }
else else
{ {
game.System = "NULL"; // "PCECD"; game.System = "NULL"; // "PCECD";
} }
break; break;
@ -583,9 +583,9 @@ namespace BizHawk.Client.Common
switch (game.System) switch (game.System)
{ {
case "NULL": case "NULL":
nextEmulator = null; nextEmulator = null;
break; break;
case "GEN": case "GEN":
var genesis = new GPGX(nextComm, null, new[] { disc }, GetCoreSettings<GPGX>(), GetCoreSyncSettings<GPGX>()); var genesis = new GPGX(nextComm, null, new[] { disc }, GetCoreSettings<GPGX>(), GetCoreSyncSettings<GPGX>());
nextEmulator = genesis; nextEmulator = genesis;
@ -731,38 +731,38 @@ namespace BizHawk.Client.Common
(C64.C64Settings)GetCoreSettings<C64>(), (C64.C64Settings)GetCoreSettings<C64>(),
(C64.C64SyncSettings)GetCoreSyncSettings<C64>()); (C64.C64SyncSettings)GetCoreSyncSettings<C64>());
break; break;
case "ZXSpectrum": case "ZXSpectrum":
List<GameInfo> zxGI = new List<GameInfo>(); List<GameInfo> zxGI = new List<GameInfo>();
foreach (var a in xmlGame.Assets) foreach (var a in xmlGame.Assets)
{ {
zxGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) }); zxGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) });
} }
nextEmulator = new ZXSpectrum( nextEmulator = new ZXSpectrum(
nextComm, nextComm,
xmlGame.Assets.Select(a => a.Value), //.First(), xmlGame.Assets.Select(a => a.Value), //.First(),
zxGI, // GameInfo.NullInstance, zxGI, // GameInfo.NullInstance,
(ZXSpectrum.ZXSpectrumSettings)GetCoreSettings<ZXSpectrum>(), (ZXSpectrum.ZXSpectrumSettings)GetCoreSettings<ZXSpectrum>(),
(ZXSpectrum.ZXSpectrumSyncSettings)GetCoreSyncSettings<ZXSpectrum>(), (ZXSpectrum.ZXSpectrumSyncSettings)GetCoreSyncSettings<ZXSpectrum>(),
Deterministic); Deterministic);
break; break;
case "AmstradCPC": case "AmstradCPC":
List<GameInfo> cpcGI = new List<GameInfo>(); List<GameInfo> cpcGI = new List<GameInfo>();
foreach (var a in xmlGame.Assets) foreach (var a in xmlGame.Assets)
{ {
cpcGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) }); cpcGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) });
} }
nextEmulator = new AmstradCPC( nextEmulator = new AmstradCPC(
nextComm, nextComm,
xmlGame.Assets.Select(a => a.Value), //.First(), xmlGame.Assets.Select(a => a.Value), //.First(),
cpcGI, // GameInfo.NullInstance, cpcGI, // GameInfo.NullInstance,
(AmstradCPC.AmstradCPCSettings)GetCoreSettings<AmstradCPC>(), (AmstradCPC.AmstradCPCSettings)GetCoreSettings<AmstradCPC>(),
(AmstradCPC.AmstradCPCSyncSettings)GetCoreSyncSettings<AmstradCPC>()); (AmstradCPC.AmstradCPCSyncSettings)GetCoreSyncSettings<AmstradCPC>());
break; break;
case "PSX": case "PSX":
var entries = xmlGame.AssetFullPaths; var entries = xmlGame.AssetFullPaths;
var discs = new List<Disc>(); var discs = new List<Disc>();
var discNames = new List<string>(); var discNames = new List<string>();
@ -1127,23 +1127,23 @@ namespace BizHawk.Client.Common
var c64 = new C64(nextComm, Enumerable.Repeat(rom.FileData, 1), rom.GameInfo, GetCoreSettings<C64>(), GetCoreSyncSettings<C64>()); var c64 = new C64(nextComm, Enumerable.Repeat(rom.FileData, 1), rom.GameInfo, GetCoreSettings<C64>(), GetCoreSyncSettings<C64>());
nextEmulator = c64; nextEmulator = c64;
break; break;
case "ZXSpectrum": case "ZXSpectrum":
var zx = new ZXSpectrum(nextComm, var zx = new ZXSpectrum(nextComm,
Enumerable.Repeat(rom.RomData, 1), Enumerable.Repeat(rom.RomData, 1),
Enumerable.Repeat(rom.GameInfo, 1).ToList(), Enumerable.Repeat(rom.GameInfo, 1).ToList(),
GetCoreSettings<ZXSpectrum>(), GetCoreSettings<ZXSpectrum>(),
GetCoreSyncSettings<ZXSpectrum>(), GetCoreSyncSettings<ZXSpectrum>(),
Deterministic); Deterministic);
nextEmulator = zx; nextEmulator = zx;
break; break;
case "ChannelF": case "ChannelF":
nextEmulator = new ChannelF(nextComm, game, rom.FileData, GetCoreSettings<ChannelF>(), GetCoreSyncSettings<ChannelF>()); nextEmulator = new ChannelF(nextComm, game, rom.FileData, GetCoreSettings<ChannelF>(), GetCoreSyncSettings<ChannelF>());
break; break;
case "AmstradCPC": case "AmstradCPC":
var cpc = new AmstradCPC(nextComm, Enumerable.Repeat(rom.RomData, 1), Enumerable.Repeat(rom.GameInfo, 1).ToList(), GetCoreSettings<AmstradCPC>(), GetCoreSyncSettings<AmstradCPC>()); var cpc = new AmstradCPC(nextComm, Enumerable.Repeat(rom.RomData, 1), Enumerable.Repeat(rom.GameInfo, 1).ToList(), GetCoreSettings<AmstradCPC>(), GetCoreSyncSettings<AmstradCPC>());
nextEmulator = cpc; nextEmulator = cpc;
break; break;
case "GBA": case "GBA":
if (Global.Config.GBA_UsemGBA) if (Global.Config.GBA_UsemGBA)
{ {
core = CoreInventory.Instance["GBA", "mGBA"]; core = CoreInventory.Instance["GBA", "mGBA"];
@ -1235,13 +1235,13 @@ namespace BizHawk.Client.Common
return LoadRom(path, nextComm, false, recursiveCount + 1); return LoadRom(path, nextComm, false, recursiveCount + 1);
} }
// handle exceptions thrown by the new detected systems that bizhawk does not have cores for // handle exceptions thrown by the new detected systems that bizhawk does not have cores for
else if (ex is NoAvailableCoreException) else if (ex is NoAvailableCoreException)
{ {
DoLoadErrorCallback($"{ex.Message}\n\n{ex}", system); DoLoadErrorCallback($"{ex.Message}\n\n{ex}", system);
} }
else else
{ {
DoLoadErrorCallback($"A core accepted the rom, but threw an exception while loading it:\n\n{ex}", system); DoLoadErrorCallback($"A core accepted the rom, but threw an exception while loading it:\n\n{ex}", system);
} }

View File

@ -203,15 +203,15 @@ namespace BizHawk.Client.Common
/// </summary> /// </summary>
public static SystemInfo NeoGeoPocket { get; } = new SystemInfo("Neo-Geo Pocket", CoreSystem.NeoGeoPocket, 1); public static SystemInfo NeoGeoPocket { get; } = new SystemInfo("Neo-Geo Pocket", CoreSystem.NeoGeoPocket, 1);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for ZXSpectrum /// Gets the <see cref="SystemInfo"/> instance for ZXSpectrum
/// </summary> /// </summary>
public static SystemInfo ZXSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2); public static SystemInfo ZXSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for AmstradCPC /// Gets the <see cref="SystemInfo"/> instance for AmstradCPC
/// </summary> /// </summary>
public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2); public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2);
/// <summary> /// <summary>
/// Gets the <see cref="SystemInfo"/> instance for GGL /// Gets the <see cref="SystemInfo"/> instance for GGL

View File

@ -83,12 +83,12 @@ namespace BizHawk.Client.Common
{ {
if (hf.IsArchive) if (hf.IsArchive)
{ {
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First()); var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
hf.Unbind(); hf.Unbind();
hf.BindArchiveMember(archiveItem); hf.BindArchiveMember(archiveItem);
data = hf.GetStream().ReadAllBytes(); data = hf.GetStream().ReadAllBytes();
filename = filename.Split('|').Skip(1).First(); filename = filename.Split('|').Skip(1).First();
} }
else else
{ {

View File

@ -295,19 +295,19 @@ namespace BizHawk.Client.Common
new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, new PathEntry { System = "C64", SystemDisplayName = "Commodore 64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Base", Path = Path.Combine(".", "ZXSpectrum"), Ordinal = 0 }, new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Base", Path = Path.Combine(".", "ZXSpectrum"), Ordinal = 0 },
new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "ROM", Path = ".", Ordinal = 1 }, new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, new PathEntry { System = "ZXSpectrum", SystemDisplayName = "Sinclair ZX Spectrum", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Base", Path = Path.Combine(".", "AmstradCPC"), Ordinal = 0 }, new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Base", Path = Path.Combine(".", "AmstradCPC"), Ordinal = 0 },
new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "ROM", Path = ".", Ordinal = 1 }, new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, new PathEntry { System = "AmstradCPC", SystemDisplayName = "Amstrad CPC", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Base", Path = Path.Combine(".", "PSX"), Ordinal = 0 }, new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Base", Path = Path.Combine(".", "PSX"), Ordinal = 0 },
new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "ROM", Path = ".", Ordinal = 1 }, new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },

View File

@ -61,18 +61,18 @@ namespace BizHawk.Client.Common
["C64_DREAN"] = PALNCarrier * 2 / 7 / 312 / 65, ["C64_DREAN"] = PALNCarrier * 2 / 7 / 312 / 65,
["INTV"] = 59.92, ["INTV"] = 59.92,
["ZXSpectrum_PAL"] = 50.080128205, ["ZXSpectrum_PAL"] = 50.080128205,
["AmstradCPC_PAL"] = 50.08012820512821, ["AmstradCPC_PAL"] = 50.08012820512821,
// according to ryphecha, using // according to ryphecha, using
// clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console // clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console
// lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced // lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced
// cpl[2] = { 3412.5, 3405 }; //ntsc mode, pal mode // cpl[2] = { 3412.5, 3405 }; //ntsc mode, pal mode
// PAL PS1: 0, PAL Mode: 0, Interlaced: 0 --- 59.826106 (53.693182e06/(263*3412.5)) // PAL PS1: 0, PAL Mode: 0, Interlaced: 0 --- 59.826106 (53.693182e06/(263*3412.5))
// PAL PS1: 0, PAL Mode: 0, Interlaced: 1 --- 59.940060 (53.693182e06/(262.5*3412.5)) // PAL PS1: 0, PAL Mode: 0, Interlaced: 1 --- 59.940060 (53.693182e06/(262.5*3412.5))
// PAL PS1: 1, PAL Mode: 1, Interlaced: 0 --- 49.761427 (53.203425e06/(314*3405)) // PAL PS1: 1, PAL Mode: 1, Interlaced: 0 --- 49.761427 (53.203425e06/(314*3405))
// PAL PS1: 1, PAL Mode: 1, Interlaced: 1 --- 50.000282(53.203425e06/(312.5*3405)) // PAL PS1: 1, PAL Mode: 1, Interlaced: 1 --- 50.000282(53.203425e06/(312.5*3405))
}; };
public double this[string systemId, bool pal] public double this[string systemId, bool pal]
{ {

View File

@ -282,7 +282,7 @@ namespace BizHawk.Client.Common
["Cursor Left/Right"] = 'l', ["Cursor Left/Right"] = 'l',
["Space"] = '_' ["Space"] = '_'
}, },
["ZXSpectrum"] = new Dictionary<string, char> ["ZXSpectrum"] = new Dictionary<string, char>
{ {
["Caps Shift"] = '^', ["Caps Shift"] = '^',
["Caps Lock"] = 'L', ["Caps Lock"] = 'L',
@ -311,13 +311,13 @@ namespace BizHawk.Client.Common
["Insert Previous Disk"] = '{', ["Insert Previous Disk"] = '{',
["Get Disk Status"] = 's', ["Get Disk Status"] = 's',
["Return"] = 'e', ["Return"] = 'e',
["Space"] = '-', ["Space"] = '-',
["Up Cursor"] = 'u', ["Up Cursor"] = 'u',
["Down Cursor"] = 'd', ["Down Cursor"] = 'd',
["Left Cursor"] = 'l', ["Left Cursor"] = 'l',
["Right Cursor"] = 'r' ["Right Cursor"] = 'r'
}, },
["N64"] = new Dictionary<string, char> ["N64"] = new Dictionary<string, char>
{ {
["C Up"] = 'u', ["C Up"] = 'u',
["C Down"] = 'd', ["C Down"] = 'd',

View File

@ -47,7 +47,7 @@ namespace BizHawk.Client.Common
WasLagged = _lagLog.History(index + 1) WasLagged = _lagLog.History(index + 1)
}; };
public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null) public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null)
: base(path) : base(path)
{ {
// TODO: how to call the default constructor AND the base(path) constructor? And is base(path) calling base() ? // TODO: how to call the default constructor AND the base(path) constructor? And is base(path) calling base() ?

View File

@ -237,11 +237,11 @@ namespace BizHawk.Client.Common
public int Count => _watchList.Count; public int Count => _watchList.Count;
public Settings.SearchMode Mode => _settings.Mode; public Settings.SearchMode Mode => _settings.Mode;
public MemoryDomain Domain => _settings.Domain; public MemoryDomain Domain => _settings.Domain;
public Compare CompareTo public Compare CompareTo
{ {
get get
{ {

View File

@ -53,10 +53,10 @@ namespace BizHawk.Client.Common
/// </summary> /// </summary>
public override int Previous => 0; public override int Previous => 0;
/// <summary> /// <summary>
/// Ignore that stuff /// Ignore that stuff
/// </summary> /// </summary>
public override string ValueString => Notes; //""; public override string ValueString => Notes; //"";
/// <summary> /// <summary>
/// Ignore that stuff /// Ignore that stuff

View File

@ -64,10 +64,10 @@ namespace BizHawk.Client.EmuHawk
{ {
DrawFinish(); DrawFinish();
_GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true); _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true);
} }
catch (InvalidOperationException ex) catch (InvalidOperationException ex)
{ {
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
} }
@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
} }
_GUISurface = null; _GUISurface = null;
} }
#endregion #endregion
#region Helpers #region Helpers
@ -149,13 +149,13 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage(message); GlobalWin.OSD.AddMessage(message);
} }
public void ClearGraphics() public void ClearGraphics()
{ {
_GUISurface.Clear(); _GUISurface.Clear();
DrawFinish(); DrawFinish();
} }
public void ClearText() public void ClearText()
{ {
GlobalWin.OSD.ClearGUIText(); GlobalWin.OSD.ClearGUIText();
} }
@ -571,53 +571,53 @@ namespace BizHawk.Client.EmuHawk
} }
public void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null) public void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null)
{ {
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
try try
{ {
var index = 0; var index = 0;
if (string.IsNullOrEmpty(fontfamily)) if (string.IsNullOrEmpty(fontfamily))
{ {
index = _defaultPixelFont; index = _defaultPixelFont;
} }
else else
{ {
switch (fontfamily) switch (fontfamily)
{ {
case "fceux": case "fceux":
case "0": case "0":
index = 0; index = 0;
break; break;
case "gens": case "gens":
case "1": case "1":
index = 1; index = 1;
break; break;
default: default:
Console.WriteLine($"Unable to find font family: {fontfamily}"); Console.WriteLine($"Unable to find font family: {fontfamily}");
return; return;
} }
} }
var f = new StringFormat(StringFormat.GenericTypographic) var f = new StringFormat(StringFormat.GenericTypographic)
{ {
FormatFlags = StringFormatFlags.MeasureTrailingSpaces FormatFlags = StringFormatFlags.MeasureTrailingSpaces
}; };
var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel); var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel);
Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize();
var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0)); var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0));
if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect); if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y);
} }
catch (Exception) catch (Exception)
{ {
return; return;
} }
} }
} }
public void Text(int x, int y, string message, Color? forecolor = null, string anchor = null) public void Text(int x, int y, string message, Color? forecolor = null, string anchor = null)
{ {
var a = 0; var a = 0;

View File

@ -21,47 +21,47 @@ namespace BizHawk.Client.EmuHawk
{ {
_settings = ((AmstradCPC)Global.Emulator).GetSettings().Clone(); _settings = ((AmstradCPC)Global.Emulator).GetSettings().Clone();
// AY panning config // AY panning config
var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig));
foreach (var val in panTypes) foreach (var val in panTypes)
{ {
panTypecomboBox1.Items.Add(val); panTypecomboBox1.Items.Add(val);
} }
panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString(); panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString();
// tape volume // tape volume
tapeVolumetrackBar.Value = _settings.TapeVolume; tapeVolumetrackBar.Value = _settings.TapeVolume;
// ay volume // ay volume
ayVolumetrackBar.Value = _settings.AYVolume; ayVolumetrackBar.Value = _settings.AYVolume;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString() _settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString()
|| _settings.TapeVolume != tapeVolumetrackBar.Value || _settings.TapeVolume != tapeVolumetrackBar.Value
|| _settings.AYVolume != ayVolumetrackBar.Value; || _settings.AYVolume != ayVolumetrackBar.Value;
if (changed) if (changed)
{ {
_settings.AYPanConfig = (AY38912.AYPanConfig)Enum.Parse(typeof(AY38912.AYPanConfig), panTypecomboBox1.SelectedItem.ToString()); _settings.AYPanConfig = (AY38912.AYPanConfig)Enum.Parse(typeof(AY38912.AYPanConfig), panTypecomboBox1.SelectedItem.ToString());
_settings.TapeVolume = tapeVolumetrackBar.Value; _settings.TapeVolume = tapeVolumetrackBar.Value;
_settings.AYVolume = ayVolumetrackBar.Value; _settings.AYVolume = ayVolumetrackBar.Value;
GlobalWin.MainForm.PutCoreSettings(_settings); GlobalWin.MainForm.PutCoreSettings(_settings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -70,5 +70,5 @@ namespace BizHawk.Client.EmuHawk
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -22,56 +22,56 @@ namespace BizHawk.Client.EmuHawk
{ {
_syncSettings = ((AmstradCPC)Global.Emulator).GetSyncSettings().Clone(); _syncSettings = ((AmstradCPC)Global.Emulator).GetSyncSettings().Clone();
// machine selection // machine selection
var machineTypes = Enum.GetNames(typeof(MachineType)); var machineTypes = Enum.GetNames(typeof(MachineType));
foreach (var val in machineTypes) foreach (var val in machineTypes)
{ {
MachineSelectionComboBox.Items.Add(val); MachineSelectionComboBox.Items.Add(val);
} }
MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString();
UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()));
// border selecton // border selecton
var borderTypes = Enum.GetNames(typeof(AmstradCPC.BorderType)); var borderTypes = Enum.GetNames(typeof(AmstradCPC.BorderType));
foreach (var val in borderTypes) foreach (var val in borderTypes)
{ {
borderTypecomboBox1.Items.Add(val); borderTypecomboBox1.Items.Add(val);
} }
borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString(); borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString();
UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString())); UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString()));
// deterministic emulation // deterministic emulation
determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation; determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation;
// autoload tape // autoload tape
autoLoadcheckBox1.Checked = _syncSettings.AutoStartStopTape; autoLoadcheckBox1.Checked = _syncSettings.AutoStartStopTape;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString() _syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString()
|| _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString() || _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString()
|| _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked || _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked
|| _syncSettings.AutoStartStopTape != autoLoadcheckBox1.Checked; || _syncSettings.AutoStartStopTape != autoLoadcheckBox1.Checked;
if (changed) if (changed)
{ {
_syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()); _syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString());
_syncSettings.BorderType = (AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString()); _syncSettings.BorderType = (AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString());
_syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked;
_syncSettings.AutoStartStopTape = autoLoadcheckBox1.Checked; _syncSettings.AutoStartStopTape = autoLoadcheckBox1.Checked;
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -81,38 +81,38 @@ namespace BizHawk.Client.EmuHawk
Close(); Close();
} }
private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{ {
ComboBox cb = sender as ComboBox; ComboBox cb = sender as ComboBox;
UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString()));
} }
private void UpdateMachineNotes(MachineType type) private void UpdateMachineNotes(MachineType type)
{ {
textBoxMachineNotes.Text = CPCMachineMetaData.GetMetaString(type); textBoxMachineNotes.Text = CPCMachineMetaData.GetMetaString(type);
} }
private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e)
{ {
ComboBox cb = sender as ComboBox; ComboBox cb = sender as ComboBox;
UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), cb.SelectedItem.ToString())); UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), cb.SelectedItem.ToString()));
} }
private void UpdateBorderNotes(AmstradCPC.BorderType type) private void UpdateBorderNotes(AmstradCPC.BorderType type)
{ {
switch (type) switch (type)
{ {
case AmstradCPC.BorderType.Uniform: case AmstradCPC.BorderType.Uniform:
lblBorderInfo.Text = "Attempts to equalise the border areas"; lblBorderInfo.Text = "Attempts to equalise the border areas";
break; break;
case AmstradCPC.BorderType.Uncropped: case AmstradCPC.BorderType.Uncropped:
lblBorderInfo.Text = "Pretty much the signal the gate array is generating (looks pants)"; lblBorderInfo.Text = "Pretty much the signal the gate array is generating (looks pants)";
break; break;
case AmstradCPC.BorderType.Widescreen: case AmstradCPC.BorderType.Widescreen:
lblBorderInfo.Text = "Top and bottom border removed so that the result is *almost* 16:9"; lblBorderInfo.Text = "Top and bottom border removed so that the result is *almost* 16:9";
break; break;
} }
} }
} }
} }

View File

@ -23,35 +23,35 @@ namespace BizHawk.Client.EmuHawk
// OSD Message Verbosity // OSD Message Verbosity
var osdTypes = Enum.GetNames(typeof(AmstradCPC.OSDVerbosity)); var osdTypes = Enum.GetNames(typeof(AmstradCPC.OSDVerbosity));
foreach (var val in osdTypes) foreach (var val in osdTypes)
{ {
osdMessageVerbositycomboBox1.Items.Add(val); osdMessageVerbositycomboBox1.Items.Add(val);
} }
osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString(); osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString();
UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString())); UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()));
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString(); _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString();
if (changed) if (changed)
{ {
_settings.OSDMessageVerbosity = (AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()); _settings.OSDMessageVerbosity = (AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString());
GlobalWin.MainForm.PutCoreSettings(_settings); GlobalWin.MainForm.PutCoreSettings(_settings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -61,26 +61,26 @@ namespace BizHawk.Client.EmuHawk
Close(); Close();
} }
private void UpdateOSDNotes(AmstradCPC.OSDVerbosity type) private void UpdateOSDNotes(AmstradCPC.OSDVerbosity type)
{ {
switch (type) switch (type)
{ {
case AmstradCPC.OSDVerbosity.Full: case AmstradCPC.OSDVerbosity.Full:
lblOSDVerbinfo.Text = "Show all OSD messages"; lblOSDVerbinfo.Text = "Show all OSD messages";
break; break;
case AmstradCPC.OSDVerbosity.Medium: case AmstradCPC.OSDVerbosity.Medium:
lblOSDVerbinfo.Text = "Only show machine/device generated messages"; lblOSDVerbinfo.Text = "Only show machine/device generated messages";
break; break;
case AmstradCPC.OSDVerbosity.None: case AmstradCPC.OSDVerbosity.None:
lblOSDVerbinfo.Text = "No core-driven OSD messages"; lblOSDVerbinfo.Text = "No core-driven OSD messages";
break; break;
} }
} }
private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{ {
ComboBox cb = sender as ComboBox; ComboBox cb = sender as ComboBox;
UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), cb.SelectedItem.ToString())); UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), cb.SelectedItem.ToString()));
} }
} }
} }

View File

@ -17,14 +17,14 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var ams = (AmstradCPC)Global.Emulator; var ams = (AmstradCPC)Global.Emulator;
var addr = (ushort)numericUpDownAddress.Value; var addr = (ushort)numericUpDownAddress.Value;
var val = (byte)numericUpDownByte.Value; var val = (byte)numericUpDownByte.Value;
ams.PokeMemory(addr, val); ams.PokeMemory(addr, val);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -33,5 +33,5 @@ namespace BizHawk.Client.EmuHawk
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -181,26 +181,26 @@ namespace BizHawk.Client.EmuHawk
tt.TabPages.Add(tabname); tt.TabPages.Add(tabname);
tt.TabPages[pageidx].Controls.Add(createpanel(settings, cat.Value, tt.Size)); tt.TabPages[pageidx].Controls.Add(createpanel(settings, cat.Value, tt.Size));
// zxhawk hack - it uses multiple categoryLabels // zxhawk hack - it uses multiple categoryLabels
if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF")
pageidx++; pageidx++;
} }
if (buckets[0].Count > 0) if (buckets[0].Count > 0)
{ {
// ZXHawk needs to skip this bit // ZXHawk needs to skip this bit
if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF")
return; return;
string tabname = string tabname =
(Global.Emulator.SystemId == "C64") ? "Keyboard" : (Global.Emulator.SystemId == "C64") ? "Keyboard" :
(Global.Emulator.SystemId == "MAME") ? "Misc" : (Global.Emulator.SystemId == "MAME") ? "Misc" :
"Console"; // hack "Console"; // hack
tt.TabPages.Add(tabname); tt.TabPages.Add(tabname);
tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size)); tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size));
} }
} }
} }
public ControllerConfig(ControllerDefinition def) public ControllerConfig(ControllerDefinition def)
@ -277,27 +277,27 @@ namespace BizHawk.Client.EmuHawk
pictureBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; pictureBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
} }
if (controlName == "ZXSpectrum Controller") if (controlName == "ZXSpectrum Controller")
{ {
pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards; pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards;
pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size; pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size;
tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width;
} }
if (controlName == "ChannelF Controller") if (controlName == "ChannelF Controller")
{ {
} }
if (controlName == "AmstradCPC Controller") if (controlName == "AmstradCPC Controller")
{ {
/* /*
pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards; pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards;
pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size; pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size;
tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width;
*/ */
} }
} }
// lazy methods, but they're not called often and actually // lazy methods, but they're not called often and actually
// tracking all of the ControllerConfigPanels wouldn't be simpler // tracking all of the ControllerConfigPanels wouldn't be simpler

View File

@ -52,8 +52,8 @@ namespace BizHawk.Client.EmuHawk
{ "GBC", "Game Boy Color" }, { "GBC", "Game Boy Color" },
{ "PCFX", "PC-FX" }, { "PCFX", "PC-FX" },
{ "32X", "32X" }, { "32X", "32X" },
{ "ZXSpectrum", "ZX Spectrum" }, { "ZXSpectrum", "ZX Spectrum" },
{ "AmstradCPC", "Amstrad CPC" }, { "AmstradCPC", "Amstrad CPC" },
{ "ChannelF", "Channel F" }, { "ChannelF", "Channel F" },
{ "Vectrex", "Vectrex" } { "Vectrex", "Vectrex" }
}; };
@ -393,81 +393,81 @@ namespace BizHawk.Client.EmuHawk
{ {
ofd.InitialDirectory = currSelectorDir; ofd.InitialDirectory = currSelectorDir;
ofd.RestoreDirectory = true; ofd.RestoreDirectory = true;
string frmwarePath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null); string frmwarePath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
{ {
// remember the location we selected this firmware from, maybe there are others // remember the location we selected this firmware from, maybe there are others
currSelectorDir = Path.GetDirectoryName(ofd.FileName); currSelectorDir = Path.GetDirectoryName(ofd.FileName);
try try
{ {
using (var hf = new HawkFile(ofd.FileName)) using (var hf = new HawkFile(ofd.FileName))
{ {
// for each selected item, set the user choice (even though multiple selection for this operation is no longer allowed) // for each selected item, set the user choice (even though multiple selection for this operation is no longer allowed)
foreach (ListViewItem lvi in lvFirmwares.SelectedItems) foreach (ListViewItem lvi in lvFirmwares.SelectedItems)
{ {
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
string filePath = ofd.FileName; string filePath = ofd.FileName;
// if the selected file is an archive, allow the user to pick the inside file // if the selected file is an archive, allow the user to pick the inside file
// to always be copied to the global firmwares directory // to always be copied to the global firmwares directory
if (hf.IsArchive) if (hf.IsArchive)
{ {
var ac = new ArchiveChooser(new HawkFile(filePath)); var ac = new ArchiveChooser(new HawkFile(filePath));
int memIdx = -1; int memIdx = -1;
if (ac.ShowDialog(this) == DialogResult.OK) if (ac.ShowDialog(this) == DialogResult.OK)
{ {
memIdx = ac.SelectedMemberIndex; memIdx = ac.SelectedMemberIndex;
} }
else else
{ {
return; return;
} }
var insideFile = hf.BindArchiveMember(memIdx); var insideFile = hf.BindArchiveMember(memIdx);
var fileData = insideFile.ReadAllBytes(); var fileData = insideFile.ReadAllBytes();
// write to file in the firmwares folder // write to file in the firmwares folder
File.WriteAllBytes(Path.Combine(frmwarePath, insideFile.Name), fileData); File.WriteAllBytes(Path.Combine(frmwarePath, insideFile.Name), fileData);
filePath = Path.Combine(frmwarePath, insideFile.Name); filePath = Path.Combine(frmwarePath, insideFile.Name);
} }
else else
{ {
// selected file is not an archive // selected file is not an archive
// check whether this file is currently outside of the global firmware directory // check whether this file is currently outside of the global firmware directory
if (currSelectorDir != frmwarePath) if (currSelectorDir != frmwarePath)
{ {
var askMoveResult = MessageBox.Show(this, "The selected custom firmware does not reside in the root of the global firmware directory.\nDo you want to copy it there?", "Import Custom Firmware", MessageBoxButtons.YesNo); var askMoveResult = MessageBox.Show(this, "The selected custom firmware does not reside in the root of the global firmware directory.\nDo you want to copy it there?", "Import Custom Firmware", MessageBoxButtons.YesNo);
if (askMoveResult == DialogResult.Yes) if (askMoveResult == DialogResult.Yes)
{ {
try try
{ {
FileInfo fi = new FileInfo(filePath); FileInfo fi = new FileInfo(filePath);
filePath = Path.Combine(frmwarePath, fi.Name); filePath = Path.Combine(frmwarePath, fi.Name);
File.Copy(ofd.FileName, filePath); File.Copy(ofd.FileName, filePath);
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(this, $"There was an issue copying the file. The customization has NOT been set.\n\n{ex.StackTrace}"); MessageBox.Show(this, $"There was an issue copying the file. The customization has NOT been set.\n\n{ex.StackTrace}");
continue; continue;
} }
} }
} }
} }
Global.Config.FirmwareUserSpecifications[fr.ConfigKey] = filePath; Global.Config.FirmwareUserSpecifications[fr.ConfigKey] = filePath;
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(this, $"There was an issue during the process. The customization has NOT been set.\n\n{ex.StackTrace}"); MessageBox.Show(this, $"There was an issue during the process. The customization has NOT been set.\n\n{ex.StackTrace}");
return; return;
} }
DoScan(); DoScan();
} }
} }
} }
@ -673,10 +673,10 @@ namespace BizHawk.Client.EmuHawk
File.WriteAllBytes(outfile, ms.ToArray()); File.WriteAllBytes(outfile, ms.ToArray());
hf.Unbind(); hf.Unbind();
if (cbAllowImport.Checked || Manager.CanFileBeImported(outfile)) if (cbAllowImport.Checked || Manager.CanFileBeImported(outfile))
{ {
didSomething |= RunImportJobSingle(basepath, outfile, ref errors); didSomething |= RunImportJobSingle(basepath, outfile, ref errors);
} }
} }
} }
finally finally
@ -686,10 +686,10 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (cbAllowImport.Checked || Manager.CanFileBeImported(hf.CanonicalFullPath)) if (cbAllowImport.Checked || Manager.CanFileBeImported(hf.CanonicalFullPath))
{ {
didSomething |= RunImportJobSingle(basepath, f, ref errors); didSomething |= RunImportJobSingle(basepath, f, ref errors);
} }
} }
} }
} }
@ -716,7 +716,7 @@ namespace BizHawk.Client.EmuHawk
return base.ProcessCmdKey(ref msg, keyData); return base.ProcessCmdKey(ref msg, keyData);
} }
private void lvFirmwares_DragEnter(object sender, DragEventArgs e) private void lvFirmwares_DragEnter(object sender, DragEventArgs e)
{ {
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
} }

View File

@ -21,52 +21,52 @@ namespace BizHawk.Client.EmuHawk
{ {
_settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone(); _settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone();
// AY panning config // AY panning config
var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig));
foreach (var val in panTypes) foreach (var val in panTypes)
{ {
panTypecomboBox1.Items.Add(val); panTypecomboBox1.Items.Add(val);
} }
panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString(); panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString();
// tape volume // tape volume
tapeVolumetrackBar.Value = _settings.TapeVolume; tapeVolumetrackBar.Value = _settings.TapeVolume;
// ear volume // ear volume
earVolumetrackBar.Value = _settings.EarVolume; earVolumetrackBar.Value = _settings.EarVolume;
// ay volume // ay volume
ayVolumetrackBar.Value = _settings.AYVolume; ayVolumetrackBar.Value = _settings.AYVolume;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString() _settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString()
|| _settings.TapeVolume != tapeVolumetrackBar.Value || _settings.TapeVolume != tapeVolumetrackBar.Value
|| _settings.EarVolume != earVolumetrackBar.Value || _settings.EarVolume != earVolumetrackBar.Value
|| _settings.AYVolume != ayVolumetrackBar.Value; || _settings.AYVolume != ayVolumetrackBar.Value;
if (changed) if (changed)
{ {
_settings.AYPanConfig = (AY38912.AYPanConfig)Enum.Parse(typeof(AY38912.AYPanConfig), panTypecomboBox1.SelectedItem.ToString()); _settings.AYPanConfig = (AY38912.AYPanConfig)Enum.Parse(typeof(AY38912.AYPanConfig), panTypecomboBox1.SelectedItem.ToString());
_settings.TapeVolume = tapeVolumetrackBar.Value; _settings.TapeVolume = tapeVolumetrackBar.Value;
_settings.EarVolume = earVolumetrackBar.Value; _settings.EarVolume = earVolumetrackBar.Value;
_settings.AYVolume = ayVolumetrackBar.Value; _settings.AYVolume = ayVolumetrackBar.Value;
GlobalWin.MainForm.PutCoreSettings(_settings); GlobalWin.MainForm.PutCoreSettings(_settings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -75,5 +75,5 @@ namespace BizHawk.Client.EmuHawk
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -21,56 +21,56 @@ namespace BizHawk.Client.EmuHawk
{ {
_syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone(); _syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone();
// machine selection // machine selection
var machineTypes = Enum.GetNames(typeof(MachineType)); var machineTypes = Enum.GetNames(typeof(MachineType));
foreach (var val in machineTypes) foreach (var val in machineTypes)
{ {
MachineSelectionComboBox.Items.Add(val); MachineSelectionComboBox.Items.Add(val);
} }
MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString();
UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()));
// border selecton // border selecton
var borderTypes = Enum.GetNames(typeof(ZXSpectrum.BorderType)); var borderTypes = Enum.GetNames(typeof(ZXSpectrum.BorderType));
foreach (var val in borderTypes) foreach (var val in borderTypes)
{ {
borderTypecomboBox1.Items.Add(val); borderTypecomboBox1.Items.Add(val);
} }
borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString(); borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString();
UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString())); UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString()));
// deterministic emulation // deterministic emulation
determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation; determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation;
// autoload tape // autoload tape
autoLoadcheckBox1.Checked = _syncSettings.AutoLoadTape; autoLoadcheckBox1.Checked = _syncSettings.AutoLoadTape;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString() _syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString()
|| _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString() || _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString()
|| _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked || _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked
|| _syncSettings.AutoLoadTape != autoLoadcheckBox1.Checked; || _syncSettings.AutoLoadTape != autoLoadcheckBox1.Checked;
if (changed) if (changed)
{ {
_syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()); _syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString());
_syncSettings.BorderType = (ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString()); _syncSettings.BorderType = (ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString());
_syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked;
_syncSettings.AutoLoadTape = autoLoadcheckBox1.Checked; _syncSettings.AutoLoadTape = autoLoadcheckBox1.Checked;
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -80,43 +80,43 @@ namespace BizHawk.Client.EmuHawk
Close(); Close();
} }
private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{ {
ComboBox cb = sender as ComboBox; ComboBox cb = sender as ComboBox;
UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString()));
} }
private void UpdateMachineNotes(MachineType type) private void UpdateMachineNotes(MachineType type)
{ {
textBoxCoreDetails.Text = ZXMachineMetaData.GetMetaString(type); textBoxCoreDetails.Text = ZXMachineMetaData.GetMetaString(type);
} }
private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e)
{ {
ComboBox cb = sender as ComboBox; ComboBox cb = sender as ComboBox;
UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), cb.SelectedItem.ToString())); UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), cb.SelectedItem.ToString()));
} }
private void UpdateBorderNotes(ZXSpectrum.BorderType type) private void UpdateBorderNotes(ZXSpectrum.BorderType type)
{ {
switch (type) switch (type)
{ {
case ZXSpectrum.BorderType.Full: case ZXSpectrum.BorderType.Full:
lblBorderInfo.Text = "Original border sizes"; lblBorderInfo.Text = "Original border sizes";
break; break;
case ZXSpectrum.BorderType.Medium: case ZXSpectrum.BorderType.Medium:
lblBorderInfo.Text = "All borders 24px"; lblBorderInfo.Text = "All borders 24px";
break; break;
case ZXSpectrum.BorderType.None: case ZXSpectrum.BorderType.None:
lblBorderInfo.Text = "No border at all"; lblBorderInfo.Text = "No border at all";
break; break;
case ZXSpectrum.BorderType.Small: case ZXSpectrum.BorderType.Small:
lblBorderInfo.Text = "All borders 10px"; lblBorderInfo.Text = "All borders 10px";
break; break;
case ZXSpectrum.BorderType.Widescreen: case ZXSpectrum.BorderType.Widescreen:
lblBorderInfo.Text = "No top and bottom border (almost 16:9)"; lblBorderInfo.Text = "No top and bottom border (almost 16:9)";
break; break;
} }
} }
} }
} }

View File

@ -16,105 +16,105 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
private string[] possibleControllers; private string[] possibleControllers;
private void IntvControllerSettings_Load(object sender, EventArgs e) private void IntvControllerSettings_Load(object sender, EventArgs e)
{ {
_syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone(); _syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone();
possibleControllers = Enum.GetNames(typeof(JoystickType)); possibleControllers = Enum.GetNames(typeof(JoystickType));
foreach (var val in possibleControllers) foreach (var val in possibleControllers)
{ {
Port1ComboBox.Items.Add(val); Port1ComboBox.Items.Add(val);
Port2ComboBox.Items.Add(val); Port2ComboBox.Items.Add(val);
Port3ComboBox.Items.Add(val); Port3ComboBox.Items.Add(val);
} }
Port1ComboBox.SelectedItem = _syncSettings.JoystickType1.ToString(); Port1ComboBox.SelectedItem = _syncSettings.JoystickType1.ToString();
Port2ComboBox.SelectedItem = _syncSettings.JoystickType2.ToString(); Port2ComboBox.SelectedItem = _syncSettings.JoystickType2.ToString();
Port3ComboBox.SelectedItem = _syncSettings.JoystickType3.ToString(); Port3ComboBox.SelectedItem = _syncSettings.JoystickType3.ToString();
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_syncSettings.JoystickType1.ToString() != Port1ComboBox.SelectedItem.ToString() _syncSettings.JoystickType1.ToString() != Port1ComboBox.SelectedItem.ToString()
|| _syncSettings.JoystickType2.ToString() != Port2ComboBox.SelectedItem.ToString() || _syncSettings.JoystickType2.ToString() != Port2ComboBox.SelectedItem.ToString()
|| _syncSettings.JoystickType3.ToString() != Port3ComboBox.SelectedItem.ToString(); || _syncSettings.JoystickType3.ToString() != Port3ComboBox.SelectedItem.ToString();
if (changed) if (changed)
{ {
// enforce unique joystick selection // enforce unique joystick selection
bool selectionValid = true; bool selectionValid = true;
var j1 = Port1ComboBox.SelectedItem.ToString(); var j1 = Port1ComboBox.SelectedItem.ToString();
if (j1 != possibleControllers.First()) if (j1 != possibleControllers.First())
{ {
if (j1 == Port2ComboBox.SelectedItem.ToString()) if (j1 == Port2ComboBox.SelectedItem.ToString())
{ {
Port2ComboBox.SelectedItem = possibleControllers.First(); Port2ComboBox.SelectedItem = possibleControllers.First();
selectionValid = false; selectionValid = false;
} }
if (j1 == Port3ComboBox.SelectedItem.ToString()) if (j1 == Port3ComboBox.SelectedItem.ToString())
{ {
Port3ComboBox.SelectedItem = possibleControllers.First(); Port3ComboBox.SelectedItem = possibleControllers.First();
selectionValid = false; selectionValid = false;
} }
} }
var j2 = Port2ComboBox.SelectedItem.ToString(); var j2 = Port2ComboBox.SelectedItem.ToString();
if (j2 != possibleControllers.First()) if (j2 != possibleControllers.First())
{ {
if (j2 == Port1ComboBox.SelectedItem.ToString()) if (j2 == Port1ComboBox.SelectedItem.ToString())
{ {
Port1ComboBox.SelectedItem = possibleControllers.First(); Port1ComboBox.SelectedItem = possibleControllers.First();
selectionValid = false; selectionValid = false;
} }
if (j2 == Port3ComboBox.SelectedItem.ToString()) if (j2 == Port3ComboBox.SelectedItem.ToString())
{ {
Port3ComboBox.SelectedItem = possibleControllers.First(); Port3ComboBox.SelectedItem = possibleControllers.First();
selectionValid = false; selectionValid = false;
} }
} }
var j3 = Port3ComboBox.SelectedItem.ToString(); var j3 = Port3ComboBox.SelectedItem.ToString();
if (j3 != possibleControllers.First()) if (j3 != possibleControllers.First())
{ {
if (j3 == Port1ComboBox.SelectedItem.ToString()) if (j3 == Port1ComboBox.SelectedItem.ToString())
{ {
Port1ComboBox.SelectedItem = possibleControllers.First(); Port1ComboBox.SelectedItem = possibleControllers.First();
selectionValid = false; selectionValid = false;
} }
if (j3 == Port2ComboBox.SelectedItem.ToString()) if (j3 == Port2ComboBox.SelectedItem.ToString())
{ {
Port2ComboBox.SelectedItem = possibleControllers.First(); Port2ComboBox.SelectedItem = possibleControllers.First();
selectionValid = false; selectionValid = false;
} }
} }
if (selectionValid) if (selectionValid)
{ {
_syncSettings.JoystickType1 = (JoystickType)Enum.Parse(typeof(JoystickType), Port1ComboBox.SelectedItem.ToString()); _syncSettings.JoystickType1 = (JoystickType)Enum.Parse(typeof(JoystickType), Port1ComboBox.SelectedItem.ToString());
_syncSettings.JoystickType2 = (JoystickType)Enum.Parse(typeof(JoystickType), Port2ComboBox.SelectedItem.ToString()); _syncSettings.JoystickType2 = (JoystickType)Enum.Parse(typeof(JoystickType), Port2ComboBox.SelectedItem.ToString());
_syncSettings.JoystickType3 = (JoystickType)Enum.Parse(typeof(JoystickType), Port3ComboBox.SelectedItem.ToString()); _syncSettings.JoystickType3 = (JoystickType)Enum.Parse(typeof(JoystickType), Port3ComboBox.SelectedItem.ToString());
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
else else
{ {
MessageBox.Show("Invalid joystick configuration. \nDuplicates have automatically been changed to NULL.\n\nPlease review the configuration"); MessageBox.Show("Invalid joystick configuration. \nDuplicates have automatically been changed to NULL.\n\nPlease review the configuration");
} }
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)

View File

@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
public partial class ZXSpectrumNonSyncSettings : Form public partial class ZXSpectrumNonSyncSettings : Form
{ {
private ZXSpectrum.ZXSpectrumSettings _settings; private ZXSpectrum.ZXSpectrumSettings _settings;
private int bgColor; private int bgColor;
public ZXSpectrumNonSyncSettings() public ZXSpectrumNonSyncSettings()
{ {
@ -22,52 +22,52 @@ namespace BizHawk.Client.EmuHawk
{ {
_settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone(); _settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone();
bgColor = _settings.BackgroundColor; bgColor = _settings.BackgroundColor;
SetBtnColor(); SetBtnColor();
checkBoxShowCoreBrdColor.Checked = _settings.UseCoreBorderForBackground; checkBoxShowCoreBrdColor.Checked = _settings.UseCoreBorderForBackground;
// OSD Message Verbosity // OSD Message Verbosity
var osdTypes = Enum.GetNames(typeof(ZXSpectrum.OSDVerbosity)); var osdTypes = Enum.GetNames(typeof(ZXSpectrum.OSDVerbosity));
foreach (var val in osdTypes) foreach (var val in osdTypes)
{ {
osdMessageVerbositycomboBox1.Items.Add(val); osdMessageVerbositycomboBox1.Items.Add(val);
} }
osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString(); osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString();
UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString())); UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()));
} }
private void SetBtnColor() private void SetBtnColor()
{ {
var c = System.Drawing.Color.FromArgb(bgColor); var c = System.Drawing.Color.FromArgb(bgColor);
buttonChooseBGColor.ForeColor = c; buttonChooseBGColor.ForeColor = c;
buttonChooseBGColor.BackColor = c; buttonChooseBGColor.BackColor = c;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = bool changed =
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() || _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() ||
_settings.BackgroundColor != bgColor || _settings.BackgroundColor != bgColor ||
_settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked; _settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked;
if (changed) if (changed)
{ {
_settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()); _settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString());
_settings.BackgroundColor = bgColor; _settings.BackgroundColor = bgColor;
_settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked; _settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked;
GlobalWin.MainForm.PutCoreSettings(_settings); GlobalWin.MainForm.PutCoreSettings(_settings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
}
else
{
DialogResult = DialogResult.OK;
Close();
} }
else
{
DialogResult = DialogResult.OK;
Close();
}
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -77,84 +77,84 @@ namespace BizHawk.Client.EmuHawk
Close(); Close();
} }
private void UpdateOSDNotes(ZXSpectrum.OSDVerbosity type) private void UpdateOSDNotes(ZXSpectrum.OSDVerbosity type)
{ {
switch (type) switch (type)
{ {
case ZXSpectrum.OSDVerbosity.Full: case ZXSpectrum.OSDVerbosity.Full:
lblOSDVerbinfo.Text = "Show all OSD messages"; lblOSDVerbinfo.Text = "Show all OSD messages";
break; break;
case ZXSpectrum.OSDVerbosity.Medium: case ZXSpectrum.OSDVerbosity.Medium:
lblOSDVerbinfo.Text = "Only show machine/device generated messages"; lblOSDVerbinfo.Text = "Only show machine/device generated messages";
break; break;
case ZXSpectrum.OSDVerbosity.None: case ZXSpectrum.OSDVerbosity.None:
lblOSDVerbinfo.Text = "No core-driven OSD messages"; lblOSDVerbinfo.Text = "No core-driven OSD messages";
break; break;
} }
} }
private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{ {
ComboBox cb = sender as ComboBox; ComboBox cb = sender as ComboBox;
UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString())); UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString()));
} }
private void buttonChooseBGColor_Click(object sender, EventArgs e) private void buttonChooseBGColor_Click(object sender, EventArgs e)
{ {
var currColor = _settings.BackgroundColor; var currColor = _settings.BackgroundColor;
System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor); System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor);
using var cd = new ColorDialog(); using var cd = new ColorDialog();
System.Drawing.Color[] colors = new System.Drawing.Color[] System.Drawing.Color[] colors = new System.Drawing.Color[]
{ {
System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), System.Drawing.Color.FromArgb(0x00, 0x00, 0x00),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7), System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7),
System.Drawing.Color.FromArgb(0xD7, 0x00, 0xD7), System.Drawing.Color.FromArgb(0xD7, 0x00, 0xD7),
System.Drawing.Color.FromArgb(0x00, 0xD7, 0x00), System.Drawing.Color.FromArgb(0x00, 0xD7, 0x00),
System.Drawing.Color.FromArgb(0x00, 0xD7, 0xD7), System.Drawing.Color.FromArgb(0x00, 0xD7, 0xD7),
System.Drawing.Color.FromArgb(0xD7, 0xD7, 0x00), System.Drawing.Color.FromArgb(0xD7, 0xD7, 0x00),
System.Drawing.Color.FromArgb(0xD7, 0xD7, 0xD7), System.Drawing.Color.FromArgb(0xD7, 0xD7, 0xD7),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF), System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF),
System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), System.Drawing.Color.FromArgb(0x00, 0x00, 0x00),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF), System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF),
System.Drawing.Color.FromArgb(0xFF, 0x00, 0x00), System.Drawing.Color.FromArgb(0xFF, 0x00, 0x00),
System.Drawing.Color.FromArgb(0xFF, 0x00, 0xFF), System.Drawing.Color.FromArgb(0xFF, 0x00, 0xFF),
System.Drawing.Color.FromArgb(0x00, 0xFF, 0x00), System.Drawing.Color.FromArgb(0x00, 0xFF, 0x00),
System.Drawing.Color.FromArgb(0x00, 0xFF, 0xFF), System.Drawing.Color.FromArgb(0x00, 0xFF, 0xFF),
System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00), System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00),
System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF), System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF),
}; };
cd.CustomColors = new int[] cd.CustomColors = new int[]
{ {
System.Drawing.ColorTranslator.ToOle(colors[0]), System.Drawing.ColorTranslator.ToOle(colors[0]),
System.Drawing.ColorTranslator.ToOle(colors[1]), System.Drawing.ColorTranslator.ToOle(colors[1]),
System.Drawing.ColorTranslator.ToOle(colors[2]), System.Drawing.ColorTranslator.ToOle(colors[2]),
System.Drawing.ColorTranslator.ToOle(colors[3]), System.Drawing.ColorTranslator.ToOle(colors[3]),
System.Drawing.ColorTranslator.ToOle(colors[4]), System.Drawing.ColorTranslator.ToOle(colors[4]),
System.Drawing.ColorTranslator.ToOle(colors[5]), System.Drawing.ColorTranslator.ToOle(colors[5]),
System.Drawing.ColorTranslator.ToOle(colors[6]), System.Drawing.ColorTranslator.ToOle(colors[6]),
System.Drawing.ColorTranslator.ToOle(colors[7]), System.Drawing.ColorTranslator.ToOle(colors[7]),
System.Drawing.ColorTranslator.ToOle(colors[8]), System.Drawing.ColorTranslator.ToOle(colors[8]),
System.Drawing.ColorTranslator.ToOle(colors[9]), System.Drawing.ColorTranslator.ToOle(colors[9]),
System.Drawing.ColorTranslator.ToOle(colors[10]), System.Drawing.ColorTranslator.ToOle(colors[10]),
System.Drawing.ColorTranslator.ToOle(colors[11]), System.Drawing.ColorTranslator.ToOle(colors[11]),
System.Drawing.ColorTranslator.ToOle(colors[12]), System.Drawing.ColorTranslator.ToOle(colors[12]),
System.Drawing.ColorTranslator.ToOle(colors[13]), System.Drawing.ColorTranslator.ToOle(colors[13]),
System.Drawing.ColorTranslator.ToOle(colors[14]), System.Drawing.ColorTranslator.ToOle(colors[14]),
System.Drawing.ColorTranslator.ToOle(colors[15]), System.Drawing.ColorTranslator.ToOle(colors[15]),
}; };
cd.Color = c; cd.Color = c;
if (cd.ShowDialog() == DialogResult.OK) if (cd.ShowDialog() == DialogResult.OK)
{ {
var color = cd.Color; var color = cd.Color;
var col = color.ToArgb(); var col = color.ToArgb();
bgColor = col; bgColor = col;
SetBtnColor(); SetBtnColor();
} }
} }
} }
} }

View File

@ -17,14 +17,14 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var speccy = (ZXSpectrum)Global.Emulator; var speccy = (ZXSpectrum)Global.Emulator;
var addr = (ushort)numericUpDownAddress.Value; var addr = (ushort)numericUpDownAddress.Value;
var val = (byte)numericUpDownByte.Value; var val = (byte)numericUpDownByte.Value;
speccy.PokeMemory(addr, val); speccy.PokeMemory(addr, val);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -33,5 +33,5 @@ namespace BizHawk.Client.EmuHawk
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -171,7 +171,7 @@ namespace BizHawk.Client.EmuHawk
private IEnumerable<int> SelectedIndices => BreakpointView.SelectedIndices.Cast<int>(); private IEnumerable<int> SelectedIndices => BreakpointView.SelectedIndices.Cast<int>();
private IEnumerable<Breakpoint> SelectedItems private IEnumerable<Breakpoint> SelectedItems
{ {
get { return SelectedIndices.Select(index => _breakpoints[index]); } get { return SelectedIndices.Select(index => _breakpoints[index]); }
} }

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk
[Tool(released: true, supportedSystems: new[] { "GB", "GBA", "GEN", "N64", "NES", "PSX", "SAT", "SMS", "SNES" }, [Tool(released: true, supportedSystems: new[] { "GB", "GBA", "GEN", "N64", "NES", "PSX", "SAT", "SMS", "SNES" },
unsupportedCores: new[] { "Snes9x" })] unsupportedCores: new[] { "Snes9x" })]
public partial class GameShark : Form, IToolForm, IToolFormAutoConfig public partial class GameShark : Form, IToolForm, IToolFormAutoConfig
{ {
#region " Game Genie Dictionary " #region " Game Genie Dictionary "

View File

@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
private void DoLuaClick(object sender, EventArgs e) private void DoLuaClick(object sender, EventArgs e)
{ {
LuaWinform parent = Parent as LuaWinform; LuaWinform parent = Parent as LuaWinform;
parent?.DoLuaEvent(Handle); parent?.DoLuaEvent(Handle);
} }
protected override void OnClick(EventArgs e) protected override void OnClick(EventArgs e)

View File

@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
private void DoLuaClick(object sender, EventArgs e) private void DoLuaClick(object sender, EventArgs e)
{ {
var parent = Parent as LuaWinform; var parent = Parent as LuaWinform;
parent?.DoLuaEvent(Handle); parent?.DoLuaEvent(Handle);
} }
protected override void OnClick(EventArgs e) protected override void OnClick(EventArgs e)

View File

@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class MultiDiskFileSelector : UserControl public partial class MultiDiskFileSelector : UserControl
{ {
public string SystemString = ""; public string SystemString = "";
public string GetName() public string GetName()
{ {

View File

@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
public bool AskSaveChanges() { return true; } public bool AskSaveChanges() { return true; }
public bool UpdateBefore => false; public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { } public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues() public void UpdateValues()
{ {

View File

@ -6,255 +6,255 @@ using System.Linq;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
[Schema("ZXSpectrum")] [Schema("ZXSpectrum")]
class ZXSpectrumSchema : IVirtualPadSchema class ZXSpectrumSchema : IVirtualPadSchema
{ {
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core) public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{ {
yield return Joystick(1); yield return Joystick(1);
yield return Joystick(2); yield return Joystick(2);
yield return Joystick(3); yield return Joystick(3);
yield return Keyboard(); yield return Keyboard();
//yield return TapeDevice(); //yield return TapeDevice();
} }
private static PadSchema Joystick(int controller) private static PadSchema Joystick(int controller)
{ {
return new PadSchema return new PadSchema
{ {
DisplayName = $"Joystick {controller}", DisplayName = $"Joystick {controller}",
IsConsole = false, IsConsole = false,
DefaultSize = new Size(174, 74), DefaultSize = new Size(174, 74),
MaxSize = new Size(174, 74), MaxSize = new Size(174, 74),
Buttons = new[] Buttons = new[]
{ {
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = $"P{controller} Up", Name = $"P{controller} Up",
DisplayName = "", DisplayName = "",
Icon = Properties.Resources.BlueUp, Icon = Properties.Resources.BlueUp,
Location = new Point(23, 15), Location = new Point(23, 15),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = $"P{controller} Down", Name = $"P{controller} Down",
DisplayName = "", DisplayName = "",
Icon = Properties.Resources.BlueDown, Icon = Properties.Resources.BlueDown,
Location = new Point(23, 36), Location = new Point(23, 36),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = $"P{controller} Left", Name = $"P{controller} Left",
DisplayName = "", DisplayName = "",
Icon = Properties.Resources.Back, Icon = Properties.Resources.Back,
Location = new Point(2, 24), Location = new Point(2, 24),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = $"P{controller} Right", Name = $"P{controller} Right",
DisplayName = "", DisplayName = "",
Icon = Properties.Resources.Forward, Icon = Properties.Resources.Forward,
Location = new Point(44, 24), Location = new Point(44, 24),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = $"P{controller} Button", Name = $"P{controller} Button",
DisplayName = "B", DisplayName = "B",
Location = new Point(124, 24), Location = new Point(124, 24),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
} }
} }
}; };
} }
private class ButtonLayout private class ButtonLayout
{ {
public string Name { get; set; } public string Name { get; set; }
public string DisName { get; set; } public string DisName { get; set; }
public double WidthFactor { get; set; } public double WidthFactor { get; set; }
public int Row { get; set; } public int Row { get; set; }
public bool IsActive = true; public bool IsActive = true;
} }
private static PadSchema Keyboard() private static PadSchema Keyboard()
{ {
List<ButtonLayout> bls = new List<ButtonLayout> List<ButtonLayout> bls = new List<ButtonLayout>
{ {
new ButtonLayout { Name = "Key True Video", DisName = "TV", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key True Video", DisName = "TV", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key Inv Video", DisName = "IV", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key Inv Video", DisName = "IV", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 1", DisName = "1", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 1", DisName = "1", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 2", DisName = "2", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 2", DisName = "2", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 3", DisName = "3", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 3", DisName = "3", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 4", DisName = "4", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 4", DisName = "4", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 5", DisName = "5", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 5", DisName = "5", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 6", DisName = "6", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 6", DisName = "6", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 7", DisName = "7", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 7", DisName = "7", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 8", DisName = "8", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 8", DisName = "8", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 9", DisName = "9", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 9", DisName = "9", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key 0", DisName = "0", Row = 0, WidthFactor = 1 }, new ButtonLayout { Name = "Key 0", DisName = "0", Row = 0, WidthFactor = 1 },
new ButtonLayout { Name = "Key Break", DisName = "BREAK", Row = 0, WidthFactor = 1.5 }, new ButtonLayout { Name = "Key Break", DisName = "BREAK", Row = 0, WidthFactor = 1.5 },
new ButtonLayout { Name = "Key Delete", DisName = "DEL", Row = 1, WidthFactor = 1.5 }, new ButtonLayout { Name = "Key Delete", DisName = "DEL", Row = 1, WidthFactor = 1.5 },
new ButtonLayout { Name = "Key Graph", DisName = "GR", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key Graph", DisName = "GR", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key Q", DisName = "Q", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key Q", DisName = "Q", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key W", DisName = "W", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key W", DisName = "W", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key E", DisName = "E", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key E", DisName = "E", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key R", DisName = "R", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key R", DisName = "R", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key T", DisName = "T", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key T", DisName = "T", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key Y", DisName = "Y", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key Y", DisName = "Y", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key U", DisName = "U", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key U", DisName = "U", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key I", DisName = "I", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key I", DisName = "I", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key O", DisName = "O", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key O", DisName = "O", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key P", DisName = "P", Row = 1, WidthFactor = 1 }, new ButtonLayout { Name = "Key P", DisName = "P", Row = 1, WidthFactor = 1 },
new ButtonLayout { Name = "Key Extend Mode", DisName = "EM", Row = 2, WidthFactor = 1.5 }, new ButtonLayout { Name = "Key Extend Mode", DisName = "EM", Row = 2, WidthFactor = 1.5 },
new ButtonLayout { Name = "Key Edit", DisName = "ED", Row = 2, WidthFactor = 1.25}, new ButtonLayout { Name = "Key Edit", DisName = "ED", Row = 2, WidthFactor = 1.25},
new ButtonLayout { Name = "Key A", DisName = "A", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key A", DisName = "A", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key S", DisName = "S", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key S", DisName = "S", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key D", DisName = "D", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key D", DisName = "D", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key F", DisName = "F", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key F", DisName = "F", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key G", DisName = "G", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key G", DisName = "G", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key H", DisName = "H", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key H", DisName = "H", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key J", DisName = "J", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key J", DisName = "J", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key K", DisName = "K", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key K", DisName = "K", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key L", DisName = "L", Row = 2, WidthFactor = 1 }, new ButtonLayout { Name = "Key L", DisName = "L", Row = 2, WidthFactor = 1 },
new ButtonLayout { Name = "Key Return", DisName = "ENTER", Row = 2, WidthFactor = 1.75 }, new ButtonLayout { Name = "Key Return", DisName = "ENTER", Row = 2, WidthFactor = 1.75 },
new ButtonLayout { Name = "Key Caps Shift", DisName = "CAPS-S", Row = 3, WidthFactor = 2.25 }, new ButtonLayout { Name = "Key Caps Shift", DisName = "CAPS-S", Row = 3, WidthFactor = 2.25 },
new ButtonLayout { Name = "Key Caps Lock", DisName = "CL", Row = 3, WidthFactor = 1}, new ButtonLayout { Name = "Key Caps Lock", DisName = "CL", Row = 3, WidthFactor = 1},
new ButtonLayout { Name = "Key Z", DisName = "Z", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key Z", DisName = "Z", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key X", DisName = "X", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key X", DisName = "X", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key C", DisName = "C", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key C", DisName = "C", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key V", DisName = "V", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key V", DisName = "V", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key B", DisName = "B", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key B", DisName = "B", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key N", DisName = "N", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key N", DisName = "N", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key M", DisName = "M", Row = 3, WidthFactor = 1 }, new ButtonLayout { Name = "Key M", DisName = "M", Row = 3, WidthFactor = 1 },
new ButtonLayout { Name = "Key Period", DisName = ".", Row = 3, WidthFactor = 1}, new ButtonLayout { Name = "Key Period", DisName = ".", Row = 3, WidthFactor = 1},
new ButtonLayout { Name = "Key Caps Shift", DisName = "CAPS-S", Row = 3, WidthFactor = 2.25 }, new ButtonLayout { Name = "Key Caps Shift", DisName = "CAPS-S", Row = 3, WidthFactor = 2.25 },
new ButtonLayout { Name = "Key Symbol Shift", DisName = "SS", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Symbol Shift", DisName = "SS", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Semi-Colon", DisName = ";", Row = 4, WidthFactor = 1}, new ButtonLayout { Name = "Key Semi-Colon", DisName = ";", Row = 4, WidthFactor = 1},
new ButtonLayout { Name = "Key Quote", DisName = "\"", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Quote", DisName = "\"", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Left Cursor", DisName = "←", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Left Cursor", DisName = "←", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Right Cursor", DisName = "→", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Right Cursor", DisName = "→", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Space", DisName = "SPACE", Row = 4, WidthFactor = 4.5 }, new ButtonLayout { Name = "Key Space", DisName = "SPACE", Row = 4, WidthFactor = 4.5 },
new ButtonLayout { Name = "Key Up Cursor", DisName = "↑", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Up Cursor", DisName = "↑", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Down Cursor", DisName = "↓", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Down Cursor", DisName = "↓", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Comma", DisName = ",", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Comma", DisName = ",", Row = 4, WidthFactor = 1 },
new ButtonLayout { Name = "Key Symbol Shift", DisName = "SS", Row = 4, WidthFactor = 1 }, new ButtonLayout { Name = "Key Symbol Shift", DisName = "SS", Row = 4, WidthFactor = 1 },
}; };
PadSchema ps = new PadSchema PadSchema ps = new PadSchema
{ {
DisplayName = "Keyboard", DisplayName = "Keyboard",
IsConsole = false, IsConsole = false,
DefaultSize = new Size(500, 170) DefaultSize = new Size(500, 170)
}; };
List<PadSchema.ButtonSchema> btns = new List<PadSchema.ButtonSchema>(); List<PadSchema.ButtonSchema> btns = new List<PadSchema.ButtonSchema>();
int rowHeight = 29; //24 int rowHeight = 29; //24
int stdButtonWidth = 29; //24 int stdButtonWidth = 29; //24
int yPos = 18; int yPos = 18;
int xPos = 22; int xPos = 22;
int currRow = 0; int currRow = 0;
foreach (var b in bls) foreach (var b in bls)
{ {
if (b.Row > currRow) if (b.Row > currRow)
{ {
currRow++; currRow++;
yPos += rowHeight; yPos += rowHeight;
xPos = 22; xPos = 22;
} }
int txtLength = b.DisName.Length; int txtLength = b.DisName.Length;
int btnSize = System.Convert.ToInt32((double)stdButtonWidth * b.WidthFactor); int btnSize = System.Convert.ToInt32((double)stdButtonWidth * b.WidthFactor);
string disp = b.DisName; string disp = b.DisName;
if (txtLength == 1) if (txtLength == 1)
disp = $" {disp}"; disp = $" {disp}";
switch(b.DisName) switch(b.DisName)
{ {
case "SPACE": disp = $" {disp} "; break; case "SPACE": disp = $" {disp} "; break;
case "I": disp = $" {disp} "; break; case "I": disp = $" {disp} "; break;
case "W": disp = b.DisName; break; case "W": disp = b.DisName; break;
} }
if (b.IsActive) if (b.IsActive)
{ {
PadSchema.ButtonSchema btn = new PadSchema.ButtonSchema(); PadSchema.ButtonSchema btn = new PadSchema.ButtonSchema();
btn.Name = b.Name; btn.Name = b.Name;
btn.DisplayName = disp; btn.DisplayName = disp;
btn.Location = new Point(xPos, yPos); btn.Location = new Point(xPos, yPos);
btn.Type = PadSchema.PadInputType.Boolean; btn.Type = PadSchema.PadInputType.Boolean;
btns.Add(btn); btns.Add(btn);
} }
xPos += btnSize; xPos += btnSize;
} }
ps.Buttons = btns.ToArray(); ps.Buttons = btns.ToArray();
return ps; return ps;
} }
private static PadSchema TapeDevice() private static PadSchema TapeDevice()
{ {
return new PadSchema return new PadSchema
{ {
DisplayName = "DATACORDER", DisplayName = "DATACORDER",
IsConsole = false, IsConsole = false,
DefaultSize = new Size(174, 74), DefaultSize = new Size(174, 74),
MaxSize = new Size(174, 74), MaxSize = new Size(174, 74),
Buttons = new[] Buttons = new[]
{ {
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = "Play Tape", Name = "Play Tape",
Icon = Properties.Resources.Play, Icon = Properties.Resources.Play,
Location = new Point(23, 22), Location = new Point(23, 22),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = "Stop Tape", Name = "Stop Tape",
Icon = Properties.Resources.Stop, Icon = Properties.Resources.Stop,
Location = new Point(53, 22), Location = new Point(53, 22),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = "RTZ Tape", Name = "RTZ Tape",
Icon = Properties.Resources.BackMore, Icon = Properties.Resources.BackMore,
Location = new Point(83, 22), Location = new Point(83, 22),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = "Insert Next Tape", Name = "Insert Next Tape",
DisplayName = "NEXT TAPE", DisplayName = "NEXT TAPE",
//Icon = Properties.Resources.MoveRight, //Icon = Properties.Resources.MoveRight,
Location = new Point(23, 52), Location = new Point(23, 52),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
new PadSchema.ButtonSchema new PadSchema.ButtonSchema
{ {
Name = "Insert Previous Tape", Name = "Insert Previous Tape",
DisplayName = "PREV TAPE", DisplayName = "PREV TAPE",
//Icon = Properties.Resources.MoveLeft, //Icon = Properties.Resources.MoveLeft,
Location = new Point(100, 52), Location = new Point(100, 52),
Type = PadSchema.PadInputType.Boolean Type = PadSchema.PadInputType.Boolean
}, },
} }
}; };
} }
} }
} }

View File

@ -28,31 +28,31 @@ namespace BizHawk.Common
} }
} }
/// <summary> /// <summary>
/// compose multiple ImportResolvers, where subsequent ones takes precedence over earlier ones /// compose multiple ImportResolvers, where subsequent ones takes precedence over earlier ones
/// </summary> /// </summary>
public class PatchImportResolver : IImportResolver public class PatchImportResolver : IImportResolver
{ {
private readonly List<IImportResolver> _resolvers = new List<IImportResolver>(); private readonly List<IImportResolver> _resolvers = new List<IImportResolver>();
public PatchImportResolver(params IImportResolver[] rr) public PatchImportResolver(params IImportResolver[] rr)
{ {
Add(rr); Add(rr);
} }
public void Add(params IImportResolver[] rr) public void Add(params IImportResolver[] rr)
{ {
_resolvers.AddRange(rr); _resolvers.AddRange(rr);
} }
public IntPtr Resolve(string entryPoint) public IntPtr Resolve(string entryPoint)
{ {
for (int i = _resolvers.Count - 1; i >= 0; i--) for (int i = _resolvers.Count - 1; i >= 0; i--)
{ {
var ret = _resolvers[i].Resolve(entryPoint); var ret = _resolvers[i].Resolve(entryPoint);
if (ret != IntPtr.Zero) if (ret != IntPtr.Zero)
return ret; return ret;
} }
return IntPtr.Zero; return IntPtr.Zero;
} }
} }
} }

View File

@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Common
[JsonIgnore] [JsonIgnore]
private Node Current => Nodes.Peek(); private Node Current => Nodes.Peek();
public void Prepare() public void Prepare()
{ {
Nodes = new Stack<Node>(); Nodes = new Stack<Node>();
Nodes.Push(Root); Nodes.Push(Root);

View File

@ -3,9 +3,9 @@ using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Arcades.MAME namespace BizHawk.Emulation.Cores.Arcades.MAME
{ {
public static class LibMAME public static class LibMAME
{ {
const string dll = "libmamearcade64.dll"; // libmamearcade64.dll libpacmansh64d.dll const string dll = "libmamearcade64.dll"; // libmamearcade64.dll libpacmansh64d.dll
const CallingConvention cc = CallingConvention.Cdecl; const CallingConvention cc = CallingConvention.Cdecl;
public enum OutputChannel public enum OutputChannel

View File

@ -171,182 +171,182 @@ namespace BizHawk.Emulation.Cores.Components.M68000
static readonly string[] Xn3 = { "000", "001", "010", "011", "100", "101", "110", "111" }; static readonly string[] Xn3 = { "000", "001", "010", "011", "100", "101", "110", "111" };
static readonly string[] Xn3Am3 = { static readonly string[] Xn3Am3 = {
"000000", // Dn Data register "000000", // Dn Data register
"001000", "001000",
"010000", "010000",
"011000", "011000",
"100000", "100000",
"101000", "101000",
"110000", "110000",
"111000", "111000",
"000001", // An Address register "000001", // An Address register
"001001", "001001",
"010001", "010001",
"011001", "011001",
"100001", "100001",
"101001", "101001",
"110001", "110001",
"111001", "111001",
"000010", // (An) Address "000010", // (An) Address
"001010", "001010",
"010010", "010010",
"011010", "011010",
"100010", "100010",
"101010", "101010",
"110010", "110010",
"111010", "111010",
"000011", // (An)+ Address with Postincrement "000011", // (An)+ Address with Postincrement
"001011", "001011",
"010011", "010011",
"011011", "011011",
"100011", "100011",
"101011", "101011",
"110011", "110011",
"111011", "111011",
"000100", // -(An) Address with Predecrement "000100", // -(An) Address with Predecrement
"001100", "001100",
"010100", "010100",
"011100", "011100",
"100100", "100100",
"101100", "101100",
"110100", "110100",
"111100", "111100",
"000101", // (d16, An) Address with Displacement "000101", // (d16, An) Address with Displacement
"001101", "001101",
"010101", "010101",
"011101", "011101",
"100101", "100101",
"101101", "101101",
"110101", "110101",
"111101", "111101",
"000110", // (d8, An, Xn) Address with Index "000110", // (d8, An, Xn) Address with Index
"001110", "001110",
"010110", "010110",
"011110", "011110",
"100110", "100110",
"101110", "101110",
"110110", "110110",
"111110", "111110",
"010111", // (d16, PC) PC with Displacement "010111", // (d16, PC) PC with Displacement
"011111", // (d8, PC, Xn) PC with Index "011111", // (d8, PC, Xn) PC with Index
"000111", // (xxx).W Absolute Short "000111", // (xxx).W Absolute Short
"001111", // (xxx).L Absolute Long "001111", // (xxx).L Absolute Long
"100111", // #imm Immediate "100111", // #imm Immediate
}; };
static readonly string[] Am3Xn3 = { static readonly string[] Am3Xn3 = {
"000000", // Dn Data register "000000", // Dn Data register
"000001", "000001",
"000010", "000010",
"000011", "000011",
"000100", "000100",
"000101", "000101",
"000110", "000110",
"000111", "000111",
"001000", // An Address register "001000", // An Address register
"001001", "001001",
"001010", "001010",
"001011", "001011",
"001100", "001100",
"001101", "001101",
"001110", "001110",
"001111", "001111",
"010000", // (An) Address "010000", // (An) Address
"010001", "010001",
"010010", "010010",
"010011", "010011",
"010100", "010100",
"010101", "010101",
"010110", "010110",
"010111", "010111",
"011000", // (An)+ Address with Postincrement "011000", // (An)+ Address with Postincrement
"011001", "011001",
"011010", "011010",
"011011", "011011",
"011100", "011100",
"011101", "011101",
"011110", "011110",
"011111", "011111",
"100000", // -(An) Address with Predecrement "100000", // -(An) Address with Predecrement
"100001", "100001",
"100010", "100010",
"100011", "100011",
"100100", "100100",
"100101", "100101",
"100110", "100110",
"100111", "100111",
"101000", // (d16, An) Address with Displacement "101000", // (d16, An) Address with Displacement
"101001", "101001",
"101010", "101010",
"101011", "101011",
"101100", "101100",
"101101", "101101",
"101110", "101110",
"101111", "101111",
"110000", // (d8, An, Xn) Address with Index "110000", // (d8, An, Xn) Address with Index
"110001", "110001",
"110010", "110010",
"110011", "110011",
"110100", "110100",
"110101", "110101",
"110110", "110110",
"110111", "110111",
"111010", // (d16, PC) PC with Displacement "111010", // (d16, PC) PC with Displacement
"111011", // (d8, PC, Xn) PC with Index "111011", // (d8, PC, Xn) PC with Index
"111000", // (xxx).W Absolute Short "111000", // (xxx).W Absolute Short
"111001", // (xxx).L Absolute Long "111001", // (xxx).L Absolute Long
"111100", // #imm Immediate "111100", // #imm Immediate
}; };
static readonly string[] ConditionMain = { static readonly string[] ConditionMain = {
"0010", // HI Higher (unsigned) "0010", // HI Higher (unsigned)
"0011", // LS Lower or Same (unsigned) "0011", // LS Lower or Same (unsigned)
"0100", // CC Carry Clear (aka Higher or Same, unsigned) "0100", // CC Carry Clear (aka Higher or Same, unsigned)
"0101", // CS Carry Set (aka Lower, unsigned) "0101", // CS Carry Set (aka Lower, unsigned)
"0110", // NE Not Equal "0110", // NE Not Equal
"0111", // EQ Equal "0111", // EQ Equal
"1000", // VC Overflow Clear "1000", // VC Overflow Clear
"1001", // VS Overflow Set "1001", // VS Overflow Set
"1010", // PL Plus "1010", // PL Plus
"1011", // MI Minus "1011", // MI Minus
"1100", // GE Greater or Equal (signed) "1100", // GE Greater or Equal (signed)
"1101", // LT Less Than (signed) "1101", // LT Less Than (signed)
"1110", // GT Greater Than (signed) "1110", // GT Greater Than (signed)
"1111" // LE Less or Equal (signed) "1111" // LE Less or Equal (signed)
}; };
static readonly string[] ConditionAll = { static readonly string[] ConditionAll = {
"0000", // T True "0000", // T True
"0001", // F False "0001", // F False
"0010", // HI Higher (unsigned) "0010", // HI Higher (unsigned)
"0011", // LS Lower or Same (unsigned) "0011", // LS Lower or Same (unsigned)
"0100", // CC Carry Clear (aka Higher or Same, unsigned) "0100", // CC Carry Clear (aka Higher or Same, unsigned)
"0101", // CS Carry Set (aka Lower, unsigned) "0101", // CS Carry Set (aka Lower, unsigned)
"0110", // NE Not Equal "0110", // NE Not Equal
"0111", // EQ Equal "0111", // EQ Equal
"1000", // VC Overflow Clear "1000", // VC Overflow Clear
"1001", // VS Overflow Set "1001", // VS Overflow Set
"1010", // PL Plus "1010", // PL Plus
"1011", // MI Minus "1011", // MI Minus
"1100", // GE Greater or Equal (signed) "1100", // GE Greater or Equal (signed)
"1101", // LT Less Than (signed) "1101", // LT Less Than (signed)
"1110", // GT Greater Than (signed) "1110", // GT Greater Than (signed)
"1111" // LE Less or Equal (signed) "1111" // LE Less or Equal (signed)
}; };
#endregion #endregion
} }

View File

@ -296,23 +296,23 @@ namespace BizHawk.Emulation.Cores.Components.H6280
} }
private static readonly byte[] TableNZ = private static readonly byte[] TableNZ =
{ {
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
}; };
} }
} }

View File

@ -7,8 +7,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
public long TotalExecutedCycles; public long TotalExecutedCycles;
private int EI_pending; private int EI_pending;
// ZXHawk needs to be able to read this for zx-state snapshot export // ZXHawk needs to be able to read this for zx-state snapshot export
public int EIPending { get { return EI_pending; } } public int EIPending { get { return EI_pending; } }
public const ushort CBpre = 0; public const ushort CBpre = 0;
public const ushort EXTDpre = 1; public const ushort EXTDpre = 1;

View File

@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
public Action IRQCallback = delegate () { }; public Action IRQCallback = delegate () { };
public Action NMICallback = delegate () { }; public Action NMICallback = delegate () { };
// this will be a few cycles off for now // this will be a few cycles off for now
// it should suffice for now until Alyosha returns from hiatus // it should suffice for now until Alyosha returns from hiatus
public Action IRQACKCallback = delegate () { }; public Action IRQACKCallback = delegate () { };
private void NMI_() private void NMI_()
{ {
@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
PopulateBUSRQ(0, 0, 0, 0, PCh, 0, 0); PopulateBUSRQ(0, 0, 0, 0, PCh, 0, 0);
PopulateMEMRQ(0, 0, 0, 0, PCh, 0, 0); PopulateMEMRQ(0, 0, 0, 0, PCh, 0, 0);
IRQS = 7; IRQS = 7;
} }
// Just jump to $0038 // Just jump to $0038
private void INTERRUPT_1() private void INTERRUPT_1()
@ -96,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
PopulateBUSRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0); PopulateBUSRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0);
PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0); PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0);
IRQS = 13; IRQS = 13;
} }
// Interrupt mode 2 uses the I vector combined with a byte on the data bus // Interrupt mode 2 uses the I vector combined with a byte on the data bus
private void INTERRUPT_2() private void INTERRUPT_2()
@ -125,7 +125,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
PopulateBUSRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0); PopulateBUSRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0);
PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0); PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0);
IRQS = 19; IRQS = 19;
} }
private void ResetInterrupts() private void ResetInterrupts()
{ {

View File

@ -97,13 +97,13 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
} }
public void IN_A_N_INC_Func(ushort dest, ushort src_l, ushort src_h) public void IN_A_N_INC_Func(ushort dest, ushort src_l, ushort src_h)
{ {
Regs[dest] = ReadHardware((ushort)(Regs[src_l] | (Regs[src_h]) << 8)); Regs[dest] = ReadHardware((ushort)(Regs[src_l] | (Regs[src_h]) << 8));
Regs[DB] = Regs[dest]; Regs[DB] = Regs[dest];
INC16_Func(src_l, src_h); INC16_Func(src_l, src_h);
} }
public void TR_Func(ushort dest, ushort src) public void TR_Func(ushort dest, ushort src)
{ {
Regs[dest] = Regs[src]; Regs[dest] = Regs[src];
} }

View File

@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
public const ushort RST = 65; public const ushort RST = 65;
public const ushort REP_OP_I = 66; public const ushort REP_OP_I = 66;
public const ushort REP_OP_O = 67; public const ushort REP_OP_O = 67;
public const ushort IN_A_N_INC = 68; public const ushort IN_A_N_INC = 68;
public const ushort RD_INC_TR_PC = 69; // transfer WZ to PC after read public const ushort RD_INC_TR_PC = 69; // transfer WZ to PC after read
public const ushort WR_TR_PC = 70; // transfer WZ to PC after write public const ushort WR_TR_PC = 70; // transfer WZ to PC after write
public const ushort OUT_INC = 71; public const ushort OUT_INC = 71;
@ -436,8 +436,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
IN_INC_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); IN_INC_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break; break;
case IN_A_N_INC: case IN_A_N_INC:
IN_A_N_INC_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); IN_A_N_INC_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break; break;
case NEG: case NEG:
NEG_8_Func(cur_instr[instr_pntr++]); NEG_8_Func(cur_instr[instr_pntr++]);
break; break;

View File

@ -71,9 +71,9 @@ namespace BizHawk.Emulation.Cores.Calculators
public string SystemId => "TI83"; public string SystemId => "TI83";
public bool DeterministicEmulation => true; public bool DeterministicEmulation => true;
public void ResetCounters() public void ResetCounters()
{ {
Frame = 0; Frame = 0;
_lagCount = 0; _lagCount = 0;

View File

@ -35,11 +35,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{ {
[DisplayName("Border type")] [DisplayName("Border type")]
[Description("Select how to show the border area\n" + [Description("Select how to show the border area\n" +
"NORMAL:\t Horizontal and Vertical border both set to 32 pixels (although horizontal will appear narrower due to pixel density)\n" + "NORMAL:\t Horizontal and Vertical border both set to 32 pixels (although horizontal will appear narrower due to pixel density)\n" +
"SMALL PROPORTIONAL:\t Horizontal and Vertical border both set to 16 pixels (although horizontal will appear narrower due to pixel density)\n" + "SMALL PROPORTIONAL:\t Horizontal and Vertical border both set to 16 pixels (although horizontal will appear narrower due to pixel density)\n" +
"SMALL FIXED:\t Horizontal border is set to 16 pixels and vertical is made slightly smaller so as to appear horizontal and vertical are the same after pixel density has been applied\n" + "SMALL FIXED:\t Horizontal border is set to 16 pixels and vertical is made slightly smaller so as to appear horizontal and vertical are the same after pixel density has been applied\n" +
"NONE:\t Only the pixel buffer is rendered" "NONE:\t Only the pixel buffer is rendered"
)] )]
[DefaultValue(BorderType.SmallProportional)] [DefaultValue(BorderType.SmallProportional)]
public BorderType BorderType { get; set; } public BorderType BorderType { get; set; }

View File

@ -108,46 +108,46 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_port = new IecPort(readIec, readUserPort); _port = new IecPort(readIec, readUserPort);
} }
public void HardReset() public void HardReset()
{ {
_pra = 0; _pra = 0;
_prb = 0; _prb = 0;
_ddra = 0; _ddra = 0;
_ddrb = 0; _ddrb = 0;
_ta = 0xFFFF; _ta = 0xFFFF;
_tb = 0xFFFF; _tb = 0xFFFF;
_latcha = 1; _latcha = 1;
_latchb = 1; _latchb = 1;
_tod10Ths = 0; _tod10Ths = 0;
_todSec = 0; _todSec = 0;
_todMin = 0; _todMin = 0;
_todHr = 0; _todHr = 0;
_alm10Ths = 0; _alm10Ths = 0;
_almSec = 0; _almSec = 0;
_almMin = 0; _almMin = 0;
_almHr = 0; _almHr = 0;
_sdr = 0; _sdr = 0;
_icr = 0; _icr = 0;
_cra = 0; _cra = 0;
_crb = 0; _crb = 0;
_intMask = 0; _intMask = 0;
_todLatch = false; _todLatch = false;
_taCntPhi2 = false; _taCntPhi2 = false;
_taCntCnt = false; _taCntCnt = false;
_tbCntPhi2 = false; _tbCntPhi2 = false;
_tbCntTa = false; _tbCntTa = false;
_tbCntCnt = false; _tbCntCnt = false;
_taIrqNextCycle = false; _taIrqNextCycle = false;
_tbIrqNextCycle = false; _tbIrqNextCycle = false;
_taState = TimerState.Stop; _taState = TimerState.Stop;
_tbState = TimerState.Stop; _tbState = TimerState.Stop;
_lastCnt = true; _lastCnt = true;
} }
public void ExecutePhase() public void ExecutePhase()
{ {
_thisCnt = ReadCnt(); _thisCnt = ReadCnt();
_taUnderflow = false; _taUnderflow = false;
if (_taIrqNextCycle) if (_taIrqNextCycle)
{ {
@ -161,358 +161,358 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
TriggerInterrupt(2); TriggerInterrupt(2);
} }
if (_taPrb6NegativeNextCycle) if (_taPrb6NegativeNextCycle)
{ {
_prb &= 0xBF; _prb &= 0xBF;
_taPrb6NegativeNextCycle = false; _taPrb6NegativeNextCycle = false;
} }
if (_tbPrb7NegativeNextCycle) if (_tbPrb7NegativeNextCycle)
{ {
_prb &= 0x7F; _prb &= 0x7F;
_tbPrb7NegativeNextCycle = false; _tbPrb7NegativeNextCycle = false;
} }
switch (_taState) switch (_taState)
{ {
case TimerState.WaitThenCount: case TimerState.WaitThenCount:
_taState = TimerState.Count; _taState = TimerState.Count;
Ta_Idle(); Ta_Idle();
break; break;
case TimerState.Stop: case TimerState.Stop:
Ta_Idle(); Ta_Idle();
break; break;
case TimerState.LoadThenStop: case TimerState.LoadThenStop:
_taState = TimerState.Stop; _taState = TimerState.Stop;
_ta = _latcha; _ta = _latcha;
Ta_Idle(); Ta_Idle();
break; break;
case TimerState.LoadThenCount: case TimerState.LoadThenCount:
_taState = TimerState.Count; _taState = TimerState.Count;
_ta = _latcha; _ta = _latcha;
Ta_Idle(); Ta_Idle();
break; break;
case TimerState.LoadThenWaitThenCount: case TimerState.LoadThenWaitThenCount:
_taState = TimerState.WaitThenCount; _taState = TimerState.WaitThenCount;
if (_ta == 1) if (_ta == 1)
{ {
Ta_Interrupt(); Ta_Interrupt();
_taUnderflow = true; _taUnderflow = true;
} }
else else
{ {
_ta = _latcha; _ta = _latcha;
} }
Ta_Idle(); Ta_Idle();
break; break;
case TimerState.Count: case TimerState.Count:
Ta_Count(); Ta_Count();
break; break;
case TimerState.CountThenStop: case TimerState.CountThenStop:
_taState = TimerState.Stop; _taState = TimerState.Stop;
Ta_Count(); Ta_Count();
break; break;
} }
switch (_tbState) switch (_tbState)
{ {
case TimerState.WaitThenCount: case TimerState.WaitThenCount:
_tbState = TimerState.Count; _tbState = TimerState.Count;
Tb_Idle(); Tb_Idle();
break; break;
case TimerState.Stop: case TimerState.Stop:
Tb_Idle(); Tb_Idle();
break; break;
case TimerState.LoadThenStop: case TimerState.LoadThenStop:
_tbState = TimerState.Stop; _tbState = TimerState.Stop;
_tb = _latchb; _tb = _latchb;
Tb_Idle(); Tb_Idle();
break; break;
case TimerState.LoadThenCount: case TimerState.LoadThenCount:
_tbState = TimerState.Count; _tbState = TimerState.Count;
_tb = _latchb; _tb = _latchb;
Tb_Idle(); Tb_Idle();
break; break;
case TimerState.LoadThenWaitThenCount: case TimerState.LoadThenWaitThenCount:
_tbState = TimerState.WaitThenCount; _tbState = TimerState.WaitThenCount;
if (_tb == 1) if (_tb == 1)
{ {
Tb_Interrupt(); Tb_Interrupt();
} }
else else
{ {
_tb = _latchb; _tb = _latchb;
} }
Tb_Idle(); Tb_Idle();
break; break;
case TimerState.Count: case TimerState.Count:
Tb_Count(); Tb_Count();
break; break;
case TimerState.CountThenStop: case TimerState.CountThenStop:
_tbState = TimerState.Stop; _tbState = TimerState.Stop;
Tb_Count(); Tb_Count();
break; break;
} }
CountTod(); CountTod();
if (!_todLatch) if (!_todLatch)
{ {
_latch10Ths = _tod10Ths; _latch10Ths = _tod10Ths;
_latchSec = _todSec; _latchSec = _todSec;
_latchMin = _todMin; _latchMin = _todMin;
_latchHr = _todHr; _latchHr = _todHr;
} }
_flagInput = ReadFlag(); _flagInput = ReadFlag();
if (!_flagInput && _flagLatch) if (!_flagInput && _flagLatch)
{ {
TriggerInterrupt(16); TriggerInterrupt(16);
} }
_flagLatch = _flagInput; _flagLatch = _flagInput;
if ((_cra & 0x02) != 0) if ((_cra & 0x02) != 0)
_ddra |= 0x40; _ddra |= 0x40;
if ((_crb & 0x02) != 0) if ((_crb & 0x02) != 0)
_ddrb |= 0x80; _ddrb |= 0x80;
_lastCnt = _thisCnt; _lastCnt = _thisCnt;
} }
private void Ta_Count() private void Ta_Count()
{ {
if (_taCntPhi2 || (_taCntCnt && !_lastCnt && _thisCnt)) if (_taCntPhi2 || (_taCntCnt && !_lastCnt && _thisCnt))
{ {
if (_ta <= 0 || --_ta == 0) if (_ta <= 0 || --_ta == 0)
{ {
if (_taState != TimerState.Stop) if (_taState != TimerState.Stop)
{ {
Ta_Interrupt(); Ta_Interrupt();
} }
_taUnderflow = true; _taUnderflow = true;
} }
} }
Ta_Idle(); Ta_Idle();
} }
private void Ta_Interrupt() private void Ta_Interrupt()
{ {
_ta = _latcha; _ta = _latcha;
if (DelayedInterrupts) if (DelayedInterrupts)
_taIrqNextCycle = true; _taIrqNextCycle = true;
else else
TriggerInterrupt(1); TriggerInterrupt(1);
_icr |= 1; _icr |= 1;
if ((_cra & 0x08) != 0) if ((_cra & 0x08) != 0)
{ {
_cra &= 0xFE; _cra &= 0xFE;
_newCra &= 0xFE; _newCra &= 0xFE;
_taState = TimerState.LoadThenStop; _taState = TimerState.LoadThenStop;
} }
else else
{ {
_taState = TimerState.LoadThenCount; _taState = TimerState.LoadThenCount;
} }
if ((_cra & 0x02) != 0) if ((_cra & 0x02) != 0)
{ {
if ((_cra & 0x04) != 0) if ((_cra & 0x04) != 0)
{ {
_taPrb6NegativeNextCycle = true; _taPrb6NegativeNextCycle = true;
_prb |= 0x40; _prb |= 0x40;
} }
else else
{ {
_prb ^= 0x40; _prb ^= 0x40;
} }
_ddrb |= 0x40; _ddrb |= 0x40;
} }
} }
private void Ta_Idle() private void Ta_Idle()
{ {
if (_hasNewCra) if (_hasNewCra)
{ {
switch (_taState) switch (_taState)
{ {
case TimerState.Stop: case TimerState.Stop:
case TimerState.LoadThenStop: case TimerState.LoadThenStop:
if ((_newCra & 0x01) != 0) if ((_newCra & 0x01) != 0)
{ {
_taState = (_newCra & 0x10) != 0 _taState = (_newCra & 0x10) != 0
? TimerState.LoadThenWaitThenCount ? TimerState.LoadThenWaitThenCount
: TimerState.WaitThenCount; : TimerState.WaitThenCount;
} }
else else
{ {
if ((_newCra & 0x10) != 0) if ((_newCra & 0x10) != 0)
{ {
_taState = TimerState.LoadThenStop; _taState = TimerState.LoadThenStop;
} }
} }
break; break;
case TimerState.Count: case TimerState.Count:
if ((_newCra & 0x01) != 0) if ((_newCra & 0x01) != 0)
{ {
if ((_newCra & 0x10) != 0) if ((_newCra & 0x10) != 0)
{ {
_taState = TimerState.LoadThenWaitThenCount; _taState = TimerState.LoadThenWaitThenCount;
} }
} }
else else
{ {
_taState = (_newCra & 0x10) != 0 _taState = (_newCra & 0x10) != 0
? TimerState.LoadThenStop ? TimerState.LoadThenStop
: TimerState.CountThenStop; : TimerState.CountThenStop;
} }
break; break;
case TimerState.LoadThenCount: case TimerState.LoadThenCount:
case TimerState.WaitThenCount: case TimerState.WaitThenCount:
if ((_newCra & 0x01) != 0) if ((_newCra & 0x01) != 0)
{ {
if ((_newCra & 0x08) != 0) if ((_newCra & 0x08) != 0)
{ {
_newCra &= 0xFE; _newCra &= 0xFE;
_taState = TimerState.Stop; _taState = TimerState.Stop;
} }
else if ((_newCra & 0x10) != 0) else if ((_newCra & 0x10) != 0)
{ {
_taState = TimerState.LoadThenWaitThenCount; _taState = TimerState.LoadThenWaitThenCount;
} }
} }
else else
{ {
_taState = TimerState.Stop; _taState = TimerState.Stop;
} }
break; break;
} }
_cra = _newCra & 0xEF; _cra = _newCra & 0xEF;
_hasNewCra = false; _hasNewCra = false;
} }
} }
private void Tb_Count() private void Tb_Count()
{ {
if (_tbCntPhi2 || (_tbCntTa && _taUnderflow) || (_tbCntTaCnt && _taUnderflow && _thisCnt) || (_tbCntCnt && !_lastCnt && _thisCnt)) if (_tbCntPhi2 || (_tbCntTa && _taUnderflow) || (_tbCntTaCnt && _taUnderflow && _thisCnt) || (_tbCntCnt && !_lastCnt && _thisCnt))
{ {
if (_tb <= 0 || --_tb == 0) if (_tb <= 0 || --_tb == 0)
{ {
if (_tbState != TimerState.Stop) if (_tbState != TimerState.Stop)
{ {
Tb_Interrupt(); Tb_Interrupt();
} }
} }
} }
Tb_Idle(); Tb_Idle();
} }
private void Tb_Interrupt() private void Tb_Interrupt()
{ {
_tb = _latchb; _tb = _latchb;
if (DelayedInterrupts) if (DelayedInterrupts)
_tbIrqNextCycle = true; _tbIrqNextCycle = true;
else else
TriggerInterrupt(2); TriggerInterrupt(2);
_icr |= 2; _icr |= 2;
if ((_crb & 0x08) != 0) if ((_crb & 0x08) != 0)
{ {
_crb &= 0xFE; _crb &= 0xFE;
_newCrb &= 0xFE; _newCrb &= 0xFE;
_tbState = TimerState.LoadThenStop; _tbState = TimerState.LoadThenStop;
} }
else else
{ {
_tbState = TimerState.LoadThenCount; _tbState = TimerState.LoadThenCount;
} }
if ((_crb & 0x02) != 0) if ((_crb & 0x02) != 0)
{ {
if ((_crb & 0x04) != 0) if ((_crb & 0x04) != 0)
{ {
_tbPrb7NegativeNextCycle = true; _tbPrb7NegativeNextCycle = true;
_prb |= 0x80; _prb |= 0x80;
} }
else else
{ {
_prb ^= 0x80; _prb ^= 0x80;
} }
} }
} }
private void Tb_Idle() private void Tb_Idle()
{ {
if (_hasNewCrb) if (_hasNewCrb)
{ {
switch (_tbState) switch (_tbState)
{ {
case TimerState.Stop: case TimerState.Stop:
case TimerState.LoadThenStop: case TimerState.LoadThenStop:
if ((_newCrb & 0x01) != 0) if ((_newCrb & 0x01) != 0)
{ {
_tbState = (_newCrb & 0x10) != 0 _tbState = (_newCrb & 0x10) != 0
? TimerState.LoadThenWaitThenCount ? TimerState.LoadThenWaitThenCount
: TimerState.WaitThenCount; : TimerState.WaitThenCount;
} }
else else
{ {
if ((_newCrb & 0x10) != 0) if ((_newCrb & 0x10) != 0)
{ {
_tbState = TimerState.LoadThenStop; _tbState = TimerState.LoadThenStop;
} }
} }
break; break;
case TimerState.Count: case TimerState.Count:
if ((_newCrb & 0x01) != 0) if ((_newCrb & 0x01) != 0)
{ {
if ((_newCrb & 0x10) != 0) if ((_newCrb & 0x10) != 0)
{ {
_tbState = TimerState.LoadThenWaitThenCount; _tbState = TimerState.LoadThenWaitThenCount;
} }
} }
else else
{ {
_tbState = (_newCrb & 0x10) != 0 _tbState = (_newCrb & 0x10) != 0
? TimerState.LoadThenStop ? TimerState.LoadThenStop
: TimerState.CountThenStop; : TimerState.CountThenStop;
} }
break; break;
case TimerState.LoadThenCount: case TimerState.LoadThenCount:
case TimerState.WaitThenCount: case TimerState.WaitThenCount:
if ((_newCrb & 0x01) != 0) if ((_newCrb & 0x01) != 0)
{ {
if ((_newCrb & 0x08) != 0) if ((_newCrb & 0x08) != 0)
{ {
_newCrb &= 0xFE; _newCrb &= 0xFE;
_tbState = TimerState.Stop; _tbState = TimerState.Stop;
} }
else if ((_newCrb & 0x10) != 0) else if ((_newCrb & 0x10) != 0)
{ {
_tbState = TimerState.LoadThenWaitThenCount; _tbState = TimerState.LoadThenWaitThenCount;
} }
} }
else else
{ {
_tbState = TimerState.Stop; _tbState = TimerState.Stop;
} }
break; break;
} }
_crb = _newCrb & 0xEF; _crb = _newCrb & 0xEF;
_hasNewCrb = false; _hasNewCrb = false;
} }
} }
private void TriggerInterrupt(int bit) private void TriggerInterrupt(int bit)
{ {
_icr |= bit; _icr |= bit;
if ((_intMask & bit) == 0) return; if ((_intMask & bit) == 0) return;
_icr |= 0x80; _icr |= 0x80;
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {

View File

@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
else else
{ {
_t1C--; _t1C--;
if (_t1C == 0) if (_t1C == 0)
{ {
switch (_acrT1Control) switch (_acrT1Control)
{ {
@ -216,7 +216,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
break; break;
} }
} }
else if (_t1C < 0) else if (_t1C < 0)
{ {
if (_t1CLoaded) if (_t1CLoaded)
{ {
@ -331,7 +331,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
break; break;
} }
// interrupt generation // interrupt generation
if (_acrSrControl == ACR_SR_CONTROL_DISABLED) if (_acrSrControl == ACR_SR_CONTROL_DISABLED)
{ {
@ -350,30 +350,30 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
with output pins on the peripheral ports. with output pins on the peripheral ports.
*/ */
if ((_pcrCa1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Ca1 && !_ca1L) || if ((_pcrCa1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Ca1 && !_ca1L) ||
(_pcrCa1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Ca1 && _ca1L)) (_pcrCa1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Ca1 && _ca1L))
{ {
if (_acrPaLatchEnable && (_ifr & 0x02) == 0) if (_acrPaLatchEnable && (_ifr & 0x02) == 0)
_paLatch = _port.ReadExternalPra(); _paLatch = _port.ReadExternalPra();
_ifr |= 0x02; _ifr |= 0x02;
} }
/* /*
Input latching on the PB port is controlled in the same manner as that described for the PA port. Input latching on the PB port is controlled in the same manner as that described for the PA port.
However, with the peripheral B port the input latch will store either the voltage on the pin or the contents However, with the peripheral B port the input latch will store either the voltage on the pin or the contents
of the Output Register (ORB) depending on whether the pin is programmed to act as an input or an of the Output Register (ORB) depending on whether the pin is programmed to act as an input or an
output. As with the PA port, the processor always reads the input latches. output. As with the PA port, the processor always reads the input latches.
*/ */
if ((_pcrCb1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Cb1 && !_cb1L) || if ((_pcrCb1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Cb1 && !_cb1L) ||
(_pcrCb1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Cb1 && _cb1L)) (_pcrCb1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Cb1 && _cb1L))
{ {
if (_acrPbLatchEnable && (_ifr & 0x10) == 0) if (_acrPbLatchEnable && (_ifr & 0x10) == 0)
_pbLatch = _port.ReadPrb(_prb, _ddrb); _pbLatch = _port.ReadPrb(_prb, _ddrb);
if (_acrSrControl == ACR_SR_CONTROL_DISABLED) if (_acrSrControl == ACR_SR_CONTROL_DISABLED)
_shiftIn = true; _shiftIn = true;
_ifr |= 0x10; _ifr |= 0x10;
} }
if (_shiftIn) if (_shiftIn)
{ {

View File

@ -128,27 +128,27 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
newVblankStart = 0xFA + hBorderSize; newVblankStart = 0xFA + hBorderSize;
newVblankEnd = 0x32 - hBorderSize; newVblankEnd = 0x32 - hBorderSize;
break; break;
case C64.BorderType.None: case C64.BorderType.None:
newHblankStart = 0x158 + PixBufferSize; newHblankStart = 0x158 + PixBufferSize;
newHblankEnd = 0x018 + PixBufferSize; newHblankEnd = 0x018 + PixBufferSize;
newVblankStart = 0xFA; newVblankStart = 0xFA;
newVblankEnd = 0x32; newVblankEnd = 0x32;
_vblank = true; _vblank = true;
_hblank = true; _hblank = true;
break; break;
} }
// wrap values // wrap values
if (_hblank) if (_hblank)
{ {
newHblankStart = WrapValue(0, maxWidth, newHblankStart); newHblankStart = WrapValue(0, maxWidth, newHblankStart);
newHblankEnd = WrapValue(0, maxWidth, newHblankEnd); newHblankEnd = WrapValue(0, maxWidth, newHblankEnd);
} }
if (_vblank) if (_vblank)
{ {
newVblankStart = WrapValue(0, lines, newVblankStart); newVblankStart = WrapValue(0, lines, newVblankStart);
newVblankEnd = WrapValue(0, lines, newVblankEnd); newVblankEnd = WrapValue(0, lines, newVblankEnd);
} }
// calculate output dimensions // calculate output dimensions
_hblankStartCheckXRaster = newHblankStart & 0xFFC; _hblankStartCheckXRaster = newHblankStart & 0xFFC;

View File

@ -181,76 +181,76 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
public static Disk Read(byte[] source) public static Disk Read(byte[] source)
{ {
var formatB = source[D64_DISK_ID_OFFSET + 0x00]; var formatB = source[D64_DISK_ID_OFFSET + 0x00];
var formatA = source[D64_DISK_ID_OFFSET + 0x01]; var formatA = source[D64_DISK_ID_OFFSET + 0x01];
using (var mem = new MemoryStream(source)) using (var mem = new MemoryStream(source))
{ {
var reader = new BinaryReader(mem); var reader = new BinaryReader(mem);
var trackDatas = new List<byte[]>(); var trackDatas = new List<byte[]>();
var trackLengths = new List<int>(); var trackLengths = new List<int>();
var trackNumbers = new List<int>(); var trackNumbers = new List<int>();
var trackDensities = new List<int>(); var trackDensities = new List<int>();
var errorType = ErrorType.NoError; var errorType = ErrorType.NoError;
int trackCount; int trackCount;
int errorOffset = -1; int errorOffset = -1;
switch (source.Length) switch (source.Length)
{ {
case 174848: // 35 tracks no errors case 174848: // 35 tracks no errors
trackCount = 35; trackCount = 35;
break; break;
case 175531: // 35 tracks with errors case 175531: // 35 tracks with errors
trackCount = 35; trackCount = 35;
errorOffset = 174848; errorOffset = 174848;
break; break;
case 196608: // 40 tracks no errors case 196608: // 40 tracks no errors
trackCount = 40; trackCount = 40;
break; break;
case 197376: // 40 tracks with errors case 197376: // 40 tracks with errors
trackCount = 40; trackCount = 40;
errorOffset = 196608; errorOffset = 196608;
break; break;
default: default:
throw new Exception("Not able to identify capacity of the D64 file."); throw new Exception("Not able to identify capacity of the D64 file.");
} }
for (var i = 0; i < trackCount; i++) for (var i = 0; i < trackCount; i++)
{ {
if (errorOffset >= 0) if (errorOffset >= 0)
{ {
errorType = (ErrorType) source[errorOffset]; errorType = (ErrorType) source[errorOffset];
errorOffset++; errorOffset++;
} }
var sectors = SectorsPerTrack[i]; var sectors = SectorsPerTrack[i];
var trackLengthBits = 0; var trackLengthBits = 0;
using (var trackMem = new MemoryStream()) using (var trackMem = new MemoryStream())
{ {
for (var j = 0; j < sectors; j++) for (var j = 0; j < sectors; j++)
{ {
int bitsWritten; int bitsWritten;
var sectorData = reader.ReadBytes(256); var sectorData = reader.ReadBytes(256);
var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out bitsWritten); var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out bitsWritten);
trackMem.Write(diskData, 0, diskData.Length); trackMem.Write(diskData, 0, diskData.Length);
trackLengthBits += bitsWritten; trackLengthBits += bitsWritten;
} }
var density = DensityTable[i]; var density = DensityTable[i];
// we pad the tracks with extra gap bytes to meet MNIB standards // we pad the tracks with extra gap bytes to meet MNIB standards
while (trackMem.Length < StandardTrackLengthBytes[density]) while (trackMem.Length < StandardTrackLengthBytes[density])
{ {
trackMem.WriteByte(0x55); trackMem.WriteByte(0x55);
} }
trackDatas.Add(trackMem.ToArray()); trackDatas.Add(trackMem.ToArray());
trackLengths.Add(trackLengthBits); trackLengths.Add(trackLengthBits);
trackNumbers.Add(i * 2); trackNumbers.Add(i * 2);
trackDensities.Add(DensityTable[i]); trackDensities.Add(DensityTable[i]);
} }
} }
return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = false}; return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = false};
} }
} }
} }
} }

View File

@ -64,79 +64,79 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
} }
} }
public static byte[] Write(IList<byte[]> trackData, IList<int> trackNumbers, IList<int> trackDensities) public static byte[] Write(IList<byte[]> trackData, IList<int> trackNumbers, IList<int> trackDensities)
{ {
const byte version = 0; const byte version = 0;
const byte trackCount = 84; const byte trackCount = 84;
const int headerLength = 0xC; const int headerLength = 0xC;
const byte dataFillerValue = 0xFF; const byte dataFillerValue = 0xFF;
var trackMaxLength = (ushort)Math.Max(7928, trackData.Max(d => d.Length)); var trackMaxLength = (ushort)Math.Max(7928, trackData.Max(d => d.Length));
using (var mem = new MemoryStream()) using (var mem = new MemoryStream())
{ {
var writer = new BinaryWriter(mem); var writer = new BinaryWriter(mem);
// header ID // header ID
writer.Write("GCR-1541".ToCharArray()); writer.Write("GCR-1541".ToCharArray());
// version # // version #
writer.Write(version); writer.Write(version);
// tracks in the image // tracks in the image
writer.Write(trackCount); writer.Write(trackCount);
// maximum track size in bytes // maximum track size in bytes
writer.Write(trackMaxLength); writer.Write(trackMaxLength);
// combine track data // combine track data
var offsets = new List<int>(); var offsets = new List<int>();
var densities = new List<int>(); var densities = new List<int>();
using (var trackMem = new MemoryStream()) using (var trackMem = new MemoryStream())
{ {
var trackMemWriter = new BinaryWriter(trackMem); var trackMemWriter = new BinaryWriter(trackMem);
for (var i = 0; i < trackCount; i++) for (var i = 0; i < trackCount; i++)
{ {
if (trackNumbers.Contains(i)) if (trackNumbers.Contains(i))
{ {
var trackIndex = trackNumbers.IndexOf(i); var trackIndex = trackNumbers.IndexOf(i);
offsets.Add((int)trackMem.Length); offsets.Add((int)trackMem.Length);
densities.Add(trackDensities[trackIndex]); densities.Add(trackDensities[trackIndex]);
var data = trackData[trackIndex]; var data = trackData[trackIndex];
var buffer = Enumerable.Repeat(dataFillerValue, trackMaxLength).ToArray(); var buffer = Enumerable.Repeat(dataFillerValue, trackMaxLength).ToArray();
var dataBytes = data.Select(d => unchecked((byte)d)).ToArray(); var dataBytes = data.Select(d => unchecked((byte)d)).ToArray();
Array.Copy(dataBytes, buffer, dataBytes.Length); Array.Copy(dataBytes, buffer, dataBytes.Length);
trackMemWriter.Write((ushort)dataBytes.Length); trackMemWriter.Write((ushort)dataBytes.Length);
trackMemWriter.Write(buffer); trackMemWriter.Write(buffer);
} }
else else
{ {
offsets.Add(-1); offsets.Add(-1);
densities.Add(0); densities.Add(0);
} }
} }
trackMemWriter.Flush(); trackMemWriter.Flush();
// offset table // offset table
foreach (var offset in offsets.Select(o => o >= 0 ? o + headerLength + trackCount * 8 : 0)) foreach (var offset in offsets.Select(o => o >= 0 ? o + headerLength + trackCount * 8 : 0))
{ {
writer.Write(offset); writer.Write(offset);
} }
// speed zone data // speed zone data
foreach (var density in densities) foreach (var density in densities)
{ {
writer.Write(density); writer.Write(density);
} }
// track data // track data
writer.Write(trackMem.ToArray()); writer.Write(trackMem.ToArray());
} }
writer.Flush(); writer.Flush();
return mem.ToArray(); return mem.ToArray();
} }
} }
} }
} }

View File

@ -36,167 +36,167 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial
_rngCurrent = unchecked((int) ((_rngCurrent * LEHMER_RNG_PRIME) & int.MaxValue)); _rngCurrent = unchecked((int) ((_rngCurrent * LEHMER_RNG_PRIME) & int.MaxValue));
} }
private void ExecuteFlux() private void ExecuteFlux()
{ {
// This actually executes the main 16mhz clock // This actually executes the main 16mhz clock
while (_clocks > 0) while (_clocks > 0)
{ {
_clocks--; _clocks--;
// rotate disk // rotate disk
if (_motorEnabled) if (_motorEnabled)
{ {
if (_disk == null) if (_disk == null)
{ {
_diskBitsLeft = 1; _diskBitsLeft = 1;
_diskBits = 0; _diskBits = 0;
} }
else else
{ {
if (_diskBitsLeft <= 0) if (_diskBitsLeft <= 0)
{ {
if (_diskWriteEnabled) if (_diskWriteEnabled)
_trackImageData[_diskByteOffset] = _diskOutputBits; _trackImageData[_diskByteOffset] = _diskOutputBits;
_diskByteOffset++; _diskByteOffset++;
if (_diskByteOffset == Disk.FluxEntriesPerTrack) if (_diskByteOffset == Disk.FluxEntriesPerTrack)
_diskByteOffset = 0; _diskByteOffset = 0;
if (!_diskWriteEnabled) if (!_diskWriteEnabled)
_diskBits = _trackImageData[_diskByteOffset]; _diskBits = _trackImageData[_diskByteOffset];
_diskOutputBits = 0; _diskOutputBits = 0;
_diskBitsLeft = Disk.FluxBitsPerEntry; _diskBitsLeft = Disk.FluxBitsPerEntry;
} }
} }
_diskOutputBits >>= 1; _diskOutputBits >>= 1;
if (_diskWriteEnabled && !_diskWriteProtected) if (_diskWriteEnabled && !_diskWriteProtected)
_countsBeforeRandomTransition = 0; _countsBeforeRandomTransition = 0;
if ((_diskBits & 1) != 0) if ((_diskBits & 1) != 0)
{ {
_countsBeforeRandomTransition = 0; _countsBeforeRandomTransition = 0;
_diskFluxReversalDetected = true; _diskFluxReversalDetected = true;
_diskOutputBits |= int.MinValue; // set bit 31 _diskOutputBits |= int.MinValue; // set bit 31
} }
else else
{ {
_diskOutputBits &= int.MaxValue; // clear bit 31 _diskOutputBits &= int.MaxValue; // clear bit 31
} }
_diskBits >>= 1; _diskBits >>= 1;
_diskBitsLeft--; _diskBitsLeft--;
} }
// random flux transition readings for unformatted data // random flux transition readings for unformatted data
if (_countsBeforeRandomTransition > 0) if (_countsBeforeRandomTransition > 0)
{ {
_countsBeforeRandomTransition--; _countsBeforeRandomTransition--;
if (_countsBeforeRandomTransition == 0) if (_countsBeforeRandomTransition == 0)
{ {
_diskFluxReversalDetected = true; _diskFluxReversalDetected = true;
AdvanceRng(); AdvanceRng();
// This constant is what VICE uses. TODO: Determine accuracy. // This constant is what VICE uses. TODO: Determine accuracy.
_countsBeforeRandomTransition = (_rngCurrent % 367) + 33; _countsBeforeRandomTransition = (_rngCurrent % 367) + 33;
} }
} }
// flux transition circuitry // flux transition circuitry
if (_diskFluxReversalDetected) if (_diskFluxReversalDetected)
{ {
if (!_diskWriteEnabled) if (!_diskWriteEnabled)
{ {
_diskDensityCounter = _diskDensity; _diskDensityCounter = _diskDensity;
_diskSupplementaryCounter = 0; _diskSupplementaryCounter = 0;
} }
_diskFluxReversalDetected = false; _diskFluxReversalDetected = false;
if (_countsBeforeRandomTransition == 0) if (_countsBeforeRandomTransition == 0)
{ {
AdvanceRng(); AdvanceRng();
// This constant is what VICE uses. TODO: Determine accuracy. // This constant is what VICE uses. TODO: Determine accuracy.
_countsBeforeRandomTransition = (_rngCurrent & 0x1F) + 289; _countsBeforeRandomTransition = (_rngCurrent & 0x1F) + 289;
} }
} }
// counter circuitry // counter circuitry
if (_diskDensityCounter >= 16) if (_diskDensityCounter >= 16)
{ {
_diskDensityCounter = _diskDensity; _diskDensityCounter = _diskDensity;
_diskSupplementaryCounter++; _diskSupplementaryCounter++;
if ((_diskSupplementaryCounter & 0x3) == 0x2) if ((_diskSupplementaryCounter & 0x3) == 0x2)
{ {
if (!_diskWriteEnabled) if (!_diskWriteEnabled)
_diskWriteBitsRemaining = 0; _diskWriteBitsRemaining = 0;
_diskWriteEnabled = !Via1.Cb2; _diskWriteEnabled = !Via1.Cb2;
_diskWriteBitsRemaining--; _diskWriteBitsRemaining--;
if (_diskWriteEnabled) if (_diskWriteEnabled)
{ {
_countsBeforeRandomTransition = 0; _countsBeforeRandomTransition = 0;
_byteReady = false; _byteReady = false;
if (_diskWriteBitsRemaining <= 0) if (_diskWriteBitsRemaining <= 0)
{ {
_diskWriteLatch = Via1.EffectivePrA; _diskWriteLatch = Via1.EffectivePrA;
_diskWriteBitsRemaining = 8; _diskWriteBitsRemaining = 8;
_byteReady = Via1.Ca2; _byteReady = Via1.Ca2;
} }
if ((_diskWriteLatch & 0x80) != 0) if ((_diskWriteLatch & 0x80) != 0)
{ {
_diskOutputBits |= int.MinValue; // set bit 31 _diskOutputBits |= int.MinValue; // set bit 31
} }
_diskWriteLatch <<= 1; _diskWriteLatch <<= 1;
} }
else else
{ {
_bitsRemainingInLatchedByte--; _bitsRemainingInLatchedByte--;
_byteReady = false; _byteReady = false;
_bitHistory = (_bitHistory << 1) | ((_diskSupplementaryCounter & 0xC) == 0x0 ? 1 : 0); _bitHistory = (_bitHistory << 1) | ((_diskSupplementaryCounter & 0xC) == 0x0 ? 1 : 0);
_sync = false; _sync = false;
if (!_diskWriteEnabled && (_bitHistory & 0x3FF) == 0x3FF) if (!_diskWriteEnabled && (_bitHistory & 0x3FF) == 0x3FF)
{ {
_sync = true; _sync = true;
_bitsRemainingInLatchedByte = 8; _bitsRemainingInLatchedByte = 8;
_byteReady = false; _byteReady = false;
} }
if (_bitsRemainingInLatchedByte <= 0) if (_bitsRemainingInLatchedByte <= 0)
{ {
_bitsRemainingInLatchedByte = 8; _bitsRemainingInLatchedByte = 8;
// SOE (SO/Byte Ready enabled) // SOE (SO/Byte Ready enabled)
_byteReady = Via1.Ca2; _byteReady = Via1.Ca2;
} }
} }
} }
// negative transition activates SO pin on CPU // negative transition activates SO pin on CPU
_previousCa1 = Via1.Ca1; _previousCa1 = Via1.Ca1;
Via1.Ca1 = !_byteReady; Via1.Ca1 = !_byteReady;
if (_previousCa1 && !Via1.Ca1) if (_previousCa1 && !Via1.Ca1)
{ {
// cycle 6 is roughly 400ns // cycle 6 is roughly 400ns
_overflowFlagDelaySr |= _diskCycle > 6 ? 4 : 2; _overflowFlagDelaySr |= _diskCycle > 6 ? 4 : 2;
} }
} }
if (_diskSupplementaryCounter >= 16) if (_diskSupplementaryCounter >= 16)
{ {
_diskSupplementaryCounter = 0; _diskSupplementaryCounter = 0;
} }
_cpuClocks--; _cpuClocks--;
if (_cpuClocks <= 0) if (_cpuClocks <= 0)
{ {
ExecuteSystem(); ExecuteSystem();
_cpuClocks = 16; _cpuClocks = 16;
} }
_diskDensityCounter++; _diskDensityCounter++;
_diskCycle = (_diskCycle + 1) & 0xF; _diskCycle = (_diskCycle + 1) & 0xF;
} }
} }
} }
} }

View File

@ -429,82 +429,82 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public static readonly int[] PALPalette = public static readonly int[] PALPalette =
{ {
0x000000, 0x1c1c1c, 0x393939, 0x595959, // Grey 0x000000, 0x1c1c1c, 0x393939, 0x595959, // Grey
0x797979, 0x929292, 0xababab, 0xbcbcbc, 0x797979, 0x929292, 0xababab, 0xbcbcbc,
0xcdcdcd, 0xd9d9d9, 0xe6e6e6, 0xececec, 0xcdcdcd, 0xd9d9d9, 0xe6e6e6, 0xececec,
0xf2f2f2, 0xf8f8f8, 0xffffff, 0xffffff, 0xf2f2f2, 0xf8f8f8, 0xffffff, 0xffffff,
0x263001, 0x243803, 0x234005, 0x51541b, // Orange Green 0x263001, 0x243803, 0x234005, 0x51541b, // Orange Green
0x806931, 0x978135, 0xaf993a, 0xc2a73e, 0x806931, 0x978135, 0xaf993a, 0xc2a73e,
0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836, 0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836,
0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d, 0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d,
0x263001, 0x243803, 0x234005, 0x51541b, // Orange Green 0x263001, 0x243803, 0x234005, 0x51541b, // Orange Green
0x806931, 0x978135, 0xaf993a, 0xc2a73e, 0x806931, 0x978135, 0xaf993a, 0xc2a73e,
0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836, 0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836,
0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d, 0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d,
0x401a02, 0x581f05, 0x702408, 0x8d3a13, // Light Orange 0x401a02, 0x581f05, 0x702408, 0x8d3a13, // Light Orange
0xab511f, 0xb56427, 0xbf7730, 0xd0853a, 0xab511f, 0xb56427, 0xbf7730, 0xd0853a,
0xe19344, 0xeda04e, 0xf9ad58, 0xfcb75c, 0xe19344, 0xeda04e, 0xf9ad58, 0xfcb75c,
0xffc160, 0xffc671, 0xffcb83, 0xffcb83, 0xffc160, 0xffc671, 0xffcb83, 0xffcb83,
0x391701, 0x5e2304, 0x833008, 0xa54716, // Gold 0x391701, 0x5e2304, 0x833008, 0xa54716, // Gold
0xc85f24, 0xe37820, 0xff911d, 0xffab1d, 0xc85f24, 0xe37820, 0xff911d, 0xffab1d,
0xffc51d, 0xffce34, 0xffd84c, 0xffe651, 0xffc51d, 0xffce34, 0xffd84c, 0xffe651,
0xfff456, 0xfff977, 0xffff98, 0xffff98, 0xfff456, 0xfff977, 0xffff98, 0xffff98,
0x451904, 0x721e11, 0x9f241e, 0xb33a20, // Orange 0x451904, 0x721e11, 0x9f241e, 0xb33a20, // Orange
0xc85122, 0xe36920, 0xff811e, 0xff8c25, 0xc85122, 0xe36920, 0xff811e, 0xff8c25,
0xff982c, 0xffae38, 0xffc545, 0xffc559, 0xff982c, 0xffae38, 0xffc545, 0xffc559,
0xffc66d, 0xffd587, 0xffe4a1, 0xffe4a1, 0xffc66d, 0xffd587, 0xffe4a1, 0xffe4a1,
0x4a1704, 0x7e1a0d, 0xb21d17, 0xc82119, // Red Orange 0x4a1704, 0x7e1a0d, 0xb21d17, 0xc82119, // Red Orange
0xdf251c, 0xec3b38, 0xfa5255, 0xfc6161, 0xdf251c, 0xec3b38, 0xfa5255, 0xfc6161,
0xff706e, 0xff7f7e, 0xff8f8f, 0xff9d9e, 0xff706e, 0xff7f7e, 0xff8f8f, 0xff9d9e,
0xffabad, 0xffb9bd, 0xffc7ce, 0xffc7ce, 0xffabad, 0xffb9bd, 0xffc7ce, 0xffc7ce,
0x050568, 0x3b136d, 0x712272, 0x8b2a8c, // Pink 0x050568, 0x3b136d, 0x712272, 0x8b2a8c, // Pink
0xa532a6, 0xb938ba, 0xcd3ecf, 0xdb47dd, 0xa532a6, 0xb938ba, 0xcd3ecf, 0xdb47dd,
0xea51eb, 0xf45ff5, 0xfe6dff, 0xfe7afd, 0xea51eb, 0xf45ff5, 0xfe6dff, 0xfe7afd,
0xff87fb, 0xff95fd, 0xffa4ff, 0xffa4ff, 0xff87fb, 0xff95fd, 0xffa4ff, 0xffa4ff,
0x280479, 0x400984, 0x590f90, 0x70249d, // Purple 0x280479, 0x400984, 0x590f90, 0x70249d, // Purple
0x8839aa, 0xa441c3, 0xc04adc, 0xd054ed, 0x8839aa, 0xa441c3, 0xc04adc, 0xd054ed,
0xe05eff, 0xe96dff, 0xf27cff, 0xf88aff, 0xe05eff, 0xe96dff, 0xf27cff, 0xf88aff,
0xff98ff, 0xfea1ff, 0xfeabff, 0xfeabff, 0xff98ff, 0xfea1ff, 0xfeabff, 0xfeabff,
0x051e81, 0x0626a5, 0x082fca, 0x263dd4, // Blue1 0x051e81, 0x0626a5, 0x082fca, 0x263dd4, // Blue1
0x444cde, 0x4f5aee, 0x5a68ff, 0x6575ff, 0x444cde, 0x4f5aee, 0x5a68ff, 0x6575ff,
0x7183ff, 0x8091ff, 0x90a0ff, 0x97a9ff, 0x7183ff, 0x8091ff, 0x90a0ff, 0x97a9ff,
0x9fb2ff, 0xafbeff, 0xc0cbff, 0xc0cbff, 0x9fb2ff, 0xafbeff, 0xc0cbff, 0xc0cbff,
0x0c048b, 0x2218a0, 0x382db5, 0x483ec7, // Blue2 0x0c048b, 0x2218a0, 0x382db5, 0x483ec7, // Blue2
0x584fda, 0x6159ec, 0x6b64ff, 0x7a74ff, 0x584fda, 0x6159ec, 0x6b64ff, 0x7a74ff,
0x8a84ff, 0x918eff, 0x9998ff, 0xa5a3ff, 0x8a84ff, 0x918eff, 0x9998ff, 0xa5a3ff,
0xb1aeff, 0xb8b8ff, 0xc0c2ff, 0xc0c2ff, 0xb1aeff, 0xb8b8ff, 0xc0c2ff, 0xc0c2ff,
0x1d295a, 0x1d3876, 0x1d4892, 0x1c5cac, // Light Blue 0x1d295a, 0x1d3876, 0x1d4892, 0x1c5cac, // Light Blue
0x1c71c6, 0x3286cf, 0x489bd9, 0x4ea8ec, 0x1c71c6, 0x3286cf, 0x489bd9, 0x4ea8ec,
0x55b6ff, 0x70c7ff, 0x8cd8ff, 0x93dbff, 0x55b6ff, 0x70c7ff, 0x8cd8ff, 0x93dbff,
0x9bdfff, 0xafe4ff, 0xc3e9ff, 0xc3e9ff, 0x9bdfff, 0xafe4ff, 0xc3e9ff, 0xc3e9ff,
0x2f4302, 0x395202, 0x446103, 0x417a12, // Turquoise 0x2f4302, 0x395202, 0x446103, 0x417a12, // Turquoise
0x3e9421, 0x4a9f2e, 0x57ab3b, 0x5cbd55, 0x3e9421, 0x4a9f2e, 0x57ab3b, 0x5cbd55,
0x61d070, 0x69e27a, 0x72f584, 0x7cfa8d, 0x61d070, 0x69e27a, 0x72f584, 0x7cfa8d,
0x87ff97, 0x9affa6, 0xadffb6, 0xadffb6, 0x87ff97, 0x9affa6, 0xadffb6, 0xadffb6,
0x0a4108, 0x0d540a, 0x10680d, 0x137d0f, // Green Blue 0x0a4108, 0x0d540a, 0x10680d, 0x137d0f, // Green Blue
0x169212, 0x19a514, 0x1cb917, 0x1ec919, 0x169212, 0x19a514, 0x1cb917, 0x1ec919,
0x21d91b, 0x47e42d, 0x6ef040, 0x78f74d, 0x21d91b, 0x47e42d, 0x6ef040, 0x78f74d,
0x83ff5b, 0x9aff7a, 0xb2ff9a, 0xb2ff9a, 0x83ff5b, 0x9aff7a, 0xb2ff9a, 0xb2ff9a,
0x04410b, 0x05530e, 0x066611, 0x077714, // Green 0x04410b, 0x05530e, 0x066611, 0x077714, // Green
0x088817, 0x099b1a, 0x0baf1d, 0x48c41f, 0x088817, 0x099b1a, 0x0baf1d, 0x48c41f,
0x86d922, 0x8fe924, 0x99f927, 0xa8fc41, 0x86d922, 0x8fe924, 0x99f927, 0xa8fc41,
0xb7ff5b, 0xc9ff6e, 0xdcff81, 0xdcff81, 0xb7ff5b, 0xc9ff6e, 0xdcff81, 0xdcff81,
0x02350f, 0x073f15, 0x0c4a1c, 0x2d5f1e, // Yellow Green 0x02350f, 0x073f15, 0x0c4a1c, 0x2d5f1e, // Yellow Green
0x4f7420, 0x598324, 0x649228, 0x82a12e, 0x4f7420, 0x598324, 0x649228, 0x82a12e,
0xa1b034, 0xa9c13a, 0xb2d241, 0xc4d945, 0xa1b034, 0xa9c13a, 0xb2d241, 0xc4d945,
0xd6e149, 0xe4f04e, 0xf2ff53, 0xf2ff53 0xd6e149, 0xe4f04e, 0xf2ff53, 0xf2ff53
}; };

View File

@ -63,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static byte[] TRIANGLE_TABLE = static byte[] TRIANGLE_TABLE =
{ {
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
}; };
static int[] NOISE_TABLE_NTSC = static int[] NOISE_TABLE_NTSC =
{ {

View File

@ -2,8 +2,8 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
public partial class NES public partial class NES
{ {
public struct CpuLink : IMOS6502XLink public struct CpuLink : IMOS6502XLink
{ {
private readonly NES _nes; private readonly NES _nes;

View File

@ -1,143 +1,143 @@
namespace BizHawk.Emulation.Cores.Sega.MasterSystem namespace BizHawk.Emulation.Cores.Sega.MasterSystem
{ {
public partial class VDP public partial class VDP
{ {
// TODO: HCounter // TODO: HCounter
readonly byte[] VLineCounterTableNTSC192 = readonly byte[] VLineCounterTableNTSC192 =
{ {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
}; };
readonly byte[] VLineCounterTableNTSC224 = readonly byte[] VLineCounterTableNTSC224 =
{ {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
}; };
readonly byte[] VLineCounterTableNTSC240 = readonly byte[] VLineCounterTableNTSC240 =
{ {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05 0x00, 0x01, 0x02, 0x03, 0x04, 0x05
}; };
readonly byte[] VLineCounterTablePAL192 = readonly byte[] VLineCounterTablePAL192 =
{ {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF0, 0xF1, 0xF2,
0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
}; };
readonly byte[] VLineCounterTablePAL224 = readonly byte[] VLineCounterTablePAL224 =
{ {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
0x00, 0x01, 0x02, 0x00, 0x01, 0x02,
0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
}; };
readonly byte[] VLineCounterTablePAL240 = readonly byte[] VLineCounterTablePAL240 =
{ {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
}; };
} }
} }

View File

@ -42,8 +42,8 @@ namespace BizHawk.Emulation.Cores
WS, WSC, NGC, WS, WSC, NGC,
C64, C64,
ZXSpectrum, ZXSpectrum,
AmstradCPC, AmstradCPC,
INT, INT,
A26, A52, A78, LNX, A26, A52, A78, LNX,

View File

@ -526,134 +526,134 @@ namespace BizHawk.Emulation.Common.Components
#region tables #region tables
static readonly byte[] egRateCounterShiftValues = static readonly byte[] egRateCounterShiftValues =
{ {
11, 11, 11, 11, // Rates 0-3 11, 11, 11, 11, // Rates 0-3
10, 10, 10, 10, // Rates 4-7 10, 10, 10, 10, // Rates 4-7
9, 9, 9, 9, // Rates 8-11 9, 9, 9, 9, // Rates 8-11
8, 8, 8, 8, // Rates 12-15 8, 8, 8, 8, // Rates 12-15
7, 7, 7, 7, // Rates 16-19 7, 7, 7, 7, // Rates 16-19
6, 6, 6, 6, // Rates 20-23 6, 6, 6, 6, // Rates 20-23
5, 5, 5, 5, // Rates 24-27 5, 5, 5, 5, // Rates 24-27
4, 4, 4, 4, // Rates 28-31 4, 4, 4, 4, // Rates 28-31
3, 3, 3, 3, // Rates 32-35 3, 3, 3, 3, // Rates 32-35
2, 2, 2, 2, // Rates 36-39 2, 2, 2, 2, // Rates 36-39
1, 1, 1, 1, // Rates 40-43 1, 1, 1, 1, // Rates 40-43
0, 0, 0, 0, // Rates 44-47 0, 0, 0, 0, // Rates 44-47
0, 0, 0, 0, // Rates 48-51 0, 0, 0, 0, // Rates 48-51
0, 0, 0, 0, // Rates 52-55 0, 0, 0, 0, // Rates 52-55
0, 0, 0, 0, // Rates 56-59 0, 0, 0, 0, // Rates 56-59
0, 0, 0, 0 // Rates 60-63 0, 0, 0, 0 // Rates 60-63
}; };
static readonly byte[] egRateIncrementValues = static readonly byte[] egRateIncrementValues =
{ {
0,0,0,0,0,0,0,0, // Rate 0 0,0,0,0,0,0,0,0, // Rate 0
0,0,0,0,0,0,0,0, // Rate 1 0,0,0,0,0,0,0,0, // Rate 1
0,1,0,1,0,1,0,1, // Rate 2 0,1,0,1,0,1,0,1, // Rate 2
0,1,0,1,0,1,0,1, // Rate 3 0,1,0,1,0,1,0,1, // Rate 3
0,1,0,1,0,1,0,1, // Rate 4 0,1,0,1,0,1,0,1, // Rate 4
0,1,0,1,0,1,0,1, // Rate 5 0,1,0,1,0,1,0,1, // Rate 5
0,1,1,1,0,1,1,1, // Rate 6 0,1,1,1,0,1,1,1, // Rate 6
0,1,1,1,0,1,1,1, // Rate 7 0,1,1,1,0,1,1,1, // Rate 7
0,1,0,1,0,1,0,1, // Rate 8 0,1,0,1,0,1,0,1, // Rate 8
0,1,0,1,1,1,0,1, // Rate 9 0,1,0,1,1,1,0,1, // Rate 9
0,1,1,1,0,1,1,1, // Rate 10 0,1,1,1,0,1,1,1, // Rate 10
0,1,1,1,1,1,1,1, // Rate 11 0,1,1,1,1,1,1,1, // Rate 11
0,1,0,1,0,1,0,1, // Rate 12 0,1,0,1,0,1,0,1, // Rate 12
0,1,0,1,1,1,0,1, // Rate 13 0,1,0,1,1,1,0,1, // Rate 13
0,1,1,1,0,1,1,1, // Rate 14 0,1,1,1,0,1,1,1, // Rate 14
0,1,1,1,1,1,1,1, // Rate 15 0,1,1,1,1,1,1,1, // Rate 15
0,1,0,1,0,1,0,1, // Rate 16 0,1,0,1,0,1,0,1, // Rate 16
0,1,0,1,1,1,0,1, // Rate 17 0,1,0,1,1,1,0,1, // Rate 17
0,1,1,1,0,1,1,1, // Rate 18 0,1,1,1,0,1,1,1, // Rate 18
0,1,1,1,1,1,1,1, // Rate 19 0,1,1,1,1,1,1,1, // Rate 19
0,1,0,1,0,1,0,1, // Rate 20 0,1,0,1,0,1,0,1, // Rate 20
0,1,0,1,1,1,0,1, // Rate 21 0,1,0,1,1,1,0,1, // Rate 21
0,1,1,1,0,1,1,1, // Rate 22 0,1,1,1,0,1,1,1, // Rate 22
0,1,1,1,1,1,1,1, // Rate 23 0,1,1,1,1,1,1,1, // Rate 23
0,1,0,1,0,1,0,1, // Rate 24 0,1,0,1,0,1,0,1, // Rate 24
0,1,0,1,1,1,0,1, // Rate 25 0,1,0,1,1,1,0,1, // Rate 25
0,1,1,1,0,1,1,1, // Rate 26 0,1,1,1,0,1,1,1, // Rate 26
0,1,1,1,1,1,1,1, // Rate 27 0,1,1,1,1,1,1,1, // Rate 27
0,1,0,1,0,1,0,1, // Rate 28 0,1,0,1,0,1,0,1, // Rate 28
0,1,0,1,1,1,0,1, // Rate 29 0,1,0,1,1,1,0,1, // Rate 29
0,1,1,1,0,1,1,1, // Rate 30 0,1,1,1,0,1,1,1, // Rate 30
0,1,1,1,1,1,1,1, // Rate 31 0,1,1,1,1,1,1,1, // Rate 31
0,1,0,1,0,1,0,1, // Rate 32 0,1,0,1,0,1,0,1, // Rate 32
0,1,0,1,1,1,0,1, // Rate 33 0,1,0,1,1,1,0,1, // Rate 33
0,1,1,1,0,1,1,1, // Rate 34 0,1,1,1,0,1,1,1, // Rate 34
0,1,1,1,1,1,1,1, // Rate 35 0,1,1,1,1,1,1,1, // Rate 35
0,1,0,1,0,1,0,1, // Rate 36 0,1,0,1,0,1,0,1, // Rate 36
0,1,0,1,1,1,0,1, // Rate 37 0,1,0,1,1,1,0,1, // Rate 37
0,1,1,1,0,1,1,1, // Rate 38 0,1,1,1,0,1,1,1, // Rate 38
0,1,1,1,1,1,1,1, // Rate 39 0,1,1,1,1,1,1,1, // Rate 39
0,1,0,1,0,1,0,1, // Rate 40 0,1,0,1,0,1,0,1, // Rate 40
0,1,0,1,1,1,0,1, // Rate 41 0,1,0,1,1,1,0,1, // Rate 41
0,1,1,1,0,1,1,1, // Rate 42 0,1,1,1,0,1,1,1, // Rate 42
0,1,1,1,1,1,1,1, // Rate 43 0,1,1,1,1,1,1,1, // Rate 43
0,1,0,1,0,1,0,1, // Rate 44 0,1,0,1,0,1,0,1, // Rate 44
0,1,0,1,1,1,0,1, // Rate 45 0,1,0,1,1,1,0,1, // Rate 45
0,1,1,1,0,1,1,1, // Rate 46 0,1,1,1,0,1,1,1, // Rate 46
0,1,1,1,1,1,1,1, // Rate 47 0,1,1,1,1,1,1,1, // Rate 47
1,1,1,1,1,1,1,1, // Rate 48 1,1,1,1,1,1,1,1, // Rate 48
1,1,1,2,1,1,1,2, // Rate 49 1,1,1,2,1,1,1,2, // Rate 49
1,2,1,2,1,2,1,2, // Rate 50 1,2,1,2,1,2,1,2, // Rate 50
1,2,2,2,1,2,2,2, // Rate 51 1,2,2,2,1,2,2,2, // Rate 51
2,2,2,2,2,2,2,2, // Rate 52 2,2,2,2,2,2,2,2, // Rate 52
2,2,2,4,2,2,2,4, // Rate 53 2,2,2,4,2,2,2,4, // Rate 53
2,4,2,4,2,4,2,4, // Rate 54 2,4,2,4,2,4,2,4, // Rate 54
2,4,4,4,2,4,4,4, // Rate 55 2,4,4,4,2,4,4,4, // Rate 55
4,4,4,4,4,4,4,4, // Rate 56 4,4,4,4,4,4,4,4, // Rate 56
4,4,4,8,4,4,4,8, // Rate 57 4,4,4,8,4,4,4,8, // Rate 57
4,8,4,8,4,8,4,8, // Rate 58 4,8,4,8,4,8,4,8, // Rate 58
4,8,8,8,4,8,8,8, // Rate 59 4,8,8,8,4,8,8,8, // Rate 59
8,8,8,8,8,8,8,8, // Rate 60 8,8,8,8,8,8,8,8, // Rate 60
8,8,8,8,8,8,8,8, // Rate 61 8,8,8,8,8,8,8,8, // Rate 61
8,8,8,8,8,8,8,8, // Rate 62 8,8,8,8,8,8,8,8, // Rate 62
8,8,8,8,8,8,8,8 // Rate 63 8,8,8,8,8,8,8,8 // Rate 63
}; };
static readonly int[] slTable = // translates a 4-bit SL value into a 10-bit attenuation value static readonly int[] slTable = // translates a 4-bit SL value into a 10-bit attenuation value
{ {
0x000, 0x020, 0x040, 0x060, 0x080, 0x0A0, 0x0C0, 0x0E0, 0x000, 0x020, 0x040, 0x060, 0x080, 0x0A0, 0x0C0, 0x0E0,
0x100, 0x120, 0x140, 0x160, 0x180, 0x1A0, 0x1C0, 0x3FF 0x100, 0x120, 0x140, 0x160, 0x180, 0x1A0, 0x1C0, 0x3FF
}; };
static readonly int[] detuneTable = static readonly int[] detuneTable =
{ {
0, 0, 1, 2, // Key-Code 0 0, 0, 1, 2, // Key-Code 0
0, 0, 1, 2, // Key-Code 1 0, 0, 1, 2, // Key-Code 1
0, 0, 1, 2, // Key-Code 2 0, 0, 1, 2, // Key-Code 2
0, 0, 1, 2, // Key-Code 3 0, 0, 1, 2, // Key-Code 3
0, 1, 2, 2, // Key-Code 4 0, 1, 2, 2, // Key-Code 4
0, 1, 2, 3, // Key-Code 5 0, 1, 2, 3, // Key-Code 5
0, 1, 2, 3, // Key-Code 6 0, 1, 2, 3, // Key-Code 6
0, 1, 2, 3, // Key-Code 7 0, 1, 2, 3, // Key-Code 7
0, 1, 2, 4, // Key-Code 8 0, 1, 2, 4, // Key-Code 8
0, 1, 3, 4, // Key-Code 9 0, 1, 3, 4, // Key-Code 9
0, 1, 3, 4, // Key-Code 10 0, 1, 3, 4, // Key-Code 10
0, 1, 3, 5, // Key-Code 11 0, 1, 3, 5, // Key-Code 11
0, 2, 4, 5, // Key-Code 12 0, 2, 4, 5, // Key-Code 12
0, 2, 4, 6, // Key-Code 13 0, 2, 4, 6, // Key-Code 13
0, 2, 4, 6, // Key-Code 14 0, 2, 4, 6, // Key-Code 14
0, 2, 5, 7, // Key-Code 15 0, 2, 5, 7, // Key-Code 15
0, 2, 5, 8, // Key-Code 16 0, 2, 5, 8, // Key-Code 16
0, 3, 6, 8, // Key-Code 17 0, 3, 6, 8, // Key-Code 17
0, 3, 6, 9, // Key-Code 18 0, 3, 6, 9, // Key-Code 18
0, 3, 7, 10, // Key-Code 19 0, 3, 7, 10, // Key-Code 19
0, 4, 8, 11, // Key-Code 20 0, 4, 8, 11, // Key-Code 20
0, 4, 8, 12, // Key-Code 21 0, 4, 8, 12, // Key-Code 21
0, 4, 9, 13, // Key-Code 22 0, 4, 9, 13, // Key-Code 22
0, 5, 10, 14, // Key-Code 23 0, 5, 10, 14, // Key-Code 23
0, 5, 11, 16, // Key-Code 24 0, 5, 11, 16, // Key-Code 24
0, 6, 12, 17, // Key-Code 25 0, 6, 12, 17, // Key-Code 25
0, 6, 13, 19, // Key-Code 26 0, 6, 13, 19, // Key-Code 26
0, 7, 14, 20, // Key-Code 27 0, 7, 14, 20, // Key-Code 27
0, 8, 16, 22, // Key-Code 28 0, 8, 16, 22, // Key-Code 28
0, 8, 16, 22, // Key-Code 29 0, 8, 16, 22, // Key-Code 29
0, 8, 16, 22, // Key-Code 30 0, 8, 16, 22, // Key-Code 30
0, 8, 16, 22 // Key-Code 31 0, 8, 16, 22 // Key-Code 31
}; };
#endregion #endregion
// ==================================================================================== // ====================================================================================

View File

@ -5,151 +5,151 @@ using System.Text;
namespace BizHawk.Emulation.DiscSystem namespace BizHawk.Emulation.DiscSystem
{ {
/// <summary> /// <summary>
/// Helper class to convert big and little endian numbers from a byte /// Helper class to convert big and little endian numbers from a byte
/// array to a value. /// array to a value.
/// ///
/// This code was modified from the endian bit converter presented by /// This code was modified from the endian bit converter presented by
/// Robert Unoki in his blog post: /// Robert Unoki in his blog post:
/// http://blogs.msdn.com/robunoki/archive/2006/04/05/568737.aspx /// http://blogs.msdn.com/robunoki/archive/2006/04/05/568737.aspx
/// ///
/// I have added support for more data types and the ability to /// I have added support for more data types and the ability to
/// specify an offset into the array to be converted where the value /// specify an offset into the array to be converted where the value
/// begins. /// begins.
/// </summary> /// </summary>
public class EndianBitConverter { public class EndianBitConverter {
#region Static Constructors #region Static Constructors
/// <summary> /// <summary>
/// Build a converter from little endian to the system endian-ness. /// Build a converter from little endian to the system endian-ness.
/// </summary> /// </summary>
/// <returns>The converter</returns> /// <returns>The converter</returns>
public static EndianBitConverter CreateForLittleEndian() { public static EndianBitConverter CreateForLittleEndian() {
return new EndianBitConverter(!BitConverter.IsLittleEndian); return new EndianBitConverter(!BitConverter.IsLittleEndian);
} }
/// <summary> /// <summary>
/// Build a converter from big endian to the system endian-ness. /// Build a converter from big endian to the system endian-ness.
/// </summary> /// </summary>
/// <returns>The converter</returns> /// <returns>The converter</returns>
public static EndianBitConverter CreateForBigEndian() { public static EndianBitConverter CreateForBigEndian() {
return new EndianBitConverter(BitConverter.IsLittleEndian); return new EndianBitConverter(BitConverter.IsLittleEndian);
} }
#endregion #endregion
#region Private Properties #region Private Properties
/// <summary> /// <summary>
/// Keep track of whether we need to swap the bytes or not /// Keep track of whether we need to swap the bytes or not
/// </summary> /// </summary>
private bool swap; private bool swap;
#endregion #endregion
#region Private Constructor #region Private Constructor
/// <summary> /// <summary>
/// Create the converter with the given endian-ness. /// Create the converter with the given endian-ness.
/// </summary> /// </summary>
/// <param name="swapBytes">Whether or not to swap bytes.</param> /// <param name="swapBytes">Whether or not to swap bytes.</param>
private EndianBitConverter(bool swapBytes) { private EndianBitConverter(bool swapBytes) {
swap = swapBytes; swap = swapBytes;
} }
#endregion #endregion
#region 16-bit #region 16-bit
public Int16 ToInt16(byte[] data) { public Int16 ToInt16(byte[] data) {
return ToInt16(data, 0); return ToInt16(data, 0);
} }
public Int16 ToInt16(byte[] data, int offset) { public Int16 ToInt16(byte[] data, int offset) {
byte[] corrected; byte[] corrected;
if (swap) { if (swap) {
corrected = (byte[])data.Clone(); corrected = (byte[])data.Clone();
Array.Reverse(corrected, offset, 2); Array.Reverse(corrected, offset, 2);
} }
else { else {
corrected = data; corrected = data;
} }
return BitConverter.ToInt16(corrected, offset); return BitConverter.ToInt16(corrected, offset);
} }
#endregion #endregion
#region 32-bit #region 32-bit
public Int32 ToInt32(byte[] data) { public Int32 ToInt32(byte[] data) {
return ToInt32(data, 0); return ToInt32(data, 0);
} }
public Int32 ToInt32(byte[] data, int offset) { public Int32 ToInt32(byte[] data, int offset) {
byte[] corrected; byte[] corrected;
if (swap) { if (swap) {
corrected = (byte[])data.Clone(); corrected = (byte[])data.Clone();
Array.Reverse(corrected, offset, 4); Array.Reverse(corrected, offset, 4);
} }
else { else {
corrected = data; corrected = data;
} }
return BitConverter.ToInt32(corrected, offset); return BitConverter.ToInt32(corrected, offset);
} }
#endregion #endregion
#region 64-bit #region 64-bit
public Int64 ToInt64(byte[] data) { public Int64 ToInt64(byte[] data) {
return ToInt64(data, 0); return ToInt64(data, 0);
} }
public Int64 ToInt64(byte[] data, int offset) { public Int64 ToInt64(byte[] data, int offset) {
byte[] corrected; byte[] corrected;
if (swap) { if (swap) {
corrected = (byte[])data.Clone(); corrected = (byte[])data.Clone();
Array.Reverse(corrected, offset, 8); Array.Reverse(corrected, offset, 8);
} }
else { else {
corrected = data; corrected = data;
} }
return BitConverter.ToInt64(corrected, offset); return BitConverter.ToInt64(corrected, offset);
} }
#endregion #endregion
// (asni 20171013) - Some methods I wrote that have been shoehorned in from another project to speed up development time // (asni 20171013) - Some methods I wrote that have been shoehorned in from another project to speed up development time
// If these are offensive in any way, tell me I suck and that I need to do more work with existing methods // If these are offensive in any way, tell me I suck and that I need to do more work with existing methods
#region Misc #region Misc
/// <summary> /// <summary>
/// Returns a byte array of any length /// Returns a byte array of any length
/// Not really anything endian going on, but I struggled to find a better place for it /// Not really anything endian going on, but I struggled to find a better place for it
/// </summary> /// </summary>
public byte[] ReadBytes(byte[] buffer, int offset, int length) public byte[] ReadBytes(byte[] buffer, int offset, int length)
{ {
return buffer.Skip(offset).Take(length).ToArray(); return buffer.Skip(offset).Take(length).ToArray();
} }
/// <summary> /// <summary>
/// Returns an int32 value from any size byte array /// Returns an int32 value from any size byte array
/// (careful, data may/will be truncated) /// (careful, data may/will be truncated)
/// </summary> /// </summary>
public int ReadIntValue(byte[] buffer, int offset, int length) public int ReadIntValue(byte[] buffer, int offset, int length)
{ {
var bytes = buffer.Skip(offset).Take(length).ToArray(); var bytes = buffer.Skip(offset).Take(length).ToArray();
if (swap) if (swap)
Array.Reverse(bytes); Array.Reverse(bytes);
if (length == 1) if (length == 1)
return bytes.FirstOrDefault(); return bytes.FirstOrDefault();
if (length == 2) if (length == 2)
return BitConverter.ToInt16(bytes, 0); return BitConverter.ToInt16(bytes, 0);
int result = BitConverter.ToInt32(bytes, 0); int result = BitConverter.ToInt32(bytes, 0);
return result; return result;
} }
#endregion #endregion
} }
} }

View File

@ -49,23 +49,23 @@ namespace BizHawk.Emulation.DiscSystem
List<ISONodeRecord> records = new List<ISONodeRecord>(); List<ISONodeRecord> records = new List<ISONodeRecord>();
// Read the directory entries // Read the directory entries
while (s.Position < ((this.Offset * ISOFile.SECTOR_SIZE) + this.Length)) while (s.Position < ((this.Offset * ISOFile.SECTOR_SIZE) + this.Length))
{ {
ISONode node; ISONode node;
ISONodeRecord record; ISONodeRecord record;
// Read the record // Read the record
record = new ISONodeRecord(); record = new ISONodeRecord();
if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive)
record.ParseCDInteractive(s); record.ParseCDInteractive(s);
if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) if (ISOFile.Format == ISOFile.ISOFormat.ISO9660)
record.ParseISO9660(s); record.ParseISO9660(s);
//zero 24-jun-2013 - improved validity checks //zero 24-jun-2013 - improved validity checks
//theres nothing here! //theres nothing here!
if (record.Length == 0) if (record.Length == 0)
{ {
break; break;
} }
@ -98,8 +98,8 @@ namespace BizHawk.Emulation.DiscSystem
} }
// Add the node as a child // Add the node as a child
if (!this.Children.ContainsKey(record.Name)) if (!this.Children.ContainsKey(record.Name))
this.Children.Add(record.Name, node); this.Children.Add(record.Name, node);
} }
} }

View File

@ -6,47 +6,47 @@ using System.Linq;
namespace BizHawk.Emulation.DiscSystem namespace BizHawk.Emulation.DiscSystem
{ {
/// <summary> /// <summary>
/// This class is meant to parse disk images as specified by: /// This class is meant to parse disk images as specified by:
/// ///
/// ISO9660 /// ISO9660
/// ------- /// -------
/// It should work for most disk images that are created /// It should work for most disk images that are created
/// by the stanard disk imaging software. This class is by no means /// by the stanard disk imaging software. This class is by no means
/// robust to all variations of ISO9660. /// robust to all variations of ISO9660.
/// Also, this class does not currently support the UDF file system. /// Also, this class does not currently support the UDF file system.
/// ///
/// The information for building class came from three primary sources: /// The information for building class came from three primary sources:
/// 1. The ISO9660 wikipedia article: /// 1. The ISO9660 wikipedia article:
/// http://en.wikipedia.org/wiki/ISO_9660 /// http://en.wikipedia.org/wiki/ISO_9660
/// 2. ISO9660 Simplified for DOS/Windows /// 2. ISO9660 Simplified for DOS/Windows
/// http://alumnus.caltech.edu/~pje/iso9660.html /// http://alumnus.caltech.edu/~pje/iso9660.html
/// 3. The ISO 9660 File System /// 3. The ISO 9660 File System
/// http://users.telenet.be/it3.consultants.bvba/handouts/ISO9960.html /// http://users.telenet.be/it3.consultants.bvba/handouts/ISO9960.html
/// ///
/// ///
/// CD-I /// CD-I
/// ---- /// ----
/// (asni - 20171013) - Class modified to be able to detect and consume Green /// (asni - 20171013) - Class modified to be able to detect and consume Green
/// Book disc images. /// Book disc images.
/// ///
/// The implemtation of CD-I in this class adds some (but not all) additional /// The implemtation of CD-I in this class adds some (but not all) additional
/// properties to the class structures that CD-I brings. This means that /// properties to the class structures that CD-I brings. This means that
/// the same ISO class structures can be returned for both standards. /// the same ISO class structures can be returned for both standards.
/// These small additions are readily found in ISOVolumeDescriptor.cs /// These small additions are readily found in ISOVolumeDescriptor.cs
/// ///
/// ISOFile.cs also now contains a public 'ISOFormat' enum that is set /// ISOFile.cs also now contains a public 'ISOFormat' enum that is set
/// during disc parsing. /// during disc parsing.
/// ///
/// The main reference source for this implementation: /// The main reference source for this implementation:
/// 1. The CD-I Full Functional Specification (aka Green Book) /// 1. The CD-I Full Functional Specification (aka Green Book)
/// https://www.lscdweb.com/data/downloadables/2/8/cdi_may94_r2.pdf /// https://www.lscdweb.com/data/downloadables/2/8/cdi_may94_r2.pdf
/// ///
/// ///
/// TODO: Add functions to enumerate a directory or visit a file... /// TODO: Add functions to enumerate a directory or visit a file...
/// ///
/// </summary> /// </summary>
public class ISOFile public class ISOFile
{ {
#region Constants #region Constants
@ -55,36 +55,36 @@ namespace BizHawk.Emulation.DiscSystem
/// </summary> /// </summary>
public const int SECTOR_SIZE = 2048; public const int SECTOR_SIZE = 2048;
#endregion #endregion
#region Static Members #region Static Members
/// <summary> /// <summary>
/// Making this a static for now. Every other way I tried was fairly ineligant (asni) /// Making this a static for now. Every other way I tried was fairly ineligant (asni)
/// </summary> /// </summary>
public static ISOFormat Format; public static ISOFormat Format;
public static List<CDIPathNode> CDIPathTable; public static List<CDIPathNode> CDIPathTable;
#endregion #endregion
#region Public Members #region Public Members
/// <summary> /// <summary>
/// This is a list of all the volume descriptors in the disk image. /// This is a list of all the volume descriptors in the disk image.
/// NOTE: The first entry should be the primary volume. /// NOTE: The first entry should be the primary volume.
/// </summary> /// </summary>
public List<ISOVolumeDescriptor> VolumeDescriptors; public List<ISOVolumeDescriptor> VolumeDescriptors;
/// <summary> /// <summary>
/// The Directory that is the root of this file system /// The Directory that is the root of this file system
/// </summary> /// </summary>
public ISODirectoryNode Root; public ISODirectoryNode Root;
/// <summary> /// <summary>
/// The type of CDFS format detected /// The type of CDFS format detected
/// </summary> /// </summary>
public ISOFormat CDFSType; public ISOFormat CDFSType;
#endregion #endregion
@ -118,8 +118,8 @@ namespace BizHawk.Emulation.DiscSystem
// Seek through the first volume descriptor // Seek through the first volume descriptor
s.Seek(startPosition + (SECTOR_SIZE * startSector), SeekOrigin.Begin); s.Seek(startPosition + (SECTOR_SIZE * startSector), SeekOrigin.Begin);
// Read one of more volume descriptors // Read one of more volume descriptors
do do
{ {
//zero 24-jun-2013 - improved validity checks //zero 24-jun-2013 - improved validity checks
@ -127,7 +127,7 @@ namespace BizHawk.Emulation.DiscSystem
bool isValid = desc.Parse(s); bool isValid = desc.Parse(s);
if (!isValid) return false; if (!isValid) return false;
this.CDFSType = Format; this.CDFSType = Format;
if (desc.IsTerminator()) if (desc.IsTerminator())
break; break;
@ -140,17 +140,17 @@ namespace BizHawk.Emulation.DiscSystem
} while (true); } while (true);
//zero 24-jun-2013 - well, my very first test iso had 2 volume descriptors. //zero 24-jun-2013 - well, my very first test iso had 2 volume descriptors.
// Check to make sure we only read one volume descriptor // Check to make sure we only read one volume descriptor
// Finding more could be an error with the disk. // Finding more could be an error with the disk.
//if (this.VolumeDescriptors.Count != 1) { //if (this.VolumeDescriptors.Count != 1) {
// Console.WriteLine("Strange ISO format..."); // Console.WriteLine("Strange ISO format...");
// return; // return;
//} //}
//zero 24-jun-2013 - if theres no volume descriptors, we're gonna call this not a cdfs //zero 24-jun-2013 - if theres no volume descriptors, we're gonna call this not a cdfs
if (VolumeDescriptors.Count == 0) return false; if (VolumeDescriptors.Count == 0) return false;
// Visit all the directories and get the offset of each directory/file // Visit all the directories and get the offset of each directory/file
@ -160,63 +160,63 @@ namespace BizHawk.Emulation.DiscSystem
// Create (and visit) the root node // Create (and visit) the root node
this.Root = new ISODirectoryNode(this.VolumeDescriptors[0].RootDirectoryRecord); this.Root = new ISODirectoryNode(this.VolumeDescriptors[0].RootDirectoryRecord);
visitedNodes.Add(this.Root.Offset, this.Root); visitedNodes.Add(this.Root.Offset, this.Root);
this.Root.Parse(s, visitedNodes); this.Root.Parse(s, visitedNodes);
return true; return true;
} }
private List<KeyValuePair<string, ISOFileNode>> fileNodes; private List<KeyValuePair<string, ISOFileNode>> fileNodes;
private List<ISODirectoryNode> dirsParsed; private List<ISODirectoryNode> dirsParsed;
/// <summary> /// <summary>
/// Returns a flat list of all recursed files /// Returns a flat list of all recursed files
/// </summary> /// </summary>
public List<KeyValuePair<string, ISOFileNode>> EnumerateAllFilesRecursively() public List<KeyValuePair<string, ISOFileNode>> EnumerateAllFilesRecursively()
{ {
fileNodes = new List<KeyValuePair<string, ISOFileNode>>(); fileNodes = new List<KeyValuePair<string, ISOFileNode>>();
dirsParsed = new List<ISODirectoryNode>(); dirsParsed = new List<ISODirectoryNode>();
if (Root.Children == null) if (Root.Children == null)
return fileNodes; return fileNodes;
// get all folders // get all folders
var dirs = (from a in Root.Children where a.Value.GetType() == typeof(ISODirectoryNode) select a); var dirs = (from a in Root.Children where a.Value.GetType() == typeof(ISODirectoryNode) select a);
// iterate through each folder // iterate through each folder
foreach (var d in dirs) foreach (var d in dirs)
{ {
// process all files in this directory (and recursively process files in sub folders // process all files in this directory (and recursively process files in sub folders
ISODirectoryNode idn = d.Value as ISODirectoryNode; ISODirectoryNode idn = d.Value as ISODirectoryNode;
if (dirsParsed.Where(a => a == idn).Count() > 0) if (dirsParsed.Where(a => a == idn).Count() > 0)
continue; continue;
dirsParsed.Add(idn); dirsParsed.Add(idn);
ProcessDirectoryFiles(idn.Children); ProcessDirectoryFiles(idn.Children);
} }
return fileNodes.Distinct().ToList(); return fileNodes.Distinct().ToList();
} }
private void ProcessDirectoryFiles(Dictionary<string, ISONode> idn) private void ProcessDirectoryFiles(Dictionary<string, ISONode> idn)
{ {
foreach (var n in idn) foreach (var n in idn)
{ {
if (n.Value.GetType() == typeof(ISODirectoryNode)) if (n.Value.GetType() == typeof(ISODirectoryNode))
{ {
if (dirsParsed.Where(a => a == n.Value).Count() > 0) if (dirsParsed.Where(a => a == n.Value).Count() > 0)
continue; continue;
dirsParsed.Add(n.Value as ISODirectoryNode); dirsParsed.Add(n.Value as ISODirectoryNode);
ProcessDirectoryFiles((n.Value as ISODirectoryNode).Children); ProcessDirectoryFiles((n.Value as ISODirectoryNode).Children);
} }
else else
{ {
KeyValuePair<string, ISOFileNode> f = new KeyValuePair<string, ISOFileNode>(n.Key, n.Value as ISOFileNode); KeyValuePair<string, ISOFileNode> f = new KeyValuePair<string, ISOFileNode>(n.Key, n.Value as ISOFileNode);
fileNodes.Add(f); fileNodes.Add(f);
} }
} }
} }
#endregion #endregion
@ -231,17 +231,17 @@ namespace BizHawk.Emulation.DiscSystem
this.Root.Print(0); this.Root.Print(0);
} }
#endregion #endregion
#region Misc #region Misc
public enum ISOFormat public enum ISOFormat
{ {
Unknown, Unknown,
ISO9660, ISO9660,
CDInteractive CDInteractive
} }
#endregion #endregion
} }
} }

View File

@ -31,16 +31,16 @@ namespace BizHawk.Emulation.DiscSystem
/// </summary> /// </summary>
public byte Length; public byte Length;
/// <summary> /// <summary>
/// This is the number of blocks at the beginning of the file reserved for extended attribute information /// This is the number of blocks at the beginning of the file reserved for extended attribute information
/// The format of the extended attribute record is not defined and is reserved for application use /// The format of the extended attribute record is not defined and is reserved for application use
/// </summary> /// </summary>
public byte ExtendedAttribRecordLength; public byte ExtendedAttribRecordLength;
/// <summary> /// <summary>
/// The file offset of the data for this file/directory (in sectors). /// The file offset of the data for this file/directory (in sectors).
/// </summary> /// </summary>
public long OffsetOfData; public long OffsetOfData;
/// <summary> /// <summary>
/// The length of the data for this file/directory (in bytes). /// The length of the data for this file/directory (in bytes).
/// </summary> /// </summary>
@ -155,11 +155,11 @@ namespace BizHawk.Emulation.DiscSystem
MemoryStream s = new MemoryStream(data); MemoryStream s = new MemoryStream(data);
s.Seek(cursor, SeekOrigin.Begin); s.Seek(cursor, SeekOrigin.Begin);
if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) if (ISOFile.Format == ISOFile.ISOFormat.ISO9660)
this.ParseISO9660(s); this.ParseISO9660(s);
if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive)
this.ParseCDInteractive(s); this.ParseCDInteractive(s);
} }
/// <summary> /// <summary>
@ -223,100 +223,100 @@ namespace BizHawk.Emulation.DiscSystem
s.Seek(startPosition + this.Length, SeekOrigin.Begin); s.Seek(startPosition + this.Length, SeekOrigin.Begin);
} }
/// <summary> /// <summary>
/// Parse the node record from the given CD-I stream. /// Parse the node record from the given CD-I stream.
/// </summary> /// </summary>
/// <param name="s">The stream to parse from.</param> /// <param name="s">The stream to parse from.</param>
public void ParseCDInteractive(Stream s) public void ParseCDInteractive(Stream s)
{ {
/* /*
BP Size in bytes Description BP Size in bytes Description
1 1 Record length 1 1 Record length
2 1 Extended Attribute record length 2 1 Extended Attribute record length
3 4 Reserved 3 4 Reserved
7 4 File beginning LBN 7 4 File beginning LBN
11 4 Reserved 11 4 Reserved
15 4 File size 15 4 File size
19 6 Creation date 19 6 Creation date
25 1 Reserved 25 1 Reserved
26 1 File flags 26 1 File flags
27 2 Interleave 27 2 Interleave
29 2 Reserved 29 2 Reserved
31 2 Album Set Sequence number 31 2 Album Set Sequence number
33 1 File name size 33 1 File name size
34 (n) File name 34 (n) File name
34+n 4 Owner ID 34+n 4 Owner ID
38+n 2 Attributes 38+n 2 Attributes
40+n 2 Reserved 40+n 2 Reserved
42+n 1 File number 42+n 1 File number
43+n 1 Reserved 43+n 1 Reserved
43+n Total 43+n Total
*/ */
EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian();
EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian();
long startPosition = s.Position; long startPosition = s.Position;
byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; byte[] buffer = new byte[ISOFile.SECTOR_SIZE];
// Read the entire structure // Read the entire structure
s.Read(buffer, 0, ISOFile.SECTOR_SIZE); s.Read(buffer, 0, ISOFile.SECTOR_SIZE);
s.Position -= ISOFile.SECTOR_SIZE; s.Position -= ISOFile.SECTOR_SIZE;
// Get the record length // Get the record length
this.Length = buffer[0]; this.Length = buffer[0];
// extended attribute record length // extended attribute record length
this.ExtendedAttribRecordLength = buffer[1]; this.ExtendedAttribRecordLength = buffer[1];
// Read Data Offset // Read Data Offset
this.OffsetOfData = bcBig.ReadIntValue(buffer, 6, 4); this.OffsetOfData = bcBig.ReadIntValue(buffer, 6, 4);
// Read Data Length // Read Data Length
this.LengthOfData = bcBig.ReadIntValue(buffer, 14, 4); this.LengthOfData = bcBig.ReadIntValue(buffer, 14, 4);
// Read the time // Read the time
var ti = bc.ReadBytes(buffer, 18, 6); var ti = bc.ReadBytes(buffer, 18, 6);
this.Year = ti[0]; this.Year = ti[0];
this.Month = ti[1]; this.Month = ti[1];
this.Day = ti[2]; this.Day = ti[2];
this.Hour = ti[3]; this.Hour = ti[3];
this.Minute = ti[4]; this.Minute = ti[4];
this.Second = ti[5]; this.Second = ti[5];
// read interleave - still to do // read interleave - still to do
// read album (volume) set sequence number (we are ignoring this) // read album (volume) set sequence number (we are ignoring this)
// Read the name length // Read the name length
this.NameLength = buffer[32]; this.NameLength = buffer[32];
// Read the file/directory name // Read the file/directory name
var name = bc.ReadBytes(buffer, 33, this.NameLength); var name = bc.ReadBytes(buffer, 33, this.NameLength);
if (this.NameLength == 1 && (name[0] == 0 || name[0] == 1)) if (this.NameLength == 1 && (name[0] == 0 || name[0] == 1))
{ {
if (name[0] == 0) if (name[0] == 0)
this.Name = ISONodeRecord.CURRENT_DIRECTORY; this.Name = ISONodeRecord.CURRENT_DIRECTORY;
else else
this.Name = ISONodeRecord.PARENT_DIRECTORY; this.Name = ISONodeRecord.PARENT_DIRECTORY;
} }
else else
{ {
this.Name = ASCIIEncoding.ASCII.GetString(name, 0, this.NameLength); this.Name = ASCIIEncoding.ASCII.GetString(name, 0, this.NameLength);
} }
// skip ownerID for now // skip ownerID for now
// read the flags - only really interested in the directory attribute (bit 15) // read the flags - only really interested in the directory attribute (bit 15)
// (confusingly these are called 'attributes' in CD-I. the CD-I 'File Flags' entry is something else entirely) // (confusingly these are called 'attributes' in CD-I. the CD-I 'File Flags' entry is something else entirely)
this.Flags = buffer[37 + this.NameLength]; this.Flags = buffer[37 + this.NameLength];
// skip filenumber // skip filenumber
//this.FileNumber = buffer[41 + this.NameLength]; //this.FileNumber = buffer[41 + this.NameLength];
// Seek to end // Seek to end
s.Seek(startPosition + this.Length, SeekOrigin.Begin); s.Seek(startPosition + this.Length, SeekOrigin.Begin);
} }
#endregion #endregion
} }
} }

View File

@ -25,21 +25,21 @@ namespace BizHawk.Emulation.DiscSystem
private const int LENGTH_TIME = 17; private const int LENGTH_TIME = 17;
private const int LENGTH_RESERVED = 512; private const int LENGTH_RESERVED = 512;
#endregion #endregion
#region Private Properties #region Private Properties
private EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); private EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian();
private EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); private EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian();
#endregion #endregion
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// The type of this volume description, only 1 and 255 are supported /// The type of this volume description, only 1 and 255 are supported
/// </summary> /// </summary>
public byte Type; public byte Type;
/// <summary> /// <summary>
/// The system identifier /// The system identifier
@ -76,18 +76,18 @@ namespace BizHawk.Emulation.DiscSystem
/// (ISO9660 only) Sector offset of the first path table /// (ISO9660 only) Sector offset of the first path table
/// </summary> /// </summary>
public int OffsetOfFirstLittleEndianPathTable; public int OffsetOfFirstLittleEndianPathTable;
/// <summary> /// <summary>
/// (ISO9660 only) Sector offset of the second path table /// (ISO9660 only) Sector offset of the second path table
/// </summary> /// </summary>
public int OffsetOfSecondLittleEndianPathTable; public int OffsetOfSecondLittleEndianPathTable;
/// <summary> /// <summary>
/// (ISO9660 only) Sector offset of the first path table /// (ISO9660 only) Sector offset of the first path table
/// </summary> /// </summary>
public int OffsetOfFirstBigEndianPathTable; public int OffsetOfFirstBigEndianPathTable;
/// <summary> /// <summary>
/// (ISO9660 only) Sector offset of the second path table /// (ISO9660 only) Sector offset of the second path table
/// </summary> /// </summary>
public int OffsetOfSecondBigEndianPathTable; public int OffsetOfSecondBigEndianPathTable;
/// <summary> /// <summary>
/// The root directory record /// The root directory record
@ -141,39 +141,39 @@ namespace BizHawk.Emulation.DiscSystem
/// </summary> /// </summary>
public byte[] EffectiveDateTime; public byte[] EffectiveDateTime;
/// <summary> /// <summary>
/// (ISO9660 only) Extra reserved data /// (ISO9660 only) Extra reserved data
/// </summary> /// </summary>
public byte[] Reserved; public byte[] Reserved;
// CD-Interactive only // CD-Interactive only
/// <summary> /// <summary>
/// The bits of this field are numbered from 0 to 7 starting with the least significant bit /// The bits of this field are numbered from 0 to 7 starting with the least significant bit
/// BitPosition 0: A value of 0 = the coded character set identifier field specifies only an escape sequence registered according to ISO 2375 /// BitPosition 0: A value of 0 = the coded character set identifier field specifies only an escape sequence registered according to ISO 2375
/// A value of 1 = the coded character set identifier field specifies only an escape sequence NOT registered according to ISO 2375 /// A value of 1 = the coded character set identifier field specifies only an escape sequence NOT registered according to ISO 2375
/// BitPostion 1-7: All bits are 0 (reserved for future standardization) /// BitPostion 1-7: All bits are 0 (reserved for future standardization)
/// </summary> /// </summary>
public byte VolumeFlags; public byte VolumeFlags;
/// <summary> /// <summary>
/// This field specifies one escape sequence according to the International Register of Coded Character Sets to be used with escape /// This field specifies one escape sequence according to the International Register of Coded Character Sets to be used with escape
/// sequence standards for recording.The ESC character, which is the first character of all sequences, shall be omitted when recording this field /// sequence standards for recording.The ESC character, which is the first character of all sequences, shall be omitted when recording this field
/// </summary> /// </summary>
public byte[] CodedCharSetIdent; public byte[] CodedCharSetIdent;
/// <summary> /// <summary>
/// The block address of the first block of the system Path Table is kept in this field /// The block address of the first block of the system Path Table is kept in this field
/// </summary> /// </summary>
public int AddressOfPathTable; public int AddressOfPathTable;
#endregion #endregion
#region Construction #region Construction
/// <summary> /// <summary>
/// Constructor. /// Constructor.
/// </summary> /// </summary>
public ISOVolumeDescriptor() public ISOVolumeDescriptor()
{ {
// Set everything to the default value // Set everything to the default value
this.Type = 0; this.Type = 0;
@ -211,10 +211,10 @@ namespace BizHawk.Emulation.DiscSystem
this.Reserved = new byte[LENGTH_RESERVED]; this.Reserved = new byte[LENGTH_RESERVED];
// CD-I specific // CD-I specific
this.VolumeFlags = 0; this.VolumeFlags = 0;
this.CodedCharSetIdent = new byte[LENGTH_SHORT_IDENTIFIER]; this.CodedCharSetIdent = new byte[LENGTH_SHORT_IDENTIFIER];
this.AddressOfPathTable = 0; this.AddressOfPathTable = 0;
} }
#endregion #endregion
@ -233,267 +233,267 @@ namespace BizHawk.Emulation.DiscSystem
// Read the entire structure // Read the entire structure
s.Read(buffer, 0, ISOFile.SECTOR_SIZE); s.Read(buffer, 0, ISOFile.SECTOR_SIZE);
// Parse based on format // Parse based on format
byte[] header = bc.ReadBytes(buffer, 0, ISOFile.SECTOR_SIZE); byte[] header = bc.ReadBytes(buffer, 0, ISOFile.SECTOR_SIZE);
if (GetISO9660(header)) if (GetISO9660(header))
{ {
ParseISO9660(s); ParseISO9660(s);
return true; return true;
} }
if (GetCDI(header)) if (GetCDI(header))
{ {
ParseCDInteractive(s); ParseCDInteractive(s);
return true; return true;
} }
return false; return false;
} }
public void ParseISO9660(Stream s) public void ParseISO9660(Stream s)
{ {
long startPosition = s.Position; long startPosition = s.Position;
byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; byte[] buffer = new byte[ISOFile.SECTOR_SIZE];
s.Position = startPosition - ISOFile.SECTOR_SIZE; s.Position = startPosition - ISOFile.SECTOR_SIZE;
// Read the entire structure // Read the entire structure
s.Read(buffer, 0, ISOFile.SECTOR_SIZE); s.Read(buffer, 0, ISOFile.SECTOR_SIZE);
// Get the type // Get the type
this.Type = buffer[0]; this.Type = buffer[0];
// Handle the primary volume information // Handle the primary volume information
if (this.Type == 1) if (this.Type == 1)
{ {
int cursor = 8; int cursor = 8;
// Get the system identifier // Get the system identifier
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.SystemIdentifier, 0, LENGTH_SHORT_IDENTIFIER); this.SystemIdentifier, 0, LENGTH_SHORT_IDENTIFIER);
cursor += LENGTH_SHORT_IDENTIFIER; cursor += LENGTH_SHORT_IDENTIFIER;
// Get the volume identifier // Get the volume identifier
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.VolumeIdentifier, 0, LENGTH_SHORT_IDENTIFIER); this.VolumeIdentifier, 0, LENGTH_SHORT_IDENTIFIER);
cursor += LENGTH_SHORT_IDENTIFIER; cursor += LENGTH_SHORT_IDENTIFIER;
cursor += 8; cursor += 8;
// Get the total number of sectors // Get the total number of sectors
this.NumberOfSectors = bc.ToInt32(buffer, cursor); this.NumberOfSectors = bc.ToInt32(buffer, cursor);
cursor += 8; cursor += 8;
cursor += 32; cursor += 32;
this.VolumeSetSize = bc.ToInt16(buffer, cursor); this.VolumeSetSize = bc.ToInt16(buffer, cursor);
cursor += 4; cursor += 4;
this.VolumeSequenceNumber = bc.ToInt16(buffer, cursor); this.VolumeSequenceNumber = bc.ToInt16(buffer, cursor);
cursor += 4; cursor += 4;
this.SectorSize = bc.ToInt16(buffer, cursor); this.SectorSize = bc.ToInt16(buffer, cursor);
cursor += 4; cursor += 4;
this.PathTableSize = bc.ToInt32(buffer, cursor); this.PathTableSize = bc.ToInt32(buffer, cursor);
cursor += 8; cursor += 8;
this.OffsetOfFirstLittleEndianPathTable = bc.ToInt32(buffer, cursor); this.OffsetOfFirstLittleEndianPathTable = bc.ToInt32(buffer, cursor);
cursor += 4; cursor += 4;
this.OffsetOfSecondLittleEndianPathTable = bc.ToInt32(buffer, cursor); this.OffsetOfSecondLittleEndianPathTable = bc.ToInt32(buffer, cursor);
cursor += 4; cursor += 4;
this.OffsetOfFirstLittleEndianPathTable = bcBig.ToInt32(buffer, cursor); this.OffsetOfFirstLittleEndianPathTable = bcBig.ToInt32(buffer, cursor);
cursor += 4; cursor += 4;
this.OffsetOfSecondLittleEndianPathTable = bcBig.ToInt32(buffer, cursor); this.OffsetOfSecondLittleEndianPathTable = bcBig.ToInt32(buffer, cursor);
cursor += 4; cursor += 4;
this.RootDirectoryRecord.Parse(buffer, cursor); this.RootDirectoryRecord.Parse(buffer, cursor);
cursor += LENGTH_ROOT_DIRECTORY_RECORD; cursor += LENGTH_ROOT_DIRECTORY_RECORD;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.VolumeSetIdentifier, 0, LENGTH_LONG_IDENTIFIER); this.VolumeSetIdentifier, 0, LENGTH_LONG_IDENTIFIER);
cursor += LENGTH_LONG_IDENTIFIER; cursor += LENGTH_LONG_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.PublisherIdentifier, 0, LENGTH_LONG_IDENTIFIER); this.PublisherIdentifier, 0, LENGTH_LONG_IDENTIFIER);
cursor += LENGTH_LONG_IDENTIFIER; cursor += LENGTH_LONG_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.DataPreparerIdentifier, 0, LENGTH_LONG_IDENTIFIER); this.DataPreparerIdentifier, 0, LENGTH_LONG_IDENTIFIER);
cursor += LENGTH_LONG_IDENTIFIER; cursor += LENGTH_LONG_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.ApplicationIdentifier, 0, LENGTH_LONG_IDENTIFIER); this.ApplicationIdentifier, 0, LENGTH_LONG_IDENTIFIER);
cursor += LENGTH_LONG_IDENTIFIER; cursor += LENGTH_LONG_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.CopyrightFileIdentifier, 0, LENGTH_IDENTIFIER); this.CopyrightFileIdentifier, 0, LENGTH_IDENTIFIER);
cursor += LENGTH_IDENTIFIER; cursor += LENGTH_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.AbstractFileIdentifier, 0, LENGTH_IDENTIFIER); this.AbstractFileIdentifier, 0, LENGTH_IDENTIFIER);
cursor += LENGTH_IDENTIFIER; cursor += LENGTH_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.BibliographicalFileIdentifier, 0, LENGTH_IDENTIFIER); this.BibliographicalFileIdentifier, 0, LENGTH_IDENTIFIER);
cursor += LENGTH_IDENTIFIER; cursor += LENGTH_IDENTIFIER;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.VolumeCreationDateTime, 0, LENGTH_TIME); this.VolumeCreationDateTime, 0, LENGTH_TIME);
cursor += LENGTH_TIME; cursor += LENGTH_TIME;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.LastModifiedDateTime, 0, LENGTH_TIME); this.LastModifiedDateTime, 0, LENGTH_TIME);
cursor += LENGTH_TIME; cursor += LENGTH_TIME;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.ExpirationDateTime, 0, LENGTH_TIME); this.ExpirationDateTime, 0, LENGTH_TIME);
cursor += LENGTH_TIME; cursor += LENGTH_TIME;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.EffectiveDateTime, 0, LENGTH_TIME); this.EffectiveDateTime, 0, LENGTH_TIME);
cursor += LENGTH_TIME; cursor += LENGTH_TIME;
cursor += 1; cursor += 1;
cursor += 1; cursor += 1;
Array.Copy(buffer, cursor, Array.Copy(buffer, cursor,
this.Reserved, 0, LENGTH_RESERVED); this.Reserved, 0, LENGTH_RESERVED);
cursor += LENGTH_RESERVED; cursor += LENGTH_RESERVED;
} }
} }
public void ParseCDInteractive(Stream s) public void ParseCDInteractive(Stream s)
{ {
/* From the Green Book Spec /* From the Green Book Spec
* BP (byte position) obviously is n+1 * BP (byte position) obviously is n+1
BP Size in Bytes Description BP Size in Bytes Description
1 1 Disc Label Record Type 1 1 Disc Label Record Type
2 5 Volume Structure Standard ID 2 5 Volume Structure Standard ID
7 1 Volume Structure Version number 7 1 Volume Structure Version number
8 1 Volume flags 8 1 Volume flags
9 32 System identifier 9 32 System identifier
41 32 Volume identifier 41 32 Volume identifier
73 12 Reserved 73 12 Reserved
85 4 Volume space size 85 4 Volume space size
89 32 Coded Character Set identifier 89 32 Coded Character Set identifier
121 2 Reserved 121 2 Reserved
123 2 Number of Volumes in Album 123 2 Number of Volumes in Album
125 2 Reserved 125 2 Reserved
127 2 Album Set Sequence number 127 2 Album Set Sequence number
129 2 Reserved 129 2 Reserved
131 2 Logical Block size 131 2 Logical Block size
133 4 Reserved 133 4 Reserved
137 4 Path Table size 137 4 Path Table size
141 8 Reserved 141 8 Reserved
149 4 Address of Path Table 149 4 Address of Path Table
153 38 Reserved 153 38 Reserved
191 128 Album identifier 191 128 Album identifier
319 128 Publisher identifier 319 128 Publisher identifier
447 128 Data Preparer identifier 447 128 Data Preparer identifier
575 128 Application identifier 575 128 Application identifier
703 32 Copyright file name 703 32 Copyright file name
735 5 Reserved 735 5 Reserved
740 32 Abstract file name 740 32 Abstract file name
772 5 Reserved 772 5 Reserved
777 32 Bibliographic file name 777 32 Bibliographic file name
809 5 Reserved 809 5 Reserved
814 16 Creation date and time 814 16 Creation date and time
830 1 Reserved 830 1 Reserved
831 16 Modification date and time 831 16 Modification date and time
847 1 Reserved 847 1 Reserved
848 16 Expiration date and time 848 16 Expiration date and time
864 1 Reserved 864 1 Reserved
865 16 Effective date and time 865 16 Effective date and time
881 1 Reserved 881 1 Reserved
882 1 File Structure Standard Version number 882 1 File Structure Standard Version number
883 1 Reserved 883 1 Reserved
884 512 Application use 884 512 Application use
1396 653 Reserved */ 1396 653 Reserved */
long startPosition = s.Position; long startPosition = s.Position;
byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; byte[] buffer = new byte[ISOFile.SECTOR_SIZE];
s.Position = startPosition - ISOFile.SECTOR_SIZE; s.Position = startPosition - ISOFile.SECTOR_SIZE;
// Read the entire structure // Read the entire structure
s.Read(buffer, 0, ISOFile.SECTOR_SIZE); s.Read(buffer, 0, ISOFile.SECTOR_SIZE);
// Get the type // Get the type
this.Type = buffer[0]; this.Type = buffer[0];
// Handle the primary volume information // Handle the primary volume information
if (this.Type == 1) if (this.Type == 1)
{ {
this.VolumeFlags = buffer[7]; this.VolumeFlags = buffer[7];
this.SystemIdentifier = bc.ReadBytes(buffer, 8, LENGTH_SHORT_IDENTIFIER); this.SystemIdentifier = bc.ReadBytes(buffer, 8, LENGTH_SHORT_IDENTIFIER);
this.VolumeIdentifier = bc.ReadBytes(buffer, 40, LENGTH_SHORT_IDENTIFIER); this.VolumeIdentifier = bc.ReadBytes(buffer, 40, LENGTH_SHORT_IDENTIFIER);
this.NumberOfSectors = bcBig.ReadIntValue(buffer, 84, 4); this.NumberOfSectors = bcBig.ReadIntValue(buffer, 84, 4);
this.CodedCharSetIdent = bc.ReadBytes(buffer, 88, LENGTH_SHORT_IDENTIFIER); this.CodedCharSetIdent = bc.ReadBytes(buffer, 88, LENGTH_SHORT_IDENTIFIER);
this.VolumeSetSize = bcBig.ReadIntValue(buffer, 122, 2); this.VolumeSetSize = bcBig.ReadIntValue(buffer, 122, 2);
this.VolumeSequenceNumber = bcBig.ReadIntValue(buffer, 126, 2); this.VolumeSequenceNumber = bcBig.ReadIntValue(buffer, 126, 2);
this.SectorSize = bcBig.ReadIntValue(buffer, 130, 2); this.SectorSize = bcBig.ReadIntValue(buffer, 130, 2);
this.PathTableSize = bcBig.ReadIntValue(buffer, 136, 4); this.PathTableSize = bcBig.ReadIntValue(buffer, 136, 4);
this.AddressOfPathTable = bcBig.ReadIntValue(buffer, 148, 4); this.AddressOfPathTable = bcBig.ReadIntValue(buffer, 148, 4);
this.VolumeSetIdentifier = bc.ReadBytes(buffer, 190, LENGTH_LONG_IDENTIFIER); this.VolumeSetIdentifier = bc.ReadBytes(buffer, 190, LENGTH_LONG_IDENTIFIER);
this.PublisherIdentifier = bc.ReadBytes(buffer, 318, LENGTH_LONG_IDENTIFIER); this.PublisherIdentifier = bc.ReadBytes(buffer, 318, LENGTH_LONG_IDENTIFIER);
this.DataPreparerIdentifier = bc.ReadBytes(buffer, 446, LENGTH_LONG_IDENTIFIER); this.DataPreparerIdentifier = bc.ReadBytes(buffer, 446, LENGTH_LONG_IDENTIFIER);
this.ApplicationIdentifier = bc.ReadBytes(buffer, 574, LENGTH_LONG_IDENTIFIER); this.ApplicationIdentifier = bc.ReadBytes(buffer, 574, LENGTH_LONG_IDENTIFIER);
this.CopyrightFileIdentifier = bc.ReadBytes(buffer, 702, LENGTH_SHORT_IDENTIFIER); this.CopyrightFileIdentifier = bc.ReadBytes(buffer, 702, LENGTH_SHORT_IDENTIFIER);
this.AbstractFileIdentifier = bc.ReadBytes(buffer, 739, LENGTH_SHORT_IDENTIFIER); this.AbstractFileIdentifier = bc.ReadBytes(buffer, 739, LENGTH_SHORT_IDENTIFIER);
this.BibliographicalFileIdentifier = bc.ReadBytes(buffer, 776, LENGTH_SHORT_IDENTIFIER); this.BibliographicalFileIdentifier = bc.ReadBytes(buffer, 776, LENGTH_SHORT_IDENTIFIER);
this.VolumeCreationDateTime = bc.ReadBytes(buffer, 813, 16); this.VolumeCreationDateTime = bc.ReadBytes(buffer, 813, 16);
this.LastModifiedDateTime = bc.ReadBytes(buffer, 830, 16); this.LastModifiedDateTime = bc.ReadBytes(buffer, 830, 16);
this.ExpirationDateTime = bc.ReadBytes(buffer, 847, 16); this.ExpirationDateTime = bc.ReadBytes(buffer, 847, 16);
this.EffectiveDateTime = bc.ReadBytes(buffer, 864, 16); this.EffectiveDateTime = bc.ReadBytes(buffer, 864, 16);
// save current position // save current position
long pos = s.Position; long pos = s.Position;
// get path table records // get path table records
s.Position = ISOFile.SECTOR_SIZE * this.AddressOfPathTable; s.Position = ISOFile.SECTOR_SIZE * this.AddressOfPathTable;
ISOFile.CDIPathTable = CDIPathNode.ParsePathTable(s, this.PathTableSize); ISOFile.CDIPathTable = CDIPathNode.ParsePathTable(s, this.PathTableSize);
// read the root dir record // read the root dir record
s.Position = ISOFile.SECTOR_SIZE * ISOFile.CDIPathTable[0].DirectoryBlockAddress; s.Position = ISOFile.SECTOR_SIZE * ISOFile.CDIPathTable[0].DirectoryBlockAddress;
s.Read(buffer, 0, ISOFile.SECTOR_SIZE); s.Read(buffer, 0, ISOFile.SECTOR_SIZE);
this.RootDirectoryRecord.Parse(buffer, 0); this.RootDirectoryRecord.Parse(buffer, 0);
// go back to where we were // go back to where we were
s.Position = pos; s.Position = pos;
} }
} }
/// <summary> /// <summary>
/// Detect ISO9660 /// Detect ISO9660
/// </summary> /// </summary>
public bool GetISO9660(byte[] buffer) public bool GetISO9660(byte[] buffer)
{ {
//zero 24-jun-2013 - validate ISO9660 //zero 24-jun-2013 - validate ISO9660
// "CD001\x01" // "CD001\x01"
if (buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' && buffer[4] == '0' && buffer[5] == '1' && buffer[6] == 0x01) if (buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' && buffer[4] == '0' && buffer[5] == '1' && buffer[6] == 0x01)
{ {
ISOFile.Format = ISOFile.ISOFormat.ISO9660; ISOFile.Format = ISOFile.ISOFormat.ISO9660;
return true; return true;
} }
return false; return false;
} }
/// <summary> /// <summary>
/// Detect CD-I /// Detect CD-I
/// </summary> /// </summary>
public bool GetCDI(byte[] buffer) public bool GetCDI(byte[] buffer)
{ {
// CD-Interactive // CD-Interactive
if (Encoding.ASCII.GetString(bc.ReadBytes(buffer, 1, 5)).Contains("CD-I")) if (Encoding.ASCII.GetString(bc.ReadBytes(buffer, 1, 5)).Contains("CD-I"))
{ {
ISOFile.Format = ISOFile.ISOFormat.CDInteractive; ISOFile.Format = ISOFile.ISOFormat.CDInteractive;
return true; return true;
} }
return false; return false;
} }
#endregion #endregion
#region Type Information #region Type Information
/// <summary> /// <summary>
/// Returns true if this is the terminator volume descriptor. /// Returns true if this is the terminator volume descriptor.
/// </summary> /// </summary>
/// <returns>True if the terminator.</returns> /// <returns>True if the terminator.</returns>
public bool IsTerminator() public bool IsTerminator()
{ {
return (this.Type == 255); return (this.Type == 255);
} }
@ -501,108 +501,108 @@ namespace BizHawk.Emulation.DiscSystem
#endregion #endregion
} }
/// <summary> /// <summary>
/// Represents a Directory Path Table entry on a CD-I disc /// Represents a Directory Path Table entry on a CD-I disc
/// </summary> /// </summary>
public class CDIPathNode public class CDIPathNode
{ {
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// The length of the directory name. /// The length of the directory name.
/// </summary> /// </summary>
public byte NameLength; public byte NameLength;
/// <summary> /// <summary>
/// This is the length of the Extended Attribute record /// This is the length of the Extended Attribute record
/// </summary> /// </summary>
public byte ExtendedAttribRecordLength; public byte ExtendedAttribRecordLength;
/// <summary> /// <summary>
/// This field contains the beginning logical block number (LBN) of the directory file on disc /// This field contains the beginning logical block number (LBN) of the directory file on disc
/// </summary> /// </summary>
public int DirectoryBlockAddress; public int DirectoryBlockAddress;
/// <summary> /// <summary>
/// This is the number (relative to the beginning of the Path Table) of this directory's parent /// This is the number (relative to the beginning of the Path Table) of this directory's parent
/// </summary> /// </summary>
public int ParentDirectoryNumber; public int ParentDirectoryNumber;
/// <summary> /// <summary>
/// The directory name. /// The directory name.
/// This variable length field is used to store the actual text representing the name of the directory. /// This variable length field is used to store the actual text representing the name of the directory.
/// If the length of the file name is odd, a null padding byte is added to make the size of the Path Table record even. /// If the length of the file name is odd, a null padding byte is added to make the size of the Path Table record even.
/// The padding byte is not included in the name size field. /// The padding byte is not included in the name size field.
/// </summary> /// </summary>
public string Name; public string Name;
#endregion #endregion
#region Construction #region Construction
/// <summary> /// <summary>
/// Empty Constructor /// Empty Constructor
/// </summary> /// </summary>
public CDIPathNode() public CDIPathNode()
{ {
} }
#endregion #endregion
#region Parsing #region Parsing
/* /*
BP Size in bytes Description BP Size in bytes Description
1 1 Name size 1 1 Name size
2 1 Extended Attribute record length 2 1 Extended Attribute record length
3 4 Directory block address 3 4 Directory block address
7 2 Parent Directory number 7 2 Parent Directory number
9 n Directory file name 9 n Directory file name
*/ */
public static List<CDIPathNode> ParsePathTable(Stream s, int PathTableSize) public static List<CDIPathNode> ParsePathTable(Stream s, int PathTableSize)
{ {
EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian();
EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian();
byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; byte[] buffer = new byte[ISOFile.SECTOR_SIZE];
// Read the entire structure // Read the entire structure
s.Read(buffer, 0, ISOFile.SECTOR_SIZE); s.Read(buffer, 0, ISOFile.SECTOR_SIZE);
int startCursor = 0; int startCursor = 0;
List<CDIPathNode> pathNodes = new List<CDIPathNode>(); List<CDIPathNode> pathNodes = new List<CDIPathNode>();
int pad = 0; int pad = 0;
do do
{ {
CDIPathNode node = new CDIPathNode(); CDIPathNode node = new CDIPathNode();
byte[] data = bc.ReadBytes(buffer, startCursor, ISOFile.SECTOR_SIZE - startCursor); byte[] data = bc.ReadBytes(buffer, startCursor, ISOFile.SECTOR_SIZE - startCursor);
node.NameLength = data[0]; node.NameLength = data[0];
node.ExtendedAttribRecordLength = data[1]; node.ExtendedAttribRecordLength = data[1];
node.DirectoryBlockAddress = bcBig.ReadIntValue(data, 2, 4); node.DirectoryBlockAddress = bcBig.ReadIntValue(data, 2, 4);
node.ParentDirectoryNumber = bcBig.ReadIntValue(data, 6, 2); node.ParentDirectoryNumber = bcBig.ReadIntValue(data, 6, 2);
node.Name = Encoding.ASCII.GetString(bc.ReadBytes(data, 8, data[0])); node.Name = Encoding.ASCII.GetString(bc.ReadBytes(data, 8, data[0]));
// if nameLength is odd a padding byte must be added // if nameLength is odd a padding byte must be added
if (node.NameLength % 2 != 0) if (node.NameLength % 2 != 0)
pad = 1; pad = 1;
pathNodes.Add(node); pathNodes.Add(node);
startCursor += node.NameLength + 8; startCursor += node.NameLength + 8;
} while (startCursor < PathTableSize + pad); } while (startCursor < PathTableSize + pad);
return pathNodes; return pathNodes;
} }
#endregion #endregion
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -53,45 +53,45 @@ namespace BizHawk.Emulation.DiscSystem
/// </summary> /// </summary>
PCFX, PCFX,
/// <summary> /// <summary>
/// By Panasonic /// By Panasonic
/// </summary> /// </summary>
Panasonic3DO, Panasonic3DO,
/// <summary> /// <summary>
/// Philips /// Philips
/// </summary> /// </summary>
CDi, CDi,
/// <summary> /// <summary>
/// Nintendo Gamecube /// Nintendo Gamecube
/// </summary> /// </summary>
GameCube, GameCube,
/// <summary> /// <summary>
/// Nintendo Wii /// Nintendo Wii
/// </summary> /// </summary>
Wii, Wii,
/// <summary> /// <summary>
/// SNK NeoGeo /// SNK NeoGeo
/// </summary> /// </summary>
NeoGeoCD, NeoGeoCD,
/// <summary> /// <summary>
/// Bandai Playdia /// Bandai Playdia
/// </summary> /// </summary>
Playdia, Playdia,
/// <summary> /// <summary>
/// Either CDTV or CD32 (I havent found a reliable way of distinguishing between them yet -asni) /// Either CDTV or CD32 (I havent found a reliable way of distinguishing between them yet -asni)
/// </summary> /// </summary>
Amiga, Amiga,
/// <summary> /// <summary>
/// Sega Dreamcast /// Sega Dreamcast
/// </summary> /// </summary>
Dreamcast Dreamcast
} }
public class DiscIdentifier public class DiscIdentifier
@ -121,19 +121,19 @@ namespace BizHawk.Emulation.DiscSystem
if (DetectPCFX()) if (DetectPCFX())
return DiscType.PCFX; return DiscType.PCFX;
if (DetectTurboCD()) if (DetectTurboCD())
return DiscType.TurboCD; return DiscType.TurboCD;
//check track 1's data type. if it's an audio track, further data-track testing is useless //check track 1's data type. if it's an audio track, further data-track testing is useless
//furthermore, it's probably senseless (no binary data there to read) //furthermore, it's probably senseless (no binary data there to read)
if (!_disc.TOC.TOCItems[1].IsData) if (!_disc.TOC.TOCItems[1].IsData)
return DiscType.AudioDisc; return DiscType.AudioDisc;
// if (_dsr.ReadLBA_Mode(_disc.TOC.TOCItems[1].LBA) == 0) // if (_dsr.ReadLBA_Mode(_disc.TOC.TOCItems[1].LBA) == 0)
// return DiscType.AudioDisc; // return DiscType.AudioDisc;
// sega doesnt put anything identifying in the cdfs volume info. but its consistent about putting its own header here in sector 0 // sega doesnt put anything identifying in the cdfs volume info. but its consistent about putting its own header here in sector 0
//asni - this isn't strictly true - SystemIdentifier in volume descriptor has been observed on occasion (see below) //asni - this isn't strictly true - SystemIdentifier in volume descriptor has been observed on occasion (see below)
if (DetectSegaSaturn()) if (DetectSegaSaturn())
return DiscType.SegaSaturn; return DiscType.SegaSaturn;
@ -145,79 +145,79 @@ namespace BizHawk.Emulation.DiscSystem
if (DetectPSX()) if (DetectPSX())
return DiscType.SonyPSX; return DiscType.SonyPSX;
if (Detect3DO()) if (Detect3DO())
return DiscType.Panasonic3DO; return DiscType.Panasonic3DO;
if (DetectCDi()) if (DetectCDi())
return DiscType.CDi; return DiscType.CDi;
if (DetectGameCube()) if (DetectGameCube())
return DiscType.GameCube; return DiscType.GameCube;
if (DetectWii()) if (DetectWii())
return DiscType.Wii; return DiscType.Wii;
var discView = EDiscStreamView.DiscStreamView_Mode1_2048; var discView = EDiscStreamView.DiscStreamView_Mode1_2048;
if (_disc.TOC.Session1Format == SessionFormat.Type20_CDXA) if (_disc.TOC.Session1Format == SessionFormat.Type20_CDXA)
discView = EDiscStreamView.DiscStreamView_Mode2_Form1_2048; discView = EDiscStreamView.DiscStreamView_Mode2_Form1_2048;
var iso = new ISOFile(); var iso = new ISOFile();
bool isIso = iso.Parse(new DiscStream(_disc, discView, 0)); bool isIso = iso.Parse(new DiscStream(_disc, discView, 0));
if (!isIso) if (!isIso)
{ {
// its much quicker to detect dreamcast from ISO data. Only do this if ISO is not detected // its much quicker to detect dreamcast from ISO data. Only do this if ISO is not detected
if (DetectDreamcast()) if (DetectDreamcast())
return DiscType.Dreamcast; return DiscType.Dreamcast;
} }
//*** asni - 20171011 - Suggestion: move this to the beginning of the DetectDiscType() method before any longer running lookups? //*** asni - 20171011 - Suggestion: move this to the beginning of the DetectDiscType() method before any longer running lookups?
//its a cheap win for a lot of systems, but ONLY if the iso.Parse() method is quick running (might have to time it) //its a cheap win for a lot of systems, but ONLY if the iso.Parse() method is quick running (might have to time it)
if (isIso) if (isIso)
{ {
var appId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].ApplicationIdentifier).TrimEnd('\0', ' '); var appId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].ApplicationIdentifier).TrimEnd('\0', ' ');
var sysId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].SystemIdentifier).TrimEnd('\0', ' '); var sysId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].SystemIdentifier).TrimEnd('\0', ' ');
//for example: PSX magical drop F (JP SLPS_02337) doesn't have the correct iso PVD fields //for example: PSX magical drop F (JP SLPS_02337) doesn't have the correct iso PVD fields
//but, some PSX games (junky rips) don't have the 'licensed by string' so we'll hope they get caught here //but, some PSX games (junky rips) don't have the 'licensed by string' so we'll hope they get caught here
if (appId == "PLAYSTATION") if (appId == "PLAYSTATION")
return DiscType.SonyPSX; return DiscType.SonyPSX;
if (appId == "PSP GAME") if (appId == "PSP GAME")
return DiscType.SonyPSP; return DiscType.SonyPSP;
// in case the appId is not set correctly... // in case the appId is not set correctly...
if (iso.Root.Children.Where(a => a.Key == "PSP_GAME").FirstOrDefault().Value as ISODirectoryNode != null) if (iso.Root.Children.Where(a => a.Key == "PSP_GAME").FirstOrDefault().Value as ISODirectoryNode != null)
return DiscType.SonyPSP; return DiscType.SonyPSP;
if (sysId == "SEGA SEGASATURN") if (sysId == "SEGA SEGASATURN")
return DiscType.SegaSaturn; return DiscType.SegaSaturn;
if (sysId.Contains("SEGAKATANA")) if (sysId.Contains("SEGAKATANA"))
return DiscType.Dreamcast; return DiscType.Dreamcast;
if (sysId == "MEGA_CD") if (sysId == "MEGA_CD")
return DiscType.MegaCD; return DiscType.MegaCD;
if (sysId == "ASAHI-CDV") if (sysId == "ASAHI-CDV")
return DiscType.Playdia; return DiscType.Playdia;
if (sysId == "CDTV" || sysId == "AMIGA") if (sysId == "CDTV" || sysId == "AMIGA")
return DiscType.Amiga; return DiscType.Amiga;
foreach (var f in iso.Root.Children) foreach (var f in iso.Root.Children)
if (f.Key.ToLower().Contains("cd32")) if (f.Key.ToLower().Contains("cd32"))
return DiscType.Amiga; return DiscType.Amiga;
// NeoGeoCD Check // NeoGeoCD Check
var absTxt = iso.Root.Children.Where(a => a.Key.Contains("ABS.TXT")).ToList(); var absTxt = iso.Root.Children.Where(a => a.Key.Contains("ABS.TXT")).ToList();
if (absTxt.Count > 0) if (absTxt.Count > 0)
{ {
if (SectorContains("abstracted by snk", Convert.ToInt32(absTxt.First().Value.Offset))) if (SectorContains("abstracted by snk", Convert.ToInt32(absTxt.First().Value.Offset)))
return DiscType.NeoGeoCD; return DiscType.NeoGeoCD;
} }
return DiscType.UnknownCDFS; return DiscType.UnknownCDFS;
} }
return DiscType.UnknownFormat; return DiscType.UnknownFormat;
} }
@ -256,87 +256,87 @@ namespace BizHawk.Emulation.DiscSystem
t++) t++)
{ {
var track = _disc.TOC.TOCItems[t]; var track = _disc.TOC.TOCItems[t];
//asni - this search is less specific - turns out there are discs where 'Hu:' is not present //asni - this search is less specific - turns out there are discs where 'Hu:' is not present
if (track.IsData && SectorContains("pc-fx", track.LBA)) if (track.IsData && SectorContains("pc-fx", track.LBA))
return true; return true;
} }
return false; return false;
} }
//asni 20171011 - this ONLY works if a valid cuefile/ccd is passed into DiscIdentifier. //asni 20171011 - this ONLY works if a valid cuefile/ccd is passed into DiscIdentifier.
//if an .iso is presented, the internally manufactured cue data does not work - possibly something to do with //if an .iso is presented, the internally manufactured cue data does not work - possibly something to do with
//track 01 being Audio. Not tested, but presumably PCFX has the same issue //track 01 being Audio. Not tested, but presumably PCFX has the same issue
bool DetectTurboCD() bool DetectTurboCD()
{ {
var toc = _disc.TOC; var toc = _disc.TOC;
for (int t = toc.FirstRecordedTrackNumber; for (int t = toc.FirstRecordedTrackNumber;
t <= toc.LastRecordedTrackNumber; t <= toc.LastRecordedTrackNumber;
t++) t++)
{ {
var track = _disc.TOC.TOCItems[t]; var track = _disc.TOC.TOCItems[t];
//asni - pcfx games also contain the 'PC Engine' string //asni - pcfx games also contain the 'PC Engine' string
if ((track.IsData && SectorContains("pc engine", track.LBA + 1) && !SectorContains("pc-fx", track.LBA + 1))) if ((track.IsData && SectorContains("pc engine", track.LBA + 1) && !SectorContains("pc-fx", track.LBA + 1)))
return true; return true;
} }
return false; return false;
} }
bool Detect3DO() bool Detect3DO()
{ {
var toc = _disc.TOC; var toc = _disc.TOC;
for (int t = toc.FirstRecordedTrackNumber; for (int t = toc.FirstRecordedTrackNumber;
t <= toc.LastRecordedTrackNumber; t <= toc.LastRecordedTrackNumber;
t++) t++)
{ {
var track = _disc.TOC.TOCItems[t]; var track = _disc.TOC.TOCItems[t];
if (track.IsData && SectorContains("iamaduckiamaduck", track.LBA)) if (track.IsData && SectorContains("iamaduckiamaduck", track.LBA))
return true; return true;
} }
return false; return false;
} }
//asni - slightly longer running than the others due to its brute-force nature. Should run later in the method //asni - slightly longer running than the others due to its brute-force nature. Should run later in the method
bool DetectDreamcast() bool DetectDreamcast()
{ {
for (int i = 0; i < 1000; i++) for (int i = 0; i < 1000; i++)
{ {
if (SectorContains("segakatana", i)) if (SectorContains("segakatana", i))
return true; return true;
} }
return false; return false;
} }
bool DetectCDi() bool DetectCDi()
{ {
return StringAt("CD-RTOS", 8, 16); return StringAt("CD-RTOS", 8, 16);
} }
bool DetectGameCube() bool DetectGameCube()
{ {
var data = ReadSectorCached(0); var data = ReadSectorCached(0);
if (data == null) return false; if (data == null) return false;
byte[] magic = data.Skip(28).Take(4).ToArray(); byte[] magic = data.Skip(28).Take(4).ToArray();
string hexString = ""; string hexString = "";
foreach (var b in magic) foreach (var b in magic)
hexString += b.ToString("X2"); hexString += b.ToString("X2");
return hexString == "C2339F3D"; return hexString == "C2339F3D";
} }
bool DetectWii() bool DetectWii()
{ {
var data = ReadSectorCached(0); var data = ReadSectorCached(0);
if (data == null) return false; if (data == null) return false;
byte[] magic = data.Skip(24).Take(4).ToArray(); byte[] magic = data.Skip(24).Take(4).ToArray();
string hexString = ""; string hexString = "";
foreach (var b in magic) foreach (var b in magic)
hexString += b.ToString("X2"); hexString += b.ToString("X2");
return hexString == "5D1C9EA3"; return hexString == "5D1C9EA3";
} }
private byte[] ReadSectorCached(int lba) private byte[] ReadSectorCached(int lba)
{ {
//read it if we dont have it cached //read it if we dont have it cached
//we wont be caching very much here, it's no big deal //we wont be caching very much here, it's no big deal
@ -363,11 +363,11 @@ namespace BizHawk.Emulation.DiscSystem
return System.Linq.Enumerable.SequenceEqual(cmp, cmp2); return System.Linq.Enumerable.SequenceEqual(cmp, cmp2);
} }
private bool SectorContains(string s, int lba = 0) private bool SectorContains(string s, int lba = 0)
{ {
var data = ReadSectorCached(lba); var data = ReadSectorCached(lba);
if (data == null) return false; if (data == null) return false;
return System.Text.Encoding.ASCII.GetString(data).ToLower().Contains(s.ToLower()); return System.Text.Encoding.ASCII.GetString(data).ToLower().Contains(s.ToLower());
} }
} }
} }

View File

@ -186,11 +186,11 @@ namespace BizHawk.Emulation.DiscSystem
CCD_Format ccdLoader = new CCD_Format(); CCD_Format ccdLoader = new CCD_Format();
OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy); OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy);
} }
else if (ext == ".mds") else if (ext == ".mds")
{ {
MDS_Format mdsLoader = new MDS_Format(); MDS_Format mdsLoader = new MDS_Format();
OUT_Disc = mdsLoader.LoadMDSToDisc(IN_FromPath, IN_DiscMountPolicy); OUT_Disc = mdsLoader.LoadMDSToDisc(IN_FromPath, IN_DiscMountPolicy);
} }
DONE: DONE:

View File

@ -103,8 +103,8 @@ namespace BizHawk.Bizware.BizwareGL
sampler0.Set(tex); sampler0.Set(tex);
Owner.SetViewport(OutputSize); Owner.SetViewport(OutputSize);
float time = DateTime.Now.Second + (float)DateTime.Now.Millisecond / 1000; float time = DateTime.Now.Second + (float)DateTime.Now.Millisecond / 1000;
Pipeline["Time"].Set(time); Pipeline["Time"].Set(time);
int w = OutputSize.Width; int w = OutputSize.Width;
int h = OutputSize.Height; int h = OutputSize.Height;

View File

@ -4,58 +4,58 @@ using System.IO;
namespace BizHawk.Emulation.CPUs.M6502 namespace BizHawk.Emulation.CPUs.M6502
{ {
public sealed partial class MOS6502 public sealed partial class MOS6502
{ {
public MOS6502() public MOS6502()
{ {
//InitTableNZ(); //InitTableNZ();
Reset(); Reset();
} }
/* /*
private byte[] TableNZ; private byte[] TableNZ;
private void InitTableNZ() private void InitTableNZ()
{ {
TableNZ = new byte[256]; TableNZ = new byte[256];
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
byte b = 0; byte b = 0;
if (i == 0) b |= 0x02; if (i == 0) b |= 0x02;
if (i > 127) b |= 0x80; if (i > 127) b |= 0x80;
TableNZ[i] = b; TableNZ[i] = b;
} }
}*/ }*/
public bool debug; public bool debug;
public bool throw_unhandled; public bool throw_unhandled;
public void Reset() public void Reset()
{ {
A = 0; A = 0;
X = 0; X = 0;
Y = 0; Y = 0;
P = 0; P = 0;
S = 0; S = 0;
PC = 0; PC = 0;
PendingCycles = 0; PendingCycles = 0;
TotalExecutedCycles = 0; TotalExecutedCycles = 0;
} }
public string State() public string State()
{ {
int notused; int notused;
string a = string.Format("{0:X4} {1:X2} {2} ", PC, ReadMemory(PC), Disassemble(PC, out notused)).PadRight(30); string a = string.Format("{0:X4} {1:X2} {2} ", PC, ReadMemory(PC), Disassemble(PC, out notused)).PadRight(30);
string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles); string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles);
string val = a + b + " "; string val = a + b + " ";
if (FlagN) val = val + "N"; if (FlagN) val = val + "N";
if (FlagV) val = val + "V"; if (FlagV) val = val + "V";
if (FlagT) val = val + "T"; if (FlagT) val = val + "T";
if (FlagB) val = val + "B"; if (FlagB) val = val + "B";
if (FlagD) val = val + "D"; if (FlagD) val = val + "D";
if (FlagI) val = val + "I"; if (FlagI) val = val + "I";
if (FlagZ) val = val + "Z"; if (FlagZ) val = val + "Z";
if (FlagC) val = val + "C"; if (FlagC) val = val + "C";
return val; return val;
} }
public const ushort NMIVector = 0xFFFA; public const ushort NMIVector = 0xFFFA;
public const ushort ResetVector = 0xFFFC; public const ushort ResetVector = 0xFFFC;
@ -92,17 +92,17 @@ namespace BizHawk.Emulation.CPUs.M6502
PendingCycles -= 7; PendingCycles -= 7;
} }
// ==== CPU State ==== // ==== CPU State ====
public byte A; public byte A;
public byte X; public byte X;
public byte Y; public byte Y;
public byte P; public byte P;
public ushort PC; public ushort PC;
public byte S; public byte S;
public bool IRQ; public bool IRQ;
public bool NMI; public bool NMI;
public bool CLI_Pending; public bool CLI_Pending;
public bool SEI_Pending; public bool SEI_Pending;
@ -127,115 +127,115 @@ namespace BizHawk.Emulation.CPUs.M6502
public void SaveStateBinary(BinaryWriter writer) { SyncState(Serializer.CreateBinaryWriter(writer)); } public void SaveStateBinary(BinaryWriter writer) { SyncState(Serializer.CreateBinaryWriter(writer)); }
public void LoadStateBinary(BinaryReader reader) { SyncState(Serializer.CreateBinaryReader(reader)); } public void LoadStateBinary(BinaryReader reader) { SyncState(Serializer.CreateBinaryReader(reader)); }
// ==== End State ==== // ==== End State ====
/// <summary>Carry Flag</summary> /// <summary>Carry Flag</summary>
private bool FlagC private bool FlagC
{ {
get { return (P & 0x01) != 0; } get { return (P & 0x01) != 0; }
set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); } set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); }
} }
/// <summary>Zero Flag</summary> /// <summary>Zero Flag</summary>
private bool FlagZ private bool FlagZ
{ {
get { return (P & 0x02) != 0; } get { return (P & 0x02) != 0; }
set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); } set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); }
} }
/// <summary>Interrupt Disable Flag</summary> /// <summary>Interrupt Disable Flag</summary>
public bool FlagI public bool FlagI
{ {
get { return (P & 0x04) != 0; } get { return (P & 0x04) != 0; }
set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); } set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); }
} }
/// <summary>Decimal Mode Flag</summary> /// <summary>Decimal Mode Flag</summary>
private bool FlagD private bool FlagD
{ {
get { return (P & 0x08) != 0; } get { return (P & 0x08) != 0; }
set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); } set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); }
} }
/// <summary>Break Flag</summary> /// <summary>Break Flag</summary>
private bool FlagB private bool FlagB
{ {
get { return (P & 0x10) != 0; } get { return (P & 0x10) != 0; }
set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); } set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); }
} }
/// <summary>T... Flag</summary> /// <summary>T... Flag</summary>
private bool FlagT private bool FlagT
{ {
get { return (P & 0x20) != 0; } get { return (P & 0x20) != 0; }
set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); } set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); }
} }
/// <summary>Overflow Flag</summary> /// <summary>Overflow Flag</summary>
private bool FlagV private bool FlagV
{ {
get { return (P & 0x40) != 0; } get { return (P & 0x40) != 0; }
set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); } set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); }
} }
/// <summary>Negative Flag</summary> /// <summary>Negative Flag</summary>
private bool FlagN private bool FlagN
{ {
get { return (P & 0x80) != 0; } get { return (P & 0x80) != 0; }
set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); } set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); }
} }
public int TotalExecutedCycles; public int TotalExecutedCycles;
public int PendingCycles; public int PendingCycles;
public Func<ushort, byte> ReadMemory; public Func<ushort, byte> ReadMemory;
public Action<ushort, byte> WriteMemory; public Action<ushort, byte> WriteMemory;
public void UnregisterMemoryMapper() public void UnregisterMemoryMapper()
{ {
ReadMemory = null; ReadMemory = null;
WriteMemory = null; WriteMemory = null;
} }
public ushort ReadWord(ushort address) public ushort ReadWord(ushort address)
{ {
byte l = ReadMemory(address); byte l = ReadMemory(address);
byte h = ReadMemory(++address); byte h = ReadMemory(++address);
return (ushort)((h << 8) | l); return (ushort)((h << 8) | l);
} }
private void WriteWord(ushort address, ushort value) private void WriteWord(ushort address, ushort value)
{ {
byte l = (byte)(value & 0xFF); byte l = (byte)(value & 0xFF);
byte h = (byte)(value >> 8); byte h = (byte)(value >> 8);
WriteMemory(address, l); WriteMemory(address, l);
WriteMemory(++address, h); WriteMemory(++address, h);
} }
private ushort ReadWordPageWrap(ushort address) private ushort ReadWordPageWrap(ushort address)
{ {
ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF)); ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF));
return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8)); return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8));
} }
private static readonly byte[] TableNZ = private static readonly byte[] TableNZ =
{ {
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
}; };
} }
} }