diff --git a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs index 16da2eddb0..0957068e5b 100644 --- a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs +++ b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs @@ -99,11 +99,11 @@ namespace BizHawk.Client.ApiHawk case "WSWAN": return CoreSystem.WonderSwan; - case "ZXSpectrum": - return CoreSystem.ZXSpectrum; + case "ZXSpectrum": + return CoreSystem.ZXSpectrum; - case "AmstradCPC": - return CoreSystem.AmstradCPC; + case "AmstradCPC": + return CoreSystem.AmstradCPC; case "GGL": return CoreSystem.GGL; @@ -229,11 +229,11 @@ namespace BizHawk.Client.ApiHawk case CoreSystem.WonderSwan: return "WSWAN"; - case CoreSystem.ZXSpectrum: - return "ZXSpectrum"; + case CoreSystem.ZXSpectrum: + return "ZXSpectrum"; - case CoreSystem.AmstradCPC: - return "AmstradCPC"; + case CoreSystem.AmstradCPC: + return "AmstradCPC"; default: throw new IndexOutOfRangeException($"{value.ToString()} is missing in convert list"); diff --git a/BizHawk.Client.Common/Api/CoreSystem.cs b/BizHawk.Client.Common/Api/CoreSystem.cs index 3fad8c8563..af723e110c 100644 --- a/BizHawk.Client.Common/Api/CoreSystem.cs +++ b/BizHawk.Client.Common/Api/CoreSystem.cs @@ -31,8 +31,8 @@ VirtualBoy, Vectrex, NeoGeoPocket, - ZXSpectrum, - AmstradCPC, + ZXSpectrum, + AmstradCPC, GGL, GB3x, GB4x, diff --git a/BizHawk.Client.Common/FirmwareManager.cs b/BizHawk.Client.Common/FirmwareManager.cs index d6dc3040fa..90ad436077 100644 --- a/BizHawk.Client.Common/FirmwareManager.cs +++ b/BizHawk.Client.Common/FirmwareManager.cs @@ -126,35 +126,35 @@ namespace BizHawk.Client.Common public Dictionary Dict { get; } = new Dictionary(); } - /// - /// Test to determine whether the supplied firmware file matches something in the firmware database - /// - public bool CanFileBeImported(string f) - { - try - { - var fi = new FileInfo(f); - if (!fi.Exists) - return false; + /// + /// Test to determine whether the supplied firmware file matches something in the firmware database + /// + public bool CanFileBeImported(string f) + { + try + { + var fi = new FileInfo(f); + if (!fi.Exists) + return false; - // weed out filesizes first to reduce the unnecessary overhead of a hashing operation - if (FirmwareDatabase.FirmwareFiles.Where(a => a.Size == fi.Length).FirstOrDefault() == null) - return false; + // weed out filesizes first to reduce the unnecessary overhead of a hashing operation + if (FirmwareDatabase.FirmwareFiles.Where(a => a.Size == fi.Length).FirstOrDefault() == null) + return false; - // check the hash - using (var reader = new RealFirmwareReader()) - { - reader.Read(fi); - if (FirmwareDatabase.FirmwareFiles.Where(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash).FirstOrDefault() != null) - return true; - } - } - catch { } + // check the hash + using (var reader = new RealFirmwareReader()) + { + reader.Read(fi); + if (FirmwareDatabase.FirmwareFiles.Where(a => a.Hash == reader.Dict.FirstOrDefault().Value.Hash).FirstOrDefault() != null) + return true; + } + } + catch { } - return false; - } + return false; + } - public void DoScanAndResolve() + public void DoScanAndResolve() { // build a list of file sizes. Only those will be checked during scanning HashSet sizes = new HashSet(); diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index 020f0672f1..c690845cce 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -156,10 +156,10 @@ namespace BizHawk.Client.Common return SystemInfo.Vectrex; case "NGP": return SystemInfo.NeoGeoPocket; - case "ZXSpectrum": - return SystemInfo.ZXSpectrum; - case "AmstradCPC": - return SystemInfo.AmstradCPC; + case "ZXSpectrum": + return SystemInfo.ZXSpectrum; + case "AmstradCPC": + return SystemInfo.AmstradCPC; case "ChannelF": return SystemInfo.ChannelF; } diff --git a/BizHawk.Client.Common/OpenAdvanced.cs b/BizHawk.Client.Common/OpenAdvanced.cs index 88fbee6689..e1ddd48609 100644 --- a/BizHawk.Client.Common/OpenAdvanced.cs +++ b/BizHawk.Client.Common/OpenAdvanced.cs @@ -57,30 +57,30 @@ namespace BizHawk.Client.Common string token = text.Substring(idx + 1); IOpenAdvanced ioa; - if (type == OpenAdvancedTypes.OpenRom) - { - ioa = new OpenAdvanced_OpenRom(); + if (type == OpenAdvancedTypes.OpenRom) + { + ioa = new OpenAdvanced_OpenRom(); } - else if (type == OpenAdvancedTypes.Libretro) - { - ioa = new OpenAdvanced_Libretro(); + else if (type == OpenAdvancedTypes.Libretro) + { + ioa = new OpenAdvanced_Libretro(); } - else if (type == OpenAdvancedTypes.LibretroNoGame) - { - ioa = new OpenAdvanced_LibretroNoGame(); + else if (type == OpenAdvancedTypes.LibretroNoGame) + { + ioa = new OpenAdvanced_LibretroNoGame(); } - else if (type == OpenAdvancedTypes.MAME) - { - ioa = new OpenAdvanced_MAME(); + else if (type == OpenAdvancedTypes.MAME) + { + ioa = new OpenAdvanced_MAME(); } - else - { - ioa = null; + else + { + ioa = null; } - if (ioa == null) + if (ioa == null) { - throw new InvalidOperationException($"{nameof(IOpenAdvanced)} deserialization error"); + throw new InvalidOperationException($"{nameof(IOpenAdvanced)} deserialization error"); } ioa.Deserialize(token); diff --git a/BizHawk.Client.Common/RomGame.cs b/BizHawk.Client.Common/RomGame.cs index 0a69964793..78f1aeec6a 100644 --- a/BizHawk.Client.Common/RomGame.cs +++ b/BizHawk.Client.Common/RomGame.cs @@ -66,14 +66,14 @@ namespace BizHawk.Client.Common { RomData = FileData; } - else if (file.Extension == ".DSK" || file.Extension == ".TAP" || file.Extension == ".TZX" || - 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 - // where a header offset is detected. This should mitigate this issue until a cleaner solution is found - // (-Asnivor) - RomData = FileData; - } + else if (file.Extension == ".DSK" || file.Extension == ".TAP" || file.Extension == ".TZX" || + 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 + // where a header offset is detected. This should mitigate this issue until a cleaner solution is found + // (-Asnivor) + RomData = FileData; + } 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) diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 58e417333a..115901b558 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -529,9 +529,9 @@ namespace BizHawk.Client.Common // try to use our wizard methods 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: game.System = "SAT"; @@ -549,21 +549,21 @@ namespace BizHawk.Client.Common case DiscType.PCFX: game.System = "PCFX"; break; - case DiscType.TurboCD: - game.System = "PCECD"; - break; + case DiscType.TurboCD: + game.System = "PCECD"; + break; - case DiscType.Amiga: - case DiscType.CDi: - case DiscType.Dreamcast: - case DiscType.GameCube: - case DiscType.NeoGeoCD: - case DiscType.Panasonic3DO: - case DiscType.Playdia: - case DiscType.Wii: - // no supported emulator core for these (yet) - game.System = dt.ToString(); - throw new NoAvailableCoreException(dt.ToString()); + case DiscType.Amiga: + case DiscType.CDi: + case DiscType.Dreamcast: + case DiscType.GameCube: + case DiscType.NeoGeoCD: + case DiscType.Panasonic3DO: + case DiscType.Playdia: + case DiscType.Wii: + // no supported emulator core for these (yet) + game.System = dt.ToString(); + throw new NoAvailableCoreException(dt.ToString()); case DiscType.AudioDisc: case DiscType.UnknownCDFS: @@ -574,7 +574,7 @@ namespace BizHawk.Client.Common } else { - game.System = "NULL"; // "PCECD"; + game.System = "NULL"; // "PCECD"; } break; @@ -583,9 +583,9 @@ namespace BizHawk.Client.Common switch (game.System) { - case "NULL": - nextEmulator = null; - break; + case "NULL": + nextEmulator = null; + break; case "GEN": var genesis = new GPGX(nextComm, null, new[] { disc }, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = genesis; @@ -731,38 +731,38 @@ namespace BizHawk.Client.Common (C64.C64Settings)GetCoreSettings(), (C64.C64SyncSettings)GetCoreSyncSettings()); break; - case "ZXSpectrum": + case "ZXSpectrum": - List zxGI = new List(); - foreach (var a in xmlGame.Assets) - { - zxGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) }); - } + List zxGI = new List(); + foreach (var a in xmlGame.Assets) + { + zxGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) }); + } - nextEmulator = new ZXSpectrum( - nextComm, - xmlGame.Assets.Select(a => a.Value), //.First(), - zxGI, // GameInfo.NullInstance, - (ZXSpectrum.ZXSpectrumSettings)GetCoreSettings(), - (ZXSpectrum.ZXSpectrumSyncSettings)GetCoreSyncSettings(), - Deterministic); - break; - case "AmstradCPC": + nextEmulator = new ZXSpectrum( + nextComm, + xmlGame.Assets.Select(a => a.Value), //.First(), + zxGI, // GameInfo.NullInstance, + (ZXSpectrum.ZXSpectrumSettings)GetCoreSettings(), + (ZXSpectrum.ZXSpectrumSyncSettings)GetCoreSyncSettings(), + Deterministic); + break; + case "AmstradCPC": - List cpcGI = new List(); - foreach (var a in xmlGame.Assets) - { - cpcGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) }); - } + List cpcGI = new List(); + foreach (var a in xmlGame.Assets) + { + cpcGI.Add(new GameInfo { Name = Path.GetFileNameWithoutExtension(a.Key) }); + } - nextEmulator = new AmstradCPC( - nextComm, - xmlGame.Assets.Select(a => a.Value), //.First(), - cpcGI, // GameInfo.NullInstance, - (AmstradCPC.AmstradCPCSettings)GetCoreSettings(), - (AmstradCPC.AmstradCPCSyncSettings)GetCoreSyncSettings()); - break; - case "PSX": + nextEmulator = new AmstradCPC( + nextComm, + xmlGame.Assets.Select(a => a.Value), //.First(), + cpcGI, // GameInfo.NullInstance, + (AmstradCPC.AmstradCPCSettings)GetCoreSettings(), + (AmstradCPC.AmstradCPCSyncSettings)GetCoreSyncSettings()); + break; + case "PSX": var entries = xmlGame.AssetFullPaths; var discs = new List(); var discNames = new List(); @@ -1127,23 +1127,23 @@ namespace BizHawk.Client.Common var c64 = new C64(nextComm, Enumerable.Repeat(rom.FileData, 1), rom.GameInfo, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = c64; break; - case "ZXSpectrum": - var zx = new ZXSpectrum(nextComm, - Enumerable.Repeat(rom.RomData, 1), - Enumerable.Repeat(rom.GameInfo, 1).ToList(), - GetCoreSettings(), - GetCoreSyncSettings(), - Deterministic); - nextEmulator = zx; - break; + case "ZXSpectrum": + var zx = new ZXSpectrum(nextComm, + Enumerable.Repeat(rom.RomData, 1), + Enumerable.Repeat(rom.GameInfo, 1).ToList(), + GetCoreSettings(), + GetCoreSyncSettings(), + Deterministic); + nextEmulator = zx; + break; case "ChannelF": nextEmulator = new ChannelF(nextComm, game, rom.FileData, GetCoreSettings(), GetCoreSyncSettings()); break; - case "AmstradCPC": - var cpc = new AmstradCPC(nextComm, Enumerable.Repeat(rom.RomData, 1), Enumerable.Repeat(rom.GameInfo, 1).ToList(), GetCoreSettings(), GetCoreSyncSettings()); - nextEmulator = cpc; - break; - case "GBA": + case "AmstradCPC": + var cpc = new AmstradCPC(nextComm, Enumerable.Repeat(rom.RomData, 1), Enumerable.Repeat(rom.GameInfo, 1).ToList(), GetCoreSettings(), GetCoreSyncSettings()); + nextEmulator = cpc; + break; + case "GBA": if (Global.Config.GBA_UsemGBA) { core = CoreInventory.Instance["GBA", "mGBA"]; @@ -1235,13 +1235,13 @@ namespace BizHawk.Client.Common return LoadRom(path, nextComm, false, recursiveCount + 1); } - // handle exceptions thrown by the new detected systems that bizhawk does not have cores for - else if (ex is NoAvailableCoreException) - { - DoLoadErrorCallback($"{ex.Message}\n\n{ex}", system); - } + // handle exceptions thrown by the new detected systems that bizhawk does not have cores for + else if (ex is NoAvailableCoreException) + { + 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); } diff --git a/BizHawk.Client.Common/SystemInfo.cs b/BizHawk.Client.Common/SystemInfo.cs index 880074f08f..40bf90c704 100644 --- a/BizHawk.Client.Common/SystemInfo.cs +++ b/BizHawk.Client.Common/SystemInfo.cs @@ -203,15 +203,15 @@ namespace BizHawk.Client.Common /// public static SystemInfo NeoGeoPocket { get; } = new SystemInfo("Neo-Geo Pocket", CoreSystem.NeoGeoPocket, 1); - /// - /// Gets the instance for ZXSpectrum - /// - public static SystemInfo ZXSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2); + /// + /// Gets the instance for ZXSpectrum + /// + public static SystemInfo ZXSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2); - /// - /// Gets the instance for AmstradCPC - /// - public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2); + /// + /// Gets the instance for AmstradCPC + /// + public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2); /// /// Gets the instance for GGL diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index af6d4d6693..a4a8429bf0 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -83,12 +83,12 @@ namespace BizHawk.Client.Common { 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.BindArchiveMember(archiveItem); data = hf.GetStream().ReadAllBytes(); - filename = filename.Split('|').Skip(1).First(); + filename = filename.Split('|').Skip(1).First(); } else { diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 2c91df1807..353e78d3e7 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, new PathEntry { System = "PSX", SystemDisplayName = "Playstation", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs index 101674a187..a3029b34a8 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.UserData.cs @@ -18,23 +18,23 @@ namespace BizHawk.Client.EmuHawk public override string Name => "userdata"; - [LuaMethodExample("userdata.set(\"Unique key\", \"Current key data\");")] + [LuaMethodExample("userdata.set(\"Unique key\", \"Current key data\");")] [LuaMethod("set", "adds or updates the data with the given key with the given value")] public void Set(string name, object value) - { - if (value != null) - { - var t = value.GetType(); - if (!t.IsPrimitive && t != typeof(string)) - { - throw new InvalidOperationException("Invalid type for userdata"); - } + { + if (value != null) + { + var t = value.GetType(); + if (!t.IsPrimitive && t != typeof(string)) + { + throw new InvalidOperationException("Invalid type for userdata"); + } } Global.UserBag[name] = value; } - [LuaMethodExample("local obuseget = userdata.get( \"Unique key\" );")] + [LuaMethodExample("local obuseget = userdata.get( \"Unique key\" );")] [LuaMethod("get", "gets the data with the given key, if the key does not exist it will return nil")] public object Get(string key) { @@ -46,21 +46,21 @@ namespace BizHawk.Client.EmuHawk return null; } - [LuaMethodExample("userdata.clear( );")] + [LuaMethodExample("userdata.clear( );")] [LuaMethod("clear", "clears all user data")] public void Clear() { Global.UserBag.Clear(); } - [LuaMethodExample("if ( userdata.remove( \"Unique key\" ) ) then\r\n\tconsole.log( \"remove the data with the given key.Returns true if the element is successfully found and removed; otherwise, false.\" );\r\nend;")] + [LuaMethodExample("if ( userdata.remove( \"Unique key\" ) ) then\r\n\tconsole.log( \"remove the data with the given key.Returns true if the element is successfully found and removed; otherwise, false.\" );\r\nend;")] [LuaMethod("remove", "remove the data with the given key. Returns true if the element is successfully found and removed; otherwise, false.")] public bool Remove(string key) { return Global.UserBag.Remove(key); } - [LuaMethodExample("if ( userdata.containskey( \"Unique key\" ) ) then\r\n\tconsole.log( \"returns whether or not there is an entry for the given key\" );\r\nend;")] + [LuaMethodExample("if ( userdata.containskey( \"Unique key\" ) ) then\r\n\tconsole.log( \"returns whether or not there is an entry for the given key\" );\r\nend;")] [LuaMethod("containskey", "returns whether or not there is an entry for the given key")] public bool ContainsKey(string key) { diff --git a/BizHawk.Client.Common/movie/PlatformFrameRates.cs b/BizHawk.Client.Common/movie/PlatformFrameRates.cs index f199e4ee8a..e5bed219d7 100644 --- a/BizHawk.Client.Common/movie/PlatformFrameRates.cs +++ b/BizHawk.Client.Common/movie/PlatformFrameRates.cs @@ -61,18 +61,18 @@ namespace BizHawk.Client.Common ["C64_DREAN"] = PALNCarrier * 2 / 7 / 312 / 65, ["INTV"] = 59.92, - ["ZXSpectrum_PAL"] = 50.080128205, - ["AmstradCPC_PAL"] = 50.08012820512821, + ["ZXSpectrum_PAL"] = 50.080128205, + ["AmstradCPC_PAL"] = 50.08012820512821, - // according to ryphecha, using - // clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console - // lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced - // 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: 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: 1 --- 50.000282(53.203425e06/(312.5*3405)) - }; + // according to ryphecha, using + // clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console + // lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced + // 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: 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: 1 --- 50.000282(53.203425e06/(312.5*3405)) + }; public double this[string systemId, bool pal] { diff --git a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs index ce08de1f90..8edd630a79 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2MnemonicConstants.cs @@ -282,7 +282,7 @@ namespace BizHawk.Client.Common ["Cursor Left/Right"] = 'l', ["Space"] = '_' }, - ["ZXSpectrum"] = new Dictionary + ["ZXSpectrum"] = new Dictionary { ["Caps Shift"] = '^', ["Caps Lock"] = 'L', @@ -311,13 +311,13 @@ namespace BizHawk.Client.Common ["Insert Previous Disk"] = '{', ["Get Disk Status"] = 's', ["Return"] = 'e', - ["Space"] = '-', - ["Up Cursor"] = 'u', - ["Down Cursor"] = 'd', - ["Left Cursor"] = 'l', - ["Right Cursor"] = 'r' - }, - ["N64"] = new Dictionary + ["Space"] = '-', + ["Up Cursor"] = 'u', + ["Down Cursor"] = 'd', + ["Left Cursor"] = 'l', + ["Right Cursor"] = 'r' + }, + ["N64"] = new Dictionary { ["C Up"] = 'u', ["C Down"] = 'd', diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index ee482e958f..c7df946d72 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -47,7 +47,7 @@ namespace BizHawk.Client.Common 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) { // TODO: how to call the default constructor AND the base(path) constructor? And is base(path) calling base() ? diff --git a/BizHawk.Client.Common/movie/tasproj/TasSession.cs b/BizHawk.Client.Common/movie/tasproj/TasSession.cs index 4e1bc173ae..355454e635 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasSession.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasSession.cs @@ -23,9 +23,9 @@ namespace BizHawk.Client.Common } public override string ToString() - { - UpdateValues(); - + { + UpdateValues(); + var sb = new StringBuilder(); sb.AppendLine(CurrentFrame.ToString()); sb.AppendLine(CurrentBranch.ToString()); diff --git a/BizHawk.Client.Common/tools/RamSearchEngine.cs b/BizHawk.Client.Common/tools/RamSearchEngine.cs index c65d589143..92baf4a619 100644 --- a/BizHawk.Client.Common/tools/RamSearchEngine.cs +++ b/BizHawk.Client.Common/tools/RamSearchEngine.cs @@ -237,11 +237,11 @@ namespace BizHawk.Client.Common 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 { diff --git a/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs b/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs index c0b5cf4d0b..77b8c8111e 100644 --- a/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs @@ -53,10 +53,10 @@ namespace BizHawk.Client.Common /// public override int Previous => 0; - /// - /// Ignore that stuff - /// - public override string ValueString => Notes; //""; + /// + /// Ignore that stuff + /// + public override string ValueString => Notes; //""; /// /// Ignore that stuff diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs index 2bf55c06c8..6e6ea8af05 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs @@ -26,13 +26,13 @@ namespace BizHawk.Client.Common } return false; - } - + } + if (ReferenceEquals(y, null)) { return false; - } - + } + if (ReferenceEquals(x, y)) { return true; diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs index 6f16a229b1..76f16d9f17 100644 --- a/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs @@ -64,10 +64,10 @@ namespace BizHawk.Client.EmuHawk { DrawFinish(); _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true); - } + } catch (InvalidOperationException ex) { - Console.WriteLine(ex.ToString()); + Console.WriteLine(ex.ToString()); } } @@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk } _GUISurface = null; - } + } #endregion #region Helpers @@ -149,13 +149,13 @@ namespace BizHawk.Client.EmuHawk GlobalWin.OSD.AddMessage(message); } - public void ClearGraphics() + public void ClearGraphics() { _GUISurface.Clear(); DrawFinish(); } - public void ClearText() + public void ClearText() { 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) - { - using (var g = GetGraphics()) - { - try - { - var index = 0; - if (string.IsNullOrEmpty(fontfamily)) - { - index = _defaultPixelFont; - } - else - { - switch (fontfamily) - { - case "fceux": - case "0": - index = 0; - break; - case "gens": - case "1": - index = 1; - break; - default: - Console.WriteLine($"Unable to find font family: {fontfamily}"); - return; - } - } + { + using (var g = GetGraphics()) + { + try + { + var index = 0; + if (string.IsNullOrEmpty(fontfamily)) + { + index = _defaultPixelFont; + } + else + { + switch (fontfamily) + { + case "fceux": + case "0": + index = 0; + break; + case "gens": + case "1": + index = 1; + break; + default: + Console.WriteLine($"Unable to find font family: {fontfamily}"); + return; + } + } - var f = new StringFormat(StringFormat.GenericTypographic) - { - FormatFlags = StringFormatFlags.MeasureTrailingSpaces - }; - var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel); - Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); - var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0)); - if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect); - g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); - } - catch (Exception) - { - return; - } - } - } + var f = new StringFormat(StringFormat.GenericTypographic) + { + FormatFlags = StringFormatFlags.MeasureTrailingSpaces + }; + var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel); + Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); + var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0)); + if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect); + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); + } + catch (Exception) + { + 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; diff --git a/BizHawk.Client.EmuHawk/ArgParser.cs b/BizHawk.Client.EmuHawk/ArgParser.cs index 6d053c97aa..42df6369ae 100644 --- a/BizHawk.Client.EmuHawk/ArgParser.cs +++ b/BizHawk.Client.EmuHawk/ArgParser.cs @@ -6,11 +6,11 @@ using System.Windows.Forms; namespace BizHawk.Client.EmuHawk { - class ArgParser - //parses command line arguments and adds the values to a class attribute - //default values are null for strings and false for boolean - //the last value will overwrite previously set values - //unrecognized parameters are simply ignored or in the worst case assumed to be a ROM name [cmdRom] + class ArgParser + //parses command line arguments and adds the values to a class attribute + //default values are null for strings and false for boolean + //the last value will overwrite previously set values + //unrecognized parameters are simply ignored or in the worst case assumed to be a ROM name [cmdRom] { public string cmdRom = null; public string cmdLoadSlot = null; @@ -22,8 +22,8 @@ namespace BizHawk.Client.EmuHawk public string cmdDumpName = null; public HashSet _currAviWriterFrameList; public int _autoDumpLength; - public bool _autoCloseOnDump = false; - // chrome is never shown, even in windowed mode + public bool _autoCloseOnDump = false; + // chrome is never shown, even in windowed mode public bool _chromeless = false; public bool startFullscreen = false; public string luaScript = null; @@ -38,12 +38,12 @@ namespace BizHawk.Client.EmuHawk public void ParseArguments(string[] args) { for (int i = 0; i < args.Length; i++) - { - // For some reason sometimes visual studio will pass this to us on the commandline. it makes no sense. + { + // For some reason sometimes visual studio will pass this to us on the commandline. it makes no sense. if (args[i] == ">") { i++; - var stdout = args[i]; + var stdout = args[i]; Console.SetOut(new StreamWriter(stdout)); continue; } @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk cmdLoadState = args[i].Substring(args[i].IndexOf('=') + 1); } if (arg.StartsWith("--config=")) - { + { cmdConfigFile = args[i].Substring(args[i].IndexOf('=') + 1); } else if (arg.StartsWith("--movie=")) @@ -78,9 +78,9 @@ namespace BizHawk.Client.EmuHawk foreach (string item in items) { _currAviWriterFrameList.Add(int.Parse(item)); - } - - // automatically set dump length to maximum frame + } + + // automatically set dump length to maximum frame _autoDumpLength = _currAviWriterFrameList.OrderBy(x => x).Last(); } else if (arg.StartsWith("--dump-name=")) @@ -132,20 +132,20 @@ namespace BizHawk.Client.EmuHawk { URL_post = args[i].Substring(args[i].IndexOf('=') + 1); } - else if (arg.StartsWith("--audiosync=")) - { - audiosync = arg.Substring(arg.IndexOf('=') + 1) == "true"; + else if (arg.StartsWith("--audiosync=")) + { + audiosync = arg.Substring(arg.IndexOf('=') + 1) == "true"; } else { cmdRom = args[i]; } - } - - //initialize HTTP communication + } + + //initialize HTTP communication if (URL_get != null || URL_post != null) { - GlobalWin.httpCommunication = new Communication.HttpCommunication(); + GlobalWin.httpCommunication = new Communication.HttpCommunication(); if (URL_get != null) { GlobalWin.httpCommunication.GetUrl = URL_get; @@ -154,20 +154,20 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.httpCommunication.PostUrl = URL_post; } - } - - //inititalize socket server + } + + //inititalize socket server if (socket_ip != null && socket_port > 0) - { + { GlobalWin.socketServer = new Communication.SocketServer(); GlobalWin.socketServer.SetIp(socket_ip, socket_port); } else if (socket_ip == null ^ socket_port == 0) { throw new ArgParserException("Socket server needs both --socket_ip and --socket_port. Socket server was not started"); - } - - //initialize mapped memory files + } + + //initialize mapped memory files if (mmf_filename != null) { GlobalWin.memoryMappedFiles = new Communication.MemoryMappedFiles(); @@ -176,19 +176,19 @@ namespace BizHawk.Client.EmuHawk } public static string GetCmdConfigFile(string[] args) - { - return args.FirstOrDefault(arg => arg.StartsWith("--config=", StringComparison.InvariantCultureIgnoreCase))?.Substring(9); + { + return args.FirstOrDefault(arg => arg.StartsWith("--config=", StringComparison.InvariantCultureIgnoreCase))?.Substring(9); + } + } + + class ArgParserException : Exception + { + public ArgParserException() + { + } + + public ArgParserException(string message) : base(message) + { } - } - - class ArgParserException : Exception - { - public ArgParserException() - { - } - - public ArgParserException(string message) : base(message) - { - } } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs index 103f3fd916..599f96ace6 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs @@ -1,6 +1,6 @@ using System; using System.Drawing; - + namespace BizHawk.Client.EmuHawk.CustomControls { public class GdiPlusRenderer : IControlRenderer @@ -50,18 +50,18 @@ namespace BizHawk.Client.EmuHawk.CustomControls } public void DrawString(string str, Point point) - { - if (_rotateString) - { - _graphics.TranslateTransform(point.X, point.Y); - _graphics.RotateTransform(90); - _graphics.DrawString(str, _currentFont, _currentStringBrush, Point.Empty); - _graphics.ResetTransform(); - } - else - { - _graphics.DrawString(str, _currentFont, _currentStringBrush, point); - } + { + if (_rotateString) + { + _graphics.TranslateTransform(point.X, point.Y); + _graphics.RotateTransform(90); + _graphics.DrawString(str, _currentFont, _currentStringBrush, Point.Empty); + _graphics.ResetTransform(); + } + else + { + _graphics.DrawString(str, _currentFont, _currentStringBrush, point); + } } public void FillRectangle(int x, int y, int w, int h) diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs index db18513b43..5fe9548407 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; @@ -8,7 +8,7 @@ using BizHawk.Client.EmuHawk.WinFormExtensions; namespace BizHawk.Client.EmuHawk { public partial class InputRoll - { + { protected override void OnPaint(PaintEventArgs e) { using (_renderer.LockGraphics(e.Graphics, Width, Height)) @@ -73,33 +73,33 @@ namespace BizHawk.Client.EmuHawk _horizontalColumnHeights = null; _horizontalColumnTops = null; return; - } - - _horizontalColumnHeights = new int[visibleColumns.Count]; - _horizontalColumnTops = new int[visibleColumns.Count]; - - int top = 0; - int startRow = FirstVisibleRow; - for (int j = 0; j < visibleColumns.Count; j++) - { - RollColumn col = visibleColumns[j]; - int height = CellHeight; - if (col.Rotatable && col.RotatedHeight != null) - { - height = Math.Max(height, col.RotatedHeight.Value); - } - else if (col.Rotatable) - { - string text; - int strOffsetX = 0; - int strOffsetY = 0; - QueryItemText(startRow, col, out text, ref strOffsetX, ref strOffsetY); - int textWidth = _renderer.MeasureString(text, _font).Width; - height = Math.Max(height, textWidth + (CellWidthPadding * 2)); - } - _horizontalColumnHeights[j] = height; - _horizontalColumnTops[j] = top; - top += height; + } + + _horizontalColumnHeights = new int[visibleColumns.Count]; + _horizontalColumnTops = new int[visibleColumns.Count]; + + int top = 0; + int startRow = FirstVisibleRow; + for (int j = 0; j < visibleColumns.Count; j++) + { + RollColumn col = visibleColumns[j]; + int height = CellHeight; + if (col.Rotatable && col.RotatedHeight != null) + { + height = Math.Max(height, col.RotatedHeight.Value); + } + else if (col.Rotatable) + { + string text; + int strOffsetX = 0; + int strOffsetY = 0; + QueryItemText(startRow, col, out text, ref strOffsetX, ref strOffsetY); + int textWidth = _renderer.MeasureString(text, _font).Width; + height = Math.Max(height, textWidth + (CellWidthPadding * 2)); + } + _horizontalColumnHeights[j] = height; + _horizontalColumnTops[j] = top; + top += height; } } @@ -228,15 +228,15 @@ namespace BizHawk.Client.EmuHawk if (HorizontalOrientation) { int startRow = FirstVisibleRow; - int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1; - - _renderer.PrepDrawString(_font, _foreColor); - int lastVisible = LastVisibleColumnIndex; - for (int j = FirstVisibleColumn; j <= lastVisible; j++) - { - RollColumn col = visibleColumns[j]; - int colHeight = GetHColHeight(j); - + int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1; + + _renderer.PrepDrawString(_font, _foreColor); + int lastVisible = LastVisibleColumnIndex; + for (int j = FirstVisibleColumn; j <= lastVisible; j++) + { + RollColumn col = visibleColumns[j]; + int colHeight = GetHColHeight(j); + for (int i = 0, f = 0; f < range; i++, f++) { f += _lagFrames[i]; @@ -268,7 +268,7 @@ namespace BizHawk.Client.EmuHawk int textWidth = _renderer.MeasureString(text, _font).Width; if (col.Rotatable) { - // Center Text + // Center Text int textX = Math.Max(((colHeight - textWidth) / 2), CellWidthPadding) + strOffsetX; int textY = CellWidthPadding + strOffsetY; var point = new Point(baseX - textY, baseY + textX); @@ -278,10 +278,10 @@ namespace BizHawk.Client.EmuHawk _renderer.PrepDrawString(_font, _foreColor, rotate: false); } else - { - // Center Text - int textX = Math.Max(((CellWidth - textWidth) / 2), CellWidthPadding) + strOffsetX; - int textY = CellHeightPadding + strOffsetY; + { + // Center Text + int textX = Math.Max(((CellWidth - textWidth) / 2), CellWidthPadding) + strOffsetX; + int textY = CellHeightPadding + strOffsetY; var point = new Point(baseX + textX, baseY + textY); DrawString(text, ColumnWidth, point); diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index 0c2341f1f6..d0a830b087 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -35,9 +35,9 @@ namespace BizHawk.Client.EmuHawk private int _maxCharactersInHorizontal = 1; private int _rowCount; - private Size _charSize; - - // Updated on paint + private Size _charSize; + + // Updated on paint private int[] _horizontalColumnHeights; private int[] _horizontalColumnTops; @@ -94,11 +94,11 @@ namespace BizHawk.Client.EmuHawk using (var g = CreateGraphics()) using (_renderer.LockGraphics(g, Width, Height)) - { - // Measure width change to ignore extra padding at start/end - var size1 = _renderer.MeasureString("A", _font); - var size2 = _renderer.MeasureString("AA", _font); - _charSize = new Size(size2.Width - size1.Width, size1.Height); // TODO make this a property so changing it updates other values. + { + // Measure width change to ignore extra padding at start/end + var size1 = _renderer.MeasureString("A", _font); + var size2 = _renderer.MeasureString("AA", _font); + _charSize = new Size(size2.Width - size1.Width, size1.Height); // TODO make this a property so changing it updates other values. } UpdateCellSize(); @@ -1631,7 +1631,7 @@ namespace BizHawk.Client.EmuHawk { UpdateDrawSize(); - var columns = _columns.VisibleColumns.ToList(); + var columns = _columns.VisibleColumns.ToList(); int iLastColumn = columns.Count - 1; if (HorizontalOrientation) @@ -1896,13 +1896,13 @@ namespace BizHawk.Client.EmuHawk } } else - { - foreach (RollColumn column in _columns.VisibleColumns) - { - if (column.Left.Value - _hBar.Value <= pixel && column.Right.Value - _hBar.Value >= pixel) - { - return column; - } + { + foreach (RollColumn column in _columns.VisibleColumns) + { + if (column.Left.Value - _hBar.Value <= pixel && column.Right.Value - _hBar.Value >= pixel) + { + return column; + } } } return null; @@ -1940,13 +1940,13 @@ namespace BizHawk.Client.EmuHawk private int GetHColHeight(int index) => _horizontalColumnHeights != null && index < _horizontalColumnHeights.Length ? _horizontalColumnHeights[index] : CellHeight; - private int GetHColTop(int index) => - _horizontalColumnTops != null && index < _horizontalColumnTops.Length ? _horizontalColumnTops[index] : (index * CellHeight); - - private int GetHColBottom(int index) => - GetHColTop(index) + GetHColHeight(index); - - // The width of the largest column cell in Horizontal Orientation + private int GetHColTop(int index) => + _horizontalColumnTops != null && index < _horizontalColumnTops.Length ? _horizontalColumnTops[index] : (index * CellHeight); + + private int GetHColBottom(int index) => + GetHColTop(index) + GetHColHeight(index); + + // The width of the largest column cell in Horizontal Orientation private int ColumnWidth { get; set; } // The height of a column cell in Vertical Orientation. diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs index 0999e9ebe6..dd0710e525 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace BizHawk.Client.EmuHawk { public class RollColumn @@ -18,13 +18,13 @@ namespace BizHawk.Client.EmuHawk /// public bool Emphasis { get; set; } - /// - /// Column header text will be drawn rotated, if true + /// + /// Column header text will be drawn rotated, if true /// public bool Rotatable { get; set; } - /// - /// If drawn rotated, specifies the desired height, or null to auto-size + /// + /// If drawn rotated, specifies the desired height, or null to auto-size /// public int? RotatedHeight { get; set; } } diff --git a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs index f68d411837..3ab5a03b47 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs +++ b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs @@ -7,7 +7,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; - + using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores; using BizHawk.Emulation.Cores.Libretro; @@ -129,13 +129,13 @@ namespace BizHawk.Client.EmuHawk Result = AdvancedRomLoaderType.LibretroLaunchGame; DialogResult = DialogResult.OK; Close(); - } - - private void btnMAMELaunchGame_Click(object sender, EventArgs e) - { + } + + private void btnMAMELaunchGame_Click(object sender, EventArgs e) + { Result = AdvancedRomLoaderType.MAMELaunchGame; DialogResult = DialogResult.OK; - Close(); + Close(); } private void btnClassicLaunchGame_Click(object sender, EventArgs e) @@ -172,6 +172,6 @@ namespace BizHawk.Client.EmuHawk var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); Global.Config.LibretroCore = filePaths[0]; RefreshLibretroCore(false); - } + } } } diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs index 1cd8a83fec..0b1679cd0f 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs @@ -21,47 +21,47 @@ namespace BizHawk.Client.EmuHawk { _settings = ((AmstradCPC)Global.Emulator).GetSettings().Clone(); - // AY panning config - var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); + // AY panning config + var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); foreach (var val in panTypes) { panTypecomboBox1.Items.Add(val); - } - panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString(); + } + panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString(); - // tape volume - tapeVolumetrackBar.Value = _settings.TapeVolume; + // tape volume + tapeVolumetrackBar.Value = _settings.TapeVolume; - // ay volume - ayVolumetrackBar.Value = _settings.AYVolume; + // ay volume + ayVolumetrackBar.Value = _settings.AYVolume; - - } + + } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = - _settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString() - || _settings.TapeVolume != tapeVolumetrackBar.Value - || _settings.AYVolume != ayVolumetrackBar.Value; + bool changed = + _settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString() + || _settings.TapeVolume != tapeVolumetrackBar.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.AYVolume = ayVolumetrackBar.Value; + _settings.TapeVolume = tapeVolumetrackBar.Value; + _settings.AYVolume = ayVolumetrackBar.Value; - GlobalWin.MainForm.PutCoreSettings(_settings); + GlobalWin.MainForm.PutCoreSettings(_settings); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.OK; + Close(); } - else - { - DialogResult = DialogResult.OK; - Close(); - } } private void CancelBtn_Click(object sender, EventArgs e) @@ -70,5 +70,5 @@ namespace BizHawk.Client.EmuHawk DialogResult = DialogResult.Cancel; Close(); } - } + } } diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs index 9d6c7405c7..fbb876166a 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs @@ -22,56 +22,56 @@ namespace BizHawk.Client.EmuHawk { _syncSettings = ((AmstradCPC)Global.Emulator).GetSyncSettings().Clone(); - // machine selection - var machineTypes = Enum.GetNames(typeof(MachineType)); + // machine selection + var machineTypes = Enum.GetNames(typeof(MachineType)); foreach (var val in machineTypes) { MachineSelectionComboBox.Items.Add(val); - } - MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); - UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); + } + MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); + UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); - // border selecton - var borderTypes = Enum.GetNames(typeof(AmstradCPC.BorderType)); - foreach (var val in borderTypes) - { - borderTypecomboBox1.Items.Add(val); - } - borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString(); - UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString())); + // border selecton + var borderTypes = Enum.GetNames(typeof(AmstradCPC.BorderType)); + foreach (var val in borderTypes) + { + borderTypecomboBox1.Items.Add(val); + } + borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString(); + UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString())); - // deterministic emulation - determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation; + // deterministic emulation + determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation; - // autoload tape - autoLoadcheckBox1.Checked = _syncSettings.AutoStartStopTape; - } + // autoload tape + autoLoadcheckBox1.Checked = _syncSettings.AutoStartStopTape; + } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = - _syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString() - || _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString() - || _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked - || _syncSettings.AutoStartStopTape != autoLoadcheckBox1.Checked; + bool changed = + _syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString() + || _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString() + || _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked + || _syncSettings.AutoStartStopTape != autoLoadcheckBox1.Checked; - if (changed) + if (changed) { - _syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()); - _syncSettings.BorderType = (AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString()); - _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; - _syncSettings.AutoStartStopTape = autoLoadcheckBox1.Checked; + _syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()); + _syncSettings.BorderType = (AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), borderTypecomboBox1.SelectedItem.ToString()); + _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; + _syncSettings.AutoStartStopTape = autoLoadcheckBox1.Checked; - GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); + GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.OK; + Close(); } - else - { - DialogResult = DialogResult.OK; - Close(); - } } private void CancelBtn_Click(object sender, EventArgs e) @@ -81,38 +81,38 @@ namespace BizHawk.Client.EmuHawk Close(); } - private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - ComboBox cb = sender as ComboBox; - UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); - } + private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); + } - private void UpdateMachineNotes(MachineType type) - { - textBoxMachineNotes.Text = CPCMachineMetaData.GetMetaString(type); - } + private void UpdateMachineNotes(MachineType type) + { + textBoxMachineNotes.Text = CPCMachineMetaData.GetMetaString(type); + } - private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) - { - ComboBox cb = sender as ComboBox; - UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), cb.SelectedItem.ToString())); - } + private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + UpdateBorderNotes((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), cb.SelectedItem.ToString())); + } - private void UpdateBorderNotes(AmstradCPC.BorderType type) - { - switch (type) - { - case AmstradCPC.BorderType.Uniform: - lblBorderInfo.Text = "Attempts to equalise the border areas"; - break; - case AmstradCPC.BorderType.Uncropped: - lblBorderInfo.Text = "Pretty much the signal the gate array is generating (looks pants)"; - break; + private void UpdateBorderNotes(AmstradCPC.BorderType type) + { + switch (type) + { + case AmstradCPC.BorderType.Uniform: + lblBorderInfo.Text = "Attempts to equalise the border areas"; + break; + case AmstradCPC.BorderType.Uncropped: + lblBorderInfo.Text = "Pretty much the signal the gate array is generating (looks pants)"; + break; - case AmstradCPC.BorderType.Widescreen: - lblBorderInfo.Text = "Top and bottom border removed so that the result is *almost* 16:9"; - break; - } - } - } + case AmstradCPC.BorderType.Widescreen: + lblBorderInfo.Text = "Top and bottom border removed so that the result is *almost* 16:9"; + break; + } + } + } } diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs index 63dc150f70..4614d6e334 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs @@ -21,37 +21,37 @@ namespace BizHawk.Client.EmuHawk { _settings = ((AmstradCPC)Global.Emulator).GetSettings().Clone(); - + - // OSD Message Verbosity - var osdTypes = Enum.GetNames(typeof(AmstradCPC.OSDVerbosity)); - foreach (var val in osdTypes) - { - osdMessageVerbositycomboBox1.Items.Add(val); - } - osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString(); - UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString())); - } + // OSD Message Verbosity + var osdTypes = Enum.GetNames(typeof(AmstradCPC.OSDVerbosity)); + foreach (var val in osdTypes) + { + osdMessageVerbositycomboBox1.Items.Add(val); + } + osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString(); + UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString())); + } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = - _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString(); + bool changed = + _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; - Close(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.OK; + Close(); } - else - { - DialogResult = DialogResult.OK; - Close(); - } } private void CancelBtn_Click(object sender, EventArgs e) @@ -61,26 +61,26 @@ namespace BizHawk.Client.EmuHawk Close(); } - private void UpdateOSDNotes(AmstradCPC.OSDVerbosity type) - { - switch (type) - { - case AmstradCPC.OSDVerbosity.Full: - lblOSDVerbinfo.Text = "Show all OSD messages"; - break; - case AmstradCPC.OSDVerbosity.Medium: - lblOSDVerbinfo.Text = "Only show machine/device generated messages"; - break; - case AmstradCPC.OSDVerbosity.None: - lblOSDVerbinfo.Text = "No core-driven OSD messages"; - break; - } - } + private void UpdateOSDNotes(AmstradCPC.OSDVerbosity type) + { + switch (type) + { + case AmstradCPC.OSDVerbosity.Full: + lblOSDVerbinfo.Text = "Show all OSD messages"; + break; + case AmstradCPC.OSDVerbosity.Medium: + lblOSDVerbinfo.Text = "Only show machine/device generated messages"; + break; + case AmstradCPC.OSDVerbosity.None: + lblOSDVerbinfo.Text = "No core-driven OSD messages"; + break; + } + } - private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - ComboBox cb = sender as ComboBox; - UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), cb.SelectedItem.ToString())); - } - } + private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), cb.SelectedItem.ToString())); + } + } } diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs index 8175e472ad..f17efc62d6 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs @@ -17,14 +17,14 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { - var ams = (AmstradCPC)Global.Emulator; - var addr = (ushort)numericUpDownAddress.Value; - var val = (byte)numericUpDownByte.Value; + var ams = (AmstradCPC)Global.Emulator; + var addr = (ushort)numericUpDownAddress.Value; + var val = (byte)numericUpDownByte.Value; - ams.PokeMemory(addr, val); + ams.PokeMemory(addr, val); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); } private void CancelBtn_Click(object sender, EventArgs e) @@ -33,5 +33,5 @@ namespace BizHawk.Client.EmuHawk DialogResult = DialogResult.Cancel; Close(); } - } + } } diff --git a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs index 01408593e5..b908423953 100644 --- a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs @@ -181,26 +181,26 @@ namespace BizHawk.Client.EmuHawk tt.TabPages.Add(tabname); tt.TabPages[pageidx].Controls.Add(createpanel(settings, cat.Value, tt.Size)); - // zxhawk hack - it uses multiple categoryLabels - if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") - pageidx++; + // zxhawk hack - it uses multiple categoryLabels + if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") + pageidx++; - } + } if (buckets[0].Count > 0) { - // ZXHawk needs to skip this bit - if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") - return; + // ZXHawk needs to skip this bit + if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") + return; - string tabname = + string tabname = (Global.Emulator.SystemId == "C64") ? "Keyboard" : (Global.Emulator.SystemId == "MAME") ? "Misc" : "Console"; // hack - tt.TabPages.Add(tabname); - tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size)); - } - } + tt.TabPages.Add(tabname); + tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size)); + } + } } public ControllerConfig(ControllerDefinition def) @@ -277,27 +277,27 @@ namespace BizHawk.Client.EmuHawk pictureBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; } - if (controlName == "ZXSpectrum Controller") - { - pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards; - pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size; - tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; - } + if (controlName == "ZXSpectrum Controller") + { + pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards; + pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size; + tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; + } if (controlName == "ChannelF Controller") { } - if (controlName == "AmstradCPC Controller") - { - /* - pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards; - pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size; - tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; - */ - } - } + if (controlName == "AmstradCPC Controller") + { + /* + pictureBox1.Image = Properties.Resources.ZXSpectrumKeyboards; + pictureBox1.Size = Properties.Resources.ZXSpectrumKeyboards.Size; + tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; + */ + } + } // lazy methods, but they're not called often and actually // tracking all of the ControllerConfigPanels wouldn't be simpler diff --git a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs index e146d1ea38..b3a9f55cae 100644 --- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs +++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs @@ -52,8 +52,8 @@ namespace BizHawk.Client.EmuHawk { "GBC", "Game Boy Color" }, { "PCFX", "PC-FX" }, { "32X", "32X" }, - { "ZXSpectrum", "ZX Spectrum" }, - { "AmstradCPC", "Amstrad CPC" }, + { "ZXSpectrum", "ZX Spectrum" }, + { "AmstradCPC", "Amstrad CPC" }, { "ChannelF", "Channel F" }, { "Vectrex", "Vectrex" } }; @@ -393,81 +393,81 @@ namespace BizHawk.Client.EmuHawk { ofd.InitialDirectory = currSelectorDir; 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 currSelectorDir = Path.GetDirectoryName(ofd.FileName); - try - { - 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) - foreach (ListViewItem lvi in lvFirmwares.SelectedItems) - { - var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; - string filePath = ofd.FileName; + try + { + 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) + foreach (ListViewItem lvi in lvFirmwares.SelectedItems) + { + var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; + string filePath = ofd.FileName; - // if the selected file is an archive, allow the user to pick the inside file - // to always be copied to the global firmwares directory - if (hf.IsArchive) - { - var ac = new ArchiveChooser(new HawkFile(filePath)); - int memIdx = -1; + // if the selected file is an archive, allow the user to pick the inside file + // to always be copied to the global firmwares directory + if (hf.IsArchive) + { + var ac = new ArchiveChooser(new HawkFile(filePath)); + int memIdx = -1; - if (ac.ShowDialog(this) == DialogResult.OK) - { - memIdx = ac.SelectedMemberIndex; - } - else - { - return; - } + if (ac.ShowDialog(this) == DialogResult.OK) + { + memIdx = ac.SelectedMemberIndex; + } + else + { + return; + } - var insideFile = hf.BindArchiveMember(memIdx); - var fileData = insideFile.ReadAllBytes(); + var insideFile = hf.BindArchiveMember(memIdx); + var fileData = insideFile.ReadAllBytes(); - // write to file in the firmwares folder - File.WriteAllBytes(Path.Combine(frmwarePath, insideFile.Name), fileData); - filePath = Path.Combine(frmwarePath, insideFile.Name); - } - else - { - // selected file is not an archive - // check whether this file is currently outside of the global firmware directory - 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); - if (askMoveResult == DialogResult.Yes) - { - try - { - FileInfo fi = new FileInfo(filePath); - filePath = Path.Combine(frmwarePath, fi.Name); - File.Copy(ofd.FileName, filePath); - } - catch (Exception ex) - { - MessageBox.Show(this, $"There was an issue copying the file. The customization has NOT been set.\n\n{ex.StackTrace}"); - continue; - } - } - } - } + // write to file in the firmwares folder + File.WriteAllBytes(Path.Combine(frmwarePath, insideFile.Name), fileData); + filePath = Path.Combine(frmwarePath, insideFile.Name); + } + else + { + // selected file is not an archive + // check whether this file is currently outside of the global firmware directory + 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); + if (askMoveResult == DialogResult.Yes) + { + try + { + FileInfo fi = new FileInfo(filePath); + filePath = Path.Combine(frmwarePath, fi.Name); + File.Copy(ofd.FileName, filePath); + } + catch (Exception ex) + { + MessageBox.Show(this, $"There was an issue copying the file. The customization has NOT been set.\n\n{ex.StackTrace}"); + continue; + } + } + } + } - Global.Config.FirmwareUserSpecifications[fr.ConfigKey] = filePath; - } - } - } - catch (Exception ex) - { - MessageBox.Show(this, $"There was an issue during the process. The customization has NOT been set.\n\n{ex.StackTrace}"); - return; - } + Global.Config.FirmwareUserSpecifications[fr.ConfigKey] = filePath; + } + } + } + catch (Exception ex) + { + MessageBox.Show(this, $"There was an issue during the process. The customization has NOT been set.\n\n{ex.StackTrace}"); + return; + } - DoScan(); + DoScan(); } } } @@ -673,10 +673,10 @@ namespace BizHawk.Client.EmuHawk File.WriteAllBytes(outfile, ms.ToArray()); hf.Unbind(); - if (cbAllowImport.Checked || Manager.CanFileBeImported(outfile)) - { - didSomething |= RunImportJobSingle(basepath, outfile, ref errors); - } + if (cbAllowImport.Checked || Manager.CanFileBeImported(outfile)) + { + didSomething |= RunImportJobSingle(basepath, outfile, ref errors); + } } } finally @@ -686,10 +686,10 @@ namespace BizHawk.Client.EmuHawk } else { - if (cbAllowImport.Checked || Manager.CanFileBeImported(hf.CanonicalFullPath)) - { - didSomething |= RunImportJobSingle(basepath, f, ref errors); - } + if (cbAllowImport.Checked || Manager.CanFileBeImported(hf.CanonicalFullPath)) + { + didSomething |= RunImportJobSingle(basepath, f, ref errors); + } } } } @@ -716,7 +716,7 @@ namespace BizHawk.Client.EmuHawk 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; } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs index 0eb6e977cc..305fcb55f9 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs @@ -21,52 +21,52 @@ namespace BizHawk.Client.EmuHawk { _settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone(); - // AY panning config - var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); + // AY panning config + var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); foreach (var val in panTypes) { panTypecomboBox1.Items.Add(val); - } - panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString(); + } + panTypecomboBox1.SelectedItem = _settings.AYPanConfig.ToString(); - // tape volume - tapeVolumetrackBar.Value = _settings.TapeVolume; + // tape volume + tapeVolumetrackBar.Value = _settings.TapeVolume; - // ear volume - earVolumetrackBar.Value = _settings.EarVolume; + // ear volume + earVolumetrackBar.Value = _settings.EarVolume; - // ay volume - ayVolumetrackBar.Value = _settings.AYVolume; + // ay volume + ayVolumetrackBar.Value = _settings.AYVolume; - - } + + } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = - _settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString() - || _settings.TapeVolume != tapeVolumetrackBar.Value - || _settings.EarVolume != earVolumetrackBar.Value - || _settings.AYVolume != ayVolumetrackBar.Value; + bool changed = + _settings.AYPanConfig.ToString() != panTypecomboBox1.SelectedItem.ToString() + || _settings.TapeVolume != tapeVolumetrackBar.Value + || _settings.EarVolume != earVolumetrackBar.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.EarVolume = earVolumetrackBar.Value; - _settings.AYVolume = ayVolumetrackBar.Value; + _settings.TapeVolume = tapeVolumetrackBar.Value; + _settings.EarVolume = earVolumetrackBar.Value; + _settings.AYVolume = ayVolumetrackBar.Value; - GlobalWin.MainForm.PutCoreSettings(_settings); + GlobalWin.MainForm.PutCoreSettings(_settings); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.OK; + Close(); } - else - { - DialogResult = DialogResult.OK; - Close(); - } } private void CancelBtn_Click(object sender, EventArgs e) @@ -75,5 +75,5 @@ namespace BizHawk.Client.EmuHawk DialogResult = DialogResult.Cancel; Close(); } - } + } } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs index 2888cf7231..20834ad90e 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs @@ -21,56 +21,56 @@ namespace BizHawk.Client.EmuHawk { _syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone(); - // machine selection - var machineTypes = Enum.GetNames(typeof(MachineType)); + // machine selection + var machineTypes = Enum.GetNames(typeof(MachineType)); foreach (var val in machineTypes) { MachineSelectionComboBox.Items.Add(val); - } - MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); - UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); + } + MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString(); + UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString())); - // border selecton - var borderTypes = Enum.GetNames(typeof(ZXSpectrum.BorderType)); - foreach (var val in borderTypes) - { - borderTypecomboBox1.Items.Add(val); - } - borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString(); - UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString())); + // border selecton + var borderTypes = Enum.GetNames(typeof(ZXSpectrum.BorderType)); + foreach (var val in borderTypes) + { + borderTypecomboBox1.Items.Add(val); + } + borderTypecomboBox1.SelectedItem = _syncSettings.BorderType.ToString(); + UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString())); - // deterministic emulation - determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation; + // deterministic emulation + determEmucheckBox1.Checked = _syncSettings.DeterministicEmulation; - // autoload tape - autoLoadcheckBox1.Checked = _syncSettings.AutoLoadTape; - } + // autoload tape + autoLoadcheckBox1.Checked = _syncSettings.AutoLoadTape; + } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = - _syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString() - || _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString() - || _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked - || _syncSettings.AutoLoadTape != autoLoadcheckBox1.Checked; + bool changed = + _syncSettings.MachineType.ToString() != MachineSelectionComboBox.SelectedItem.ToString() + || _syncSettings.BorderType.ToString() != borderTypecomboBox1.SelectedItem.ToString() + || _syncSettings.DeterministicEmulation != determEmucheckBox1.Checked + || _syncSettings.AutoLoadTape != autoLoadcheckBox1.Checked; - if (changed) + if (changed) { - _syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()); - _syncSettings.BorderType = (ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString()); - _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; - _syncSettings.AutoLoadTape = autoLoadcheckBox1.Checked; + _syncSettings.MachineType = (MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()); + _syncSettings.BorderType = (ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), borderTypecomboBox1.SelectedItem.ToString()); + _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; + _syncSettings.AutoLoadTape = autoLoadcheckBox1.Checked; - GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); + GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.OK; + Close(); } - else - { - DialogResult = DialogResult.OK; - Close(); - } } private void CancelBtn_Click(object sender, EventArgs e) @@ -80,43 +80,43 @@ namespace BizHawk.Client.EmuHawk Close(); } - private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - ComboBox cb = sender as ComboBox; - UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); - } + private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString())); + } - private void UpdateMachineNotes(MachineType type) - { - textBoxCoreDetails.Text = ZXMachineMetaData.GetMetaString(type); - } + private void UpdateMachineNotes(MachineType type) + { + textBoxCoreDetails.Text = ZXMachineMetaData.GetMetaString(type); + } - private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) - { - ComboBox cb = sender as ComboBox; - UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), cb.SelectedItem.ToString())); - } + private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), cb.SelectedItem.ToString())); + } - private void UpdateBorderNotes(ZXSpectrum.BorderType type) - { - switch (type) - { - case ZXSpectrum.BorderType.Full: - lblBorderInfo.Text = "Original border sizes"; - break; - case ZXSpectrum.BorderType.Medium: - lblBorderInfo.Text = "All borders 24px"; - break; - case ZXSpectrum.BorderType.None: - lblBorderInfo.Text = "No border at all"; - break; - case ZXSpectrum.BorderType.Small: - lblBorderInfo.Text = "All borders 10px"; - break; - case ZXSpectrum.BorderType.Widescreen: - lblBorderInfo.Text = "No top and bottom border (almost 16:9)"; - break; - } - } - } + private void UpdateBorderNotes(ZXSpectrum.BorderType type) + { + switch (type) + { + case ZXSpectrum.BorderType.Full: + lblBorderInfo.Text = "Original border sizes"; + break; + case ZXSpectrum.BorderType.Medium: + lblBorderInfo.Text = "All borders 24px"; + break; + case ZXSpectrum.BorderType.None: + lblBorderInfo.Text = "No border at all"; + break; + case ZXSpectrum.BorderType.Small: + lblBorderInfo.Text = "All borders 10px"; + break; + case ZXSpectrum.BorderType.Widescreen: + lblBorderInfo.Text = "No top and bottom border (almost 16:9)"; + break; + } + } + } } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs index fc151c843c..f672d8a563 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs @@ -16,105 +16,105 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } - private string[] possibleControllers; + private string[] possibleControllers; private void IntvControllerSettings_Load(object sender, EventArgs e) { _syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone(); - possibleControllers = Enum.GetNames(typeof(JoystickType)); + possibleControllers = Enum.GetNames(typeof(JoystickType)); foreach (var val in possibleControllers) { Port1ComboBox.Items.Add(val); Port2ComboBox.Items.Add(val); - Port3ComboBox.Items.Add(val); - } + Port3ComboBox.Items.Add(val); + } Port1ComboBox.SelectedItem = _syncSettings.JoystickType1.ToString(); Port2ComboBox.SelectedItem = _syncSettings.JoystickType2.ToString(); - Port3ComboBox.SelectedItem = _syncSettings.JoystickType3.ToString(); - } + Port3ComboBox.SelectedItem = _syncSettings.JoystickType3.ToString(); + } private void OkBtn_Click(object sender, EventArgs e) { bool changed = _syncSettings.JoystickType1.ToString() != Port1ComboBox.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(); - if (j1 != possibleControllers.First()) - { - if (j1 == Port2ComboBox.SelectedItem.ToString()) - { - Port2ComboBox.SelectedItem = possibleControllers.First(); - selectionValid = false; - } - if (j1 == Port3ComboBox.SelectedItem.ToString()) - { - Port3ComboBox.SelectedItem = possibleControllers.First(); - selectionValid = false; - } - } + var j1 = Port1ComboBox.SelectedItem.ToString(); + if (j1 != possibleControllers.First()) + { + if (j1 == Port2ComboBox.SelectedItem.ToString()) + { + Port2ComboBox.SelectedItem = possibleControllers.First(); + selectionValid = false; + } + if (j1 == Port3ComboBox.SelectedItem.ToString()) + { + Port3ComboBox.SelectedItem = possibleControllers.First(); + selectionValid = false; + } + } - var j2 = Port2ComboBox.SelectedItem.ToString(); - if (j2 != possibleControllers.First()) - { - if (j2 == Port1ComboBox.SelectedItem.ToString()) - { - Port1ComboBox.SelectedItem = possibleControllers.First(); - selectionValid = false; - } - if (j2 == Port3ComboBox.SelectedItem.ToString()) - { - Port3ComboBox.SelectedItem = possibleControllers.First(); - selectionValid = false; - } - } + var j2 = Port2ComboBox.SelectedItem.ToString(); + if (j2 != possibleControllers.First()) + { + if (j2 == Port1ComboBox.SelectedItem.ToString()) + { + Port1ComboBox.SelectedItem = possibleControllers.First(); + selectionValid = false; + } + if (j2 == Port3ComboBox.SelectedItem.ToString()) + { + Port3ComboBox.SelectedItem = possibleControllers.First(); + selectionValid = false; + } + } - var j3 = Port3ComboBox.SelectedItem.ToString(); - if (j3 != possibleControllers.First()) - { - if (j3 == Port1ComboBox.SelectedItem.ToString()) - { - Port1ComboBox.SelectedItem = possibleControllers.First(); - selectionValid = false; - } - if (j3 == Port2ComboBox.SelectedItem.ToString()) - { - Port2ComboBox.SelectedItem = possibleControllers.First(); - selectionValid = false; - } - } + var j3 = Port3ComboBox.SelectedItem.ToString(); + if (j3 != possibleControllers.First()) + { + if (j3 == Port1ComboBox.SelectedItem.ToString()) + { + Port1ComboBox.SelectedItem = possibleControllers.First(); + selectionValid = false; + } + if (j3 == Port2ComboBox.SelectedItem.ToString()) + { + Port2ComboBox.SelectedItem = possibleControllers.First(); + selectionValid = false; + } + } - if (selectionValid) - { - _syncSettings.JoystickType1 = (JoystickType)Enum.Parse(typeof(JoystickType), Port1ComboBox.SelectedItem.ToString()); - _syncSettings.JoystickType2 = (JoystickType)Enum.Parse(typeof(JoystickType), Port2ComboBox.SelectedItem.ToString()); - _syncSettings.JoystickType3 = (JoystickType)Enum.Parse(typeof(JoystickType), Port3ComboBox.SelectedItem.ToString()); + if (selectionValid) + { + _syncSettings.JoystickType1 = (JoystickType)Enum.Parse(typeof(JoystickType), Port1ComboBox.SelectedItem.ToString()); + _syncSettings.JoystickType2 = (JoystickType)Enum.Parse(typeof(JoystickType), Port2ComboBox.SelectedItem.ToString()); + _syncSettings.JoystickType3 = (JoystickType)Enum.Parse(typeof(JoystickType), Port3ComboBox.SelectedItem.ToString()); - GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); + GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); - DialogResult = DialogResult.OK; - Close(); - } - else - { - MessageBox.Show("Invalid joystick configuration. \nDuplicates have automatically been changed to NULL.\n\nPlease review the configuration"); - } + DialogResult = DialogResult.OK; + Close(); + } + else + { + 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) diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs index d7da354c59..005f54363d 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs @@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk public partial class ZXSpectrumNonSyncSettings : Form { private ZXSpectrum.ZXSpectrumSettings _settings; - private int bgColor; + private int bgColor; public ZXSpectrumNonSyncSettings() { @@ -22,52 +22,52 @@ namespace BizHawk.Client.EmuHawk { _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 - var osdTypes = Enum.GetNames(typeof(ZXSpectrum.OSDVerbosity)); - foreach (var val in osdTypes) - { - osdMessageVerbositycomboBox1.Items.Add(val); - } - osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString(); - UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString())); - } + // OSD Message Verbosity + var osdTypes = Enum.GetNames(typeof(ZXSpectrum.OSDVerbosity)); + foreach (var val in osdTypes) + { + osdMessageVerbositycomboBox1.Items.Add(val); + } + osdMessageVerbositycomboBox1.SelectedItem = _settings.OSDMessageVerbosity.ToString(); + UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString())); + } - private void SetBtnColor() - { - var c = System.Drawing.Color.FromArgb(bgColor); - buttonChooseBGColor.ForeColor = c; - buttonChooseBGColor.BackColor = c; - } + private void SetBtnColor() + { + var c = System.Drawing.Color.FromArgb(bgColor); + buttonChooseBGColor.ForeColor = c; + buttonChooseBGColor.BackColor = c; + } private void OkBtn_Click(object sender, EventArgs e) { - bool changed = - _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() || - _settings.BackgroundColor != bgColor || - _settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked; + bool changed = + _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() || + _settings.BackgroundColor != bgColor || + _settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked; - if (changed) + if (changed) { - _settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()); - _settings.BackgroundColor = bgColor; - _settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked; + _settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()); + _settings.BackgroundColor = bgColor; + _settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked; - GlobalWin.MainForm.PutCoreSettings(_settings); + GlobalWin.MainForm.PutCoreSettings(_settings); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + DialogResult = DialogResult.OK; + Close(); } - else - { - DialogResult = DialogResult.OK; - Close(); - } } private void CancelBtn_Click(object sender, EventArgs e) @@ -77,84 +77,84 @@ namespace BizHawk.Client.EmuHawk Close(); } - private void UpdateOSDNotes(ZXSpectrum.OSDVerbosity type) - { - switch (type) - { - case ZXSpectrum.OSDVerbosity.Full: - lblOSDVerbinfo.Text = "Show all OSD messages"; - break; - case ZXSpectrum.OSDVerbosity.Medium: - lblOSDVerbinfo.Text = "Only show machine/device generated messages"; - break; - case ZXSpectrum.OSDVerbosity.None: - lblOSDVerbinfo.Text = "No core-driven OSD messages"; - break; - } - } + private void UpdateOSDNotes(ZXSpectrum.OSDVerbosity type) + { + switch (type) + { + case ZXSpectrum.OSDVerbosity.Full: + lblOSDVerbinfo.Text = "Show all OSD messages"; + break; + case ZXSpectrum.OSDVerbosity.Medium: + lblOSDVerbinfo.Text = "Only show machine/device generated messages"; + break; + case ZXSpectrum.OSDVerbosity.None: + lblOSDVerbinfo.Text = "No core-driven OSD messages"; + break; + } + } - private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - ComboBox cb = sender as ComboBox; - UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString())); - } + private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString())); + } - private void buttonChooseBGColor_Click(object sender, EventArgs e) - { - var currColor = _settings.BackgroundColor; - System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor); - using var cd = new ColorDialog(); + private void buttonChooseBGColor_Click(object sender, EventArgs e) + { + var currColor = _settings.BackgroundColor; + System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor); + using var cd = new ColorDialog(); - System.Drawing.Color[] colors = new System.Drawing.Color[] - { - System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), - System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7), - System.Drawing.Color.FromArgb(0xD7, 0x00, 0xD7), - System.Drawing.Color.FromArgb(0x00, 0xD7, 0x00), - System.Drawing.Color.FromArgb(0x00, 0xD7, 0xD7), - System.Drawing.Color.FromArgb(0xD7, 0xD7, 0x00), - System.Drawing.Color.FromArgb(0xD7, 0xD7, 0xD7), - System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF), - System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), - System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF), - System.Drawing.Color.FromArgb(0xFF, 0x00, 0x00), - System.Drawing.Color.FromArgb(0xFF, 0x00, 0xFF), - System.Drawing.Color.FromArgb(0x00, 0xFF, 0x00), - System.Drawing.Color.FromArgb(0x00, 0xFF, 0xFF), - System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00), - System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF), - }; + System.Drawing.Color[] colors = new System.Drawing.Color[] + { + System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), + System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7), + System.Drawing.Color.FromArgb(0xD7, 0x00, 0xD7), + System.Drawing.Color.FromArgb(0x00, 0xD7, 0x00), + System.Drawing.Color.FromArgb(0x00, 0xD7, 0xD7), + System.Drawing.Color.FromArgb(0xD7, 0xD7, 0x00), + System.Drawing.Color.FromArgb(0xD7, 0xD7, 0xD7), + System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF), + System.Drawing.Color.FromArgb(0x00, 0x00, 0x00), + System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF), + System.Drawing.Color.FromArgb(0xFF, 0x00, 0x00), + System.Drawing.Color.FromArgb(0xFF, 0x00, 0xFF), + System.Drawing.Color.FromArgb(0x00, 0xFF, 0x00), + System.Drawing.Color.FromArgb(0x00, 0xFF, 0xFF), + System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00), + System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF), + }; - cd.CustomColors = new int[] - { - System.Drawing.ColorTranslator.ToOle(colors[0]), - System.Drawing.ColorTranslator.ToOle(colors[1]), - System.Drawing.ColorTranslator.ToOle(colors[2]), - System.Drawing.ColorTranslator.ToOle(colors[3]), - System.Drawing.ColorTranslator.ToOle(colors[4]), - System.Drawing.ColorTranslator.ToOle(colors[5]), - System.Drawing.ColorTranslator.ToOle(colors[6]), - System.Drawing.ColorTranslator.ToOle(colors[7]), - System.Drawing.ColorTranslator.ToOle(colors[8]), - System.Drawing.ColorTranslator.ToOle(colors[9]), - System.Drawing.ColorTranslator.ToOle(colors[10]), - System.Drawing.ColorTranslator.ToOle(colors[11]), - System.Drawing.ColorTranslator.ToOle(colors[12]), - System.Drawing.ColorTranslator.ToOle(colors[13]), - System.Drawing.ColorTranslator.ToOle(colors[14]), - System.Drawing.ColorTranslator.ToOle(colors[15]), - }; + cd.CustomColors = new int[] + { + System.Drawing.ColorTranslator.ToOle(colors[0]), + System.Drawing.ColorTranslator.ToOle(colors[1]), + System.Drawing.ColorTranslator.ToOle(colors[2]), + System.Drawing.ColorTranslator.ToOle(colors[3]), + System.Drawing.ColorTranslator.ToOle(colors[4]), + System.Drawing.ColorTranslator.ToOle(colors[5]), + System.Drawing.ColorTranslator.ToOle(colors[6]), + System.Drawing.ColorTranslator.ToOle(colors[7]), + System.Drawing.ColorTranslator.ToOle(colors[8]), + System.Drawing.ColorTranslator.ToOle(colors[9]), + System.Drawing.ColorTranslator.ToOle(colors[10]), + System.Drawing.ColorTranslator.ToOle(colors[11]), + System.Drawing.ColorTranslator.ToOle(colors[12]), + System.Drawing.ColorTranslator.ToOle(colors[13]), + System.Drawing.ColorTranslator.ToOle(colors[14]), + System.Drawing.ColorTranslator.ToOle(colors[15]), + }; - cd.Color = c; + cd.Color = c; - if (cd.ShowDialog() == DialogResult.OK) - { - var color = cd.Color; - var col = color.ToArgb(); - bgColor = col; + if (cd.ShowDialog() == DialogResult.OK) + { + var color = cd.Color; + var col = color.ToArgb(); + bgColor = col; - SetBtnColor(); - } - } - } + SetBtnColor(); + } + } + } } diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs index 9c3ec12f96..777ec61315 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs @@ -17,14 +17,14 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { - var speccy = (ZXSpectrum)Global.Emulator; - var addr = (ushort)numericUpDownAddress.Value; - var val = (byte)numericUpDownByte.Value; + var speccy = (ZXSpectrum)Global.Emulator; + var addr = (ushort)numericUpDownAddress.Value; + var val = (byte)numericUpDownByte.Value; - speccy.PokeMemory(addr, val); + speccy.PokeMemory(addr, val); - DialogResult = DialogResult.OK; - Close(); + DialogResult = DialogResult.OK; + Close(); } private void CancelBtn_Click(object sender, EventArgs e) @@ -33,5 +33,5 @@ namespace BizHawk.Client.EmuHawk DialogResult = DialogResult.Cancel; Close(); } - } + } } diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs b/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs index 9594007e9d..058971c02a 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs @@ -171,7 +171,7 @@ namespace BizHawk.Client.EmuHawk private IEnumerable SelectedIndices => BreakpointView.SelectedIndices.Cast(); - private IEnumerable SelectedItems + private IEnumerable SelectedItems { get { return SelectedIndices.Select(index => _breakpoints[index]); } } diff --git a/BizHawk.Client.EmuHawk/tools/GameShark.cs b/BizHawk.Client.EmuHawk/tools/GameShark.cs index 7cbfefe75e..99a5d28850 100644 --- a/BizHawk.Client.EmuHawk/tools/GameShark.cs +++ b/BizHawk.Client.EmuHawk/tools/GameShark.cs @@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk [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 { #region " Game Genie Dictionary " diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs index 3b39e74645..eab3a6accc 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs @@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk private void DoLuaClick(object sender, EventArgs e) { LuaWinform parent = Parent as LuaWinform; - parent?.DoLuaEvent(Handle); + parent?.DoLuaEvent(Handle); } protected override void OnClick(EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs index 17ee26082f..5f61da9993 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs @@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk private void DoLuaClick(object sender, EventArgs e) { var parent = Parent as LuaWinform; - parent?.DoLuaEvent(Handle); + parent?.DoLuaEvent(Handle); } protected override void OnClick(EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs index 3859e0d905..b15ad65787 100644 --- a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs +++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs @@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk { public partial class MultiDiskFileSelector : UserControl { - public string SystemString = ""; + public string SystemString = ""; public string GetName() { diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index 7c6535b182..905d0234b3 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -155,8 +155,8 @@ namespace BizHawk.Client.EmuHawk SyncCore(); if (Visible) { - RegenerateData(); - InternalUpdateValues(); + RegenerateData(); + InternalUpdateValues(); } } diff --git a/BizHawk.Client.EmuHawk/tools/TI83/TI83KeyPad.cs b/BizHawk.Client.EmuHawk/tools/TI83/TI83KeyPad.cs index 2d66b548cd..3a15f9d64d 100644 --- a/BizHawk.Client.EmuHawk/tools/TI83/TI83KeyPad.cs +++ b/BizHawk.Client.EmuHawk/tools/TI83/TI83KeyPad.cs @@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk public bool AskSaveChanges() { return true; } public bool UpdateBefore => false; - public void NewUpdate(ToolFormUpdateType type) { } + public void NewUpdate(ToolFormUpdateType type) { } public void UpdateValues() { diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs index fa8150558f..66ea6715e2 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs @@ -6,255 +6,255 @@ using System.Linq; namespace BizHawk.Client.EmuHawk { - [Schema("ZXSpectrum")] - class ZXSpectrumSchema : IVirtualPadSchema - { - public IEnumerable GetPadSchemas(IEmulator core) - { - yield return Joystick(1); - yield return Joystick(2); - yield return Joystick(3); - yield return Keyboard(); - //yield return TapeDevice(); - } + [Schema("ZXSpectrum")] + class ZXSpectrumSchema : IVirtualPadSchema + { + public IEnumerable GetPadSchemas(IEmulator core) + { + yield return Joystick(1); + yield return Joystick(2); + yield return Joystick(3); + yield return Keyboard(); + //yield return TapeDevice(); + } - private static PadSchema Joystick(int controller) - { - return new PadSchema - { - DisplayName = $"Joystick {controller}", - IsConsole = false, - DefaultSize = new Size(174, 74), - MaxSize = new Size(174, 74), - Buttons = new[] - { - new PadSchema.ButtonSchema - { - Name = $"P{controller} Up", - DisplayName = "", - Icon = Properties.Resources.BlueUp, - Location = new Point(23, 15), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = $"P{controller} Down", - DisplayName = "", - Icon = Properties.Resources.BlueDown, - Location = new Point(23, 36), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = $"P{controller} Left", - DisplayName = "", - Icon = Properties.Resources.Back, - Location = new Point(2, 24), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = $"P{controller} Right", - DisplayName = "", - Icon = Properties.Resources.Forward, - Location = new Point(44, 24), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = $"P{controller} Button", - DisplayName = "B", - Location = new Point(124, 24), - Type = PadSchema.PadInputType.Boolean - } - } - }; - } + private static PadSchema Joystick(int controller) + { + return new PadSchema + { + DisplayName = $"Joystick {controller}", + IsConsole = false, + DefaultSize = new Size(174, 74), + MaxSize = new Size(174, 74), + Buttons = new[] + { + new PadSchema.ButtonSchema + { + Name = $"P{controller} Up", + DisplayName = "", + Icon = Properties.Resources.BlueUp, + Location = new Point(23, 15), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Down", + DisplayName = "", + Icon = Properties.Resources.BlueDown, + Location = new Point(23, 36), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Left", + DisplayName = "", + Icon = Properties.Resources.Back, + Location = new Point(2, 24), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Right", + DisplayName = "", + Icon = Properties.Resources.Forward, + Location = new Point(44, 24), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Button", + DisplayName = "B", + Location = new Point(124, 24), + Type = PadSchema.PadInputType.Boolean + } + } + }; + } - private class ButtonLayout - { - public string Name { get; set; } - public string DisName { get; set; } - public double WidthFactor { get; set; } - public int Row { get; set; } - public bool IsActive = true; - } + private class ButtonLayout + { + public string Name { get; set; } + public string DisName { get; set; } + public double WidthFactor { get; set; } + public int Row { get; set; } + public bool IsActive = true; + } - private static PadSchema Keyboard() - { - List bls = new List - { - 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 1", DisName = "1", 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 4", DisName = "4", 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 7", DisName = "7", 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 0", DisName = "0", Row = 0, WidthFactor = 1 }, - new ButtonLayout { Name = "Key Break", DisName = "BREAK", Row = 0, WidthFactor = 1.5 }, + private static PadSchema Keyboard() + { + List bls = new List + { + 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 1", DisName = "1", 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 4", DisName = "4", 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 7", DisName = "7", 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 0", DisName = "0", Row = 0, WidthFactor = 1 }, + 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 Graph", DisName = "GR", 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 E", DisName = "E", 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 Y", DisName = "Y", 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 O", DisName = "O", Row = 1, WidthFactor = 1 }, - new ButtonLayout { Name = "Key P", DisName = "P", Row = 1, WidthFactor = 1 }, + 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 Q", DisName = "Q", 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 R", DisName = "R", 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 U", DisName = "U", 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 P", DisName = "P", Row = 1, WidthFactor = 1 }, - 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 A", DisName = "A", 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 F", DisName = "F", 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 J", DisName = "J", 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 Return", DisName = "ENTER", Row = 2, WidthFactor = 1.75 }, + 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 A", DisName = "A", 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 F", DisName = "F", 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 J", DisName = "J", 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 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 Lock", DisName = "CL", 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 C", DisName = "C", 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 N", DisName = "N", 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 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 Z", DisName = "Z", 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 V", DisName = "V", 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 M", DisName = "M", 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 Symbol Shift", DisName = "SS", 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 Left 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 Up 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 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 Quote", 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 Space", DisName = "SPACE", Row = 4, WidthFactor = 4.5 }, + 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 Comma", DisName = ",", Row = 4, WidthFactor = 1 }, + new ButtonLayout { Name = "Key Symbol Shift", DisName = "SS", Row = 4, WidthFactor = 1 }, + }; - PadSchema ps = new PadSchema - { - DisplayName = "Keyboard", - IsConsole = false, - DefaultSize = new Size(500, 170) - }; + PadSchema ps = new PadSchema + { + DisplayName = "Keyboard", + IsConsole = false, + DefaultSize = new Size(500, 170) + }; - List btns = new List(); + List btns = new List(); - int rowHeight = 29; //24 - int stdButtonWidth = 29; //24 - int yPos = 18; - int xPos = 22; - int currRow = 0; + int rowHeight = 29; //24 + int stdButtonWidth = 29; //24 + int yPos = 18; + int xPos = 22; + int currRow = 0; - foreach (var b in bls) - { - if (b.Row > currRow) - { - currRow++; - yPos += rowHeight; - xPos = 22; - } + foreach (var b in bls) + { + if (b.Row > currRow) + { + currRow++; + yPos += rowHeight; + xPos = 22; + } - int txtLength = b.DisName.Length; - int btnSize = System.Convert.ToInt32((double)stdButtonWidth * b.WidthFactor); - + int txtLength = b.DisName.Length; + int btnSize = System.Convert.ToInt32((double)stdButtonWidth * b.WidthFactor); + - string disp = b.DisName; - if (txtLength == 1) - disp = $" {disp}"; - - switch(b.DisName) - { - case "SPACE": disp = $" {disp} "; break; - case "I": disp = $" {disp} "; break; - case "W": disp = b.DisName; break; - } - - - if (b.IsActive) - { - PadSchema.ButtonSchema btn = new PadSchema.ButtonSchema(); - btn.Name = b.Name; - btn.DisplayName = disp; - btn.Location = new Point(xPos, yPos); - btn.Type = PadSchema.PadInputType.Boolean; - btns.Add(btn); - } - - xPos += btnSize; - } + string disp = b.DisName; + if (txtLength == 1) + disp = $" {disp}"; + + switch(b.DisName) + { + case "SPACE": disp = $" {disp} "; break; + case "I": disp = $" {disp} "; break; + case "W": disp = b.DisName; break; + } + + + if (b.IsActive) + { + PadSchema.ButtonSchema btn = new PadSchema.ButtonSchema(); + btn.Name = b.Name; + btn.DisplayName = disp; + btn.Location = new Point(xPos, yPos); + btn.Type = PadSchema.PadInputType.Boolean; + btns.Add(btn); + } + + xPos += btnSize; + } - ps.Buttons = btns.ToArray(); - return ps; - } + ps.Buttons = btns.ToArray(); + return ps; + } - private static PadSchema TapeDevice() - { - return new PadSchema - { - DisplayName = "DATACORDER", - IsConsole = false, - DefaultSize = new Size(174, 74), - MaxSize = new Size(174, 74), - Buttons = new[] - { - new PadSchema.ButtonSchema - { - Name = "Play Tape", - Icon = Properties.Resources.Play, - Location = new Point(23, 22), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = "Stop Tape", - Icon = Properties.Resources.Stop, - Location = new Point(53, 22), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = "RTZ Tape", - Icon = Properties.Resources.BackMore, - Location = new Point(83, 22), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = "Insert Next Tape", - DisplayName = "NEXT TAPE", - //Icon = Properties.Resources.MoveRight, - Location = new Point(23, 52), - Type = PadSchema.PadInputType.Boolean - }, - new PadSchema.ButtonSchema - { - Name = "Insert Previous Tape", - DisplayName = "PREV TAPE", - //Icon = Properties.Resources.MoveLeft, - Location = new Point(100, 52), - Type = PadSchema.PadInputType.Boolean - }, - - } - }; - } - } + private static PadSchema TapeDevice() + { + return new PadSchema + { + DisplayName = "DATACORDER", + IsConsole = false, + DefaultSize = new Size(174, 74), + MaxSize = new Size(174, 74), + Buttons = new[] + { + new PadSchema.ButtonSchema + { + Name = "Play Tape", + Icon = Properties.Resources.Play, + Location = new Point(23, 22), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "Stop Tape", + Icon = Properties.Resources.Stop, + Location = new Point(53, 22), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "RTZ Tape", + Icon = Properties.Resources.BackMore, + Location = new Point(83, 22), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "Insert Next Tape", + DisplayName = "NEXT TAPE", + //Icon = Properties.Resources.MoveRight, + Location = new Point(23, 52), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = "Insert Previous Tape", + DisplayName = "PREV TAPE", + //Icon = Properties.Resources.MoveLeft, + Location = new Point(100, 52), + Type = PadSchema.PadInputType.Boolean + }, + + } + }; + } + } } diff --git a/BizHawk.Common/IImportResolver.cs b/BizHawk.Common/IImportResolver.cs index ece638c7c3..06b33b1085 100644 --- a/BizHawk.Common/IImportResolver.cs +++ b/BizHawk.Common/IImportResolver.cs @@ -28,31 +28,31 @@ namespace BizHawk.Common } } - /// - /// compose multiple ImportResolvers, where subsequent ones takes precedence over earlier ones - /// - public class PatchImportResolver : IImportResolver - { - private readonly List _resolvers = new List(); + /// + /// compose multiple ImportResolvers, where subsequent ones takes precedence over earlier ones + /// + public class PatchImportResolver : IImportResolver + { + private readonly List _resolvers = new List(); - public PatchImportResolver(params IImportResolver[] rr) - { - Add(rr); - } - public void Add(params IImportResolver[] rr) - { - _resolvers.AddRange(rr); - } + public PatchImportResolver(params IImportResolver[] rr) + { + Add(rr); + } + public void Add(params IImportResolver[] rr) + { + _resolvers.AddRange(rr); + } - public IntPtr Resolve(string entryPoint) - { - for (int i = _resolvers.Count - 1; i >= 0; i--) - { - var ret = _resolvers[i].Resolve(entryPoint); - if (ret != IntPtr.Zero) - return ret; - } - return IntPtr.Zero; - } - } + public IntPtr Resolve(string entryPoint) + { + for (int i = _resolvers.Count - 1; i >= 0; i--) + { + var ret = _resolvers[i].Resolve(entryPoint); + if (ret != IntPtr.Zero) + return ret; + } + return IntPtr.Zero; + } + } } diff --git a/BizHawk.Emulation.Common/TextState.cs b/BizHawk.Emulation.Common/TextState.cs index e00e641a33..6dd099d275 100644 --- a/BizHawk.Emulation.Common/TextState.cs +++ b/BizHawk.Emulation.Common/TextState.cs @@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Common [JsonIgnore] private Node Current => Nodes.Peek(); - public void Prepare() + public void Prepare() { Nodes = new Stack(); Nodes.Push(Root); diff --git a/BizHawk.Emulation.Cores/Arcades/MAME/LibMAME.cs b/BizHawk.Emulation.Cores/Arcades/MAME/LibMAME.cs index 476ddf78ef..e10e06cfca 100644 --- a/BizHawk.Emulation.Cores/Arcades/MAME/LibMAME.cs +++ b/BizHawk.Emulation.Cores/Arcades/MAME/LibMAME.cs @@ -3,9 +3,9 @@ using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Arcades.MAME { - public static class LibMAME - { - const string dll = "libmamearcade64.dll"; // libmamearcade64.dll libpacmansh64d.dll + public static class LibMAME + { + const string dll = "libmamearcade64.dll"; // libmamearcade64.dll libpacmansh64d.dll const CallingConvention cc = CallingConvention.Cdecl; public enum OutputChannel diff --git a/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs b/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs index 5776c9f879..7cdb09dc00 100644 --- a/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs +++ b/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs @@ -60,13 +60,13 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME private ManualResetEvent MAMEFrameComplete = new ManualResetEvent(false); private SortedDictionary fieldsPorts = new SortedDictionary(); private IController Controller = NullController.Instance; - private int[] frameBuffer = new int[0]; + private int[] frameBuffer = new int[0]; private short[] audioBuffer = new short[0]; private Queue audioSamples = new Queue(); private int sampleRate = 44100; private bool paused = true; private bool exiting = false; - private bool frameDone = true; + private bool frameDone = true; private int numSamples = 0; private string gameDirectory; private string gameFilename; @@ -116,15 +116,15 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME #region ISoundProvider public void SetSyncMode(SyncSoundMode mode) - { - if (mode == SyncSoundMode.Async) - { - throw new NotSupportedException("Async mode is not supported."); + { + if (mode == SyncSoundMode.Async) + { + throw new NotSupportedException("Async mode is not supported."); } } public void GetSamplesSync(out short[] samples, out int nsamp) - { + { nsamp = samplesPerFrame; samples = new short[samplesPerFrame * 2]; @@ -142,7 +142,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME } public void GetSamplesAsync(short[] samples) - { + { throw new InvalidOperationException("Async mode is not supported."); } diff --git a/BizHawk.Emulation.Cores/CPUs/68000/OpcodeTable.cs b/BizHawk.Emulation.Cores/CPUs/68000/OpcodeTable.cs index 14e11515ad..ac94bfae87 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/OpcodeTable.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/OpcodeTable.cs @@ -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[] Xn3Am3 = { - "000000", // Dn Data register - "001000", - "010000", - "011000", - "100000", - "101000", - "110000", - "111000", + "000000", // Dn Data register + "001000", + "010000", + "011000", + "100000", + "101000", + "110000", + "111000", - "000001", // An Address register - "001001", - "010001", - "011001", - "100001", - "101001", - "110001", - "111001", + "000001", // An Address register + "001001", + "010001", + "011001", + "100001", + "101001", + "110001", + "111001", - "000010", // (An) Address - "001010", - "010010", - "011010", - "100010", - "101010", - "110010", - "111010", + "000010", // (An) Address + "001010", + "010010", + "011010", + "100010", + "101010", + "110010", + "111010", - "000011", // (An)+ Address with Postincrement - "001011", - "010011", - "011011", - "100011", - "101011", - "110011", - "111011", + "000011", // (An)+ Address with Postincrement + "001011", + "010011", + "011011", + "100011", + "101011", + "110011", + "111011", - "000100", // -(An) Address with Predecrement - "001100", - "010100", - "011100", - "100100", - "101100", - "110100", - "111100", + "000100", // -(An) Address with Predecrement + "001100", + "010100", + "011100", + "100100", + "101100", + "110100", + "111100", - "000101", // (d16, An) Address with Displacement - "001101", - "010101", - "011101", - "100101", - "101101", - "110101", - "111101", + "000101", // (d16, An) Address with Displacement + "001101", + "010101", + "011101", + "100101", + "101101", + "110101", + "111101", - "000110", // (d8, An, Xn) Address with Index - "001110", - "010110", - "011110", - "100110", - "101110", - "110110", - "111110", + "000110", // (d8, An, Xn) Address with Index + "001110", + "010110", + "011110", + "100110", + "101110", + "110110", + "111110", - "010111", // (d16, PC) PC with Displacement - "011111", // (d8, PC, Xn) PC with Index - "000111", // (xxx).W Absolute Short - "001111", // (xxx).L Absolute Long - "100111", // #imm Immediate - }; + "010111", // (d16, PC) PC with Displacement + "011111", // (d8, PC, Xn) PC with Index + "000111", // (xxx).W Absolute Short + "001111", // (xxx).L Absolute Long + "100111", // #imm Immediate + }; static readonly string[] Am3Xn3 = { - "000000", // Dn Data register - "000001", - "000010", - "000011", - "000100", - "000101", - "000110", - "000111", + "000000", // Dn Data register + "000001", + "000010", + "000011", + "000100", + "000101", + "000110", + "000111", - "001000", // An Address register - "001001", - "001010", - "001011", - "001100", - "001101", - "001110", - "001111", + "001000", // An Address register + "001001", + "001010", + "001011", + "001100", + "001101", + "001110", + "001111", - "010000", // (An) Address - "010001", - "010010", - "010011", - "010100", - "010101", - "010110", - "010111", + "010000", // (An) Address + "010001", + "010010", + "010011", + "010100", + "010101", + "010110", + "010111", - "011000", // (An)+ Address with Postincrement - "011001", - "011010", - "011011", - "011100", - "011101", - "011110", - "011111", + "011000", // (An)+ Address with Postincrement + "011001", + "011010", + "011011", + "011100", + "011101", + "011110", + "011111", - "100000", // -(An) Address with Predecrement - "100001", - "100010", - "100011", - "100100", - "100101", - "100110", - "100111", + "100000", // -(An) Address with Predecrement + "100001", + "100010", + "100011", + "100100", + "100101", + "100110", + "100111", - "101000", // (d16, An) Address with Displacement - "101001", - "101010", - "101011", - "101100", - "101101", - "101110", - "101111", + "101000", // (d16, An) Address with Displacement + "101001", + "101010", + "101011", + "101100", + "101101", + "101110", + "101111", - "110000", // (d8, An, Xn) Address with Index - "110001", - "110010", - "110011", - "110100", - "110101", - "110110", - "110111", + "110000", // (d8, An, Xn) Address with Index + "110001", + "110010", + "110011", + "110100", + "110101", + "110110", + "110111", - "111010", // (d16, PC) PC with Displacement - "111011", // (d8, PC, Xn) PC with Index - "111000", // (xxx).W Absolute Short - "111001", // (xxx).L Absolute Long - "111100", // #imm Immediate - }; + "111010", // (d16, PC) PC with Displacement + "111011", // (d8, PC, Xn) PC with Index + "111000", // (xxx).W Absolute Short + "111001", // (xxx).L Absolute Long + "111100", // #imm Immediate + }; static readonly string[] ConditionMain = { - "0010", // HI Higher (unsigned) - "0011", // LS Lower or Same (unsigned) - "0100", // CC Carry Clear (aka Higher or Same, unsigned) - "0101", // CS Carry Set (aka Lower, unsigned) - "0110", // NE Not Equal - "0111", // EQ Equal - "1000", // VC Overflow Clear - "1001", // VS Overflow Set - "1010", // PL Plus - "1011", // MI Minus - "1100", // GE Greater or Equal (signed) - "1101", // LT Less Than (signed) - "1110", // GT Greater Than (signed) - "1111" // LE Less or Equal (signed) - }; + "0010", // HI Higher (unsigned) + "0011", // LS Lower or Same (unsigned) + "0100", // CC Carry Clear (aka Higher or Same, unsigned) + "0101", // CS Carry Set (aka Lower, unsigned) + "0110", // NE Not Equal + "0111", // EQ Equal + "1000", // VC Overflow Clear + "1001", // VS Overflow Set + "1010", // PL Plus + "1011", // MI Minus + "1100", // GE Greater or Equal (signed) + "1101", // LT Less Than (signed) + "1110", // GT Greater Than (signed) + "1111" // LE Less or Equal (signed) + }; static readonly string[] ConditionAll = { - "0000", // T True - "0001", // F False - "0010", // HI Higher (unsigned) - "0011", // LS Lower or Same (unsigned) - "0100", // CC Carry Clear (aka Higher or Same, unsigned) - "0101", // CS Carry Set (aka Lower, unsigned) - "0110", // NE Not Equal - "0111", // EQ Equal - "1000", // VC Overflow Clear - "1001", // VS Overflow Set - "1010", // PL Plus - "1011", // MI Minus - "1100", // GE Greater or Equal (signed) - "1101", // LT Less Than (signed) - "1110", // GT Greater Than (signed) - "1111" // LE Less or Equal (signed) - }; + "0000", // T True + "0001", // F False + "0010", // HI Higher (unsigned) + "0011", // LS Lower or Same (unsigned) + "0100", // CC Carry Clear (aka Higher or Same, unsigned) + "0101", // CS Carry Set (aka Lower, unsigned) + "0110", // NE Not Equal + "0111", // EQ Equal + "1000", // VC Overflow Clear + "1001", // VS Overflow Set + "1010", // PL Plus + "1011", // MI Minus + "1100", // GE Greater or Equal (signed) + "1101", // LT Less Than (signed) + "1110", // GT Greater Than (signed) + "1111" // LE Less or Equal (signed) + }; #endregion } diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs index a08f0e7a0a..12807fa509 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs @@ -296,23 +296,23 @@ namespace BizHawk.Emulation.Cores.Components.H6280 } private static readonly byte[] TableNZ = - { - 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, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 - }; + { + 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, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 + }; } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs index d9a9c4336c..edc4823150 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs @@ -7,8 +7,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A public long TotalExecutedCycles; private int EI_pending; - // ZXHawk needs to be able to read this for zx-state snapshot export - public int EIPending { get { return EI_pending; } } + // ZXHawk needs to be able to read this for zx-state snapshot export + public int EIPending { get { return EI_pending; } } public const ushort CBpre = 0; public const ushort EXTDpre = 1; diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs index 869dcdac8a..565fef3e6a 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs @@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.Components.Z80A public Action IRQCallback = delegate () { }; public Action NMICallback = delegate () { }; - // this will be a few cycles off for now - // it should suffice for now until Alyosha returns from hiatus - public Action IRQACKCallback = delegate () { }; + // this will be a few cycles off for now + // it should suffice for now until Alyosha returns from hiatus + public Action IRQACKCallback = delegate () { }; private void NMI_() { @@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A PopulateBUSRQ(0, 0, 0, 0, PCh, 0, 0); PopulateMEMRQ(0, 0, 0, 0, PCh, 0, 0); IRQS = 7; - } + } // Just jump to $0038 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); PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0); IRQS = 13; - } + } // Interrupt mode 2 uses the I vector combined with a byte on the data bus 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); PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0); IRQS = 19; - } + } private void ResetInterrupts() { diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs index 1212430187..e2a6280737 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs @@ -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) - { - Regs[dest] = ReadHardware((ushort)(Regs[src_l] | (Regs[src_h]) << 8)); - Regs[DB] = Regs[dest]; + { + Regs[dest] = ReadHardware((ushort)(Regs[src_l] | (Regs[src_h]) << 8)); + Regs[DB] = Regs[dest]; 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]; } diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 4f6cbbb156..310781381a 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A public const ushort RST = 65; public const ushort REP_OP_I = 66; 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 WR_TR_PC = 70; // transfer WZ to PC after write 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++]); break; case IN_A_N_INC: - IN_A_N_INC_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); - break; + IN_A_N_INC_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; case NEG: NEG_8_Func(cur_instr[instr_pntr++]); break; diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs index ba1f2efde3..c76e33f2c9 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs @@ -71,9 +71,9 @@ namespace BizHawk.Emulation.Cores.Calculators public string SystemId => "TI83"; - public bool DeterministicEmulation => true; + public bool DeterministicEmulation => true; - public void ResetCounters() + public void ResetCounters() { Frame = 0; _lagCount = 0; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs index 7a6b99dcb3..d58347d4d0 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs @@ -35,11 +35,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { [DisplayName("Border type")] [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" + - "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" + - "NONE:\t Only the pixel buffer is rendered" - )] + "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 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" + )] [DefaultValue(BorderType.SmallProportional)] public BorderType BorderType { get; set; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs index 974bead03d..025acfc538 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs @@ -108,46 +108,46 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS _port = new IecPort(readIec, readUserPort); } - public void HardReset() - { - _pra = 0; - _prb = 0; - _ddra = 0; - _ddrb = 0; - _ta = 0xFFFF; - _tb = 0xFFFF; - _latcha = 1; - _latchb = 1; - _tod10Ths = 0; - _todSec = 0; - _todMin = 0; - _todHr = 0; - _alm10Ths = 0; - _almSec = 0; - _almMin = 0; - _almHr = 0; - _sdr = 0; - _icr = 0; - _cra = 0; - _crb = 0; - _intMask = 0; - _todLatch = false; - _taCntPhi2 = false; - _taCntCnt = false; - _tbCntPhi2 = false; - _tbCntTa = false; - _tbCntCnt = false; - _taIrqNextCycle = false; - _tbIrqNextCycle = false; - _taState = TimerState.Stop; - _tbState = TimerState.Stop; - _lastCnt = true; - } + public void HardReset() + { + _pra = 0; + _prb = 0; + _ddra = 0; + _ddrb = 0; + _ta = 0xFFFF; + _tb = 0xFFFF; + _latcha = 1; + _latchb = 1; + _tod10Ths = 0; + _todSec = 0; + _todMin = 0; + _todHr = 0; + _alm10Ths = 0; + _almSec = 0; + _almMin = 0; + _almHr = 0; + _sdr = 0; + _icr = 0; + _cra = 0; + _crb = 0; + _intMask = 0; + _todLatch = false; + _taCntPhi2 = false; + _taCntCnt = false; + _tbCntPhi2 = false; + _tbCntTa = false; + _tbCntCnt = false; + _taIrqNextCycle = false; + _tbIrqNextCycle = false; + _taState = TimerState.Stop; + _tbState = TimerState.Stop; + _lastCnt = true; + } - public void ExecutePhase() - { - _thisCnt = ReadCnt(); - _taUnderflow = false; + public void ExecutePhase() + { + _thisCnt = ReadCnt(); + _taUnderflow = false; if (_taIrqNextCycle) { @@ -161,358 +161,358 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS TriggerInterrupt(2); } - if (_taPrb6NegativeNextCycle) - { - _prb &= 0xBF; - _taPrb6NegativeNextCycle = false; - } + if (_taPrb6NegativeNextCycle) + { + _prb &= 0xBF; + _taPrb6NegativeNextCycle = false; + } - if (_tbPrb7NegativeNextCycle) - { - _prb &= 0x7F; - _tbPrb7NegativeNextCycle = false; - } + if (_tbPrb7NegativeNextCycle) + { + _prb &= 0x7F; + _tbPrb7NegativeNextCycle = false; + } - switch (_taState) - { - case TimerState.WaitThenCount: - _taState = TimerState.Count; - Ta_Idle(); - break; - case TimerState.Stop: - Ta_Idle(); - break; - case TimerState.LoadThenStop: - _taState = TimerState.Stop; - _ta = _latcha; - Ta_Idle(); - break; - case TimerState.LoadThenCount: - _taState = TimerState.Count; - _ta = _latcha; - Ta_Idle(); - break; - case TimerState.LoadThenWaitThenCount: - _taState = TimerState.WaitThenCount; - if (_ta == 1) - { - Ta_Interrupt(); - _taUnderflow = true; - } - else - { - _ta = _latcha; - } - Ta_Idle(); - break; - case TimerState.Count: - Ta_Count(); - break; - case TimerState.CountThenStop: - _taState = TimerState.Stop; - Ta_Count(); - break; - } + switch (_taState) + { + case TimerState.WaitThenCount: + _taState = TimerState.Count; + Ta_Idle(); + break; + case TimerState.Stop: + Ta_Idle(); + break; + case TimerState.LoadThenStop: + _taState = TimerState.Stop; + _ta = _latcha; + Ta_Idle(); + break; + case TimerState.LoadThenCount: + _taState = TimerState.Count; + _ta = _latcha; + Ta_Idle(); + break; + case TimerState.LoadThenWaitThenCount: + _taState = TimerState.WaitThenCount; + if (_ta == 1) + { + Ta_Interrupt(); + _taUnderflow = true; + } + else + { + _ta = _latcha; + } + Ta_Idle(); + break; + case TimerState.Count: + Ta_Count(); + break; + case TimerState.CountThenStop: + _taState = TimerState.Stop; + Ta_Count(); + break; + } - switch (_tbState) - { - case TimerState.WaitThenCount: - _tbState = TimerState.Count; - Tb_Idle(); - break; - case TimerState.Stop: - Tb_Idle(); - break; - case TimerState.LoadThenStop: - _tbState = TimerState.Stop; - _tb = _latchb; - Tb_Idle(); - break; - case TimerState.LoadThenCount: - _tbState = TimerState.Count; - _tb = _latchb; - Tb_Idle(); - break; - case TimerState.LoadThenWaitThenCount: - _tbState = TimerState.WaitThenCount; - if (_tb == 1) - { - Tb_Interrupt(); - } - else - { - _tb = _latchb; - } - Tb_Idle(); - break; - case TimerState.Count: - Tb_Count(); - break; - case TimerState.CountThenStop: - _tbState = TimerState.Stop; - Tb_Count(); - break; - } + switch (_tbState) + { + case TimerState.WaitThenCount: + _tbState = TimerState.Count; + Tb_Idle(); + break; + case TimerState.Stop: + Tb_Idle(); + break; + case TimerState.LoadThenStop: + _tbState = TimerState.Stop; + _tb = _latchb; + Tb_Idle(); + break; + case TimerState.LoadThenCount: + _tbState = TimerState.Count; + _tb = _latchb; + Tb_Idle(); + break; + case TimerState.LoadThenWaitThenCount: + _tbState = TimerState.WaitThenCount; + if (_tb == 1) + { + Tb_Interrupt(); + } + else + { + _tb = _latchb; + } + Tb_Idle(); + break; + case TimerState.Count: + Tb_Count(); + break; + case TimerState.CountThenStop: + _tbState = TimerState.Stop; + Tb_Count(); + break; + } - CountTod(); + CountTod(); - if (!_todLatch) - { - _latch10Ths = _tod10Ths; - _latchSec = _todSec; - _latchMin = _todMin; - _latchHr = _todHr; - } + if (!_todLatch) + { + _latch10Ths = _tod10Ths; + _latchSec = _todSec; + _latchMin = _todMin; + _latchHr = _todHr; + } - _flagInput = ReadFlag(); - if (!_flagInput && _flagLatch) - { - TriggerInterrupt(16); - } - _flagLatch = _flagInput; + _flagInput = ReadFlag(); + if (!_flagInput && _flagLatch) + { + TriggerInterrupt(16); + } + _flagLatch = _flagInput; - if ((_cra & 0x02) != 0) - _ddra |= 0x40; - if ((_crb & 0x02) != 0) - _ddrb |= 0x80; + if ((_cra & 0x02) != 0) + _ddra |= 0x40; + if ((_crb & 0x02) != 0) + _ddrb |= 0x80; - _lastCnt = _thisCnt; - } + _lastCnt = _thisCnt; + } - private void Ta_Count() - { - if (_taCntPhi2 || (_taCntCnt && !_lastCnt && _thisCnt)) - { - if (_ta <= 0 || --_ta == 0) - { - if (_taState != TimerState.Stop) - { - Ta_Interrupt(); - } - _taUnderflow = true; - } - } - Ta_Idle(); - } + private void Ta_Count() + { + if (_taCntPhi2 || (_taCntCnt && !_lastCnt && _thisCnt)) + { + if (_ta <= 0 || --_ta == 0) + { + if (_taState != TimerState.Stop) + { + Ta_Interrupt(); + } + _taUnderflow = true; + } + } + Ta_Idle(); + } - private void Ta_Interrupt() - { - _ta = _latcha; + private void Ta_Interrupt() + { + _ta = _latcha; if (DelayedInterrupts) _taIrqNextCycle = true; else TriggerInterrupt(1); - _icr |= 1; + _icr |= 1; - if ((_cra & 0x08) != 0) - { - _cra &= 0xFE; - _newCra &= 0xFE; - _taState = TimerState.LoadThenStop; - } - else - { - _taState = TimerState.LoadThenCount; - } + if ((_cra & 0x08) != 0) + { + _cra &= 0xFE; + _newCra &= 0xFE; + _taState = TimerState.LoadThenStop; + } + else + { + _taState = TimerState.LoadThenCount; + } - if ((_cra & 0x02) != 0) - { - if ((_cra & 0x04) != 0) - { - _taPrb6NegativeNextCycle = true; - _prb |= 0x40; - } - else - { - _prb ^= 0x40; - } - _ddrb |= 0x40; - } - } + if ((_cra & 0x02) != 0) + { + if ((_cra & 0x04) != 0) + { + _taPrb6NegativeNextCycle = true; + _prb |= 0x40; + } + else + { + _prb ^= 0x40; + } + _ddrb |= 0x40; + } + } - private void Ta_Idle() - { - if (_hasNewCra) - { - switch (_taState) - { - case TimerState.Stop: - case TimerState.LoadThenStop: - if ((_newCra & 0x01) != 0) - { - _taState = (_newCra & 0x10) != 0 - ? TimerState.LoadThenWaitThenCount - : TimerState.WaitThenCount; - } - else - { - if ((_newCra & 0x10) != 0) - { - _taState = TimerState.LoadThenStop; - } - } - break; - case TimerState.Count: - if ((_newCra & 0x01) != 0) - { - if ((_newCra & 0x10) != 0) - { - _taState = TimerState.LoadThenWaitThenCount; - } - } - else - { - _taState = (_newCra & 0x10) != 0 - ? TimerState.LoadThenStop - : TimerState.CountThenStop; - } - break; - case TimerState.LoadThenCount: - case TimerState.WaitThenCount: - if ((_newCra & 0x01) != 0) - { - if ((_newCra & 0x08) != 0) - { - _newCra &= 0xFE; - _taState = TimerState.Stop; - } - else if ((_newCra & 0x10) != 0) - { - _taState = TimerState.LoadThenWaitThenCount; - } - } - else - { - _taState = TimerState.Stop; - } - break; - } - _cra = _newCra & 0xEF; - _hasNewCra = false; - } - } + private void Ta_Idle() + { + if (_hasNewCra) + { + switch (_taState) + { + case TimerState.Stop: + case TimerState.LoadThenStop: + if ((_newCra & 0x01) != 0) + { + _taState = (_newCra & 0x10) != 0 + ? TimerState.LoadThenWaitThenCount + : TimerState.WaitThenCount; + } + else + { + if ((_newCra & 0x10) != 0) + { + _taState = TimerState.LoadThenStop; + } + } + break; + case TimerState.Count: + if ((_newCra & 0x01) != 0) + { + if ((_newCra & 0x10) != 0) + { + _taState = TimerState.LoadThenWaitThenCount; + } + } + else + { + _taState = (_newCra & 0x10) != 0 + ? TimerState.LoadThenStop + : TimerState.CountThenStop; + } + break; + case TimerState.LoadThenCount: + case TimerState.WaitThenCount: + if ((_newCra & 0x01) != 0) + { + if ((_newCra & 0x08) != 0) + { + _newCra &= 0xFE; + _taState = TimerState.Stop; + } + else if ((_newCra & 0x10) != 0) + { + _taState = TimerState.LoadThenWaitThenCount; + } + } + else + { + _taState = TimerState.Stop; + } + break; + } + _cra = _newCra & 0xEF; + _hasNewCra = false; + } + } - private void Tb_Count() - { - if (_tbCntPhi2 || (_tbCntTa && _taUnderflow) || (_tbCntTaCnt && _taUnderflow && _thisCnt) || (_tbCntCnt && !_lastCnt && _thisCnt)) - { - if (_tb <= 0 || --_tb == 0) - { - if (_tbState != TimerState.Stop) - { - Tb_Interrupt(); - } - } - } - Tb_Idle(); - } + private void Tb_Count() + { + if (_tbCntPhi2 || (_tbCntTa && _taUnderflow) || (_tbCntTaCnt && _taUnderflow && _thisCnt) || (_tbCntCnt && !_lastCnt && _thisCnt)) + { + if (_tb <= 0 || --_tb == 0) + { + if (_tbState != TimerState.Stop) + { + Tb_Interrupt(); + } + } + } + Tb_Idle(); + } - private void Tb_Interrupt() - { - _tb = _latchb; + private void Tb_Interrupt() + { + _tb = _latchb; if (DelayedInterrupts) _tbIrqNextCycle = true; else TriggerInterrupt(2); - _icr |= 2; + _icr |= 2; - if ((_crb & 0x08) != 0) - { - _crb &= 0xFE; - _newCrb &= 0xFE; - _tbState = TimerState.LoadThenStop; - } - else - { - _tbState = TimerState.LoadThenCount; - } + if ((_crb & 0x08) != 0) + { + _crb &= 0xFE; + _newCrb &= 0xFE; + _tbState = TimerState.LoadThenStop; + } + else + { + _tbState = TimerState.LoadThenCount; + } - if ((_crb & 0x02) != 0) - { - if ((_crb & 0x04) != 0) - { - _tbPrb7NegativeNextCycle = true; - _prb |= 0x80; - } - else - { - _prb ^= 0x80; - } - } - } + if ((_crb & 0x02) != 0) + { + if ((_crb & 0x04) != 0) + { + _tbPrb7NegativeNextCycle = true; + _prb |= 0x80; + } + else + { + _prb ^= 0x80; + } + } + } - private void Tb_Idle() - { - if (_hasNewCrb) - { - switch (_tbState) - { - case TimerState.Stop: - case TimerState.LoadThenStop: - if ((_newCrb & 0x01) != 0) - { - _tbState = (_newCrb & 0x10) != 0 - ? TimerState.LoadThenWaitThenCount - : TimerState.WaitThenCount; - } - else - { - if ((_newCrb & 0x10) != 0) - { - _tbState = TimerState.LoadThenStop; - } - } - break; - case TimerState.Count: - if ((_newCrb & 0x01) != 0) - { - if ((_newCrb & 0x10) != 0) - { - _tbState = TimerState.LoadThenWaitThenCount; - } - } - else - { - _tbState = (_newCrb & 0x10) != 0 - ? TimerState.LoadThenStop - : TimerState.CountThenStop; - } - break; - case TimerState.LoadThenCount: - case TimerState.WaitThenCount: - if ((_newCrb & 0x01) != 0) - { - if ((_newCrb & 0x08) != 0) - { - _newCrb &= 0xFE; - _tbState = TimerState.Stop; - } - else if ((_newCrb & 0x10) != 0) - { - _tbState = TimerState.LoadThenWaitThenCount; - } - } - else - { - _tbState = TimerState.Stop; - } - break; - } - _crb = _newCrb & 0xEF; - _hasNewCrb = false; - } - } + private void Tb_Idle() + { + if (_hasNewCrb) + { + switch (_tbState) + { + case TimerState.Stop: + case TimerState.LoadThenStop: + if ((_newCrb & 0x01) != 0) + { + _tbState = (_newCrb & 0x10) != 0 + ? TimerState.LoadThenWaitThenCount + : TimerState.WaitThenCount; + } + else + { + if ((_newCrb & 0x10) != 0) + { + _tbState = TimerState.LoadThenStop; + } + } + break; + case TimerState.Count: + if ((_newCrb & 0x01) != 0) + { + if ((_newCrb & 0x10) != 0) + { + _tbState = TimerState.LoadThenWaitThenCount; + } + } + else + { + _tbState = (_newCrb & 0x10) != 0 + ? TimerState.LoadThenStop + : TimerState.CountThenStop; + } + break; + case TimerState.LoadThenCount: + case TimerState.WaitThenCount: + if ((_newCrb & 0x01) != 0) + { + if ((_newCrb & 0x08) != 0) + { + _newCrb &= 0xFE; + _tbState = TimerState.Stop; + } + else if ((_newCrb & 0x10) != 0) + { + _tbState = TimerState.LoadThenWaitThenCount; + } + } + else + { + _tbState = TimerState.Stop; + } + break; + } + _crb = _newCrb & 0xEF; + _hasNewCrb = false; + } + } - private void TriggerInterrupt(int bit) - { - _icr |= bit; - if ((_intMask & bit) == 0) return; - _icr |= 0x80; - } + private void TriggerInterrupt(int bit) + { + _icr |= bit; + if ((_intMask & bit) == 0) return; + _icr |= 0x80; + } public void SyncState(Serializer ser) { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.cs index cd57404c71..395ba526a6 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.cs @@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS else { _t1C--; - if (_t1C == 0) + if (_t1C == 0) { switch (_acrT1Control) { @@ -216,7 +216,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS break; } } - else if (_t1C < 0) + else if (_t1C < 0) { if (_t1CLoaded) { @@ -331,7 +331,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS break; } - // interrupt generation + // interrupt generation if (_acrSrControl == ACR_SR_CONTROL_DISABLED) { @@ -350,30 +350,30 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS with output pins on the peripheral ports. */ - if ((_pcrCa1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Ca1 && !_ca1L) || - (_pcrCa1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Ca1 && _ca1L)) - { - if (_acrPaLatchEnable && (_ifr & 0x02) == 0) + if ((_pcrCa1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Ca1 && !_ca1L) || + (_pcrCa1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Ca1 && _ca1L)) + { + if (_acrPaLatchEnable && (_ifr & 0x02) == 0) _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. 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 output. As with the PA port, the processor always reads the input latches. */ - if ((_pcrCb1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Cb1 && !_cb1L) || - (_pcrCb1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Cb1 && _cb1L)) - { - if (_acrPbLatchEnable && (_ifr & 0x10) == 0) + if ((_pcrCb1IntControl == PCR_INT_CONTROL_POSITIVE_EDGE && Cb1 && !_cb1L) || + (_pcrCb1IntControl == PCR_INT_CONTROL_NEGATIVE_EDGE && !Cb1 && _cb1L)) + { + if (_acrPbLatchEnable && (_ifr & 0x10) == 0) _pbLatch = _port.ReadPrb(_prb, _ddrb); if (_acrSrControl == ACR_SR_CONTROL_DISABLED) _shiftIn = true; - _ifr |= 0x10; - } + _ifr |= 0x10; + } if (_shiftIn) { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs index c0fc6740bb..1a997b0fce 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.cs @@ -95,7 +95,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS switch (borderType) { - + case C64.BorderType.Full: newHblankStart = -1; newHblankEnd = -1; @@ -128,27 +128,27 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS newVblankStart = 0xFA + hBorderSize; newVblankEnd = 0x32 - hBorderSize; break; - case C64.BorderType.None: - newHblankStart = 0x158 + PixBufferSize; - newHblankEnd = 0x018 + PixBufferSize; - newVblankStart = 0xFA; - newVblankEnd = 0x32; - _vblank = true; - _hblank = true; - break; + case C64.BorderType.None: + newHblankStart = 0x158 + PixBufferSize; + newHblankEnd = 0x018 + PixBufferSize; + newVblankStart = 0xFA; + newVblankEnd = 0x32; + _vblank = true; + _hblank = true; + break; } // wrap values - if (_hblank) - { - newHblankStart = WrapValue(0, maxWidth, newHblankStart); - newHblankEnd = WrapValue(0, maxWidth, newHblankEnd); - } + if (_hblank) + { + newHblankStart = WrapValue(0, maxWidth, newHblankStart); + newHblankEnd = WrapValue(0, maxWidth, newHblankEnd); + } if (_vblank) - { - newVblankStart = WrapValue(0, lines, newVblankStart); - newVblankEnd = WrapValue(0, lines, newVblankEnd); - } + { + newVblankStart = WrapValue(0, lines, newVblankStart); + newVblankEnd = WrapValue(0, lines, newVblankEnd); + } // calculate output dimensions _hblankStartCheckXRaster = newHblankStart & 0xFFC; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs index f086bb3b21..fc24a083d8 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs @@ -181,76 +181,76 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media public static Disk Read(byte[] source) { - var formatB = source[D64_DISK_ID_OFFSET + 0x00]; - var formatA = source[D64_DISK_ID_OFFSET + 0x01]; + var formatB = source[D64_DISK_ID_OFFSET + 0x00]; + var formatA = source[D64_DISK_ID_OFFSET + 0x01]; - using (var mem = new MemoryStream(source)) - { - var reader = new BinaryReader(mem); - var trackDatas = new List(); - var trackLengths = new List(); - var trackNumbers = new List(); - var trackDensities = new List(); - var errorType = ErrorType.NoError; - int trackCount; - int errorOffset = -1; + using (var mem = new MemoryStream(source)) + { + var reader = new BinaryReader(mem); + var trackDatas = new List(); + var trackLengths = new List(); + var trackNumbers = new List(); + var trackDensities = new List(); + var errorType = ErrorType.NoError; + int trackCount; + int errorOffset = -1; - switch (source.Length) - { - case 174848: // 35 tracks no errors - trackCount = 35; - break; - case 175531: // 35 tracks with errors - trackCount = 35; - errorOffset = 174848; - break; - case 196608: // 40 tracks no errors - trackCount = 40; - break; - case 197376: // 40 tracks with errors - trackCount = 40; - errorOffset = 196608; - break; - default: - throw new Exception("Not able to identify capacity of the D64 file."); - } + switch (source.Length) + { + case 174848: // 35 tracks no errors + trackCount = 35; + break; + case 175531: // 35 tracks with errors + trackCount = 35; + errorOffset = 174848; + break; + case 196608: // 40 tracks no errors + trackCount = 40; + break; + case 197376: // 40 tracks with errors + trackCount = 40; + errorOffset = 196608; + break; + default: + throw new Exception("Not able to identify capacity of the D64 file."); + } - for (var i = 0; i < trackCount; i++) - { - if (errorOffset >= 0) - { - errorType = (ErrorType) source[errorOffset]; - errorOffset++; - } - var sectors = SectorsPerTrack[i]; - var trackLengthBits = 0; - using (var trackMem = new MemoryStream()) - { - for (var j = 0; j < sectors; j++) - { - int bitsWritten; - var sectorData = reader.ReadBytes(256); - var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out bitsWritten); - trackMem.Write(diskData, 0, diskData.Length); - trackLengthBits += bitsWritten; - } - var density = DensityTable[i]; + for (var i = 0; i < trackCount; i++) + { + if (errorOffset >= 0) + { + errorType = (ErrorType) source[errorOffset]; + errorOffset++; + } + var sectors = SectorsPerTrack[i]; + var trackLengthBits = 0; + using (var trackMem = new MemoryStream()) + { + for (var j = 0; j < sectors; j++) + { + int bitsWritten; + var sectorData = reader.ReadBytes(256); + var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out bitsWritten); + trackMem.Write(diskData, 0, diskData.Length); + trackLengthBits += bitsWritten; + } + var density = DensityTable[i]; - // we pad the tracks with extra gap bytes to meet MNIB standards - while (trackMem.Length < StandardTrackLengthBytes[density]) - { - trackMem.WriteByte(0x55); - } + // we pad the tracks with extra gap bytes to meet MNIB standards + while (trackMem.Length < StandardTrackLengthBytes[density]) + { + trackMem.WriteByte(0x55); + } - trackDatas.Add(trackMem.ToArray()); - trackLengths.Add(trackLengthBits); - trackNumbers.Add(i * 2); - trackDensities.Add(DensityTable[i]); - } - } + trackDatas.Add(trackMem.ToArray()); + trackLengths.Add(trackLengthBits); + trackNumbers.Add(i * 2); + trackDensities.Add(DensityTable[i]); + } + } return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = false}; } - } + } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs index 74f3fd2045..607f1ce2ec 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs @@ -64,79 +64,79 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media } } - public static byte[] Write(IList trackData, IList trackNumbers, IList trackDensities) - { - const byte version = 0; - const byte trackCount = 84; - const int headerLength = 0xC; - const byte dataFillerValue = 0xFF; + public static byte[] Write(IList trackData, IList trackNumbers, IList trackDensities) + { + const byte version = 0; + const byte trackCount = 84; + const int headerLength = 0xC; + 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()) - { - var writer = new BinaryWriter(mem); + using (var mem = new MemoryStream()) + { + var writer = new BinaryWriter(mem); - // header ID - writer.Write("GCR-1541".ToCharArray()); + // header ID + writer.Write("GCR-1541".ToCharArray()); - // version # - writer.Write(version); + // version # + writer.Write(version); - // tracks in the image - writer.Write(trackCount); + // tracks in the image + writer.Write(trackCount); - // maximum track size in bytes - writer.Write(trackMaxLength); + // maximum track size in bytes + writer.Write(trackMaxLength); - // combine track data - var offsets = new List(); - var densities = new List(); - using (var trackMem = new MemoryStream()) - { - var trackMemWriter = new BinaryWriter(trackMem); - for (var i = 0; i < trackCount; i++) - { - if (trackNumbers.Contains(i)) - { - var trackIndex = trackNumbers.IndexOf(i); - offsets.Add((int)trackMem.Length); - densities.Add(trackDensities[trackIndex]); + // combine track data + var offsets = new List(); + var densities = new List(); + using (var trackMem = new MemoryStream()) + { + var trackMemWriter = new BinaryWriter(trackMem); + for (var i = 0; i < trackCount; i++) + { + if (trackNumbers.Contains(i)) + { + var trackIndex = trackNumbers.IndexOf(i); + offsets.Add((int)trackMem.Length); + densities.Add(trackDensities[trackIndex]); - var data = trackData[trackIndex]; - var buffer = Enumerable.Repeat(dataFillerValue, trackMaxLength).ToArray(); - var dataBytes = data.Select(d => unchecked((byte)d)).ToArray(); - Array.Copy(dataBytes, buffer, dataBytes.Length); - trackMemWriter.Write((ushort)dataBytes.Length); - trackMemWriter.Write(buffer); - } - else - { - offsets.Add(-1); - densities.Add(0); - } - } - trackMemWriter.Flush(); + var data = trackData[trackIndex]; + var buffer = Enumerable.Repeat(dataFillerValue, trackMaxLength).ToArray(); + var dataBytes = data.Select(d => unchecked((byte)d)).ToArray(); + Array.Copy(dataBytes, buffer, dataBytes.Length); + trackMemWriter.Write((ushort)dataBytes.Length); + trackMemWriter.Write(buffer); + } + else + { + offsets.Add(-1); + densities.Add(0); + } + } + trackMemWriter.Flush(); - // offset table - foreach (var offset in offsets.Select(o => o >= 0 ? o + headerLength + trackCount * 8 : 0)) - { - writer.Write(offset); - } + // offset table + foreach (var offset in offsets.Select(o => o >= 0 ? o + headerLength + trackCount * 8 : 0)) + { + writer.Write(offset); + } - // speed zone data - foreach (var density in densities) - { - writer.Write(density); - } + // speed zone data + foreach (var density in densities) + { + writer.Write(density); + } - // track data - writer.Write(trackMem.ToArray()); - } + // track data + writer.Write(trackMem.ToArray()); + } - writer.Flush(); - return mem.ToArray(); - } - } + writer.Flush(); + return mem.ToArray(); + } + } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.FluxTransitions.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.FluxTransitions.cs index 569a8ef855..2e72c0f3e6 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.FluxTransitions.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.FluxTransitions.cs @@ -36,167 +36,167 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial _rngCurrent = unchecked((int) ((_rngCurrent * LEHMER_RNG_PRIME) & int.MaxValue)); } - private void ExecuteFlux() - { - // This actually executes the main 16mhz clock - while (_clocks > 0) - { - _clocks--; + private void ExecuteFlux() + { + // This actually executes the main 16mhz clock + while (_clocks > 0) + { + _clocks--; - // rotate disk - if (_motorEnabled) - { - if (_disk == null) - { - _diskBitsLeft = 1; - _diskBits = 0; - } - else - { - if (_diskBitsLeft <= 0) - { - if (_diskWriteEnabled) - _trackImageData[_diskByteOffset] = _diskOutputBits; + // rotate disk + if (_motorEnabled) + { + if (_disk == null) + { + _diskBitsLeft = 1; + _diskBits = 0; + } + else + { + if (_diskBitsLeft <= 0) + { + if (_diskWriteEnabled) + _trackImageData[_diskByteOffset] = _diskOutputBits; - _diskByteOffset++; + _diskByteOffset++; - if (_diskByteOffset == Disk.FluxEntriesPerTrack) - _diskByteOffset = 0; + if (_diskByteOffset == Disk.FluxEntriesPerTrack) + _diskByteOffset = 0; - if (!_diskWriteEnabled) - _diskBits = _trackImageData[_diskByteOffset]; + if (!_diskWriteEnabled) + _diskBits = _trackImageData[_diskByteOffset]; - _diskOutputBits = 0; - _diskBitsLeft = Disk.FluxBitsPerEntry; - } - } - _diskOutputBits >>= 1; + _diskOutputBits = 0; + _diskBitsLeft = Disk.FluxBitsPerEntry; + } + } + _diskOutputBits >>= 1; - if (_diskWriteEnabled && !_diskWriteProtected) - _countsBeforeRandomTransition = 0; + if (_diskWriteEnabled && !_diskWriteProtected) + _countsBeforeRandomTransition = 0; - if ((_diskBits & 1) != 0) - { - _countsBeforeRandomTransition = 0; - _diskFluxReversalDetected = true; - _diskOutputBits |= int.MinValue; // set bit 31 - } - else - { - _diskOutputBits &= int.MaxValue; // clear bit 31 - } + if ((_diskBits & 1) != 0) + { + _countsBeforeRandomTransition = 0; + _diskFluxReversalDetected = true; + _diskOutputBits |= int.MinValue; // set bit 31 + } + else + { + _diskOutputBits &= int.MaxValue; // clear bit 31 + } - _diskBits >>= 1; - _diskBitsLeft--; - } + _diskBits >>= 1; + _diskBitsLeft--; + } - // random flux transition readings for unformatted data - if (_countsBeforeRandomTransition > 0) - { - _countsBeforeRandomTransition--; - if (_countsBeforeRandomTransition == 0) - { - _diskFluxReversalDetected = true; - AdvanceRng(); - // This constant is what VICE uses. TODO: Determine accuracy. - _countsBeforeRandomTransition = (_rngCurrent % 367) + 33; - } - } + // random flux transition readings for unformatted data + if (_countsBeforeRandomTransition > 0) + { + _countsBeforeRandomTransition--; + if (_countsBeforeRandomTransition == 0) + { + _diskFluxReversalDetected = true; + AdvanceRng(); + // This constant is what VICE uses. TODO: Determine accuracy. + _countsBeforeRandomTransition = (_rngCurrent % 367) + 33; + } + } - // flux transition circuitry - if (_diskFluxReversalDetected) - { - if (!_diskWriteEnabled) - { - _diskDensityCounter = _diskDensity; - _diskSupplementaryCounter = 0; - } - _diskFluxReversalDetected = false; - if (_countsBeforeRandomTransition == 0) - { - AdvanceRng(); - // This constant is what VICE uses. TODO: Determine accuracy. - _countsBeforeRandomTransition = (_rngCurrent & 0x1F) + 289; - } - } + // flux transition circuitry + if (_diskFluxReversalDetected) + { + if (!_diskWriteEnabled) + { + _diskDensityCounter = _diskDensity; + _diskSupplementaryCounter = 0; + } + _diskFluxReversalDetected = false; + if (_countsBeforeRandomTransition == 0) + { + AdvanceRng(); + // This constant is what VICE uses. TODO: Determine accuracy. + _countsBeforeRandomTransition = (_rngCurrent & 0x1F) + 289; + } + } - // counter circuitry - if (_diskDensityCounter >= 16) - { - _diskDensityCounter = _diskDensity; - _diskSupplementaryCounter++; + // counter circuitry + if (_diskDensityCounter >= 16) + { + _diskDensityCounter = _diskDensity; + _diskSupplementaryCounter++; - if ((_diskSupplementaryCounter & 0x3) == 0x2) - { - if (!_diskWriteEnabled) - _diskWriteBitsRemaining = 0; - _diskWriteEnabled = !Via1.Cb2; + if ((_diskSupplementaryCounter & 0x3) == 0x2) + { + if (!_diskWriteEnabled) + _diskWriteBitsRemaining = 0; + _diskWriteEnabled = !Via1.Cb2; - _diskWriteBitsRemaining--; - if (_diskWriteEnabled) - { - _countsBeforeRandomTransition = 0; - _byteReady = false; - if (_diskWriteBitsRemaining <= 0) - { - _diskWriteLatch = Via1.EffectivePrA; - _diskWriteBitsRemaining = 8; - _byteReady = Via1.Ca2; - } - if ((_diskWriteLatch & 0x80) != 0) - { - _diskOutputBits |= int.MinValue; // set bit 31 - } - _diskWriteLatch <<= 1; - } - else - { - _bitsRemainingInLatchedByte--; - _byteReady = false; - _bitHistory = (_bitHistory << 1) | ((_diskSupplementaryCounter & 0xC) == 0x0 ? 1 : 0); - _sync = false; - if (!_diskWriteEnabled && (_bitHistory & 0x3FF) == 0x3FF) - { - _sync = true; - _bitsRemainingInLatchedByte = 8; - _byteReady = false; - } + _diskWriteBitsRemaining--; + if (_diskWriteEnabled) + { + _countsBeforeRandomTransition = 0; + _byteReady = false; + if (_diskWriteBitsRemaining <= 0) + { + _diskWriteLatch = Via1.EffectivePrA; + _diskWriteBitsRemaining = 8; + _byteReady = Via1.Ca2; + } + if ((_diskWriteLatch & 0x80) != 0) + { + _diskOutputBits |= int.MinValue; // set bit 31 + } + _diskWriteLatch <<= 1; + } + else + { + _bitsRemainingInLatchedByte--; + _byteReady = false; + _bitHistory = (_bitHistory << 1) | ((_diskSupplementaryCounter & 0xC) == 0x0 ? 1 : 0); + _sync = false; + if (!_diskWriteEnabled && (_bitHistory & 0x3FF) == 0x3FF) + { + _sync = true; + _bitsRemainingInLatchedByte = 8; + _byteReady = false; + } - if (_bitsRemainingInLatchedByte <= 0) - { - _bitsRemainingInLatchedByte = 8; + if (_bitsRemainingInLatchedByte <= 0) + { + _bitsRemainingInLatchedByte = 8; - // SOE (SO/Byte Ready enabled) - _byteReady = Via1.Ca2; - } - } - } + // SOE (SO/Byte Ready enabled) + _byteReady = Via1.Ca2; + } + } + } - // negative transition activates SO pin on CPU - _previousCa1 = Via1.Ca1; - Via1.Ca1 = !_byteReady; - if (_previousCa1 && !Via1.Ca1) - { - // cycle 6 is roughly 400ns - _overflowFlagDelaySr |= _diskCycle > 6 ? 4 : 2; - } - } + // negative transition activates SO pin on CPU + _previousCa1 = Via1.Ca1; + Via1.Ca1 = !_byteReady; + if (_previousCa1 && !Via1.Ca1) + { + // cycle 6 is roughly 400ns + _overflowFlagDelaySr |= _diskCycle > 6 ? 4 : 2; + } + } - if (_diskSupplementaryCounter >= 16) - { - _diskSupplementaryCounter = 0; - } + if (_diskSupplementaryCounter >= 16) + { + _diskSupplementaryCounter = 0; + } - _cpuClocks--; - if (_cpuClocks <= 0) - { - ExecuteSystem(); - _cpuClocks = 16; - } + _cpuClocks--; + if (_cpuClocks <= 0) + { + ExecuteSystem(); + _cpuClocks = 16; + } - _diskDensityCounter++; - _diskCycle = (_diskCycle + 1) & 0xF; - } - } + _diskDensityCounter++; + _diskCycle = (_diskCycle + 1) & 0xF; + } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs index bf70777b4a..b8e49cbe6c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs @@ -429,82 +429,82 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public static readonly int[] PALPalette = { 0x000000, 0x1c1c1c, 0x393939, 0x595959, // Grey - 0x797979, 0x929292, 0xababab, 0xbcbcbc, + 0x797979, 0x929292, 0xababab, 0xbcbcbc, 0xcdcdcd, 0xd9d9d9, 0xe6e6e6, 0xececec, 0xf2f2f2, 0xf8f8f8, 0xffffff, 0xffffff, 0x263001, 0x243803, 0x234005, 0x51541b, // Orange Green - 0x806931, 0x978135, 0xaf993a, 0xc2a73e, + 0x806931, 0x978135, 0xaf993a, 0xc2a73e, 0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836, 0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d, 0x263001, 0x243803, 0x234005, 0x51541b, // Orange Green - 0x806931, 0x978135, 0xaf993a, 0xc2a73e, + 0x806931, 0x978135, 0xaf993a, 0xc2a73e, 0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836, 0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d, 0x401a02, 0x581f05, 0x702408, 0x8d3a13, // Light Orange - 0xab511f, 0xb56427, 0xbf7730, 0xd0853a, + 0xab511f, 0xb56427, 0xbf7730, 0xd0853a, 0xe19344, 0xeda04e, 0xf9ad58, 0xfcb75c, 0xffc160, 0xffc671, 0xffcb83, 0xffcb83, 0x391701, 0x5e2304, 0x833008, 0xa54716, // Gold - 0xc85f24, 0xe37820, 0xff911d, 0xffab1d, + 0xc85f24, 0xe37820, 0xff911d, 0xffab1d, 0xffc51d, 0xffce34, 0xffd84c, 0xffe651, 0xfff456, 0xfff977, 0xffff98, 0xffff98, 0x451904, 0x721e11, 0x9f241e, 0xb33a20, // Orange - 0xc85122, 0xe36920, 0xff811e, 0xff8c25, + 0xc85122, 0xe36920, 0xff811e, 0xff8c25, 0xff982c, 0xffae38, 0xffc545, 0xffc559, 0xffc66d, 0xffd587, 0xffe4a1, 0xffe4a1, 0x4a1704, 0x7e1a0d, 0xb21d17, 0xc82119, // Red Orange - 0xdf251c, 0xec3b38, 0xfa5255, 0xfc6161, + 0xdf251c, 0xec3b38, 0xfa5255, 0xfc6161, 0xff706e, 0xff7f7e, 0xff8f8f, 0xff9d9e, 0xffabad, 0xffb9bd, 0xffc7ce, 0xffc7ce, 0x050568, 0x3b136d, 0x712272, 0x8b2a8c, // Pink - 0xa532a6, 0xb938ba, 0xcd3ecf, 0xdb47dd, + 0xa532a6, 0xb938ba, 0xcd3ecf, 0xdb47dd, 0xea51eb, 0xf45ff5, 0xfe6dff, 0xfe7afd, 0xff87fb, 0xff95fd, 0xffa4ff, 0xffa4ff, 0x280479, 0x400984, 0x590f90, 0x70249d, // Purple - 0x8839aa, 0xa441c3, 0xc04adc, 0xd054ed, + 0x8839aa, 0xa441c3, 0xc04adc, 0xd054ed, 0xe05eff, 0xe96dff, 0xf27cff, 0xf88aff, 0xff98ff, 0xfea1ff, 0xfeabff, 0xfeabff, 0x051e81, 0x0626a5, 0x082fca, 0x263dd4, // Blue1 - 0x444cde, 0x4f5aee, 0x5a68ff, 0x6575ff, + 0x444cde, 0x4f5aee, 0x5a68ff, 0x6575ff, 0x7183ff, 0x8091ff, 0x90a0ff, 0x97a9ff, 0x9fb2ff, 0xafbeff, 0xc0cbff, 0xc0cbff, 0x0c048b, 0x2218a0, 0x382db5, 0x483ec7, // Blue2 - 0x584fda, 0x6159ec, 0x6b64ff, 0x7a74ff, + 0x584fda, 0x6159ec, 0x6b64ff, 0x7a74ff, 0x8a84ff, 0x918eff, 0x9998ff, 0xa5a3ff, 0xb1aeff, 0xb8b8ff, 0xc0c2ff, 0xc0c2ff, 0x1d295a, 0x1d3876, 0x1d4892, 0x1c5cac, // Light Blue - 0x1c71c6, 0x3286cf, 0x489bd9, 0x4ea8ec, + 0x1c71c6, 0x3286cf, 0x489bd9, 0x4ea8ec, 0x55b6ff, 0x70c7ff, 0x8cd8ff, 0x93dbff, 0x9bdfff, 0xafe4ff, 0xc3e9ff, 0xc3e9ff, 0x2f4302, 0x395202, 0x446103, 0x417a12, // Turquoise - 0x3e9421, 0x4a9f2e, 0x57ab3b, 0x5cbd55, + 0x3e9421, 0x4a9f2e, 0x57ab3b, 0x5cbd55, 0x61d070, 0x69e27a, 0x72f584, 0x7cfa8d, 0x87ff97, 0x9affa6, 0xadffb6, 0xadffb6, 0x0a4108, 0x0d540a, 0x10680d, 0x137d0f, // Green Blue - 0x169212, 0x19a514, 0x1cb917, 0x1ec919, + 0x169212, 0x19a514, 0x1cb917, 0x1ec919, 0x21d91b, 0x47e42d, 0x6ef040, 0x78f74d, 0x83ff5b, 0x9aff7a, 0xb2ff9a, 0xb2ff9a, 0x04410b, 0x05530e, 0x066611, 0x077714, // Green - 0x088817, 0x099b1a, 0x0baf1d, 0x48c41f, + 0x088817, 0x099b1a, 0x0baf1d, 0x48c41f, 0x86d922, 0x8fe924, 0x99f927, 0xa8fc41, 0xb7ff5b, 0xc9ff6e, 0xdcff81, 0xdcff81, 0x02350f, 0x073f15, 0x0c4a1c, 0x2d5f1e, // Yellow Green - 0x4f7420, 0x598324, 0x649228, 0x82a12e, + 0x4f7420, 0x598324, 0x649228, 0x82a12e, 0xa1b034, 0xa9c13a, 0xb2d241, 0xc4d945, 0xd6e149, 0xe4f04e, 0xf2ff53, 0xf2ff53 }; diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs index ea6dc8b99c..acf63f850c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision { get { - return _lagcount; + return _lagcount; } set diff --git a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs index a108e501d7..abb706c4d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs +++ b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX public int Port1; public int Port2; public int PixelPro; - } + } [BizImport(CC)] public abstract void SetCDCallbacks(LibSaturnus.CDTOCCallback toccallback, diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs index b0e9a8822f..d09a6571fb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs @@ -63,13 +63,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 ForceGammaCorrection = false; GammaCorrectionLevel = 2.0f; EnableOverscan = false; - OverscanNtscTop = 0; - OverscanNtscBottom = 0; - OverscanNtscLeft = 0; - OverscanNtscRight = 0; - OverscanPalTop = 0; - OverscanPalBottom = 0; - OverscanPalLeft = 0; + OverscanNtscTop = 0; + OverscanNtscBottom = 0; + OverscanNtscLeft = 0; + OverscanNtscRight = 0; + OverscanPalTop = 0; + OverscanPalBottom = 0; + OverscanPalLeft = 0; OverscanPalRight = 0; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs index 85a8644175..5306a7b4ad 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs @@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public int BufferWidth { get; private set; } public int BufferHeight { get; private set; } public int BackgroundColor { get { return 0; } } - public int VsyncNumerator { get; internal set; } + public int VsyncNumerator { get; internal set; } public int VsyncDenominator { get; internal set; } /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs index 78bb3379ee..d76a55e839 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs @@ -63,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES static byte[] TRIANGLE_TABLE = { 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 = { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.CpuLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.CpuLink.cs index 13ae69905f..daccb94f1d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.CpuLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.CpuLink.cs @@ -2,8 +2,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - public partial class NES - { + public partial class NES + { public struct CpuLink : IMOS6502XLink { private readonly NES _nes; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs index 440db2278a..f05d542f0d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs @@ -66,8 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES eMessage_BRK_hook_write, eMessage_BRK_hook_nmi, eMessage_BRK_hook_irq, - eMessage_BRK_hook_exec_smp, - eMessage_BRK_hook_read_smp, + eMessage_BRK_hook_exec_smp, + eMessage_BRK_hook_read_smp, eMessage_BRK_hook_write_smp, eMessage_BRK_scanlineStart, }; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.Tables.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.Tables.cs index dcd382b20a..f8eeeea7dd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.Tables.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.Tables.cs @@ -1,143 +1,143 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public partial class VDP - { - // TODO: HCounter - readonly byte[] VLineCounterTableNTSC192 = - { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - }; + public partial class VDP + { + // TODO: HCounter + readonly byte[] VLineCounterTableNTSC192 = + { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + }; - readonly byte[] VLineCounterTableNTSC224 = - { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, - 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, - }; + readonly byte[] VLineCounterTableNTSC224 = + { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, + 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, + }; - readonly byte[] VLineCounterTableNTSC240 = - { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 - }; + readonly byte[] VLineCounterTableNTSC240 = + { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 + }; - readonly byte[] VLineCounterTablePAL192 = - { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, - 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 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, - 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 - }; + readonly byte[] VLineCounterTablePAL192 = + { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, + 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 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, + 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 + }; - readonly byte[] VLineCounterTablePAL224 = - { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 0x00, 0x01, 0x02, - 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 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, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF - }; + readonly byte[] VLineCounterTablePAL224 = + { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 0x00, 0x01, 0x02, + 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 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, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF + }; - readonly byte[] VLineCounterTablePAL240 = - { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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 - }; - } + readonly byte[] VLineCounterTablePAL240 = + { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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 + }; + } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs index 03ddcbfefb..5f02e69389 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs @@ -234,10 +234,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn protected override string[] AnalogNames => _analogNames; - public ThreeDeeGamepad() - { - Definition.FloatRanges[2] = new FloatRange(0, 0, 255); - Definition.FloatRanges[3] = new FloatRange(0, 0, 255); + public ThreeDeeGamepad() + { + Definition.FloatRanges[2] = new FloatRange(0, 0, 255); + Definition.FloatRanges[3] = new FloatRange(0, 0, 255); } public override void Update(IController controller, byte[] dest, int offset) @@ -275,9 +275,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn "Mouse Left", "Mouse Right", "Mouse Center", "Start" }; - protected override string[] ButtonNames => _buttonNames; - - private static readonly string[] _analogNames = + protected override string[] ButtonNames => _buttonNames; + + private static readonly string[] _analogNames = { "X", "Y" }; @@ -288,7 +288,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn { switch (name) { - default: + default: case "Mouse Left": return 0; case "Mouse Center": @@ -366,7 +366,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn switch (name) { default: - return 0; + return 0; case "Start": return 1; case "A": @@ -557,116 +557,116 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn { switch (name) { - default: return 0; - case "Escape": return 1; - case "F1": return 2; - case "F2": return 3; - case "F3": return 4; + default: return 0; + case "Escape": return 1; + case "F1": return 2; + case "F2": return 3; + case "F3": return 4; case "F4": return 5; case "F5": return 6; - case "F6": return 7; - case "F7": return 8; - case "F8": return 9; - case "F9": return 10; - case "F10": return 11; - case "F11": return 12; - case "F12": return 13; - - case "Grave`": return 100; - case "1(One)": return 101; - case "2": return 102; - case "3": return 103; + case "F6": return 7; + case "F7": return 8; + case "F8": return 9; + case "F9": return 10; + case "F10": return 11; + case "F11": return 12; + case "F12": return 13; + + case "Grave`": return 100; + case "1(One)": return 101; + case "2": return 102; + case "3": return 103; case "4": return 104; - case "5": return 105; - case "6": return 106; + case "5": return 105; + case "6": return 106; case "7": return 107; - case "8": return 108; - case "9": return 109; - case "0(Zero)": return 110; - case "Minus-": return 111; - case "Equals=": return 112; - case "Backslash\\": return 113; - case "Backspace": return 114; - - case "Tab": return 200; - case "Q": return 201; - case "W": return 202; - case "E": return 203; - case "R(Key)": return 204; - case "T": return 205; - case "Y(Key)": return 206; - case "U": return 207; - case "I": return 208; - case "O": return 209; - case "P": return 210; - case "LeftBracket[": return 211; - case "RightBracket]": return 212; - case "Enter": return 213; - - case "CapsLock": return 300; - case "A(Key)": return 301; - case "S": return 302; - case "D": return 303; - case "F": return 304; - case "G": return 305; + case "8": return 108; + case "9": return 109; + case "0(Zero)": return 110; + case "Minus-": return 111; + case "Equals=": return 112; + case "Backslash\\": return 113; + case "Backspace": return 114; + + case "Tab": return 200; + case "Q": return 201; + case "W": return 202; + case "E": return 203; + case "R(Key)": return 204; + case "T": return 205; + case "Y(Key)": return 206; + case "U": return 207; + case "I": return 208; + case "O": return 209; + case "P": return 210; + case "LeftBracket[": return 211; + case "RightBracket]": return 212; + case "Enter": return 213; + + case "CapsLock": return 300; + case "A(Key)": return 301; + case "S": return 302; + case "D": return 303; + case "F": return 304; + case "G": return 305; case "H": return 306; - case "J": return 307; - case "K": return 308; - case "L(Key)": return 309; - case "Semicolon;": return 310; - case "Quote'": return 311; - - case "LeftShift": return 400; - case "Z(Key)": return 401; - case "X(Key)": return 402; + case "J": return 307; + case "K": return 308; + case "L(Key)": return 309; + case "Semicolon;": return 310; + case "Quote'": return 311; + + case "LeftShift": return 400; + case "Z(Key)": return 401; + case "X(Key)": return 402; case "C(Key)": return 403; - case "V": return 404; - case "B(Key)": return 405; - case "N": return 406; - case "M": return 407; + case "V": return 404; + case "B(Key)": return 405; + case "N": return 406; + case "M": return 407; case "Comma,": return 408; case "Period.": return 409; - case "Slash/": return 410; - case "RightShift": return 411; - - case "LeftCtrl": return 500; - case "LeftAlt": return 501; - case "Space": return 502; - case "RightAlt": return 503; - case "RightCtrl": return 504; - - case "PrintScreen": return 1000; - case "ScrollLock": return 1001; - case "Pause": return 1002; - - case "Insert": return 1100; - case "Delete": return 1101; + case "Slash/": return 410; + case "RightShift": return 411; + + case "LeftCtrl": return 500; + case "LeftAlt": return 501; + case "Space": return 502; + case "RightAlt": return 503; + case "RightCtrl": return 504; + + case "PrintScreen": return 1000; + case "ScrollLock": return 1001; + case "Pause": return 1002; + + case "Insert": return 1100; + case "Delete": return 1101; case "Home": return 1102; - case "End": return 1103; + case "End": return 1103; case "PageUp": return 1104; - case "PageDown": return 1105; - + case "PageDown": return 1105; + case "Up": return 1200; - case "Down": return 1201; - case "CursorLeft": return 1202; - case "Right": return 1203; - - case "NumLock": return 1300; - case "KeypadSlash(Divide)": return 1301; - case "KeypadAsterisk(Multiply)": return 1302; - case "KeypadMinus": return 1303; - case "KeypadHome/7": return 1304; - case "KeypadUp/8": return 1305; - case "KeypadPageup/9": return 1306; - case "KeypadPlus": return 1307; - case "KeypadLeft/4": return 1308; + case "Down": return 1201; + case "CursorLeft": return 1202; + case "Right": return 1203; + + case "NumLock": return 1300; + case "KeypadSlash(Divide)": return 1301; + case "KeypadAsterisk(Multiply)": return 1302; + case "KeypadMinus": return 1303; + case "KeypadHome/7": return 1304; + case "KeypadUp/8": return 1305; + case "KeypadPageup/9": return 1306; + case "KeypadPlus": return 1307; + case "KeypadLeft/4": return 1308; case "KeypadCenter/5": return 1309; - case "KeypadRight/6": return 1310; - case "KeypadEnd/1": return 1311; - case "KeypadDown/2": return 1312; - case "KeypadPagedown/3": return 1313; - case "KeypadEnter": return 1314; - case "KeypadInsert/0": return 1315; + case "KeypadRight/6": return 1310; + case "KeypadEnd/1": return 1311; + case "KeypadDown/2": return 1312; + case "KeypadPagedown/3": return 1313; + case "KeypadEnter": return 1314; + case "KeypadInsert/0": return 1315; case "KeypadDelete": return 1316; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs index ea17bf2374..913ba15a86 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs @@ -61,20 +61,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx private void InitMemCallbacks() { - ExecCallback = new LibGPGX.mem_cb(a => - { - uint flags = (uint)(MemoryCallbackFlags.AccessExecute); + ExecCallback = new LibGPGX.mem_cb(a => + { + uint flags = (uint)(MemoryCallbackFlags.AccessExecute); MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS"); }); - ReadCallback = new LibGPGX.mem_cb(a => - { - uint flags = (uint)(MemoryCallbackFlags.AccessRead); - MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS"); + ReadCallback = new LibGPGX.mem_cb(a => + { + uint flags = (uint)(MemoryCallbackFlags.AccessRead); + MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS"); }); - WriteCallback = new LibGPGX.mem_cb(a => - { - uint flags = (uint)(MemoryCallbackFlags.AccessWrite); - MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS"); + WriteCallback = new LibGPGX.mem_cb(a => + { + uint flags = (uint)(MemoryCallbackFlags.AccessWrite); + MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS"); }); _memoryCallbacks.ActiveChanged += RefreshMemCallbacks; } diff --git a/BizHawk.Emulation.Cores/FileID.cs b/BizHawk.Emulation.Cores/FileID.cs index d86fe0e53e..8519aec6f7 100644 --- a/BizHawk.Emulation.Cores/FileID.cs +++ b/BizHawk.Emulation.Cores/FileID.cs @@ -42,8 +42,8 @@ namespace BizHawk.Emulation.Cores WS, WSC, NGC, C64, - ZXSpectrum, - AmstradCPC, + ZXSpectrum, + AmstradCPC, INT, A26, A52, A78, LNX, diff --git a/BizHawk.Emulation.Cores/Sound/YM2612.cs b/BizHawk.Emulation.Cores/Sound/YM2612.cs index a856524c57..02cf1493d9 100644 --- a/BizHawk.Emulation.Cores/Sound/YM2612.cs +++ b/BizHawk.Emulation.Cores/Sound/YM2612.cs @@ -526,134 +526,134 @@ namespace BizHawk.Emulation.Common.Components #region tables static readonly byte[] egRateCounterShiftValues = - { - 11, 11, 11, 11, // Rates 0-3 - 10, 10, 10, 10, // Rates 4-7 - 9, 9, 9, 9, // Rates 8-11 - 8, 8, 8, 8, // Rates 12-15 - 7, 7, 7, 7, // Rates 16-19 - 6, 6, 6, 6, // Rates 20-23 - 5, 5, 5, 5, // Rates 24-27 - 4, 4, 4, 4, // Rates 28-31 - 3, 3, 3, 3, // Rates 32-35 - 2, 2, 2, 2, // Rates 36-39 - 1, 1, 1, 1, // Rates 40-43 - 0, 0, 0, 0, // Rates 44-47 - 0, 0, 0, 0, // Rates 48-51 - 0, 0, 0, 0, // Rates 52-55 - 0, 0, 0, 0, // Rates 56-59 - 0, 0, 0, 0 // Rates 60-63 - }; + { + 11, 11, 11, 11, // Rates 0-3 + 10, 10, 10, 10, // Rates 4-7 + 9, 9, 9, 9, // Rates 8-11 + 8, 8, 8, 8, // Rates 12-15 + 7, 7, 7, 7, // Rates 16-19 + 6, 6, 6, 6, // Rates 20-23 + 5, 5, 5, 5, // Rates 24-27 + 4, 4, 4, 4, // Rates 28-31 + 3, 3, 3, 3, // Rates 32-35 + 2, 2, 2, 2, // Rates 36-39 + 1, 1, 1, 1, // Rates 40-43 + 0, 0, 0, 0, // Rates 44-47 + 0, 0, 0, 0, // Rates 48-51 + 0, 0, 0, 0, // Rates 52-55 + 0, 0, 0, 0, // Rates 56-59 + 0, 0, 0, 0 // Rates 60-63 + }; static readonly byte[] egRateIncrementValues = - { - 0,0,0,0,0,0,0,0, // Rate 0 - 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 3 - 0,1,0,1,0,1,0,1, // Rate 4 - 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 7 - 0,1,0,1,0,1,0,1, // Rate 8 - 0,1,0,1,1,1,0,1, // Rate 9 - 0,1,1,1,0,1,1,1, // Rate 10 - 0,1,1,1,1,1,1,1, // Rate 11 - 0,1,0,1,0,1,0,1, // Rate 12 - 0,1,0,1,1,1,0,1, // Rate 13 - 0,1,1,1,0,1,1,1, // Rate 14 - 0,1,1,1,1,1,1,1, // Rate 15 - 0,1,0,1,0,1,0,1, // Rate 16 - 0,1,0,1,1,1,0,1, // Rate 17 - 0,1,1,1,0,1,1,1, // Rate 18 - 0,1,1,1,1,1,1,1, // Rate 19 - 0,1,0,1,0,1,0,1, // Rate 20 - 0,1,0,1,1,1,0,1, // Rate 21 - 0,1,1,1,0,1,1,1, // Rate 22 - 0,1,1,1,1,1,1,1, // Rate 23 - 0,1,0,1,0,1,0,1, // Rate 24 - 0,1,0,1,1,1,0,1, // Rate 25 - 0,1,1,1,0,1,1,1, // Rate 26 - 0,1,1,1,1,1,1,1, // Rate 27 - 0,1,0,1,0,1,0,1, // Rate 28 - 0,1,0,1,1,1,0,1, // Rate 29 - 0,1,1,1,0,1,1,1, // Rate 30 - 0,1,1,1,1,1,1,1, // Rate 31 - 0,1,0,1,0,1,0,1, // Rate 32 - 0,1,0,1,1,1,0,1, // Rate 33 - 0,1,1,1,0,1,1,1, // Rate 34 - 0,1,1,1,1,1,1,1, // Rate 35 - 0,1,0,1,0,1,0,1, // Rate 36 - 0,1,0,1,1,1,0,1, // Rate 37 - 0,1,1,1,0,1,1,1, // Rate 38 - 0,1,1,1,1,1,1,1, // Rate 39 - 0,1,0,1,0,1,0,1, // Rate 40 - 0,1,0,1,1,1,0,1, // Rate 41 - 0,1,1,1,0,1,1,1, // Rate 42 - 0,1,1,1,1,1,1,1, // Rate 43 - 0,1,0,1,0,1,0,1, // Rate 44 - 0,1,0,1,1,1,0,1, // Rate 45 - 0,1,1,1,0,1,1,1, // Rate 46 - 0,1,1,1,1,1,1,1, // Rate 47 - 1,1,1,1,1,1,1,1, // Rate 48 - 1,1,1,2,1,1,1,2, // Rate 49 - 1,2,1,2,1,2,1,2, // Rate 50 - 1,2,2,2,1,2,2,2, // Rate 51 - 2,2,2,2,2,2,2,2, // Rate 52 - 2,2,2,4,2,2,2,4, // Rate 53 - 2,4,2,4,2,4,2,4, // Rate 54 - 2,4,4,4,2,4,4,4, // Rate 55 - 4,4,4,4,4,4,4,4, // Rate 56 - 4,4,4,8,4,4,4,8, // Rate 57 - 4,8,4,8,4,8,4,8, // Rate 58 - 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 61 - 8,8,8,8,8,8,8,8, // Rate 62 - 8,8,8,8,8,8,8,8 // Rate 63 - }; + { + 0,0,0,0,0,0,0,0, // Rate 0 + 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 3 + 0,1,0,1,0,1,0,1, // Rate 4 + 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 7 + 0,1,0,1,0,1,0,1, // Rate 8 + 0,1,0,1,1,1,0,1, // Rate 9 + 0,1,1,1,0,1,1,1, // Rate 10 + 0,1,1,1,1,1,1,1, // Rate 11 + 0,1,0,1,0,1,0,1, // Rate 12 + 0,1,0,1,1,1,0,1, // Rate 13 + 0,1,1,1,0,1,1,1, // Rate 14 + 0,1,1,1,1,1,1,1, // Rate 15 + 0,1,0,1,0,1,0,1, // Rate 16 + 0,1,0,1,1,1,0,1, // Rate 17 + 0,1,1,1,0,1,1,1, // Rate 18 + 0,1,1,1,1,1,1,1, // Rate 19 + 0,1,0,1,0,1,0,1, // Rate 20 + 0,1,0,1,1,1,0,1, // Rate 21 + 0,1,1,1,0,1,1,1, // Rate 22 + 0,1,1,1,1,1,1,1, // Rate 23 + 0,1,0,1,0,1,0,1, // Rate 24 + 0,1,0,1,1,1,0,1, // Rate 25 + 0,1,1,1,0,1,1,1, // Rate 26 + 0,1,1,1,1,1,1,1, // Rate 27 + 0,1,0,1,0,1,0,1, // Rate 28 + 0,1,0,1,1,1,0,1, // Rate 29 + 0,1,1,1,0,1,1,1, // Rate 30 + 0,1,1,1,1,1,1,1, // Rate 31 + 0,1,0,1,0,1,0,1, // Rate 32 + 0,1,0,1,1,1,0,1, // Rate 33 + 0,1,1,1,0,1,1,1, // Rate 34 + 0,1,1,1,1,1,1,1, // Rate 35 + 0,1,0,1,0,1,0,1, // Rate 36 + 0,1,0,1,1,1,0,1, // Rate 37 + 0,1,1,1,0,1,1,1, // Rate 38 + 0,1,1,1,1,1,1,1, // Rate 39 + 0,1,0,1,0,1,0,1, // Rate 40 + 0,1,0,1,1,1,0,1, // Rate 41 + 0,1,1,1,0,1,1,1, // Rate 42 + 0,1,1,1,1,1,1,1, // Rate 43 + 0,1,0,1,0,1,0,1, // Rate 44 + 0,1,0,1,1,1,0,1, // Rate 45 + 0,1,1,1,0,1,1,1, // Rate 46 + 0,1,1,1,1,1,1,1, // Rate 47 + 1,1,1,1,1,1,1,1, // Rate 48 + 1,1,1,2,1,1,1,2, // Rate 49 + 1,2,1,2,1,2,1,2, // Rate 50 + 1,2,2,2,1,2,2,2, // Rate 51 + 2,2,2,2,2,2,2,2, // Rate 52 + 2,2,2,4,2,2,2,4, // Rate 53 + 2,4,2,4,2,4,2,4, // Rate 54 + 2,4,4,4,2,4,4,4, // Rate 55 + 4,4,4,4,4,4,4,4, // Rate 56 + 4,4,4,8,4,4,4,8, // Rate 57 + 4,8,4,8,4,8,4,8, // Rate 58 + 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 61 + 8,8,8,8,8,8,8,8, // Rate 62 + 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 - { - 0x000, 0x020, 0x040, 0x060, 0x080, 0x0A0, 0x0C0, 0x0E0, - 0x100, 0x120, 0x140, 0x160, 0x180, 0x1A0, 0x1C0, 0x3FF - }; + { + 0x000, 0x020, 0x040, 0x060, 0x080, 0x0A0, 0x0C0, 0x0E0, + 0x100, 0x120, 0x140, 0x160, 0x180, 0x1A0, 0x1C0, 0x3FF + }; static readonly int[] detuneTable = - { - 0, 0, 1, 2, // Key-Code 0 - 0, 0, 1, 2, // Key-Code 1 - 0, 0, 1, 2, // Key-Code 2 - 0, 0, 1, 2, // Key-Code 3 - 0, 1, 2, 2, // Key-Code 4 - 0, 1, 2, 3, // Key-Code 5 - 0, 1, 2, 3, // Key-Code 6 - 0, 1, 2, 3, // Key-Code 7 - 0, 1, 2, 4, // Key-Code 8 - 0, 1, 3, 4, // Key-Code 9 - 0, 1, 3, 4, // Key-Code 10 - 0, 1, 3, 5, // Key-Code 11 - 0, 2, 4, 5, // Key-Code 12 - 0, 2, 4, 6, // Key-Code 13 - 0, 2, 4, 6, // Key-Code 14 - 0, 2, 5, 7, // Key-Code 15 - 0, 2, 5, 8, // Key-Code 16 - 0, 3, 6, 8, // Key-Code 17 - 0, 3, 6, 9, // Key-Code 18 - 0, 3, 7, 10, // Key-Code 19 - 0, 4, 8, 11, // Key-Code 20 - 0, 4, 8, 12, // Key-Code 21 - 0, 4, 9, 13, // Key-Code 22 - 0, 5, 10, 14, // Key-Code 23 - 0, 5, 11, 16, // Key-Code 24 - 0, 6, 12, 17, // Key-Code 25 - 0, 6, 13, 19, // Key-Code 26 - 0, 7, 14, 20, // Key-Code 27 - 0, 8, 16, 22, // Key-Code 28 - 0, 8, 16, 22, // Key-Code 29 - 0, 8, 16, 22, // Key-Code 30 - 0, 8, 16, 22 // Key-Code 31 - }; + { + 0, 0, 1, 2, // Key-Code 0 + 0, 0, 1, 2, // Key-Code 1 + 0, 0, 1, 2, // Key-Code 2 + 0, 0, 1, 2, // Key-Code 3 + 0, 1, 2, 2, // Key-Code 4 + 0, 1, 2, 3, // Key-Code 5 + 0, 1, 2, 3, // Key-Code 6 + 0, 1, 2, 3, // Key-Code 7 + 0, 1, 2, 4, // Key-Code 8 + 0, 1, 3, 4, // Key-Code 9 + 0, 1, 3, 4, // Key-Code 10 + 0, 1, 3, 5, // Key-Code 11 + 0, 2, 4, 5, // Key-Code 12 + 0, 2, 4, 6, // Key-Code 13 + 0, 2, 4, 6, // Key-Code 14 + 0, 2, 5, 7, // Key-Code 15 + 0, 2, 5, 8, // Key-Code 16 + 0, 3, 6, 8, // Key-Code 17 + 0, 3, 6, 9, // Key-Code 18 + 0, 3, 7, 10, // Key-Code 19 + 0, 4, 8, 11, // Key-Code 20 + 0, 4, 8, 12, // Key-Code 21 + 0, 4, 9, 13, // Key-Code 22 + 0, 5, 10, 14, // Key-Code 23 + 0, 5, 11, 16, // Key-Code 24 + 0, 6, 12, 17, // Key-Code 25 + 0, 6, 13, 19, // Key-Code 26 + 0, 7, 14, 20, // Key-Code 27 + 0, 8, 16, 22, // Key-Code 28 + 0, 8, 16, 22, // Key-Code 29 + 0, 8, 16, 22, // Key-Code 30 + 0, 8, 16, 22 // Key-Code 31 + }; #endregion // ==================================================================================== diff --git a/BizHawk.Emulation.Cores/Waterbox/Swappable.cs b/BizHawk.Emulation.Cores/Waterbox/Swappable.cs index ff973176eb..5536fa297d 100644 --- a/BizHawk.Emulation.Cores/Waterbox/Swappable.cs +++ b/BizHawk.Emulation.Cores/Waterbox/Swappable.cs @@ -1,6 +1,6 @@ using BizHawk.Common; -using BizHawk.Common.BizInvoke; -using BizHawk.Common.BufferExtensions; +using BizHawk.Common.BizInvoke; +using BizHawk.Common.BufferExtensions; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -31,8 +31,8 @@ namespace BizHawk.Emulation.Cores.Waterbox /// private List _memoryBlocks = new List(); - /// - /// an informative name for each memory block: used for debugging purposes + /// + /// an informative name for each memory block: used for debugging purposes /// private List _memoryBlockNames = new List(); @@ -136,15 +136,15 @@ namespace BizHawk.Emulation.Cores.Waterbox m.Activate(); } - public void PrintDebuggingInfo() - { - using (this.EnterExit()) - { - foreach (var a in _memoryBlocks.Zip(_memoryBlockNames, (m, s) => new { m, s })) - { - Console.WriteLine($"{a.m.FullHash().BytesToHexString()}: {a.s}"); - } - } + public void PrintDebuggingInfo() + { + using (this.EnterExit()) + { + foreach (var a in _memoryBlocks.Zip(_memoryBlockNames, (m, s) => new { m, s })) + { + Console.WriteLine($"{a.m.FullHash().BytesToHexString()}: {a.s}"); + } + } } private bool _disposed = false; diff --git a/BizHawk.Emulation.DiscSystem/CDFS/EndianBitConverter.cs b/BizHawk.Emulation.DiscSystem/CDFS/EndianBitConverter.cs index 307185eb91..f7cd0b47eb 100644 --- a/BizHawk.Emulation.DiscSystem/CDFS/EndianBitConverter.cs +++ b/BizHawk.Emulation.DiscSystem/CDFS/EndianBitConverter.cs @@ -5,151 +5,151 @@ using System.Text; namespace BizHawk.Emulation.DiscSystem { - /// - /// Helper class to convert big and little endian numbers from a byte - /// array to a value. - /// - /// This code was modified from the endian bit converter presented by - /// Robert Unoki in his blog post: - /// http://blogs.msdn.com/robunoki/archive/2006/04/05/568737.aspx - /// - /// I have added support for more data types and the ability to - /// specify an offset into the array to be converted where the value - /// begins. - /// - public class EndianBitConverter { - #region Static Constructors + /// + /// Helper class to convert big and little endian numbers from a byte + /// array to a value. + /// + /// This code was modified from the endian bit converter presented by + /// Robert Unoki in his blog post: + /// http://blogs.msdn.com/robunoki/archive/2006/04/05/568737.aspx + /// + /// I have added support for more data types and the ability to + /// specify an offset into the array to be converted where the value + /// begins. + /// + public class EndianBitConverter { + #region Static Constructors - /// - /// Build a converter from little endian to the system endian-ness. - /// - /// The converter - public static EndianBitConverter CreateForLittleEndian() { - return new EndianBitConverter(!BitConverter.IsLittleEndian); - } + /// + /// Build a converter from little endian to the system endian-ness. + /// + /// The converter + public static EndianBitConverter CreateForLittleEndian() { + return new EndianBitConverter(!BitConverter.IsLittleEndian); + } - /// - /// Build a converter from big endian to the system endian-ness. - /// - /// The converter - public static EndianBitConverter CreateForBigEndian() { - return new EndianBitConverter(BitConverter.IsLittleEndian); - } + /// + /// Build a converter from big endian to the system endian-ness. + /// + /// The converter + public static EndianBitConverter CreateForBigEndian() { + return new EndianBitConverter(BitConverter.IsLittleEndian); + } - #endregion + #endregion - #region Private Properties + #region Private Properties - /// - /// Keep track of whether we need to swap the bytes or not - /// - private bool swap; + /// + /// Keep track of whether we need to swap the bytes or not + /// + private bool swap; - #endregion + #endregion - #region Private Constructor + #region Private Constructor - /// - /// Create the converter with the given endian-ness. - /// - /// Whether or not to swap bytes. - private EndianBitConverter(bool swapBytes) { - swap = swapBytes; - } + /// + /// Create the converter with the given endian-ness. + /// + /// Whether or not to swap bytes. + private EndianBitConverter(bool swapBytes) { + swap = swapBytes; + } - #endregion + #endregion - #region 16-bit + #region 16-bit - public Int16 ToInt16(byte[] data) { - return ToInt16(data, 0); - } - public Int16 ToInt16(byte[] data, int offset) { - byte[] corrected; - if (swap) { - corrected = (byte[])data.Clone(); - Array.Reverse(corrected, offset, 2); - } - else { - corrected = data; - } - return BitConverter.ToInt16(corrected, offset); - } + public Int16 ToInt16(byte[] data) { + return ToInt16(data, 0); + } + public Int16 ToInt16(byte[] data, int offset) { + byte[] corrected; + if (swap) { + corrected = (byte[])data.Clone(); + Array.Reverse(corrected, offset, 2); + } + else { + corrected = data; + } + return BitConverter.ToInt16(corrected, offset); + } - #endregion + #endregion - #region 32-bit + #region 32-bit - public Int32 ToInt32(byte[] data) { - return ToInt32(data, 0); - } - public Int32 ToInt32(byte[] data, int offset) { - byte[] corrected; - if (swap) { - corrected = (byte[])data.Clone(); - Array.Reverse(corrected, offset, 4); - } - else { - corrected = data; - } - return BitConverter.ToInt32(corrected, offset); - } + public Int32 ToInt32(byte[] data) { + return ToInt32(data, 0); + } + public Int32 ToInt32(byte[] data, int offset) { + byte[] corrected; + if (swap) { + corrected = (byte[])data.Clone(); + Array.Reverse(corrected, offset, 4); + } + else { + corrected = data; + } + return BitConverter.ToInt32(corrected, offset); + } - #endregion + #endregion - #region 64-bit + #region 64-bit - public Int64 ToInt64(byte[] data) { - return ToInt64(data, 0); - } - public Int64 ToInt64(byte[] data, int offset) { - byte[] corrected; - if (swap) { - corrected = (byte[])data.Clone(); - Array.Reverse(corrected, offset, 8); - } - else { - corrected = data; - } - return BitConverter.ToInt64(corrected, offset); - } + public Int64 ToInt64(byte[] data) { + return ToInt64(data, 0); + } + public Int64 ToInt64(byte[] data, int offset) { + byte[] corrected; + if (swap) { + corrected = (byte[])data.Clone(); + Array.Reverse(corrected, offset, 8); + } + else { + corrected = data; + } + 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 - // If these are offensive in any way, tell me I suck and that I need to do more work with existing methods - #region Misc + // (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 + #region Misc - /// - /// Returns a byte array of any length - /// Not really anything endian going on, but I struggled to find a better place for it - /// - public byte[] ReadBytes(byte[] buffer, int offset, int length) - { - return buffer.Skip(offset).Take(length).ToArray(); - } + /// + /// Returns a byte array of any length + /// Not really anything endian going on, but I struggled to find a better place for it + /// + public byte[] ReadBytes(byte[] buffer, int offset, int length) + { + return buffer.Skip(offset).Take(length).ToArray(); + } - /// - /// Returns an int32 value from any size byte array - /// (careful, data may/will be truncated) - /// - public int ReadIntValue(byte[] buffer, int offset, int length) - { - var bytes = buffer.Skip(offset).Take(length).ToArray(); + /// + /// Returns an int32 value from any size byte array + /// (careful, data may/will be truncated) + /// + public int ReadIntValue(byte[] buffer, int offset, int length) + { + var bytes = buffer.Skip(offset).Take(length).ToArray(); - if (swap) - Array.Reverse(bytes); + if (swap) + Array.Reverse(bytes); - if (length == 1) - return bytes.FirstOrDefault(); + if (length == 1) + return bytes.FirstOrDefault(); - if (length == 2) - return BitConverter.ToInt16(bytes, 0); + if (length == 2) + return BitConverter.ToInt16(bytes, 0); - int result = BitConverter.ToInt32(bytes, 0); - return result; - } + int result = BitConverter.ToInt32(bytes, 0); + return result; + } - #endregion - } + #endregion + } } diff --git a/BizHawk.Emulation.DiscSystem/CDFS/ISODirectoryNode.cs b/BizHawk.Emulation.DiscSystem/CDFS/ISODirectoryNode.cs index 2b40ebb9a0..78728d90d3 100644 --- a/BizHawk.Emulation.DiscSystem/CDFS/ISODirectoryNode.cs +++ b/BizHawk.Emulation.DiscSystem/CDFS/ISODirectoryNode.cs @@ -48,24 +48,24 @@ namespace BizHawk.Emulation.DiscSystem s.Seek(this.Offset * ISOFile.SECTOR_SIZE, SeekOrigin.Begin); List records = new List(); - - // Read the directory entries - while (s.Position < ((this.Offset * ISOFile.SECTOR_SIZE) + this.Length)) + + // Read the directory entries + while (s.Position < ((this.Offset * ISOFile.SECTOR_SIZE) + this.Length)) { ISONode node; ISONodeRecord record; - + // Read the record record = new ISONodeRecord(); - if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) - record.ParseCDInteractive(s); - if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) - record.ParseISO9660(s); + if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) + record.ParseCDInteractive(s); + if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) + record.ParseISO9660(s); - //zero 24-jun-2013 - improved validity checks - //theres nothing here! - if (record.Length == 0) + //zero 24-jun-2013 - improved validity checks + //theres nothing here! + if (record.Length == 0) { break; } @@ -98,8 +98,8 @@ namespace BizHawk.Emulation.DiscSystem } // Add the node as a child - if (!this.Children.ContainsKey(record.Name)) - this.Children.Add(record.Name, node); + if (!this.Children.ContainsKey(record.Name)) + this.Children.Add(record.Name, node); } } diff --git a/BizHawk.Emulation.DiscSystem/CDFS/ISOFile.cs b/BizHawk.Emulation.DiscSystem/CDFS/ISOFile.cs index 14cb54fe02..ed37f11971 100644 --- a/BizHawk.Emulation.DiscSystem/CDFS/ISOFile.cs +++ b/BizHawk.Emulation.DiscSystem/CDFS/ISOFile.cs @@ -6,47 +6,47 @@ using System.Linq; namespace BizHawk.Emulation.DiscSystem { - /// - /// This class is meant to parse disk images as specified by: - /// - /// ISO9660 - /// ------- - /// It should work for most disk images that are created - /// by the stanard disk imaging software. This class is by no means - /// robust to all variations of ISO9660. - /// Also, this class does not currently support the UDF file system. - /// - /// The information for building class came from three primary sources: - /// 1. The ISO9660 wikipedia article: - /// http://en.wikipedia.org/wiki/ISO_9660 - /// 2. ISO9660 Simplified for DOS/Windows - /// http://alumnus.caltech.edu/~pje/iso9660.html - /// 3. The ISO 9660 File System - /// http://users.telenet.be/it3.consultants.bvba/handouts/ISO9960.html - /// - /// - /// CD-I - /// ---- - /// (asni - 20171013) - Class modified to be able to detect and consume Green - /// Book disc images. - /// - /// 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 - /// the same ISO class structures can be returned for both standards. - /// These small additions are readily found in ISOVolumeDescriptor.cs - /// - /// ISOFile.cs also now contains a public 'ISOFormat' enum that is set - /// during disc parsing. - /// - /// The main reference source for this implementation: - /// 1. The CD-I Full Functional Specification (aka Green Book) - /// https://www.lscdweb.com/data/downloadables/2/8/cdi_may94_r2.pdf - /// - /// - /// TODO: Add functions to enumerate a directory or visit a file... - /// - /// - public class ISOFile + /// + /// This class is meant to parse disk images as specified by: + /// + /// ISO9660 + /// ------- + /// It should work for most disk images that are created + /// by the stanard disk imaging software. This class is by no means + /// robust to all variations of ISO9660. + /// Also, this class does not currently support the UDF file system. + /// + /// The information for building class came from three primary sources: + /// 1. The ISO9660 wikipedia article: + /// http://en.wikipedia.org/wiki/ISO_9660 + /// 2. ISO9660 Simplified for DOS/Windows + /// http://alumnus.caltech.edu/~pje/iso9660.html + /// 3. The ISO 9660 File System + /// http://users.telenet.be/it3.consultants.bvba/handouts/ISO9960.html + /// + /// + /// CD-I + /// ---- + /// (asni - 20171013) - Class modified to be able to detect and consume Green + /// Book disc images. + /// + /// 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 + /// the same ISO class structures can be returned for both standards. + /// These small additions are readily found in ISOVolumeDescriptor.cs + /// + /// ISOFile.cs also now contains a public 'ISOFormat' enum that is set + /// during disc parsing. + /// + /// The main reference source for this implementation: + /// 1. The CD-I Full Functional Specification (aka Green Book) + /// https://www.lscdweb.com/data/downloadables/2/8/cdi_may94_r2.pdf + /// + /// + /// TODO: Add functions to enumerate a directory or visit a file... + /// + /// + public class ISOFile { #region Constants @@ -55,36 +55,36 @@ namespace BizHawk.Emulation.DiscSystem /// public const int SECTOR_SIZE = 2048; - #endregion + #endregion - #region Static Members + #region Static Members - /// - /// Making this a static for now. Every other way I tried was fairly ineligant (asni) - /// - public static ISOFormat Format; + /// + /// Making this a static for now. Every other way I tried was fairly ineligant (asni) + /// + public static ISOFormat Format; - public static List CDIPathTable; + public static List CDIPathTable; - #endregion + #endregion - #region Public Members + #region Public Members - /// - /// This is a list of all the volume descriptors in the disk image. - /// NOTE: The first entry should be the primary volume. - /// - public List VolumeDescriptors; + /// + /// This is a list of all the volume descriptors in the disk image. + /// NOTE: The first entry should be the primary volume. + /// + public List VolumeDescriptors; /// /// The Directory that is the root of this file system /// public ISODirectoryNode Root; - /// - /// The type of CDFS format detected - /// - public ISOFormat CDFSType; + /// + /// The type of CDFS format detected + /// + public ISOFormat CDFSType; #endregion @@ -117,9 +117,9 @@ namespace BizHawk.Emulation.DiscSystem // Seek through the first volume descriptor s.Seek(startPosition + (SECTOR_SIZE * startSector), SeekOrigin.Begin); - - // Read one of more volume descriptors - do + + // Read one of more volume descriptors + do { //zero 24-jun-2013 - improved validity checks @@ -127,7 +127,7 @@ namespace BizHawk.Emulation.DiscSystem bool isValid = desc.Parse(s); if (!isValid) return false; - this.CDFSType = Format; + this.CDFSType = Format; if (desc.IsTerminator()) break; @@ -140,17 +140,17 @@ namespace BizHawk.Emulation.DiscSystem } while (true); - //zero 24-jun-2013 - well, my very first test iso had 2 volume descriptors. - // Check to make sure we only read one volume descriptor - // Finding more could be an error with the disk. - //if (this.VolumeDescriptors.Count != 1) { - // Console.WriteLine("Strange ISO format..."); - // return; - //} + //zero 24-jun-2013 - well, my very first test iso had 2 volume descriptors. + // Check to make sure we only read one volume descriptor + // Finding more could be an error with the disk. + //if (this.VolumeDescriptors.Count != 1) { + // Console.WriteLine("Strange ISO format..."); + // return; + //} - //zero 24-jun-2013 - if theres no volume descriptors, we're gonna call this not a cdfs - if (VolumeDescriptors.Count == 0) return false; + //zero 24-jun-2013 - if theres no volume descriptors, we're gonna call this not a cdfs + if (VolumeDescriptors.Count == 0) return false; // Visit all the directories and get the offset of each directory/file @@ -159,64 +159,64 @@ namespace BizHawk.Emulation.DiscSystem // Create (and visit) the root node this.Root = new ISODirectoryNode(this.VolumeDescriptors[0].RootDirectoryRecord); - - visitedNodes.Add(this.Root.Offset, this.Root); - this.Root.Parse(s, visitedNodes); + + visitedNodes.Add(this.Root.Offset, this.Root); + this.Root.Parse(s, visitedNodes); return true; } - private List> fileNodes; - private List dirsParsed; + private List> fileNodes; + private List dirsParsed; - /// - /// Returns a flat list of all recursed files - /// - public List> EnumerateAllFilesRecursively() - { - fileNodes = new List>(); - dirsParsed = new List(); + /// + /// Returns a flat list of all recursed files + /// + public List> EnumerateAllFilesRecursively() + { + fileNodes = new List>(); + dirsParsed = new List(); - if (Root.Children == null) - return fileNodes; + if (Root.Children == null) + return fileNodes; - // get all folders - var dirs = (from a in Root.Children where a.Value.GetType() == typeof(ISODirectoryNode) select a); - // iterate through each folder - foreach (var d in dirs) - { - // process all files in this directory (and recursively process files in sub folders - ISODirectoryNode idn = d.Value as ISODirectoryNode; - if (dirsParsed.Where(a => a == idn).Count() > 0) - continue; + // get all folders + var dirs = (from a in Root.Children where a.Value.GetType() == typeof(ISODirectoryNode) select a); + // iterate through each folder + foreach (var d in dirs) + { + // process all files in this directory (and recursively process files in sub folders + ISODirectoryNode idn = d.Value as ISODirectoryNode; + if (dirsParsed.Where(a => a == idn).Count() > 0) + continue; - dirsParsed.Add(idn); - ProcessDirectoryFiles(idn.Children); - } + dirsParsed.Add(idn); + ProcessDirectoryFiles(idn.Children); + } - return fileNodes.Distinct().ToList(); - } + return fileNodes.Distinct().ToList(); + } - private void ProcessDirectoryFiles(Dictionary idn) - { - foreach (var n in idn) - { - if (n.Value.GetType() == typeof(ISODirectoryNode)) - { - if (dirsParsed.Where(a => a == n.Value).Count() > 0) - continue; + private void ProcessDirectoryFiles(Dictionary idn) + { + foreach (var n in idn) + { + if (n.Value.GetType() == typeof(ISODirectoryNode)) + { + if (dirsParsed.Where(a => a == n.Value).Count() > 0) + continue; - dirsParsed.Add(n.Value as ISODirectoryNode); - ProcessDirectoryFiles((n.Value as ISODirectoryNode).Children); - } - else - { - KeyValuePair f = new KeyValuePair(n.Key, n.Value as ISOFileNode); - fileNodes.Add(f); - } - } - } + dirsParsed.Add(n.Value as ISODirectoryNode); + ProcessDirectoryFiles((n.Value as ISODirectoryNode).Children); + } + else + { + KeyValuePair f = new KeyValuePair(n.Key, n.Value as ISOFileNode); + fileNodes.Add(f); + } + } + } #endregion @@ -231,17 +231,17 @@ namespace BizHawk.Emulation.DiscSystem this.Root.Print(0); } - #endregion + #endregion - #region Misc + #region Misc - public enum ISOFormat - { - Unknown, - ISO9660, - CDInteractive - } + public enum ISOFormat + { + Unknown, + ISO9660, + CDInteractive + } - #endregion - } + #endregion + } } diff --git a/BizHawk.Emulation.DiscSystem/CDFS/ISONodeRecord.cs b/BizHawk.Emulation.DiscSystem/CDFS/ISONodeRecord.cs index 72bb82cfff..adb6d96be8 100644 --- a/BizHawk.Emulation.DiscSystem/CDFS/ISONodeRecord.cs +++ b/BizHawk.Emulation.DiscSystem/CDFS/ISONodeRecord.cs @@ -31,16 +31,16 @@ namespace BizHawk.Emulation.DiscSystem /// public byte Length; - /// - /// 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 - /// - public byte ExtendedAttribRecordLength; + /// + /// 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 + /// + public byte ExtendedAttribRecordLength; - /// - /// The file offset of the data for this file/directory (in sectors). - /// - public long OffsetOfData; + /// + /// The file offset of the data for this file/directory (in sectors). + /// + public long OffsetOfData; /// /// The length of the data for this file/directory (in bytes). /// @@ -155,11 +155,11 @@ namespace BizHawk.Emulation.DiscSystem MemoryStream s = new MemoryStream(data); s.Seek(cursor, SeekOrigin.Begin); - if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) - this.ParseISO9660(s); + if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) + this.ParseISO9660(s); - if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) - this.ParseCDInteractive(s); + if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) + this.ParseCDInteractive(s); } /// @@ -223,100 +223,100 @@ namespace BizHawk.Emulation.DiscSystem s.Seek(startPosition + this.Length, SeekOrigin.Begin); } - /// + /// /// Parse the node record from the given CD-I stream. /// /// The stream to parse from. public void ParseCDInteractive(Stream s) - { - /* - BP Size in bytes Description - 1 1 Record length - 2 1 Extended Attribute record length - 3 4 Reserved - 7 4 File beginning LBN - 11 4 Reserved - 15 4 File size - 19 6 Creation date - 25 1 Reserved - 26 1 File flags - 27 2 Interleave - 29 2 Reserved - 31 2 Album Set Sequence number - 33 1 File name size - 34 (n) File name - 34+n 4 Owner ID - 38+n 2 Attributes - 40+n 2 Reserved - 42+n 1 File number - 43+n 1 Reserved - 43+n Total - */ + { + /* + BP Size in bytes Description + 1 1 Record length + 2 1 Extended Attribute record length + 3 4 Reserved + 7 4 File beginning LBN + 11 4 Reserved + 15 4 File size + 19 6 Creation date + 25 1 Reserved + 26 1 File flags + 27 2 Interleave + 29 2 Reserved + 31 2 Album Set Sequence number + 33 1 File name size + 34 (n) File name + 34+n 4 Owner ID + 38+n 2 Attributes + 40+n 2 Reserved + 42+n 1 File number + 43+n 1 Reserved + 43+n Total + */ - EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); - EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); - long startPosition = s.Position; - byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; + EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); + EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); + long startPosition = s.Position; + byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; - // Read the entire structure - s.Read(buffer, 0, ISOFile.SECTOR_SIZE); - s.Position -= ISOFile.SECTOR_SIZE; + // Read the entire structure + s.Read(buffer, 0, ISOFile.SECTOR_SIZE); + s.Position -= ISOFile.SECTOR_SIZE; - // Get the record length - this.Length = buffer[0]; + // Get the record length + this.Length = buffer[0]; - // extended attribute record length - this.ExtendedAttribRecordLength = buffer[1]; + // extended attribute record length + this.ExtendedAttribRecordLength = buffer[1]; - // Read Data Offset - this.OffsetOfData = bcBig.ReadIntValue(buffer, 6, 4); + // Read Data Offset + this.OffsetOfData = bcBig.ReadIntValue(buffer, 6, 4); - // Read Data Length - this.LengthOfData = bcBig.ReadIntValue(buffer, 14, 4); + // Read Data Length + this.LengthOfData = bcBig.ReadIntValue(buffer, 14, 4); - // Read the time - var ti = bc.ReadBytes(buffer, 18, 6); - this.Year = ti[0]; - this.Month = ti[1]; - this.Day = ti[2]; - this.Hour = ti[3]; - this.Minute = ti[4]; - this.Second = ti[5]; + // Read the time + var ti = bc.ReadBytes(buffer, 18, 6); + this.Year = ti[0]; + this.Month = ti[1]; + this.Day = ti[2]; + this.Hour = ti[3]; + this.Minute = ti[4]; + 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 - this.NameLength = buffer[32]; + // Read the name length + this.NameLength = buffer[32]; - // Read the file/directory name - var name = bc.ReadBytes(buffer, 33, this.NameLength); - if (this.NameLength == 1 && (name[0] == 0 || name[0] == 1)) - { - if (name[0] == 0) - this.Name = ISONodeRecord.CURRENT_DIRECTORY; - else - this.Name = ISONodeRecord.PARENT_DIRECTORY; - } - else - { - this.Name = ASCIIEncoding.ASCII.GetString(name, 0, this.NameLength); - } + // Read the file/directory name + var name = bc.ReadBytes(buffer, 33, this.NameLength); + if (this.NameLength == 1 && (name[0] == 0 || name[0] == 1)) + { + if (name[0] == 0) + this.Name = ISONodeRecord.CURRENT_DIRECTORY; + else + this.Name = ISONodeRecord.PARENT_DIRECTORY; + } + else + { + 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) - // (confusingly these are called 'attributes' in CD-I. the CD-I 'File Flags' entry is something else entirely) - this.Flags = buffer[37 + this.NameLength]; + // 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) + this.Flags = buffer[37 + this.NameLength]; - // skip filenumber - //this.FileNumber = buffer[41 + this.NameLength]; + // skip filenumber + //this.FileNumber = buffer[41 + this.NameLength]; - // Seek to end - s.Seek(startPosition + this.Length, SeekOrigin.Begin); - } + // Seek to end + s.Seek(startPosition + this.Length, SeekOrigin.Begin); + } - #endregion - } + #endregion + } } diff --git a/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs b/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs index b3ee6f46a7..0f226f722d 100644 --- a/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs +++ b/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs @@ -25,21 +25,21 @@ namespace BizHawk.Emulation.DiscSystem private const int LENGTH_TIME = 17; private const int LENGTH_RESERVED = 512; - #endregion + #endregion - #region Private Properties + #region Private Properties - private EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); - private EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); + private EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); + private EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); - #endregion + #endregion - #region Public Properties + #region Public Properties - /// - /// The type of this volume description, only 1 and 255 are supported - /// - public byte Type; + /// + /// The type of this volume description, only 1 and 255 are supported + /// + public byte Type; /// /// The system identifier @@ -76,18 +76,18 @@ namespace BizHawk.Emulation.DiscSystem /// (ISO9660 only) Sector offset of the first path table /// public int OffsetOfFirstLittleEndianPathTable; - /// - /// (ISO9660 only) Sector offset of the second path table - /// - public int OffsetOfSecondLittleEndianPathTable; - /// - /// (ISO9660 only) Sector offset of the first path table - /// - public int OffsetOfFirstBigEndianPathTable; - /// - /// (ISO9660 only) Sector offset of the second path table - /// - public int OffsetOfSecondBigEndianPathTable; + /// + /// (ISO9660 only) Sector offset of the second path table + /// + public int OffsetOfSecondLittleEndianPathTable; + /// + /// (ISO9660 only) Sector offset of the first path table + /// + public int OffsetOfFirstBigEndianPathTable; + /// + /// (ISO9660 only) Sector offset of the second path table + /// + public int OffsetOfSecondBigEndianPathTable; /// /// The root directory record @@ -141,39 +141,39 @@ namespace BizHawk.Emulation.DiscSystem /// public byte[] EffectiveDateTime; - /// - /// (ISO9660 only) Extra reserved data - /// - public byte[] Reserved; + /// + /// (ISO9660 only) Extra reserved data + /// + public byte[] Reserved; - // CD-Interactive only - - /// - /// 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 - /// 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) - /// - public byte VolumeFlags; - /// - /// 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 - /// - public byte[] CodedCharSetIdent; - /// - /// The block address of the first block of the system Path Table is kept in this field - /// - public int AddressOfPathTable; + // CD-Interactive only + + /// + /// 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 + /// 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) + /// + public byte VolumeFlags; + /// + /// 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 + /// + public byte[] CodedCharSetIdent; + /// + /// The block address of the first block of the system Path Table is kept in this field + /// + public int AddressOfPathTable; - #endregion + #endregion - #region Construction + #region Construction - /// - /// Constructor. - /// - public ISOVolumeDescriptor() + /// + /// Constructor. + /// + public ISOVolumeDescriptor() { // Set everything to the default value this.Type = 0; @@ -211,10 +211,10 @@ namespace BizHawk.Emulation.DiscSystem this.Reserved = new byte[LENGTH_RESERVED]; - // CD-I specific - this.VolumeFlags = 0; - this.CodedCharSetIdent = new byte[LENGTH_SHORT_IDENTIFIER]; - this.AddressOfPathTable = 0; + // CD-I specific + this.VolumeFlags = 0; + this.CodedCharSetIdent = new byte[LENGTH_SHORT_IDENTIFIER]; + this.AddressOfPathTable = 0; } #endregion @@ -233,267 +233,267 @@ namespace BizHawk.Emulation.DiscSystem // Read the entire structure s.Read(buffer, 0, ISOFile.SECTOR_SIZE); - // Parse based on format - byte[] header = bc.ReadBytes(buffer, 0, ISOFile.SECTOR_SIZE); - if (GetISO9660(header)) - { - ParseISO9660(s); - return true; - } - if (GetCDI(header)) - { - ParseCDInteractive(s); - return true; - } + // Parse based on format + byte[] header = bc.ReadBytes(buffer, 0, ISOFile.SECTOR_SIZE); + if (GetISO9660(header)) + { + ParseISO9660(s); + return true; + } + if (GetCDI(header)) + { + ParseCDInteractive(s); + return true; + } - return false; + return false; } - public void ParseISO9660(Stream s) - { - long startPosition = s.Position; - byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; - s.Position = startPosition - ISOFile.SECTOR_SIZE; + public void ParseISO9660(Stream s) + { + long startPosition = s.Position; + byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; + s.Position = startPosition - ISOFile.SECTOR_SIZE; - // Read the entire structure - s.Read(buffer, 0, ISOFile.SECTOR_SIZE); + // Read the entire structure + s.Read(buffer, 0, ISOFile.SECTOR_SIZE); - // Get the type - this.Type = buffer[0]; + // Get the type + this.Type = buffer[0]; - // Handle the primary volume information - if (this.Type == 1) - { - int cursor = 8; - // Get the system identifier - Array.Copy(buffer, cursor, - this.SystemIdentifier, 0, LENGTH_SHORT_IDENTIFIER); - cursor += LENGTH_SHORT_IDENTIFIER; + // Handle the primary volume information + if (this.Type == 1) + { + int cursor = 8; + // Get the system identifier + Array.Copy(buffer, cursor, + this.SystemIdentifier, 0, LENGTH_SHORT_IDENTIFIER); + cursor += LENGTH_SHORT_IDENTIFIER; - // Get the volume identifier - Array.Copy(buffer, cursor, - this.VolumeIdentifier, 0, LENGTH_SHORT_IDENTIFIER); - cursor += LENGTH_SHORT_IDENTIFIER; + // Get the volume identifier + Array.Copy(buffer, cursor, + this.VolumeIdentifier, 0, LENGTH_SHORT_IDENTIFIER); + cursor += LENGTH_SHORT_IDENTIFIER; - cursor += 8; + cursor += 8; - // Get the total number of sectors - this.NumberOfSectors = bc.ToInt32(buffer, cursor); - cursor += 8; + // Get the total number of sectors + this.NumberOfSectors = bc.ToInt32(buffer, cursor); + cursor += 8; - cursor += 32; + cursor += 32; - this.VolumeSetSize = bc.ToInt16(buffer, cursor); - cursor += 4; - this.VolumeSequenceNumber = bc.ToInt16(buffer, cursor); - cursor += 4; - this.SectorSize = bc.ToInt16(buffer, cursor); - cursor += 4; + this.VolumeSetSize = bc.ToInt16(buffer, cursor); + cursor += 4; + this.VolumeSequenceNumber = bc.ToInt16(buffer, cursor); + cursor += 4; + this.SectorSize = bc.ToInt16(buffer, cursor); + cursor += 4; - this.PathTableSize = bc.ToInt32(buffer, cursor); - cursor += 8; - this.OffsetOfFirstLittleEndianPathTable = bc.ToInt32(buffer, cursor); - cursor += 4; - this.OffsetOfSecondLittleEndianPathTable = bc.ToInt32(buffer, cursor); - cursor += 4; - this.OffsetOfFirstLittleEndianPathTable = bcBig.ToInt32(buffer, cursor); - cursor += 4; - this.OffsetOfSecondLittleEndianPathTable = bcBig.ToInt32(buffer, cursor); - cursor += 4; + this.PathTableSize = bc.ToInt32(buffer, cursor); + cursor += 8; + this.OffsetOfFirstLittleEndianPathTable = bc.ToInt32(buffer, cursor); + cursor += 4; + this.OffsetOfSecondLittleEndianPathTable = bc.ToInt32(buffer, cursor); + cursor += 4; + this.OffsetOfFirstLittleEndianPathTable = bcBig.ToInt32(buffer, cursor); + cursor += 4; + this.OffsetOfSecondLittleEndianPathTable = bcBig.ToInt32(buffer, cursor); + cursor += 4; - this.RootDirectoryRecord.Parse(buffer, cursor); - cursor += LENGTH_ROOT_DIRECTORY_RECORD; + this.RootDirectoryRecord.Parse(buffer, cursor); + cursor += LENGTH_ROOT_DIRECTORY_RECORD; - Array.Copy(buffer, cursor, - this.VolumeSetIdentifier, 0, LENGTH_LONG_IDENTIFIER); - cursor += LENGTH_LONG_IDENTIFIER; - Array.Copy(buffer, cursor, - this.PublisherIdentifier, 0, LENGTH_LONG_IDENTIFIER); - cursor += LENGTH_LONG_IDENTIFIER; - Array.Copy(buffer, cursor, - this.DataPreparerIdentifier, 0, LENGTH_LONG_IDENTIFIER); - cursor += LENGTH_LONG_IDENTIFIER; - Array.Copy(buffer, cursor, - this.ApplicationIdentifier, 0, LENGTH_LONG_IDENTIFIER); - cursor += LENGTH_LONG_IDENTIFIER; + Array.Copy(buffer, cursor, + this.VolumeSetIdentifier, 0, LENGTH_LONG_IDENTIFIER); + cursor += LENGTH_LONG_IDENTIFIER; + Array.Copy(buffer, cursor, + this.PublisherIdentifier, 0, LENGTH_LONG_IDENTIFIER); + cursor += LENGTH_LONG_IDENTIFIER; + Array.Copy(buffer, cursor, + this.DataPreparerIdentifier, 0, LENGTH_LONG_IDENTIFIER); + cursor += LENGTH_LONG_IDENTIFIER; + Array.Copy(buffer, cursor, + this.ApplicationIdentifier, 0, LENGTH_LONG_IDENTIFIER); + cursor += LENGTH_LONG_IDENTIFIER; - Array.Copy(buffer, cursor, - this.CopyrightFileIdentifier, 0, LENGTH_IDENTIFIER); - cursor += LENGTH_IDENTIFIER; - Array.Copy(buffer, cursor, - this.AbstractFileIdentifier, 0, LENGTH_IDENTIFIER); - cursor += LENGTH_IDENTIFIER; - Array.Copy(buffer, cursor, - this.BibliographicalFileIdentifier, 0, LENGTH_IDENTIFIER); - cursor += LENGTH_IDENTIFIER; + Array.Copy(buffer, cursor, + this.CopyrightFileIdentifier, 0, LENGTH_IDENTIFIER); + cursor += LENGTH_IDENTIFIER; + Array.Copy(buffer, cursor, + this.AbstractFileIdentifier, 0, LENGTH_IDENTIFIER); + cursor += LENGTH_IDENTIFIER; + Array.Copy(buffer, cursor, + this.BibliographicalFileIdentifier, 0, LENGTH_IDENTIFIER); + cursor += LENGTH_IDENTIFIER; - Array.Copy(buffer, cursor, - this.VolumeCreationDateTime, 0, LENGTH_TIME); - cursor += LENGTH_TIME; - Array.Copy(buffer, cursor, - this.LastModifiedDateTime, 0, LENGTH_TIME); - cursor += LENGTH_TIME; - Array.Copy(buffer, cursor, - this.ExpirationDateTime, 0, LENGTH_TIME); - cursor += LENGTH_TIME; - Array.Copy(buffer, cursor, - this.EffectiveDateTime, 0, LENGTH_TIME); - cursor += LENGTH_TIME; + Array.Copy(buffer, cursor, + this.VolumeCreationDateTime, 0, LENGTH_TIME); + cursor += LENGTH_TIME; + Array.Copy(buffer, cursor, + this.LastModifiedDateTime, 0, LENGTH_TIME); + cursor += LENGTH_TIME; + Array.Copy(buffer, cursor, + this.ExpirationDateTime, 0, LENGTH_TIME); + cursor += LENGTH_TIME; + Array.Copy(buffer, cursor, + this.EffectiveDateTime, 0, LENGTH_TIME); + cursor += LENGTH_TIME; - cursor += 1; + cursor += 1; - cursor += 1; + cursor += 1; - Array.Copy(buffer, cursor, - this.Reserved, 0, LENGTH_RESERVED); - cursor += LENGTH_RESERVED; - } - } + Array.Copy(buffer, cursor, + this.Reserved, 0, LENGTH_RESERVED); + cursor += LENGTH_RESERVED; + } + } - public void ParseCDInteractive(Stream s) - { - /* From the Green Book Spec - * BP (byte position) obviously is n+1 - - BP Size in Bytes Description - 1 1 Disc Label Record Type - 2 5 Volume Structure Standard ID - 7 1 Volume Structure Version number - 8 1 Volume flags - 9 32 System identifier - 41 32 Volume identifier - 73 12 Reserved - 85 4 Volume space size - 89 32 Coded Character Set identifier - 121 2 Reserved - 123 2 Number of Volumes in Album - 125 2 Reserved - 127 2 Album Set Sequence number - 129 2 Reserved - 131 2 Logical Block size - 133 4 Reserved - 137 4 Path Table size - 141 8 Reserved - 149 4 Address of Path Table - 153 38 Reserved - 191 128 Album identifier - 319 128 Publisher identifier - 447 128 Data Preparer identifier - 575 128 Application identifier - 703 32 Copyright file name - 735 5 Reserved - 740 32 Abstract file name - 772 5 Reserved - 777 32 Bibliographic file name - 809 5 Reserved - 814 16 Creation date and time - 830 1 Reserved - 831 16 Modification date and time - 847 1 Reserved - 848 16 Expiration date and time - 864 1 Reserved - 865 16 Effective date and time - 881 1 Reserved - 882 1 File Structure Standard Version number - 883 1 Reserved - 884 512 Application use - 1396 653 Reserved */ + public void ParseCDInteractive(Stream s) + { + /* From the Green Book Spec + * BP (byte position) obviously is n+1 - long startPosition = s.Position; - byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; - s.Position = startPosition - ISOFile.SECTOR_SIZE; + BP Size in Bytes Description + 1 1 Disc Label Record Type + 2 5 Volume Structure Standard ID + 7 1 Volume Structure Version number + 8 1 Volume flags + 9 32 System identifier + 41 32 Volume identifier + 73 12 Reserved + 85 4 Volume space size + 89 32 Coded Character Set identifier + 121 2 Reserved + 123 2 Number of Volumes in Album + 125 2 Reserved + 127 2 Album Set Sequence number + 129 2 Reserved + 131 2 Logical Block size + 133 4 Reserved + 137 4 Path Table size + 141 8 Reserved + 149 4 Address of Path Table + 153 38 Reserved + 191 128 Album identifier + 319 128 Publisher identifier + 447 128 Data Preparer identifier + 575 128 Application identifier + 703 32 Copyright file name + 735 5 Reserved + 740 32 Abstract file name + 772 5 Reserved + 777 32 Bibliographic file name + 809 5 Reserved + 814 16 Creation date and time + 830 1 Reserved + 831 16 Modification date and time + 847 1 Reserved + 848 16 Expiration date and time + 864 1 Reserved + 865 16 Effective date and time + 881 1 Reserved + 882 1 File Structure Standard Version number + 883 1 Reserved + 884 512 Application use + 1396 653 Reserved */ - // Read the entire structure - s.Read(buffer, 0, ISOFile.SECTOR_SIZE); + long startPosition = s.Position; + byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; + s.Position = startPosition - ISOFile.SECTOR_SIZE; - // Get the type - this.Type = buffer[0]; + // Read the entire structure + s.Read(buffer, 0, ISOFile.SECTOR_SIZE); - // Handle the primary volume information - if (this.Type == 1) - { - this.VolumeFlags = buffer[7]; - this.SystemIdentifier = bc.ReadBytes(buffer, 8, LENGTH_SHORT_IDENTIFIER); - this.VolumeIdentifier = bc.ReadBytes(buffer, 40, LENGTH_SHORT_IDENTIFIER); - this.NumberOfSectors = bcBig.ReadIntValue(buffer, 84, 4); - this.CodedCharSetIdent = bc.ReadBytes(buffer, 88, LENGTH_SHORT_IDENTIFIER); - this.VolumeSetSize = bcBig.ReadIntValue(buffer, 122, 2); - this.VolumeSequenceNumber = bcBig.ReadIntValue(buffer, 126, 2); - this.SectorSize = bcBig.ReadIntValue(buffer, 130, 2); - this.PathTableSize = bcBig.ReadIntValue(buffer, 136, 4); - this.AddressOfPathTable = bcBig.ReadIntValue(buffer, 148, 4); + // Get the type + this.Type = buffer[0]; - this.VolumeSetIdentifier = bc.ReadBytes(buffer, 190, LENGTH_LONG_IDENTIFIER); - this.PublisherIdentifier = bc.ReadBytes(buffer, 318, LENGTH_LONG_IDENTIFIER); - this.DataPreparerIdentifier = bc.ReadBytes(buffer, 446, LENGTH_LONG_IDENTIFIER); - this.ApplicationIdentifier = bc.ReadBytes(buffer, 574, LENGTH_LONG_IDENTIFIER); + // Handle the primary volume information + if (this.Type == 1) + { + this.VolumeFlags = buffer[7]; + this.SystemIdentifier = bc.ReadBytes(buffer, 8, LENGTH_SHORT_IDENTIFIER); + this.VolumeIdentifier = bc.ReadBytes(buffer, 40, LENGTH_SHORT_IDENTIFIER); + this.NumberOfSectors = bcBig.ReadIntValue(buffer, 84, 4); + this.CodedCharSetIdent = bc.ReadBytes(buffer, 88, LENGTH_SHORT_IDENTIFIER); + this.VolumeSetSize = bcBig.ReadIntValue(buffer, 122, 2); + this.VolumeSequenceNumber = bcBig.ReadIntValue(buffer, 126, 2); + this.SectorSize = bcBig.ReadIntValue(buffer, 130, 2); + this.PathTableSize = bcBig.ReadIntValue(buffer, 136, 4); + this.AddressOfPathTable = bcBig.ReadIntValue(buffer, 148, 4); - this.CopyrightFileIdentifier = bc.ReadBytes(buffer, 702, LENGTH_SHORT_IDENTIFIER); - this.AbstractFileIdentifier = bc.ReadBytes(buffer, 739, LENGTH_SHORT_IDENTIFIER); - this.BibliographicalFileIdentifier = bc.ReadBytes(buffer, 776, LENGTH_SHORT_IDENTIFIER); + this.VolumeSetIdentifier = bc.ReadBytes(buffer, 190, LENGTH_LONG_IDENTIFIER); + this.PublisherIdentifier = bc.ReadBytes(buffer, 318, LENGTH_LONG_IDENTIFIER); + this.DataPreparerIdentifier = bc.ReadBytes(buffer, 446, LENGTH_LONG_IDENTIFIER); + this.ApplicationIdentifier = bc.ReadBytes(buffer, 574, LENGTH_LONG_IDENTIFIER); - this.VolumeCreationDateTime = bc.ReadBytes(buffer, 813, 16); - this.LastModifiedDateTime = bc.ReadBytes(buffer, 830, 16); - this.ExpirationDateTime = bc.ReadBytes(buffer, 847, 16); - this.EffectiveDateTime = bc.ReadBytes(buffer, 864, 16); + this.CopyrightFileIdentifier = bc.ReadBytes(buffer, 702, LENGTH_SHORT_IDENTIFIER); + this.AbstractFileIdentifier = bc.ReadBytes(buffer, 739, LENGTH_SHORT_IDENTIFIER); + this.BibliographicalFileIdentifier = bc.ReadBytes(buffer, 776, LENGTH_SHORT_IDENTIFIER); - // save current position - long pos = s.Position; - - // get path table records - s.Position = ISOFile.SECTOR_SIZE * this.AddressOfPathTable; - ISOFile.CDIPathTable = CDIPathNode.ParsePathTable(s, this.PathTableSize); + this.VolumeCreationDateTime = bc.ReadBytes(buffer, 813, 16); + this.LastModifiedDateTime = bc.ReadBytes(buffer, 830, 16); + this.ExpirationDateTime = bc.ReadBytes(buffer, 847, 16); + this.EffectiveDateTime = bc.ReadBytes(buffer, 864, 16); - // read the root dir record - s.Position = ISOFile.SECTOR_SIZE * ISOFile.CDIPathTable[0].DirectoryBlockAddress; - s.Read(buffer, 0, ISOFile.SECTOR_SIZE); - this.RootDirectoryRecord.Parse(buffer, 0); + // save current position + long pos = s.Position; + + // get path table records + s.Position = ISOFile.SECTOR_SIZE * this.AddressOfPathTable; + ISOFile.CDIPathTable = CDIPathNode.ParsePathTable(s, this.PathTableSize); - // go back to where we were - s.Position = pos; - } - } + // read the root dir record + s.Position = ISOFile.SECTOR_SIZE * ISOFile.CDIPathTable[0].DirectoryBlockAddress; + s.Read(buffer, 0, ISOFile.SECTOR_SIZE); + this.RootDirectoryRecord.Parse(buffer, 0); - /// - /// Detect ISO9660 - /// - public bool GetISO9660(byte[] buffer) - { - //zero 24-jun-2013 - validate ISO9660 - // "CD001\x01" - if (buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' && buffer[4] == '0' && buffer[5] == '1' && buffer[6] == 0x01) - { - ISOFile.Format = ISOFile.ISOFormat.ISO9660; - return true; - } + // go back to where we were + s.Position = pos; + } + } - return false; - } + /// + /// Detect ISO9660 + /// + public bool GetISO9660(byte[] buffer) + { + //zero 24-jun-2013 - validate ISO9660 + // "CD001\x01" + if (buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' && buffer[4] == '0' && buffer[5] == '1' && buffer[6] == 0x01) + { + ISOFile.Format = ISOFile.ISOFormat.ISO9660; + return true; + } - /// - /// Detect CD-I - /// - public bool GetCDI(byte[] buffer) - { - // CD-Interactive - if (Encoding.ASCII.GetString(bc.ReadBytes(buffer, 1, 5)).Contains("CD-I")) - { - ISOFile.Format = ISOFile.ISOFormat.CDInteractive; - return true; - } + return false; + } - return false; - } + /// + /// Detect CD-I + /// + public bool GetCDI(byte[] buffer) + { + // CD-Interactive + if (Encoding.ASCII.GetString(bc.ReadBytes(buffer, 1, 5)).Contains("CD-I")) + { + ISOFile.Format = ISOFile.ISOFormat.CDInteractive; + return true; + } - #endregion + return false; + } - #region Type Information + #endregion - /// - /// Returns true if this is the terminator volume descriptor. - /// - /// True if the terminator. - public bool IsTerminator() + #region Type Information + + /// + /// Returns true if this is the terminator volume descriptor. + /// + /// True if the terminator. + public bool IsTerminator() { return (this.Type == 255); } @@ -501,108 +501,108 @@ namespace BizHawk.Emulation.DiscSystem #endregion } - /// - /// Represents a Directory Path Table entry on a CD-I disc - /// - public class CDIPathNode - { - #region Public Properties + /// + /// Represents a Directory Path Table entry on a CD-I disc + /// + public class CDIPathNode + { + #region Public Properties - /// - /// The length of the directory name. - /// - public byte NameLength; + /// + /// The length of the directory name. + /// + public byte NameLength; - /// - /// This is the length of the Extended Attribute record - /// - public byte ExtendedAttribRecordLength; + /// + /// This is the length of the Extended Attribute record + /// + public byte ExtendedAttribRecordLength; - /// - /// This field contains the beginning logical block number (LBN) of the directory file on disc - /// - public int DirectoryBlockAddress; + /// + /// This field contains the beginning logical block number (LBN) of the directory file on disc + /// + public int DirectoryBlockAddress; - /// - /// This is the number (relative to the beginning of the Path Table) of this directory's parent - /// - public int ParentDirectoryNumber; + /// + /// This is the number (relative to the beginning of the Path Table) of this directory's parent + /// + public int ParentDirectoryNumber; - /// - /// The directory name. - /// 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. - /// The padding byte is not included in the name size field. - /// - public string Name; + /// + /// The directory name. + /// 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. + /// The padding byte is not included in the name size field. + /// + public string Name; - #endregion + #endregion - #region Construction + #region Construction - /// - /// Empty Constructor - /// - public CDIPathNode() - { + /// + /// Empty Constructor + /// + public CDIPathNode() + { - } + } - #endregion + #endregion - #region Parsing + #region Parsing - /* - BP Size in bytes Description - 1 1 Name size - 2 1 Extended Attribute record length - 3 4 Directory block address - 7 2 Parent Directory number - 9 n Directory file name - */ + /* + BP Size in bytes Description + 1 1 Name size + 2 1 Extended Attribute record length + 3 4 Directory block address + 7 2 Parent Directory number + 9 n Directory file name + */ - public static List ParsePathTable(Stream s, int PathTableSize) - { - EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); - EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); + public static List ParsePathTable(Stream s, int PathTableSize) + { + EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); + EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); - byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; + byte[] buffer = new byte[ISOFile.SECTOR_SIZE]; - // Read the entire structure - s.Read(buffer, 0, ISOFile.SECTOR_SIZE); + // Read the entire structure + s.Read(buffer, 0, ISOFile.SECTOR_SIZE); - int startCursor = 0; + int startCursor = 0; - List pathNodes = new List(); + List pathNodes = new List(); - int pad = 0; + int pad = 0; - do - { - CDIPathNode node = new CDIPathNode(); - byte[] data = bc.ReadBytes(buffer, startCursor, ISOFile.SECTOR_SIZE - startCursor); - node.NameLength = data[0]; + do + { + CDIPathNode node = new CDIPathNode(); + byte[] data = bc.ReadBytes(buffer, startCursor, ISOFile.SECTOR_SIZE - startCursor); + node.NameLength = data[0]; - node.ExtendedAttribRecordLength = data[1]; - node.DirectoryBlockAddress = bcBig.ReadIntValue(data, 2, 4); - node.ParentDirectoryNumber = bcBig.ReadIntValue(data, 6, 2); - node.Name = Encoding.ASCII.GetString(bc.ReadBytes(data, 8, data[0])); + node.ExtendedAttribRecordLength = data[1]; + node.DirectoryBlockAddress = bcBig.ReadIntValue(data, 2, 4); + node.ParentDirectoryNumber = bcBig.ReadIntValue(data, 6, 2); + node.Name = Encoding.ASCII.GetString(bc.ReadBytes(data, 8, data[0])); - // if nameLength is odd a padding byte must be added - - if (node.NameLength % 2 != 0) - pad = 1; + // if nameLength is odd a padding byte must be added + + if (node.NameLength % 2 != 0) + 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 + } } diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index 4023f114ba..8c051f8c17 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -8,522 +8,522 @@ using System.Runtime.InteropServices; namespace BizHawk.Emulation.DiscSystem { - /// - /// Parsing Alcohol 120% files - /// Info taken from: - /// * http://forum.redump.org/post/41803/#p41803 - /// * Libmirage image-mds parser - https://sourceforge.net/projects/cdemu/files/libmirage/ - /// * DiscImageChef - https://github.com/claunia/DiscImageChef/blob/master/DiscImageChef.DiscImages/Alcohol120.cs - /// + /// + /// Parsing Alcohol 120% files + /// Info taken from: + /// * http://forum.redump.org/post/41803/#p41803 + /// * Libmirage image-mds parser - https://sourceforge.net/projects/cdemu/files/libmirage/ + /// * DiscImageChef - https://github.com/claunia/DiscImageChef/blob/master/DiscImageChef.DiscImages/Alcohol120.cs + /// public class MDS_Format - { - /// - /// A loose representation of an Alcohol 120 .mds file (with a few extras) - /// - public class AFile - { - /// - /// Full path to the MDS file - /// - public string MDSPath; + { + /// + /// A loose representation of an Alcohol 120 .mds file (with a few extras) + /// + public class AFile + { + /// + /// Full path to the MDS file + /// + public string MDSPath; - /// - /// MDS Header - /// - public AHeader Header = new AHeader(); + /// + /// MDS Header + /// + public AHeader Header = new AHeader(); - /// - /// List of MDS session blocks - /// - public List Sessions = new List(); + /// + /// List of MDS session blocks + /// + public List Sessions = new List(); - /// - /// List of track blocks - /// - public List Tracks = new List(); + /// + /// List of track blocks + /// + public List Tracks = new List(); - /// - /// Current parsed session objects - /// - public List ParsedSession = new List(); + /// + /// Current parsed session objects + /// + public List ParsedSession = new List(); - /// - /// Calculated MDS TOC entries (still to be parsed into BizHawk) - /// - public List TOCEntries = new List(); - - } + /// + /// Calculated MDS TOC entries (still to be parsed into BizHawk) + /// + public List TOCEntries = new List(); + + } - public class AHeader - { - /// - /// Standard alcohol 120% signature - usually "MEDIA DESCRIPTOR" - /// - public string Signature; // 16 bytes + public class AHeader + { + /// + /// Standard alcohol 120% signature - usually "MEDIA DESCRIPTOR" + /// + public string Signature; // 16 bytes - /// - /// Alcohol version? - /// - public byte[] Version; // 2 bytes + /// + /// Alcohol version? + /// + public byte[] Version; // 2 bytes - /// - /// The medium type - /// * 0x00 - CD - /// * 0x01 - CD-R - /// * 0x02 - CD-RW - /// * 0x10 - DVD - /// * 0x12 - DVD-R - /// - public int Medium; + /// + /// The medium type + /// * 0x00 - CD + /// * 0x01 - CD-R + /// * 0x02 - CD-RW + /// * 0x10 - DVD + /// * 0x12 - DVD-R + /// + public int Medium; - /// - /// Number of sessions - /// - public int SessionCount; + /// + /// Number of sessions + /// + public int SessionCount; - /// - /// Burst Cutting Area length - /// - public int BCALength; + /// + /// Burst Cutting Area length + /// + public int BCALength; - /// - /// Burst Cutting Area data offset - /// - public Int64 BCAOffset; + /// + /// Burst Cutting Area data offset + /// + public Int64 BCAOffset; - /// - /// Offset to disc (DVD?) structures - /// - public Int64 StructureOffset; + /// + /// Offset to disc (DVD?) structures + /// + public Int64 StructureOffset; - /// - /// Offset to the first session block - /// - public Int64 SessionOffset; + /// + /// Offset to the first session block + /// + public Int64 SessionOffset; - /// - /// Data Position Measurement offset - /// - public Int64 DPMOffset; + /// + /// Data Position Measurement offset + /// + public Int64 DPMOffset; - /// - /// Parse mds stream for the header - /// - public AHeader Parse(Stream stream) - { - EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); - EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); - - byte[] header = new byte[88]; - stream.Read(header, 0, 88); + /// + /// Parse mds stream for the header + /// + public AHeader Parse(Stream stream) + { + EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); + EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); + + byte[] header = new byte[88]; + stream.Read(header, 0, 88); - this.Signature = Encoding.ASCII.GetString(header.Take(16).ToArray()); - this.Version = header.Skip(16).Take(2).ToArray(); - this.Medium = bc.ToInt16(header.Skip(18).Take(2).ToArray()); - this.SessionCount = bc.ToInt16(header.Skip(20).Take(2).ToArray()); - this.BCALength = bc.ToInt16(header.Skip(26).Take(2).ToArray()); - this.BCAOffset = bc.ToInt32(header.Skip(36).Take(4).ToArray()); - this.StructureOffset = bc.ToInt32(header.Skip(64).Take(4).ToArray()); - this.SessionOffset = bc.ToInt32(header.Skip(80).Take(4).ToArray()); - this.DPMOffset = bc.ToInt32(header.Skip(84).Take(4).ToArray()); + this.Signature = Encoding.ASCII.GetString(header.Take(16).ToArray()); + this.Version = header.Skip(16).Take(2).ToArray(); + this.Medium = bc.ToInt16(header.Skip(18).Take(2).ToArray()); + this.SessionCount = bc.ToInt16(header.Skip(20).Take(2).ToArray()); + this.BCALength = bc.ToInt16(header.Skip(26).Take(2).ToArray()); + this.BCAOffset = bc.ToInt32(header.Skip(36).Take(4).ToArray()); + this.StructureOffset = bc.ToInt32(header.Skip(64).Take(4).ToArray()); + this.SessionOffset = bc.ToInt32(header.Skip(80).Take(4).ToArray()); + this.DPMOffset = bc.ToInt32(header.Skip(84).Take(4).ToArray()); - return this; - } - } + return this; + } + } - /// - /// MDS session block representation - /// - public class ASession - { - public int SessionStart; /* Session's start address */ - public int SessionEnd; /* Session's end address */ - public int SessionNumber; /* Session number */ - public byte AllBlocks; /* Number of all data blocks. */ - public byte NonTrackBlocks; /* Number of lead-in data blocks */ - public int FirstTrack; /* First track in session */ - public int LastTrack; /* Last track in session */ - public Int64 TrackOffset; /* Offset of lead-in+regular track data blocks. */ - } + /// + /// MDS session block representation + /// + public class ASession + { + public int SessionStart; /* Session's start address */ + public int SessionEnd; /* Session's end address */ + public int SessionNumber; /* Session number */ + public byte AllBlocks; /* Number of all data blocks. */ + public byte NonTrackBlocks; /* Number of lead-in data blocks */ + public int FirstTrack; /* First track in session */ + public int LastTrack; /* Last track in session */ + public Int64 TrackOffset; /* Offset of lead-in+regular track data blocks. */ + } - /// - /// Representation of an MDS track block - /// For convenience (and extra confusion) this also holds the track extrablock, filename(footer) block infos - /// as well as the calculated image filepath as specified in the MDS file - /// - public class ATrack - { - /// - /// The specified data mode - /// 0x00 - None (no data) - /// 0x02 - DVD - /// 0xA9 - Audio - /// 0xAA - Mode1 - /// 0xAB - Mode2 - /// 0xAC - Mode2 Form1 - /// 0xAD - Mode2 Form2 - /// - public byte Mode; /* Track mode */ + /// + /// Representation of an MDS track block + /// For convenience (and extra confusion) this also holds the track extrablock, filename(footer) block infos + /// as well as the calculated image filepath as specified in the MDS file + /// + public class ATrack + { + /// + /// The specified data mode + /// 0x00 - None (no data) + /// 0x02 - DVD + /// 0xA9 - Audio + /// 0xAA - Mode1 + /// 0xAB - Mode2 + /// 0xAC - Mode2 Form1 + /// 0xAD - Mode2 Form2 + /// + public byte Mode; /* Track mode */ - /// - /// Subchannel mode for the track (0x00 = None, 0x08 = Interleaved) - /// - public byte SubMode; /* Subchannel mode */ + /// + /// Subchannel mode for the track (0x00 = None, 0x08 = Interleaved) + /// + public byte SubMode; /* Subchannel mode */ - /* These are the fields from Sub-channel Q information, which are + /* These are the fields from Sub-channel Q information, which are also returned in full TOC by READ TOC/PMA/ATIP command */ - public int ADR_Control; /* Adr/Ctl */ - public int TrackNo; /* Track number field */ - public int Point; /* Point field (= track number for track entries) */ - public int AMin; /* Min */ - public int ASec; /* Sec */ - public int AFrame; /* Frame */ - public int Zero; /* Zero */ - public int PMin; /* PMin */ - public int PSec; /* PSec */ - public int PFrame; /* PFrame */ + public int ADR_Control; /* Adr/Ctl */ + public int TrackNo; /* Track number field */ + public int Point; /* Point field (= track number for track entries) */ + public int AMin; /* Min */ + public int ASec; /* Sec */ + public int AFrame; /* Frame */ + public int Zero; /* Zero */ + public int PMin; /* PMin */ + public int PSec; /* PSec */ + public int PFrame; /* PFrame */ - public Int64 ExtraOffset; /* Start offset of this track's extra block. */ - public int SectorSize; /* Sector size. */ - public Int64 PLBA; /* Track start sector (PLBA). */ - public ulong StartOffset; /* Track start offset (from beginning of MDS file) */ - public Int64 Files; /* Number of filenames for this track */ - public Int64 FooterOffset; /* Start offset of footer (from beginning of MDS file) */ + public Int64 ExtraOffset; /* Start offset of this track's extra block. */ + public int SectorSize; /* Sector size. */ + public Int64 PLBA; /* Track start sector (PLBA). */ + public ulong StartOffset; /* Track start offset (from beginning of MDS file) */ + public Int64 Files; /* Number of filenames for this track */ + public Int64 FooterOffset; /* Start offset of footer (from beginning of MDS file) */ - /// - /// Track extra block - /// - public ATrackExtra ExtraBlock = new ATrackExtra(); + /// + /// Track extra block + /// + public ATrackExtra ExtraBlock = new ATrackExtra(); - /// - /// List of footer(filename) blocks for this track - /// - public List FooterBlocks = new List(); + /// + /// List of footer(filename) blocks for this track + /// + public List FooterBlocks = new List(); - /// - /// List of the calculated full paths to this track's image file - /// The MDS file itself may contain a filename, or just an *.extension - /// - public List ImageFileNamePaths = new List(); + /// + /// List of the calculated full paths to this track's image file + /// The MDS file itself may contain a filename, or just an *.extension + /// + public List ImageFileNamePaths = new List(); - public int BlobIndex; - } + public int BlobIndex; + } - /// - /// Extra track block - /// - public class ATrackExtra - { - public Int64 Pregap; /* Number of sectors in pregap. */ - public Int64 Sectors; /* Number of sectors in track. */ - } + /// + /// Extra track block + /// + public class ATrackExtra + { + public Int64 Pregap; /* Number of sectors in pregap. */ + public Int64 Sectors; /* Number of sectors in track. */ + } - /// - /// Footer (filename) block - potentially one for every track - /// - public class AFooter - { - public Int64 FilenameOffset; /* Start offset of image filename string (from beginning of mds file) */ - public Int64 WideChar; /* Seems to be set to 1 if widechar filename is used */ - } + /// + /// Footer (filename) block - potentially one for every track + /// + public class AFooter + { + public Int64 FilenameOffset; /* Start offset of image filename string (from beginning of mds file) */ + public Int64 WideChar; /* Seems to be set to 1 if widechar filename is used */ + } - /// - /// Represents a parsed MDS TOC entry - /// - public class ATOCEntry - { - public ATOCEntry(int entryNum) - { - EntryNum = entryNum; - } + /// + /// Represents a parsed MDS TOC entry + /// + public class ATOCEntry + { + public ATOCEntry(int entryNum) + { + EntryNum = entryNum; + } - /// - /// these should be 0-indexed - /// - public int EntryNum; + /// + /// these should be 0-indexed + /// + public int EntryNum; - /// - /// 1-indexed - the session that this entry belongs to - /// - public int Session; + /// + /// 1-indexed - the session that this entry belongs to + /// + public int Session; // /// // /// this seems just to be the LBA corresponding to AMIN:ASEC:AFRAME (give or take 150). It's not stored on the disc, and it's redundant. // /// // public int ALBA; - /// - /// this seems just to be the LBA corresponding to PMIN:PSEC:PFRAME (give or take 150). - /// - public int PLBA; + /// + /// this seems just to be the LBA corresponding to PMIN:PSEC:PFRAME (give or take 150). + /// + public int PLBA; - //these correspond pretty directly to values in the Q subchannel fields - //NOTE: they're specified as absolute MSF. That means, they're 2 seconds off from what they should be when viewed as final TOC values - public int ADR_Control; - public int TrackNo; - public int Point; - public int AMin; - public int ASec; - public int AFrame; - public int Zero; - public int PMin; - public int PSec; - public int PFrame; + //these correspond pretty directly to values in the Q subchannel fields + //NOTE: they're specified as absolute MSF. That means, they're 2 seconds off from what they should be when viewed as final TOC values + public int ADR_Control; + public int TrackNo; + public int Point; + public int AMin; + public int ASec; + public int AFrame; + public int Zero; + public int PMin; + public int PSec; + public int PFrame; - public int SectorSize; - public long TrackOffset; + public int SectorSize; + public long TrackOffset; - /// - /// List of the calculated full paths to this track's image file - /// The MDS file itself may contain a filename, or just an *.extension - /// - public List ImageFileNamePaths = new List(); + /// + /// List of the calculated full paths to this track's image file + /// The MDS file itself may contain a filename, or just an *.extension + /// + public List ImageFileNamePaths = new List(); - /// - /// Track extra block - /// - public ATrackExtra ExtraBlock = new ATrackExtra(); + /// + /// Track extra block + /// + public ATrackExtra ExtraBlock = new ATrackExtra(); - public int BlobIndex; - } + public int BlobIndex; + } - public AFile Parse(Stream stream) - { - EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); - EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); - bool isDvd = false; + public AFile Parse(Stream stream) + { + EndianBitConverter bc = EndianBitConverter.CreateForLittleEndian(); + EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); + bool isDvd = false; - AFile aFile = new AFile(); + AFile aFile = new AFile(); - aFile.MDSPath = (stream as FileStream).Name; + aFile.MDSPath = (stream as FileStream).Name; - stream.Seek(0, SeekOrigin.Begin); + stream.Seek(0, SeekOrigin.Begin); - // check whether the header in the mds file is long enough - if (stream.Length < 88) throw new MDSParseException("Malformed MDS format: The descriptor file does not appear to be long enough."); + // check whether the header in the mds file is long enough + if (stream.Length < 88) throw new MDSParseException("Malformed MDS format: The descriptor file does not appear to be long enough."); - // parse header - aFile.Header = aFile.Header.Parse(stream); + // parse header + aFile.Header = aFile.Header.Parse(stream); - // check version to make sure this is only v1.x - // currently NO support for version 2.x + // check version to make sure this is only v1.x + // currently NO support for version 2.x - if (aFile.Header.Version[0] > 1) - { - throw new MDSParseException($"MDS Parse Error: Only MDS version 1.x is supported!\nDetected version: {aFile.Header.Version[0]}.{aFile.Header.Version[1]}"); - } + if (aFile.Header.Version[0] > 1) + { + throw new MDSParseException($"MDS Parse Error: Only MDS version 1.x is supported!\nDetected version: {aFile.Header.Version[0]}.{aFile.Header.Version[1]}"); + } - // parse sessions - Dictionary aSessions = new Dictionary(); + // parse sessions + Dictionary aSessions = new Dictionary(); - stream.Seek(aFile.Header.SessionOffset, SeekOrigin.Begin); - for (int se = 0; se < aFile.Header.SessionCount; se++) - { - byte[] sessionHeader = new byte[24]; - stream.Read(sessionHeader, 0, 24); - //sessionHeader.Reverse().ToArray(); + stream.Seek(aFile.Header.SessionOffset, SeekOrigin.Begin); + for (int se = 0; se < aFile.Header.SessionCount; se++) + { + byte[] sessionHeader = new byte[24]; + stream.Read(sessionHeader, 0, 24); + //sessionHeader.Reverse().ToArray(); - ASession session = new ASession(); + ASession session = new ASession(); - session.SessionStart = bc.ToInt32(sessionHeader.Take(4).ToArray()); - session.SessionEnd = bc.ToInt32(sessionHeader.Skip(4).Take(4).ToArray()); - session.SessionNumber = bc.ToInt16(sessionHeader.Skip(8).Take(2).ToArray()); - session.AllBlocks = sessionHeader[10]; - session.NonTrackBlocks = sessionHeader[11]; - session.FirstTrack = bc.ToInt16(sessionHeader.Skip(12).Take(2).ToArray()); - session.LastTrack = bc.ToInt16(sessionHeader.Skip(14).Take(2).ToArray()); - session.TrackOffset = bc.ToInt32(sessionHeader.Skip(20).Take(4).ToArray()); + session.SessionStart = bc.ToInt32(sessionHeader.Take(4).ToArray()); + session.SessionEnd = bc.ToInt32(sessionHeader.Skip(4).Take(4).ToArray()); + session.SessionNumber = bc.ToInt16(sessionHeader.Skip(8).Take(2).ToArray()); + session.AllBlocks = sessionHeader[10]; + session.NonTrackBlocks = sessionHeader[11]; + session.FirstTrack = bc.ToInt16(sessionHeader.Skip(12).Take(2).ToArray()); + session.LastTrack = bc.ToInt16(sessionHeader.Skip(14).Take(2).ToArray()); + session.TrackOffset = bc.ToInt32(sessionHeader.Skip(20).Take(4).ToArray()); - //mdsf.Sessions.Add(session); - aSessions.Add(session.SessionNumber, session); - } + //mdsf.Sessions.Add(session); + aSessions.Add(session.SessionNumber, session); + } - long footerOffset = 0; + long footerOffset = 0; - // parse track blocks - Dictionary aTracks = new Dictionary(); + // parse track blocks + Dictionary aTracks = new Dictionary(); - // iterate through each session block - foreach (ASession session in aSessions.Values) - { - stream.Seek(session.TrackOffset, SeekOrigin.Begin); - //Dictionary sessionToc = new Dictionary(); + // iterate through each session block + foreach (ASession session in aSessions.Values) + { + stream.Seek(session.TrackOffset, SeekOrigin.Begin); + //Dictionary sessionToc = new Dictionary(); - // iterate through every block specified in each session - for (int bl = 0; bl < session.AllBlocks; bl++) - { - byte[] trackHeader; - ATrack track = new ATrack(); + // iterate through every block specified in each session + for (int bl = 0; bl < session.AllBlocks; bl++) + { + byte[] trackHeader; + ATrack track = new ATrack(); - trackHeader = new byte[80]; + trackHeader = new byte[80]; - stream.Read(trackHeader, 0, 80); + stream.Read(trackHeader, 0, 80); - track.Mode = trackHeader[0]; - track.SubMode = trackHeader[1]; - track.ADR_Control = trackHeader[2]; - track.TrackNo = trackHeader[3]; - track.Point = trackHeader[4]; - track.AMin = trackHeader[5]; - track.ASec = trackHeader[6]; - track.AFrame = trackHeader[7]; - track.Zero = trackHeader[8]; - track.PMin = trackHeader[9]; - track.PSec = trackHeader[10]; - track.PFrame = trackHeader[11]; - track.ExtraOffset = bc.ToInt32(trackHeader.Skip(12).Take(4).ToArray()); - track.SectorSize = bc.ToInt16(trackHeader.Skip(16).Take(2).ToArray()); - track.PLBA = bc.ToInt32(trackHeader.Skip(36).Take(4).ToArray()); - track.StartOffset = BitConverter.ToUInt64(trackHeader.Skip(40).Take(8).ToArray(), 0); - track.Files = bc.ToInt32(trackHeader.Skip(48).Take(4).ToArray()); - track.FooterOffset = bc.ToInt32(trackHeader.Skip(52).Take(4).ToArray()); + track.Mode = trackHeader[0]; + track.SubMode = trackHeader[1]; + track.ADR_Control = trackHeader[2]; + track.TrackNo = trackHeader[3]; + track.Point = trackHeader[4]; + track.AMin = trackHeader[5]; + track.ASec = trackHeader[6]; + track.AFrame = trackHeader[7]; + track.Zero = trackHeader[8]; + track.PMin = trackHeader[9]; + track.PSec = trackHeader[10]; + track.PFrame = trackHeader[11]; + track.ExtraOffset = bc.ToInt32(trackHeader.Skip(12).Take(4).ToArray()); + track.SectorSize = bc.ToInt16(trackHeader.Skip(16).Take(2).ToArray()); + track.PLBA = bc.ToInt32(trackHeader.Skip(36).Take(4).ToArray()); + track.StartOffset = BitConverter.ToUInt64(trackHeader.Skip(40).Take(8).ToArray(), 0); + track.Files = bc.ToInt32(trackHeader.Skip(48).Take(4).ToArray()); + track.FooterOffset = bc.ToInt32(trackHeader.Skip(52).Take(4).ToArray()); - if (track.Mode == 0x02) - { - isDvd = true; - throw new MDSParseException("DVD Detected. Not currently supported!"); - } - + if (track.Mode == 0x02) + { + isDvd = true; + throw new MDSParseException("DVD Detected. Not currently supported!"); + } + - // check for track extra block - this can probably be handled in a separate loop, - // but I'll just store the current stream position then seek forward to the extra block for this track - Int64 currPos = stream.Position; + // check for track extra block - this can probably be handled in a separate loop, + // but I'll just store the current stream position then seek forward to the extra block for this track + Int64 currPos = stream.Position; - // Only CDs have extra blocks - for DVDs ExtraOffset = track length - if (track.ExtraOffset > 0 && !isDvd) - { - byte[] extHeader = new byte[8]; - stream.Seek(track.ExtraOffset, SeekOrigin.Begin); - stream.Read(extHeader, 0, 8); - track.ExtraBlock.Pregap = bc.ToInt32(extHeader.Take(4).ToArray()); - track.ExtraBlock.Sectors = bc.ToInt32(extHeader.Skip(4).Take(4).ToArray()); - stream.Seek(currPos, SeekOrigin.Begin); - } - else if (isDvd == true) - { - track.ExtraBlock.Sectors = track.ExtraOffset; - } + // Only CDs have extra blocks - for DVDs ExtraOffset = track length + if (track.ExtraOffset > 0 && !isDvd) + { + byte[] extHeader = new byte[8]; + stream.Seek(track.ExtraOffset, SeekOrigin.Begin); + stream.Read(extHeader, 0, 8); + track.ExtraBlock.Pregap = bc.ToInt32(extHeader.Take(4).ToArray()); + track.ExtraBlock.Sectors = bc.ToInt32(extHeader.Skip(4).Take(4).ToArray()); + stream.Seek(currPos, SeekOrigin.Begin); + } + else if (isDvd == true) + { + track.ExtraBlock.Sectors = track.ExtraOffset; + } - // read the footer/filename block for this track - currPos = stream.Position; - long numOfFilenames = track.Files; - for (long fi = 1; fi <= numOfFilenames; fi++) - { - // skip leadin/out info tracks - if (track.FooterOffset == 0) - continue; + // read the footer/filename block for this track + currPos = stream.Position; + long numOfFilenames = track.Files; + for (long fi = 1; fi <= numOfFilenames; fi++) + { + // skip leadin/out info tracks + if (track.FooterOffset == 0) + continue; - byte[] foot = new byte[16]; - stream.Seek(track.FooterOffset, SeekOrigin.Begin); - stream.Read(foot, 0, 16); + byte[] foot = new byte[16]; + stream.Seek(track.FooterOffset, SeekOrigin.Begin); + stream.Read(foot, 0, 16); - AFooter f = new AFooter(); - f.FilenameOffset = bc.ToInt32(foot.Take(4).ToArray()); - f.WideChar = bc.ToInt32(foot.Skip(4).Take(4).ToArray()); - track.FooterBlocks.Add(f); - track.FooterBlocks = track.FooterBlocks.Distinct().ToList(); + AFooter f = new AFooter(); + f.FilenameOffset = bc.ToInt32(foot.Take(4).ToArray()); + f.WideChar = bc.ToInt32(foot.Skip(4).Take(4).ToArray()); + track.FooterBlocks.Add(f); + track.FooterBlocks = track.FooterBlocks.Distinct().ToList(); - // parse the filename string - string fileName = "*.mdf"; - if (f.FilenameOffset > 0) - { - // filename offset is present - stream.Seek(f.FilenameOffset, SeekOrigin.Begin); - byte[] fname; + // parse the filename string + string fileName = "*.mdf"; + if (f.FilenameOffset > 0) + { + // filename offset is present + stream.Seek(f.FilenameOffset, SeekOrigin.Begin); + byte[] fname; - if (numOfFilenames == 1) - { - if (aFile.Header.DPMOffset == 0) - { - // filename is in the remaining space to EOF - fname = new byte[stream.Length - stream.Position]; - } - else - { - // filename is in the remaining space to EOF + dpm offset - fname = new byte[aFile.Header.DPMOffset - stream.Position]; - } - } + if (numOfFilenames == 1) + { + if (aFile.Header.DPMOffset == 0) + { + // filename is in the remaining space to EOF + fname = new byte[stream.Length - stream.Position]; + } + else + { + // filename is in the remaining space to EOF + dpm offset + fname = new byte[aFile.Header.DPMOffset - stream.Position]; + } + } - else - { - // looks like each filename string is 6 bytes with a trailing \0 - fname = new byte[6]; - } - + else + { + // looks like each filename string is 6 bytes with a trailing \0 + fname = new byte[6]; + } + - // read the filename - stream.Read(fname, 0, fname.Length); + // read the filename + stream.Read(fname, 0, fname.Length); - // if widechar is 1 filename is stored using 16-bit, otherwise 8-bit is used - if (f.WideChar == 1) - fileName = Encoding.Unicode.GetString(fname).TrimEnd('\0'); - else - fileName = Encoding.Default.GetString(fname).TrimEnd('\0'); - } + // if widechar is 1 filename is stored using 16-bit, otherwise 8-bit is used + if (f.WideChar == 1) + fileName = Encoding.Unicode.GetString(fname).TrimEnd('\0'); + else + fileName = Encoding.Default.GetString(fname).TrimEnd('\0'); + } - else - { - // assume an MDF file with the same name as the MDS - } + else + { + // assume an MDF file with the same name as the MDS + } - string dir = Path.GetDirectoryName(aFile.MDSPath); + string dir = Path.GetDirectoryName(aFile.MDSPath); - if (f.FilenameOffset == 0 || - string.Compare(fileName, "*.mdf", StringComparison.InvariantCultureIgnoreCase) == 0) - { - fileName = $@"{dir}\{Path.GetFileNameWithoutExtension(aFile.MDSPath)}.mdf"; - } - else - { - fileName = $@"{dir}\{fileName}"; - } + if (f.FilenameOffset == 0 || + string.Compare(fileName, "*.mdf", StringComparison.InvariantCultureIgnoreCase) == 0) + { + fileName = $@"{dir}\{Path.GetFileNameWithoutExtension(aFile.MDSPath)}.mdf"; + } + else + { + fileName = $@"{dir}\{fileName}"; + } - track.ImageFileNamePaths.Add(fileName); - track.ImageFileNamePaths = track.ImageFileNamePaths.Distinct().ToList(); - } + track.ImageFileNamePaths.Add(fileName); + track.ImageFileNamePaths = track.ImageFileNamePaths.Distinct().ToList(); + } - stream.Position = currPos; + stream.Position = currPos; - aTracks.Add(track.Point, track); - aFile.Tracks.Add(track); + aTracks.Add(track.Point, track); + aFile.Tracks.Add(track); - if (footerOffset == 0) - footerOffset = track.FooterOffset; - } - } + if (footerOffset == 0) + footerOffset = track.FooterOffset; + } + } - - // build custom session object - aFile.ParsedSession = new List(); - foreach (var s in aSessions.Values) - { - Session session = new Session(); - ATrack startTrack; - ATrack endTrack; + + // build custom session object + aFile.ParsedSession = new List(); + foreach (var s in aSessions.Values) + { + Session session = new Session(); + ATrack startTrack; + ATrack endTrack; - if (!aTracks.TryGetValue(s.FirstTrack, out startTrack)) - { - break; - } + if (!aTracks.TryGetValue(s.FirstTrack, out startTrack)) + { + break; + } - if (!aTracks.TryGetValue(s.LastTrack, out endTrack)) - { - break; - } + if (!aTracks.TryGetValue(s.LastTrack, out endTrack)) + { + break; + } - session.StartSector = startTrack.PLBA; - session.StartTrack = s.FirstTrack; - session.SessionSequence = s.SessionNumber; - session.EndSector = endTrack.PLBA + endTrack.ExtraBlock.Sectors - 1; - session.EndTrack = s.LastTrack; + session.StartSector = startTrack.PLBA; + session.StartTrack = s.FirstTrack; + session.SessionSequence = s.SessionNumber; + session.EndSector = endTrack.PLBA + endTrack.ExtraBlock.Sectors - 1; + session.EndTrack = s.LastTrack; - aFile.ParsedSession.Add(session); - } + aFile.ParsedSession.Add(session); + } // now build the TOC object foreach (var se in aFile.ParsedSession) @@ -553,350 +553,350 @@ namespace BizHawk.Emulation.DiscSystem }); } - return aFile; - } + return aFile; + } - /// - /// Custom session object - /// - public class Session - { - public long StartSector; - public int StartTrack; - public int SessionSequence; - public long EndSector; - public int EndTrack; - } + /// + /// Custom session object + /// + public class Session + { + public long StartSector; + public int StartTrack; + public int SessionSequence; + public long EndSector; + public int EndTrack; + } - public class MDSParseException : Exception - { - public MDSParseException(string message) : base(message) { } - } - + public class MDSParseException : Exception + { + public MDSParseException(string message) : base(message) { } + } + - public class LoadResults - { - public List RawTOCEntries; - public AFile ParsedMDSFile; - public bool Valid; - public Exception FailureException; - public string MdsPath; - } + public class LoadResults + { + public List RawTOCEntries; + public AFile ParsedMDSFile; + public bool Valid; + public Exception FailureException; + public string MdsPath; + } - public static LoadResults LoadMDSPath(string path) - { - LoadResults ret = new LoadResults(); - ret.MdsPath = path; - //ret.MdfPath = Path.ChangeExtension(path, ".mdf"); - try - { - if (!File.Exists(path)) throw new MDSParseException("Malformed MDS format: nonexistent MDS file!"); + public static LoadResults LoadMDSPath(string path) + { + LoadResults ret = new LoadResults(); + ret.MdsPath = path; + //ret.MdfPath = Path.ChangeExtension(path, ".mdf"); + try + { + if (!File.Exists(path)) throw new MDSParseException("Malformed MDS format: nonexistent MDS file!"); - AFile mdsf; - using (var infMDS = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) - mdsf = new MDS_Format().Parse(infMDS); + AFile mdsf; + using (var infMDS = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) + mdsf = new MDS_Format().Parse(infMDS); - ret.ParsedMDSFile = mdsf; + ret.ParsedMDSFile = mdsf; - ret.Valid = true; - } - catch (MDSParseException ex) - { - ret.FailureException = ex; - } + ret.Valid = true; + } + catch (MDSParseException ex) + { + ret.FailureException = ex; + } - return ret; - } + return ret; + } - Dictionary MountBlobs(AFile mdsf, Disc disc) - { - Dictionary BlobIndex = new Dictionary(); + Dictionary MountBlobs(AFile mdsf, Disc disc) + { + Dictionary BlobIndex = new Dictionary(); - int count = 0; - foreach (var track in mdsf.Tracks) - { - foreach (var file in track.ImageFileNamePaths.Distinct()) - { - if (!File.Exists(file)) - throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}"); + int count = 0; + foreach (var track in mdsf.Tracks) + { + foreach (var file in track.ImageFileNamePaths.Distinct()) + { + if (!File.Exists(file)) + throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}"); - IBlob mdfBlob = null; - long mdfLen = -1; + IBlob mdfBlob = null; + long mdfLen = -1; - //mount the file - if (mdfBlob == null) - { - var mdfFile = new Disc.Blob_RawFile() { PhysicalPath = file }; - mdfLen = mdfFile.Length; - mdfBlob = mdfFile; - } + //mount the file + if (mdfBlob == null) + { + var mdfFile = new Disc.Blob_RawFile() { PhysicalPath = file }; + mdfLen = mdfFile.Length; + mdfBlob = mdfFile; + } - bool dupe = false; - foreach (var re in disc.DisposableResources) - { - if (re.ToString() == mdfBlob.ToString()) - dupe = true; - } + bool dupe = false; + foreach (var re in disc.DisposableResources) + { + if (re.ToString() == mdfBlob.ToString()) + dupe = true; + } - if (!dupe) - { - // wrap in zeropadadapter - disc.DisposableResources.Add(mdfBlob); - BlobIndex[count++] = mdfBlob; - } - } - } + if (!dupe) + { + // wrap in zeropadadapter + disc.DisposableResources.Add(mdfBlob); + BlobIndex[count++] = mdfBlob; + } + } + } - return BlobIndex; - } + return BlobIndex; + } - RawTOCEntry EmitRawTOCEntry(ATOCEntry entry) - { - BCD2 tno, ino; + RawTOCEntry EmitRawTOCEntry(ATOCEntry entry) + { + BCD2 tno, ino; - //this should actually be zero. im not sure if this is stored as BCD2 or not - tno = BCD2.FromDecimal(entry.TrackNo); + //this should actually be zero. im not sure if this is stored as BCD2 or not + tno = BCD2.FromDecimal(entry.TrackNo); - //these are special values.. I think, taken from this: - //http://www.staff.uni-mainz.de/tacke/scsi/SCSI2-14.html - //the CCD will contain Points as decimal values except for these specially converted decimal values which should stay as BCD. - //Why couldn't they all be BCD? I don't know. I guess because BCD is inconvenient, but only A0 and friends have special meaning. It's confusing. - ino = BCD2.FromDecimal(entry.Point); - if (entry.Point == 0xA0) ino.BCDValue = 0xA0; - else if (entry.Point == 0xA1) ino.BCDValue = 0xA1; - else if (entry.Point == 0xA2) ino.BCDValue = 0xA2; + //these are special values.. I think, taken from this: + //http://www.staff.uni-mainz.de/tacke/scsi/SCSI2-14.html + //the CCD will contain Points as decimal values except for these specially converted decimal values which should stay as BCD. + //Why couldn't they all be BCD? I don't know. I guess because BCD is inconvenient, but only A0 and friends have special meaning. It's confusing. + ino = BCD2.FromDecimal(entry.Point); + if (entry.Point == 0xA0) ino.BCDValue = 0xA0; + else if (entry.Point == 0xA1) ino.BCDValue = 0xA1; + else if (entry.Point == 0xA2) ino.BCDValue = 0xA2; - // get ADR & Control from ADR_Control byte - byte adrc = Convert.ToByte(entry.ADR_Control); - var Control = adrc & 0x0F; - var ADR = adrc >> 4; + // get ADR & Control from ADR_Control byte + byte adrc = Convert.ToByte(entry.ADR_Control); + var Control = adrc & 0x0F; + var ADR = adrc >> 4; - var q = new SubchannelQ - { - q_status = SubchannelQ.ComputeStatus(ADR, (EControlQ)(Control & 0xF)), - q_tno = tno, - q_index = ino, - min = BCD2.FromDecimal(entry.AMin), - sec = BCD2.FromDecimal(entry.ASec), - frame = BCD2.FromDecimal(entry.AFrame), - zero = (byte)entry.Zero, - ap_min = BCD2.FromDecimal(entry.PMin), - ap_sec = BCD2.FromDecimal(entry.PSec), - ap_frame = BCD2.FromDecimal(entry.PFrame), - q_crc = 0, //meaningless - }; + var q = new SubchannelQ + { + q_status = SubchannelQ.ComputeStatus(ADR, (EControlQ)(Control & 0xF)), + q_tno = tno, + q_index = ino, + min = BCD2.FromDecimal(entry.AMin), + sec = BCD2.FromDecimal(entry.ASec), + frame = BCD2.FromDecimal(entry.AFrame), + zero = (byte)entry.Zero, + ap_min = BCD2.FromDecimal(entry.PMin), + ap_sec = BCD2.FromDecimal(entry.PSec), + ap_frame = BCD2.FromDecimal(entry.PFrame), + q_crc = 0, //meaningless + }; - return new RawTOCEntry { QData = q }; - } + return new RawTOCEntry { QData = q }; + } - /// - /// Loads a MDS at the specified path to a Disc object - /// - public Disc LoadMDSToDisc(string mdsPath, DiscMountPolicy IN_DiscMountPolicy) - { - var loadResults = LoadMDSPath(mdsPath); - if (!loadResults.Valid) - throw loadResults.FailureException; + /// + /// Loads a MDS at the specified path to a Disc object + /// + public Disc LoadMDSToDisc(string mdsPath, DiscMountPolicy IN_DiscMountPolicy) + { + var loadResults = LoadMDSPath(mdsPath); + if (!loadResults.Valid) + throw loadResults.FailureException; - Disc disc = new Disc(); + Disc disc = new Disc(); - // load all blobs - Dictionary BlobIndex = MountBlobs(loadResults.ParsedMDSFile, disc); + // load all blobs + Dictionary BlobIndex = MountBlobs(loadResults.ParsedMDSFile, disc); - var mdsf = loadResults.ParsedMDSFile; - - //generate DiscTOCRaw items from the ones specified in the MDS file - disc.RawTOCEntries = new List(); - foreach (var entry in mdsf.TOCEntries) - { - disc.RawTOCEntries.Add(EmitRawTOCEntry(entry)); - } + var mdsf = loadResults.ParsedMDSFile; + + //generate DiscTOCRaw items from the ones specified in the MDS file + disc.RawTOCEntries = new List(); + foreach (var entry in mdsf.TOCEntries) + { + disc.RawTOCEntries.Add(EmitRawTOCEntry(entry)); + } - //analyze the RAWTocEntries to figure out what type of track track 1 is - var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = disc.RawTOCEntries }; - tocSynth.Run(); + //analyze the RAWTocEntries to figure out what type of track track 1 is + var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = disc.RawTOCEntries }; + tocSynth.Run(); - // now build the sectors - int currBlobIndex = 0; - foreach (var session in mdsf.ParsedSession) - { - for (int i = session.StartTrack; i <= session.EndTrack; i++) - { - int relMSF = -1; + // now build the sectors + int currBlobIndex = 0; + foreach (var session in mdsf.ParsedSession) + { + for (int i = session.StartTrack; i <= session.EndTrack; i++) + { + int relMSF = -1; - var track = mdsf.TOCEntries.Where(t => t.Point == i).FirstOrDefault(); - if (track == null) - break; + var track = mdsf.TOCEntries.Where(t => t.Point == i).FirstOrDefault(); + if (track == null) + break; - // ignore the info entries - if (track.Point == 0xA0 || - track.Point == 0xA1 || - track.Point == 0xA2) - { - continue; - } + // ignore the info entries + if (track.Point == 0xA0 || + track.Point == 0xA1 || + track.Point == 0xA2) + { + continue; + } - // get the blob(s) for this track - // its probably a safe assumption that there will be only one blob per track, - // but i'm still not 100% sure on this - var tr = (from a in mdsf.TOCEntries - where a.Point == i - select a).FirstOrDefault(); + // get the blob(s) for this track + // its probably a safe assumption that there will be only one blob per track, + // but i'm still not 100% sure on this + var tr = (from a in mdsf.TOCEntries + where a.Point == i + select a).FirstOrDefault(); - if (tr == null) - throw new MDSParseException("BLOB Error!"); + if (tr == null) + throw new MDSParseException("BLOB Error!"); - List blobstrings = new List(); - foreach (var t in tr.ImageFileNamePaths) - { - if (!blobstrings.Contains(t)) - blobstrings.Add(t); - } + List blobstrings = new List(); + foreach (var t in tr.ImageFileNamePaths) + { + if (!blobstrings.Contains(t)) + blobstrings.Add(t); + } - var tBlobs = (from a in tr.ImageFileNamePaths - select a).ToList(); + var tBlobs = (from a in tr.ImageFileNamePaths + select a).ToList(); - if (tBlobs.Count < 1) - throw new MDSParseException("BLOB Error!"); + if (tBlobs.Count < 1) + throw new MDSParseException("BLOB Error!"); - // is the currBlob valid for this track, or do we need to increment? - string bString = tBlobs.First(); + // is the currBlob valid for this track, or do we need to increment? + string bString = tBlobs.First(); - IBlob mdfBlob = null; - - // check for track pregap and create if neccessary - // this is specified in the track extras block - if (track.ExtraBlock.Pregap > 0) - { - CUE.CueTrackType pregapTrackType = CUE.CueTrackType.Audio; - if (tocSynth.Result.TOCItems[1].IsData) - { - if (tocSynth.Result.Session1Format == SessionFormat.Type20_CDXA) - pregapTrackType = CUE.CueTrackType.Mode2_2352; - else if (tocSynth.Result.Session1Format == SessionFormat.Type10_CDI) - pregapTrackType = CUE.CueTrackType.CDI_2352; - else if (tocSynth.Result.Session1Format == SessionFormat.Type00_CDROM_CDDA) - pregapTrackType = CUE.CueTrackType.Mode1_2352; - } - for (int pre = 0; pre < track.ExtraBlock.Pregap; pre++) - { - relMSF++; + IBlob mdfBlob = null; + + // check for track pregap and create if neccessary + // this is specified in the track extras block + if (track.ExtraBlock.Pregap > 0) + { + CUE.CueTrackType pregapTrackType = CUE.CueTrackType.Audio; + if (tocSynth.Result.TOCItems[1].IsData) + { + if (tocSynth.Result.Session1Format == SessionFormat.Type20_CDXA) + pregapTrackType = CUE.CueTrackType.Mode2_2352; + else if (tocSynth.Result.Session1Format == SessionFormat.Type10_CDI) + pregapTrackType = CUE.CueTrackType.CDI_2352; + else if (tocSynth.Result.Session1Format == SessionFormat.Type00_CDROM_CDDA) + pregapTrackType = CUE.CueTrackType.Mode1_2352; + } + for (int pre = 0; pre < track.ExtraBlock.Pregap; pre++) + { + relMSF++; - var ss_gap = new CUE.SS_Gap() - { - Policy = IN_DiscMountPolicy, - TrackType = pregapTrackType - }; - disc._Sectors.Add(ss_gap); + var ss_gap = new CUE.SS_Gap() + { + Policy = IN_DiscMountPolicy, + TrackType = pregapTrackType + }; + disc._Sectors.Add(ss_gap); - int qRelMSF = pre - Convert.ToInt32(track.ExtraBlock.Pregap); + int qRelMSF = pre - Convert.ToInt32(track.ExtraBlock.Pregap); - //tweak relMSF due to ambiguity/contradiction in yellowbook docs - if (!IN_DiscMountPolicy.CUE_PregapContradictionModeA) - qRelMSF++; + //tweak relMSF due to ambiguity/contradiction in yellowbook docs + if (!IN_DiscMountPolicy.CUE_PregapContradictionModeA) + qRelMSF++; - //setup subQ - byte ADR = 1; //absent some kind of policy for how to set it, this is a safe assumption: - ss_gap.sq.SetStatus(ADR, tocSynth.Result.TOCItems[1].Control); - ss_gap.sq.q_tno = BCD2.FromDecimal(1); - ss_gap.sq.q_index = BCD2.FromDecimal(0); - ss_gap.sq.AP_Timestamp = pre; - ss_gap.sq.Timestamp = qRelMSF; + //setup subQ + byte ADR = 1; //absent some kind of policy for how to set it, this is a safe assumption: + ss_gap.sq.SetStatus(ADR, tocSynth.Result.TOCItems[1].Control); + ss_gap.sq.q_tno = BCD2.FromDecimal(1); + ss_gap.sq.q_index = BCD2.FromDecimal(0); + ss_gap.sq.AP_Timestamp = pre; + ss_gap.sq.Timestamp = qRelMSF; - //setup subP - ss_gap.Pause = true; - } - // pregap processing completed - } + //setup subP + ss_gap.Pause = true; + } + // pregap processing completed + } - // create track sectors - long currBlobOffset = track.TrackOffset; - for (long sector = session.StartSector; sector <= session.EndSector; sector++) - { - CUE.SS_Base sBase = null; + // create track sectors + long currBlobOffset = track.TrackOffset; + for (long sector = session.StartSector; sector <= session.EndSector; sector++) + { + CUE.SS_Base sBase = null; - // get the current blob from the BlobIndex - Disc.Blob_RawFile currBlob = BlobIndex[currBlobIndex] as Disc.Blob_RawFile; - long currBlobLength = currBlob.Length; - long currBlobPosition = sector; - if (currBlobPosition == currBlobLength) - currBlobIndex++; - mdfBlob = disc.DisposableResources[currBlobIndex] as Disc.Blob_RawFile; + // get the current blob from the BlobIndex + Disc.Blob_RawFile currBlob = BlobIndex[currBlobIndex] as Disc.Blob_RawFile; + long currBlobLength = currBlob.Length; + long currBlobPosition = sector; + if (currBlobPosition == currBlobLength) + currBlobIndex++; + mdfBlob = disc.DisposableResources[currBlobIndex] as Disc.Blob_RawFile; - //int userSector = 2048; - switch (track.SectorSize) - { - case 2448: - sBase = new CUE.SS_2352() - { - Policy = IN_DiscMountPolicy - }; - //userSector = 2352; - break; - case 2048: - default: - sBase = new CUE.SS_Mode1_2048() - { - Policy = IN_DiscMountPolicy - }; - //userSector = 2048; - break; - - //throw new Exception($"Not supported: Sector Size {track.SectorSize}"); - } + //int userSector = 2048; + switch (track.SectorSize) + { + case 2448: + sBase = new CUE.SS_2352() + { + Policy = IN_DiscMountPolicy + }; + //userSector = 2352; + break; + case 2048: + default: + sBase = new CUE.SS_Mode1_2048() + { + Policy = IN_DiscMountPolicy + }; + //userSector = 2048; + break; + + //throw new Exception($"Not supported: Sector Size {track.SectorSize}"); + } - // configure blob - sBase.Blob = mdfBlob; - sBase.BlobOffset = currBlobOffset; + // configure blob + sBase.Blob = mdfBlob; + sBase.BlobOffset = currBlobOffset; - currBlobOffset += track.SectorSize; // userSector; - - // add subchannel data - relMSF++; - BCD2 tno, ino; + currBlobOffset += track.SectorSize; // userSector; + + // add subchannel data + relMSF++; + BCD2 tno, ino; - //this should actually be zero. im not sure if this is stored as BCD2 or not - tno = BCD2.FromDecimal(track.TrackNo); + //this should actually be zero. im not sure if this is stored as BCD2 or not + tno = BCD2.FromDecimal(track.TrackNo); - //these are special values.. I think, taken from this: - //http://www.staff.uni-mainz.de/tacke/scsi/SCSI2-14.html - //the CCD will contain Points as decimal values except for these specially converted decimal values which should stay as BCD. - //Why couldn't they all be BCD? I don't know. I guess because BCD is inconvenient, but only A0 and friends have special meaning. It's confusing. - ino = BCD2.FromDecimal(track.Point); - if (track.Point == 0xA0) ino.BCDValue = 0xA0; - else if (track.Point == 0xA1) ino.BCDValue = 0xA1; - else if (track.Point == 0xA2) ino.BCDValue = 0xA2; + //these are special values.. I think, taken from this: + //http://www.staff.uni-mainz.de/tacke/scsi/SCSI2-14.html + //the CCD will contain Points as decimal values except for these specially converted decimal values which should stay as BCD. + //Why couldn't they all be BCD? I don't know. I guess because BCD is inconvenient, but only A0 and friends have special meaning. It's confusing. + ino = BCD2.FromDecimal(track.Point); + if (track.Point == 0xA0) ino.BCDValue = 0xA0; + else if (track.Point == 0xA1) ino.BCDValue = 0xA1; + else if (track.Point == 0xA2) ino.BCDValue = 0xA2; - // get ADR & Control from ADR_Control byte - byte adrc = Convert.ToByte(track.ADR_Control); - var Control = adrc & 0x0F; - var ADR = adrc >> 4; + // get ADR & Control from ADR_Control byte + byte adrc = Convert.ToByte(track.ADR_Control); + var Control = adrc & 0x0F; + var ADR = adrc >> 4; - var q = new SubchannelQ - { - q_status = SubchannelQ.ComputeStatus(ADR, (EControlQ)(Control & 0xF)), - q_tno = BCD2.FromDecimal(track.Point), - q_index = ino, - AP_Timestamp = disc._Sectors.Count, - Timestamp = relMSF - Convert.ToInt32(track.ExtraBlock.Pregap) - }; + var q = new SubchannelQ + { + q_status = SubchannelQ.ComputeStatus(ADR, (EControlQ)(Control & 0xF)), + q_tno = BCD2.FromDecimal(track.Point), + q_index = ino, + AP_Timestamp = disc._Sectors.Count, + Timestamp = relMSF - Convert.ToInt32(track.ExtraBlock.Pregap) + }; - sBase.sq = q; + sBase.sq = q; - disc._Sectors.Add(sBase); - - } - } - } + disc._Sectors.Add(sBase); + + } + } + } - return disc; - } + return disc; + } - } //class MDS_Format + } //class MDS_Format } diff --git a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index e4fe3c2f74..98486527eb 100644 --- a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -53,45 +53,45 @@ namespace BizHawk.Emulation.DiscSystem /// PCFX, - /// - /// By Panasonic - /// - Panasonic3DO, + /// + /// By Panasonic + /// + Panasonic3DO, - /// - /// Philips - /// - CDi, + /// + /// Philips + /// + CDi, - /// - /// Nintendo Gamecube - /// - GameCube, + /// + /// Nintendo Gamecube + /// + GameCube, - /// - /// Nintendo Wii - /// - Wii, + /// + /// Nintendo Wii + /// + Wii, - /// - /// SNK NeoGeo - /// - NeoGeoCD, + /// + /// SNK NeoGeo + /// + NeoGeoCD, - /// - /// Bandai Playdia - /// - Playdia, + /// + /// Bandai Playdia + /// + Playdia, - /// - /// Either CDTV or CD32 (I havent found a reliable way of distinguishing between them yet -asni) - /// - Amiga, + /// + /// Either CDTV or CD32 (I havent found a reliable way of distinguishing between them yet -asni) + /// + Amiga, - /// - /// Sega Dreamcast - /// - Dreamcast + /// + /// Sega Dreamcast + /// + Dreamcast } public class DiscIdentifier @@ -121,19 +121,19 @@ namespace BizHawk.Emulation.DiscSystem if (DetectPCFX()) return DiscType.PCFX; - if (DetectTurboCD()) - return DiscType.TurboCD; + if (DetectTurboCD()) + return DiscType.TurboCD; - //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) - if (!_disc.TOC.TOCItems[1].IsData) + //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) + if (!_disc.TOC.TOCItems[1].IsData) return DiscType.AudioDisc; // if (_dsr.ReadLBA_Mode(_disc.TOC.TOCItems[1].LBA) == 0) // 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 - //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()) return DiscType.SegaSaturn; @@ -145,79 +145,79 @@ namespace BizHawk.Emulation.DiscSystem if (DetectPSX()) return DiscType.SonyPSX; - if (Detect3DO()) - return DiscType.Panasonic3DO; + if (Detect3DO()) + return DiscType.Panasonic3DO; - if (DetectCDi()) - return DiscType.CDi; + if (DetectCDi()) + return DiscType.CDi; - if (DetectGameCube()) - return DiscType.GameCube; + if (DetectGameCube()) + return DiscType.GameCube; - if (DetectWii()) - return DiscType.Wii; + if (DetectWii()) + return DiscType.Wii; - var discView = EDiscStreamView.DiscStreamView_Mode1_2048; + var discView = EDiscStreamView.DiscStreamView_Mode1_2048; if (_disc.TOC.Session1Format == SessionFormat.Type20_CDXA) discView = EDiscStreamView.DiscStreamView_Mode2_Form1_2048; var iso = new ISOFile(); bool isIso = iso.Parse(new DiscStream(_disc, discView, 0)); - if (!isIso) - { - // its much quicker to detect dreamcast from ISO data. Only do this if ISO is not detected - if (DetectDreamcast()) - return DiscType.Dreamcast; - } + if (!isIso) + { + // its much quicker to detect dreamcast from ISO data. Only do this if ISO is not detected + if (DetectDreamcast()) + return DiscType.Dreamcast; + } - //*** 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) + //*** 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) if (isIso) { 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 - //but, some PSX games (junky rips) don't have the 'licensed by string' so we'll hope they get caught here - if (appId == "PLAYSTATION") + //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 + if (appId == "PLAYSTATION") return DiscType.SonyPSX; if (appId == "PSP GAME") return DiscType.SonyPSP; - // in case the appId is not set correctly... - if (iso.Root.Children.Where(a => a.Key == "PSP_GAME").FirstOrDefault().Value as ISODirectoryNode != null) - return DiscType.SonyPSP; + // in case the appId is not set correctly... + if (iso.Root.Children.Where(a => a.Key == "PSP_GAME").FirstOrDefault().Value as ISODirectoryNode != null) + return DiscType.SonyPSP; - if (sysId == "SEGA SEGASATURN") - return DiscType.SegaSaturn; + if (sysId == "SEGA SEGASATURN") + return DiscType.SegaSaturn; - if (sysId.Contains("SEGAKATANA")) - return DiscType.Dreamcast; + if (sysId.Contains("SEGAKATANA")) + return DiscType.Dreamcast; - if (sysId == "MEGA_CD") - return DiscType.MegaCD; + if (sysId == "MEGA_CD") + return DiscType.MegaCD; - if (sysId == "ASAHI-CDV") - return DiscType.Playdia; + if (sysId == "ASAHI-CDV") + return DiscType.Playdia; - if (sysId == "CDTV" || sysId == "AMIGA") - return DiscType.Amiga; - foreach (var f in iso.Root.Children) - if (f.Key.ToLower().Contains("cd32")) - return DiscType.Amiga; + if (sysId == "CDTV" || sysId == "AMIGA") + return DiscType.Amiga; + foreach (var f in iso.Root.Children) + if (f.Key.ToLower().Contains("cd32")) + return DiscType.Amiga; - // NeoGeoCD Check - var absTxt = iso.Root.Children.Where(a => a.Key.Contains("ABS.TXT")).ToList(); - if (absTxt.Count > 0) - { - if (SectorContains("abstracted by snk", Convert.ToInt32(absTxt.First().Value.Offset))) - return DiscType.NeoGeoCD; - } - + // NeoGeoCD Check + var absTxt = iso.Root.Children.Where(a => a.Key.Contains("ABS.TXT")).ToList(); + if (absTxt.Count > 0) + { + if (SectorContains("abstracted by snk", Convert.ToInt32(absTxt.First().Value.Offset))) + return DiscType.NeoGeoCD; + } + - return DiscType.UnknownCDFS; - } + return DiscType.UnknownCDFS; + } return DiscType.UnknownFormat; } @@ -256,87 +256,87 @@ namespace BizHawk.Emulation.DiscSystem 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)) return true; } return false; } - //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 - //track 01 being Audio. Not tested, but presumably PCFX has the same issue - bool DetectTurboCD() - { - var toc = _disc.TOC; - for (int t = toc.FirstRecordedTrackNumber; - t <= toc.LastRecordedTrackNumber; - t++) - { - var track = _disc.TOC.TOCItems[t]; - //asni - pcfx games also contain the 'PC Engine' string - if ((track.IsData && SectorContains("pc engine", track.LBA + 1) && !SectorContains("pc-fx", track.LBA + 1))) - return true; - } - return false; - } + //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 + //track 01 being Audio. Not tested, but presumably PCFX has the same issue + bool DetectTurboCD() + { + var toc = _disc.TOC; + for (int t = toc.FirstRecordedTrackNumber; + t <= toc.LastRecordedTrackNumber; + t++) + { + var track = _disc.TOC.TOCItems[t]; + //asni - pcfx games also contain the 'PC Engine' string + if ((track.IsData && SectorContains("pc engine", track.LBA + 1) && !SectorContains("pc-fx", track.LBA + 1))) + return true; + } + return false; + } - bool Detect3DO() - { - var toc = _disc.TOC; - for (int t = toc.FirstRecordedTrackNumber; - t <= toc.LastRecordedTrackNumber; - t++) - { - var track = _disc.TOC.TOCItems[t]; - if (track.IsData && SectorContains("iamaduckiamaduck", track.LBA)) - return true; - } - return false; - } + bool Detect3DO() + { + var toc = _disc.TOC; + for (int t = toc.FirstRecordedTrackNumber; + t <= toc.LastRecordedTrackNumber; + t++) + { + var track = _disc.TOC.TOCItems[t]; + if (track.IsData && SectorContains("iamaduckiamaduck", track.LBA)) + return true; + } + return false; + } - //asni - slightly longer running than the others due to its brute-force nature. Should run later in the method - bool DetectDreamcast() - { - for (int i = 0; i < 1000; i++) - { - if (SectorContains("segakatana", i)) - return true; - } + //asni - slightly longer running than the others due to its brute-force nature. Should run later in the method + bool DetectDreamcast() + { + for (int i = 0; i < 1000; i++) + { + if (SectorContains("segakatana", i)) + return true; + } - return false; - } + return false; + } - bool DetectCDi() - { - return StringAt("CD-RTOS", 8, 16); - } + bool DetectCDi() + { + return StringAt("CD-RTOS", 8, 16); + } - bool DetectGameCube() - { - var data = ReadSectorCached(0); - if (data == null) return false; - byte[] magic = data.Skip(28).Take(4).ToArray(); - string hexString = ""; - foreach (var b in magic) - hexString += b.ToString("X2"); + bool DetectGameCube() + { + var data = ReadSectorCached(0); + if (data == null) return false; + byte[] magic = data.Skip(28).Take(4).ToArray(); + string hexString = ""; + foreach (var b in magic) + hexString += b.ToString("X2"); - return hexString == "C2339F3D"; - } + return hexString == "C2339F3D"; + } - bool DetectWii() - { - var data = ReadSectorCached(0); - if (data == null) return false; - byte[] magic = data.Skip(24).Take(4).ToArray(); - string hexString = ""; - foreach (var b in magic) - hexString += b.ToString("X2"); + bool DetectWii() + { + var data = ReadSectorCached(0); + if (data == null) return false; + byte[] magic = data.Skip(24).Take(4).ToArray(); + string hexString = ""; + foreach (var b in magic) + 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 //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); } - private bool SectorContains(string s, int lba = 0) - { - var data = ReadSectorCached(lba); - if (data == null) return false; - return System.Text.Encoding.ASCII.GetString(data).ToLower().Contains(s.ToLower()); - } + private bool SectorContains(string s, int lba = 0) + { + var data = ReadSectorCached(lba); + if (data == null) return false; + return System.Text.Encoding.ASCII.GetString(data).ToLower().Contains(s.ToLower()); + } } } \ No newline at end of file diff --git a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs index a2597e0d55..a2be4dfa49 100644 --- a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs +++ b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs @@ -186,11 +186,11 @@ namespace BizHawk.Emulation.DiscSystem CCD_Format ccdLoader = new CCD_Format(); OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy); } - else if (ext == ".mds") - { - MDS_Format mdsLoader = new MDS_Format(); - OUT_Disc = mdsLoader.LoadMDSToDisc(IN_FromPath, IN_DiscMountPolicy); - } + else if (ext == ".mds") + { + MDS_Format mdsLoader = new MDS_Format(); + OUT_Disc = mdsLoader.LoadMDSToDisc(IN_FromPath, IN_DiscMountPolicy); + } DONE: diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs index 4b0c14564e..a261a93629 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs @@ -103,8 +103,8 @@ namespace BizHawk.Bizware.BizwareGL sampler0.Set(tex); Owner.SetViewport(OutputSize); - float time = DateTime.Now.Second + (float)DateTime.Now.Millisecond / 1000; - Pipeline["Time"].Set(time); + float time = DateTime.Now.Second + (float)DateTime.Now.Millisecond / 1000; + Pipeline["Time"].Set(time); int w = OutputSize.Width; int h = OutputSize.Height; diff --git a/attic/MOS 6502/MOS6502.cs b/attic/MOS 6502/MOS6502.cs index 091eb245b9..36163b5e67 100644 --- a/attic/MOS 6502/MOS6502.cs +++ b/attic/MOS 6502/MOS6502.cs @@ -4,58 +4,58 @@ using System.IO; namespace BizHawk.Emulation.CPUs.M6502 { - public sealed partial class MOS6502 - { - public MOS6502() - { - //InitTableNZ(); - Reset(); - } + public sealed partial class MOS6502 + { + public MOS6502() + { + //InitTableNZ(); + Reset(); + } /* - private byte[] TableNZ; - private void InitTableNZ() - { - TableNZ = new byte[256]; - for (int i = 0; i < 256; i++) - { - byte b = 0; - if (i == 0) b |= 0x02; - if (i > 127) b |= 0x80; - TableNZ[i] = b; - } - }*/ + private byte[] TableNZ; + private void InitTableNZ() + { + TableNZ = new byte[256]; + for (int i = 0; i < 256; i++) + { + byte b = 0; + if (i == 0) b |= 0x02; + if (i > 127) b |= 0x80; + TableNZ[i] = b; + } + }*/ public bool debug; public bool throw_unhandled; - public void Reset() - { - A = 0; - X = 0; - Y = 0; - P = 0; - S = 0; - PC = 0; - PendingCycles = 0; - TotalExecutedCycles = 0; - } + public void Reset() + { + A = 0; + X = 0; + Y = 0; + P = 0; + S = 0; + PC = 0; + PendingCycles = 0; + TotalExecutedCycles = 0; + } - public string State() - { - int notused; - 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 val = a + b + " "; - if (FlagN) val = val + "N"; - if (FlagV) val = val + "V"; - if (FlagT) val = val + "T"; - if (FlagB) val = val + "B"; - if (FlagD) val = val + "D"; - if (FlagI) val = val + "I"; - if (FlagZ) val = val + "Z"; - if (FlagC) val = val + "C"; - return val; - } + public string State() + { + int notused; + 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 val = a + b + " "; + if (FlagN) val = val + "N"; + if (FlagV) val = val + "V"; + if (FlagT) val = val + "T"; + if (FlagB) val = val + "B"; + if (FlagD) val = val + "D"; + if (FlagI) val = val + "I"; + if (FlagZ) val = val + "Z"; + if (FlagC) val = val + "C"; + return val; + } public const ushort NMIVector = 0xFFFA; public const ushort ResetVector = 0xFFFC; @@ -92,17 +92,17 @@ namespace BizHawk.Emulation.CPUs.M6502 PendingCycles -= 7; } - // ==== CPU State ==== + // ==== CPU State ==== - public byte A; - public byte X; - public byte Y; - public byte P; - public ushort PC; - public byte S; + public byte A; + public byte X; + public byte Y; + public byte P; + public ushort PC; + public byte S; - public bool IRQ; - public bool NMI; + public bool IRQ; + public bool NMI; public bool CLI_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 LoadStateBinary(BinaryReader reader) { SyncState(Serializer.CreateBinaryReader(reader)); } - // ==== End State ==== + // ==== End State ==== - /// Carry Flag - private bool FlagC - { - get { return (P & 0x01) != 0; } - set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); } - } + /// Carry Flag + private bool FlagC + { + get { return (P & 0x01) != 0; } + set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); } + } - /// Zero Flag - private bool FlagZ - { - get { return (P & 0x02) != 0; } - set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); } - } + /// Zero Flag + private bool FlagZ + { + get { return (P & 0x02) != 0; } + set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); } + } - /// Interrupt Disable Flag - public bool FlagI - { - get { return (P & 0x04) != 0; } - set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); } - } + /// Interrupt Disable Flag + public bool FlagI + { + get { return (P & 0x04) != 0; } + set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); } + } - /// Decimal Mode Flag - private bool FlagD - { - get { return (P & 0x08) != 0; } - set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); } - } + /// Decimal Mode Flag + private bool FlagD + { + get { return (P & 0x08) != 0; } + set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); } + } - /// Break Flag - private bool FlagB - { - get { return (P & 0x10) != 0; } - set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); } - } + /// Break Flag + private bool FlagB + { + get { return (P & 0x10) != 0; } + set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); } + } - /// T... Flag - private bool FlagT - { - get { return (P & 0x20) != 0; } - set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); } - } + /// T... Flag + private bool FlagT + { + get { return (P & 0x20) != 0; } + set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); } + } - /// Overflow Flag - private bool FlagV - { - get { return (P & 0x40) != 0; } - set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); } - } + /// Overflow Flag + private bool FlagV + { + get { return (P & 0x40) != 0; } + set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); } + } - /// Negative Flag - private bool FlagN - { - get { return (P & 0x80) != 0; } - set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); } - } + /// Negative Flag + private bool FlagN + { + get { return (P & 0x80) != 0; } + set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); } + } - public int TotalExecutedCycles; - public int PendingCycles; + public int TotalExecutedCycles; + public int PendingCycles; - public Func ReadMemory; - public Action WriteMemory; + public Func ReadMemory; + public Action WriteMemory; - public void UnregisterMemoryMapper() - { - ReadMemory = null; - WriteMemory = null; - } + public void UnregisterMemoryMapper() + { + ReadMemory = null; + WriteMemory = null; + } - public ushort ReadWord(ushort address) - { - byte l = ReadMemory(address); - byte h = ReadMemory(++address); - return (ushort)((h << 8) | l); - } + public ushort ReadWord(ushort address) + { + byte l = ReadMemory(address); + byte h = ReadMemory(++address); + return (ushort)((h << 8) | l); + } - private void WriteWord(ushort address, ushort value) - { - byte l = (byte)(value & 0xFF); - byte h = (byte)(value >> 8); - WriteMemory(address, l); - WriteMemory(++address, h); - } + private void WriteWord(ushort address, ushort value) + { + byte l = (byte)(value & 0xFF); + byte h = (byte)(value >> 8); + WriteMemory(address, l); + WriteMemory(++address, h); + } - private ushort ReadWordPageWrap(ushort address) - { - ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF)); - return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8)); - } + private ushort ReadWordPageWrap(ushort address) + { + ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF)); + return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8)); + } - private static readonly byte[] TableNZ = - { - 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, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 - }; - } + private static readonly byte[] TableNZ = + { + 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, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 + }; + } } \ No newline at end of file