diff --git a/.gitignore b/.gitignore index 44e618d..41a8bcd 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ /AxibugEmuOnline.Client/ProjectSettings/ProjectVersion.txt /AxibugEmuOnline.Client/ProjectSettings/AutoStreamingSettings.asset /AxibugEmuOnline.Client/Logs +/virtuanessrc097-master/save diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Bandai.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Bandai.cs deleted file mode 100644 index 01cf683..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Bandai.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal abstract class Bandai : Board - { - private bool irq_enable; - - private int irq_counter; - - private Eprom eprom; - - internal override void Initialize(IRom rom) - { - base.Initialize(rom); - if (base.BoardType.ToLower().Contains("24c01")) - { - eprom = new Eprom(128); - } - else - { - eprom = new Eprom((base.MapperNumber == 16) ? 256 : 128); - } - } - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - irq_enable = false; - irq_counter = 0; - eprom.HardReset(); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - WritePRG(ref address, ref data); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF) - { - case 0: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 1: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 2: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 3: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 4: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 5: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 6: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 7: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 8: - Switch16KPRG(data, PRGArea.Area8000); - break; - case 9: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 10: - irq_enable = (data & 1) == 1; - NesEmu.IRQFlags &= -9; - break; - case 11: - irq_counter = (irq_counter & 0xFF00) | data; - break; - case 12: - irq_counter = (irq_counter & 0xFF) | (data << 8); - break; - case 13: - eprom.Write(address, data); - break; - } - } - - internal override void ReadSRM(ref ushort address, out byte value) - { - value = eprom.Read(address); - } - - internal override void OnCPUClock() - { - if (irq_enable) - { - irq_counter--; - if (irq_counter == 0) - { - NesEmu.IRQFlags |= 8; - } - if (irq_counter < 0) - { - irq_counter = 65535; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_enable); - stream.Write(irq_counter); - eprom.SaveState(stream); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_enable = stream.ReadBoolean(); - irq_counter = stream.ReadInt32(); - eprom.LoadState(stream); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfo.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfo.cs deleted file mode 100644 index a435e93..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal struct BankInfo - { - public bool IsRAM; - - public bool Enabled; - - public bool Writable; - - public bool IsBattery; - - public string ID; - - public byte[] DATA; - - public BankInfo(string ID, bool IsRAM, bool Writable, bool Enabled, bool IsBattery, byte[] DATA) - { - this.ID = ID; - this.IsRAM = IsRAM; - this.Writable = Writable; - this.Enabled = Enabled; - this.DATA = DATA; - this.IsBattery = IsBattery; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfoSorter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfoSorter.cs deleted file mode 100644 index 1393c5b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfoSorter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class BankInfoSorter : IComparer - { - public int Compare(BankInfo x, BankInfo y) - { - int result = 0; - int result2 = 0; - int.TryParse(x.ID, out result); - int.TryParse(y.ID, out result2); - return result2 - result; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankJoypad.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankJoypad.cs deleted file mode 100644 index 5fad7bc..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankJoypad.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class BlankJoypad : IJoypadConnecter - { - public override void Update() - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankShortuctsHandler.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankShortuctsHandler.cs deleted file mode 100644 index 7414228..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankShortuctsHandler.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class BlankShortuctsHandler : IShortcutsHandler - { - public void Update() - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankShortuctsHandler.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankShortuctsHandler.cs.meta deleted file mode 100644 index 9271f36..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankShortuctsHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d719eb3b397dd0743a86ded70de8d9dc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Board.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Board.cs deleted file mode 100644 index 7d810ea..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Board.cs +++ /dev/null @@ -1,1121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal abstract class Board - { - protected byte[][] PRG_RAM; - - protected bool[] PRG_RAM_ENABLED; - - protected bool[] PRG_RAM_WRITABLE; - - protected bool[] PRG_RAM_BATTERY; - - protected byte[][] PRG_ROM; - - protected int PRG_RAM_08KB_DEFAULT_BLK_Count; - - internal int PRG_ROM_04KB_Count; - - protected int PRG_ROM_08KB_Count; - - protected int PRG_ROM_16KB_Count; - - protected int PRG_ROM_32KB_Count; - - protected int PRG_ROM_04KB_Mask; - - protected int PRG_ROM_08KB_Mask; - - protected int PRG_ROM_16KB_Mask; - - protected int PRG_ROM_32KB_Mask; - - internal int PRG_RAM_04KB_Count; - - protected int PRG_RAM_08KB_Count; - - protected int PRG_RAM_16KB_Count; - - protected int PRG_RAM_32KB_Count; - - protected int PRG_RAM_04KB_Mask; - - protected int PRG_RAM_08KB_Mask; - - protected int PRG_RAM_16KB_Mask; - - protected int PRG_RAM_32KB_Mask; - - protected bool[] PRG_AREA_BLK_RAM; - - protected int[] PRG_AREA_BLK_INDEX; - - protected int PRG_TMP_INDX; - - protected int PRG_TMP_AREA; - - protected byte[][] CHR_RAM; - - protected bool[] CHR_RAM_ENABLED; - - protected bool[] CHR_RAM_WRITABLE; - - protected bool[] CHR_RAM_BATTERY; - - protected byte[][] CHR_ROM; - - protected bool[] CHR_AREA_BLK_RAM; - - protected int[] CHR_AREA_BLK_INDEX; - - protected int CHR_TMP_INDX; - - protected int CHR_TMP_AREA; - - protected int CHR_ROM_01KB_DEFAULT_BLK_Count; - - internal int CHR_ROM_01KB_Count; - - protected int CHR_ROM_02KB_Count; - - protected int CHR_ROM_04KB_Count; - - protected int CHR_ROM_08KB_Count; - - internal int CHR_ROM_01KB_Mask; - - protected int CHR_ROM_02KB_Mask; - - protected int CHR_ROM_04KB_Mask; - - protected int CHR_ROM_08KB_Mask; - - internal int CHR_RAM_01KB_Count; - - protected int CHR_RAM_02KB_Count; - - protected int CHR_RAM_04KB_Count; - - protected int CHR_RAM_08KB_Count; - - internal int CHR_RAM_01KB_Mask; - - protected int CHR_RAM_02KB_Mask; - - protected int CHR_RAM_04KB_Mask; - - protected int CHR_RAM_08KB_Mask; - - protected byte[][] NMT_RAM; - - internal int[] NMT_AREA_BLK_INDEX; - - protected int NMT_TMP_INDX; - - protected int NMT_TMP_AREA; - - internal Mirroring NMT_DEFAULT_MIRROR; - - internal string SHA1 = ""; - - internal string CRC = ""; - - internal bool IsGameFoundOnDB; - - internal NesCartDatabaseGameInfo GameInfo; - - internal NesCartDatabaseCartridgeInfo GameCartInfo; - - internal bool SRAMSaveRequired; - - protected bool enabled_ppuA12ToggleTimer; - - protected bool ppuA12TogglesOnRaisingEdge; - - protected int old_vram_address; - - protected int new_vram_address; - - protected int ppu_cycles_timer; - - internal bool enable_external_sound; - - internal bool IsGameGenieActive; - - internal GameGenieCode[] GameGenieCodes; - - internal string BoardType { get; private set; } - - internal string BoardPCB { get; private set; } - - internal List Chips { get; private set; } - - internal string Name { get; set; } - - internal int MapperNumber { get; set; } - - internal bool HasIssues { get; set; } - - internal virtual string Issues { get; set; } - - public Board() - { - MapperNumber = -1; - PRG_RAM_08KB_DEFAULT_BLK_Count = 1; - CHR_ROM_01KB_DEFAULT_BLK_Count = 8; - LoadAttrs(); - } - - internal virtual void Initialize(IRom rom) - { - SHA1 = rom.SHA1; - SRAMSaveRequired = false; - IsGameGenieActive = false; - BoardType = "N/A"; - BoardPCB = "N/A"; - Chips = new List(); - if (NesCartDatabase.Ready) - { - Tracer.WriteLine("Looking for rom in the database .."); - GameInfo = NesCartDatabase.Find(SHA1, out IsGameFoundOnDB); - if (GameInfo.Cartridges != null) - { - foreach (NesCartDatabaseCartridgeInfo cartridge in GameInfo.Cartridges) - { - if (cartridge.SHA1.ToLower() == SHA1.ToLower()) - { - GameCartInfo = cartridge; - break; - } - } - } - if (IsGameFoundOnDB) - { - Tracer.WriteInformation("Game found in Database !!"); - Tracer.WriteLine("> Game name: " + GameInfo.Game_Name); - Tracer.WriteLine("> Game alt name: " + GameInfo.Game_AltName); - BoardType = GameCartInfo.Board_Type; - Tracer.WriteLine("> Board Type: " + BoardType); - BoardPCB = GameCartInfo.Board_Pcb; - Tracer.WriteLine("> Board Pcb: " + BoardPCB); - if (GameCartInfo.chip_type != null) - { - for (int i = 0; i < GameCartInfo.chip_type.Count; i++) - { - Console.WriteLine($"> CHIP {(i + 1).ToString()}: {GameCartInfo.chip_type[i]}"); - Chips.Add(GameCartInfo.chip_type[i]); - } - } - } - else - { - Tracer.WriteWarning("Game is not found in database ."); - } - } - Tracer.WriteLine("Initializing the board (Mapper # " + MapperNumber + ") ...."); - Tracer.WriteLine("Loading PRG ROM ..."); - PRG_AREA_BLK_RAM = new bool[16]; - PRG_AREA_BLK_INDEX = new int[16]; - PRG_ROM = new byte[0][]; - int num = 0; - for (int j = 0; j < rom.PRG.Length; j += 4096) - { - Array.Resize(ref PRG_ROM, PRG_ROM.GetLength(0) + 1); - PRG_ROM[num] = new byte[4096]; - for (int k = 0; k < 4096; k++) - { - PRG_ROM[num][k] = rom.PRG[j + k]; - } - num++; - } - PRG_ROM_04KB_Count = PRG_ROM.GetLength(0); - PRG_ROM_04KB_Mask = PRG_ROM_04KB_Count - 1; - PRG_ROM_08KB_Count = PRG_ROM_04KB_Count / 2; - PRG_ROM_08KB_Mask = PRG_ROM_08KB_Count - 1; - PRG_ROM_16KB_Count = PRG_ROM_04KB_Count / 4; - PRG_ROM_16KB_Mask = PRG_ROM_16KB_Count - 1; - PRG_ROM_32KB_Count = PRG_ROM_04KB_Count / 8; - PRG_ROM_32KB_Mask = PRG_ROM_32KB_Count - 1; - Tracer.WriteLine("PRG ROM loaded successfully."); - Tracer.WriteLine("PRG ROM Size = " + PRG_ROM_04KB_Count * 4 + "KB"); - Tracer.WriteLine("Loading PRG RAM ..."); - SRAMBankInfo[] pRGRAM8KCountFromDB = GetPRGRAM8KCountFromDB(); - PRG_RAM = new byte[0][]; - PRG_RAM_BATTERY = new bool[0]; - PRG_RAM_ENABLED = new bool[0]; - PRG_RAM_WRITABLE = new bool[0]; - SRAMBankInfo[] array = pRGRAM8KCountFromDB; - for (int l = 0; l < array.Length; l++) - { - SRAMBankInfo sRAMBankInfo = array[l]; - if (sRAMBankInfo.BATTERY) - { - SRAMSaveRequired = true; - } - int result = 0; - int.TryParse(sRAMBankInfo.SIZE.Replace("k", ""), out result); - if (result > 0) - { - int num2 = result / 2; - for (int m = 0; m < num2; m++) - { - Array.Resize(ref PRG_RAM_BATTERY, PRG_RAM_BATTERY.Length + 1); - Array.Resize(ref PRG_RAM_ENABLED, PRG_RAM_ENABLED.Length + 1); - Array.Resize(ref PRG_RAM_WRITABLE, PRG_RAM_WRITABLE.Length + 1); - Array.Resize(ref PRG_RAM, PRG_RAM.GetLength(0) + 1); - PRG_RAM[PRG_RAM.GetLength(0) - 1] = new byte[4096]; - PRG_RAM_BATTERY[PRG_RAM_BATTERY.Length - 1] = sRAMBankInfo.BATTERY; - PRG_RAM_ENABLED[PRG_RAM_ENABLED.Length - 1] = true; - PRG_RAM_WRITABLE[PRG_RAM_WRITABLE.Length - 1] = true; - } - } - } - PRG_RAM_04KB_Count = PRG_RAM.GetLength(0); - PRG_RAM_04KB_Mask = PRG_RAM_04KB_Count - 1; - PRG_RAM_08KB_Count = PRG_RAM_04KB_Count / 2; - PRG_RAM_08KB_Mask = PRG_RAM_08KB_Count - 1; - PRG_RAM_16KB_Count = PRG_RAM_04KB_Count / 4; - PRG_RAM_16KB_Mask = PRG_RAM_16KB_Count - 1; - PRG_RAM_32KB_Count = PRG_RAM_04KB_Count / 8; - PRG_RAM_32KB_Mask = PRG_RAM_32KB_Count - 1; - Tracer.WriteLine("PRG RAM loaded successfully."); - Tracer.WriteLine("PRG RAM Size = " + PRG_RAM_04KB_Count * 4 + "KB"); - if (rom.HasTrainer) - { - rom.Trainer.CopyTo(PRG_RAM[3], 0); - } - Tracer.WriteLine("Loading CHR ROM ..."); - CHR_ROM = new byte[0][]; - CHR_AREA_BLK_RAM = new bool[8]; - CHR_AREA_BLK_INDEX = new int[8]; - num = 0; - for (int n = 0; n < rom.CHR.Length; n += 1024) - { - Array.Resize(ref CHR_ROM, CHR_ROM.GetLength(0) + 1); - CHR_ROM[num] = new byte[1024]; - for (int num3 = 0; num3 < 1024; num3++) - { - CHR_ROM[num][num3] = rom.CHR[n + num3]; - } - num++; - } - CHR_ROM_01KB_Count = CHR_ROM.GetLength(0); - CHR_ROM_01KB_Mask = CHR_ROM_01KB_Count - 1; - CHR_ROM_02KB_Count = CHR_ROM_01KB_Count / 2; - CHR_ROM_02KB_Mask = CHR_ROM_02KB_Count - 1; - CHR_ROM_04KB_Count = CHR_ROM_01KB_Count / 4; - CHR_ROM_04KB_Mask = CHR_ROM_04KB_Count - 1; - CHR_ROM_08KB_Count = CHR_ROM_01KB_Count / 8; - CHR_ROM_08KB_Mask = CHR_ROM_08KB_Count - 1; - Tracer.WriteLine("CHR ROM loaded successfully."); - Tracer.WriteLine("CHR ROM Size = " + CHR_ROM_01KB_Count + "KB"); - Tracer.WriteLine("Loading CHR RAM ..."); - int cHRRAM1KCountFromDB = GetCHRRAM1KCountFromDB(); - CHR_RAM = new byte[0][]; - CHR_RAM_BATTERY = new bool[cHRRAM1KCountFromDB]; - CHR_RAM_ENABLED = new bool[cHRRAM1KCountFromDB]; - CHR_RAM_WRITABLE = new bool[cHRRAM1KCountFromDB]; - for (int num4 = 0; num4 < cHRRAM1KCountFromDB; num4++) - { - Array.Resize(ref CHR_RAM, CHR_RAM.GetLength(0) + 1); - CHR_RAM[num4] = new byte[1024]; - CHR_RAM_BATTERY[num4] = false; - CHR_RAM_ENABLED[num4] = true; - CHR_RAM_WRITABLE[num4] = true; - } - CHR_RAM_01KB_Count = CHR_RAM.GetLength(0); - CHR_RAM_01KB_Mask = CHR_RAM_01KB_Count - 1; - CHR_RAM_02KB_Count = CHR_RAM_01KB_Count / 2; - CHR_RAM_02KB_Mask = CHR_RAM_02KB_Count - 1; - CHR_RAM_04KB_Count = CHR_RAM_01KB_Count / 4; - CHR_RAM_04KB_Mask = CHR_RAM_04KB_Count - 1; - CHR_RAM_08KB_Count = CHR_RAM_01KB_Count / 8; - CHR_RAM_08KB_Mask = CHR_RAM_08KB_Count - 1; - Tracer.WriteLine("CHR RAM loaded successfully."); - Tracer.WriteLine("CHR RAM Size = " + CHR_RAM_01KB_Count + "KB"); - Tracer.WriteLine("Loading Nametables ..."); - NMT_AREA_BLK_INDEX = new int[4]; - NMT_RAM = new byte[0][]; - for (int num5 = 0; num5 < 4; num5++) - { - Array.Resize(ref NMT_RAM, NMT_RAM.GetLength(0) + 1); - NMT_RAM[num5] = new byte[1024]; - } - NMT_DEFAULT_MIRROR = rom.Mirroring; - Tracer.WriteLine("Mirroring set to " + NMT_DEFAULT_MIRROR); - Tracer.WriteLine("Board (Mapper # " + MapperNumber + ") initialized successfully."); - } - - internal virtual void HardReset() - { - Tracer.WriteLine("Hard reset board (Mapper # " + MapperNumber + ") ...."); - Tracer.WriteLine("Switching 16KB PRG RAM at 0x4000 - 0x7000"); - Toggle16KPRG_RAM(ram: true, PRGArea.Area4000); - Switch16KPRG(0, PRGArea.Area4000); - Tracer.WriteLine("Switching 32KB PRG ROM at 0x8000 - 0xF000"); - Toggle32KPRG_RAM(ram: false, PRGArea.Area8000); - Switch32KPRG(0, PRGArea.Area8000); - Tracer.WriteLine("Switching 8KB CHR " + ((CHR_ROM_01KB_Count == 0) ? "RAM" : "ROM") + " at 0x0000 - 0x1000"); - Toggle08KCHR_RAM(CHR_ROM_01KB_Count == 0); - Switch08KCHR(0); - Tracer.WriteLine("Switching to mirroring: " + NMT_DEFAULT_MIRROR); - Switch01KNMTFromMirroring(NMT_DEFAULT_MIRROR); - Tracer.WriteLine("Hard reset board (Mapper # " + MapperNumber + ") is done successfully."); - } - - internal virtual void SoftReset() - { - } - - protected virtual void LoadAttrs() - { - enable_external_sound = false; - Attribute[] customAttributes = Attribute.GetCustomAttributes(GetType()); - foreach (Attribute attribute in customAttributes) - { - if (attribute.GetType() == typeof(BoardInfoAttribute)) - { - BoardInfoAttribute boardInfoAttribute = (BoardInfoAttribute)attribute; - Name = boardInfoAttribute.Name; - MapperNumber = boardInfoAttribute.Mapper; - PRG_RAM_08KB_DEFAULT_BLK_Count = boardInfoAttribute.DefaultPRG_RAM_8KB_BanksCount; - CHR_ROM_01KB_DEFAULT_BLK_Count = boardInfoAttribute.DefaultCHR_RAM_1KB_BanksCount; - enabled_ppuA12ToggleTimer = boardInfoAttribute.Enabled_ppuA12ToggleTimer; - ppuA12TogglesOnRaisingEdge = boardInfoAttribute.PPUA12TogglesOnRaisingEdge; - } - else if (attribute.GetType() == typeof(WithExternalSoundAttribute)) - { - enable_external_sound = true; - } - else if (attribute.GetType() == typeof(HassIssuesAttribute)) - { - HasIssues = true; - } - } - } - - protected SRAMBankInfo[] GetPRGRAM8KCountFromDB() - { - Tracer.WriteLine("Retrieving PRG RAM information from database ...."); - List list = new List(); - if (IsGameFoundOnDB) - { - if (GameCartInfo.WRAMBanks.Count > 0) - { - foreach (SRAMBankInfo wRAMBank in GameCartInfo.WRAMBanks) - { - list.Add(wRAMBank); - } - } - else - { - Tracer.WriteLine("This game has no PRG RAM !"); - Tracer.WriteWarning("> Adding 8K x " + PRG_RAM_08KB_DEFAULT_BLK_Count + " PRG RAM BANKS to avoid exceptions."); - SRAMBankInfo item = new SRAMBankInfo(0, PRG_RAM_08KB_DEFAULT_BLK_Count * 8 + "k", BATTERY: true); - list.Add(item); - } - } - else - { - Tracer.WriteWarning("Could't find this game in database .... Adding 8K x " + PRG_RAM_08KB_DEFAULT_BLK_Count + " PRG RAM BANKS to avoid exceptions."); - SRAMBankInfo item2 = new SRAMBankInfo(0, PRG_RAM_08KB_DEFAULT_BLK_Count * 8 + "k", BATTERY: true); - list.Add(item2); - } - return list.ToArray(); - } - - protected int GetCHRRAM1KCountFromDB() - { - int num = 0; - Tracer.WriteLine("Retrieving CHR RAM information from database ...."); - if (IsGameFoundOnDB) - { - bool flag = false; - if (GameCartInfo.VRAM_sizes != null) - { - Tracer.WriteLine("Using database to initialize CHR RAM ....."); - foreach (string vRAM_size in GameCartInfo.VRAM_sizes) - { - int result = 0; - if (int.TryParse(vRAM_size.Replace("k", ""), out result)) - { - Tracer.WriteLine(">CHR RAM CHIP SIZE " + vRAM_size + " KB added"); - num += result; - if (num > 0) - { - flag = true; - } - } - } - } - if (!flag) - { - Tracer.WriteLine("Game not found in database to initialize CHR RAM; CHR RAM size set to " + CHR_ROM_01KB_DEFAULT_BLK_Count + " KB"); - num = CHR_ROM_01KB_DEFAULT_BLK_Count; - } - } - else - { - Tracer.WriteWarning("Game not found in database to initialize CHR RAM; CHR RAM size set to " + CHR_ROM_01KB_DEFAULT_BLK_Count + " KB"); - num = CHR_ROM_01KB_DEFAULT_BLK_Count; - } - return num; - } - - internal virtual void WriteEX(ref ushort addr, ref byte val) - { - PRG_TMP_AREA = (addr >> 12) & 0xF; - if (PRG_AREA_BLK_RAM[PRG_TMP_AREA]) - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_RAM_04KB_Mask; - if (PRG_RAM_ENABLED[PRG_TMP_INDX] && PRG_RAM_WRITABLE[PRG_TMP_INDX]) - { - PRG_RAM[PRG_TMP_INDX][addr & 0xFFF] = val; - } - } - } - - internal virtual void WriteSRM(ref ushort addr, ref byte val) - { - PRG_TMP_AREA = (addr >> 12) & 0xF; - if (PRG_AREA_BLK_RAM[PRG_TMP_AREA]) - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_RAM_04KB_Mask; - if (PRG_RAM_ENABLED[PRG_TMP_INDX] && PRG_RAM_WRITABLE[PRG_TMP_INDX]) - { - PRG_RAM[PRG_TMP_INDX][addr & 0xFFF] = val; - } - } - } - - internal virtual void WritePRG(ref ushort addr, ref byte val) - { - PRG_TMP_AREA = (addr >> 12) & 0xF; - if (PRG_AREA_BLK_RAM[PRG_TMP_AREA]) - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_RAM_04KB_Mask; - if (PRG_RAM_ENABLED[PRG_TMP_INDX] && PRG_RAM_WRITABLE[PRG_TMP_INDX]) - { - PRG_RAM[PRG_TMP_INDX][addr & 0xFFF] = val; - } - } - } - - internal virtual void ReadEX(ref ushort addr, out byte val) - { - PRG_TMP_AREA = (addr >> 12) & 0xF; - if (PRG_AREA_BLK_RAM[PRG_TMP_AREA]) - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_RAM_04KB_Mask; - if (PRG_RAM_ENABLED[PRG_TMP_INDX]) - { - val = PRG_RAM[PRG_TMP_INDX][addr & 0xFFF]; - } - else - { - val = 0; - } - } - else - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_ROM_04KB_Mask; - val = PRG_ROM[PRG_TMP_INDX][addr & 0xFFF]; - } - } - - internal virtual void ReadSRM(ref ushort addr, out byte val) - { - PRG_TMP_AREA = (addr >> 12) & 0xF; - if (PRG_AREA_BLK_RAM[PRG_TMP_AREA]) - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_RAM_04KB_Mask; - if (PRG_RAM_ENABLED[PRG_TMP_INDX]) - { - val = PRG_RAM[PRG_TMP_INDX][addr & 0xFFF]; - } - else - { - val = 0; - } - } - else - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_ROM_04KB_Mask; - val = PRG_ROM[PRG_TMP_INDX][addr & 0xFFF]; - } - } - - internal virtual void ReadPRG(ref ushort addr, out byte val) - { - PRG_TMP_AREA = (addr >> 12) & 0xF; - if (PRG_AREA_BLK_RAM[PRG_TMP_AREA]) - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_RAM_04KB_Mask; - if (PRG_RAM_ENABLED[PRG_TMP_INDX]) - { - val = PRG_RAM[PRG_TMP_INDX][addr & 0xFFF]; - } - else - { - val = 0; - } - } - else - { - PRG_TMP_INDX = PRG_AREA_BLK_INDEX[PRG_TMP_AREA] & PRG_ROM_04KB_Mask; - val = PRG_ROM[PRG_TMP_INDX][addr & 0xFFF]; - } - if (!IsGameGenieActive) - { - return; - } - GameGenieCode[] gameGenieCodes = GameGenieCodes; - for (int i = 0; i < gameGenieCodes.Length; i++) - { - GameGenieCode gameGenieCode = gameGenieCodes[i]; - if (!gameGenieCode.Enabled || gameGenieCode.Address != addr) - { - continue; - } - if (gameGenieCode.IsCompare) - { - if (gameGenieCode.Compare == val) - { - val = gameGenieCode.Value; - } - } - else - { - val = gameGenieCode.Value; - } - break; - } - } - - internal virtual void WriteCHR(ref ushort addr, ref byte val) - { - CHR_TMP_AREA = (addr >> 10) & 7; - if (CHR_AREA_BLK_RAM[CHR_TMP_AREA]) - { - CHR_TMP_INDX = CHR_AREA_BLK_INDEX[CHR_TMP_AREA] & CHR_RAM_01KB_Mask; - if (CHR_RAM_ENABLED[CHR_TMP_INDX] && CHR_RAM_WRITABLE[CHR_TMP_INDX]) - { - CHR_RAM[CHR_TMP_INDX][addr & 0x3FF] = val; - } - } - } - - internal virtual void ReadCHR(ref ushort addr, out byte val) - { - CHR_TMP_AREA = (addr >> 10) & 7; - CHR_TMP_INDX = CHR_AREA_BLK_INDEX[CHR_TMP_AREA]; - if (CHR_AREA_BLK_RAM[CHR_TMP_AREA]) - { - CHR_TMP_INDX &= CHR_RAM_01KB_Mask; - if (CHR_RAM_ENABLED[CHR_TMP_INDX]) - { - val = CHR_RAM[CHR_TMP_INDX][addr & 0x3FF]; - } - else - { - val = 0; - } - } - else - { - CHR_TMP_INDX &= CHR_ROM_01KB_Mask; - val = CHR_ROM[CHR_TMP_INDX][addr & 0x3FF]; - } - } - - internal virtual void WriteNMT(ref ushort addr, ref byte val) - { - NMT_TMP_AREA = (addr >> 10) & 3; - NMT_TMP_INDX = NMT_AREA_BLK_INDEX[NMT_TMP_AREA]; - NMT_RAM[NMT_TMP_INDX][addr & 0x3FF] = val; - } - - internal virtual void ReadNMT(ref ushort addr, out byte val) - { - NMT_TMP_AREA = (addr >> 10) & 3; - NMT_TMP_INDX = NMT_AREA_BLK_INDEX[NMT_TMP_AREA]; - val = NMT_RAM[NMT_TMP_INDX][addr & 0x3FF]; - } - - protected void Switch04KPRG(int index, PRGArea area) - { - PRG_AREA_BLK_INDEX[(uint)area] = index; - } - - protected void Switch08KPRG(int index, PRGArea area) - { - index *= 2; - PRG_AREA_BLK_INDEX[(uint)area] = index; - PRG_AREA_BLK_INDEX[(uint)(area + 1)] = index + 1; - } - - protected void Switch16KPRG(int index, PRGArea area) - { - index *= 4; - PRG_AREA_BLK_INDEX[(uint)area] = index; - PRG_AREA_BLK_INDEX[(uint)(area + 1)] = index + 1; - PRG_AREA_BLK_INDEX[(uint)(area + 2)] = index + 2; - PRG_AREA_BLK_INDEX[(uint)(area + 3)] = index + 3; - } - - protected void Switch32KPRG(int index, PRGArea area) - { - index *= 8; - PRG_AREA_BLK_INDEX[(uint)area] = index; - PRG_AREA_BLK_INDEX[(uint)(area + 1)] = index + 1; - PRG_AREA_BLK_INDEX[(uint)(area + 2)] = index + 2; - PRG_AREA_BLK_INDEX[(uint)(area + 3)] = index + 3; - PRG_AREA_BLK_INDEX[(uint)(area + 4)] = index + 4; - PRG_AREA_BLK_INDEX[(uint)(area + 5)] = index + 5; - PRG_AREA_BLK_INDEX[(uint)(area + 6)] = index + 6; - PRG_AREA_BLK_INDEX[(uint)(area + 7)] = index + 7; - } - - protected void Toggle04KPRG_RAM(bool ram, PRGArea area) - { - PRG_AREA_BLK_RAM[(uint)area] = ram; - } - - protected void Toggle08KPRG_RAM(bool ram, PRGArea area) - { - PRG_AREA_BLK_RAM[(uint)area] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 1)] = ram; - } - - protected void Toggle16KPRG_RAM(bool ram, PRGArea area) - { - PRG_AREA_BLK_RAM[(uint)area] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 1)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 2)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 3)] = ram; - } - - protected void Toggle32KPRG_RAM(bool ram, PRGArea area) - { - PRG_AREA_BLK_RAM[(uint)area] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 1)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 2)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 3)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 4)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 5)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 6)] = ram; - PRG_AREA_BLK_RAM[(uint)(area + 7)] = ram; - } - - protected void TogglePRGRAMEnable(bool enable) - { - for (int i = 0; i < PRG_RAM_ENABLED.Length; i++) - { - PRG_RAM_ENABLED[i] = enable; - } - } - - protected void TogglePRGRAMWritableEnable(bool enable) - { - for (int i = 0; i < PRG_RAM_WRITABLE.Length; i++) - { - PRG_RAM_WRITABLE[i] = enable; - } - } - - protected void Toggle04KPRG_RAM_Enabled(bool enable, int index) - { - PRG_RAM_ENABLED[index] = enable; - } - - protected void Toggle04KPRG_RAM_Writable(bool enable, int index) - { - PRG_RAM_WRITABLE[index] = enable; - } - - protected void Toggle04KPRG_RAM_Battery(bool enable, int index) - { - PRG_RAM_BATTERY[index] = enable; - } - - protected void Switch01KCHR(int index, CHRArea area) - { - CHR_AREA_BLK_INDEX[(uint)area] = index; - } - - protected void Switch02KCHR(int index, CHRArea area) - { - index *= 2; - CHR_AREA_BLK_INDEX[(uint)area] = index; - CHR_AREA_BLK_INDEX[(uint)(area + 1)] = index + 1; - } - - protected void Switch04KCHR(int index, CHRArea area) - { - index *= 4; - CHR_AREA_BLK_INDEX[(uint)area] = index; - CHR_AREA_BLK_INDEX[(uint)(area + 1)] = index + 1; - CHR_AREA_BLK_INDEX[(uint)(area + 2)] = index + 2; - CHR_AREA_BLK_INDEX[(uint)(area + 3)] = index + 3; - } - - protected void Switch08KCHR(int index) - { - index *= 8; - CHR_AREA_BLK_INDEX[0] = index; - CHR_AREA_BLK_INDEX[1] = index + 1; - CHR_AREA_BLK_INDEX[2] = index + 2; - CHR_AREA_BLK_INDEX[3] = index + 3; - CHR_AREA_BLK_INDEX[4] = index + 4; - CHR_AREA_BLK_INDEX[5] = index + 5; - CHR_AREA_BLK_INDEX[6] = index + 6; - CHR_AREA_BLK_INDEX[7] = index + 7; - } - - protected void Toggle01KCHR_RAM(bool ram, CHRArea area) - { - CHR_AREA_BLK_RAM[(uint)area] = ram; - } - - protected void Toggle02KCHR_RAM(bool ram, CHRArea area) - { - CHR_AREA_BLK_RAM[(uint)area] = ram; - CHR_AREA_BLK_RAM[(uint)(area + 1)] = ram; - } - - protected void Toggle04KCHR_RAM(bool ram, CHRArea area) - { - CHR_AREA_BLK_RAM[(uint)area] = ram; - CHR_AREA_BLK_RAM[(uint)(area + 1)] = ram; - CHR_AREA_BLK_RAM[(uint)(area + 2)] = ram; - CHR_AREA_BLK_RAM[(uint)(area + 3)] = ram; - } - - protected void Toggle08KCHR_RAM(bool ram) - { - CHR_AREA_BLK_RAM[0] = ram; - CHR_AREA_BLK_RAM[1] = ram; - CHR_AREA_BLK_RAM[2] = ram; - CHR_AREA_BLK_RAM[3] = ram; - CHR_AREA_BLK_RAM[4] = ram; - CHR_AREA_BLK_RAM[5] = ram; - CHR_AREA_BLK_RAM[6] = ram; - CHR_AREA_BLK_RAM[7] = ram; - } - - protected void Toggle01KCHR_RAM_Enabled(bool enable, int index) - { - CHR_RAM_ENABLED[index] = enable; - } - - protected void Toggle01KCHR_RAM_Writable(bool enable, int index) - { - CHR_RAM_WRITABLE[index] = enable; - } - - protected void ToggleCHRRAMWritableEnable(bool enable) - { - for (int i = 0; i < CHR_RAM_WRITABLE.Length; i++) - { - CHR_RAM_WRITABLE[i] = enable; - } - } - - protected void Toggle01KCHR_RAM_Battery(bool enable, int index) - { - CHR_RAM_BATTERY[index] = enable; - } - - protected void Switch01KNMT(int index, byte area) - { - NMT_AREA_BLK_INDEX[area] = index; - } - - protected void Switch01KNMT(byte mirroring) - { - NMT_AREA_BLK_INDEX[0] = mirroring & 3; - NMT_AREA_BLK_INDEX[1] = (mirroring >> 2) & 3; - NMT_AREA_BLK_INDEX[2] = (mirroring >> 4) & 3; - NMT_AREA_BLK_INDEX[3] = (mirroring >> 6) & 3; - } - - protected void Switch01KNMTFromMirroring(Mirroring mirroring) - { - NMT_AREA_BLK_INDEX[0] = (int)(mirroring & (Mirroring)3); - NMT_AREA_BLK_INDEX[1] = ((int)mirroring >> 2) & 3; - NMT_AREA_BLK_INDEX[2] = ((int)mirroring >> 4) & 3; - NMT_AREA_BLK_INDEX[3] = ((int)mirroring >> 6) & 3; - } - - internal virtual void OnPPUAddressUpdate(ref ushort address) - { - if (!enabled_ppuA12ToggleTimer) - { - return; - } - old_vram_address = new_vram_address; - new_vram_address = address & 0x1000; - if (ppuA12TogglesOnRaisingEdge) - { - if (old_vram_address < new_vram_address) - { - if (ppu_cycles_timer > 8) - { - OnPPUA12RaisingEdge(); - } - ppu_cycles_timer = 0; - } - } - else if (old_vram_address > new_vram_address) - { - if (ppu_cycles_timer > 8) - { - OnPPUA12RaisingEdge(); - } - ppu_cycles_timer = 0; - } - } - - internal virtual void OnCPUClock() - { - } - - internal virtual void OnPPUClock() - { - if (enabled_ppuA12ToggleTimer) - { - ppu_cycles_timer++; - } - } - - internal virtual void OnPPUA12RaisingEdge() - { - } - - internal virtual void OnPPUScanlineTick() - { - } - - internal virtual void OnAPUClockDuration() - { - } - - internal virtual void OnAPUClockEnvelope() - { - } - - internal virtual void OnAPUClockSingle() - { - } - - internal virtual void OnAPUClock() - { - } - - internal virtual double APUGetSample() - { - return 0.0; - } - - internal virtual void APUApplyChannelsSettings() - { - } - - internal void SetupGameGenie(bool IsGameGenieActive, GameGenieCode[] GameGenieCodes) - { - this.IsGameGenieActive = IsGameGenieActive; - this.GameGenieCodes = GameGenieCodes; - } - - internal virtual void WriteStateData(ref BinaryWriter bin) - { - for (int i = 0; i < PRG_RAM.Length; i++) - { - bin.Write(PRG_RAM[i]); - } - for (int j = 0; j < PRG_RAM_ENABLED.Length; j++) - { - bin.Write(PRG_RAM_ENABLED[j]); - } - for (int k = 0; k < PRG_RAM_WRITABLE.Length; k++) - { - bin.Write(PRG_RAM_WRITABLE[k]); - } - for (int l = 0; l < PRG_RAM_BATTERY.Length; l++) - { - bin.Write(PRG_RAM_BATTERY[l]); - } - for (int m = 0; m < PRG_AREA_BLK_RAM.Length; m++) - { - bin.Write(PRG_AREA_BLK_RAM[m]); - } - for (int n = 0; n < PRG_AREA_BLK_INDEX.Length; n++) - { - bin.Write(PRG_AREA_BLK_INDEX[n]); - } - bin.Write(PRG_TMP_INDX); - bin.Write(PRG_TMP_AREA); - for (int num = 0; num < CHR_RAM.Length; num++) - { - bin.Write(CHR_RAM[num]); - } - for (int num2 = 0; num2 < CHR_RAM_ENABLED.Length; num2++) - { - bin.Write(CHR_RAM_ENABLED[num2]); - } - for (int num3 = 0; num3 < CHR_RAM_WRITABLE.Length; num3++) - { - bin.Write(CHR_RAM_WRITABLE[num3]); - } - for (int num4 = 0; num4 < CHR_RAM_BATTERY.Length; num4++) - { - bin.Write(CHR_RAM_BATTERY[num4]); - } - for (int num5 = 0; num5 < CHR_AREA_BLK_RAM.Length; num5++) - { - bin.Write(CHR_AREA_BLK_RAM[num5]); - } - for (int num6 = 0; num6 < CHR_AREA_BLK_INDEX.Length; num6++) - { - bin.Write(CHR_AREA_BLK_INDEX[num6]); - } - bin.Write(CHR_TMP_INDX); - bin.Write(CHR_TMP_AREA); - for (int num7 = 0; num7 < NMT_RAM.Length; num7++) - { - bin.Write(NMT_RAM[num7]); - } - for (int num8 = 0; num8 < NMT_AREA_BLK_INDEX.Length; num8++) - { - bin.Write(NMT_AREA_BLK_INDEX[num8]); - } - bin.Write(NMT_TMP_INDX); - bin.Write(NMT_TMP_AREA); - } - - internal virtual void ReadStateData(ref BinaryReader bin) - { - for (int i = 0; i < PRG_RAM.Length; i++) - { - bin.Read(PRG_RAM[i], 0, PRG_RAM[i].Length); - } - for (int j = 0; j < PRG_RAM_ENABLED.Length; j++) - { - PRG_RAM_ENABLED[j] = bin.ReadBoolean(); - } - for (int k = 0; k < PRG_RAM_WRITABLE.Length; k++) - { - PRG_RAM_WRITABLE[k] = bin.ReadBoolean(); - } - for (int l = 0; l < PRG_RAM_BATTERY.Length; l++) - { - PRG_RAM_BATTERY[l] = bin.ReadBoolean(); - } - for (int m = 0; m < PRG_AREA_BLK_RAM.Length; m++) - { - PRG_AREA_BLK_RAM[m] = bin.ReadBoolean(); - } - for (int n = 0; n < PRG_AREA_BLK_INDEX.Length; n++) - { - PRG_AREA_BLK_INDEX[n] = bin.ReadInt32(); - } - PRG_TMP_INDX = bin.ReadInt32(); - PRG_TMP_AREA = bin.ReadInt32(); - for (int num = 0; num < CHR_RAM.Length; num++) - { - bin.Read(CHR_RAM[num], 0, CHR_RAM[num].Length); - } - for (int num2 = 0; num2 < CHR_RAM_ENABLED.Length; num2++) - { - CHR_RAM_ENABLED[num2] = bin.ReadBoolean(); - } - for (int num3 = 0; num3 < CHR_RAM_WRITABLE.Length; num3++) - { - CHR_RAM_WRITABLE[num3] = bin.ReadBoolean(); - } - for (int num4 = 0; num4 < CHR_RAM_BATTERY.Length; num4++) - { - CHR_RAM_BATTERY[num4] = bin.ReadBoolean(); - } - for (int num5 = 0; num5 < CHR_AREA_BLK_RAM.Length; num5++) - { - CHR_AREA_BLK_RAM[num5] = bin.ReadBoolean(); - } - for (int num6 = 0; num6 < CHR_AREA_BLK_INDEX.Length; num6++) - { - CHR_AREA_BLK_INDEX[num6] = bin.ReadInt32(); - } - CHR_TMP_INDX = bin.ReadInt32(); - CHR_TMP_AREA = bin.ReadInt32(); - for (int num7 = 0; num7 < NMT_RAM.Length; num7++) - { - bin.Read(NMT_RAM[num7], 0, NMT_RAM[num7].Length); - } - for (int num8 = 0; num8 < NMT_AREA_BLK_INDEX.Length; num8++) - { - NMT_AREA_BLK_INDEX[num8] = bin.ReadInt32(); - } - NMT_TMP_INDX = bin.ReadInt32(); - NMT_TMP_AREA = bin.ReadInt32(); - } - - internal void SaveSRAM(Stream stream) - { - for (int i = 0; i < PRG_RAM_04KB_Count; i++) - { - if (PRG_RAM_BATTERY[i]) - { - stream.Write(PRG_RAM[i], 0, 4096); - } - } - } - - internal byte[] GetSRAMBuffer() - { - List list = new List(); - for (int i = 0; i < PRG_RAM_04KB_Count; i++) - { - if (PRG_RAM_BATTERY[i]) - { - list.AddRange(PRG_RAM[i]); - } - } - return list.ToArray(); - } - - internal void LoadSRAM(Stream stream) - { - for (int i = 0; i < PRG_RAM_04KB_Count; i++) - { - if (PRG_RAM_BATTERY[i]) - { - stream.Read(PRG_RAM[i], 0, 4096); - } - } - } - - internal void LoadSRAM(byte[] buffer) - { - int num = 0; - for (int i = 0; i < PRG_RAM_04KB_Count; i++) - { - if (PRG_RAM_BATTERY[i]) - { - for (int j = 0; j < 4096; j++) - { - PRG_RAM[i][j] = buffer[j + num]; - } - num += 4096; - } - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Board.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Board.cs.meta deleted file mode 100644 index 633023e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Board.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a649aa2f72c13234481b8a2db2b101f8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoAttribute.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoAttribute.cs deleted file mode 100644 index 7ca8060..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoAttribute.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class BoardInfoAttribute : Attribute - { - public string Name { get; private set; } - - public int Mapper { get; private set; } - - public int DefaultPRG_RAM_8KB_BanksCount { get; private set; } - - public int DefaultCHR_RAM_1KB_BanksCount { get; private set; } - - public bool Enabled_ppuA12ToggleTimer { get; private set; } - - public bool PPUA12TogglesOnRaisingEdge { get; private set; } - - public BoardInfoAttribute(string boardName, int inesMapperNumber) - { - Name = boardName; - Mapper = inesMapperNumber; - DefaultPRG_RAM_8KB_BanksCount = 1; - DefaultCHR_RAM_1KB_BanksCount = 8; - Enabled_ppuA12ToggleTimer = (PPUA12TogglesOnRaisingEdge = false); - } - - public BoardInfoAttribute(string boardName, int inesMapperNumber, int defaultPRG_RAM_8KB_BanksCount, int defaultCHR_RAM_1KB_BanksCount) - { - Name = boardName; - Mapper = inesMapperNumber; - DefaultPRG_RAM_8KB_BanksCount = defaultPRG_RAM_8KB_BanksCount; - DefaultCHR_RAM_1KB_BanksCount = defaultCHR_RAM_1KB_BanksCount; - Enabled_ppuA12ToggleTimer = (PPUA12TogglesOnRaisingEdge = false); - } - - public BoardInfoAttribute(string boardName, int inesMapperNumber, bool Enabled_ppuA12ToggleTimer, bool PPUA12TogglesOnRaisingEdge) - { - Name = boardName; - Mapper = inesMapperNumber; - DefaultPRG_RAM_8KB_BanksCount = 1; - DefaultCHR_RAM_1KB_BanksCount = 8; - this.Enabled_ppuA12ToggleTimer = Enabled_ppuA12ToggleTimer; - this.PPUA12TogglesOnRaisingEdge = PPUA12TogglesOnRaisingEdge; - } - - public BoardInfoAttribute(string boardName, int inesMapperNumber, int defaultPRG_RAM_8KB_BanksCount, int defaultCHR_RAM_1KB_BanksCount, bool Enabled_ppuA12ToggleTimer, bool PPUA12TogglesOnRaisingEdge) - { - Name = boardName; - Mapper = inesMapperNumber; - DefaultPRG_RAM_8KB_BanksCount = defaultPRG_RAM_8KB_BanksCount; - DefaultCHR_RAM_1KB_BanksCount = defaultCHR_RAM_1KB_BanksCount; - this.Enabled_ppuA12ToggleTimer = Enabled_ppuA12ToggleTimer; - this.PPUA12TogglesOnRaisingEdge = PPUA12TogglesOnRaisingEdge; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoAttribute.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoAttribute.cs.meta deleted file mode 100644 index 1b46dc5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 42db8567eb222464faed6061346980df -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoObject.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoObject.cs deleted file mode 100644 index bf1d238..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoObject.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class BoardInfoObject - { - public string Name { get; internal set; } - - public int MapperNumber { get; internal set; } - - public bool IsSupported { get; internal set; } - - public string Issues { get; internal set; } - - public bool HasIssues { get; internal set; } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoObject.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoObject.cs.meta deleted file mode 100644 index 35a33db..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BoardInfoObject.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 02faf494147d32b4d9288978c3ae6145 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/CHRArea.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/CHRArea.cs deleted file mode 100644 index 7d9637b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/CHRArea.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace MyNes.Core -{ - internal enum CHRArea : byte - { - Area0000, - Area0400, - Area0800, - Area0C00, - Area1000, - Area1400, - Area1800, - Area1C00 - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/CHRArea.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/CHRArea.cs.meta deleted file mode 100644 index 6fd0dbe..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/CHRArea.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 682bde94b329bbe40bca1f57566c3bdd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Adler32.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Adler32.cs deleted file mode 100644 index 3a6fcd5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Adler32.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class Adler32 - { - private const int BASE = 65521; - - private const int NMAX = 5552; - - internal long adler32(long adler, byte[] buf, int index, int len) - { - if (buf == null) - { - return 1L; - } - long num = adler & 0xFFFF; - long num2 = (adler >> 16) & 0xFFFF; - while (len > 0) - { - int num3 = ((len < 5552) ? len : 5552); - len -= num3; - while (num3 >= 16) - { - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num += buf[index++] & 0xFF; - num2 += num; - num3 -= 16; - } - if (num3 != 0) - { - do - { - num += buf[index++] & 0xFF; - num2 += num; - } - while (--num3 != 0); - } - num %= 65521; - num2 %= 65521; - } - return (num2 << 16) | num; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Adler32.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Adler32.cs.meta deleted file mode 100644 index 17aacb1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Adler32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5f0afef237e01da488c3afdb23b495d4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Deflate.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Deflate.cs deleted file mode 100644 index 9272bee..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Deflate.cs +++ /dev/null @@ -1,1412 +0,0 @@ -using System; - -namespace ComponentAce.Compression.Libs.zlib -{ - public sealed class Deflate - { - internal class Config - { - internal int good_length; - - internal int max_lazy; - - internal int nice_length; - - internal int max_chain; - - internal int func; - - internal Config(int good_length, int max_lazy, int nice_length, int max_chain, int func) - { - this.good_length = good_length; - this.max_lazy = max_lazy; - this.nice_length = nice_length; - this.max_chain = max_chain; - this.func = func; - } - } - - private const int MAX_MEM_LEVEL = 9; - - private const int Z_DEFAULT_COMPRESSION = -1; - - private const int MAX_WBITS = 15; - - private const int DEF_MEM_LEVEL = 8; - - private const int STORED = 0; - - private const int FAST = 1; - - private const int SLOW = 2; - - private static Config[] config_table; - - private static readonly string[] z_errmsg; - - private const int NeedMore = 0; - - private const int BlockDone = 1; - - private const int FinishStarted = 2; - - private const int FinishDone = 3; - - private const int PRESET_DICT = 32; - - private const int Z_FILTERED = 1; - - private const int Z_HUFFMAN_ONLY = 2; - - private const int Z_DEFAULT_STRATEGY = 0; - - private const int Z_NO_FLUSH = 0; - - private const int Z_PARTIAL_FLUSH = 1; - - private const int Z_SYNC_FLUSH = 2; - - private const int Z_FULL_FLUSH = 3; - - private const int Z_FINISH = 4; - - private const int Z_OK = 0; - - private const int Z_STREAM_END = 1; - - private const int Z_NEED_DICT = 2; - - private const int Z_ERRNO = -1; - - private const int Z_STREAM_ERROR = -2; - - private const int Z_DATA_ERROR = -3; - - private const int Z_MEM_ERROR = -4; - - private const int Z_BUF_ERROR = -5; - - private const int Z_VERSION_ERROR = -6; - - private const int INIT_STATE = 42; - - private const int BUSY_STATE = 113; - - private const int FINISH_STATE = 666; - - private const int Z_DEFLATED = 8; - - private const int STORED_BLOCK = 0; - - private const int STATIC_TREES = 1; - - private const int DYN_TREES = 2; - - private const int Z_BINARY = 0; - - private const int Z_ASCII = 1; - - private const int Z_UNKNOWN = 2; - - private const int Buf_size = 16; - - private const int REP_3_6 = 16; - - private const int REPZ_3_10 = 17; - - private const int REPZ_11_138 = 18; - - private const int MIN_MATCH = 3; - - private const int MAX_MATCH = 258; - - private static readonly int MIN_LOOKAHEAD; - - private const int MAX_BITS = 15; - - private const int D_CODES = 30; - - private const int BL_CODES = 19; - - private const int LENGTH_CODES = 29; - - private const int LITERALS = 256; - - private static readonly int L_CODES; - - private static readonly int HEAP_SIZE; - - private const int END_BLOCK = 256; - - internal ZStream strm; - - internal int status; - - internal byte[] pending_buf; - - internal int pending_buf_size; - - internal int pending_out; - - internal int pending; - - internal int noheader; - - internal byte data_type; - - internal byte method; - - internal int last_flush; - - internal int w_size; - - internal int w_bits; - - internal int w_mask; - - internal byte[] window; - - internal int window_size; - - internal short[] prev; - - internal short[] head; - - internal int ins_h; - - internal int hash_size; - - internal int hash_bits; - - internal int hash_mask; - - internal int hash_shift; - - internal int block_start; - - internal int match_length; - - internal int prev_match; - - internal int match_available; - - internal int strstart; - - internal int match_start; - - internal int lookahead; - - internal int prev_length; - - internal int max_chain_length; - - internal int max_lazy_match; - - internal int level; - - internal int strategy; - - internal int good_match; - - internal int nice_match; - - internal short[] dyn_ltree; - - internal short[] dyn_dtree; - - internal short[] bl_tree; - - internal Tree l_desc = new Tree(); - - internal Tree d_desc = new Tree(); - - internal Tree bl_desc = new Tree(); - - internal short[] bl_count = new short[16]; - - internal int[] heap = new int[2 * L_CODES + 1]; - - internal int heap_len; - - internal int heap_max; - - internal byte[] depth = new byte[2 * L_CODES + 1]; - - internal int l_buf; - - internal int lit_bufsize; - - internal int last_lit; - - internal int d_buf; - - internal int opt_len; - - internal int static_len; - - internal int matches; - - internal int last_eob_len; - - internal short bi_buf; - - internal int bi_valid; - - internal Deflate() - { - dyn_ltree = new short[HEAP_SIZE * 2]; - dyn_dtree = new short[122]; - bl_tree = new short[78]; - } - - internal void lm_init() - { - window_size = 2 * w_size; - head[hash_size - 1] = 0; - for (int i = 0; i < hash_size - 1; i++) - { - head[i] = 0; - } - max_lazy_match = config_table[level].max_lazy; - good_match = config_table[level].good_length; - nice_match = config_table[level].nice_length; - max_chain_length = config_table[level].max_chain; - strstart = 0; - block_start = 0; - lookahead = 0; - match_length = (prev_length = 2); - match_available = 0; - ins_h = 0; - } - - internal void tr_init() - { - l_desc.dyn_tree = dyn_ltree; - l_desc.stat_desc = StaticTree.static_l_desc; - d_desc.dyn_tree = dyn_dtree; - d_desc.stat_desc = StaticTree.static_d_desc; - bl_desc.dyn_tree = bl_tree; - bl_desc.stat_desc = StaticTree.static_bl_desc; - bi_buf = 0; - bi_valid = 0; - last_eob_len = 8; - init_block(); - } - - internal void init_block() - { - for (int i = 0; i < L_CODES; i++) - { - dyn_ltree[i * 2] = 0; - } - for (int j = 0; j < 30; j++) - { - dyn_dtree[j * 2] = 0; - } - for (int k = 0; k < 19; k++) - { - bl_tree[k * 2] = 0; - } - dyn_ltree[512] = 1; - opt_len = (static_len = 0); - last_lit = (matches = 0); - } - - internal void pqdownheap(short[] tree, int k) - { - int num = heap[k]; - for (int num2 = k << 1; num2 <= heap_len; num2 <<= 1) - { - if (num2 < heap_len && smaller(tree, heap[num2 + 1], heap[num2], depth)) - { - num2++; - } - if (smaller(tree, num, heap[num2], depth)) - { - break; - } - heap[k] = heap[num2]; - k = num2; - } - heap[k] = num; - } - - internal static bool smaller(short[] tree, int n, int m, byte[] depth) - { - if (tree[n * 2] >= tree[m * 2]) - { - if (tree[n * 2] == tree[m * 2]) - { - return depth[n] <= depth[m]; - } - return false; - } - return true; - } - - internal void scan_tree(short[] tree, int max_code) - { - int num = -1; - int num2 = tree[1]; - int num3 = 0; - int num4 = 7; - int num5 = 4; - if (num2 == 0) - { - num4 = 138; - num5 = 3; - } - tree[(max_code + 1) * 2 + 1] = (short)SupportClass.Identity(65535L); - for (int i = 0; i <= max_code; i++) - { - int num6 = num2; - num2 = tree[(i + 1) * 2 + 1]; - if (++num3 < num4 && num6 == num2) - { - continue; - } - if (num3 < num5) - { - bl_tree[num6 * 2] = (short)(bl_tree[num6 * 2] + num3); - } - else if (num6 != 0) - { - if (num6 != num) - { - bl_tree[num6 * 2]++; - } - bl_tree[32]++; - } - else if (num3 <= 10) - { - bl_tree[34]++; - } - else - { - bl_tree[36]++; - } - num3 = 0; - num = num6; - if (num2 == 0) - { - num4 = 138; - num5 = 3; - } - else if (num6 == num2) - { - num4 = 6; - num5 = 3; - } - else - { - num4 = 7; - num5 = 4; - } - } - } - - internal int build_bl_tree() - { - scan_tree(dyn_ltree, l_desc.max_code); - scan_tree(dyn_dtree, d_desc.max_code); - bl_desc.build_tree(this); - int num = 18; - while (num >= 3 && bl_tree[Tree.bl_order[num] * 2 + 1] == 0) - { - num--; - } - opt_len += 3 * (num + 1) + 5 + 5 + 4; - return num; - } - - internal void send_all_trees(int lcodes, int dcodes, int blcodes) - { - send_bits(lcodes - 257, 5); - send_bits(dcodes - 1, 5); - send_bits(blcodes - 4, 4); - for (int i = 0; i < blcodes; i++) - { - send_bits(bl_tree[Tree.bl_order[i] * 2 + 1], 3); - } - send_tree(dyn_ltree, lcodes - 1); - send_tree(dyn_dtree, dcodes - 1); - } - - internal void send_tree(short[] tree, int max_code) - { - int num = -1; - int num2 = tree[1]; - int num3 = 0; - int num4 = 7; - int num5 = 4; - if (num2 == 0) - { - num4 = 138; - num5 = 3; - } - for (int i = 0; i <= max_code; i++) - { - int num6 = num2; - num2 = tree[(i + 1) * 2 + 1]; - if (++num3 < num4 && num6 == num2) - { - continue; - } - if (num3 < num5) - { - do - { - send_code(num6, bl_tree); - } - while (--num3 != 0); - } - else if (num6 != 0) - { - if (num6 != num) - { - send_code(num6, bl_tree); - num3--; - } - send_code(16, bl_tree); - send_bits(num3 - 3, 2); - } - else if (num3 <= 10) - { - send_code(17, bl_tree); - send_bits(num3 - 3, 3); - } - else - { - send_code(18, bl_tree); - send_bits(num3 - 11, 7); - } - num3 = 0; - num = num6; - if (num2 == 0) - { - num4 = 138; - num5 = 3; - } - else if (num6 == num2) - { - num4 = 6; - num5 = 3; - } - else - { - num4 = 7; - num5 = 4; - } - } - } - - internal void put_byte(byte[] p, int start, int len) - { - Array.Copy(p, start, pending_buf, pending, len); - pending += len; - } - - internal void put_byte(byte c) - { - pending_buf[pending++] = c; - } - - internal void put_short(int w) - { - put_byte((byte)w); - put_byte((byte)SupportClass.URShift(w, 8)); - } - - internal void putShortMSB(int b) - { - put_byte((byte)(b >> 8)); - put_byte((byte)b); - } - - internal void send_code(int c, short[] tree) - { - send_bits(tree[c * 2] & 0xFFFF, tree[c * 2 + 1] & 0xFFFF); - } - - internal void send_bits(int value_Renamed, int length) - { - if (bi_valid > 16 - length) - { - bi_buf = (short)((ushort)bi_buf | (ushort)((value_Renamed << bi_valid) & 0xFFFF)); - put_short(bi_buf); - bi_buf = (short)SupportClass.URShift(value_Renamed, 16 - bi_valid); - bi_valid += length - 16; - } - else - { - bi_buf = (short)((ushort)bi_buf | (ushort)((value_Renamed << bi_valid) & 0xFFFF)); - bi_valid += length; - } - } - - internal void _tr_align() - { - send_bits(2, 3); - send_code(256, StaticTree.static_ltree); - bi_flush(); - if (1 + last_eob_len + 10 - bi_valid < 9) - { - send_bits(2, 3); - send_code(256, StaticTree.static_ltree); - bi_flush(); - } - last_eob_len = 7; - } - - internal bool _tr_tally(int dist, int lc) - { - pending_buf[d_buf + last_lit * 2] = (byte)SupportClass.URShift(dist, 8); - pending_buf[d_buf + last_lit * 2 + 1] = (byte)dist; - pending_buf[l_buf + last_lit] = (byte)lc; - last_lit++; - if (dist == 0) - { - dyn_ltree[lc * 2]++; - } - else - { - matches++; - dist--; - dyn_ltree[(Tree._length_code[lc] + 256 + 1) * 2]++; - dyn_dtree[Tree.d_code(dist) * 2]++; - } - if ((last_lit & 0x1FFF) == 0 && level > 2) - { - int num = last_lit * 8; - int num2 = strstart - block_start; - for (int i = 0; i < 30; i++) - { - num = (int)(num + dyn_dtree[i * 2] * (5L + (long)Tree.extra_dbits[i])); - } - num = SupportClass.URShift(num, 3); - if (matches < last_lit / 2 && num < num2 / 2) - { - return true; - } - } - return last_lit == lit_bufsize - 1; - } - - internal void compress_block(short[] ltree, short[] dtree) - { - int num = 0; - if (last_lit != 0) - { - do - { - int num2 = ((pending_buf[d_buf + num * 2] << 8) & 0xFF00) | (pending_buf[d_buf + num * 2 + 1] & 0xFF); - int num3 = pending_buf[l_buf + num] & 0xFF; - num++; - if (num2 == 0) - { - send_code(num3, ltree); - continue; - } - int num4 = Tree._length_code[num3]; - send_code(num4 + 256 + 1, ltree); - int num5 = Tree.extra_lbits[num4]; - if (num5 != 0) - { - num3 -= Tree.base_length[num4]; - send_bits(num3, num5); - } - num2--; - num4 = Tree.d_code(num2); - send_code(num4, dtree); - num5 = Tree.extra_dbits[num4]; - if (num5 != 0) - { - num2 -= Tree.base_dist[num4]; - send_bits(num2, num5); - } - } - while (num < last_lit); - } - send_code(256, ltree); - last_eob_len = ltree[513]; - } - - internal void set_data_type() - { - int i = 0; - int num = 0; - int num2 = 0; - for (; i < 7; i++) - { - num2 += dyn_ltree[i * 2]; - } - for (; i < 128; i++) - { - num += dyn_ltree[i * 2]; - } - for (; i < 256; i++) - { - num2 += dyn_ltree[i * 2]; - } - data_type = (byte)((num2 <= SupportClass.URShift(num, 2)) ? 1u : 0u); - } - - internal void bi_flush() - { - if (bi_valid == 16) - { - put_short(bi_buf); - bi_buf = 0; - bi_valid = 0; - } - else if (bi_valid >= 8) - { - put_byte((byte)bi_buf); - bi_buf = (short)SupportClass.URShift(bi_buf, 8); - bi_valid -= 8; - } - } - - internal void bi_windup() - { - if (bi_valid > 8) - { - put_short(bi_buf); - } - else if (bi_valid > 0) - { - put_byte((byte)bi_buf); - } - bi_buf = 0; - bi_valid = 0; - } - - internal void copy_block(int buf, int len, bool header) - { - bi_windup(); - last_eob_len = 8; - if (header) - { - put_short((short)len); - put_short((short)(~len)); - } - put_byte(window, buf, len); - } - - internal void flush_block_only(bool eof) - { - _tr_flush_block((block_start >= 0) ? block_start : (-1), strstart - block_start, eof); - block_start = strstart; - strm.flush_pending(); - } - - internal int deflate_stored(int flush) - { - int num = 65535; - if (num > pending_buf_size - 5) - { - num = pending_buf_size - 5; - } - while (true) - { - if (lookahead <= 1) - { - fill_window(); - if (lookahead == 0 && flush == 0) - { - return 0; - } - if (lookahead == 0) - { - break; - } - } - strstart += lookahead; - lookahead = 0; - int num2 = block_start + num; - if (strstart == 0 || strstart >= num2) - { - lookahead = strstart - num2; - strstart = num2; - flush_block_only(eof: false); - if (strm.avail_out == 0) - { - return 0; - } - } - if (strstart - block_start >= w_size - MIN_LOOKAHEAD) - { - flush_block_only(eof: false); - if (strm.avail_out == 0) - { - return 0; - } - } - } - flush_block_only(flush == 4); - if (strm.avail_out == 0) - { - if (flush != 4) - { - return 0; - } - return 2; - } - if (flush != 4) - { - return 1; - } - return 3; - } - - internal void _tr_stored_block(int buf, int stored_len, bool eof) - { - send_bits(eof ? 1 : 0, 3); - copy_block(buf, stored_len, header: true); - } - - internal void _tr_flush_block(int buf, int stored_len, bool eof) - { - int num = 0; - int num2; - int num3; - if (level > 0) - { - if (data_type == 2) - { - set_data_type(); - } - l_desc.build_tree(this); - d_desc.build_tree(this); - num = build_bl_tree(); - num2 = SupportClass.URShift(opt_len + 3 + 7, 3); - num3 = SupportClass.URShift(static_len + 3 + 7, 3); - if (num3 <= num2) - { - num2 = num3; - } - } - else - { - num2 = (num3 = stored_len + 5); - } - if (stored_len + 4 <= num2 && buf != -1) - { - _tr_stored_block(buf, stored_len, eof); - } - else if (num3 == num2) - { - send_bits(2 + (eof ? 1 : 0), 3); - compress_block(StaticTree.static_ltree, StaticTree.static_dtree); - } - else - { - send_bits(4 + (eof ? 1 : 0), 3); - send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, num + 1); - compress_block(dyn_ltree, dyn_dtree); - } - init_block(); - if (eof) - { - bi_windup(); - } - } - - internal void fill_window() - { - do - { - int num = window_size - lookahead - strstart; - int num2; - if (num == 0 && strstart == 0 && lookahead == 0) - { - num = w_size; - } - else if (num == -1) - { - num--; - } - else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) - { - Array.Copy(window, w_size, window, 0, w_size); - match_start -= w_size; - strstart -= w_size; - block_start -= w_size; - num2 = hash_size; - int num3 = num2; - do - { - int num4 = head[--num3] & 0xFFFF; - head[num3] = (short)((num4 >= w_size) ? (num4 - w_size) : 0); - } - while (--num2 != 0); - num2 = w_size; - num3 = num2; - do - { - int num4 = prev[--num3] & 0xFFFF; - prev[num3] = (short)((num4 >= w_size) ? (num4 - w_size) : 0); - } - while (--num2 != 0); - num += w_size; - } - if (strm.avail_in == 0) - { - break; - } - num2 = strm.read_buf(window, strstart + lookahead, num); - lookahead += num2; - if (lookahead >= 3) - { - ins_h = window[strstart] & 0xFF; - ins_h = ((ins_h << hash_shift) ^ (window[strstart + 1] & 0xFF)) & hash_mask; - } - } - while (lookahead < MIN_LOOKAHEAD && strm.avail_in != 0); - } - - internal int deflate_fast(int flush) - { - int num = 0; - while (true) - { - if (lookahead < MIN_LOOKAHEAD) - { - fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == 0) - { - return 0; - } - if (lookahead == 0) - { - break; - } - } - if (lookahead >= 3) - { - ins_h = ((ins_h << hash_shift) ^ (window[strstart + 2] & 0xFF)) & hash_mask; - num = head[ins_h] & 0xFFFF; - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short)strstart; - } - if (num != 0L && ((strstart - num) & 0xFFFF) <= w_size - MIN_LOOKAHEAD && strategy != 2) - { - match_length = longest_match(num); - } - bool flag; - if (match_length >= 3) - { - flag = _tr_tally(strstart - match_start, match_length - 3); - lookahead -= match_length; - if (match_length <= max_lazy_match && lookahead >= 3) - { - match_length--; - do - { - strstart++; - ins_h = ((ins_h << hash_shift) ^ (window[strstart + 2] & 0xFF)) & hash_mask; - num = head[ins_h] & 0xFFFF; - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short)strstart; - } - while (--match_length != 0); - strstart++; - } - else - { - strstart += match_length; - match_length = 0; - ins_h = window[strstart] & 0xFF; - ins_h = ((ins_h << hash_shift) ^ (window[strstart + 1] & 0xFF)) & hash_mask; - } - } - else - { - flag = _tr_tally(0, window[strstart] & 0xFF); - lookahead--; - strstart++; - } - if (flag) - { - flush_block_only(eof: false); - if (strm.avail_out == 0) - { - return 0; - } - } - } - flush_block_only(flush == 4); - if (strm.avail_out == 0) - { - if (flush == 4) - { - return 2; - } - return 0; - } - if (flush != 4) - { - return 1; - } - return 3; - } - - internal int deflate_slow(int flush) - { - int num = 0; - while (true) - { - if (lookahead < MIN_LOOKAHEAD) - { - fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == 0) - { - return 0; - } - if (lookahead == 0) - { - break; - } - } - if (lookahead >= 3) - { - ins_h = ((ins_h << hash_shift) ^ (window[strstart + 2] & 0xFF)) & hash_mask; - num = head[ins_h] & 0xFFFF; - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short)strstart; - } - prev_length = match_length; - prev_match = match_start; - match_length = 2; - if (num != 0 && prev_length < max_lazy_match && ((strstart - num) & 0xFFFF) <= w_size - MIN_LOOKAHEAD) - { - if (strategy != 2) - { - match_length = longest_match(num); - } - if (match_length <= 5 && (strategy == 1 || (match_length == 3 && strstart - match_start > 4096))) - { - match_length = 2; - } - } - if (prev_length >= 3 && match_length <= prev_length) - { - int num2 = strstart + lookahead - 3; - bool flag = _tr_tally(strstart - 1 - prev_match, prev_length - 3); - lookahead -= prev_length - 1; - prev_length -= 2; - do - { - if (++strstart <= num2) - { - ins_h = ((ins_h << hash_shift) ^ (window[strstart + 2] & 0xFF)) & hash_mask; - num = head[ins_h] & 0xFFFF; - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short)strstart; - } - } - while (--prev_length != 0); - match_available = 0; - match_length = 2; - strstart++; - if (flag) - { - flush_block_only(eof: false); - if (strm.avail_out == 0) - { - return 0; - } - } - } - else if (match_available != 0) - { - if (_tr_tally(0, window[strstart - 1] & 0xFF)) - { - flush_block_only(eof: false); - } - strstart++; - lookahead--; - if (strm.avail_out == 0) - { - return 0; - } - } - else - { - match_available = 1; - strstart++; - lookahead--; - } - } - if (match_available != 0) - { - bool flag = _tr_tally(0, window[strstart - 1] & 0xFF); - match_available = 0; - } - flush_block_only(flush == 4); - if (strm.avail_out == 0) - { - if (flush == 4) - { - return 2; - } - return 0; - } - if (flush != 4) - { - return 1; - } - return 3; - } - - internal int longest_match(int cur_match) - { - int num = max_chain_length; - int num2 = strstart; - int num3 = prev_length; - int num4 = ((strstart > w_size - MIN_LOOKAHEAD) ? (strstart - (w_size - MIN_LOOKAHEAD)) : 0); - int num5 = nice_match; - int num6 = w_mask; - int num7 = strstart + 258; - byte b = window[num2 + num3 - 1]; - byte b2 = window[num2 + num3]; - if (prev_length >= good_match) - { - num >>= 2; - } - if (num5 > lookahead) - { - num5 = lookahead; - } - do - { - int num8 = cur_match; - if (window[num8 + num3] != b2 || window[num8 + num3 - 1] != b || window[num8] != window[num2] || window[++num8] != window[num2 + 1]) - { - continue; - } - num2 += 2; - num8++; - while (window[++num2] == window[++num8] && window[++num2] == window[++num8] && window[++num2] == window[++num8] && window[++num2] == window[++num8] && window[++num2] == window[++num8] && window[++num2] == window[++num8] && window[++num2] == window[++num8] && window[++num2] == window[++num8] && num2 < num7) - { - } - int num9 = 258 - (num7 - num2); - num2 = num7 - 258; - if (num9 > num3) - { - match_start = cur_match; - num3 = num9; - if (num9 >= num5) - { - break; - } - b = window[num2 + num3 - 1]; - b2 = window[num2 + num3]; - } - } - while ((cur_match = prev[cur_match & num6] & 0xFFFF) > num4 && --num != 0); - if (num3 <= lookahead) - { - return num3; - } - return lookahead; - } - - internal int deflateInit(ZStream strm, int level, int bits) - { - return deflateInit2(strm, level, 8, bits, 8, 0); - } - - internal int deflateInit(ZStream strm, int level) - { - return deflateInit(strm, level, 15); - } - - internal int deflateInit2(ZStream strm, int level, int method, int windowBits, int memLevel, int strategy) - { - int num = 0; - strm.msg = null; - if (level == -1) - { - level = 6; - } - if (windowBits < 0) - { - num = 1; - windowBits = -windowBits; - } - if (memLevel < 1 || memLevel > 9 || method != 8 || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > 2) - { - return -2; - } - strm.dstate = this; - noheader = num; - w_bits = windowBits; - w_size = 1 << w_bits; - w_mask = w_size - 1; - hash_bits = memLevel + 7; - hash_size = 1 << hash_bits; - hash_mask = hash_size - 1; - hash_shift = (hash_bits + 3 - 1) / 3; - window = new byte[w_size * 2]; - prev = new short[w_size]; - head = new short[hash_size]; - lit_bufsize = 1 << memLevel + 6; - pending_buf = new byte[lit_bufsize * 4]; - pending_buf_size = lit_bufsize * 4; - d_buf = lit_bufsize; - l_buf = 3 * lit_bufsize; - this.level = level; - this.strategy = strategy; - this.method = (byte)method; - return deflateReset(strm); - } - - internal int deflateReset(ZStream strm) - { - strm.total_in = (strm.total_out = 0L); - strm.msg = null; - strm.data_type = 2; - pending = 0; - pending_out = 0; - if (noheader < 0) - { - noheader = 0; - } - status = ((noheader != 0) ? 113 : 42); - strm.adler = strm._adler.adler32(0L, null, 0, 0); - last_flush = 0; - tr_init(); - lm_init(); - return 0; - } - - internal int deflateEnd() - { - if (status != 42 && status != 113 && status != 666) - { - return -2; - } - pending_buf = null; - head = null; - prev = null; - window = null; - if (status != 113) - { - return 0; - } - return -3; - } - - internal int deflateParams(ZStream strm, int _level, int _strategy) - { - int result = 0; - if (_level == -1) - { - _level = 6; - } - if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > 2) - { - return -2; - } - if (config_table[level].func != config_table[_level].func && strm.total_in != 0L) - { - result = strm.deflate(1); - } - if (level != _level) - { - level = _level; - max_lazy_match = config_table[level].max_lazy; - good_match = config_table[level].good_length; - nice_match = config_table[level].nice_length; - max_chain_length = config_table[level].max_chain; - } - strategy = _strategy; - return result; - } - - internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength) - { - int num = dictLength; - int sourceIndex = 0; - if (dictionary == null || status != 42) - { - return -2; - } - strm.adler = strm._adler.adler32(strm.adler, dictionary, 0, dictLength); - if (num < 3) - { - return 0; - } - if (num > w_size - MIN_LOOKAHEAD) - { - num = w_size - MIN_LOOKAHEAD; - sourceIndex = dictLength - num; - } - Array.Copy(dictionary, sourceIndex, window, 0, num); - strstart = num; - block_start = num; - ins_h = window[0] & 0xFF; - ins_h = ((ins_h << hash_shift) ^ (window[1] & 0xFF)) & hash_mask; - for (int i = 0; i <= num - 3; i++) - { - ins_h = ((ins_h << hash_shift) ^ (window[i + 2] & 0xFF)) & hash_mask; - prev[i & w_mask] = head[ins_h]; - head[ins_h] = (short)i; - } - return 0; - } - - internal int deflate(ZStream strm, int flush) - { - if (flush > 4 || flush < 0) - { - return -2; - } - if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == 666 && flush != 4)) - { - strm.msg = z_errmsg[4]; - return -2; - } - if (strm.avail_out == 0) - { - strm.msg = z_errmsg[7]; - return -5; - } - this.strm = strm; - int num = last_flush; - last_flush = flush; - if (status == 42) - { - int num2 = 8 + (w_bits - 8 << 4) << 8; - int num3 = ((level - 1) & 0xFF) >> 1; - if (num3 > 3) - { - num3 = 3; - } - num2 |= num3 << 6; - if (strstart != 0) - { - num2 |= 0x20; - } - num2 += 31 - num2 % 31; - status = 113; - putShortMSB(num2); - if (strstart != 0) - { - putShortMSB((int)SupportClass.URShift(strm.adler, 16)); - putShortMSB((int)(strm.adler & 0xFFFF)); - } - strm.adler = strm._adler.adler32(0L, null, 0, 0); - } - if (pending != 0) - { - strm.flush_pending(); - if (strm.avail_out == 0) - { - last_flush = -1; - return 0; - } - } - else if (strm.avail_in == 0 && flush <= num && flush != 4) - { - strm.msg = z_errmsg[7]; - return -5; - } - if (status == 666 && strm.avail_in != 0) - { - strm.msg = z_errmsg[7]; - return -5; - } - if (strm.avail_in != 0 || lookahead != 0 || (flush != 0 && status != 666)) - { - int num4 = -1; - switch (config_table[level].func) - { - case 0: - num4 = deflate_stored(flush); - break; - case 1: - num4 = deflate_fast(flush); - break; - case 2: - num4 = deflate_slow(flush); - break; - } - if (num4 == 2 || num4 == 3) - { - status = 666; - } - switch (num4) - { - case 0: - case 2: - if (strm.avail_out == 0) - { - last_flush = -1; - } - return 0; - case 1: - if (flush == 1) - { - _tr_align(); - } - else - { - _tr_stored_block(0, 0, eof: false); - if (flush == 3) - { - for (int i = 0; i < hash_size; i++) - { - head[i] = 0; - } - } - } - strm.flush_pending(); - if (strm.avail_out == 0) - { - last_flush = -1; - return 0; - } - break; - } - } - if (flush != 4) - { - return 0; - } - if (noheader != 0) - { - return 1; - } - putShortMSB((int)SupportClass.URShift(strm.adler, 16)); - putShortMSB((int)(strm.adler & 0xFFFF)); - strm.flush_pending(); - noheader = -1; - if (pending == 0) - { - return 1; - } - return 0; - } - - static Deflate() - { - z_errmsg = new string[10] { "need dictionary", "stream end", "", "file error", "stream error", "data error", "insufficient memory", "buffer error", "incompatible version", "" }; - MIN_LOOKAHEAD = 262; - L_CODES = 286; - HEAP_SIZE = 2 * L_CODES + 1; - config_table = new Config[10]; - config_table[0] = new Config(0, 0, 0, 0, 0); - config_table[1] = new Config(4, 4, 8, 4, 1); - config_table[2] = new Config(4, 5, 16, 8, 1); - config_table[3] = new Config(4, 6, 32, 32, 1); - config_table[4] = new Config(4, 4, 16, 16, 2); - config_table[5] = new Config(8, 16, 32, 32, 2); - config_table[6] = new Config(8, 16, 128, 128, 2); - config_table[7] = new Config(8, 32, 128, 256, 2); - config_table[8] = new Config(32, 128, 258, 1024, 2); - config_table[9] = new Config(32, 258, 258, 4096, 2); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Deflate.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Deflate.cs.meta deleted file mode 100644 index 191cf63..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Deflate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2dfc48049b9e04b4eadd12cb50383cb8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfBlocks.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfBlocks.cs deleted file mode 100644 index e9373ee..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfBlocks.cs +++ /dev/null @@ -1,661 +0,0 @@ -using System; - -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class InfBlocks - { - private const int MANY = 1440; - - private static readonly int[] inflate_mask = new int[17] - { - 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, - 1023, 2047, 4095, 8191, 16383, 32767, 65535 - }; - - internal static readonly int[] border = new int[19] - { - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, - 11, 4, 12, 3, 13, 2, 14, 1, 15 - }; - - private const int Z_OK = 0; - - private const int Z_STREAM_END = 1; - - private const int Z_NEED_DICT = 2; - - private const int Z_ERRNO = -1; - - private const int Z_STREAM_ERROR = -2; - - private const int Z_DATA_ERROR = -3; - - private const int Z_MEM_ERROR = -4; - - private const int Z_BUF_ERROR = -5; - - private const int Z_VERSION_ERROR = -6; - - private const int TYPE = 0; - - private const int LENS = 1; - - private const int STORED = 2; - - private const int TABLE = 3; - - private const int BTREE = 4; - - private const int DTREE = 5; - - private const int CODES = 6; - - private const int DRY = 7; - - private const int DONE = 8; - - private const int BAD = 9; - - internal int mode; - - internal int left; - - internal int table; - - internal int index; - - internal int[] blens; - - internal int[] bb = new int[1]; - - internal int[] tb = new int[1]; - - internal InfCodes codes; - - internal int last; - - internal int bitk; - - internal int bitb; - - internal int[] hufts; - - internal byte[] window; - - internal int end; - - internal int read; - - internal int write; - - internal object checkfn; - - internal long check; - - internal InfBlocks(ZStream z, object checkfn, int w) - { - hufts = new int[4320]; - window = new byte[w]; - end = w; - this.checkfn = checkfn; - mode = 0; - reset(z, null); - } - - internal void reset(ZStream z, long[] c) - { - if (c != null) - { - c[0] = check; - } - if (mode == 4 || mode == 5) - { - blens = null; - } - if (mode == 6) - { - codes.free(z); - } - mode = 0; - bitk = 0; - bitb = 0; - read = (write = 0); - if (checkfn != null) - { - z.adler = (check = z._adler.adler32(0L, null, 0, 0)); - } - } - - internal int proc(ZStream z, int r) - { - int num = z.next_in_index; - int num2 = z.avail_in; - int num3 = bitb; - int i = bitk; - int num4 = write; - int num5 = ((num4 < read) ? (read - num4 - 1) : (end - num4)); - while (true) - { - switch (mode) - { - case 0: - { - for (; i < 3; i += 8) - { - if (num2 != 0) - { - r = 0; - num2--; - num3 |= (z.next_in[num++] & 0xFF) << i; - continue; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - int num6 = num3 & 7; - last = num6 & 1; - switch (SupportClass.URShift(num6, 1)) - { - case 0: - num3 = SupportClass.URShift(num3, 3); - i -= 3; - num6 = i & 7; - num3 = SupportClass.URShift(num3, num6); - i -= num6; - mode = 1; - break; - case 1: - { - int[] array5 = new int[1]; - int[] array6 = new int[1]; - int[][] array7 = new int[1][]; - int[][] array8 = new int[1][]; - InfTree.inflate_trees_fixed(array5, array6, array7, array8, z); - codes = new InfCodes(array5[0], array6[0], array7[0], array8[0], z); - num3 = SupportClass.URShift(num3, 3); - i -= 3; - mode = 6; - break; - } - case 2: - num3 = SupportClass.URShift(num3, 3); - i -= 3; - mode = 3; - break; - case 3: - num3 = SupportClass.URShift(num3, 3); - i -= 3; - mode = 9; - z.msg = "invalid block type"; - r = -3; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - break; - } - case 1: - for (; i < 32; i += 8) - { - if (num2 != 0) - { - r = 0; - num2--; - num3 |= (z.next_in[num++] & 0xFF) << i; - continue; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - if ((SupportClass.URShift(~num3, 16) & 0xFFFF) != (num3 & 0xFFFF)) - { - mode = 9; - z.msg = "invalid stored block lengths"; - r = -3; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - left = num3 & 0xFFFF; - num3 = (i = 0); - mode = ((left != 0) ? 2 : ((last != 0) ? 7 : 0)); - break; - case 2: - { - if (num2 == 0) - { - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - if (num5 == 0) - { - if (num4 == end && read != 0) - { - num4 = 0; - num5 = ((num4 < read) ? (read - num4 - 1) : (end - num4)); - } - if (num5 == 0) - { - write = num4; - r = inflate_flush(z, r); - num4 = write; - num5 = ((num4 < read) ? (read - num4 - 1) : (end - num4)); - if (num4 == end && read != 0) - { - num4 = 0; - num5 = ((num4 < read) ? (read - num4 - 1) : (end - num4)); - } - if (num5 == 0) - { - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - } - } - r = 0; - int num6 = left; - if (num6 > num2) - { - num6 = num2; - } - if (num6 > num5) - { - num6 = num5; - } - Array.Copy(z.next_in, num, window, num4, num6); - num += num6; - num2 -= num6; - num4 += num6; - num5 -= num6; - if ((left -= num6) == 0) - { - mode = ((last != 0) ? 7 : 0); - } - break; - } - case 3: - { - for (; i < 14; i += 8) - { - if (num2 != 0) - { - r = 0; - num2--; - num3 |= (z.next_in[num++] & 0xFF) << i; - continue; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - int num6 = (table = num3 & 0x3FFF); - if ((num6 & 0x1F) > 29 || ((num6 >> 5) & 0x1F) > 29) - { - mode = 9; - z.msg = "too many length or distance symbols"; - r = -3; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - num6 = 258 + (num6 & 0x1F) + ((num6 >> 5) & 0x1F); - blens = new int[num6]; - num3 = SupportClass.URShift(num3, 14); - i -= 14; - index = 0; - mode = 4; - goto case 4; - } - case 4: - { - while (index < 4 + SupportClass.URShift(table, 10)) - { - for (; i < 3; i += 8) - { - if (num2 != 0) - { - r = 0; - num2--; - num3 |= (z.next_in[num++] & 0xFF) << i; - continue; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - blens[border[index++]] = num3 & 7; - num3 = SupportClass.URShift(num3, 3); - i -= 3; - } - while (index < 19) - { - blens[border[index++]] = 0; - } - bb[0] = 7; - int num6 = InfTree.inflate_trees_bits(blens, bb, tb, hufts, z); - if (num6 != 0) - { - r = num6; - if (r == -3) - { - blens = null; - mode = 9; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - index = 0; - mode = 5; - goto case 5; - } - case 5: - { - int num6; - while (true) - { - num6 = table; - if (index >= 258 + (num6 & 0x1F) + ((num6 >> 5) & 0x1F)) - { - break; - } - for (num6 = bb[0]; i < num6; i += 8) - { - if (num2 != 0) - { - r = 0; - num2--; - num3 |= (z.next_in[num++] & 0xFF) << i; - continue; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - _ = tb[0]; - _ = -1; - num6 = hufts[(tb[0] + (num3 & inflate_mask[num6])) * 3 + 1]; - int num7 = hufts[(tb[0] + (num3 & inflate_mask[num6])) * 3 + 2]; - if (num7 < 16) - { - num3 = SupportClass.URShift(num3, num6); - i -= num6; - blens[index++] = num7; - continue; - } - int num8 = ((num7 == 18) ? 7 : (num7 - 14)); - int num9 = ((num7 == 18) ? 11 : 3); - for (; i < num6 + num8; i += 8) - { - if (num2 != 0) - { - r = 0; - num2--; - num3 |= (z.next_in[num++] & 0xFF) << i; - continue; - } - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - num3 = SupportClass.URShift(num3, num6); - i -= num6; - num9 += num3 & inflate_mask[num8]; - num3 = SupportClass.URShift(num3, num8); - i -= num8; - num8 = index; - num6 = table; - if (num8 + num9 > 258 + (num6 & 0x1F) + ((num6 >> 5) & 0x1F) || (num7 == 16 && num8 < 1)) - { - blens = null; - mode = 9; - z.msg = "invalid bit length repeat"; - r = -3; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - num7 = ((num7 == 16) ? blens[num8 - 1] : 0); - do - { - blens[num8++] = num7; - } - while (--num9 != 0); - index = num8; - } - tb[0] = -1; - int[] array = new int[1]; - int[] array2 = new int[1]; - int[] array3 = new int[1]; - int[] array4 = new int[1]; - array[0] = 9; - array2[0] = 6; - num6 = table; - num6 = InfTree.inflate_trees_dynamic(257 + (num6 & 0x1F), 1 + ((num6 >> 5) & 0x1F), blens, array, array2, array3, array4, hufts, z); - if (num6 != 0) - { - if (num6 == -3) - { - blens = null; - mode = 9; - } - r = num6; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - codes = new InfCodes(array[0], array2[0], hufts, array3[0], hufts, array4[0], z); - blens = null; - mode = 6; - goto case 6; - } - case 6: - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - if ((r = codes.proc(this, z, r)) != 1) - { - return inflate_flush(z, r); - } - r = 0; - codes.free(z); - num = z.next_in_index; - num2 = z.avail_in; - num3 = bitb; - i = bitk; - num4 = write; - num5 = ((num4 < read) ? (read - num4 - 1) : (end - num4)); - if (last == 0) - { - mode = 0; - break; - } - mode = 7; - goto case 7; - case 7: - write = num4; - r = inflate_flush(z, r); - num4 = write; - num5 = ((num4 < read) ? (read - num4 - 1) : (end - num4)); - if (read != write) - { - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - mode = 8; - goto case 8; - case 8: - r = 1; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - case 9: - r = -3; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - default: - r = -2; - bitb = num3; - bitk = i; - z.avail_in = num2; - z.total_in += num - z.next_in_index; - z.next_in_index = num; - write = num4; - return inflate_flush(z, r); - } - } - } - - internal void free(ZStream z) - { - reset(z, null); - window = null; - hufts = null; - } - - internal void set_dictionary(byte[] d, int start, int n) - { - Array.Copy(d, start, window, 0, n); - read = (write = n); - } - - internal int sync_point() - { - if (mode != 1) - { - return 0; - } - return 1; - } - - internal int inflate_flush(ZStream z, int r) - { - int next_out_index = z.next_out_index; - int num = read; - int num2 = ((num <= write) ? write : end) - num; - if (num2 > z.avail_out) - { - num2 = z.avail_out; - } - if (num2 != 0 && r == -5) - { - r = 0; - } - z.avail_out -= num2; - z.total_out += num2; - if (checkfn != null) - { - z.adler = (check = z._adler.adler32(check, window, num, num2)); - } - Array.Copy(window, num, z.next_out, next_out_index, num2); - next_out_index += num2; - num += num2; - if (num == end) - { - num = 0; - if (write == end) - { - write = 0; - } - num2 = write - num; - if (num2 > z.avail_out) - { - num2 = z.avail_out; - } - if (num2 != 0 && r == -5) - { - r = 0; - } - z.avail_out -= num2; - z.total_out += num2; - if (checkfn != null) - { - z.adler = (check = z._adler.adler32(check, window, num, num2)); - } - Array.Copy(window, num, z.next_out, next_out_index, num2); - next_out_index += num2; - num += num2; - } - z.next_out_index = next_out_index; - read = num; - return r; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfBlocks.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfBlocks.cs.meta deleted file mode 100644 index 553006c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfBlocks.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 38ff23616a4cf9349add205940d1e8de -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfCodes.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfCodes.cs deleted file mode 100644 index 47e6970..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfCodes.cs +++ /dev/null @@ -1,664 +0,0 @@ -using System; - -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class InfCodes - { - private static readonly int[] inflate_mask = new int[17] - { - 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, - 1023, 2047, 4095, 8191, 16383, 32767, 65535 - }; - - private const int Z_OK = 0; - - private const int Z_STREAM_END = 1; - - private const int Z_NEED_DICT = 2; - - private const int Z_ERRNO = -1; - - private const int Z_STREAM_ERROR = -2; - - private const int Z_DATA_ERROR = -3; - - private const int Z_MEM_ERROR = -4; - - private const int Z_BUF_ERROR = -5; - - private const int Z_VERSION_ERROR = -6; - - private const int START = 0; - - private const int LEN = 1; - - private const int LENEXT = 2; - - private const int DIST = 3; - - private const int DISTEXT = 4; - - private const int COPY = 5; - - private const int LIT = 6; - - private const int WASH = 7; - - private const int END = 8; - - private const int BADCODE = 9; - - internal int mode; - - internal int len; - - internal int[] tree; - - internal int tree_index; - - internal int need; - - internal int lit; - - internal int get_Renamed; - - internal int dist; - - internal byte lbits; - - internal byte dbits; - - internal int[] ltree; - - internal int ltree_index; - - internal int[] dtree; - - internal int dtree_index; - - internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) - { - mode = 0; - lbits = (byte)bl; - dbits = (byte)bd; - ltree = tl; - ltree_index = tl_index; - dtree = td; - dtree_index = td_index; - } - - internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z) - { - mode = 0; - lbits = (byte)bl; - dbits = (byte)bd; - ltree = tl; - ltree_index = 0; - dtree = td; - dtree_index = 0; - } - - internal int proc(InfBlocks s, ZStream z, int r) - { - int num = 0; - int num2 = 0; - int num3 = 0; - num3 = z.next_in_index; - int num4 = z.avail_in; - num = s.bitb; - num2 = s.bitk; - int num5 = s.write; - int num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - while (true) - { - switch (mode) - { - case 0: - if (num6 >= 258 && num4 >= 10) - { - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); - num3 = z.next_in_index; - num4 = z.avail_in; - num = s.bitb; - num2 = s.bitk; - num5 = s.write; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - if (r != 0) - { - mode = ((r == 1) ? 7 : 9); - break; - } - } - need = lbits; - tree = ltree; - tree_index = ltree_index; - mode = 1; - goto case 1; - case 1: - { - int num7; - for (num7 = need; num2 < num7; num2 += 8) - { - if (num4 != 0) - { - r = 0; - num4--; - num |= (z.next_in[num3++] & 0xFF) << num2; - continue; - } - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - int num8 = (tree_index + (num & inflate_mask[num7])) * 3; - num = SupportClass.URShift(num, tree[num8 + 1]); - num2 -= tree[num8 + 1]; - int num9 = tree[num8]; - if (num9 == 0) - { - lit = tree[num8 + 2]; - mode = 6; - break; - } - if (((uint)num9 & 0x10u) != 0) - { - get_Renamed = num9 & 0xF; - len = tree[num8 + 2]; - mode = 2; - break; - } - if ((num9 & 0x40) == 0) - { - need = num9; - tree_index = num8 / 3 + tree[num8 + 2]; - break; - } - if (((uint)num9 & 0x20u) != 0) - { - mode = 7; - break; - } - mode = 9; - z.msg = "invalid literal/length code"; - r = -3; - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - case 2: - { - int num7; - for (num7 = get_Renamed; num2 < num7; num2 += 8) - { - if (num4 != 0) - { - r = 0; - num4--; - num |= (z.next_in[num3++] & 0xFF) << num2; - continue; - } - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - len += num & inflate_mask[num7]; - num >>= num7; - num2 -= num7; - need = dbits; - tree = dtree; - tree_index = dtree_index; - mode = 3; - goto case 3; - } - case 3: - { - int num7; - for (num7 = need; num2 < num7; num2 += 8) - { - if (num4 != 0) - { - r = 0; - num4--; - num |= (z.next_in[num3++] & 0xFF) << num2; - continue; - } - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - int num8 = (tree_index + (num & inflate_mask[num7])) * 3; - num >>= tree[num8 + 1]; - num2 -= tree[num8 + 1]; - int num9 = tree[num8]; - if (((uint)num9 & 0x10u) != 0) - { - get_Renamed = num9 & 0xF; - dist = tree[num8 + 2]; - mode = 4; - break; - } - if ((num9 & 0x40) == 0) - { - need = num9; - tree_index = num8 / 3 + tree[num8 + 2]; - break; - } - mode = 9; - z.msg = "invalid distance code"; - r = -3; - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - case 4: - { - int num7; - for (num7 = get_Renamed; num2 < num7; num2 += 8) - { - if (num4 != 0) - { - r = 0; - num4--; - num |= (z.next_in[num3++] & 0xFF) << num2; - continue; - } - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - dist += num & inflate_mask[num7]; - num >>= num7; - num2 -= num7; - mode = 5; - goto case 5; - } - case 5: - { - int i; - for (i = num5 - dist; i < 0; i += s.end) - { - } - while (len != 0) - { - if (num6 == 0) - { - if (num5 == s.end && s.read != 0) - { - num5 = 0; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - } - if (num6 == 0) - { - s.write = num5; - r = s.inflate_flush(z, r); - num5 = s.write; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - if (num5 == s.end && s.read != 0) - { - num5 = 0; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - } - if (num6 == 0) - { - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - } - } - s.window[num5++] = s.window[i++]; - num6--; - if (i == s.end) - { - i = 0; - } - len--; - } - mode = 0; - break; - } - case 6: - if (num6 == 0) - { - if (num5 == s.end && s.read != 0) - { - num5 = 0; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - } - if (num6 == 0) - { - s.write = num5; - r = s.inflate_flush(z, r); - num5 = s.write; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - if (num5 == s.end && s.read != 0) - { - num5 = 0; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - } - if (num6 == 0) - { - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - } - } - r = 0; - s.window[num5++] = (byte)lit; - num6--; - mode = 0; - break; - case 7: - if (num2 > 7) - { - num2 -= 8; - num4++; - num3--; - } - s.write = num5; - r = s.inflate_flush(z, r); - num5 = s.write; - num6 = ((num5 < s.read) ? (s.read - num5 - 1) : (s.end - num5)); - if (s.read != s.write) - { - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - mode = 8; - goto case 8; - case 8: - r = 1; - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - case 9: - r = -3; - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - default: - r = -2; - s.bitb = num; - s.bitk = num2; - z.avail_in = num4; - z.total_in += num3 - z.next_in_index; - z.next_in_index = num3; - s.write = num5; - return s.inflate_flush(z, r); - } - } - } - - internal void free(ZStream z) - { - } - - internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) - { - int next_in_index = z.next_in_index; - int num = z.avail_in; - int num2 = s.bitb; - int num3 = s.bitk; - int num4 = s.write; - int num5 = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4)); - int num6 = inflate_mask[bl]; - int num7 = inflate_mask[bd]; - int num11; - while (true) - { - if (num3 < 20) - { - num--; - num2 |= (z.next_in[next_in_index++] & 0xFF) << num3; - num3 += 8; - continue; - } - int num8 = num2 & num6; - int[] array = tl; - int num9 = tl_index; - int num10; - if ((num10 = array[(num9 + num8) * 3]) == 0) - { - num2 >>= array[(num9 + num8) * 3 + 1]; - num3 -= array[(num9 + num8) * 3 + 1]; - s.window[num4++] = (byte)array[(num9 + num8) * 3 + 2]; - num5--; - } - else - { - while (true) - { - num2 >>= array[(num9 + num8) * 3 + 1]; - num3 -= array[(num9 + num8) * 3 + 1]; - if (((uint)num10 & 0x10u) != 0) - { - num10 &= 0xF; - num11 = array[(num9 + num8) * 3 + 2] + (num2 & inflate_mask[num10]); - num2 >>= num10; - for (num3 -= num10; num3 < 15; num3 += 8) - { - num--; - num2 |= (z.next_in[next_in_index++] & 0xFF) << num3; - } - num8 = num2 & num7; - array = td; - num9 = td_index; - num10 = array[(num9 + num8) * 3]; - while (true) - { - num2 >>= array[(num9 + num8) * 3 + 1]; - num3 -= array[(num9 + num8) * 3 + 1]; - if (((uint)num10 & 0x10u) != 0) - { - break; - } - if ((num10 & 0x40) == 0) - { - num8 += array[(num9 + num8) * 3 + 2]; - num8 += num2 & inflate_mask[num10]; - num10 = array[(num9 + num8) * 3]; - continue; - } - z.msg = "invalid distance code"; - num11 = z.avail_in - num; - num11 = ((num3 >> 3 < num11) ? (num3 >> 3) : num11); - num += num11; - next_in_index -= num11; - num3 -= num11 << 3; - s.bitb = num2; - s.bitk = num3; - z.avail_in = num; - z.total_in += next_in_index - z.next_in_index; - z.next_in_index = next_in_index; - s.write = num4; - return -3; - } - for (num10 &= 0xF; num3 < num10; num3 += 8) - { - num--; - num2 |= (z.next_in[next_in_index++] & 0xFF) << num3; - } - int num12 = array[(num9 + num8) * 3 + 2] + (num2 & inflate_mask[num10]); - num2 >>= num10; - num3 -= num10; - num5 -= num11; - int num13; - if (num4 >= num12) - { - num13 = num4 - num12; - if (num4 - num13 > 0 && 2 > num4 - num13) - { - s.window[num4++] = s.window[num13++]; - num11--; - s.window[num4++] = s.window[num13++]; - num11--; - } - else - { - Array.Copy(s.window, num13, s.window, num4, 2); - num4 += 2; - num13 += 2; - num11 -= 2; - } - } - else - { - num13 = num4 - num12; - do - { - num13 += s.end; - } - while (num13 < 0); - num10 = s.end - num13; - if (num11 > num10) - { - num11 -= num10; - if (num4 - num13 > 0 && num10 > num4 - num13) - { - do - { - s.window[num4++] = s.window[num13++]; - } - while (--num10 != 0); - } - else - { - Array.Copy(s.window, num13, s.window, num4, num10); - num4 += num10; - num13 += num10; - num10 = 0; - } - num13 = 0; - } - } - if (num4 - num13 > 0 && num11 > num4 - num13) - { - do - { - s.window[num4++] = s.window[num13++]; - } - while (--num11 != 0); - break; - } - Array.Copy(s.window, num13, s.window, num4, num11); - num4 += num11; - num13 += num11; - num11 = 0; - break; - } - if ((num10 & 0x40) == 0) - { - num8 += array[(num9 + num8) * 3 + 2]; - num8 += num2 & inflate_mask[num10]; - if ((num10 = array[(num9 + num8) * 3]) == 0) - { - num2 >>= array[(num9 + num8) * 3 + 1]; - num3 -= array[(num9 + num8) * 3 + 1]; - s.window[num4++] = (byte)array[(num9 + num8) * 3 + 2]; - num5--; - break; - } - continue; - } - if (((uint)num10 & 0x20u) != 0) - { - num11 = z.avail_in - num; - num11 = ((num3 >> 3 < num11) ? (num3 >> 3) : num11); - num += num11; - next_in_index -= num11; - num3 -= num11 << 3; - s.bitb = num2; - s.bitk = num3; - z.avail_in = num; - z.total_in += next_in_index - z.next_in_index; - z.next_in_index = next_in_index; - s.write = num4; - return 1; - } - z.msg = "invalid literal/length code"; - num11 = z.avail_in - num; - num11 = ((num3 >> 3 < num11) ? (num3 >> 3) : num11); - num += num11; - next_in_index -= num11; - num3 -= num11 << 3; - s.bitb = num2; - s.bitk = num3; - z.avail_in = num; - z.total_in += next_in_index - z.next_in_index; - z.next_in_index = next_in_index; - s.write = num4; - return -3; - } - } - if (num5 < 258 || num < 10) - { - break; - } - } - num11 = z.avail_in - num; - num11 = ((num3 >> 3 < num11) ? (num3 >> 3) : num11); - num += num11; - next_in_index -= num11; - num3 -= num11 << 3; - s.bitb = num2; - s.bitk = num3; - z.avail_in = num; - z.total_in += next_in_index - z.next_in_index; - z.next_in_index = next_in_index; - s.write = num4; - return 0; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfCodes.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfCodes.cs.meta deleted file mode 100644 index e6eeab3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfCodes.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 848289b37732055419a0cc1d6f28d36a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfTree.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfTree.cs deleted file mode 100644 index 0541076..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfTree.cs +++ /dev/null @@ -1,479 +0,0 @@ -using System; - -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class InfTree - { - private const int MANY = 1440; - - private const int Z_OK = 0; - - private const int Z_STREAM_END = 1; - - private const int Z_NEED_DICT = 2; - - private const int Z_ERRNO = -1; - - private const int Z_STREAM_ERROR = -2; - - private const int Z_DATA_ERROR = -3; - - private const int Z_MEM_ERROR = -4; - - private const int Z_BUF_ERROR = -5; - - private const int Z_VERSION_ERROR = -6; - - internal const int fixed_bl = 9; - - internal const int fixed_bd = 5; - - internal static readonly int[] fixed_tl = new int[1536] - { - 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, - 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, - 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, - 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, - 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, - 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, - 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, - 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, - 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, - 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, - 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, - 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, - 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, - 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, - 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, - 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, - 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, - 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, - 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, - 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, - 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, - 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, - 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, - 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, - 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, - 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, - 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, - 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, - 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, - 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, - 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, - 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, - 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, - 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, - 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, - 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, - 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, - 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, - 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, - 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, - 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, - 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, - 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, - 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, - 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, - 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, - 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, - 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, - 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, - 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, - 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, - 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, - 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, - 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, - 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, - 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, - 45, 0, 9, 186, 0, 8, 13, 0, 8, 141, - 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, - 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, - 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, - 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, - 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, - 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, - 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, - 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, - 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, - 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, - 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, - 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, - 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, - 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, - 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, - 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, - 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, - 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, - 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, - 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, - 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, - 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, - 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, - 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, - 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, - 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, - 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, - 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, - 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, - 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, - 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, - 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, - 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, - 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, - 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, - 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, - 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, - 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, - 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, - 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, - 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, - 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, - 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, - 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, - 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, - 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, - 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, - 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, - 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, - 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, - 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, - 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, - 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, - 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, - 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, - 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, - 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, - 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, - 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, - 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, - 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, - 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, - 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, - 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, - 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, - 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, - 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, - 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, - 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, - 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, - 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, - 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, - 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, - 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, - 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, - 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, - 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, - 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, - 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, - 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, - 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, - 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, - 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, - 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, - 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, - 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, - 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, - 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, - 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, - 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, - 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, - 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, - 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, - 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, - 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, - 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, - 0, 8, 79, 0, 9, 255 - }; - - internal static readonly int[] fixed_td = new int[96] - { - 80, 5, 1, 87, 5, 257, 83, 5, 17, 91, - 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, - 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, - 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, - 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, - 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, - 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, - 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, - 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, - 86, 5, 193, 192, 5, 24577 - }; - - internal static readonly int[] cplens = new int[31] - { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, - 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, - 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, - 0 - }; - - internal static readonly int[] cplext = new int[31] - { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, - 112 - }; - - internal static readonly int[] cpdist = new int[30] - { - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, - 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, - 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 - }; - - internal static readonly int[] cpdext = new int[30] - { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 - }; - - internal const int BMAX = 15; - - internal static int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v) - { - int[] array = new int[16]; - int[] array2 = new int[3]; - int[] array3 = new int[15]; - int[] array4 = new int[16]; - int num = 0; - int num2 = n; - do - { - array[b[bindex + num]]++; - num++; - num2--; - } - while (num2 != 0); - if (array[0] == n) - { - t[0] = -1; - m[0] = 0; - return 0; - } - int num3 = m[0]; - int i; - for (i = 1; i <= 15 && array[i] == 0; i++) - { - } - int j = i; - if (num3 < i) - { - num3 = i; - } - num2 = 15; - while (num2 != 0 && array[num2] == 0) - { - num2--; - } - int num4 = num2; - if (num3 > num2) - { - num3 = num2; - } - m[0] = num3; - int num5 = 1 << i; - while (i < num2) - { - if ((num5 -= array[i]) < 0) - { - return -3; - } - i++; - num5 <<= 1; - } - if ((num5 -= array[num2]) < 0) - { - return -3; - } - array[num2] += num5; - i = (array4[1] = 0); - num = 1; - int num6 = 2; - while (--num2 != 0) - { - i = (array4[num6] = i + array[num]); - num6++; - num++; - } - num2 = 0; - num = 0; - do - { - if ((i = b[bindex + num]) != 0) - { - v[array4[i]++] = num2; - } - num++; - } - while (++num2 < n); - n = array4[num4]; - num2 = (array4[0] = 0); - num = 0; - int num7 = -1; - int num8 = -num3; - array3[0] = 0; - int num9 = 0; - int num10 = 0; - for (; j <= num4; j++) - { - int num11 = array[j]; - while (num11-- != 0) - { - int num12; - while (j > num8 + num3) - { - num7++; - num8 += num3; - num10 = num4 - num8; - num10 = ((num10 > num3) ? num3 : num10); - if ((num12 = 1 << (i = j - num8)) > num11 + 1) - { - num12 -= num11 + 1; - num6 = j; - if (i < num10) - { - while (++i < num10 && (num12 <<= 1) > array[++num6]) - { - num12 -= array[num6]; - } - } - } - num10 = 1 << i; - if (hn[0] + num10 > 1440) - { - return -3; - } - num9 = (array3[num7] = hn[0]); - hn[0] += num10; - if (num7 != 0) - { - array4[num7] = num2; - array2[0] = (byte)i; - array2[1] = (byte)num3; - i = SupportClass.URShift(num2, num8 - num3); - array2[2] = num9 - array3[num7 - 1] - i; - Array.Copy(array2, 0, hp, (array3[num7 - 1] + i) * 3, 3); - } - else - { - t[0] = num9; - } - } - array2[1] = (byte)(j - num8); - if (num >= n) - { - array2[0] = 192; - } - else if (v[num] < s) - { - array2[0] = (byte)((v[num] >= 256) ? 96 : 0); - array2[2] = v[num++]; - } - else - { - array2[0] = (byte)(e[v[num] - s] + 16 + 64); - array2[2] = d[v[num++] - s]; - } - num12 = 1 << j - num8; - for (i = SupportClass.URShift(num2, num8); i < num10; i += num12) - { - Array.Copy(array2, 0, hp, (num9 + i) * 3, 3); - } - i = 1 << j - 1; - while ((num2 & i) != 0) - { - num2 ^= i; - i = SupportClass.URShift(i, 1); - } - num2 ^= i; - int num13 = (1 << num8) - 1; - while ((num2 & num13) != array4[num7]) - { - num7--; - num8 -= num3; - num13 = (1 << num8) - 1; - } - } - } - if (num5 == 0 || num4 == 1) - { - return 0; - } - return -5; - } - - internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) - { - int[] hn = new int[1]; - int[] v = new int[19]; - int num = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v); - if (num == -3) - { - z.msg = "oversubscribed dynamic bit lengths tree"; - } - else if (num == -5 || bb[0] == 0) - { - z.msg = "incomplete dynamic bit lengths tree"; - num = -3; - } - return num; - } - - internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) - { - int[] hn = new int[1]; - int[] v = new int[288]; - int num = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v); - if (num != 0 || bl[0] == 0) - { - switch (num) - { - case -3: - z.msg = "oversubscribed literal/length tree"; - break; - default: - z.msg = "incomplete literal/length tree"; - num = -3; - break; - case -4: - break; - } - return num; - } - num = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v); - if (num != 0 || (bd[0] == 0 && nl > 257)) - { - switch (num) - { - case -3: - z.msg = "oversubscribed distance tree"; - break; - case -5: - z.msg = "incomplete distance tree"; - num = -3; - break; - default: - z.msg = "empty distance tree with lengths"; - num = -3; - break; - case -4: - break; - } - return num; - } - return 0; - } - - internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) - { - bl[0] = 9; - bd[0] = 5; - tl[0] = fixed_tl; - td[0] = fixed_td; - return 0; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfTree.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfTree.cs.meta deleted file mode 100644 index 23d1b6a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/InfTree.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 12c1095bcb2a9e748af19115781c4483 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Inflate.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Inflate.cs deleted file mode 100644 index d2ee7f1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Inflate.cs +++ /dev/null @@ -1,409 +0,0 @@ -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class Inflate - { - private const int MAX_WBITS = 15; - - private const int PRESET_DICT = 32; - - internal const int Z_NO_FLUSH = 0; - - internal const int Z_PARTIAL_FLUSH = 1; - - internal const int Z_SYNC_FLUSH = 2; - - internal const int Z_FULL_FLUSH = 3; - - internal const int Z_FINISH = 4; - - private const int Z_DEFLATED = 8; - - private const int Z_OK = 0; - - private const int Z_STREAM_END = 1; - - private const int Z_NEED_DICT = 2; - - private const int Z_ERRNO = -1; - - private const int Z_STREAM_ERROR = -2; - - private const int Z_DATA_ERROR = -3; - - private const int Z_MEM_ERROR = -4; - - private const int Z_BUF_ERROR = -5; - - private const int Z_VERSION_ERROR = -6; - - private const int METHOD = 0; - - private const int FLAG = 1; - - private const int DICT4 = 2; - - private const int DICT3 = 3; - - private const int DICT2 = 4; - - private const int DICT1 = 5; - - private const int DICT0 = 6; - - private const int BLOCKS = 7; - - private const int CHECK4 = 8; - - private const int CHECK3 = 9; - - private const int CHECK2 = 10; - - private const int CHECK1 = 11; - - private const int DONE = 12; - - private const int BAD = 13; - - internal int mode; - - internal int method; - - internal long[] was = new long[1]; - - internal long need; - - internal int marker; - - internal int nowrap; - - internal int wbits; - - internal InfBlocks blocks; - - private static byte[] mark = new byte[4] - { - 0, - 0, - (byte)SupportClass.Identity(255L), - (byte)SupportClass.Identity(255L) - }; - - internal int inflateReset(ZStream z) - { - if (z == null || z.istate == null) - { - return -2; - } - z.total_in = (z.total_out = 0L); - z.msg = null; - z.istate.mode = ((z.istate.nowrap != 0) ? 7 : 0); - z.istate.blocks.reset(z, null); - return 0; - } - - internal int inflateEnd(ZStream z) - { - if (blocks != null) - { - blocks.free(z); - } - blocks = null; - return 0; - } - - internal int inflateInit(ZStream z, int w) - { - z.msg = null; - blocks = null; - nowrap = 0; - if (w < 0) - { - w = -w; - nowrap = 1; - } - if (w < 8 || w > 15) - { - inflateEnd(z); - return -2; - } - wbits = w; - z.istate.blocks = new InfBlocks(z, (z.istate.nowrap != 0) ? null : this, 1 << w); - inflateReset(z); - return 0; - } - - internal int inflate(ZStream z, int f) - { - if (z == null || z.istate == null || z.next_in == null) - { - return -2; - } - f = ((f == 4) ? (-5) : 0); - int num = -5; - while (true) - { - switch (z.istate.mode) - { - case 0: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xF) != 8) - { - z.istate.mode = 13; - z.msg = "unknown compression method"; - z.istate.marker = 5; - break; - } - if ((z.istate.method >> 4) + 8 > z.istate.wbits) - { - z.istate.mode = 13; - z.msg = "invalid window size"; - z.istate.marker = 5; - break; - } - z.istate.mode = 1; - goto case 1; - case 1: - { - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - int num2 = z.next_in[z.next_in_index++] & 0xFF; - if (((z.istate.method << 8) + num2) % 31 != 0) - { - z.istate.mode = 13; - z.msg = "incorrect header check"; - z.istate.marker = 5; - break; - } - if ((num2 & 0x20) == 0) - { - z.istate.mode = 7; - break; - } - z.istate.mode = 2; - goto case 2; - } - case 2: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need = ((z.next_in[z.next_in_index++] & 0xFF) << 24) & -16777216; - z.istate.mode = 3; - goto case 3; - case 3: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need += (long)((ulong)((z.next_in[z.next_in_index++] & 0xFF) << 16) & 0xFF0000uL); - z.istate.mode = 4; - goto case 4; - case 4: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need += (long)((ulong)((z.next_in[z.next_in_index++] & 0xFF) << 8) & 0xFF00uL); - z.istate.mode = 5; - goto case 5; - case 5: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need += (long)((ulong)z.next_in[z.next_in_index++] & 0xFFuL); - z.adler = z.istate.need; - z.istate.mode = 6; - return 2; - case 6: - z.istate.mode = 13; - z.msg = "need dictionary"; - z.istate.marker = 0; - return -2; - case 7: - num = z.istate.blocks.proc(z, num); - switch (num) - { - case -3: - z.istate.mode = 13; - z.istate.marker = 0; - goto end_IL_0031; - case 0: - num = f; - break; - } - if (num != 1) - { - return num; - } - num = f; - z.istate.blocks.reset(z, z.istate.was); - if (z.istate.nowrap != 0) - { - z.istate.mode = 12; - break; - } - z.istate.mode = 8; - goto case 8; - case 8: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need = ((z.next_in[z.next_in_index++] & 0xFF) << 24) & -16777216; - z.istate.mode = 9; - goto case 9; - case 9: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need += (long)((ulong)((z.next_in[z.next_in_index++] & 0xFF) << 16) & 0xFF0000uL); - z.istate.mode = 10; - goto case 10; - case 10: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need += (long)((ulong)((z.next_in[z.next_in_index++] & 0xFF) << 8) & 0xFF00uL); - z.istate.mode = 11; - goto case 11; - case 11: - if (z.avail_in == 0) - { - return num; - } - num = f; - z.avail_in--; - z.total_in++; - z.istate.need += (long)((ulong)z.next_in[z.next_in_index++] & 0xFFuL); - if ((int)z.istate.was[0] != (int)z.istate.need) - { - z.istate.mode = 13; - z.msg = "incorrect data check"; - z.istate.marker = 5; - break; - } - z.istate.mode = 12; - goto case 12; - case 12: - return 1; - case 13: - return -3; - default: - { - return -2; - } - end_IL_0031: - break; - } - } - } - - internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) - { - int start = 0; - int num = dictLength; - if (z == null || z.istate == null || z.istate.mode != 6) - { - return -2; - } - if (z._adler.adler32(1L, dictionary, 0, dictLength) != z.adler) - { - return -3; - } - z.adler = z._adler.adler32(0L, null, 0, 0); - if (num >= 1 << z.istate.wbits) - { - num = (1 << z.istate.wbits) - 1; - start = dictLength - num; - } - z.istate.blocks.set_dictionary(dictionary, start, num); - z.istate.mode = 7; - return 0; - } - - internal int inflateSync(ZStream z) - { - if (z == null || z.istate == null) - { - return -2; - } - if (z.istate.mode != 13) - { - z.istate.mode = 13; - z.istate.marker = 0; - } - int num; - if ((num = z.avail_in) == 0) - { - return -5; - } - int num2 = z.next_in_index; - int num3 = z.istate.marker; - while (num != 0 && num3 < 4) - { - num3 = ((z.next_in[num2] != mark[num3]) ? ((z.next_in[num2] == 0) ? (4 - num3) : 0) : (num3 + 1)); - num2++; - num--; - } - z.total_in += num2 - z.next_in_index; - z.next_in_index = num2; - z.avail_in = num; - z.istate.marker = num3; - if (num3 != 4) - { - return -3; - } - long total_in = z.total_in; - long total_out = z.total_out; - inflateReset(z); - z.total_in = total_in; - z.total_out = total_out; - z.istate.mode = 7; - return 0; - } - - internal int inflateSyncPoint(ZStream z) - { - if (z == null || z.istate == null || z.istate.blocks == null) - { - return -2; - } - return z.istate.blocks.sync_point(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Inflate.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Inflate.cs.meta deleted file mode 100644 index a814ad8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Inflate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f0c7c284a3a696541b95af8150097d7d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/StaticTree.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/StaticTree.cs deleted file mode 100644 index a19fb00..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/StaticTree.cs +++ /dev/null @@ -1,126 +0,0 @@ -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class StaticTree - { - private const int MAX_BITS = 15; - - private const int BL_CODES = 19; - - private const int D_CODES = 30; - - private const int LITERALS = 256; - - private const int LENGTH_CODES = 29; - - private static readonly int L_CODES; - - internal const int MAX_BL_BITS = 7; - - internal static readonly short[] static_ltree; - - internal static readonly short[] static_dtree; - - internal static StaticTree static_l_desc; - - internal static StaticTree static_d_desc; - - internal static StaticTree static_bl_desc; - - internal short[] static_tree; - - internal int[] extra_bits; - - internal int extra_base; - - internal int elems; - - internal int max_length; - - internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length) - { - this.static_tree = static_tree; - this.extra_bits = extra_bits; - this.extra_base = extra_base; - this.elems = elems; - this.max_length = max_length; - } - - static StaticTree() - { - L_CODES = 286; - static_ltree = new short[576] - { - 12, 8, 140, 8, 76, 8, 204, 8, 44, 8, - 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, - 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, - 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, - 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, - 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, - 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, - 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, - 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, - 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, - 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, - 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, - 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, - 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, - 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, - 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, - 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, - 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, - 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, - 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, - 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, - 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, - 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, - 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, - 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, - 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, - 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, - 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, - 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, - 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, - 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, - 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, - 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, - 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, - 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, - 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, - 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, - 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, - 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, - 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, - 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, - 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, - 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, - 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, - 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, - 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, - 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, - 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, - 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, - 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, - 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, - 511, 9, 0, 7, 64, 7, 32, 7, 96, 7, - 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, - 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, - 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, - 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, - 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, - 163, 8, 99, 8, 227, 8 - }; - static_dtree = new short[60] - { - 0, 5, 16, 5, 8, 5, 24, 5, 4, 5, - 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, - 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, - 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, - 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, - 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 - }; - static_l_desc = new StaticTree(static_ltree, Tree.extra_lbits, 257, L_CODES, 15); - static_d_desc = new StaticTree(static_dtree, Tree.extra_dbits, 0, 30, 15); - static_bl_desc = new StaticTree(null, Tree.extra_blbits, 0, 19, 7); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/StaticTree.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/StaticTree.cs.meta deleted file mode 100644 index ea36f10..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/StaticTree.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6d5351586a003ca4da795d2ce129ba8e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/SupportClass.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/SupportClass.cs deleted file mode 100644 index b55a3af..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/SupportClass.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System.IO; -using System.Text; - -namespace ComponentAce.Compression.Libs.zlib -{ - public class SupportClass - { - public static long Identity(long literal) - { - return literal; - } - - public static ulong Identity(ulong literal) - { - return literal; - } - - public static float Identity(float literal) - { - return literal; - } - - public static double Identity(double literal) - { - return literal; - } - - public static int URShift(int number, int bits) - { - if (number >= 0) - { - return number >> bits; - } - return (number >> bits) + (2 << ~bits); - } - - public static int URShift(int number, long bits) - { - return URShift(number, (int)bits); - } - - public static long URShift(long number, int bits) - { - if (number >= 0) - { - return number >> bits; - } - return (number >> bits) + (2L << ~bits); - } - - public static long URShift(long number, long bits) - { - return URShift(number, (int)bits); - } - - public static int ReadInput(Stream sourceStream, byte[] target, int start, int count) - { - if (target.Length == 0) - { - return 0; - } - byte[] array = new byte[target.Length]; - int num = sourceStream.Read(array, start, count); - if (num == 0) - { - return -1; - } - for (int i = start; i < start + num; i++) - { - target[i] = array[i]; - } - return num; - } - - public static int ReadInput(TextReader sourceTextReader, byte[] target, int start, int count) - { - if (target.Length == 0) - { - return 0; - } - char[] array = new char[target.Length]; - int num = sourceTextReader.Read(array, start, count); - if (num == 0) - { - return -1; - } - for (int i = start; i < start + num; i++) - { - target[i] = (byte)array[i]; - } - return num; - } - - public static byte[] ToByteArray(string sourceString) - { - return Encoding.UTF8.GetBytes(sourceString); - } - - public static char[] ToCharArray(byte[] byteArray) - { - return Encoding.UTF8.GetChars(byteArray); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/SupportClass.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/SupportClass.cs.meta deleted file mode 100644 index f145dcd..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/SupportClass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 192062774319d2845b2df445d3215268 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Tree.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Tree.cs deleted file mode 100644 index 163b300..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Tree.cs +++ /dev/null @@ -1,341 +0,0 @@ -using System; - -namespace ComponentAce.Compression.Libs.zlib -{ - internal sealed class Tree - { - private const int MAX_BITS = 15; - - private const int BL_CODES = 19; - - private const int D_CODES = 30; - - private const int LITERALS = 256; - - private const int LENGTH_CODES = 29; - - private static readonly int L_CODES = 286; - - private static readonly int HEAP_SIZE = 2 * L_CODES + 1; - - internal const int MAX_BL_BITS = 7; - - internal const int END_BLOCK = 256; - - internal const int REP_3_6 = 16; - - internal const int REPZ_3_10 = 17; - - internal const int REPZ_11_138 = 18; - - internal static readonly int[] extra_lbits = new int[29] - { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 5, 5, 5, 5, 0 - }; - - internal static readonly int[] extra_dbits = new int[30] - { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 - }; - - internal static readonly int[] extra_blbits = new int[19] - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2, 3, 7 - }; - - internal static readonly byte[] bl_order = new byte[19] - { - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, - 11, 4, 12, 3, 13, 2, 14, 1, 15 - }; - - internal const int Buf_size = 16; - - internal const int DIST_CODE_LEN = 512; - - internal static readonly byte[] _dist_code = new byte[512] - { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, - 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, - 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, - 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, - 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29 - }; - - internal static readonly byte[] _length_code = new byte[256] - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, - 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, - 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, - 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, - 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, - 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, - 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 28 - }; - - internal static readonly int[] base_length = new int[29] - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, - 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, - 64, 80, 96, 112, 128, 160, 192, 224, 0 - }; - - internal static readonly int[] base_dist = new int[30] - { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 - }; - - internal short[] dyn_tree; - - internal int max_code; - - internal StaticTree stat_desc; - - internal static int d_code(int dist) - { - if (dist >= 256) - { - return _dist_code[256 + SupportClass.URShift(dist, 7)]; - } - return _dist_code[dist]; - } - - internal void gen_bitlen(Deflate s) - { - short[] array = dyn_tree; - short[] static_tree = stat_desc.static_tree; - int[] extra_bits = stat_desc.extra_bits; - int extra_base = stat_desc.extra_base; - int max_length = stat_desc.max_length; - int num = 0; - for (int i = 0; i <= 15; i++) - { - s.bl_count[i] = 0; - } - array[s.heap[s.heap_max] * 2 + 1] = 0; - int j; - for (j = s.heap_max + 1; j < HEAP_SIZE; j++) - { - int num2 = s.heap[j]; - int i = array[array[num2 * 2 + 1] * 2 + 1] + 1; - if (i > max_length) - { - i = max_length; - num++; - } - array[num2 * 2 + 1] = (short)i; - if (num2 <= max_code) - { - s.bl_count[i]++; - int num3 = 0; - if (num2 >= extra_base) - { - num3 = extra_bits[num2 - extra_base]; - } - short num4 = array[num2 * 2]; - s.opt_len += num4 * (i + num3); - if (static_tree != null) - { - s.static_len += num4 * (static_tree[num2 * 2 + 1] + num3); - } - } - } - if (num == 0) - { - return; - } - do - { - int i = max_length - 1; - while (s.bl_count[i] == 0) - { - i--; - } - s.bl_count[i]--; - s.bl_count[i + 1] = (short)(s.bl_count[i + 1] + 2); - s.bl_count[max_length]--; - num -= 2; - } - while (num > 0); - for (int i = max_length; i != 0; i--) - { - int num2 = s.bl_count[i]; - while (num2 != 0) - { - int num5 = s.heap[--j]; - if (num5 <= max_code) - { - if (array[num5 * 2 + 1] != i) - { - s.opt_len = (int)(s.opt_len + ((long)i - (long)array[num5 * 2 + 1]) * array[num5 * 2]); - array[num5 * 2 + 1] = (short)i; - } - num2--; - } - } - } - } - - internal void build_tree(Deflate s) - { - short[] array = dyn_tree; - short[] static_tree = stat_desc.static_tree; - int elems = stat_desc.elems; - int num = -1; - s.heap_len = 0; - s.heap_max = HEAP_SIZE; - for (int i = 0; i < elems; i++) - { - if (array[i * 2] != 0) - { - num = (s.heap[++s.heap_len] = i); - s.depth[i] = 0; - } - else - { - array[i * 2 + 1] = 0; - } - } - int num2; - while (s.heap_len < 2) - { - num2 = (s.heap[++s.heap_len] = ((num < 2) ? (++num) : 0)); - array[num2 * 2] = 1; - s.depth[num2] = 0; - s.opt_len--; - if (static_tree != null) - { - s.static_len -= static_tree[num2 * 2 + 1]; - } - } - max_code = num; - for (int i = s.heap_len / 2; i >= 1; i--) - { - s.pqdownheap(array, i); - } - num2 = elems; - do - { - int i = s.heap[1]; - s.heap[1] = s.heap[s.heap_len--]; - s.pqdownheap(array, 1); - int num3 = s.heap[1]; - s.heap[--s.heap_max] = i; - s.heap[--s.heap_max] = num3; - array[num2 * 2] = (short)(array[i * 2] + array[num3 * 2]); - s.depth[num2] = (byte)(Math.Max(s.depth[i], s.depth[num3]) + 1); - array[i * 2 + 1] = (array[num3 * 2 + 1] = (short)num2); - s.heap[1] = num2++; - s.pqdownheap(array, 1); - } - while (s.heap_len >= 2); - s.heap[--s.heap_max] = s.heap[1]; - gen_bitlen(s); - gen_codes(array, num, s.bl_count); - } - - internal static void gen_codes(short[] tree, int max_code, short[] bl_count) - { - short[] array = new short[16]; - short num = 0; - for (int i = 1; i <= 15; i++) - { - num = (array[i] = (short)(num + bl_count[i - 1] << 1)); - } - for (int j = 0; j <= max_code; j++) - { - int num2 = tree[j * 2 + 1]; - if (num2 != 0) - { - tree[j * 2] = (short)bi_reverse(array[num2]++, num2); - } - } - } - - internal static int bi_reverse(int code, int len) - { - int num = 0; - do - { - num |= code & 1; - code = SupportClass.URShift(code, 1); - num <<= 1; - } - while (--len > 0); - return SupportClass.URShift(num, 1); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Tree.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Tree.cs.meta deleted file mode 100644 index dc2f835..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/Tree.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 09b036b3d0426fe42bf7d0dd3bd0cca9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZInputStream.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZInputStream.cs deleted file mode 100644 index 4cb829c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZInputStream.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System.IO; - -namespace ComponentAce.Compression.Libs.zlib -{ - public class ZInputStream : BinaryReader - { - protected ZStream z = new ZStream(); - - protected int bufsize = 512; - - protected int flush; - - protected byte[] buf; - - protected byte[] buf1 = new byte[1]; - - protected bool compress; - - internal Stream in_Renamed; - - internal bool nomoreinput; - - public virtual int FlushMode - { - get - { - return flush; - } - set - { - flush = value; - } - } - - public virtual long TotalIn => z.total_in; - - public virtual long TotalOut => z.total_out; - - internal void InitBlock() - { - flush = 0; - buf = new byte[bufsize]; - } - - public ZInputStream(Stream in_Renamed) - : base(in_Renamed) - { - InitBlock(); - this.in_Renamed = in_Renamed; - z.inflateInit(); - compress = false; - z.next_in = buf; - z.next_in_index = 0; - z.avail_in = 0; - } - - public ZInputStream(Stream in_Renamed, int level) - : base(in_Renamed) - { - InitBlock(); - this.in_Renamed = in_Renamed; - z.deflateInit(level); - compress = true; - z.next_in = buf; - z.next_in_index = 0; - z.avail_in = 0; - } - - public override int Read() - { - if (read(buf1, 0, 1) == -1) - { - return -1; - } - return buf1[0] & 0xFF; - } - - public int read(byte[] b, int off, int len) - { - if (len == 0) - { - return 0; - } - z.next_out = b; - z.next_out_index = off; - z.avail_out = len; - int num; - do - { - if (z.avail_in == 0 && !nomoreinput) - { - z.next_in_index = 0; - z.avail_in = SupportClass.ReadInput(in_Renamed, buf, 0, bufsize); - if (z.avail_in == -1) - { - z.avail_in = 0; - nomoreinput = true; - } - } - num = ((!compress) ? z.inflate(flush) : z.deflate(flush)); - if (nomoreinput && num == -5) - { - return -1; - } - if (num != 0 && num != 1) - { - throw new ZStreamException((compress ? "de" : "in") + "flating: " + z.msg); - } - if (nomoreinput && z.avail_out == len) - { - return -1; - } - } - while (z.avail_out == len && num == 0); - return len - z.avail_out; - } - - public long skip(long n) - { - int num = 512; - if (n < num) - { - num = (int)n; - } - byte[] array = new byte[num]; - return SupportClass.ReadInput(BaseStream, array, 0, array.Length); - } - - public override void Close() - { - in_Renamed.Close(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZInputStream.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZInputStream.cs.meta deleted file mode 100644 index e9ed2b9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZInputStream.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 005058a4e4fb325449d934f67cfa0ce9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZOutputStream.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZOutputStream.cs deleted file mode 100644 index 0681b55..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZOutputStream.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.IO; - -namespace ComponentAce.Compression.Libs.zlib -{ - public class ZOutputStream : Stream - { - protected internal ZStream z = new ZStream(); - - protected internal int bufsize = 4096; - - protected internal int flush_Renamed_Field; - - protected internal byte[] buf; - - protected internal byte[] buf1 = new byte[1]; - - protected internal bool compress; - - private Stream out_Renamed; - - public virtual int FlushMode - { - get - { - return flush_Renamed_Field; - } - set - { - flush_Renamed_Field = value; - } - } - - public virtual long TotalIn => z.total_in; - - public virtual long TotalOut => z.total_out; - - public override bool CanRead => false; - - public override bool CanSeek => false; - - public override bool CanWrite => false; - - public override long Length => 0L; - - public override long Position - { - get - { - return 0L; - } - set - { - } - } - - private void InitBlock() - { - flush_Renamed_Field = 0; - buf = new byte[bufsize]; - } - - public ZOutputStream(Stream out_Renamed) - { - InitBlock(); - this.out_Renamed = out_Renamed; - z.inflateInit(); - compress = false; - } - - public ZOutputStream(Stream out_Renamed, int level) - { - InitBlock(); - this.out_Renamed = out_Renamed; - z.deflateInit(level); - compress = true; - } - - public void WriteByte(int b) - { - buf1[0] = (byte)b; - Write(buf1, 0, 1); - } - - public override void WriteByte(byte b) - { - WriteByte(b); - } - - public override void Write(byte[] b1, int off, int len) - { - if (len == 0) - { - return; - } - byte[] array = new byte[b1.Length]; - Array.Copy(b1, 0, array, 0, b1.Length); - z.next_in = array; - z.next_in_index = off; - z.avail_in = len; - do - { - z.next_out = buf; - z.next_out_index = 0; - z.avail_out = bufsize; - int num = ((!compress) ? z.inflate(flush_Renamed_Field) : z.deflate(flush_Renamed_Field)); - if (num != 0 && num != 1) - { - throw new ZStreamException((compress ? "de" : "in") + "flating: " + z.msg); - } - out_Renamed.Write(buf, 0, bufsize - z.avail_out); - } - while (z.avail_in > 0 || z.avail_out == 0); - } - - public virtual void finish() - { - do - { - z.next_out = buf; - z.next_out_index = 0; - z.avail_out = bufsize; - int num = ((!compress) ? z.inflate(4) : z.deflate(4)); - if (num != 1 && num != 0) - { - throw new ZStreamException((compress ? "de" : "in") + "flating: " + z.msg); - } - if (bufsize - z.avail_out > 0) - { - out_Renamed.Write(buf, 0, bufsize - z.avail_out); - } - } - while (z.avail_in > 0 || z.avail_out == 0); - try - { - Flush(); - } - catch - { - } - } - - public virtual void end() - { - if (compress) - { - z.deflateEnd(); - } - else - { - z.inflateEnd(); - } - z.free(); - z = null; - } - - public override void Close() - { - try - { - finish(); - } - catch - { - } - finally - { - end(); - out_Renamed.Close(); - out_Renamed = null; - } - } - - public override void Flush() - { - out_Renamed.Flush(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - return 0; - } - - public override void SetLength(long value) - { - } - - public override long Seek(long offset, SeekOrigin origin) - { - return 0L; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZOutputStream.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZOutputStream.cs.meta deleted file mode 100644 index 569e09b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZOutputStream.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7c3c209ceb37db9499856d560dffd88e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStream.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStream.cs deleted file mode 100644 index c94d957..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStream.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; - -namespace ComponentAce.Compression.Libs.zlib -{ - public sealed class ZStream - { - private const int MAX_WBITS = 15; - - private static readonly int DEF_WBITS = 15; - - private const int Z_NO_FLUSH = 0; - - private const int Z_PARTIAL_FLUSH = 1; - - private const int Z_SYNC_FLUSH = 2; - - private const int Z_FULL_FLUSH = 3; - - private const int Z_FINISH = 4; - - private const int MAX_MEM_LEVEL = 9; - - private const int Z_OK = 0; - - private const int Z_STREAM_END = 1; - - private const int Z_NEED_DICT = 2; - - private const int Z_ERRNO = -1; - - private const int Z_STREAM_ERROR = -2; - - private const int Z_DATA_ERROR = -3; - - private const int Z_MEM_ERROR = -4; - - private const int Z_BUF_ERROR = -5; - - private const int Z_VERSION_ERROR = -6; - - public byte[] next_in; - - public int next_in_index; - - public int avail_in; - - public long total_in; - - public byte[] next_out; - - public int next_out_index; - - public int avail_out; - - public long total_out; - - public string msg; - - internal Deflate dstate; - - internal Inflate istate; - - internal int data_type; - - public long adler; - - internal Adler32 _adler = new Adler32(); - - public int inflateInit() - { - return inflateInit(DEF_WBITS); - } - - public int inflateInit(int w) - { - istate = new Inflate(); - return istate.inflateInit(this, w); - } - - public int inflate(int f) - { - if (istate == null) - { - return -2; - } - return istate.inflate(this, f); - } - - public int inflateEnd() - { - if (istate == null) - { - return -2; - } - int result = istate.inflateEnd(this); - istate = null; - return result; - } - - public int inflateSync() - { - if (istate == null) - { - return -2; - } - return istate.inflateSync(this); - } - - public int inflateSetDictionary(byte[] dictionary, int dictLength) - { - if (istate == null) - { - return -2; - } - return istate.inflateSetDictionary(this, dictionary, dictLength); - } - - public int deflateInit(int level) - { - return deflateInit(level, 15); - } - - public int deflateInit(int level, int bits) - { - dstate = new Deflate(); - return dstate.deflateInit(this, level, bits); - } - - public int deflate(int flush) - { - if (dstate == null) - { - return -2; - } - return dstate.deflate(this, flush); - } - - public int deflateEnd() - { - if (dstate == null) - { - return -2; - } - int result = dstate.deflateEnd(); - dstate = null; - return result; - } - - public int deflateParams(int level, int strategy) - { - if (dstate == null) - { - return -2; - } - return dstate.deflateParams(this, level, strategy); - } - - public int deflateSetDictionary(byte[] dictionary, int dictLength) - { - if (dstate == null) - { - return -2; - } - return dstate.deflateSetDictionary(this, dictionary, dictLength); - } - - internal void flush_pending() - { - int pending = dstate.pending; - if (pending > avail_out) - { - pending = avail_out; - } - if (pending != 0) - { - if (dstate.pending_buf.Length > dstate.pending_out && next_out.Length > next_out_index && dstate.pending_buf.Length >= dstate.pending_out + pending) - { - _ = next_out.Length; - _ = next_out_index + pending; - } - Array.Copy(dstate.pending_buf, dstate.pending_out, next_out, next_out_index, pending); - next_out_index += pending; - dstate.pending_out += pending; - total_out += pending; - avail_out -= pending; - dstate.pending -= pending; - if (dstate.pending == 0) - { - dstate.pending_out = 0; - } - } - } - - internal int read_buf(byte[] buf, int start, int size) - { - int num = avail_in; - if (num > size) - { - num = size; - } - if (num == 0) - { - return 0; - } - avail_in -= num; - if (dstate.noheader == 0) - { - adler = _adler.adler32(adler, next_in, next_in_index, num); - } - Array.Copy(next_in, next_in_index, buf, start, num); - next_in_index += num; - total_in += num; - return num; - } - - public void free() - { - next_in = null; - next_out = null; - msg = null; - _adler = null; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStream.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStream.cs.meta deleted file mode 100644 index fd3afb8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStream.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a7dac276d0775834da0bd77f4b3bca54 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStreamException.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStreamException.cs deleted file mode 100644 index 5d3cf67..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStreamException.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.IO; - -namespace ComponentAce.Compression.Libs.zlib -{ - public class ZStreamException : IOException - { - public ZStreamException() - { - } - - public ZStreamException(string s) - : base(s) - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStreamException.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStreamException.cs.meta deleted file mode 100644 index 865aa54..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/ZStreamException.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9059b75bb33b8f546a3634f6c1f15418 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/zlibConst.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/zlibConst.cs deleted file mode 100644 index 3211281..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/zlibConst.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace ComponentAce.Compression.Libs.zlib -{ - public sealed class zlibConst - { - private const string version_Renamed_Field = "1.0.2"; - - public const int Z_NO_COMPRESSION = 0; - - public const int Z_BEST_SPEED = 1; - - public const int Z_BEST_COMPRESSION = 9; - - public const int Z_DEFAULT_COMPRESSION = -1; - - public const int Z_FILTERED = 1; - - public const int Z_HUFFMAN_ONLY = 2; - - public const int Z_DEFAULT_STRATEGY = 0; - - public const int Z_NO_FLUSH = 0; - - public const int Z_PARTIAL_FLUSH = 1; - - public const int Z_SYNC_FLUSH = 2; - - public const int Z_FULL_FLUSH = 3; - - public const int Z_FINISH = 4; - - public const int Z_OK = 0; - - public const int Z_STREAM_END = 1; - - public const int Z_NEED_DICT = 2; - - public const int Z_ERRNO = -1; - - public const int Z_STREAM_ERROR = -2; - - public const int Z_DATA_ERROR = -3; - - public const int Z_MEM_ERROR = -4; - - public const int Z_BUF_ERROR = -5; - - public const int Z_VERSION_ERROR = -6; - - public static string version() - { - return "1.0.2"; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/zlibConst.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/zlibConst.cs.meta deleted file mode 100644 index d5c4e96..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib/zlibConst.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 189574d77199372408e8e294f65e987a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Crc32.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Crc32.cs deleted file mode 100644 index db98f0f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Crc32.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System.Security.Cryptography; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class Crc32 : HashAlgorithm - { - public const uint DefaultPolynomial = 3988292384u; - - public const uint DefaultSeed = uint.MaxValue; - - private uint hash; - - private uint seed; - - private uint[] table; - - private static uint[] defaultTable; - - public override int HashSize => 32; - - public Crc32() - { - table = InitializeTable(3988292384u); - seed = uint.MaxValue; - Initialize(); - } - - public Crc32(uint polynomial, uint seed) - { - table = InitializeTable(polynomial); - this.seed = seed; - Initialize(); - } - - public override void Initialize() - { - hash = seed; - } - - protected override void HashCore(byte[] buffer, int start, int length) - { - hash = CalculateHash(table, hash, buffer, start, length); - } - - protected override byte[] HashFinal() - { - return HashValue = UInt32ToBigEndianBytes(~hash); - } - - public static uint Compute(byte[] buffer) - { - return ~CalculateHash(InitializeTable(3988292384u), uint.MaxValue, buffer, 0, buffer.Length); - } - - public static uint Compute(uint seed, byte[] buffer) - { - return ~CalculateHash(InitializeTable(3988292384u), seed, buffer, 0, buffer.Length); - } - - public static uint Compute(uint polynomial, uint seed, byte[] buffer) - { - return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length); - } - - private static uint[] InitializeTable(uint polynomial) - { - if (polynomial == 3988292384u && defaultTable != null) - { - return defaultTable; - } - uint[] array = new uint[256]; - for (int i = 0; i < 256; i++) - { - uint num = (uint)i; - for (int j = 0; j < 8; j++) - { - num = (((num & 1) != 1) ? (num >> 1) : ((num >> 1) ^ polynomial)); - } - array[i] = num; - } - if (polynomial == 3988292384u) - { - defaultTable = array; - } - return array; - } - - private static uint CalculateHash(uint[] table, uint seed, byte[] buffer, int start, int size) - { - uint num = seed; - for (int i = start; i < size; i++) - { - num = (num >> 8) ^ table[buffer[i] ^ (num & 0xFF)]; - } - return num; - } - - private byte[] UInt32ToBigEndianBytes(uint x) - { - return new byte[4] - { - (byte)((x >> 24) & 0xFFu), - (byte)((x >> 16) & 0xFFu), - (byte)((x >> 8) & 0xFFu), - (byte)(x & 0xFFu) - }; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Crc32.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Crc32.cs.meta deleted file mode 100644 index 1b43454..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Crc32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6735365dc98ead64aacb1d9fa1b79cbc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuRegion.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuRegion.cs deleted file mode 100644 index 3c162cb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuRegion.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MyNes.Core -{ - public enum EmuRegion - { - NTSC, - PALB, - DENDY - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuRegion.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuRegion.cs.meta deleted file mode 100644 index 94d3767..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuRegion.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f091eb23796c9f2469aca986fc0c75d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuSettings.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuSettings.cs deleted file mode 100644 index 6718559..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuSettings.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class EmuSettings : ISettings - { - public string SnapsFolder = "Snaps"; - - public string WavesFolder = "SoundRecords"; - - public string SnapsFormat = ".png"; - - public bool SnapsReplace; - - public int RegionSetting; - - public string StateFolder = "States"; - - public string GameGenieFolder = "GMCodes"; - - public string SRAMFolder = "Srams"; - - public bool SaveSRAMAtEmuShutdown = true; - - public EmuSettings(string path) - : base(path) - { - } - - public override void LoadSettings() - { - base.LoadSettings(); - if (MyNesMain.WorkingFolder == null) - { - MyNesMain.MakeWorkingFolder(); - } - if (SnapsFolder == "Snaps") - { - SnapsFolder = Path.Combine(MyNesMain.WorkingFolder, "Snaps"); - } - if (StateFolder == "States") - { - StateFolder = Path.Combine(MyNesMain.WorkingFolder, "States"); - } - if (GameGenieFolder == "GMCodes") - { - GameGenieFolder = Path.Combine(MyNesMain.WorkingFolder, "GMCodes"); - } - if (SRAMFolder == "Srams") - { - SRAMFolder = Path.Combine(MyNesMain.WorkingFolder, "Srams"); - } - if (WavesFolder == "SoundRecords") - { - WavesFolder = Path.Combine(MyNesMain.WorkingFolder, "SoundRecords"); - } - try - { - Directory.CreateDirectory(WavesFolder); - } - catch - { - Tracer.WriteError("Cannot create sound records folder !!"); - } - try - { - Directory.CreateDirectory(SnapsFolder); - } - catch - { - Tracer.WriteError("Cannot create snaps folder !!"); - } - try - { - Directory.CreateDirectory(StateFolder); - } - catch - { - Tracer.WriteError("Cannot create states folder !!"); - } - try - { - Directory.CreateDirectory(SRAMFolder); - } - catch - { - Tracer.WriteError("Cannot create srams folder !!"); - } - try - { - Directory.CreateDirectory(GameGenieFolder); - } - catch - { - Tracer.WriteError("Cannot create game genie codes folder !!"); - } - StateHandler.StateFolder = StateFolder; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuSettings.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuSettings.cs.meta deleted file mode 100644 index 273ac16..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/EmuSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f3b3769eaf4c4d54f9ac64295acde90b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Eprom.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Eprom.cs deleted file mode 100644 index a0dcfa3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Eprom.cs +++ /dev/null @@ -1,387 +0,0 @@ -using System; -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class Eprom - { - private enum EpromDevice - { - X24C01, - X24C02 - } - - private enum EpromMode - { - Data, - Addressing, - Idle, - Read, - Write, - Ack, - NotAck, - AckWait - } - - private byte[] data; - - private EpromMode mode; - - private EpromMode nextmode; - - private EpromDevice device; - - private bool psda; - - private bool pscl; - - private int output; - - private int cbit; - - private int caddress; - - private int cdata; - - private bool isRead; - - private bool cSCL; - - private bool cSDA; - - public Eprom(int memorySize) - { - Console.WriteLine("Initializing Eprom ..."); - data = new byte[memorySize]; - device = ((memorySize == 256) ? EpromDevice.X24C02 : EpromDevice.X24C01); - Console.WriteLine("Eprom memory size = " + memorySize); - Console.WriteLine("Eprom device = " + device); - } - - public void HardReset() - { - pscl = false; - psda = false; - mode = EpromMode.Idle; - nextmode = EpromMode.Idle; - cbit = 0; - caddress = 0; - cdata = 0; - isRead = false; - output = 16; - } - - public void Write(int address, byte data) - { - cSCL = (data & 0x20) == 32; - cSDA = (data & 0x40) == 64; - if (pscl && (!cSDA & psda)) - { - Start(); - } - else if (pscl && (cSDA & !psda)) - { - Stop(); - } - else if (cSCL & !pscl) - { - switch (device) - { - case EpromDevice.X24C01: - RiseX24C01((data >> 6) & 1); - break; - case EpromDevice.X24C02: - RiseX24C02((data >> 6) & 1); - break; - } - } - else if (!cSCL & pscl) - { - switch (device) - { - case EpromDevice.X24C01: - FallX24C01(); - break; - case EpromDevice.X24C02: - FallX24C02(); - break; - } - } - pscl = cSCL; - psda = cSDA; - } - - public byte Read(int address) - { - return (byte)output; - } - - private void Start() - { - switch (device) - { - case EpromDevice.X24C01: - mode = EpromMode.Addressing; - cbit = 0; - caddress = 0; - output = 16; - break; - case EpromDevice.X24C02: - mode = EpromMode.Data; - cbit = 0; - output = 16; - break; - } - } - - private void Stop() - { - mode = EpromMode.Idle; - output = 16; - } - - private void RiseX24C01(int bit) - { - switch (mode) - { - case EpromMode.Addressing: - if (cbit < 7) - { - caddress &= ~(1 << cbit); - caddress |= bit << cbit++; - } - else if (cbit < 8) - { - cbit = 8; - if (bit != 0) - { - nextmode = EpromMode.Read; - cdata = data[caddress]; - } - else - { - nextmode = EpromMode.Write; - } - } - break; - case EpromMode.Ack: - output = 0; - break; - case EpromMode.Read: - if (cbit < 8) - { - output = (((cdata & (1 << cbit++)) != 0) ? 16 : 0); - } - break; - case EpromMode.Write: - if (cbit < 8) - { - cdata &= ~(1 << cbit); - cdata |= bit << cbit++; - } - break; - case EpromMode.AckWait: - if (bit == 0) - { - nextmode = EpromMode.Idle; - } - break; - case EpromMode.Idle: - case EpromMode.NotAck: - break; - } - } - - private void RiseX24C02(int bit) - { - switch (mode) - { - case EpromMode.Data: - if (cbit < 8) - { - cdata &= ~(1 << 7 - cbit); - cdata |= bit << 7 - cbit++; - } - break; - case EpromMode.Addressing: - if (cbit < 8) - { - caddress &= ~(1 << 7 - cbit); - caddress |= bit << 7 - cbit++; - } - break; - case EpromMode.Read: - if (cbit < 8) - { - output = (((cdata & (1 << 7 - cbit++)) != 0) ? 16 : 0); - } - break; - case EpromMode.Write: - if (cbit < 8) - { - cdata &= ~(1 << 7 - cbit); - cdata |= bit << 7 - cbit++; - } - break; - case EpromMode.NotAck: - output = 16; - break; - case EpromMode.Ack: - output = 0; - break; - case EpromMode.AckWait: - if (bit == 0) - { - nextmode = EpromMode.Read; - cdata = data[caddress]; - } - break; - case EpromMode.Idle: - break; - } - } - - private void FallX24C01() - { - switch (mode) - { - case EpromMode.Addressing: - if (cbit == 8) - { - mode = EpromMode.Ack; - output = 16; - } - break; - case EpromMode.Ack: - mode = nextmode; - cbit = 0; - output = 16; - break; - case EpromMode.Read: - if (cbit == 8) - { - mode = EpromMode.AckWait; - caddress = (caddress + 1) & 0x7F; - } - break; - case EpromMode.Write: - if (cbit == 8) - { - mode = EpromMode.Ack; - nextmode = EpromMode.Idle; - data[caddress] = (byte)cdata; - caddress = (caddress + 1) & 0x7F; - } - break; - case EpromMode.Idle: - break; - } - } - - private void FallX24C02() - { - switch (mode) - { - case EpromMode.Data: - if (cbit != 8) - { - break; - } - if ((cdata & 0xA0) == 160) - { - cbit = 0; - mode = EpromMode.Ack; - isRead = (cdata & 1) == 1; - output = 16; - if (isRead) - { - nextmode = EpromMode.Read; - cdata = data[caddress]; - } - else - { - nextmode = EpromMode.Addressing; - } - } - else - { - mode = EpromMode.NotAck; - nextmode = EpromMode.Idle; - output = 16; - } - break; - case EpromMode.Addressing: - if (cbit == 8) - { - cbit = 0; - mode = EpromMode.Ack; - nextmode = (isRead ? EpromMode.Idle : EpromMode.Write); - output = 16; - } - break; - case EpromMode.Read: - if (cbit == 8) - { - mode = EpromMode.AckWait; - caddress = (caddress + 1) & 0xFF; - } - break; - case EpromMode.Write: - if (cbit == 8) - { - cbit = 0; - mode = EpromMode.Ack; - nextmode = EpromMode.Write; - data[caddress] = (byte)cdata; - caddress = (caddress + 1) & 0xFF; - } - break; - case EpromMode.NotAck: - mode = EpromMode.Idle; - cbit = 0; - output = 16; - break; - case EpromMode.Ack: - case EpromMode.AckWait: - mode = nextmode; - cbit = 0; - output = 16; - break; - case EpromMode.Idle: - break; - } - } - - public void SaveState(BinaryWriter stream) - { - stream.Write(data); - stream.Write((int)mode); - stream.Write((int)nextmode); - stream.Write(psda); - stream.Write(pscl); - stream.Write(output); - stream.Write(cbit); - stream.Write(caddress); - stream.Write(cdata); - stream.Write(isRead); - } - - public void LoadState(BinaryReader stream) - { - stream.Read(data, 0, data.Length); - mode = (EpromMode)stream.ReadInt32(); - nextmode = (EpromMode)stream.ReadInt32(); - psda = stream.ReadBoolean(); - pscl = stream.ReadBoolean(); - output = stream.ReadInt32(); - cbit = stream.ReadInt32(); - caddress = stream.ReadInt32(); - cdata = stream.ReadInt32(); - isRead = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Eprom.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Eprom.cs.meta deleted file mode 100644 index bfc4ec5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Eprom.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bf9a039fae5474f4d9699753440312cf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/FFE.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/FFE.cs deleted file mode 100644 index 880b175..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/FFE.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal abstract class FFE : Board - { - protected bool irqEnable; - - protected int irqCounter; - - internal override void WriteEX(ref ushort address, ref byte data) - { - switch (address) - { - case 17665: - irqEnable = false; - NesEmu.IRQFlags &= -9; - break; - case 17666: - irqCounter = (irqCounter & 0xFF00) | data; - break; - case 17667: - irqEnable = true; - irqCounter = (irqCounter & 0xFF) | (data << 8); - break; - } - } - - internal override void OnCPUClock() - { - if (irqEnable) - { - irqCounter++; - if (irqCounter >= 65535) - { - irqCounter = 0; - NesEmu.IRQFlags |= 8; - } - } - } - - internal override void WriteStateData(ref BinaryWriter bin) - { - base.WriteStateData(ref bin); - bin.Write(irqEnable); - bin.Write(irqCounter); - } - - internal override void ReadStateData(ref BinaryReader bin) - { - base.ReadStateData(ref bin); - irqEnable = bin.ReadBoolean(); - irqCounter = bin.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/FFE.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/FFE.cs.meta deleted file mode 100644 index 85c1a4e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/FFE.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 05457d6300519b04a966034b34ad95df -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenie.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenie.cs deleted file mode 100644 index 29c8c57..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenie.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System.Collections.Generic; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class GameGenie - { - public string[] LettersTable = new string[16] - { - "A", "P", "Z", "L", "G", "I", "T", "Y", "E", "O", - "X", "U", "K", "S", "V", "N" - }; - - public byte[] HEXTable = new byte[16] - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15 - }; - - private List lettersTable = new List(); - - public GameGenie() - { - lettersTable = new List(LettersTable); - } - - public int GetCodeAsHEX(string code) - { - int num = 0; - int num2 = code.ToCharArray().Length - 1; - char[] array = code.ToCharArray(); - foreach (char c in array) - { - num |= HEXTable[lettersTable.IndexOf(c.ToString())] << num2 * 4; - num2--; - } - return num; - } - - public byte GetGGValue(int code, int length) - { - int num = 0; - int num2 = 0; - int num3 = 0; - int num4 = 0; - int num5 = 0; - int num6 = 0; - int num7 = 0; - int num8 = 0; - switch (length) - { - case 6: - num8 = (code & 0x800000) >> 23; - num7 = (code & 0x40000) >> 18; - num6 = (code & 0x20000) >> 17; - num5 = (code & 0x10000) >> 16; - num4 = (code & 8) >> 3; - num3 = (code & 0x400000) >> 22; - num2 = (code & 0x200000) >> 21; - num = (code & 0x100000) >> 20; - break; - case 8: - num8 = (code >> 31) & 1; - num7 = (code >> 27) & 1; - num6 = (code >> 26) & 1; - num5 = (code >> 25) & 1; - num4 = (code >> 3) & 1; - num3 = (code >> 30) & 1; - num2 = (code >> 29) & 1; - num = (code >> 28) & 1; - break; - } - return (byte)((num8 << 7) | (num7 << 6) | (num6 << 5) | (num5 << 4) | (num4 << 3) | (num3 << 2) | (num2 << 1) | num); - } - - public int GetGGAddress(int code, int length) - { - int num = 0; - int num2 = 0; - int num3 = 0; - int num4 = 0; - int num5 = 0; - int num6 = 0; - int num7 = 0; - int num8 = 0; - int num9 = 0; - int num10 = 0; - int num11 = 0; - int num12 = 0; - int num13 = 0; - int num14 = 0; - int num15 = 0; - switch (length) - { - case 6: - num15 = (code >> 10) & 1; - num14 = (code >> 9) & 1; - num13 = (code >> 8) & 1; - num12 = (code >> 7) & 1; - num11 = (code >> 2) & 1; - num10 = (code >> 1) & 1; - num9 = code & 1; - num8 = (code >> 19) & 1; - num7 = (code >> 14) & 1; - num6 = (code >> 13) & 1; - num5 = (code >> 12) & 1; - num4 = (code >> 11) & 1; - num3 = (code >> 6) & 1; - num2 = (code >> 5) & 1; - num = (code >> 4) & 1; - break; - case 8: - num15 = (code >> 18) & 1; - num14 = (code >> 17) & 1; - num13 = (code >> 16) & 1; - num12 = (code >> 15) & 1; - num11 = (code >> 10) & 1; - num10 = (code >> 9) & 1; - num9 = (code >> 8) & 1; - num8 = (code >> 25) & 1; - num7 = (code >> 22) & 1; - num6 = (code >> 21) & 1; - num5 = (code >> 20) & 1; - num4 = (code >> 19) & 1; - num3 = (code >> 14) & 1; - num2 = (code >> 13) & 1; - num = (code >> 12) & 1; - break; - } - return (num15 << 14) | (num14 << 13) | (num13 << 12) | (num12 << 11) | (num11 << 10) | (num10 << 9) | (num9 << 8) | (num8 << 7) | (num7 << 6) | (num6 << 5) | (num5 << 4) | (num4 << 3) | (num3 << 2) | (num2 << 1) | num; - } - - public byte GetGGCompareValue(int code) - { - int num = 0; - int num2 = 0; - int num3 = 0; - int num4 = 0; - int num5 = 0; - int num6 = 0; - int num7 = 0; - int num8 = (code >> 7) & 1; - num7 = (code >> 2) & 1; - num6 = (code >> 1) & 1; - num5 = code & 1; - num4 = (code >> 11) & 1; - num3 = (code >> 6) & 1; - num2 = (code >> 5) & 1; - num = (code >> 4) & 1; - return (byte)((num8 << 7) | (num7 << 6) | (num6 << 5) | (num5 << 4) | (num4 << 3) | (num3 << 2) | (num2 << 1) | num); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenie.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenie.cs.meta deleted file mode 100644 index 8cde216..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenie.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c440f367166527145bec0f405ad3b587 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenieCode.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenieCode.cs deleted file mode 100644 index b7bc201..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenieCode.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace MyNes.Core -{ - public struct GameGenieCode - { - public string Name; - - public string Descreption; - - public int Address; - - public byte Compare; - - public byte Value; - - public bool IsCompare; - - public bool Enabled; - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenieCode.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenieCode.cs.meta deleted file mode 100644 index 2237c1d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/GameGenieCode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0be47c6f15a83aa48b41cf4e18b98e6d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/GetIsPlaying.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/GetIsPlaying.cs deleted file mode 100644 index 1fb3f87..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/GetIsPlaying.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MyNes.Core -{ - internal delegate void GetIsPlaying(out bool playing); -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/GetIsPlaying.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/GetIsPlaying.cs.meta deleted file mode 100644 index 9a59786..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/GetIsPlaying.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d5e4818002a2f3140b2da0af5b1639fa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/HassIssuesAttribute.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/HassIssuesAttribute.cs deleted file mode 100644 index f7b92d3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/HassIssuesAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class HassIssuesAttribute : Attribute - { - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/HassIssuesAttribute.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/HassIssuesAttribute.cs.meta deleted file mode 100644 index 66e381d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/HassIssuesAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4ea93c2200789cd499484183e415c4c6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/HelperTools.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/HelperTools.cs deleted file mode 100644 index c7d1077..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/HelperTools.cs +++ /dev/null @@ -1,178 +0,0 @@ -using System.IO; -using System.Security.Cryptography; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class HelperTools - { - public static string GetFileSize(string FilePath) - { - if (File.Exists(Path.GetFullPath(FilePath))) - { - FileInfo fileInfo = new FileInfo(FilePath); - string text = " Byte"; - double num = fileInfo.Length; - if (fileInfo.Length >= 1024) - { - num = (double)fileInfo.Length / 1024.0; - text = " KB"; - } - if (num >= 1024.0) - { - num /= 1024.0; - text = " MB"; - } - if (num >= 1024.0) - { - num /= 1024.0; - text = " GB"; - } - return num.ToString("F2") + text; - } - return ""; - } - - public static string GetSize(long size) - { - string text = " Byte"; - double num = size; - if (size >= 1024) - { - num = (double)size / 1024.0; - text = " KB"; - } - if (num >= 1024.0) - { - num /= 1024.0; - text = " MB"; - } - if (num >= 1024.0) - { - num /= 1024.0; - text = " GB"; - } - if (num < 0.0) - { - return "???"; - } - return num.ToString("F2") + text; - } - - public static string GetSize(ulong size) - { - string text = " Byte"; - double num = size; - if (size >= 1024) - { - num = (double)size / 1024.0; - text = " KB"; - } - if (num >= 1024.0) - { - num /= 1024.0; - text = " MB"; - } - if (num >= 1024.0) - { - num /= 1024.0; - text = " GB"; - } - if (num < 0.0) - { - return "???"; - } - return num.ToString("F2") + text; - } - - public static long GetSizeAsBytes(string FilePath) - { - if (File.Exists(FilePath)) - { - return new FileInfo(FilePath).Length; - } - return 0L; - } - - public static bool IsStringContainsNumbers(string text) - { - char[] array = text.ToCharArray(); - foreach (char c in array) - { - int result = 0; - if (int.TryParse(c.ToString(), out result)) - { - return true; - } - } - return false; - } - - public static string CalculateCRC(string filePath) - { - if (File.Exists(filePath)) - { - Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read); - byte[] buffer = new byte[stream.Length]; - stream.Read(buffer, 0, (int)stream.Length); - stream.Close(); - string text = ""; - byte[] array = new Crc32().ComputeHash(buffer); - foreach (byte b in array) - { - text += b.ToString("x2").ToLower(); - } - return text; - } - return ""; - } - - public static string CalculateCRC(string filePath, int bytesToSkip) - { - if (File.Exists(filePath)) - { - Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read); - stream.Read(new byte[bytesToSkip], 0, bytesToSkip); - byte[] buffer = new byte[stream.Length - bytesToSkip]; - stream.Read(buffer, 0, (int)(stream.Length - bytesToSkip)); - stream.Close(); - string text = ""; - byte[] array = new Crc32().ComputeHash(buffer); - foreach (byte b in array) - { - text += b.ToString("x2").ToLower(); - } - return text; - } - return ""; - } - - public static string CalculateSHA1(string filePath) - { - if (File.Exists(filePath)) - { - byte[] buffer = GetBuffer(filePath); - string text = ""; - byte[] array = new SHA1Managed().ComputeHash(buffer); - foreach (byte b in array) - { - text += b.ToString("x2").ToLower(); - } - return text; - } - return ""; - } - - public static byte[] GetBuffer(string filePath) - { - Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read); - byte[] array = new byte[stream.Length]; - stream.Read(array, 0, (int)stream.Length); - stream.Close(); - return array; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/HelperTools.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/HelperTools.cs.meta deleted file mode 100644 index 1b20073..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/HelperTools.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6edadafe72c2a374fb7abbbf03b14cb6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IAudioProvider.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IAudioProvider.cs deleted file mode 100644 index 6388e3b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IAudioProvider.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace MyNes.Core -{ - public interface IAudioProvider - { - string Name { get; } - - string ID { get; } - - bool AllowBufferChange { get; } - - bool AllowFrequencyChange { get; } - - void SubmitSamples(ref short[] buffer, ref int samples_added); - - void TogglePause(bool paused); - - void GetIsPlaying(out bool playing); - - void Initialize(); - - void ShutDown(); - - void Reset(); - - void SignalToggle(bool started); - - void SetVolume(int Vol); - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IAudioProvider.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IAudioProvider.cs.meta deleted file mode 100644 index c38a282..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IAudioProvider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4366c4b2360b48d4c87ff24651f8dec8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IJoypadConnecter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IJoypadConnecter.cs deleted file mode 100644 index f5e4bd8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IJoypadConnecter.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public abstract class IJoypadConnecter - { - protected byte DATA; - - public abstract void Update(); - - public virtual void Destroy() - { - } - - public virtual byte GetData() - { - return DATA; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IJoypadConnecter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IJoypadConnecter.cs.meta deleted file mode 100644 index fbbe109..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IJoypadConnecter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c613333925a94f44c85ef86668ea7636 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/INes.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/INes.cs deleted file mode 100644 index 489789b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/INes.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.IO; -using System.Security.Cryptography; - -namespace MyNes.Core -{ - public class INes : IRom - { - public bool HasBattery { get; private set; } - - public bool IsPlaychoice10 { get; private set; } - - public bool IsVSUnisystem { get; private set; } - - public override void Load(string fileName, bool loadDumps) - { - var fileStream = MyNesMain.Supporter.OpenRomFile(fileName); - if (fileStream.Length < 16) - { - fileStream.Close(); - base.IsValid = false; - return; - } - byte[] array = new byte[16]; - fileStream.Read(array, 0, 16); - byte[] buffer = new byte[fileStream.Length - 16]; - fileStream.Read(buffer, 0, (int)(fileStream.Length - 16)); - base.SHA1 = ""; - byte[] array2 = new SHA1Managed().ComputeHash(buffer); - foreach (byte b in array2) - { - base.SHA1 += b.ToString("x2").ToLower(); - } - if (array[0] != 78 || array[1] != 69 || array[2] != 83 || array[3] != 26) - { - fileStream.Close(); - base.IsValid = false; - return; - } - base.PRGCount = array[4]; - base.CHRCount = array[5]; - switch (array[6] & 9) - { - case 0: - base.Mirroring = Mirroring.Horz; - break; - case 1: - base.Mirroring = Mirroring.Vert; - break; - case 8: - case 9: - base.Mirroring = Mirroring.Full; - break; - } - HasBattery = (array[6] & 2) != 0; - base.HasTrainer = (array[6] & 4) != 0; - if ((array[7] & 0xF) == 0) - { - base.MapperNumber = (byte)((array[7] & 0xF0) | (array[6] >> 4)); - } - else - { - base.MapperNumber = (byte)(array[6] >> 4); - } - IsVSUnisystem = (array[7] & 1) != 0; - IsPlaychoice10 = (array[7] & 2) != 0; - if (loadDumps) - { - fileStream.Seek(16L, SeekOrigin.Begin); - if (base.HasTrainer) - { - base.Trainer = new byte[512]; - fileStream.Read(base.Trainer, 0, 512); - } - else - { - base.Trainer = new byte[0]; - } - base.PRG = new byte[base.PRGCount * 16384]; - fileStream.Read(base.PRG, 0, base.PRGCount * 16384); - if (base.CHRCount > 0) - { - base.CHR = new byte[base.CHRCount * 8192]; - fileStream.Read(base.CHR, 0, base.CHRCount * 8192); - } - else - { - base.CHR = new byte[0]; - } - } - base.IsValid = true; - fileStream.Dispose(); - fileStream.Close(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/INes.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/INes.cs.meta deleted file mode 100644 index 80bb67b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/INes.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6d7f5c4eca034d148883c87e6c6b2443 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IRom.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IRom.cs deleted file mode 100644 index e88bbae..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IRom.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public abstract class IRom - { - public bool IsValid { get; set; } - - public int PRGCount { get; set; } - - public int CHRCount { get; set; } - - public int MapperNumber { get; set; } - - public Mirroring Mirroring { get; set; } - - public bool HasTrainer { get; set; } - - public byte[] PRG { get; set; } - - public byte[] CHR { get; set; } - - public byte[] Trainer { get; set; } - - public string SHA1 { get; set; } - - public virtual void Load(string fileName, bool loadDumps) - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IRom.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IRom.cs.meta deleted file mode 100644 index 25009e7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IRom.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 60fcaf7174409fc448d54f85371d31fc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ISettings.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ISettings.cs deleted file mode 100644 index d3f4652..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ISettings.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public abstract class ISettings - { - protected string filePath; - - protected FieldInfo[] Fields; - - public ISettings(string filePath) - { - this.filePath = filePath; - } - - public virtual void LoadSettings() - { - Fields = GetType().GetFields(); - if (!File.Exists(filePath)) - { - return; - } - string[] array = File.ReadAllLines(filePath); - for (int i = 0; i < array.Length; i++) - { - string[] array2 = array[i].Split('='); - if (array2 != null && array2.Length == 2) - { - SetField(array2[0], array2[1]); - } - } - } - - public virtual void SaveSettings() - { - Fields = GetType().GetFields(); - List list = new List(); - FieldInfo[] fields = Fields; - foreach (FieldInfo fieldInfo in fields) - { - if (fieldInfo.IsPublic) - { - list.Add(fieldInfo.Name + "=" + GetFieldValue(fieldInfo)); - } - } - File.WriteAllLines(filePath, list.ToArray()); - } - - protected virtual void SetField(string fieldName, string val) - { - for (int i = 0; i < Fields.Length; i++) - { - if (!(Fields[i].Name == fieldName)) - { - continue; - } - if (Fields[i].FieldType == typeof(string)) - { - Fields[i].SetValue(this, val); - } - else if (Fields[i].FieldType == typeof(bool)) - { - Fields[i].SetValue(this, val == "1"); - } - else if (Fields[i].FieldType == typeof(int)) - { - int result = 0; - if (int.TryParse(val, out result)) - { - Fields[i].SetValue(this, result); - } - } - else if (Fields[i].FieldType == typeof(float)) - { - float result2 = 0f; - if (float.TryParse(val, out result2)) - { - Fields[i].SetValue(this, result2); - } - } - else if (Fields[i].FieldType == typeof(string[])) - { - string[] value = val.Split(new string[1] { "*" }, StringSplitOptions.RemoveEmptyEntries); - Fields[i].SetValue(this, value); - } - else - { - Tracer.WriteLine("Unknown setting type = " + Fields[i].FieldType); - } - break; - } - } - - protected virtual string GetFieldValue(string fieldName) - { - for (int i = 0; i < Fields.Length; i++) - { - if (Fields[i].Name == fieldName) - { - return GetFieldValue(Fields[i]); - } - } - return ""; - } - - protected virtual string GetFieldValue(FieldInfo field) - { - object value = field.GetValue(this); - if (field.FieldType == typeof(string)) - { - return value.ToString(); - } - if (field.FieldType == typeof(bool)) - { - if (!(bool)value) - { - return "0"; - } - return "1"; - } - if (field.FieldType == typeof(int)) - { - return value.ToString(); - } - if (field.FieldType == typeof(float)) - { - return value.ToString(); - } - if (field.FieldType == typeof(string[])) - { - string text = ""; - string[] array = (string[])value; - if (array != null) - { - string[] array2 = array; - foreach (string text2 in array2) - { - text = text + text2 + "*"; - } - } - if (text.Length > 0) - { - return text.Substring(0, text.Length - 1); - } - return ""; - } - return ""; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ISettings.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ISettings.cs.meta deleted file mode 100644 index 8b0c3b2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ISettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3236f262a69a32f4395a1f17537be480 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IShortcutsHandler.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IShortcutsHandler.cs deleted file mode 100644 index be2d2f4..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IShortcutsHandler.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - public interface IShortcutsHandler - { - void Update(); - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IShortcutsHandler.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IShortcutsHandler.cs.meta deleted file mode 100644 index cf4b445..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IShortcutsHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e44becc2730cc364db0b40806a1dd8cd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVSUnisystemDIPConnecter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IVSUnisystemDIPConnecter.cs deleted file mode 100644 index db70a23..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVSUnisystemDIPConnecter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public abstract class IVSUnisystemDIPConnecter - { - public abstract void Update(); - - public virtual void OnEmuShutdown() - { - } - - public virtual byte GetData4016() - { - return 0; - } - - public virtual byte GetData4017() - { - return 0; - } - - public virtual void Write4020(ref byte data) - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVSUnisystemDIPConnecter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IVSUnisystemDIPConnecter.cs.meta deleted file mode 100644 index 870c2f0..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVSUnisystemDIPConnecter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 593f15ab3ef85d14a8a4c462199c9775 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVideoProvider.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IVideoProvider.cs deleted file mode 100644 index b89152c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVideoProvider.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace MyNes.Core -{ - public interface IVideoProvider - { - string Name { get; } - - string ID { get; } - - void WriteErrorNotification(string message, bool instant); - - void WriteInfoNotification(string message, bool instant); - - void WriteWarningNotification(string message, bool instant); - - void TakeSnapshotAs(string path, string format); - - void TakeSnapshot(); - - void Initialize(); - - void ShutDown(); - - void SignalToggle(bool started); - - void SubmitFrame(ref int[] buffer); - - void ResizeBegin(); - - void ResizeEnd(); - - void ApplyRegionChanges(); - - void Resume(); - - void ToggleAspectRatio(bool keep_aspect); - - void ToggleFPS(bool show_fps); - - void ApplyFilter(); - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVideoProvider.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IVideoProvider.cs.meta deleted file mode 100644 index f7a0941..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IVideoProvider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe8b5545022785849a0b156b01d15972 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IZapperConnecter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/IZapperConnecter.cs deleted file mode 100644 index 2d9ef3a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IZapperConnecter.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public abstract class IZapperConnecter - { - protected bool Trigger; - - protected bool State; - - public abstract void Update(); - - public virtual byte GetData() - { - return (byte)((Trigger ? 16u : 0u) | (State ? 8u : 0u)); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/IZapperConnecter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/IZapperConnecter.cs.meta deleted file mode 100644 index 3a72364..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/IZapperConnecter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7e39cb978938d8478d799f539c44c3f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs deleted file mode 100644 index e7453df..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; - -namespace Unity.IL2CPP.CompilerServices -{ - /// - /// The code generation options available for IL to C++ conversion. - /// Enable or disabled these with caution. - /// - public enum Option - { - /// - /// Enable or disable code generation for null checks. - /// - /// Global null check support is enabled by default when il2cpp.exe - /// is launched from the Unity editor. - /// - /// Disabling this will prevent NullReferenceException exceptions from - /// being thrown in generated code. In *most* cases, code that dereferences - /// a null pointer will crash then. Sometimes the point where the crash - /// happens is later than the location where the null reference check would - /// have been emitted though. - /// - NullChecks = 1, - /// - /// Enable or disable code generation for array bounds checks. - /// - /// Global array bounds check support is enabled by default when il2cpp.exe - /// is launched from the Unity editor. - /// - /// Disabling this will prevent IndexOutOfRangeException exceptions from - /// being thrown in generated code. This will allow reading and writing to - /// memory outside of the bounds of an array without any runtime checks. - /// Disable this check with extreme caution. - /// - ArrayBoundsChecks = 2, - /// - /// Enable or disable code generation for divide by zero checks. - /// - /// Global divide by zero check support is disabled by default when il2cpp.exe - /// is launched from the Unity editor. - /// - /// Enabling this will cause DivideByZeroException exceptions to be - /// thrown in generated code. Most code doesn't need to handle this - /// exception, so it is probably safe to leave it disabled. - /// - DivideByZeroChecks = 3, - } - - /// - /// Use this attribute on an assembly, struct, class, method, or property to inform the IL2CPP code conversion utility to override the - /// global setting for one of a few different runtime checks. - /// - /// Example: - /// - /// [Il2CppSetOption(Option.NullChecks, false)] - /// public static string MethodWithNullChecksDisabled() - /// { - /// var tmp = new Object(); - /// return tmp.ToString(); - /// } - /// - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Delegate, Inherited = false, AllowMultiple = true)] - public class Il2CppSetOptionAttribute : Attribute - { - public Option Option { get; private set; } - public object Value { get; private set; } - - public Il2CppSetOptionAttribute(Option option, object value) - { - Option = option; - Value = value; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta deleted file mode 100644 index 956232b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Il2CppSetOptionAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1fa3bc95a1fade84eb4f44a94a7409b5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC2.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC2.cs deleted file mode 100644 index 78b223c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC2.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal abstract class MMC2 : Board - { - private byte chr_reg0A; - - private byte chr_reg0B; - - private byte chr_reg1A; - - private byte chr_reg1B; - - private byte latch_a = 254; - - private byte latch_b = 254; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask - 2, PRGArea.AreaA000); - Switch08KPRG(PRG_ROM_08KB_Mask - 1, PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - chr_reg0B = 4; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF000) - { - case 40960: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 45056: - chr_reg0A = data; - if (latch_a == 253) - { - Switch04KCHR(chr_reg0A, CHRArea.Area0000); - } - break; - case 49152: - chr_reg0B = data; - if (latch_a == 254) - { - Switch04KCHR(chr_reg0B, CHRArea.Area0000); - } - break; - case 53248: - chr_reg1A = data; - if (latch_b == 253) - { - Switch04KCHR(chr_reg1A, CHRArea.Area1000); - } - break; - case 57344: - chr_reg1B = data; - if (latch_b == 254) - { - Switch04KCHR(chr_reg1B, CHRArea.Area1000); - } - break; - case 61440: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - break; - } - } - - internal override void ReadCHR(ref ushort address, out byte data) - { - if ((address & 0x1FF0) == 4048 && latch_a != 253) - { - latch_a = 253; - Switch04KCHR(chr_reg0A, CHRArea.Area0000); - } - else if ((address & 0x1FF0) == 4064 && latch_a != 254) - { - latch_a = 254; - Switch04KCHR(chr_reg0B, CHRArea.Area0000); - } - else if ((address & 0x1FF0) == 8144 && latch_b != 253) - { - latch_b = 253; - Switch04KCHR(chr_reg1A, CHRArea.Area1000); - } - else if ((address & 0x1FF0) == 8160 && latch_b != 254) - { - latch_b = 254; - Switch04KCHR(chr_reg1B, CHRArea.Area1000); - } - base.ReadCHR(ref address, out data); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(chr_reg0A); - stream.Write(chr_reg0B); - stream.Write(chr_reg1A); - stream.Write(chr_reg1B); - stream.Write(latch_a); - stream.Write(latch_b); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - chr_reg0A = stream.ReadByte(); - chr_reg0B = stream.ReadByte(); - chr_reg1A = stream.ReadByte(); - chr_reg1B = stream.ReadByte(); - latch_a = stream.ReadByte(); - latch_b = stream.ReadByte(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC2.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC2.cs.meta deleted file mode 100644 index f081fbd..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC2.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c2fd2154d001d8c4297526ae3b12644a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Pcm.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Pcm.cs deleted file mode 100644 index 8e67a5b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Pcm.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class MMC5Pcm - { - internal byte output; - - internal bool Outputable; - - private bool readMode; - - private bool PCMIRQenable; - - private bool irqTrip; - - internal void HardReset() - { - output = 0; - readMode = false; - PCMIRQenable = false; - irqTrip = false; - } - - internal void SoftReset() - { - HardReset(); - } - - internal void Write5010(byte data) - { - readMode = (data & 1) == 1; - PCMIRQenable = (data & 0x80) == 128; - if (PCMIRQenable && irqTrip) - { - NesEmu.IRQFlags |= 8; - } - } - - internal byte Read5010() - { - byte result = (byte)((irqTrip & PCMIRQenable) ? 128 : 0); - irqTrip = false; - NesEmu.IRQFlags &= -9; - return result; - } - - internal void Write5011(byte data) - { - if (readMode) - { - return; - } - if (data == 0) - { - irqTrip = true; - } - else - { - irqTrip = false; - if (Outputable) - { - output = data; - } - } - if (PCMIRQenable && irqTrip) - { - NesEmu.IRQFlags |= 8; - } - } - - internal void SaveState(ref BinaryWriter stream) - { - stream.Write(readMode); - stream.Write(PCMIRQenable); - stream.Write(irqTrip); - } - - internal void LoadState(ref BinaryReader stream) - { - readMode = stream.ReadBoolean(); - PCMIRQenable = stream.ReadBoolean(); - irqTrip = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Pcm.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Pcm.cs.meta deleted file mode 100644 index 6cdb2d8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Pcm.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b4c531b467bf54c4a9d0874c00316b40 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Sqr.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Sqr.cs deleted file mode 100644 index 7e1c39e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Sqr.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class MMC5Sqr - { - private byte[][] duty_cycle_sequences = new byte[4][] - { - new byte[8] { 0, 0, 0, 0, 0, 0, 0, 1 }, - new byte[8] { 0, 0, 0, 0, 0, 0, 1, 1 }, - new byte[8] { 0, 0, 0, 0, 1, 1, 1, 1 }, - new byte[8] { 1, 1, 1, 1, 1, 1, 0, 0 } - }; - - private byte[] duration_table = new byte[32] - { - 10, 254, 20, 2, 40, 4, 80, 6, 160, 8, - 60, 10, 14, 12, 26, 14, 12, 16, 24, 18, - 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, - 32, 30 - }; - - private byte duty_cycle; - - private bool length_halt; - - private bool constant_volume_envelope; - - private byte volume_devider_period; - - private int timer; - - private int period_devider; - - private byte seqencer; - - private bool length_enabled; - - private int length_counter; - - private bool envelope_start_flag; - - private byte envelope_devider; - - private byte envelope_decay_level_counter; - - private byte envelope; - - internal int output; - - internal bool Outputable; - - internal void HardReset() - { - duty_cycle = 0; - length_halt = false; - constant_volume_envelope = false; - volume_devider_period = 0; - timer = 0; - period_devider = 0; - seqencer = 0; - length_enabled = false; - length_counter = 0; - envelope_start_flag = false; - envelope_devider = 0; - envelope_decay_level_counter = 0; - envelope = 0; - } - - internal void SoftReset() - { - HardReset(); - } - - internal void Clock() - { - period_devider--; - if (period_devider > 0) - { - return; - } - period_devider = timer + 1; - if (length_counter > 0) - { - if (Outputable) - { - output = duty_cycle_sequences[duty_cycle][seqencer] * envelope; - } - } - else - { - output = 0; - } - if (seqencer == 0) - { - seqencer = 7; - } - else - { - seqencer--; - } - } - - internal void ClockLength() - { - if (length_counter > 0 && !length_halt) - { - length_counter--; - } - } - - internal void ClockEnvelope() - { - if (envelope_start_flag) - { - envelope_start_flag = false; - envelope_decay_level_counter = 15; - envelope_devider = (byte)(volume_devider_period + 1); - } - else if (envelope_devider > 0) - { - envelope_devider--; - } - else - { - envelope_devider = (byte)(volume_devider_period + 1); - if (envelope_decay_level_counter > 0) - { - envelope_decay_level_counter--; - } - else if (length_halt) - { - envelope_decay_level_counter = 15; - } - } - envelope = (constant_volume_envelope ? volume_devider_period : envelope_decay_level_counter); - } - - internal void Write0(ref byte value) - { - duty_cycle = (byte)((value & 0xC0) >> 6); - volume_devider_period = (byte)(value & 0xFu); - length_halt = (value & 0x20) != 0; - constant_volume_envelope = (value & 0x10) != 0; - envelope = (constant_volume_envelope ? volume_devider_period : envelope_decay_level_counter); - } - - internal void Write2(ref byte value) - { - timer = (timer & 0xFF00) | value; - } - - internal void Write3(ref byte value) - { - timer = (timer & 0xFF) | ((value & 7) << 8); - if (length_enabled) - { - length_counter = duration_table[value >> 3]; - } - seqencer = 0; - envelope_start_flag = true; - } - - internal void WriteEnabled(bool enabled) - { - length_enabled = enabled; - if (!length_enabled) - { - length_counter = 0; - } - } - - internal bool ReadEnable() - { - return length_counter > 0; - } - - internal void WriteStateData(ref BinaryWriter bin) - { - bin.Write(duty_cycle); - bin.Write(length_halt); - bin.Write(constant_volume_envelope); - bin.Write(volume_devider_period); - bin.Write(timer); - bin.Write(period_devider); - bin.Write(seqencer); - bin.Write(length_enabled); - bin.Write(length_counter); - bin.Write(envelope_start_flag); - bin.Write(envelope_devider); - bin.Write(envelope_decay_level_counter); - bin.Write(envelope); - bin.Write(output); - } - - internal void ReadStateData(ref BinaryReader bin) - { - duty_cycle = bin.ReadByte(); - length_halt = bin.ReadBoolean(); - constant_volume_envelope = bin.ReadBoolean(); - volume_devider_period = bin.ReadByte(); - timer = bin.ReadInt32(); - period_devider = bin.ReadInt32(); - seqencer = bin.ReadByte(); - length_enabled = bin.ReadBoolean(); - length_counter = bin.ReadInt32(); - envelope_start_flag = bin.ReadBoolean(); - envelope_devider = bin.ReadByte(); - envelope_decay_level_counter = bin.ReadByte(); - envelope = bin.ReadByte(); - output = bin.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Sqr.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Sqr.cs.meta deleted file mode 100644 index e80b342..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MMC5Sqr.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 21efe36faf5e4b74592b812f08f60773 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MNInterfaceLanguage.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MNInterfaceLanguage.cs deleted file mode 100644 index decd246..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MNInterfaceLanguage.cs +++ /dev/null @@ -1,134 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class MNInterfaceLanguage - { - public static string Message_RomInfoCanBeOnlyShown = "Rom info can be shown only when emulation is on (i.e. game is loaded)"; - - public static string Message_StateSlotSetTo = "State slot set to"; - - public static string Message_LoadStateCanBeUsedOnly = "Load state as can be used only when emulation is on (i.e. game is loaded)"; - - public static string Message_SaveStateCanBeUseOnly = "Save state as can be used only when emulation is on (i.e. game is loaded)"; - - public static string Message_HardResetCanBeUsedOnly = "Hard reset can be used only when emulation is on (i.e. game is loaded)"; - - public static string Message_SoftResetCanBeUsedOnly = "Soft reset can be used only when emulation is on (i.e. game is loaded)"; - - public static string Message_TurboCanBeToggledOnly = "Turbo can be toggled only when emulation is on (i.e. game is loaded)"; - - public static string Message_GameGenieCanBeConfiguredOnly = "Game Genie can be enabled/configured only when emulation is on (i.e. game is loaded)"; - - public static string Message_Error1 = "Can't save state, emu is off."; - - public static string Message_Error2 = "Can't save state, no rom file is loaded."; - - public static string Message_Error3 = "Can't save state while loading a state !"; - - public static string Message_Error4 = "Already saving state !!"; - - public static string Message_Error5 = "Can't load state, emu is off."; - - public static string Message_Error6 = "Can't load state, no rom file is loaded."; - - public static string Message_Error7 = "Can't load state while saving a state !"; - - public static string Message_Error8 = "Already loading state !!"; - - public static string Message_Error9 = "No state found in slot"; - - public static string Message_Error10 = "Unable load state at slot"; - - public static string Message_Error11 = "Not My Nes State File !"; - - public static string Message_Error12 = "Not compatible state file version !"; - - public static string Message_Error13 = "This state file is not for this game; not same SHA1 !"; - - public static string Message_Error14 = "IS NOT LOCATED, mapper is not supported or unable to find it."; - - public static string Message_Error15 = "will be used instead, assigned successfully."; - - public static string Message_Error16 = "Game Genie code length cannot be more than 8 letters"; - - public static string Message_Error17 = "has issues and may not function probably with this game."; - - public static string Message_Info1 = "State saved at slot"; - - public static string Message_Info2 = "State loaded from slot"; - - public static string Message_Info3 = "Snapshot saved"; - - public static string Message_Info4 = "Interface language set to"; - - public static string Message_PleaseRestartToApply = "Please restart My Nes to apply."; - - public static string Message_HardReset = "HARD RESET !"; - - public static string Message_SoftReset = "SOFT RESET !"; - - public static string Message_Paused = "PAUSED"; - - public static string Mapper = "Mapper"; - - public static string IssueMapper5 = "Split screen not implemented.\nUchuu Keibitai SDF game graphic corruption for unknown reason in the intro (not in the split screen)."; - - public static string IssueMapper6 = "Mapper 6 is not tested, issues may occur"; - - public static string IssueMapper8 = "Mapper 8 is not tested, issues may occur"; - - public static string IssueMapper33 = "Mapper 33: Akira is not working for unknown reason."; - - public static string IssueMapper44 = "In game Super Big 7 - in - 1 : Double Dragon 3 game does not work."; - - public static string IssueMapper53 = "Mapper 53 does not work with the test roms i have, maybe something wrong with the implementation or the roms themselves"; - - public static string IssueMapper56 = "Mapper 56 does not work with the test roms i have, maybe something wrong with the implementation or the roms themselves"; - - public static string IssueMapper58 = "Study and Game 32-in-1 (Ch) [!].nes needs keyboard ?"; - - public static string IssueMapper60 = "Mapper 60 does not work with the test roms i have, maybe something wrong with the implementation or the roms themselves"; - - public static string IssueMapper85 = "VRC7 sound channels are not supported"; - - public static string IssueMapper90 = "DipSwitch is not implemented, the irq modes 2-3 are not implemented yet."; - - public static string IssueMapper96 = "Mapper 96 does not function probably and needs special controller to be implemented."; - - public static string IssueMapper105 = "Game hangs on title screen !"; - - public static string IssueMapper119 = "Mapper 119 does not function probably"; - - public static string IssueMapper154 = "Game shows glitches with chr"; - - public static string IssueMapper180 = "Crazy Climber needs special controller which not implemented yet."; - - public static string IssueMapper191 = "Mapper 191 is not tested, issues may occur"; - - public static string IssueMapper193 = "Game show nothing but fighter sprite !"; - - public static string IssueMapper202 = "150 in 1: some games not work well. Is it mapper or rom dump ?"; - - public static string IssueMapper203 = "64-in-1: some games not work, maybe something wrong with the implementation or the rom itself"; - - public static string IssueMapper207 = "Fudou Myouou Den is not assigned as mapper 207 while it should be !"; - - public static string IssueMapper222 = "Mapper 222 is not tested, issues may occur"; - - public static string IssueMapper228 = "Mapper 228 does not function probably"; - - public static string IssueMapper229 = "Mapper 229 is not tested, issues may occur"; - - public static string IssueMapper230 = "Only Contra works !?"; - - public static string IssueMapper243 = "Shows glitches in some games."; - - public static string IssueMapper245 = "Graphic glitches, maybe chr switches."; - - public static string IssueMapper255 = "Mapper 255 is not tested, issues may occur"; - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MNInterfaceLanguage.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MNInterfaceLanguage.cs.meta deleted file mode 100644 index f42a587..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MNInterfaceLanguage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 54f6278d37c378c4f9a6fe125f4505fd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper000.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper000.cs deleted file mode 100644 index 4fe2623..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper000.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("NROM", 0)] - internal class Mapper000 : Board - { - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper000.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper000.cs.meta deleted file mode 100644 index a7515e7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper000.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 41b0e004e19b28f47812b3eab3da2622 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper001.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper001.cs deleted file mode 100644 index 099e21c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper001.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("MMC1", 1, 4, 64)] - internal class Mapper001 : Board - { - private int address_reg; - - private byte[] reg = new byte[4]; - - private byte shift; - - private byte buffer; - - private bool flag_p; - - private bool flag_c; - - private bool flag_s; - - private bool enable_wram_enable; - - private int prg_hijackedbit; - - private bool use_hijacked; - - private bool use_sram_switch; - - private int sram_switch_mask; - - private int cpuCycles; - - internal override void HardReset() - { - base.HardReset(); - cpuCycles = 0; - address_reg = 0; - reg = new byte[4]; - reg[0] = 12; - flag_c = false; - flag_s = (flag_p = true); - prg_hijackedbit = 0; - reg[1] = (reg[2] = (reg[3] = 0)); - buffer = 0; - shift = 0; - if (base.Chips.Contains("MMC1B") || base.Chips.Contains("MMC1B2")) - { - TogglePRGRAMEnable(enable: false); - Console.WriteLine("MMC1: SRAM Disabled."); - } - enable_wram_enable = !base.Chips.Contains("MMC1A"); - Console.WriteLine("MMC1: enable_wram_enable = " + enable_wram_enable); - use_hijacked = (PRG_ROM_16KB_Mask & 0x10) == 16; - if (use_hijacked) - { - prg_hijackedbit = 16; - } - use_sram_switch = false; - if (PRG_RAM_08KB_Count > 0) - { - use_sram_switch = true; - sram_switch_mask = (use_hijacked ? 8 : 24); - sram_switch_mask &= PRG_RAM_08KB_Mask << 3; - if (sram_switch_mask == 0) - { - use_sram_switch = false; - } - } - Switch16KPRG(0xF | prg_hijackedbit, PRGArea.AreaC000); - Console.WriteLine("MMC1: use_hijacked = " + use_hijacked); - Console.WriteLine("MMC1: use_sram_switch = " + use_sram_switch); - Console.WriteLine("MMC1: sram_switch_mask = " + sram_switch_mask.ToString("X2")); - } - - internal override void WritePRG(ref ushort address, ref byte value) - { - if (cpuCycles > 0) - { - return; - } - cpuCycles = 3; - if ((value & 0x80) == 128) - { - reg[0] |= 12; - flag_s = (flag_p = true); - shift = (buffer = 0); - return; - } - if ((value & 1) == 1) - { - buffer |= (byte)(1 << (int)shift); - } - if (++shift < 5) - { - return; - } - address_reg = (address & 0x7FFF) >> 13; - reg[address_reg] = buffer; - shift = (buffer = 0); - switch (address_reg) - { - case 0: - flag_c = (reg[0] & 0x10) != 0; - flag_p = (reg[0] & 8) != 0; - flag_s = (reg[0] & 4) != 0; - UpdatePRG(); - UpdateCHR(); - switch (reg[0] & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - } - break; - case 1: - if (!flag_c) - { - Switch08KCHR(reg[1] >> 1); - } - else - { - Switch04KCHR(reg[1], CHRArea.Area0000); - } - if (use_sram_switch) - { - Switch08KPRG((reg[1] & sram_switch_mask) >> 3, PRGArea.Area6000); - } - if (use_hijacked) - { - prg_hijackedbit = reg[1] & 0x10; - UpdatePRG(); - } - break; - case 2: - if (flag_c) - { - Switch04KCHR(reg[2], CHRArea.Area1000); - } - if (use_sram_switch) - { - Switch08KPRG((reg[2] & sram_switch_mask) >> 3, PRGArea.Area6000); - } - if (use_hijacked) - { - prg_hijackedbit = reg[2] & 0x10; - UpdatePRG(); - } - break; - case 3: - if (enable_wram_enable) - { - TogglePRGRAMEnable((reg[3] & 0x10) == 0); - } - UpdatePRG(); - break; - } - } - - private void UpdateCHR() - { - if (!flag_c) - { - Switch08KCHR(reg[1] >> 1); - } - else - { - Switch04KCHR(reg[1], CHRArea.Area0000); - Switch04KCHR(reg[2], CHRArea.Area1000); - } - if (use_sram_switch) - { - Switch08KPRG((reg[1] & sram_switch_mask) >> 3, PRGArea.Area6000); - } - } - - private void UpdatePRG() - { - if (!flag_p) - { - Switch32KPRG(((reg[3] & 0xF) | prg_hijackedbit) >> 1, PRGArea.Area8000); - } - else if (flag_s) - { - Switch16KPRG((reg[3] & 0xF) | prg_hijackedbit, PRGArea.Area8000); - Switch16KPRG(0xF | prg_hijackedbit, PRGArea.AreaC000); - } - else - { - Switch16KPRG(prg_hijackedbit, PRGArea.Area8000); - Switch16KPRG((reg[3] & 0xF) | prg_hijackedbit, PRGArea.AreaC000); - } - } - - internal override void OnCPUClock() - { - if (cpuCycles > 0) - { - cpuCycles--; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(reg); - stream.Write(shift); - stream.Write(buffer); - stream.Write(flag_p); - stream.Write(flag_c); - stream.Write(flag_s); - stream.Write(enable_wram_enable); - stream.Write(prg_hijackedbit); - stream.Write(use_hijacked); - stream.Write(use_sram_switch); - stream.Write(cpuCycles); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - stream.Read(reg, 0, reg.Length); - shift = stream.ReadByte(); - buffer = stream.ReadByte(); - flag_p = stream.ReadBoolean(); - flag_c = stream.ReadBoolean(); - flag_s = stream.ReadBoolean(); - enable_wram_enable = stream.ReadBoolean(); - prg_hijackedbit = stream.ReadInt32(); - use_hijacked = stream.ReadBoolean(); - use_sram_switch = stream.ReadBoolean(); - cpuCycles = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper001.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper001.cs.meta deleted file mode 100644 index 8cb1ef2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper001.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 42f133f6a434de742b44fc92425e28b8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper002.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper002.cs deleted file mode 100644 index c10202f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper002.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("UxROM", 2)] - internal class Mapper002 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort addr, ref byte val) - { - Switch16KPRG(val, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper002.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper002.cs.meta deleted file mode 100644 index db979eb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper002.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a977999313c88f0498ab5893280de143 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper003.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper003.cs deleted file mode 100644 index a4ff318..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper003.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("CNROM", 3)] - internal class Mapper003 : Board - { - private byte data_temp; - - internal override void WritePRG(ref ushort address, ref byte data) - { - ReadPRG(ref address, out data_temp); - data_temp &= data; - Switch08KCHR(data_temp); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper003.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper003.cs.meta deleted file mode 100644 index 58f60ec..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper003.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e59d7105def01754ab2fbe6d71f36875 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper004.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper004.cs deleted file mode 100644 index 1f8e5e7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper004.cs +++ /dev/null @@ -1,228 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - [BoardInfo("MMC3", 4, true, true)] - internal class Mapper004 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - mmc3_alt_behavior = false; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Tracer.WriteWarning("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Tracer.WriteWarning("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Tracer.WriteWarning("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort addr, ref byte val) - { - switch (addr & 0xE001) - { - case 32768: - address_8001 = val & 7; - flag_c = (val & 0x80) != 0; - flag_p = (val & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = val; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = val & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((val & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((val & 0x80) != 0); - TogglePRGRAMWritableEnable((val & 0x40) == 0); - break; - case 49152: - irq_reload = val; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter bin) - { - base.WriteStateData(ref bin); - bin.Write(flag_c); - bin.Write(flag_p); - bin.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - bin.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - bin.Write(prg_reg[j]); - } - bin.Write(irq_enabled); - bin.Write(irq_counter); - bin.Write(old_irq_counter); - bin.Write(irq_reload); - bin.Write(irq_clear); - bin.Write(mmc3_alt_behavior); - } - - internal override void ReadStateData(ref BinaryReader bin) - { - base.ReadStateData(ref bin); - flag_c = bin.ReadBoolean(); - flag_p = bin.ReadBoolean(); - address_8001 = bin.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = bin.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = bin.ReadInt32(); - } - irq_enabled = bin.ReadBoolean(); - irq_counter = bin.ReadByte(); - old_irq_counter = bin.ReadInt32(); - irq_reload = bin.ReadByte(); - irq_clear = bin.ReadBoolean(); - mmc3_alt_behavior = bin.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper005.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper005.cs deleted file mode 100644 index 5f22e3d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper005.cs +++ /dev/null @@ -1,870 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("MMC5", 5, 8, 16)] - [WithExternalSound] - [HassIssues] - internal class Mapper005 : Board - { - private int ram_protectA; - - private int ram_protectB; - - private int ExRAM_mode; - - private int[] CHROffset_spr; - - private int[] CHROffsetEX; - - private int[] CHROffsetSP; - - private int[] chrRegA; - - private int[] chrRegB; - - private int[] prgReg; - - private bool useSRAMmirroring; - - private int chr_high; - - private int chr_mode; - - private int prg_mode; - - private bool chr_setB_last; - - private byte temp_val; - - private byte temp_fill; - - private int lastAccessVRAM; - - private int paletteNo; - - private int shift; - - private int EXtilenumber; - - private byte multiplicand; - - private byte multiplier; - - private ushort product; - - private bool split_enable; - - private bool split_right; - - private int split_tile; - - private int split_yscroll; - - private bool split_doit; - - private int split_watch_tile; - - private byte irq_line; - - private byte irq_enable; - - private int irq_pending; - - private int irq_current_counter; - - private int irq_current_inframe; - - private MMC5Sqr snd_1; - - private MMC5Sqr snd_2; - - private MMC5Pcm snd_3; - - private double[] audio_pulse_table; - - private double[] audio_tnd_table; - - internal override string Issues => MNInterfaceLanguage.IssueMapper5; - - internal override void Initialize(IRom rom) - { - base.Initialize(rom); - snd_1 = new MMC5Sqr(); - snd_2 = new MMC5Sqr(); - snd_3 = new MMC5Pcm(); - audio_pulse_table = new double[32]; - for (int i = 0; i < 32; i++) - { - audio_pulse_table[i] = 95.52 / (8128.0 / (double)i + 100.0); - } - audio_tnd_table = new double[204]; - for (int j = 0; j < 204; j++) - { - audio_tnd_table[j] = 163.67 / (24329.0 / (double)j + 100.0); - } - } - - internal override void HardReset() - { - base.HardReset(); - switch (SHA1.ToUpper()) - { - case "37267833C984F176DB4B0BC9D45DABA0FFF45304": - useSRAMmirroring = true; - break; - case "800AEFE756E85A0A78CCB4DAE68EBBA5DF24BF41": - useSRAMmirroring = true; - break; - } - Console.WriteLine("MMC5: using PRG RAM mirroring = " + useSRAMmirroring); - CHROffset_spr = new int[8]; - CHROffsetEX = new int[8]; - CHROffsetSP = new int[8]; - chrRegA = new int[8]; - chrRegB = new int[4]; - prgReg = new int[4]; - prgReg[3] = PRG_ROM_08KB_Mask; - prg_mode = 3; - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.Area8000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaA000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - Switch04kCHREX(0, 0); - Switch04kCHRSP(0, 0); - Switch08kCHR_spr(0); - TogglePRGRAMWritableEnable(enable: true); - TogglePRGRAMEnable(enable: true); - APUApplyChannelsSettings(); - snd_1.HardReset(); - snd_2.HardReset(); - snd_3.HardReset(); - } - - internal override void SoftReset() - { - base.SoftReset(); - snd_1.SoftReset(); - snd_2.SoftReset(); - snd_3.SoftReset(); - } - - internal override void WriteEX(ref ushort address, ref byte value) - { - if (address >= 23552) - { - if (ExRAM_mode == 2) - { - NMT_RAM[2][address & 0x3FF] = value; - } - else if (ExRAM_mode < 2) - { - if (irq_current_inframe == 64) - { - NMT_RAM[2][address & 0x3FF] = value; - } - else - { - NMT_RAM[2][address & 0x3FF] = 0; - } - } - return; - } - switch (address) - { - case 20480: - snd_1.Write0(ref value); - break; - case 20482: - snd_1.Write2(ref value); - break; - case 20483: - snd_1.Write3(ref value); - break; - case 20484: - snd_2.Write0(ref value); - break; - case 20486: - snd_2.Write2(ref value); - break; - case 20487: - snd_2.Write3(ref value); - break; - case 20496: - snd_3.Write5010(value); - break; - case 20497: - snd_3.Write5011(value); - break; - case 20501: - snd_1.WriteEnabled((value & 1) != 0); - snd_2.WriteEnabled((value & 2) != 0); - break; - case 20736: - prg_mode = value & 3; - break; - case 20737: - chr_mode = value & 3; - break; - case 20738: - ram_protectA = value & 3; - UpdateRamProtect(); - break; - case 20739: - ram_protectB = value & 3; - UpdateRamProtect(); - break; - case 20740: - ExRAM_mode = value & 3; - break; - case 20741: - Switch01KNMT(value); - break; - case 20755: - if (!useSRAMmirroring) - { - Switch08KPRG(value & 7, PRGArea.Area6000); - } - else - { - Switch08KPRG((value >> 2) & 1, PRGArea.Area6000); - } - break; - case 20756: - if (prg_mode == 3) - { - Toggle08KPRG_RAM((value & 0x80) == 0, PRGArea.Area8000); - Switch08KPRG(value & 0x7F, PRGArea.Area8000); - } - break; - case 20757: - switch (prg_mode) - { - case 1: - Toggle16KPRG_RAM((value & 0x80) == 0, PRGArea.Area8000); - Switch16KPRG((value & 0x7F) >> 1, PRGArea.Area8000); - break; - case 2: - Toggle16KPRG_RAM((value & 0x80) == 0, PRGArea.Area8000); - Switch16KPRG((value & 0x7F) >> 1, PRGArea.Area8000); - break; - case 3: - Toggle08KPRG_RAM((value & 0x80) == 0, PRGArea.AreaA000); - Switch08KPRG(value & 0x7F, PRGArea.AreaA000); - break; - } - break; - case 20758: - { - int num = prg_mode; - if ((uint)(num - 2) <= 1u) - { - Toggle08KPRG_RAM((value & 0x80) == 0, PRGArea.AreaC000); - Switch08KPRG(value & 0x7F, PRGArea.AreaC000); - } - break; - } - case 20759: - switch (prg_mode) - { - case 0: - Switch32KPRG((value & 0x7C) >> 2, PRGArea.Area8000); - break; - case 1: - Switch16KPRG((value & 0x7F) >> 1, PRGArea.AreaC000); - break; - case 2: - Switch08KPRG(value & 0x7F, PRGArea.AreaE000); - break; - case 3: - Switch08KPRG(value & 0x7F, PRGArea.AreaE000); - break; - } - break; - case 20768: - chr_setB_last = false; - if (chr_mode == 3) - { - Switch01kCHR_spr(value | chr_high, 0); - } - break; - case 20769: - chr_setB_last = false; - switch (chr_mode) - { - case 2: - Switch02kCHR_spr(value | chr_high, 0); - break; - case 3: - Switch01kCHR_spr(value | chr_high, 1024); - break; - } - break; - case 20770: - chr_setB_last = false; - if (chr_mode == 3) - { - Switch01kCHR_spr(value | chr_high, 2048); - } - break; - case 20771: - chr_setB_last = false; - switch (chr_mode) - { - case 1: - Switch04kCHR_spr(value | chr_high, 0); - break; - case 2: - Switch02kCHR_spr(value | chr_high, 2048); - break; - case 3: - Switch01kCHR_spr(value | chr_high, 3072); - break; - } - break; - case 20772: - chr_setB_last = false; - if (chr_mode == 3) - { - Switch01kCHR_spr(value | chr_high, 4096); - } - break; - case 20773: - chr_setB_last = false; - switch (chr_mode) - { - case 2: - Switch02kCHR_spr(value | chr_high, 4096); - break; - case 3: - Switch01kCHR_spr(value | chr_high, 5120); - break; - } - break; - case 20774: - chr_setB_last = false; - if (chr_mode == 3) - { - Switch01kCHR_spr(value | chr_high, 6144); - } - break; - case 20775: - chr_setB_last = false; - switch (chr_mode) - { - case 0: - Switch08kCHR_spr(value | chr_high); - break; - case 1: - Switch04kCHR_spr(value | chr_high, 4096); - break; - case 2: - Switch02kCHR_spr(value | chr_high, 6144); - break; - case 3: - Switch01kCHR_spr(value | chr_high, 7168); - break; - } - break; - case 20776: - chr_setB_last = true; - if (chr_mode == 3) - { - Switch01KCHR(value | chr_high, CHRArea.Area0000); - Switch01KCHR(value | chr_high, CHRArea.Area1000); - } - break; - case 20777: - chr_setB_last = true; - switch (chr_mode) - { - case 2: - Switch02KCHR(value | chr_high, CHRArea.Area0000); - Switch02KCHR(value | chr_high, CHRArea.Area1000); - break; - case 3: - Switch01KCHR(value | chr_high, CHRArea.Area0400); - Switch01KCHR(value | chr_high, CHRArea.Area1400); - break; - } - break; - case 20778: - chr_setB_last = true; - if (chr_mode == 3) - { - Switch01KCHR(value | chr_high, CHRArea.Area0800); - Switch01KCHR(value | chr_high, CHRArea.Area1800); - } - break; - case 20779: - chr_setB_last = true; - switch (chr_mode) - { - case 0: - Switch04kCHR_bkg(value | chr_high, 0); - Switch04kCHR_bkg(value | chr_high, 4096); - break; - case 1: - Switch04KCHR(value | chr_high, CHRArea.Area0000); - Switch04KCHR(value | chr_high, CHRArea.Area1000); - break; - case 2: - Switch02KCHR(value | chr_high, CHRArea.Area0800); - Switch02KCHR(value | chr_high, CHRArea.Area1800); - break; - case 3: - Switch01KCHR(value | chr_high, CHRArea.Area0C00); - Switch01KCHR(value | chr_high, CHRArea.Area1C00); - break; - } - break; - case 20784: - chr_high = (value & 3) << 8; - break; - case 20742: - { - for (int j = 0; j < 960; j++) - { - NMT_RAM[3][j] = value; - } - break; - } - case 20743: - { - for (int i = 960; i < 1024; i++) - { - temp_fill = (byte)((uint)(2 << (value & 3)) | (value & 3u)); - temp_fill |= (byte)((temp_fill & 0xF) << 4); - NMT_RAM[3][i] = temp_fill; - } - break; - } - case 20992: - split_tile = value & 0x1F; - split_enable = (value & 0x80) == 128; - split_right = (value & 0x40) == 64; - break; - case 20993: - split_yscroll = value; - break; - case 20994: - Switch04kCHRSP(value, address & 0); - Switch04kCHRSP(value, address & 0x1000); - break; - case 20995: - irq_line = value; - break; - case 20996: - irq_enable = value; - break; - case 20997: - multiplicand = value; - product = (ushort)(multiplicand * multiplier); - break; - case 20998: - multiplier = value; - product = (ushort)(multiplicand * multiplier); - break; - } - } - - internal override void ReadEX(ref ushort address, out byte data) - { - if (address >= 23552 && ExRAM_mode >= 2) - { - data = NMT_RAM[2][address & 0x3FF]; - return; - } - switch (address) - { - case 20496: - data = snd_3.Read5010(); - break; - case 20996: - data = (byte)(irq_current_inframe | irq_pending); - irq_pending = 0; - NesEmu.IRQFlags &= -9; - break; - case 20997: - data = (byte)(product & 0xFFu); - break; - case 20998: - data = (byte)((product & 0xFF00) >> 8); - break; - case 20501: - data = (byte)((snd_1.ReadEnable() ? 1u : 0u) | (snd_2.ReadEnable() ? 2u : 0u)); - data = 0; - break; - default: - data = 0; - break; - } - } - - internal override void ReadCHR(ref ushort address, out byte data) - { - if (!NesEmu.ppu_is_sprfetch && split_enable && ExRAM_mode < 2) - { - split_watch_tile = address & 0x3F; - if (!split_right) - { - split_doit = split_watch_tile < split_tile; - } - else - { - split_doit = split_watch_tile >= split_tile; - } - _ = split_doit; - } - if (ExRAM_mode == 1) - { - if (!NesEmu.ppu_is_sprfetch) - { - EXtilenumber = NMT_RAM[2][lastAccessVRAM] & 0x3F; - Switch04kCHREX(EXtilenumber | chr_high, address & 0x1000); - data = CHR_ROM[CHROffsetEX[(address >> 10) & 7]][address & 0x3FF]; - } - else - { - data = CHR_ROM[CHROffset_spr[(address >> 10) & 7]][address & 0x3FF]; - } - } - else if (NesEmu.ppu_reg_2000_Sprite_size == 16) - { - if (!NesEmu.ppu_is_sprfetch) - { - data = CHR_ROM[CHR_AREA_BLK_INDEX[(address >> 10) & 7]][address & 0x3FF]; - } - else - { - data = CHR_ROM[CHROffset_spr[(address >> 10) & 7]][address & 0x3FF]; - } - } - else if (chr_setB_last) - { - data = CHR_ROM[CHR_AREA_BLK_INDEX[(address >> 10) & 7]][address & 0x3FF]; - } - else - { - data = CHR_ROM[CHROffset_spr[(address >> 10) & 7]][address & 0x3FF]; - } - } - - internal override void ReadNMT(ref ushort address, out byte data) - { - _ = split_doit; - if (ExRAM_mode == 1) - { - if ((address & 0x3FF) <= 959) - { - lastAccessVRAM = address & 0x3FF; - } - else - { - paletteNo = NMT_RAM[2][lastAccessVRAM] & 0xC0; - shift = ((lastAccessVRAM >> 4) & 4) | (lastAccessVRAM & 2); - switch (shift) - { - case 0: - data = (byte)(paletteNo >> 6); - return; - case 2: - data = (byte)(paletteNo >> 4); - return; - case 4: - data = (byte)(paletteNo >> 2); - return; - case 6: - data = (byte)paletteNo; - return; - } - } - } - data = NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF]; - } - - internal override void WriteNMT(ref ushort address, ref byte value) - { - if (ExRAM_mode == 1 && (address & 0x3FF) <= 959) - { - lastAccessVRAM = address & 0x3FF; - } - NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF] = value; - } - - private void UpdateRamProtect() - { - TogglePRGRAMWritableEnable(ram_protectA == 2 && ram_protectB == 1); - } - - private void Switch04kCHR_bkg(int index, int where) - { - int num = (where >> 10) & 7; - index <<= 2; - CHR_AREA_BLK_INDEX[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHR_AREA_BLK_INDEX[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHR_AREA_BLK_INDEX[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHR_AREA_BLK_INDEX[num] = index & CHR_ROM_01KB_Mask; - } - - private void Switch01kCHR_spr(int index, int where) - { - CHROffset_spr[(where >> 10) & 7] = index & CHR_ROM_01KB_Mask; - } - - private void Switch02kCHR_spr(int index, int where) - { - int num = (where >> 10) & 7; - index <<= 1; - CHROffset_spr[num] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[num + 1] = index & CHR_ROM_01KB_Mask; - } - - private void Switch04kCHR_spr(int index, int where) - { - int num = (where >> 10) & 7; - index <<= 2; - CHROffset_spr[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffset_spr[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffset_spr[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffset_spr[num] = index & CHR_ROM_01KB_Mask; - } - - private void Switch08kCHR_spr(int index) - { - index <<= 3; - CHROffset_spr[0] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[1] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[2] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[3] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[4] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[5] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[6] = index & CHR_ROM_01KB_Mask; - index++; - CHROffset_spr[7] = index & CHR_ROM_01KB_Mask; - } - - private void Switch04kCHREX(int index, int where) - { - int num = (where >> 10) & 7; - index <<= 2; - CHROffsetEX[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffsetEX[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffsetEX[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffsetEX[num] = index & CHR_ROM_01KB_Mask; - } - - private void Switch04kCHRSP(int index, int where) - { - int num = (where >> 10) & 7; - index <<= 2; - CHROffsetSP[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffsetSP[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffsetSP[num] = index & CHR_ROM_01KB_Mask; - num++; - index++; - CHROffsetSP[num] = index & CHR_ROM_01KB_Mask; - } - - internal override void OnPPUScanlineTick() - { - irq_current_inframe = ((NesEmu.IsInRender() && NesEmu.IsRenderingOn()) ? 64 : 0); - if (irq_current_inframe == 0) - { - irq_current_inframe = 64; - irq_current_counter = 0; - irq_pending = 0; - NesEmu.IRQFlags &= -9; - return; - } - irq_current_counter++; - if (irq_current_counter == irq_line) - { - irq_pending = 128; - if (irq_enable == 128) - { - NesEmu.IRQFlags |= 8; - } - } - } - - internal override void OnAPUClock() - { - base.OnAPUClock(); - snd_1.Clock(); - snd_2.Clock(); - } - - internal override void OnAPUClockEnvelope() - { - base.OnAPUClockEnvelope(); - snd_1.ClockLength(); - snd_2.ClockLength(); - snd_1.ClockEnvelope(); - snd_2.ClockEnvelope(); - } - - internal override double APUGetSample() - { - return audio_pulse_table[snd_1.output + snd_2.output] + audio_tnd_table[snd_3.output]; - } - - internal override void APUApplyChannelsSettings() - { - base.APUApplyChannelsSettings(); - snd_1.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_MMC5_SQ1; - snd_2.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_MMC5_SQ2; - snd_3.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_MMC5_PCM; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(ram_protectA); - stream.Write(ram_protectB); - stream.Write(ExRAM_mode); - for (int i = 0; i < CHROffset_spr.Length; i++) - { - stream.Write(CHROffset_spr[i]); - } - for (int j = 0; j < CHROffsetEX.Length; j++) - { - stream.Write(CHROffsetEX[j]); - } - for (int k = 0; k < CHROffsetSP.Length; k++) - { - stream.Write(CHROffsetSP[k]); - } - for (int l = 0; l < chrRegA.Length; l++) - { - stream.Write(chrRegA[l]); - } - for (int m = 0; m < chrRegB.Length; m++) - { - stream.Write(chrRegB[m]); - } - for (int n = 0; n < prgReg.Length; n++) - { - stream.Write(prgReg[n]); - } - stream.Write(useSRAMmirroring); - stream.Write(chr_high); - stream.Write(chr_mode); - stream.Write(prg_mode); - stream.Write(chr_setB_last); - stream.Write(temp_val); - stream.Write(temp_fill); - stream.Write(lastAccessVRAM); - stream.Write(paletteNo); - stream.Write(shift); - stream.Write(EXtilenumber); - stream.Write(multiplicand); - stream.Write(multiplier); - stream.Write(product); - stream.Write(split_enable); - stream.Write(split_right); - stream.Write(split_tile); - stream.Write(split_yscroll); - stream.Write(split_doit); - stream.Write(split_watch_tile); - stream.Write(irq_line); - stream.Write(irq_enable); - stream.Write(irq_pending); - stream.Write(irq_current_counter); - stream.Write(irq_current_inframe); - snd_1.WriteStateData(ref stream); - snd_2.WriteStateData(ref stream); - snd_3.SaveState(ref stream); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - ram_protectA = stream.ReadInt32(); - ram_protectB = stream.ReadInt32(); - ExRAM_mode = stream.ReadInt32(); - for (int i = 0; i < CHROffset_spr.Length; i++) - { - CHROffset_spr[i] = stream.ReadInt32(); - } - for (int j = 0; j < CHROffsetEX.Length; j++) - { - CHROffsetEX[j] = stream.ReadInt32(); - } - for (int k = 0; k < CHROffsetSP.Length; k++) - { - CHROffsetSP[k] = stream.ReadInt32(); - } - for (int l = 0; l < chrRegA.Length; l++) - { - chrRegA[l] = stream.ReadInt32(); - } - for (int m = 0; m < chrRegB.Length; m++) - { - chrRegB[m] = stream.ReadInt32(); - } - for (int n = 0; n < prgReg.Length; n++) - { - prgReg[n] = stream.ReadInt32(); - } - useSRAMmirroring = stream.ReadBoolean(); - chr_high = stream.ReadInt32(); - chr_mode = stream.ReadInt32(); - prg_mode = stream.ReadInt32(); - chr_setB_last = stream.ReadBoolean(); - temp_val = stream.ReadByte(); - temp_fill = stream.ReadByte(); - lastAccessVRAM = stream.ReadInt32(); - paletteNo = stream.ReadInt32(); - shift = stream.ReadInt32(); - EXtilenumber = stream.ReadInt32(); - multiplicand = stream.ReadByte(); - multiplier = stream.ReadByte(); - product = stream.ReadUInt16(); - split_enable = stream.ReadBoolean(); - split_right = stream.ReadBoolean(); - split_tile = stream.ReadInt32(); - split_yscroll = stream.ReadInt32(); - split_doit = stream.ReadBoolean(); - split_watch_tile = stream.ReadInt32(); - irq_line = stream.ReadByte(); - irq_enable = stream.ReadByte(); - irq_pending = stream.ReadInt32(); - irq_current_counter = stream.ReadInt32(); - irq_current_inframe = stream.ReadInt32(); - snd_1.ReadStateData(ref stream); - snd_2.ReadStateData(ref stream); - snd_3.LoadState(ref stream); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper005.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper005.cs.meta deleted file mode 100644 index bdd5693..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper005.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bf04ed9f8d2fd1e4bb54763b3bc7bcfa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper006.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper006.cs deleted file mode 100644 index eb94d01..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper006.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("FFE F4xxx", 6)] - [HassIssues] - internal class Mapper006 : FFE - { - internal override string Issues => MNInterfaceLanguage.IssueMapper6; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(7, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(data & 3); - Switch16KPRG((data >> 2) & 0xF, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper006.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper006.cs.meta deleted file mode 100644 index d05dd0f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper006.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a4104e887a80ef44f865e981d84b4d01 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper007.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper007.cs deleted file mode 100644 index c154ef8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper007.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("AxROM", 7)] - internal class Mapper007 : Board - { - internal override void WritePRG(ref ushort addr, ref byte val) - { - Switch01KNMTFromMirroring(((val & 0x10) == 16) ? Mirroring.OneScB : Mirroring.OneScA); - Switch32KPRG(val & 7, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper007.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper007.cs.meta deleted file mode 100644 index f142f13..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper007.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9829484ad2c88fd4ca0539447d126725 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper008.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper008.cs deleted file mode 100644 index 446db68..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper008.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("FFE F3xxx", 8)] - [HassIssues] - internal class Mapper008 : FFE - { - internal override string Issues => MNInterfaceLanguage.IssueMapper8; - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch32KPRG((data >> 4) & 3, PRGArea.Area8000); - Switch08KCHR(data & 3); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper008.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper008.cs.meta deleted file mode 100644 index b7e31ce..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper008.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e8b28ac4454361544919b7f879ab32d4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper009.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper009.cs deleted file mode 100644 index 4fa3514..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper009.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("MMC2", 9)] - internal class Mapper009 : MMC2 - { - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper009.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper009.cs.meta deleted file mode 100644 index c6bd0b7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper009.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b96edc1b48f9f6f44bcfa04f1d3bda1d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper010.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper010.cs deleted file mode 100644 index dfb28ae..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper010.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("MMC4", 10)] - internal class Mapper010 : MMC2 - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(0, PRGArea.Area8000); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if ((address & 0xF000) == 40960) - { - Switch16KPRG(data, PRGArea.Area8000); - } - else - { - base.WritePRG(ref address, ref data); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper010.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper010.cs.meta deleted file mode 100644 index f544b11..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper010.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4b1f6a01ae2d9b840b1bf3e87ba875f3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper011.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper011.cs deleted file mode 100644 index c758f09..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper011.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Color Dreams", 11)] - internal class Mapper011 : Board - { - private byte writeData; - - internal override void WritePRG(ref ushort address, ref byte data) - { - ReadPRG(ref address, out writeData); - writeData &= data; - Switch32KPRG(writeData & 3, PRGArea.Area8000); - Switch08KCHR((writeData >> 4) & 0xF); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper011.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper011.cs.meta deleted file mode 100644 index 36e2e45..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper011.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5c0a3239622d8e841b4cc5d0e35f15ae -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper013.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper013.cs deleted file mode 100644 index 8fe49f9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper013.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("CPROM", 13, 1, 16)] - internal class Mapper013 : Board - { - private byte writeData; - - internal override void HardReset() - { - base.HardReset(); - Toggle08KCHR_RAM(ram: true); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - ReadPRG(ref address, out writeData); - writeData &= data; - Switch04KCHR(writeData & 3, CHRArea.Area1000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper013.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper013.cs.meta deleted file mode 100644 index ad302e8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper013.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6244402647756ed4c899d2d9e2b48754 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper015.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper015.cs deleted file mode 100644 index b8ed811..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper015.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("100-in-1 Contra Function 16", 15)] - internal class Mapper015 : Board - { - private int temp; - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 3) - { - case 0: - Switch16KPRG(data & 0x3F, PRGArea.Area8000); - Switch16KPRG((data & 0x3F) | 1, PRGArea.AreaC000); - break; - case 1: - Switch16KPRG(data & 0x3F, PRGArea.Area8000); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - break; - case 2: - temp = data << 1; - temp = ((data & 0x3F) << 1) | ((data >> 7) & 1); - Switch08KPRG(temp, PRGArea.Area8000); - Switch08KPRG(temp, PRGArea.AreaA000); - Switch08KPRG(temp, PRGArea.AreaC000); - Switch08KPRG(temp, PRGArea.AreaE000); - break; - case 3: - Switch16KPRG(data & 0x3F, PRGArea.Area8000); - Switch16KPRG(data & 0x3F, PRGArea.AreaC000); - break; - } - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper015.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper015.cs.meta deleted file mode 100644 index 94eb1ed..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper015.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 91c36800c0238a84cbe2f1313237d9df -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper016.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper016.cs deleted file mode 100644 index b694bff..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper016.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Bandai", 16)] - internal class Mapper016 : Bandai - { - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper017.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper017.cs deleted file mode 100644 index 68564b2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper017.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("FFE F8xxx", 17)] - internal class Mapper017 : FFE - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - switch (address) - { - case 17668: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 17669: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 17670: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 17671: - Switch08KPRG(data, PRGArea.AreaE000); - break; - case 17680: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 17681: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 17682: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 17683: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 17684: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 17685: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 17686: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 17687: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 17672: - case 17673: - case 17674: - case 17675: - case 17676: - case 17677: - case 17678: - case 17679: - break; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper018.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper018.cs deleted file mode 100644 index b494b9f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper018.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Jaleco SS8806", 18)] - internal class Mapper018 : Board - { - private int[] prg_reg; - - private int[] chr_reg; - - private int irqRelaod; - - private int irqCounter; - - private bool irqEnable; - - private int irqMask; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - prg_reg = new int[3]; - chr_reg = new int[8]; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF003) - { - case 32768: - prg_reg[0] = (prg_reg[0] & 0xF0) | (data & 0xF); - Switch08KPRG(prg_reg[0], PRGArea.Area8000); - break; - case 32769: - prg_reg[0] = (prg_reg[0] & 0xF) | ((data & 0xF) << 4); - Switch08KPRG(prg_reg[0], PRGArea.Area8000); - break; - case 32770: - prg_reg[1] = (prg_reg[1] & 0xF0) | (data & 0xF); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - break; - case 32771: - prg_reg[1] = (prg_reg[1] & 0xF) | ((data & 0xF) << 4); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - break; - case 36864: - prg_reg[2] = (prg_reg[2] & 0xF0) | (data & 0xF); - Switch08KPRG(prg_reg[2], PRGArea.AreaC000); - break; - case 36865: - prg_reg[2] = (prg_reg[2] & 0xF) | ((data & 0xF) << 4); - Switch08KPRG(prg_reg[2], PRGArea.AreaC000); - break; - case 40960: - chr_reg[0] = (chr_reg[0] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[0], CHRArea.Area0000); - break; - case 40961: - chr_reg[0] = (chr_reg[0] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[0], CHRArea.Area0000); - break; - case 40962: - chr_reg[1] = (chr_reg[1] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[1], CHRArea.Area0400); - break; - case 40963: - chr_reg[1] = (chr_reg[1] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[1], CHRArea.Area0400); - break; - case 45056: - chr_reg[2] = (chr_reg[2] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[2], CHRArea.Area0800); - break; - case 45057: - chr_reg[2] = (chr_reg[2] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[2], CHRArea.Area0800); - break; - case 45058: - chr_reg[3] = (chr_reg[3] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[3], CHRArea.Area0C00); - break; - case 45059: - chr_reg[3] = (chr_reg[3] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[3], CHRArea.Area0C00); - break; - case 49152: - chr_reg[4] = (chr_reg[4] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[4], CHRArea.Area1000); - break; - case 49153: - chr_reg[4] = (chr_reg[4] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[4], CHRArea.Area1000); - break; - case 49154: - chr_reg[5] = (chr_reg[5] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[5], CHRArea.Area1400); - break; - case 49155: - chr_reg[5] = (chr_reg[5] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[5], CHRArea.Area1400); - break; - case 53248: - chr_reg[6] = (chr_reg[6] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[6], CHRArea.Area1800); - break; - case 53249: - chr_reg[6] = (chr_reg[6] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[6], CHRArea.Area1800); - break; - case 53250: - chr_reg[7] = (chr_reg[7] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_reg[7], CHRArea.Area1C00); - break; - case 53251: - chr_reg[7] = (chr_reg[7] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_reg[7], CHRArea.Area1C00); - break; - case 57344: - irqRelaod = (irqRelaod & 0xFFF0) | (data & 0xF); - break; - case 57345: - irqRelaod = (irqRelaod & 0xFF0F) | ((data & 0xF) << 4); - break; - case 57346: - irqRelaod = (irqRelaod & 0xF0FF) | ((data & 0xF) << 8); - break; - case 57347: - irqRelaod = (irqRelaod & 0xFFF) | ((data & 0xF) << 12); - break; - case 61440: - irqCounter = irqRelaod; - NesEmu.IRQFlags &= -9; - break; - case 61441: - irqEnable = (data & 1) == 1; - if ((data & 8) == 8) - { - irqMask = 15; - } - else if ((data & 4) == 4) - { - irqMask = 255; - } - else if ((data & 2) == 2) - { - irqMask = 4095; - } - else - { - irqMask = 65535; - } - NesEmu.IRQFlags &= -9; - break; - case 61442: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - } - } - - internal override void OnCPUClock() - { - if (irqEnable && (irqCounter & irqMask) > 0 && (--irqCounter & irqMask) == 0) - { - irqEnable = false; - NesEmu.IRQFlags |= 8; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - for (int i = 0; i < prg_reg.Length; i++) - { - stream.Write(prg_reg[i]); - } - for (int j = 0; j < chr_reg.Length; j++) - { - stream.Write(chr_reg[j]); - } - stream.Write(irqRelaod); - stream.Write(irqCounter); - stream.Write(irqEnable); - stream.Write(irqMask); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - for (int i = 0; i < prg_reg.Length; i++) - { - prg_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < chr_reg.Length; j++) - { - chr_reg[j] = stream.ReadInt32(); - } - irqRelaod = stream.ReadInt32(); - irqCounter = stream.ReadInt32(); - irqEnable = stream.ReadBoolean(); - irqMask = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper019.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper019.cs deleted file mode 100644 index a1945cb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper019.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Namcot 106", 19, 1, 256)] - internal class Mapper019 : Namcot106 - { - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper021.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper021.cs deleted file mode 100644 index e40cfff..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper021.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC4", 21)] - internal class Mapper021 : Board - { - private bool prg_mode; - - private byte prg_reg0; - - private int[] chr_Reg; - - private int irq_reload; - - private int irq_counter; - - private int prescaler; - - private bool irq_mode_cycle; - - private bool irq_enable; - - private bool irq_enable_on_ak; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - prescaler = 341; - chr_Reg = new int[8]; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - case 32770: - case 32772: - case 32774: - case 32832: - case 32896: - case 32960: - prg_reg0 = data; - Switch08KPRG(prg_mode ? (PRG_ROM_08KB_Mask - 1) : (prg_reg0 & 0x1F), PRGArea.Area8000); - Switch08KPRG(prg_mode ? (prg_reg0 & 0x1F) : (PRG_ROM_08KB_Mask - 1), PRGArea.AreaC000); - break; - case 36864: - case 36866: - case 36928: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 36868: - case 36870: - case 36992: - case 37056: - prg_mode = (data & 2) == 2; - Switch08KPRG(prg_mode ? (PRG_ROM_08KB_Mask - 1) : (prg_reg0 & 0x1F), PRGArea.Area8000); - Switch08KPRG(prg_mode ? (prg_reg0 & 0x1F) : (PRG_ROM_08KB_Mask - 1), PRGArea.AreaC000); - break; - case 40960: - case 40962: - case 40964: - case 40966: - case 41024: - case 41088: - case 41152: - Switch08KPRG(data & 0x1F, PRGArea.AreaA000); - break; - case 45056: - chr_Reg[0] = (chr_Reg[0] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[0], CHRArea.Area0000); - break; - case 45058: - case 45120: - chr_Reg[0] = (chr_Reg[0] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[0], CHRArea.Area0000); - break; - case 45060: - case 45184: - chr_Reg[1] = (chr_Reg[1] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[1], CHRArea.Area0400); - break; - case 45062: - case 45248: - chr_Reg[1] = (chr_Reg[1] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[1], CHRArea.Area0400); - break; - case 49152: - chr_Reg[2] = (chr_Reg[2] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[2], CHRArea.Area0800); - break; - case 49154: - case 49216: - chr_Reg[2] = (chr_Reg[2] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[2], CHRArea.Area0800); - break; - case 49156: - case 49280: - chr_Reg[3] = (chr_Reg[3] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[3], CHRArea.Area0C00); - break; - case 49158: - case 49344: - chr_Reg[3] = (chr_Reg[3] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[3], CHRArea.Area0C00); - break; - case 53248: - chr_Reg[4] = (chr_Reg[4] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[4], CHRArea.Area1000); - break; - case 53250: - case 53312: - chr_Reg[4] = (chr_Reg[4] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[4], CHRArea.Area1000); - break; - case 53252: - case 53376: - chr_Reg[5] = (chr_Reg[5] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[5], CHRArea.Area1400); - break; - case 53254: - case 53440: - chr_Reg[5] = (chr_Reg[5] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[5], CHRArea.Area1400); - break; - case 57344: - chr_Reg[6] = (chr_Reg[6] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[6], CHRArea.Area1800); - break; - case 57346: - case 57408: - chr_Reg[6] = (chr_Reg[6] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[6], CHRArea.Area1800); - break; - case 57348: - case 57472: - chr_Reg[7] = (chr_Reg[7] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[7], CHRArea.Area1C00); - break; - case 57350: - case 57536: - chr_Reg[7] = (chr_Reg[7] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[7], CHRArea.Area1C00); - break; - case 61440: - irq_reload = (irq_reload & 0xF0) | (data & 0xF); - break; - case 61442: - case 61504: - irq_reload = (irq_reload & 0xF) | ((data & 0xF) << 4); - break; - case 61444: - case 61568: - irq_mode_cycle = (data & 4) == 4; - irq_enable = (data & 2) == 2; - irq_enable_on_ak = (data & 1) == 1; - if (irq_enable) - { - irq_counter = irq_reload; - prescaler = 341; - } - NesEmu.IRQFlags &= -9; - break; - case 61446: - case 61632: - NesEmu.IRQFlags &= -9; - irq_enable = irq_enable_on_ak; - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_enable) - { - return; - } - if (!irq_mode_cycle) - { - if (prescaler > 0) - { - prescaler -= 3; - return; - } - prescaler = 341; - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - else - { - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_mode); - stream.Write(prg_reg0); - for (int i = 0; i < chr_Reg.Length; i++) - { - stream.Write(chr_Reg[i]); - } - stream.Write(irq_reload); - stream.Write(irq_counter); - stream.Write(prescaler); - stream.Write(irq_mode_cycle); - stream.Write(irq_enable); - stream.Write(irq_enable_on_ak); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_mode = stream.ReadBoolean(); - prg_reg0 = stream.ReadByte(); - for (int i = 0; i < chr_Reg.Length; i++) - { - chr_Reg[i] = stream.ReadInt32(); - } - irq_reload = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - prescaler = stream.ReadInt32(); - irq_mode_cycle = stream.ReadBoolean(); - irq_enable = stream.ReadBoolean(); - irq_enable_on_ak = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper022.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper022.cs deleted file mode 100644 index 6d0876d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper022.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC2", 22)] - internal class Mapper022 : Board - { - private int[] chr_Reg; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - chr_Reg = new int[8]; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - case 32769: - case 32770: - case 32771: - Switch08KPRG(data & 0xF, PRGArea.Area8000); - break; - case 36864: - case 36865: - case 36866: - case 36867: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 40960: - case 40961: - case 40962: - case 40963: - Switch08KPRG(data & 0xF, PRGArea.AreaA000); - break; - case 45056: - chr_Reg[0] = (chr_Reg[0] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[0] >> 1, CHRArea.Area0000); - break; - case 45058: - chr_Reg[0] = (chr_Reg[0] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[0] >> 1, CHRArea.Area0000); - break; - case 45057: - chr_Reg[1] = (chr_Reg[1] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[1] >> 1, CHRArea.Area0400); - break; - case 45059: - chr_Reg[1] = (chr_Reg[1] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[1] >> 1, CHRArea.Area0400); - break; - case 49152: - chr_Reg[2] = (chr_Reg[2] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[2] >> 1, CHRArea.Area0800); - break; - case 49154: - chr_Reg[2] = (chr_Reg[2] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[2] >> 1, CHRArea.Area0800); - break; - case 49153: - chr_Reg[3] = (chr_Reg[3] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[3] >> 1, CHRArea.Area0C00); - break; - case 49155: - chr_Reg[3] = (chr_Reg[3] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[3] >> 1, CHRArea.Area0C00); - break; - case 53248: - chr_Reg[4] = (chr_Reg[4] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[4] >> 1, CHRArea.Area1000); - break; - case 53250: - chr_Reg[4] = (chr_Reg[4] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[4] >> 1, CHRArea.Area1000); - break; - case 53249: - chr_Reg[5] = (chr_Reg[5] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[5] >> 1, CHRArea.Area1400); - break; - case 53251: - chr_Reg[5] = (chr_Reg[5] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[5] >> 1, CHRArea.Area1400); - break; - case 57344: - chr_Reg[6] = (chr_Reg[6] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[6] >> 1, CHRArea.Area1800); - break; - case 57346: - chr_Reg[6] = (chr_Reg[6] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[6] >> 1, CHRArea.Area1800); - break; - case 57345: - chr_Reg[7] = (chr_Reg[7] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[7] >> 1, CHRArea.Area1C00); - break; - case 57347: - chr_Reg[7] = (chr_Reg[7] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[7] >> 1, CHRArea.Area1C00); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - for (int i = 0; i < chr_Reg.Length; i++) - { - stream.Write(chr_Reg[i]); - } - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - for (int i = 0; i < chr_Reg.Length; i++) - { - chr_Reg[i] = stream.ReadInt32(); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper023.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper023.cs deleted file mode 100644 index a4ffe2f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper023.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC2", 23)] - internal class Mapper023 : Board - { - private int[] chr_Reg; - - private byte security; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - chr_Reg = new int[8]; - security = 0; - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (address == 24576) - { - security = (byte)(data & 1u); - } - } - - internal override void ReadSRM(ref ushort address, out byte data) - { - if (address == 24576) - { - data = security; - } - else - { - data = 0; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - case 32769: - case 32770: - case 32771: - Switch08KPRG(data & 0xF, PRGArea.Area8000); - break; - case 36864: - case 36865: - case 36866: - case 36867: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 40960: - case 40961: - case 40962: - case 40963: - Switch08KPRG(data & 0xF, PRGArea.AreaA000); - break; - case 45056: - chr_Reg[0] = (chr_Reg[0] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[0], CHRArea.Area0000); - break; - case 45057: - chr_Reg[0] = (chr_Reg[0] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[0], CHRArea.Area0000); - break; - case 45058: - chr_Reg[1] = (chr_Reg[1] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[1], CHRArea.Area0400); - break; - case 45059: - chr_Reg[1] = (chr_Reg[1] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[1], CHRArea.Area0400); - break; - case 49152: - chr_Reg[2] = (chr_Reg[2] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[2], CHRArea.Area0800); - break; - case 49153: - chr_Reg[2] = (chr_Reg[2] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[2], CHRArea.Area0800); - break; - case 49154: - chr_Reg[3] = (chr_Reg[3] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[3], CHRArea.Area0C00); - break; - case 49155: - chr_Reg[3] = (chr_Reg[3] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[3], CHRArea.Area0C00); - break; - case 53248: - chr_Reg[4] = (chr_Reg[4] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[4], CHRArea.Area1000); - break; - case 53249: - chr_Reg[4] = (chr_Reg[4] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[4], CHRArea.Area1000); - break; - case 53250: - chr_Reg[5] = (chr_Reg[5] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[5], CHRArea.Area1400); - break; - case 53251: - chr_Reg[5] = (chr_Reg[5] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[5], CHRArea.Area1400); - break; - case 57344: - chr_Reg[6] = (chr_Reg[6] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[6], CHRArea.Area1800); - break; - case 57345: - chr_Reg[6] = (chr_Reg[6] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[6], CHRArea.Area1800); - break; - case 57346: - chr_Reg[7] = (chr_Reg[7] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[7], CHRArea.Area1C00); - break; - case 57347: - chr_Reg[7] = (chr_Reg[7] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[7], CHRArea.Area1C00); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - for (int i = 0; i < chr_Reg.Length; i++) - { - stream.Write(chr_Reg[i]); - } - stream.Write(security); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - for (int i = 0; i < chr_Reg.Length; i++) - { - chr_Reg[i] = stream.ReadInt32(); - } - security = stream.ReadByte(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper024.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper024.cs deleted file mode 100644 index 57f2fac..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper024.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC6", 24)] - [WithExternalSound] - internal class Mapper024 : Board - { - private int irq_reload; - - private int irq_counter; - - private int prescaler; - - private bool irq_mode_cycle; - - private bool irq_enable; - - private bool irq_enable_on_ak; - - private VRC6Pulse snd_1; - - private VRC6Pulse snd_2; - - private VRC6Sawtooth snd_3; - - private double[] audio_pulse_table; - - private double[] audio_tnd_table; - - internal override void Initialize(IRom rom) - { - base.Initialize(rom); - snd_1 = new VRC6Pulse(); - snd_2 = new VRC6Pulse(); - snd_3 = new VRC6Sawtooth(); - audio_pulse_table = new double[32]; - for (int i = 0; i < 32; i++) - { - audio_pulse_table[i] = 95.52 / (8128.0 / (double)i + 100.0); - } - audio_tnd_table = new double[204]; - for (int j = 0; j < 204; j++) - { - audio_tnd_table[j] = 163.67 / (24329.0 / (double)j + 100.0); - } - } - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - APUApplyChannelsSettings(); - snd_1.HardReset(); - snd_2.HardReset(); - snd_3.HardReset(); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - case 32769: - case 32770: - case 32771: - Switch16KPRG(data, PRGArea.Area8000); - break; - case 36864: - snd_1.Write0(ref data); - break; - case 36865: - snd_1.Write1(ref data); - break; - case 36866: - snd_1.Write2(ref data); - break; - case 40960: - snd_2.Write0(ref data); - break; - case 40961: - snd_2.Write1(ref data); - break; - case 40962: - snd_2.Write2(ref data); - break; - case 45056: - snd_3.Write0(ref data); - break; - case 45057: - snd_3.Write1(ref data); - break; - case 45058: - snd_3.Write2(ref data); - break; - case 45059: - switch ((data & 0xC) >> 2) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 49152: - case 49153: - case 49154: - case 49155: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 53248: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 53249: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 53250: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 53251: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 57344: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 57345: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 57346: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 57347: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 61440: - irq_reload = data; - break; - case 61441: - irq_mode_cycle = (data & 4) == 4; - irq_enable = (data & 2) == 2; - irq_enable_on_ak = (data & 1) == 1; - if (irq_enable) - { - irq_counter = irq_reload; - prescaler = 341; - } - NesEmu.IRQFlags &= -9; - break; - case 61442: - NesEmu.IRQFlags &= -9; - irq_enable = irq_enable_on_ak; - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_enable) - { - return; - } - if (!irq_mode_cycle) - { - if (prescaler > 0) - { - prescaler -= 3; - return; - } - prescaler = 341; - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - else - { - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - } - - internal override void OnAPUClockSingle() - { - base.OnAPUClockSingle(); - snd_1.ClockSingle(); - snd_2.ClockSingle(); - snd_3.ClockSingle(); - } - - internal override void APUApplyChannelsSettings() - { - base.APUApplyChannelsSettings(); - snd_1.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_VRC6_SQ1; - snd_2.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_VRC6_SQ2; - snd_3.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_VRC6_SAW; - } - - internal override double APUGetSample() - { - return audio_pulse_table[snd_1.output + snd_2.output] + audio_tnd_table[snd_3.output]; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_reload); - stream.Write(irq_counter); - stream.Write(prescaler); - stream.Write(irq_mode_cycle); - stream.Write(irq_enable); - stream.Write(irq_enable_on_ak); - snd_1.SaveState(ref stream); - snd_2.SaveState(ref stream); - snd_3.SaveState(ref stream); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_reload = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - prescaler = stream.ReadInt32(); - irq_mode_cycle = stream.ReadBoolean(); - irq_enable = stream.ReadBoolean(); - irq_enable_on_ak = stream.ReadBoolean(); - snd_1.LoadState(ref stream); - snd_2.LoadState(ref stream); - snd_3.LoadState(ref stream); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper025.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper025.cs deleted file mode 100644 index a857cb8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper025.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC4", 25)] - internal class Mapper025 : Board - { - private bool prg_mode; - - private byte prg_reg0; - - private int[] chr_Reg; - - private int irq_reload; - - private int irq_counter; - - private int prescaler; - - private bool irq_mode_cycle; - - private bool irq_enable; - - private bool irq_enable_on_ak; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - prescaler = 341; - chr_Reg = new int[8]; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - case 32769: - case 32770: - case 32771: - case 32772: - case 32776: - case 32780: - prg_reg0 = data; - Switch08KPRG(prg_mode ? (PRG_ROM_08KB_Mask - 1) : (prg_reg0 & 0x1F), PRGArea.Area8000); - Switch08KPRG(prg_mode ? (prg_reg0 & 0x1F) : (PRG_ROM_08KB_Mask - 1), PRGArea.AreaC000); - break; - case 36864: - case 36866: - case 36872: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 36865: - case 36867: - case 36868: - case 36876: - prg_mode = (data & 2) == 2; - Switch08KPRG(prg_mode ? (PRG_ROM_08KB_Mask - 1) : (prg_reg0 & 0x1F), PRGArea.Area8000); - Switch08KPRG(prg_mode ? (prg_reg0 & 0x1F) : (PRG_ROM_08KB_Mask - 1), PRGArea.AreaC000); - break; - case 40960: - case 40961: - case 40962: - case 40963: - case 40964: - case 40968: - case 40972: - Switch08KPRG(data & 0x1F, PRGArea.AreaA000); - break; - case 45056: - chr_Reg[0] = (chr_Reg[0] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[0], CHRArea.Area0000); - break; - case 45058: - case 45064: - chr_Reg[0] = (chr_Reg[0] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[0], CHRArea.Area0000); - break; - case 45057: - case 45060: - chr_Reg[1] = (chr_Reg[1] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[1], CHRArea.Area0400); - break; - case 45059: - case 45068: - chr_Reg[1] = (chr_Reg[1] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[1], CHRArea.Area0400); - break; - case 49152: - chr_Reg[2] = (chr_Reg[2] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[2], CHRArea.Area0800); - break; - case 49154: - case 49160: - chr_Reg[2] = (chr_Reg[2] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[2], CHRArea.Area0800); - break; - case 49153: - case 49156: - chr_Reg[3] = (chr_Reg[3] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[3], CHRArea.Area0C00); - break; - case 49155: - case 49164: - chr_Reg[3] = (chr_Reg[3] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[3], CHRArea.Area0C00); - break; - case 53248: - chr_Reg[4] = (chr_Reg[4] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[4], CHRArea.Area1000); - break; - case 53250: - case 53256: - chr_Reg[4] = (chr_Reg[4] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[4], CHRArea.Area1000); - break; - case 53249: - case 53252: - chr_Reg[5] = (chr_Reg[5] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[5], CHRArea.Area1400); - break; - case 53251: - case 53260: - chr_Reg[5] = (chr_Reg[5] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[5], CHRArea.Area1400); - break; - case 57344: - chr_Reg[6] = (chr_Reg[6] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[6], CHRArea.Area1800); - break; - case 57346: - case 57352: - chr_Reg[6] = (chr_Reg[6] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[6], CHRArea.Area1800); - break; - case 57345: - case 57348: - chr_Reg[7] = (chr_Reg[7] & 0xF0) | (data & 0xF); - Switch01KCHR(chr_Reg[7], CHRArea.Area1C00); - break; - case 57347: - case 57356: - chr_Reg[7] = (chr_Reg[7] & 0xF) | ((data & 0xF) << 4); - Switch01KCHR(chr_Reg[7], CHRArea.Area1C00); - break; - case 61440: - irq_reload = (irq_reload & 0xF0) | (data & 0xF); - break; - case 61442: - case 61448: - irq_reload = (irq_reload & 0xF) | ((data & 0xF) << 4); - break; - case 61441: - case 61444: - irq_mode_cycle = (data & 4) == 4; - irq_enable = (data & 2) == 2; - irq_enable_on_ak = (data & 1) == 1; - if (irq_enable) - { - irq_counter = irq_reload; - prescaler = 341; - } - NesEmu.IRQFlags &= -9; - break; - case 61443: - case 61452: - NesEmu.IRQFlags &= -9; - irq_enable = irq_enable_on_ak; - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_enable) - { - return; - } - if (!irq_mode_cycle) - { - if (prescaler > 0) - { - prescaler -= 3; - return; - } - prescaler = 341; - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - else - { - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_mode); - stream.Write(prg_reg0); - for (int i = 0; i < chr_Reg.Length; i++) - { - stream.Write(chr_Reg[i]); - } - stream.Write(irq_reload); - stream.Write(irq_counter); - stream.Write(prescaler); - stream.Write(irq_mode_cycle); - stream.Write(irq_enable); - stream.Write(irq_enable_on_ak); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_mode = stream.ReadBoolean(); - prg_reg0 = stream.ReadByte(); - for (int i = 0; i < chr_Reg.Length; i++) - { - chr_Reg[i] = stream.ReadInt32(); - } - irq_reload = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - prescaler = stream.ReadInt32(); - irq_mode_cycle = stream.ReadBoolean(); - irq_enable = stream.ReadBoolean(); - irq_enable_on_ak = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper026.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper026.cs deleted file mode 100644 index d9a6756..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper026.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC6", 26)] - [WithExternalSound] - internal class Mapper026 : Board - { - private int irq_reload; - - private int irq_counter; - - private int prescaler; - - private bool irq_mode_cycle; - - private bool irq_enable; - - private bool irq_enable_on_ak; - - private VRC6Pulse snd_1; - - private VRC6Pulse snd_2; - - private VRC6Sawtooth snd_3; - - private double[] audio_pulse_table; - - private double[] audio_tnd_table; - - internal override void Initialize(IRom rom) - { - base.Initialize(rom); - snd_1 = new VRC6Pulse(); - snd_2 = new VRC6Pulse(); - snd_3 = new VRC6Sawtooth(); - audio_pulse_table = new double[32]; - for (int i = 0; i < 32; i++) - { - audio_pulse_table[i] = 95.52 / (8128.0 / (double)i + 100.0); - } - audio_tnd_table = new double[204]; - for (int j = 0; j < 204; j++) - { - audio_tnd_table[j] = 163.67 / (24329.0 / (double)j + 100.0); - } - } - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - APUApplyChannelsSettings(); - snd_1.HardReset(); - snd_2.HardReset(); - snd_3.HardReset(); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - case 32769: - case 32770: - case 32771: - Switch16KPRG(data, PRGArea.Area8000); - break; - case 36864: - snd_1.Write0(ref data); - break; - case 36866: - snd_1.Write1(ref data); - break; - case 36865: - snd_1.Write2(ref data); - break; - case 40960: - snd_2.Write0(ref data); - break; - case 40962: - snd_2.Write1(ref data); - break; - case 40961: - snd_2.Write2(ref data); - break; - case 45056: - snd_3.Write0(ref data); - break; - case 45058: - snd_3.Write1(ref data); - break; - case 45057: - snd_3.Write2(ref data); - break; - case 45059: - switch ((data & 0xC) >> 2) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 49152: - case 49153: - case 49154: - case 49155: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 53248: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 53250: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 53249: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 53251: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 57344: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 57346: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 57345: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 57347: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 61440: - irq_reload = data; - break; - case 61442: - irq_mode_cycle = (data & 4) == 4; - irq_enable = (data & 2) == 2; - irq_enable_on_ak = (data & 1) == 1; - if (irq_enable) - { - irq_counter = irq_reload; - prescaler = 341; - } - NesEmu.IRQFlags &= -9; - break; - case 61441: - NesEmu.IRQFlags &= -9; - irq_enable = irq_enable_on_ak; - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_enable) - { - return; - } - if (!irq_mode_cycle) - { - if (prescaler > 0) - { - prescaler -= 3; - return; - } - prescaler = 341; - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - else - { - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - } - - internal override void OnAPUClockSingle() - { - base.OnAPUClockSingle(); - snd_1.ClockSingle(); - snd_2.ClockSingle(); - snd_3.ClockSingle(); - } - - internal override void APUApplyChannelsSettings() - { - base.APUApplyChannelsSettings(); - snd_1.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_VRC6_SQ1; - snd_2.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_VRC6_SQ2; - snd_3.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_VRC6_SAW; - } - - internal override double APUGetSample() - { - return audio_pulse_table[snd_1.output + snd_2.output] + audio_tnd_table[snd_3.output]; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_reload); - stream.Write(irq_counter); - stream.Write(prescaler); - stream.Write(irq_mode_cycle); - stream.Write(irq_enable); - stream.Write(irq_enable_on_ak); - snd_1.SaveState(ref stream); - snd_2.SaveState(ref stream); - snd_3.SaveState(ref stream); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_reload = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - prescaler = stream.ReadInt32(); - irq_mode_cycle = stream.ReadBoolean(); - irq_enable = stream.ReadBoolean(); - irq_enable_on_ak = stream.ReadBoolean(); - snd_1.LoadState(ref stream); - snd_2.LoadState(ref stream); - snd_3.LoadState(ref stream); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper032.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper032.cs deleted file mode 100644 index d2147d1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper032.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Irem G-101", 32)] - internal class Mapper032 : Board - { - private bool prg_mode; - - private byte prg_reg0; - - private bool enable_mirroring_switch; - - internal override void HardReset() - { - base.HardReset(); - enable_mirroring_switch = true; - if (SHA1 == "7E4180432726A433C46BA2206D9E13B32761C11E") - { - enable_mirroring_switch = false; - Switch01KNMTFromMirroring(Mirroring.OneScA); - } - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF007) - { - case 32768: - case 32769: - case 32770: - case 32771: - case 32772: - case 32773: - case 32774: - case 32775: - prg_reg0 = data; - Switch08KPRG((!prg_mode) ? prg_reg0 : 0, PRGArea.Area8000); - Switch08KPRG(prg_mode ? prg_reg0 : (PRG_ROM_08KB_Mask - 1), PRGArea.AreaC000); - break; - case 36864: - case 36865: - case 36866: - case 36867: - case 36868: - case 36869: - case 36870: - case 36871: - prg_mode = (data & 2) == 2; - Switch08KPRG((!prg_mode) ? prg_reg0 : 0, PRGArea.Area8000); - Switch08KPRG(prg_mode ? prg_reg0 : (PRG_ROM_08KB_Mask - 1), PRGArea.AreaC000); - if (enable_mirroring_switch) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40960: - case 40961: - case 40962: - case 40963: - case 40964: - case 40965: - case 40966: - case 40967: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 45056: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 45057: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 45058: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 45059: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 45060: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 45061: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 45062: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 45063: - Switch01KCHR(data, CHRArea.Area1C00); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_mode); - stream.Write(prg_reg0); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_mode = stream.ReadBoolean(); - prg_reg0 = stream.ReadByte(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper033.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper033.cs deleted file mode 100644 index f29316f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper033.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Taito TC0190/TC0350", 33)] - [HassIssues] - internal class Mapper033 : Board - { - private bool MODE; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override string Issues => MNInterfaceLanguage.IssueMapper33; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - MODE = true; - if (IsGameFoundOnDB) - { - foreach (string chip in base.Chips) - { - if (chip.Contains("TC0190")) - { - MODE = false; - ppuA12TogglesOnRaisingEdge = true; - enabled_ppuA12ToggleTimer = true; - break; - } - } - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - mmc3_alt_behavior = false; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (!MODE) - { - switch (address & 0xE003) - { - case 32768: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 32769: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 32770: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 32771: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 40960: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 40961: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 40962: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 40963: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 49152: - irq_reload = (byte)(data ^ 0xFFu); - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 49154: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 49155: - irq_enabled = true; - break; - case 57344: - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Horz : Mirroring.Vert); - break; - } - } - else - { - switch (address & 0xA003) - { - case 32768: - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Horz : Mirroring.Vert); - Switch08KPRG(data & 0x3F, PRGArea.Area8000); - break; - case 32769: - Switch08KPRG(data & 0x3F, PRGArea.AreaA000); - break; - case 32770: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 32771: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 40960: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 40961: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 40962: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 40963: - Switch01KCHR(data, CHRArea.Area1C00); - break; - } - } - } - - internal override void OnPPUA12RaisingEdge() - { - if (!MODE) - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper034.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper034.cs deleted file mode 100644 index fbb049f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper034.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("BxROM/NINA-001", 34)] - internal class Mapper034 : Board - { - private bool BxROM; - - private byte writeData; - - internal override void HardReset() - { - base.HardReset(); - BxROM = true; - if (base.BoardType.Contains("NINA")) - { - BxROM = false; - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - base.WriteSRM(ref address, ref data); - if (!BxROM) - { - switch (address) - { - case 32765: - Switch32KPRG(data, PRGArea.Area8000); - break; - case 32766: - Switch04KCHR(data, CHRArea.Area0000); - break; - case 32767: - Switch04KCHR(data, CHRArea.Area1000); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (BxROM) - { - ReadPRG(ref address, out writeData); - writeData &= data; - Switch32KPRG(writeData, PRGArea.Area8000); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper041.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper041.cs deleted file mode 100644 index 0cb7637..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper041.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Caltron 6-in-1", 41)] - internal class Mapper041 : Board - { - private bool enableReg; - - private int vromReg; - - internal override void HardReset() - { - base.HardReset(); - vromReg = 0; - enableReg = true; - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (address <= 26623) - { - Switch32KPRG(address & 7, PRGArea.Area8000); - enableReg = (address & 4) == 4; - vromReg = (vromReg & 3) | ((address >> 1) & 0xC); - Switch08KCHR(vromReg); - Switch01KNMTFromMirroring(((address & 0x20) == 32) ? Mirroring.Horz : Mirroring.Vert); - } - else - { - base.WriteSRM(ref address, ref data); - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (enableReg) - { - vromReg = (vromReg & 0xC) | (data & 3); - Switch08KCHR(vromReg); - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(enableReg); - stream.Write(vromReg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - enableReg = stream.ReadBoolean(); - vromReg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper042.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper042.cs deleted file mode 100644 index 17590f6..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper042.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Mario Baby", 42)] - internal class Mapper042 : Board - { - private int SRAM_PRG_Page; - - private bool irqEnable; - - private int irqCounter; - - internal override void HardReset() - { - base.HardReset(); - Switch32KPRG(PRG_ROM_32KB_Mask, PRGArea.Area8000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (address == 32768) - { - Switch08KCHR(data); - return; - } - if (address == 61440) - { - SRAM_PRG_Page = data << 13; - return; - } - switch (address & 0xE003) - { - case 57344: - Switch08KPRG(data, PRGArea.Area6000); - break; - case 57345: - if ((data & 8) == 8) - { - Switch01KNMTFromMirroring(Mirroring.Horz); - } - else - { - Switch01KNMTFromMirroring(Mirroring.Vert); - } - break; - case 57346: - irqEnable = (data & 2) == 2; - if (!irqEnable) - { - irqCounter = 0; - } - NesEmu.IRQFlags &= -9; - break; - } - } - - internal override void OnCPUClock() - { - if (!irqEnable) - { - return; - } - int num = irqCounter++; - if ((irqCounter & 0x6000) != (num & 0x6000)) - { - if ((irqCounter & 0x6000) == 24576) - { - NesEmu.IRQFlags |= 8; - } - else - { - NesEmu.IRQFlags &= -9; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(SRAM_PRG_Page); - stream.Write(irqEnable); - stream.Write(irqCounter); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - SRAM_PRG_Page = stream.ReadInt32(); - irqEnable = stream.ReadBoolean(); - irqCounter = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper044.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper044.cs deleted file mode 100644 index bfa9ff3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper044.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("7-in-1 MMC3 Port A001h", 44, true, true)] - [HassIssues] - internal class Mapper044 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int block; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - private int prg_and; - - private int prg_or; - - private int chr_and; - - private int chr_or; - - internal override string Issues => MNInterfaceLanguage.IssueMapper44; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_and = 15; - prg_or = 0; - chr_and = 127; - chr_or = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - block = data & 7; - prg_and = ((block > 5) ? 31 : 15); - prg_or = ((block < 5) ? (block << 4) : 96); - chr_and = ((block > 5) ? 255 : 127); - chr_or = ((block < 5) ? (block << 7) : 768); - SetupPRG(); - SetupCHR(); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area0000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area1000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area1400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area1800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area1C00); - } - else - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area1000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area0000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area0400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area0800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG((prg_reg[flag_p ? 2 : 0] & prg_and) | prg_or, PRGArea.Area8000); - Switch08KPRG((prg_reg[1] & prg_and) | prg_or, PRGArea.AreaA000); - Switch08KPRG((prg_reg[(!flag_p) ? 2 : 0] & prg_and) | prg_or, PRGArea.AreaC000); - Switch08KPRG((prg_reg[3] & prg_and) | prg_or, PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - stream.Write(block); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(prg_and); - stream.Write(prg_or); - stream.Write(chr_and); - stream.Write(chr_or); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - block = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - prg_and = stream.ReadInt32(); - prg_or = stream.ReadInt32(); - chr_and = stream.ReadInt32(); - chr_or = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper045.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper045.cs deleted file mode 100644 index e55b8d2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper045.cs +++ /dev/null @@ -1,294 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("X-in-1 MMC3 Port 6000hx4", 45, true, true)] - internal class Mapper045 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - private bool locked; - - private int regCounter; - - private int prg_and; - - private int prg_or; - - private int chr_and; - - private int chr_or; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_and = 63; - prg_or = 0; - chr_and = 4095; - chr_or = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - locked = false; - regCounter = 0; - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (locked) - { - base.WriteSRM(ref address, ref data); - return; - } - switch (regCounter) - { - case 0: - chr_or = (chr_or & 0xFF00) | data; - SetupCHR(); - break; - case 1: - prg_or = data; - SetupPRG(); - break; - case 2: - if ((data & 8) == 8) - { - chr_and = (1 << (data & 7) + 1) - 1; - } - else - { - chr_and = ((data <= 0) ? (-1) : 0); - } - chr_or = (chr_or & 0xFF) | ((data & 0xF0) << 4); - SetupCHR(); - break; - case 3: - locked = (data & 0x40) == 64; - prg_and = (data & 0x3F) ^ 0x3F; - SetupPRG(); - break; - } - regCounter++; - if (regCounter > 3) - { - regCounter = 0; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area0000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area1000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area1400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area1800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area1C00); - } - else - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area1000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area0000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area0400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area0800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG((prg_reg[flag_p ? 2 : 0] & prg_and) | prg_or, PRGArea.Area8000); - Switch08KPRG((prg_reg[1] & prg_and) | prg_or, PRGArea.AreaA000); - Switch08KPRG((prg_reg[(!flag_p) ? 2 : 0] & prg_and) | prg_or, PRGArea.AreaC000); - Switch08KPRG((prg_reg[3] & prg_and) | prg_or, PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(prg_and); - stream.Write(prg_or); - stream.Write(chr_and); - stream.Write(chr_or); - stream.Write(locked); - stream.Write(regCounter); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - prg_and = stream.ReadInt32(); - prg_or = stream.ReadInt32(); - chr_and = stream.ReadInt32(); - chr_or = stream.ReadInt32(); - locked = stream.ReadBoolean(); - regCounter = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper046.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper046.cs deleted file mode 100644 index a80a4b7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper046.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("15-in-1 Color Dreams", 46)] - internal class Mapper046 : Board - { - private int prg_reg; - - private int chr_reg; - - internal override void WriteSRM(ref ushort address, ref byte data) - { - prg_reg = (prg_reg & 1) | ((data << 1) & 0x1E); - chr_reg = (chr_reg & 7) | ((data >> 1) & 0x78); - Switch08KCHR(chr_reg); - Switch32KPRG(prg_reg, PRGArea.Area8000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - prg_reg = (data & 1) | (prg_reg & 0x1E); - chr_reg = ((data >> 4) & 7) | (chr_reg & 0x78); - Switch08KCHR(chr_reg); - Switch32KPRG(prg_reg, PRGArea.Area8000); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_reg); - stream.Write(chr_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_reg = stream.ReadInt32(); - chr_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper047.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper047.cs deleted file mode 100644 index 5e58739..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper047.cs +++ /dev/null @@ -1,258 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("2-in-1 MMC3 Port 6000h", 47, true, true)] - internal class Mapper047 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - private int block; - - private int prg_and; - - private int prg_or; - - private int chr_and; - - private int chr_or; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_and = 15; - prg_or = 0; - chr_and = 127; - chr_or = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (PRG_RAM_ENABLED[PRG_AREA_BLK_INDEX[0]] && PRG_RAM_WRITABLE[PRG_AREA_BLK_INDEX[0]]) - { - block = data & 1; - prg_or = block << 4; - chr_or = block << 7; - SetupCHR(); - SetupPRG(); - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area0000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area1000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area1400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area1800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area1C00); - } - else - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area1000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area0000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area0400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area0800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG((prg_reg[flag_p ? 2 : 0] & prg_and) | prg_or, PRGArea.Area8000); - Switch08KPRG((prg_reg[1] & prg_and) | prg_or, PRGArea.AreaA000); - Switch08KPRG((prg_reg[(!flag_p) ? 2 : 0] & prg_and) | prg_or, PRGArea.AreaC000); - Switch08KPRG((prg_reg[3] & prg_and) | prg_or, PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - stream.Write(block); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(prg_and); - stream.Write(prg_or); - stream.Write(chr_and); - stream.Write(chr_or); - stream.Write(irq_enabled); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - block = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - prg_and = stream.ReadInt32(); - prg_or = stream.ReadInt32(); - chr_and = stream.ReadInt32(); - chr_or = stream.ReadInt32(); - irq_enabled = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper048.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper048.cs deleted file mode 100644 index 6f388cb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper048.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Taito TC0190/TC0350", 48, true, true)] - internal class Mapper048 : Board - { - private bool MODE; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - MODE = false; - if (IsGameFoundOnDB) - { - foreach (string chip in base.Chips) - { - if (chip.Contains("TC0350")) - { - MODE = true; - break; - } - } - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - mmc3_alt_behavior = false; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (!MODE) - { - switch (address & 0xE003) - { - case 32768: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 32769: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 32770: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 32771: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 40960: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 40961: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 40962: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 40963: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 49152: - irq_reload = (byte)(data ^ 0xFFu); - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 49154: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 49155: - irq_enabled = true; - break; - case 57344: - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Horz : Mirroring.Vert); - break; - } - } - else - { - switch (address & 0xA003) - { - case 32768: - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Horz : Mirroring.Vert); - Switch08KPRG(data & 0x3F, PRGArea.Area8000); - break; - case 32769: - Switch08KPRG(data & 0x3F, PRGArea.AreaA000); - break; - case 32770: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 32771: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 40960: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 40961: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 40962: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 40963: - Switch01KCHR(data, CHRArea.Area1C00); - break; - } - } - } - - internal override void OnPPUA12RaisingEdge() - { - if (!MODE) - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper049.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper049.cs deleted file mode 100644 index 8362faf..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper049.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("4-in-1 MMC3 Port 6xxxh", 49, true, true)] - internal class Mapper049 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - private bool prg_32Mode; - - private int prg_32Page; - - private int prg_and; - - private int prg_or; - - private int chr_and; - - private int chr_or; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - prg_32Mode = false; - prg_32Page = 0; - address_8001 = 0; - prg_and = 15; - prg_or = 0; - chr_and = 127; - chr_or = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (PRG_RAM_ENABLED[PRG_AREA_BLK_INDEX[0]] && PRG_RAM_WRITABLE[PRG_AREA_BLK_INDEX[0]]) - { - prg_32Mode = (data & 1) == 1; - prg_or = (data >> 2) & 0x30; - chr_or = (data & 0xC0) << 1; - prg_32Page = (data >> 4) & 3; - SetupCHR(); - SetupPRG(); - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area0000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area1000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area1400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area1800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area1C00); - } - else - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area1000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area0000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area0400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area0800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - if (prg_32Mode) - { - Switch08KPRG((prg_reg[flag_p ? 2 : 0] & prg_and) | prg_or, PRGArea.Area8000); - Switch08KPRG((prg_reg[1] & prg_and) | prg_or, PRGArea.AreaA000); - Switch08KPRG((prg_reg[(!flag_p) ? 2 : 0] & prg_and) | prg_or, PRGArea.AreaC000); - Switch08KPRG((prg_reg[3] & prg_and) | prg_or, PRGArea.AreaE000); - } - else - { - Switch32KPRG(prg_32Page, PRGArea.Area8000); - } - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(prg_and); - stream.Write(prg_or); - stream.Write(chr_and); - stream.Write(chr_or); - stream.Write(prg_32Mode); - stream.Write(prg_32Page); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - prg_and = stream.ReadInt32(); - prg_or = stream.ReadInt32(); - chr_and = stream.ReadInt32(); - chr_or = stream.ReadInt32(); - prg_32Mode = stream.ReadBoolean(); - prg_32Page = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper049.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper049.cs.meta deleted file mode 100644 index 54db8d2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper049.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1e562cabf4561140a8f52fe37210dd3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper050.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper050.cs deleted file mode 100644 index a098600..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper050.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("FDS-Port - Alt. Levels", 50)] - internal class Mapper050 : Board - { - private int prg_page; - - private int irq_counter; - - private bool irq_enabled; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(15, PRGArea.Area6000); - Switch08KPRG(8, PRGArea.Area8000); - Switch08KPRG(9, PRGArea.AreaA000); - Switch08KPRG(11, PRGArea.AreaE000); - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - switch (address & 0x4120) - { - case 16416: - prg_page = (data & 8) | ((data & 1) << 2) | ((data >> 1) & 3); - Switch08KPRG(prg_page, PRGArea.AreaC000); - break; - case 16672: - irq_enabled = (data & 1) == 1; - if (!irq_enabled) - { - irq_counter = 0; - NesEmu.IRQFlags &= -9; - } - break; - } - } - - internal override void OnCPUClock() - { - if (irq_enabled) - { - irq_counter++; - if (irq_counter == 4096) - { - NesEmu.IRQFlags |= 8; - irq_counter = 0; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_page); - stream.Write(irq_counter); - stream.Write(irq_enabled); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_page = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - irq_enabled = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper051.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper051.cs deleted file mode 100644 index 1175a42..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper051.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("11-in-1", 51)] - internal class Mapper051 : Board - { - private int bank; - - private int mode = 1; - - private int offset; - - internal override void HardReset() - { - base.HardReset(); - bank = 0; - mode = 1; - offset = 0; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE000) - { - case 32768: - case 57344: - bank = data & 0xF; - UpdateBanks(); - break; - case 49152: - bank = data & 0xF; - mode = ((data >> 3) & 2) | (mode & 1); - UpdateBanks(); - break; - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - mode = ((data >> 3) & 2) | ((data >> 1) & 1); - UpdateBanks(); - } - - private void UpdateBanks() - { - offset = 0; - if ((mode & 1) == 1) - { - Switch32KPRG(bank, PRGArea.Area8000); - offset = 35; - } - else - { - Switch08KPRG((bank << 1) | (mode >> 1), PRGArea.Area8000); - Switch08KPRG((bank << 1) | 7, PRGArea.Area8000); - offset = 47; - } - Switch08KPRG(offset | (bank << 2), PRGArea.Area6000); - Switch01KNMTFromMirroring((mode == 3) ? Mirroring.Horz : Mirroring.Vert); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(bank); - stream.Write(mode); - stream.Write(offset); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - bank = stream.ReadInt32(); - mode = stream.ReadInt32(); - offset = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper052.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper052.cs deleted file mode 100644 index dc6a7d6..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper052.cs +++ /dev/null @@ -1,273 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("7-in-1 MMC3 Port 6800h with SRAM", 52, true, true)] - internal class Mapper052 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - private int prg_and; - - private int prg_or; - - private int chr_and; - - private int chr_or; - - private bool locked; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - locked = false; - address_8001 = 0; - prg_and = 31; - prg_or = 0; - chr_and = 255; - chr_or = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void SoftReset() - { - HardReset(); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (!locked) - { - if (PRG_RAM_ENABLED[PRG_AREA_BLK_INDEX[0]] && PRG_RAM_WRITABLE[PRG_AREA_BLK_INDEX[0]]) - { - locked = true; - prg_and = ((data << 1) & 0x10) ^ 0x1F; - prg_or = ((data & 6) | ((data >> 3) & data & 1)) << 4; - chr_and = ((data & 0x40) << 1) ^ 0xFF; - chr_or = (((data >> 3) & 4) | ((data >> 1) & 2) | ((data >> 6) & (data >> 4) & 1)) << 7; - SetupCHR(); - SetupPRG(); - } - } - else - { - base.WriteSRM(ref address, ref data); - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area0000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area1000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area1400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area1800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area1C00); - } - else - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area1000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area0000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area0400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area0800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG((prg_reg[flag_p ? 2 : 0] & prg_and) | prg_or, PRGArea.Area8000); - Switch08KPRG((prg_reg[1] & prg_and) | prg_or, PRGArea.AreaA000); - Switch08KPRG((prg_reg[(!flag_p) ? 2 : 0] & prg_and) | prg_or, PRGArea.AreaC000); - Switch08KPRG((prg_reg[3] & prg_and) | prg_or, PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(prg_and); - stream.Write(prg_or); - stream.Write(chr_and); - stream.Write(chr_or); - stream.Write(locked); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - prg_and = stream.ReadInt32(); - prg_or = stream.ReadInt32(); - chr_and = stream.ReadInt32(); - chr_or = stream.ReadInt32(); - locked = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper052.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper052.cs.meta deleted file mode 100644 index 7dca79d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper052.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe5026b8a1bdd5942876adb7451904ff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper053.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper053.cs deleted file mode 100644 index 397be8d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper053.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 53)] - [HassIssues] - internal class Mapper053 : Board - { - private byte[] regs = new byte[2]; - - private bool epromFirst; - - internal override string Issues => MNInterfaceLanguage.IssueMapper53; - - internal override void HardReset() - { - base.HardReset(); - regs = new byte[2]; - epromFirst = true; - Switch08KPRG(0, PRGArea.Area6000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - regs[1] = data; - UpdatePrg(); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - regs[0] = data; - UpdatePrg(); - Switch01KNMTFromMirroring(((data & 0x20) == 32) ? Mirroring.Horz : Mirroring.Vert); - } - - private void UpdatePrg() - { - int num = (regs[0] << 3) & 0x78; - Switch08KPRG(((num << 1) | 0xF) + (epromFirst ? 4 : 0), PRGArea.Area6000); - Switch16KPRG(((regs[0] & 0x10) == 16) ? ((num | (regs[1] & 7)) + (epromFirst ? 2 : 0)) : ((!epromFirst) ? 128 : 0), PRGArea.Area8000); - Switch16KPRG(((regs[0] & 0x10) == 16) ? ((num | 7) + (epromFirst ? 2 : 0)) : (epromFirst ? 1 : 129), PRGArea.AreaC000); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(regs); - stream.Write(epromFirst); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - stream.Read(regs, 0, 2); - epromFirst = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper053.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper053.cs.meta deleted file mode 100644 index 9a603b9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper053.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fa0f9f5e47b4fd64997db593a5a91357 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper056.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper056.cs deleted file mode 100644 index 4de9059..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper056.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Pirate SMB3", 56)] - internal class Mapper056 : Board - { - private int irqCounter; - - private int irqLatch; - - private bool irqEnabled; - - private int irqControl; - - private int switchControl; - - internal override string Issues => MNInterfaceLanguage.IssueMapper56; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - irqLatch = 0; - irqCounter = 0; - irqControl = 0; - irqEnabled = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (address < 61440) - { - switch (address & 0xE000) - { - case 32768: - irqLatch = (irqLatch & 0xFFF0) | (data & 0xF); - break; - case 36864: - irqLatch = (irqLatch & 0xFF0F) | ((data & 0xF) << 4); - break; - case 40960: - irqLatch = (irqLatch & 0xF0FF) | ((data & 0xF) << 8); - break; - case 45056: - irqLatch = (irqLatch & 0xFFF) | ((data & 0xF) << 12); - break; - case 49152: - irqControl = data & 5; - irqEnabled = (data & 2) == 2; - if (irqEnabled) - { - irqCounter = irqLatch; - } - NesEmu.IRQFlags &= -9; - break; - case 53248: - irqEnabled = (irqControl & 1) == 1; - NesEmu.IRQFlags &= -9; - break; - case 57344: - switchControl = data; - break; - } - return; - } - int num = (switchControl & 0xF) - 1; - if (num < 3) - { - Switch08KPRG((data & 0xF) | (PRG_AREA_BLK_INDEX[(num >> 13) + 1] & 0x10), (PRGArea)num); - } - switch (address & 0xC00) - { - case 0: - address &= 3; - if (address < 3) - { - Switch08KPRG((data & 0xF) | (PRG_AREA_BLK_INDEX[(num >> 13) + 1] & 0x10), (PRGArea)address); - } - break; - case 2048: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Vert : Mirroring.Horz); - break; - case 3072: - Switch01KCHR(data, (CHRArea)(address & 7u)); - break; - } - } - - internal override void OnCPUClock() - { - if (irqEnabled && irqCounter++ == 65535) - { - irqCounter = irqLatch; - NesEmu.IRQFlags |= 8; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper056.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper056.cs.meta deleted file mode 100644 index 717ff54..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper056.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83d2f8d6bd1261249ae318f6c67df658 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper057.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper057.cs deleted file mode 100644 index 71e6c7d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper057.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("6-in-1 (SuperGK)", 57)] - internal class Mapper057 : Board - { - private int chr_aaa; - - private int chr_bbb; - - private int chr_hhh; - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0x8800) - { - case 32768: - chr_aaa = data & 7; - chr_hhh = (data & 0x40) >> 3; - break; - case 34816: - chr_bbb = data & 7; - if ((data & 0x10) == 16) - { - Switch32KPRG((data & 0xE0) >> 6, PRGArea.Area8000); - } - else - { - Switch16KPRG((data & 0xE0) >> 5, PRGArea.Area8000); - Switch16KPRG((data & 0xE0) >> 5, PRGArea.AreaC000); - } - Switch01KNMTFromMirroring(((data & 8) == 8) ? Mirroring.Horz : Mirroring.Vert); - break; - } - Switch08KCHR(chr_hhh | (chr_aaa | chr_bbb)); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(chr_aaa); - stream.Write(chr_bbb); - stream.Write(chr_hhh); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - chr_aaa = stream.ReadInt32(); - chr_bbb = stream.ReadInt32(); - chr_hhh = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper058.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper058.cs deleted file mode 100644 index 8291d6c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper058.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("68-in-1 (Game Star)", 58)] - [HassIssues] - internal class Mapper058 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper58; - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR((address >> 3) & 7); - if ((address & 0x40) == 0) - { - Switch32KPRG((address & 7) >> 1, PRGArea.Area8000); - } - else - { - Switch16KPRG(address & 7, PRGArea.Area8000); - Switch16KPRG(address & 7, PRGArea.AreaC000); - } - Switch01KNMTFromMirroring(((address & 0x80) == 128) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper060.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper060.cs deleted file mode 100644 index b3712b3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper060.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 60)] - [HassIssues] - internal class Mapper060 : Board - { - private int latch; - - private byte menu; - - internal override string Issues => MNInterfaceLanguage.IssueMapper60; - - internal override void HardReset() - { - base.HardReset(); - latch = 0; - menu = 0; - } - - internal override void SoftReset() - { - base.SoftReset(); - latch = 0; - menu = (byte)((uint)(menu + 1) & 3u); - Switch08KCHR(menu); - Switch16KPRG(menu, PRGArea.Area8000); - Switch16KPRG(menu, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - latch = address & 0x100; - Switch01KNMTFromMirroring(((address & 8) == 8) ? Mirroring.Horz : Mirroring.Vert); - Switch16KPRG((address >> 4) & ~((~address >> 7) & 1), PRGArea.Area8000); - Switch16KPRG((address >> 4) | ((~address >> 7) & 1), PRGArea.AreaC000); - Switch08KCHR(address); - } - - internal override void ReadPRG(ref ushort address, out byte data) - { - if (latch == 0) - { - base.ReadPRG(ref address, out data); - } - else - { - data = menu; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(latch); - stream.Write(menu); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - latch = stream.ReadInt32(); - menu = stream.ReadByte(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper061.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper061.cs deleted file mode 100644 index ff43e33..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper061.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("20-in-1", 61)] - internal class Mapper061 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - if ((address & 0x10) == 0) - { - Switch32KPRG(address & 0xF, PRGArea.Area8000); - } - else - { - Switch16KPRG(((address & 0xF) << 1) | ((address & 0x20) >> 5), PRGArea.Area8000); - Switch16KPRG(((address & 0xF) << 1) | ((address & 0x20) >> 5), PRGArea.AreaC000); - } - Switch01KNMTFromMirroring(((address & 0x80) == 128) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper062.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper062.cs deleted file mode 100644 index 45fb744..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper062.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Super 700-in-1", 62)] - internal class Mapper062 : Board - { - private int prg_page; - - internal override void WritePRG(ref ushort address, ref byte data) - { - prg_page = ((address & 0x3F00) >> 8) | (address & 0x40); - Switch08KCHR(((address & 0x1F) << 2) | (data & 3)); - if ((address & 0x20) == 32) - { - Switch16KPRG(prg_page, PRGArea.Area8000); - Switch16KPRG(prg_page, PRGArea.AreaC000); - } - else - { - Switch32KPRG(prg_page >> 1, PRGArea.Area8000); - } - Switch01KNMTFromMirroring(((address & 0x80) == 128) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper064.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper064.cs deleted file mode 100644 index b2009b5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper064.cs +++ /dev/null @@ -1,258 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Tengen RAMBO-1", 64, true, true)] - internal class Mapper064 : Board - { - private bool flag_c; - - private bool flag_p; - - private bool flag_k; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private byte irq_reload; - - private bool irq_mode; - - private bool irq_clear; - - private int irq_prescaler; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = (flag_k = false)); - address_8001 = 0; - prg_reg = new int[3]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = 2; - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - SetupPRG(); - chr_reg = new int[8]; - for (int i = 0; i < 8; i++) - { - chr_reg[i] = i; - } - SetupCHR(); - irq_enabled = false; - irq_counter = 0; - irq_prescaler = 0; - irq_mode = false; - irq_reload = byte.MaxValue; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 0xF; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - flag_k = (data & 0x20) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data; - SetupPRG(); - break; - case 8: - chr_reg[6] = data; - SetupCHR(); - break; - case 9: - chr_reg[7] = data; - SetupCHR(); - break; - case 15: - prg_reg[2] = data; - SetupPRG(); - break; - case 10: - case 11: - case 12: - case 13: - case 14: - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 49152: - irq_reload = data; - break; - case 49153: - irq_mode = (data & 1) == 1; - irq_clear = true; - irq_prescaler = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - if (!flag_k) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - } - else - { - Switch01KCHR(chr_reg[0], CHRArea.Area0000); - Switch01KCHR(chr_reg[6], CHRArea.Area0400); - Switch01KCHR(chr_reg[1], CHRArea.Area0800); - Switch01KCHR(chr_reg[7], CHRArea.Area0C00); - } - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - if (!flag_k) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - } - else - { - Switch01KCHR(chr_reg[0], CHRArea.Area1000); - Switch01KCHR(chr_reg[6], CHRArea.Area1400); - Switch01KCHR(chr_reg[1], CHRArea.Area1800); - Switch01KCHR(chr_reg[7], CHRArea.Area1C00); - } - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[(!flag_p) ? 1u : 0u], PRGArea.AreaA000); - Switch08KPRG(prg_reg[flag_p ? 1 : 2], PRGArea.AreaC000); - } - - internal override void OnPPUA12RaisingEdge() - { - ClockIRQ(); - } - - internal override void OnCPUClock() - { - if (irq_mode) - { - irq_prescaler++; - if (irq_prescaler == 4) - { - irq_prescaler = 0; - ClockIRQ(); - } - } - } - - private void ClockIRQ() - { - if (irq_clear) - { - irq_counter = (byte)(irq_reload + 1); - irq_clear = false; - } - else if (irq_counter == 0) - { - irq_counter = irq_reload; - } - else if (--irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(irq_prescaler); - stream.Write(irq_mode); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - irq_prescaler = stream.ReadInt32(); - irq_mode = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper065.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper065.cs deleted file mode 100644 index 2bf8579..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper065.cs +++ /dev/null @@ -1,94 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Irem H-3001", 65)] - internal class Mapper065 : Board - { - private bool irq_enable; - - private int irq_reload; - - private int irq_counter; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(0, PRGArea.Area8000); - Switch08KPRG(1, PRGArea.AreaA000); - Switch08KPRG(254, PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 36865: - Switch01KNMTFromMirroring(((data & 0x80) == 128) ? Mirroring.Horz : Mirroring.Vert); - break; - case 36867: - irq_enable = (data & 0x80) == 128; - NesEmu.IRQFlags &= -9; - break; - case 36868: - irq_counter = irq_reload; - NesEmu.IRQFlags &= -9; - break; - case 36869: - irq_reload = (irq_reload & 0xFF) | (data << 8); - break; - case 36870: - irq_reload = (irq_reload & 0xFF00) | data; - break; - case 40960: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 49152: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 45056: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 45057: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 45058: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 45059: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 45060: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 45061: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 45062: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 45063: - Switch01KCHR(data, CHRArea.Area1C00); - break; - } - } - - internal override void OnCPUClock() - { - if (irq_enable) - { - if (irq_counter > 0) - { - irq_counter--; - } - else if (irq_counter == 0) - { - irq_counter = -1; - NesEmu.IRQFlags |= 8; - } - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper066.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper066.cs deleted file mode 100644 index 19fc02e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper066.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("GxROM", 66)] - internal class Mapper066 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch32KPRG((data >> 4) & 3, PRGArea.Area8000); - Switch08KCHR(data & 3); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper067.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper067.cs deleted file mode 100644 index 79f2618..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper067.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Sunsoft 3", 67)] - internal class Mapper067 : Board - { - private bool irq_enabled; - - private int irq_counter; - - private bool odd; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - irq_enabled = false; - irq_counter = 65535; - odd = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF800) - { - case 34816: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 38912: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 43008: - Switch02KCHR(data, CHRArea.Area1000); - break; - case 47104: - Switch02KCHR(data, CHRArea.Area1800); - break; - case 51200: - if (!odd) - { - irq_counter = (irq_counter & 0xFF) | (data << 8); - } - else - { - irq_counter = (irq_counter & 0xFF00) | data; - } - odd = !odd; - break; - case 55296: - irq_enabled = (data & 0x10) == 16; - odd = false; - NesEmu.IRQFlags &= -9; - break; - case 59392: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 63488: - Switch16KPRG(data, PRGArea.Area8000); - break; - } - } - - internal override void OnCPUClock() - { - if (irq_enabled) - { - irq_counter--; - if (irq_counter == 0) - { - irq_counter = 65535; - NesEmu.IRQFlags |= 8; - irq_enabled = false; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(odd); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadInt32(); - odd = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper068.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper068.cs deleted file mode 100644 index 5994a85..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper068.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Sunsoft 4", 68)] - internal class Mapper068 : Board - { - private bool flag_r; - - private bool flag_m; - - private int nt_reg0; - - private int nt_reg1; - - private int temp; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF000) - { - case 32768: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 36864: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 40960: - Switch02KCHR(data, CHRArea.Area1000); - break; - case 45056: - Switch02KCHR(data, CHRArea.Area1800); - break; - case 49152: - nt_reg0 = (data & 0x7F) | 0x80; - break; - case 53248: - nt_reg1 = (data & 0x7F) | 0x80; - break; - case 57344: - flag_r = (data & 0x10) == 16; - flag_m = (data & 1) == 1; - Switch01KNMTFromMirroring(flag_m ? Mirroring.Horz : Mirroring.Vert); - break; - case 61440: - Switch16KPRG(data, PRGArea.Area8000); - break; - } - } - - internal override void ReadNMT(ref ushort address, out byte data) - { - if (!flag_r) - { - data = NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF]; - return; - } - switch ((address >> 10) & 3) - { - case 0: - data = CHR_ROM[nt_reg0][address & 0x3FF]; - break; - case 1: - data = CHR_ROM[flag_m ? nt_reg0 : nt_reg1][address & 0x3FF]; - break; - case 2: - data = CHR_ROM[flag_m ? nt_reg1 : nt_reg0][address & 0x3FF]; - break; - case 3: - data = CHR_ROM[nt_reg1][address & 0x3FF]; - break; - default: - data = 0; - break; - } - } - - internal override void WriteNMT(ref ushort address, ref byte data) - { - if (!flag_r) - { - base.WriteNMT(ref address, ref data); - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_r); - stream.Write(flag_m); - stream.Write(nt_reg0); - stream.Write(nt_reg1); - stream.Write(temp); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_r = stream.ReadBoolean(); - flag_m = stream.ReadBoolean(); - nt_reg0 = stream.ReadInt32(); - nt_reg1 = stream.ReadInt32(); - temp = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper069.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper069.cs deleted file mode 100644 index caa5957..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper069.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("FME-7/Sunsoft 5B", 69)] - [WithExternalSound] - internal class Mapper069 : Board - { - private int address_A000; - - private int address_E000; - - private int irq_counter; - - private bool irq_count_enabled; - - private bool irq_trigger_enabled; - - private Sunsoft5BChnl snd_1; - - private Sunsoft5BChnl snd_2; - - private Sunsoft5BChnl snd_3; - - private double[] audio_pulse_table; - - private double[] audio_tnd_table; - - internal override void Initialize(IRom rom) - { - base.Initialize(rom); - snd_1 = new Sunsoft5BChnl(); - snd_2 = new Sunsoft5BChnl(); - snd_3 = new Sunsoft5BChnl(); - audio_pulse_table = new double[32]; - for (int i = 0; i < 32; i++) - { - audio_pulse_table[i] = 95.52 / (8128.0 / (double)i + 100.0); - } - audio_tnd_table = new double[204]; - for (int j = 0; j < 204; j++) - { - audio_tnd_table[j] = 163.67 / (24329.0 / (double)j + 100.0); - } - } - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - address_A000 = 0; - irq_counter = 65535; - irq_count_enabled = false; - irq_trigger_enabled = false; - APUApplyChannelsSettings(); - snd_1.HardReset(); - snd_2.HardReset(); - snd_3.HardReset(); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE000) - { - case 32768: - address_A000 = data & 0xF; - break; - case 40960: - switch (address_A000) - { - case 0: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 1: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 2: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 3: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 4: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 5: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 6: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 7: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 8: - TogglePRGRAMEnable((data & 0x80) == 128); - if ((data & 0x40u) != 0) - { - Toggle08KPRG_RAM(ram: true, PRGArea.Area6000); - Switch08KPRG(data & 0x3F & PRG_RAM_08KB_Mask, PRGArea.Area6000); - } - else - { - Toggle08KPRG_RAM(ram: false, PRGArea.Area6000); - Switch08KPRG(data & 0x3F, PRGArea.Area6000); - } - break; - case 9: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 10: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 11: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 12: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 13: - irq_count_enabled = (data & 0x80) == 128; - irq_trigger_enabled = (data & 1) == 1; - if (!irq_trigger_enabled) - { - NesEmu.IRQFlags &= -9; - } - break; - case 14: - irq_counter = (irq_counter & 0xFF00) | data; - break; - case 15: - irq_counter = (irq_counter & 0xFF) | (data << 8); - break; - } - break; - case 49152: - address_E000 = data & 0xF; - break; - case 57344: - switch (address_E000) - { - case 0: - snd_1.Write0(ref data); - break; - case 1: - snd_1.Write1(ref data); - break; - case 2: - snd_2.Write0(ref data); - break; - case 3: - snd_2.Write1(ref data); - break; - case 4: - snd_3.Write0(ref data); - break; - case 5: - snd_3.Write1(ref data); - break; - case 7: - snd_1.Enabled = (data & 1) == 0; - snd_2.Enabled = (data & 2) == 0; - snd_3.Enabled = (data & 4) == 0; - break; - case 8: - snd_1.Volume = (byte)(data & 0xFu); - break; - case 9: - snd_2.Volume = (byte)(data & 0xFu); - break; - case 10: - snd_3.Volume = (byte)(data & 0xFu); - break; - case 6: - break; - } - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_count_enabled) - { - return; - } - irq_counter--; - if (irq_counter <= 0) - { - irq_counter = 65535; - if (irq_trigger_enabled) - { - NesEmu.IRQFlags |= 8; - } - } - } - - internal override double APUGetSample() - { - return audio_pulse_table[snd_1.output + snd_2.output] + audio_tnd_table[snd_3.output]; - } - - internal override void OnAPUClockSingle() - { - base.OnAPUClockSingle(); - snd_1.ClockSingle(); - snd_2.ClockSingle(); - snd_3.ClockSingle(); - } - - internal override void APUApplyChannelsSettings() - { - base.APUApplyChannelsSettings(); - snd_1.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_SUN1; - snd_2.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_SUN2; - snd_3.Outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_SUN3; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(address_A000); - stream.Write(address_E000); - stream.Write(irq_counter); - stream.Write(irq_count_enabled); - stream.Write(irq_trigger_enabled); - snd_1.SaveState(ref stream); - snd_2.SaveState(ref stream); - snd_3.SaveState(ref stream); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - address_A000 = stream.ReadInt32(); - address_E000 = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - irq_count_enabled = stream.ReadBoolean(); - irq_trigger_enabled = stream.ReadBoolean(); - snd_1.LoadState(ref stream); - snd_2.LoadState(ref stream); - snd_3.LoadState(ref stream); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper070.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper070.cs deleted file mode 100644 index da6311a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper070.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Bandai", 70)] - internal class Mapper070 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG((data >> 4) & 0xF, PRGArea.Area8000); - Switch08KCHR(data & 0xF); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper071.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper071.cs deleted file mode 100644 index 3948adf..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper071.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Camerica", 71)] - internal class Mapper071 : Board - { - private bool fireHawk; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - fireHawk = SHA1.ToUpper() == "334781C830F135CF30A33E392D8AAA4AFDC223F9"; - } - - internal override void WritePRG(ref ushort addr, ref byte val) - { - if (addr < 40960) - { - if (fireHawk) - { - Switch01KNMTFromMirroring(((val & 0x10) == 16) ? Mirroring.OneScB : Mirroring.OneScA); - } - } - else if (addr >= 49152) - { - Switch16KPRG(val, PRGArea.Area8000); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper072.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper072.cs deleted file mode 100644 index 9c9200f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper072.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Jaleco Early Mapper 0", 72)] - internal class Mapper072 : Board - { - private byte writeData; - - private int chr_reg; - - private int prg_reg; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - writeData = 0; - chr_reg = (prg_reg = 0); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch ((data >> 6) & 3) - { - case 0: - Switch08KCHR(chr_reg); - Switch16KPRG(prg_reg, PRGArea.Area8000); - break; - case 1: - chr_reg = data & 0xF; - break; - case 2: - prg_reg = data & 0xF; - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(chr_reg); - stream.Write(prg_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - chr_reg = stream.ReadInt32(); - prg_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper073.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper073.cs deleted file mode 100644 index 7d5663d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper073.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC3", 73)] - internal class Mapper073 : Board - { - private bool irq_mode_8; - - private bool irq_enable; - - private bool irq_enable_on_ak; - - private int irq_reload; - - private int irq_counter; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - irq_mode_8 = false; - irq_enable = false; - irq_enable_on_ak = false; - irq_reload = 0; - irq_counter = 0; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF000) - { - case 32768: - irq_reload = (irq_reload & 0xFFF0) | (data & 0xF); - break; - case 36864: - irq_reload = (irq_reload & 0xFF0F) | ((data & 0xF) << 4); - break; - case 40960: - irq_reload = (irq_reload & 0xF0FF) | ((data & 0xF) << 8); - break; - case 45056: - irq_reload = (irq_reload & 0xFFF) | ((data & 0xF) << 12); - break; - case 49152: - irq_mode_8 = (data & 4) == 4; - irq_enable = (data & 2) == 2; - irq_enable_on_ak = (data & 1) == 1; - if (irq_enable) - { - irq_counter = irq_reload; - } - NesEmu.IRQFlags &= -9; - break; - case 53248: - irq_enable = irq_enable_on_ak; - NesEmu.IRQFlags &= -9; - break; - case 61440: - Switch16KPRG(data & 0xF, PRGArea.Area8000); - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_enable) - { - return; - } - if (irq_mode_8) - { - irq_counter = (irq_counter & 0xFF00) | (byte)((irq_counter & 0xFF) + 1); - if ((byte)(irq_counter & 0xFF) == byte.MaxValue) - { - NesEmu.IRQFlags |= 8; - irq_counter = (irq_counter & 0xFF00) | (irq_reload & 0xFF); - } - } - else - { - irq_counter++; - if (irq_counter == 65535) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_mode_8); - stream.Write(irq_enable); - stream.Write(irq_enable_on_ak); - stream.Write(irq_reload); - stream.Write(irq_counter); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_mode_8 = stream.ReadBoolean(); - irq_enable = stream.ReadBoolean(); - irq_enable_on_ak = stream.ReadBoolean(); - irq_reload = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper074.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper074.cs deleted file mode 100644 index 17e5166..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper074.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Pirate MMC3 variant", 74, true, true)] - internal class Mapper074 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Toggle02KCHR_RAM(chr_reg[0] != 8 && chr_reg[0] != 9, CHRArea.Area0000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Toggle02KCHR_RAM(chr_reg[1] != 8 && chr_reg[1] != 9, CHRArea.Area0800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Toggle02KCHR_RAM(chr_reg[2] != 8 && chr_reg[2] != 9, CHRArea.Area1000); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Toggle02KCHR_RAM(chr_reg[3] != 8 && chr_reg[3] != 9, CHRArea.Area1400); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Toggle02KCHR_RAM(chr_reg[4] != 8 && chr_reg[4] != 9, CHRArea.Area1800); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Toggle02KCHR_RAM(chr_reg[5] != 8 && chr_reg[5] != 9, CHRArea.Area1C00); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Toggle02KCHR_RAM(chr_reg[0] != 8 && chr_reg[0] != 9, CHRArea.Area1000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Toggle02KCHR_RAM(chr_reg[1] != 8 && chr_reg[1] != 9, CHRArea.Area1800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Toggle02KCHR_RAM(chr_reg[2] != 8 && chr_reg[2] != 9, CHRArea.Area0000); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Toggle02KCHR_RAM(chr_reg[3] != 8 && chr_reg[3] != 9, CHRArea.Area0400); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Toggle02KCHR_RAM(chr_reg[4] != 8 && chr_reg[4] != 9, CHRArea.Area0800); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Toggle02KCHR_RAM(chr_reg[5] != 8 && chr_reg[5] != 9, CHRArea.Area0C00); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper075.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper075.cs deleted file mode 100644 index c9fb54e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper075.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC1", 75)] - internal class Mapper075 : Board - { - private int chr0_reg; - - private int chr1_reg; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF000) - { - case 32768: - Switch08KPRG(data & 0xF, PRGArea.Area8000); - break; - case 40960: - Switch08KPRG(data & 0xF, PRGArea.AreaA000); - break; - case 49152: - Switch08KPRG(data & 0xF, PRGArea.AreaC000); - break; - case 36864: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - chr0_reg = (chr0_reg & 0xF) | ((data & 2) << 3); - Switch04KCHR(chr0_reg, CHRArea.Area0000); - chr1_reg = (chr1_reg & 0xF) | ((data & 4) << 2); - Switch04KCHR(chr1_reg, CHRArea.Area1000); - break; - case 57344: - chr0_reg = (chr0_reg & 0x10) | (data & 0xF); - Switch04KCHR(chr0_reg, CHRArea.Area0000); - break; - case 61440: - chr1_reg = (chr1_reg & 0x10) | (data & 0xF); - Switch04KCHR(chr1_reg, CHRArea.Area1000); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(chr0_reg); - stream.Write(chr1_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - chr0_reg = stream.ReadInt32(); - chr1_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs deleted file mode 100644 index 296ecee..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Namco 109", 76)] - internal class Mapper076 : Board - { - private int address_8001; - - private bool prg_a; - - private byte prg_reg; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask - 1, PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - address_8001 = 0; - prg_a = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - prg_a = (data & 0x40) == 64; - Switch08KPRG(prg_reg, prg_a ? PRGArea.AreaC000 : PRGArea.Area8000); - break; - case 32769: - switch (address_8001) - { - case 2: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 3: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 4: - Switch02KCHR(data, CHRArea.Area1000); - break; - case 5: - Switch02KCHR(data, CHRArea.Area1800); - break; - case 6: - Switch08KPRG(prg_reg = data, prg_a ? PRGArea.AreaC000 : PRGArea.Area8000); - break; - case 7: - Switch08KPRG(data, PRGArea.AreaA000); - break; - } - break; - case 40960: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(address_8001); - stream.Write(prg_a); - stream.Write(prg_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - address_8001 = stream.ReadInt32(); - prg_a = stream.ReadBoolean(); - prg_reg = stream.ReadByte(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper077.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper077.cs deleted file mode 100644 index f4c462b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper077.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Irem", 77)] - internal class Mapper077 : Board - { - internal override void HardReset() - { - base.HardReset(); - Toggle02KCHR_RAM(ram: true, CHRArea.Area0800); - Switch02KCHR(0, CHRArea.Area0800); - Toggle02KCHR_RAM(ram: true, CHRArea.Area1000); - Switch02KCHR(1, CHRArea.Area1000); - Toggle02KCHR_RAM(ram: true, CHRArea.Area1800); - Switch02KCHR(2, CHRArea.Area1800); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch02KCHR((data >> 4) & 0xF, CHRArea.Area0000); - Switch32KPRG(data & 0xF, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper078.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper078.cs deleted file mode 100644 index a40db2b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper078.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Irem 74HC161/32", 78)] - internal class Mapper078 : Board - { - private bool mirroring_mode_single; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - mirroring_mode_single = false; - if (base.BoardType == "JALECO-JF-16") - { - mirroring_mode_single = true; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR((data >> 4) & 0xF); - Switch16KPRG(data & 7, PRGArea.Area8000); - if (mirroring_mode_single) - { - Switch01KNMTFromMirroring(((data & 8) == 8) ? Mirroring.OneScB : Mirroring.OneScA); - } - else - { - Switch01KNMTFromMirroring(((data & 8) == 8) ? Mirroring.Vert : Mirroring.Horz); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper079.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper079.cs deleted file mode 100644 index f38a3fb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper079.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("AVE Nina-3", 79)] - internal class Mapper079 : Board - { - internal override void WriteEX(ref ushort address, ref byte data) - { - if ((address ^ 0x4100) == 0) - { - Switch32KPRG((data >> 3) & 7, PRGArea.Area8000); - Switch08KCHR((data & 7) | ((data >> 3) & 8)); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper080.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper080.cs deleted file mode 100644 index c7c1ff6..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper080.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Taito X-005", 80)] - internal class Mapper080 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (address) - { - case 32496: - Switch02KCHR(data >> 1, CHRArea.Area0000); - break; - case 32497: - Switch02KCHR(data >> 1, CHRArea.Area0800); - break; - case 32498: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 32499: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 32500: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 32501: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 32502: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Vert : Mirroring.Horz); - break; - case 32506: - case 32507: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 32508: - case 32509: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 32510: - case 32511: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 32503: - case 32504: - case 32505: - break; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper082.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper082.cs deleted file mode 100644 index dfb1565..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper082.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Taito X1-17 ", 82)] - internal class Mapper082 : Board - { - private bool chr_mode; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (address) - { - case 32496: - Switch02KCHR(data >> 1, chr_mode ? CHRArea.Area1000 : CHRArea.Area0000); - break; - case 32497: - Switch02KCHR(data >> 1, chr_mode ? CHRArea.Area1800 : CHRArea.Area0800); - break; - case 32498: - Switch01KCHR(data, (!chr_mode) ? CHRArea.Area1000 : CHRArea.Area0000); - break; - case 32499: - Switch01KCHR(data, chr_mode ? CHRArea.Area0400 : CHRArea.Area1400); - break; - case 32500: - Switch01KCHR(data, chr_mode ? CHRArea.Area0800 : CHRArea.Area1800); - break; - case 32501: - Switch01KCHR(data, chr_mode ? CHRArea.Area0C00 : CHRArea.Area1C00); - break; - case 32502: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Vert : Mirroring.Horz); - chr_mode = (data & 2) == 2; - break; - case 32506: - Switch08KPRG(data >> 2, PRGArea.Area8000); - break; - case 32507: - Switch08KPRG(data >> 2, PRGArea.AreaA000); - break; - case 32508: - Switch08KPRG(data >> 2, PRGArea.AreaC000); - break; - case 32503: - case 32504: - case 32505: - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(chr_mode); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - chr_mode = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper085.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper085.cs deleted file mode 100644 index 9710354..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper085.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("VRC7", 85)] - [HassIssues] - internal class Mapper085 : Board - { - private int irq_reload; - - private int irq_counter; - - private int prescaler; - - private bool irq_mode_cycle; - - private bool irq_enable; - - private bool irq_enable_on_ak; - - internal override string Issues => MNInterfaceLanguage.IssueMapper85; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - irq_reload = 0; - prescaler = 341; - irq_counter = 0; - irq_mode_cycle = false; - irq_enable = false; - irq_enable_on_ak = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address) - { - case 32768: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 32776: - case 32784: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 36864: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 40960: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 40968: - case 40976: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 45056: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 45064: - case 45072: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 49152: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 49160: - case 49168: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 53248: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 53256: - case 53264: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 57344: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 57352: - case 57360: - irq_reload = data; - break; - case 61440: - irq_mode_cycle = (data & 4) == 4; - irq_enable = (data & 2) == 2; - irq_enable_on_ak = (data & 1) == 1; - if (irq_enable) - { - irq_counter = irq_reload; - prescaler = 341; - } - NesEmu.IRQFlags &= -9; - break; - case 61448: - case 61456: - NesEmu.IRQFlags &= -9; - irq_enable = irq_enable_on_ak; - break; - } - } - - internal override void OnCPUClock() - { - if (!irq_enable) - { - return; - } - if (!irq_mode_cycle) - { - if (prescaler > 0) - { - prescaler -= 3; - return; - } - prescaler = 341; - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - else - { - irq_counter++; - if (irq_counter == 255) - { - NesEmu.IRQFlags |= 8; - irq_counter = irq_reload; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prescaler); - stream.Write(irq_counter); - stream.Write(irq_mode_cycle); - stream.Write(irq_reload); - stream.Write(irq_enable); - stream.Write(irq_enable_on_ak); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prescaler = stream.ReadInt32(); - irq_counter = stream.ReadInt32(); - irq_mode_cycle = stream.ReadBoolean(); - irq_reload = stream.ReadInt32(); - irq_enable = stream.ReadBoolean(); - irq_enable_on_ak = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper086.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper086.cs deleted file mode 100644 index 428d741..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper086.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Jaleco Early Mapper 2", 86)] - internal class Mapper086 : Board - { - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (address < 28672) - { - Switch32KPRG((data >> 4) & 3, PRGArea.Area8000); - Switch08KCHR((data & 7) | ((data >> 4) & 4)); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper087.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper087.cs deleted file mode 100644 index 373af2e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper087.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Jaleco/Konami", 87)] - internal class Mapper087 : Board - { - internal override void WriteSRM(ref ushort address, ref byte data) - { - Switch08KCHR(((data & 2) >> 1) | ((data & 1) << 1)); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper088.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper088.cs deleted file mode 100644 index ec887ab..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper088.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Namco 118", 88)] - internal class Mapper088 : Board - { - private int address_8001; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0x8001) - { - case 32768: - address_8001 = data & 7; - break; - case 32769: - switch (address_8001) - { - case 0: - Switch02KCHR((data & 0x3F) >> 1, CHRArea.Area0000); - break; - case 1: - Switch02KCHR((data & 0x3F) >> 1, CHRArea.Area0800); - break; - case 2: - Switch01KCHR(data | 0x40, CHRArea.Area1000); - break; - case 3: - Switch01KCHR(data | 0x40, CHRArea.Area1400); - break; - case 4: - Switch01KCHR(data | 0x40, CHRArea.Area1800); - break; - case 5: - Switch01KCHR(data | 0x40, CHRArea.Area1C00); - break; - case 6: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 7: - Switch08KPRG(data, PRGArea.AreaA000); - break; - } - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(address_8001); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - address_8001 = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper089.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper089.cs deleted file mode 100644 index 03609cb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper089.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Sunsoft Early", 89)] - internal class Mapper089 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR((data & 7) | ((data >> 4) & 8)); - Switch16KPRG((data >> 4) & 7, PRGArea.Area8000); - Switch01KNMTFromMirroring(((data & 8) == 8) ? Mirroring.OneScB : Mirroring.OneScA); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper090.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper090.cs deleted file mode 100644 index ee11031..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper090.cs +++ /dev/null @@ -1,634 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Pirate MMC5-style", 90)] - [HassIssues] - internal class Mapper090 : Board - { - protected bool MAPPER90MODE; - - private int[] prg_reg; - - private int[] chr_reg; - - private int[] nt_reg; - - private int prg_mode; - - private int chr_mode; - - private bool chr_block_mode; - - private int chr_block; - - private bool chr_m; - - private bool flag_s; - - private int irqCounter; - - private bool IrqEnable; - - private bool irqCountDownMode; - - private bool irqCountUpMode; - - private bool irqFunkyMode; - - private bool irqPrescalerSize; - - private int irqSource; - - private int irqPrescaler; - - private int irqPrescalerXOR; - - private byte irqFunkyModeReg; - - private byte Dipswitch; - - private byte multiplication_a; - - private byte multiplication_b; - - private ushort multiplication; - - private byte RAM5803; - - private bool nt_advanced_enable; - - private bool nt_rom_only; - - private int nt_ram_select; - - internal override string Issues => MNInterfaceLanguage.IssueMapper90; - - internal override void HardReset() - { - base.HardReset(); - MAPPER90MODE = true; - prg_reg = new int[4]; - chr_reg = new int[8]; - nt_reg = new int[4]; - prg_mode = (chr_mode = 0); - for (int i = 0; i < 4; i++) - { - prg_reg[i] = i; - nt_reg[i] = i; - } - for (int j = 0; j < 8; j++) - { - chr_reg[j] = j; - } - SetupPRG(); - SetupCHR(); - Dipswitch = 0; - irqCounter = 0; - IrqEnable = false; - irqCountDownMode = false; - irqCountUpMode = false; - irqFunkyMode = false; - irqPrescalerSize = false; - irqSource = 0; - irqPrescaler = 0; - irqPrescalerXOR = 0; - irqFunkyModeReg = 0; - RAM5803 = 0; - flag_s = false; - multiplication_a = 0; - multiplication_b = 0; - multiplication = 0; - } - - internal override void SoftReset() - { - base.SoftReset(); - if (Dipswitch == 0) - { - Dipswitch = byte.MaxValue; - } - else - { - Dipswitch = 0; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF007) - { - case 32768: - case 32769: - case 32770: - case 32771: - case 32772: - case 32773: - case 32774: - case 32775: - prg_reg[address & 3] = data & 0x7F; - SetupPRG(); - break; - case 36864: - case 36865: - case 36866: - case 36867: - case 36868: - case 36869: - case 36870: - case 36871: - chr_reg[address & 7] = (chr_reg[address & 7] & 0xFF00) | data; - SetupCHR(); - break; - case 40960: - case 40961: - case 40962: - case 40963: - case 40964: - case 40965: - case 40966: - case 40967: - chr_reg[address & 7] = (chr_reg[address & 7] & 0xFF) | (data << 8); - SetupCHR(); - break; - case 45056: - case 45057: - case 45058: - case 45059: - nt_reg[address & 3] = (nt_reg[address & 3] & 0xFF00) | data; - break; - case 45060: - case 45061: - case 45062: - case 45063: - nt_reg[address & 3] = (nt_reg[address & 3] & 0xFF) | (data << 8); - break; - case 49152: - IrqEnable = (data & 1) == 1; - if (!IrqEnable) - { - NesEmu.IRQFlags &= -9; - } - break; - case 49153: - irqCountDownMode = (data & 0x80) == 128; - irqCountUpMode = (data & 0x40) == 64; - irqFunkyMode = (data & 8) == 8; - irqPrescalerSize = (data & 4) == 4; - irqSource = data & 3; - break; - case 49154: - IrqEnable = false; - NesEmu.IRQFlags &= -9; - break; - case 49155: - IrqEnable = true; - break; - case 49156: - irqPrescaler = data ^ irqPrescalerXOR; - break; - case 49157: - irqCounter = data ^ irqPrescalerXOR; - break; - case 49158: - irqPrescalerXOR = data; - break; - case 49159: - irqFunkyModeReg = data; - break; - case 53248: - flag_s = (data & 0x80) == 128; - prg_mode = data & 7; - chr_mode = (data >> 3) & 3; - nt_advanced_enable = (data & 0x20) == 32; - nt_rom_only = (data & 0x40) == 64; - SetupPRG(); - SetupCHR(); - break; - case 53249: - switch (data & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 53250: - nt_ram_select = data & 0x80; - break; - case 53251: - chr_m = (data & 0x80) == 128; - chr_block_mode = (data & 0x20) == 32; - chr_block = (data & 0x1F) << 8; - SetupCHR(); - break; - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - } - - internal override void ReadSRM(ref ushort address, out byte data) - { - if (flag_s) - { - base.ReadSRM(ref address, out data); - } - else - { - data = 0; - } - } - - internal override void ReadEX(ref ushort address, out byte data) - { - switch (address) - { - case 20480: - data = Dipswitch; - break; - case 22528: - data = (byte)(multiplication & 0xFFu); - break; - case 22529: - data = (byte)((multiplication & 0xFF00) >> 8); - break; - case 22531: - data = RAM5803; - break; - default: - data = 0; - break; - } - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - switch (address) - { - case 22528: - multiplication_a = data; - multiplication = (ushort)(multiplication_a * multiplication_b); - break; - case 22529: - multiplication_b = data; - multiplication = (ushort)(multiplication_a * multiplication_b); - break; - case 22531: - RAM5803 = data; - break; - case 22530: - break; - } - } - - internal override void ReadNMT(ref ushort address, out byte data) - { - if (MAPPER90MODE) - { - data = NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF]; - } - if (!nt_advanced_enable) - { - data = NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF]; - } - else if (nt_rom_only) - { - data = CHR_ROM[nt_reg[(address >> 10) & 3]][address & 0x3FF]; - } - else if ((nt_reg[(address >> 10) & 3] & 0x80) != nt_ram_select) - { - data = CHR_ROM[nt_reg[(address >> 10) & 3]][address & 0x3FF]; - } - else - { - data = NMT_RAM[nt_reg[(address >> 10) & 3] & 1][address & 0x3FF]; - } - } - - internal override void WriteNMT(ref ushort address, ref byte data) - { - if (MAPPER90MODE) - { - NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF] = data; - } - else if (!nt_advanced_enable) - { - NMT_RAM[NMT_AREA_BLK_INDEX[(address >> 10) & 3]][address & 0x3FF] = data; - } - else if (!nt_rom_only && (nt_reg[(address >> 10) & 3] & 0x80) == nt_ram_select) - { - NMT_RAM[nt_reg[(address >> 10) & 3] & 1][address & 0x3FF] = data; - } - } - - private void SetupPRG() - { - switch (prg_mode) - { - case 0: - Switch08KPRG(prg_reg[3] * 4 + 3, PRGArea.Area6000); - Switch32KPRG(PRG_ROM_32KB_Mask, PRGArea.Area8000); - break; - case 1: - Switch08KPRG(prg_reg[3] * 2 + 1, PRGArea.Area6000); - Switch16KPRG(prg_reg[1], PRGArea.Area8000); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - break; - case 2: - Switch08KPRG(prg_reg[3], PRGArea.Area6000); - Switch08KPRG(prg_reg[0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[2], PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - break; - case 3: - Switch08KPRG(ReverseByte(prg_reg[3]), PRGArea.Area6000); - Switch08KPRG(ReverseByte(prg_reg[0]), PRGArea.Area8000); - Switch08KPRG(ReverseByte(prg_reg[1]), PRGArea.AreaA000); - Switch08KPRG(ReverseByte(prg_reg[2]), PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaE000); - break; - case 4: - Switch08KPRG(prg_reg[3] * 4 + 3, PRGArea.Area6000); - Switch32KPRG(prg_reg[3], PRGArea.Area8000); - break; - case 5: - Switch08KPRG(prg_reg[3] * 2 + 1, PRGArea.Area6000); - Switch16KPRG(prg_reg[1], PRGArea.Area8000); - Switch16KPRG(prg_reg[3], PRGArea.AreaC000); - break; - case 6: - Switch08KPRG(prg_reg[3], PRGArea.Area6000); - Switch08KPRG(prg_reg[0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[2], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - break; - case 7: - Switch08KPRG(ReverseByte(prg_reg[3]), PRGArea.Area6000); - Switch08KPRG(ReverseByte(prg_reg[0]), PRGArea.Area8000); - Switch08KPRG(ReverseByte(prg_reg[1]), PRGArea.AreaA000); - Switch08KPRG(ReverseByte(prg_reg[2]), PRGArea.AreaC000); - Switch08KPRG(ReverseByte(prg_reg[3]), PRGArea.AreaE000); - break; - } - } - - private void SetupCHR() - { - switch (chr_mode) - { - case 0: - if (chr_block_mode) - { - Switch08KCHR(chr_reg[0]); - } - else - { - Switch08KCHR((chr_reg[0] & 0xFF) | chr_block); - } - break; - case 1: - if (chr_block_mode) - { - Switch04KCHR(chr_reg[0], CHRArea.Area0000); - Switch04KCHR(chr_reg[4], CHRArea.Area1000); - } - else - { - Switch04KCHR((chr_reg[0] & 0xFF) | chr_block, CHRArea.Area0000); - Switch04KCHR((chr_reg[4] & 0xFF) | chr_block, CHRArea.Area1000); - } - break; - case 2: - if (chr_block_mode) - { - Switch02KCHR(chr_reg[0], CHRArea.Area0000); - Switch02KCHR(chr_m ? chr_reg[0] : chr_reg[2], CHRArea.Area0800); - Switch02KCHR(chr_reg[4], CHRArea.Area1000); - Switch02KCHR(chr_reg[6], CHRArea.Area1800); - } - else - { - Switch02KCHR((chr_reg[0] & 0xFF) | chr_block, CHRArea.Area0000); - Switch02KCHR(((chr_m ? chr_reg[0] : chr_reg[2]) & 0xFF) | chr_block, CHRArea.Area0800); - Switch02KCHR((chr_reg[4] & 0xFF) | chr_block, CHRArea.Area1000); - Switch02KCHR((chr_reg[6] & 0xFF) | chr_block, CHRArea.Area1800); - } - break; - case 3: - if (chr_block_mode) - { - Switch01KCHR(chr_reg[0], CHRArea.Area0000); - Switch01KCHR(chr_reg[1], CHRArea.Area0400); - Switch01KCHR(chr_m ? chr_reg[0] : chr_reg[2], CHRArea.Area0800); - Switch01KCHR(chr_m ? chr_reg[1] : chr_reg[3], CHRArea.Area0C00); - Switch01KCHR(chr_reg[4], CHRArea.Area1000); - Switch01KCHR(chr_reg[5], CHRArea.Area1400); - Switch01KCHR(chr_reg[6], CHRArea.Area1800); - Switch01KCHR(chr_reg[7], CHRArea.Area1C00); - } - else - { - Switch01KCHR((chr_reg[0] & 0xFF) | chr_block, CHRArea.Area0000); - Switch01KCHR((chr_reg[1] & 0xFF) | chr_block, CHRArea.Area0400); - Switch01KCHR(((chr_m ? chr_reg[0] : chr_reg[2]) & 0xFF) | chr_block, CHRArea.Area0800); - Switch01KCHR(((chr_m ? chr_reg[1] : chr_reg[3]) & 0xFF) | chr_block, CHRArea.Area0C00); - Switch01KCHR((chr_reg[4] & 0xFF) | chr_block, CHRArea.Area1000); - Switch01KCHR((chr_reg[5] & 0xFF) | chr_block, CHRArea.Area1400); - Switch01KCHR((chr_reg[6] & 0xFF) | chr_block, CHRArea.Area1800); - Switch01KCHR((chr_reg[7] & 0xFF) | chr_block, CHRArea.Area1C00); - } - break; - } - } - - private byte ReverseByte(int value) - { - return (byte)((uint)(((value & 0x40) >> 6) | ((value & 0x20) >> 4) | ((value & 0x10) >> 2)) | ((uint)value & 8u) | (uint)((value & 4) << 2) | (uint)((value & 2) << 4) | (uint)((value & 1) << 6)); - } - - internal override void OnCPUClock() - { - if (irqSource != 0) - { - return; - } - if (irqPrescalerSize) - { - irqPrescaler = (irqPrescaler & 0xF8) | (((irqPrescaler & 7) + 1) & 7); - if ((irqPrescaler & 7) == 7) - { - ClockIRQCounter(); - } - } - else - { - irqPrescaler++; - if (irqPrescaler == 255) - { - ClockIRQCounter(); - } - } - } - - internal override void OnPPUAddressUpdate(ref ushort address) - { - if (irqSource != 1) - { - return; - } - old_vram_address = new_vram_address; - new_vram_address = address & 0x1000; - if (old_vram_address >= new_vram_address) - { - return; - } - if (irqPrescalerSize) - { - irqPrescaler = (irqPrescaler & 0xF8) | (((irqPrescaler & 7) + 1) & 7); - if ((irqPrescaler & 7) == 7) - { - ClockIRQCounter(); - } - } - else - { - irqPrescaler++; - if (irqPrescaler == 255) - { - ClockIRQCounter(); - } - } - } - - private void ClockIRQCounter() - { - if (irqCountDownMode && irqCountUpMode) - { - return; - } - if (irqCountDownMode) - { - irqCounter--; - if (irqCounter == 0) - { - irqCounter = 255; - if (IrqEnable) - { - NesEmu.IRQFlags |= 8; - } - } - } - else - { - if (!irqCountUpMode) - { - return; - } - irqCounter++; - if (irqCounter == 255) - { - irqCounter = 0; - if (IrqEnable) - { - NesEmu.IRQFlags |= 8; - } - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - for (int i = 0; i < prg_reg.Length; i++) - { - stream.Write(prg_reg[i]); - } - for (int j = 0; j < chr_reg.Length; j++) - { - stream.Write(chr_reg[j]); - } - for (int k = 0; k < nt_reg.Length; k++) - { - stream.Write(nt_reg[k]); - } - stream.Write(prg_mode); - stream.Write(chr_mode); - stream.Write(chr_block_mode); - stream.Write(chr_block); - stream.Write(chr_m); - stream.Write(flag_s); - stream.Write(irqCounter); - stream.Write(IrqEnable); - stream.Write(irqCountDownMode); - stream.Write(irqCountUpMode); - stream.Write(irqFunkyMode); - stream.Write(irqPrescalerSize); - stream.Write(irqSource); - stream.Write(irqPrescaler); - stream.Write(irqPrescalerXOR); - stream.Write(irqFunkyModeReg); - stream.Write(Dipswitch); - stream.Write(multiplication_a); - stream.Write(multiplication_b); - stream.Write(multiplication); - stream.Write(RAM5803); - stream.Write(nt_advanced_enable); - stream.Write(nt_rom_only); - stream.Write(nt_ram_select); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - for (int i = 0; i < prg_reg.Length; i++) - { - prg_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < chr_reg.Length; j++) - { - chr_reg[j] = stream.ReadInt32(); - } - for (int k = 0; k < nt_reg.Length; k++) - { - nt_reg[k] = stream.ReadInt32(); - } - prg_mode = stream.ReadInt32(); - chr_mode = stream.ReadInt32(); - chr_block_mode = stream.ReadBoolean(); - chr_block = stream.ReadInt32(); - chr_m = stream.ReadBoolean(); - flag_s = stream.ReadBoolean(); - irqCounter = stream.ReadInt32(); - IrqEnable = stream.ReadBoolean(); - irqCountDownMode = stream.ReadBoolean(); - irqCountUpMode = stream.ReadBoolean(); - irqFunkyMode = stream.ReadBoolean(); - irqPrescalerSize = stream.ReadBoolean(); - irqSource = stream.ReadInt32(); - irqPrescaler = stream.ReadInt32(); - irqPrescalerXOR = stream.ReadInt32(); - irqFunkyModeReg = stream.ReadByte(); - Dipswitch = stream.ReadByte(); - multiplication_a = stream.ReadByte(); - multiplication_b = stream.ReadByte(); - multiplication = stream.ReadUInt16(); - RAM5803 = stream.ReadByte(); - nt_advanced_enable = stream.ReadBoolean(); - nt_rom_only = stream.ReadBoolean(); - nt_ram_select = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper091.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper091.cs deleted file mode 100644 index 312367c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper091.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("HK-SF3", 91, true, true)] - internal class Mapper091 : Board - { - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (address & 0x7003) - { - case 24576: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 24577: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 24578: - Switch02KCHR(data, CHRArea.Area1000); - break; - case 24579: - Switch02KCHR(data, CHRArea.Area1800); - break; - case 28672: - Switch08KPRG(data & 0xF, PRGArea.Area8000); - break; - case 28673: - Switch08KPRG(data & 0xF, PRGArea.AreaA000); - break; - case 28674: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 28675: - irq_enabled = true; - irq_reload = 7; - irq_counter = 0; - break; - } - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper092.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper092.cs deleted file mode 100644 index 56c7ba0..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper092.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Jaleco Early Mapper 1", 92)] - internal class Mapper092 : Board - { - private int chr_reg; - - private int prg_reg; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(0, PRGArea.Area8000); - chr_reg = (prg_reg = 0); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch ((data >> 6) & 3) - { - case 0: - Switch08KCHR(chr_reg); - Switch16KPRG(prg_reg, PRGArea.AreaC000); - break; - case 1: - chr_reg = data & 0xF; - break; - case 2: - prg_reg = data & 0xF; - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(chr_reg); - stream.Write(prg_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - chr_reg = stream.ReadInt32(); - prg_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper093.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper093.cs deleted file mode 100644 index a55e53b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper093.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("74161/32", 93)] - internal class Mapper093 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG((data >> 4) & 0xF, PRGArea.Area8000); - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper094.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper094.cs deleted file mode 100644 index 933562a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper094.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("74161/32", 94)] - internal class Mapper094 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG((data >> 2) & 7, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper095.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper095.cs deleted file mode 100644 index 64d8888..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper095.cs +++ /dev/null @@ -1,265 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Namcot MMC3-Style", 95, true, true)] - internal class Mapper095 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void ReadNMT(ref ushort address, out byte value) - { - if (flag_c) - { - value = NMT_RAM[(chr_reg[((address >> 10) & 3) + 2] & 0x20) >> 5][address & 0x3FF]; - return; - } - switch ((address >> 10) & 3) - { - case 0: - case 1: - value = NMT_RAM[(chr_reg[0] & 0x20) >> 5][address & 0x3FF]; - break; - case 2: - case 3: - value = NMT_RAM[(chr_reg[1] & 0x20) >> 5][address & 0x3FF]; - break; - default: - value = 0; - break; - } - } - - internal override void WriteNMT(ref ushort address, ref byte data) - { - if (flag_c) - { - NMT_RAM[(chr_reg[((address >> 10) & 3) + 2] & 0x20) >> 5][address & 0x3FF] = data; - return; - } - switch ((address >> 10) & 3) - { - case 0: - case 1: - NMT_RAM[(chr_reg[0] & 0x20) >> 5][address & 0x3FF] = data; - break; - case 2: - case 3: - NMT_RAM[(chr_reg[1] & 0x20) >> 5][address & 0x3FF] = data; - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper096.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper096.cs deleted file mode 100644 index fc6ce4c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper096.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("74161/32", 96, 1, 32)] - internal class Mapper096 : Board - { - private int flag_c; - - internal override string Issues => MNInterfaceLanguage.IssueMapper96; - - internal override void HardReset() - { - base.HardReset(); - flag_c = 0; - Switch04KCHR(3, CHRArea.Area1000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch32KPRG(data & 3, PRGArea.Area8000); - flag_c = (((data & 4) == 4) ? 1 : 0); - Switch04KCHR(3, CHRArea.Area1000); - } - - internal override void OnPPUAddressUpdate(ref ushort address) - { - if ((address & 0x3FF) < 960 && (address & 0x1000) == 0) - { - Switch04KCHR(((address & 0x300) >> 8) | flag_c, CHRArea.Area0000); - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper097.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper097.cs deleted file mode 100644 index e4da407..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper097.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Irem - PRG HI", 97)] - internal class Mapper097 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.Area8000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG(data & 0xF, PRGArea.AreaC000); - switch ((address >> 6) & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper105.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper105.cs deleted file mode 100644 index e663921..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper105.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("NES-EVENT", 105)] - [HassIssues] - internal class Mapper105 : Board - { - private int DipSwitchNumber; - - private byte[] reg = new byte[4]; - - private byte shift; - - private byte buffer; - - private bool flag_p; - - private bool flag_s; - - private bool flag_o; - - private int reg_a; - - private int reg_b; - - private bool irq_control; - - private bool initialized; - - private int irq_counter; - - private int dipswitches; - - internal override string Issues => MNInterfaceLanguage.IssueMapper105; - - internal override void HardReset() - { - base.HardReset(); - TogglePRGRAMEnable(enable: true); - reg = new byte[4]; - reg[0] = 12; - flag_s = (flag_p = true); - reg[1] = (reg[2] = (reg[3] = 0)); - buffer = 0; - shift = 0; - initialized = false; - DipSwitchNumber = 0; - dipswitches = 0x20000000 | (DipSwitchNumber << 22); - } - - internal override void SoftReset() - { - DipSwitchNumber = (DipSwitchNumber + 1) & 0xF; - dipswitches = 0x20000000 | (DipSwitchNumber << 22); - } - - internal override void WritePRG(ref ushort address, ref byte value) - { - if ((value & 0x80) == 128) - { - reg[0] |= 12; - flag_s = (flag_p = true); - shift = (buffer = 0); - return; - } - if ((value & 1) == 1) - { - buffer |= (byte)(1 << (int)shift); - } - if (++shift < 5) - { - return; - } - address = (ushort)((address & 0x7FFF) >> 13); - reg[address] = buffer; - shift = (buffer = 0); - switch (address) - { - case 0: - flag_p = (reg[0] & 8) != 0; - flag_s = (reg[0] & 4) != 0; - UpdatePRG(); - switch (reg[0] & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.OneScA); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - } - break; - case 1: - irq_control = (reg[1] & 0x10) == 16; - if (irq_control) - { - initialized = true; - irq_counter = 0; - NesEmu.IRQFlags &= -9; - } - else - { - Switch32KPRG(0, PRGArea.Area8000); - } - flag_o = (reg[1] & 8) == 8; - reg_a = (reg[1] >> 1) & 3; - UpdatePRG(); - break; - case 3: - TogglePRGRAMEnable((reg[3] & 0x10) == 0); - reg_b = reg[3] & 0xF; - UpdatePRG(); - break; - case 2: - break; - } - } - - private void UpdatePRG() - { - if (initialized) - { - if (!flag_o) - { - Switch32KPRG(reg_a, PRGArea.Area8000); - } - else if (!flag_p) - { - Switch32KPRG((reg_b >> 1) + 4, PRGArea.Area8000); - } - else if (!flag_s) - { - Switch16KPRG(8, PRGArea.Area8000); - Switch16KPRG(reg_b + 8, PRGArea.AreaC000); - } - else - { - Switch16KPRG(reg_b + 8, PRGArea.Area8000); - Switch16KPRG(15, PRGArea.AreaC000); - } - } - } - - internal override void OnCPUClock() - { - if (!irq_control) - { - irq_counter++; - if (irq_counter == dipswitches) - { - irq_counter = 0; - NesEmu.IRQFlags |= 8; - } - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(DipSwitchNumber); - stream.Write(reg); - stream.Write(shift); - stream.Write(buffer); - stream.Write(flag_p); - stream.Write(flag_s); - stream.Write(flag_o); - stream.Write(reg_a); - stream.Write(reg_b); - stream.Write(irq_control); - stream.Write(initialized); - stream.Write(irq_counter); - stream.Write(dipswitches); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - DipSwitchNumber = stream.ReadInt32(); - stream.Read(reg, 0, reg.Length); - shift = stream.ReadByte(); - buffer = stream.ReadByte(); - flag_p = stream.ReadBoolean(); - flag_s = stream.ReadBoolean(); - flag_o = stream.ReadBoolean(); - reg_a = stream.ReadInt32(); - reg_b = stream.ReadInt32(); - irq_control = stream.ReadBoolean(); - initialized = stream.ReadBoolean(); - irq_counter = stream.ReadInt32(); - dipswitches = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper107.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper107.cs deleted file mode 100644 index 23182d9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper107.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MyNes.Core -{ - internal class Mapper107 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch32KPRG(data >> 1, PRGArea.Area8000); - Switch08KCHR(data); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper112.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper112.cs deleted file mode 100644 index b4a1ded..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper112.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Asder", 112)] - internal class Mapper112 : Board - { - private int address_A000; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_A000 = data & 7; - break; - case 40960: - switch (address_A000) - { - case 0: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 1: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 2: - Switch02KCHR(data >> 1, CHRArea.Area0000); - break; - case 3: - Switch02KCHR(data >> 1, CHRArea.Area0800); - break; - case 4: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 5: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 6: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 7: - Switch01KCHR(data, CHRArea.Area1C00); - break; - } - break; - case 57344: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(address_A000); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - address_A000 = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper113.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper113.cs deleted file mode 100644 index 8e4901a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper113.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Sachen/Hacker/Nina", 113)] - internal class Mapper113 : Board - { - internal override void WriteEX(ref ushort address, ref byte data) - { - if ((address & 0x4100) == 16640) - { - Switch08KCHR((data & 7) | ((data & 0x40) >> 3)); - Switch32KPRG((data >> 3) & 7, PRGArea.Area8000); - Switch01KNMTFromMirroring(((data & 0x80) == 128) ? Mirroring.Vert : Mirroring.Horz); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper115.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper115.cs deleted file mode 100644 index e2e6bd3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper115.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("MMC3 Cart Saint", 115, true, true)] - internal class Mapper115 : Board - { - private bool flag_c; - - private bool flag_p; - - private bool flag_o; - - private int chr_block; - - private int prg_secreg; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_o = (flag_c = (flag_p = false)); - address_8001 = 0; - chr_block = 0; - prg_secreg = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (address & 0x6001) - { - case 24576: - flag_o = (data & 0x80) == 128; - prg_secreg = data & 0xF; - SetupPRG(); - break; - case 24577: - chr_block = (data & 1) << 8; - SetupCHR(); - break; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR((chr_reg[0] >> 1) | chr_block, CHRArea.Area0000); - Switch02KCHR((chr_reg[1] >> 1) | chr_block, CHRArea.Area0800); - Switch01KCHR(chr_reg[2] | chr_block, CHRArea.Area1000); - Switch01KCHR(chr_reg[3] | chr_block, CHRArea.Area1400); - Switch01KCHR(chr_reg[4] | chr_block, CHRArea.Area1800); - Switch01KCHR(chr_reg[5] | chr_block, CHRArea.Area1C00); - } - else - { - Switch02KCHR((chr_reg[0] >> 1) | chr_block, CHRArea.Area1000); - Switch02KCHR((chr_reg[1] >> 1) | chr_block, CHRArea.Area1800); - Switch01KCHR(chr_reg[2] | chr_block, CHRArea.Area0000); - Switch01KCHR(chr_reg[3] | chr_block, CHRArea.Area0400); - Switch01KCHR(chr_reg[4] | chr_block, CHRArea.Area0800); - Switch01KCHR(chr_reg[5] | chr_block, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - if (!flag_o) - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - } - else - { - Switch16KPRG(prg_secreg, PRGArea.Area8000); - } - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(flag_o); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(chr_block); - stream.Write(prg_secreg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - flag_o = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - chr_block = stream.ReadInt32(); - prg_secreg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper118.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper118.cs deleted file mode 100644 index 58e858f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper118.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("MMC3 TLSROM", 118, true, true)] - internal class Mapper118 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - internal override void ReadNMT(ref ushort address, out byte value) - { - switch ((address >> 10) & 3) - { - case 0: - value = NMT_RAM[(chr_reg[flag_c ? 2 : 0] >> 7) & 1][address & 0x3FF]; - break; - case 1: - value = NMT_RAM[(chr_reg[flag_c ? 3 : 0] >> 7) & 1][address & 0x3FF]; - break; - case 2: - value = NMT_RAM[(chr_reg[(!flag_c) ? 1 : 4] >> 7) & 1][address & 0x3FF]; - break; - case 3: - value = NMT_RAM[(chr_reg[(!flag_c) ? 1 : 5] >> 7) & 1][address & 0x3FF]; - break; - default: - value = 0; - break; - } - } - - internal override void WriteNMT(ref ushort address, ref byte data) - { - switch ((address >> 10) & 3) - { - case 0: - NMT_RAM[(chr_reg[flag_c ? 2 : 0] >> 7) & 1][address & 0x3FF] = data; - break; - case 1: - NMT_RAM[(chr_reg[flag_c ? 3 : 0] >> 7) & 1][address & 0x3FF] = data; - break; - case 2: - NMT_RAM[(chr_reg[(!flag_c) ? 1 : 4] >> 7) & 1][address & 0x3FF] = data; - break; - case 3: - NMT_RAM[(chr_reg[(!flag_c) ? 1 : 5] >> 7) & 1][address & 0x3FF] = data; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper119.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper119.cs deleted file mode 100644 index 2634af5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper119.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("TQROM", 119, 1, 8, true, true)] - internal class Mapper119 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override string Issues => MNInterfaceLanguage.IssueMapper119; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Toggle02KCHR_RAM((chr_reg[0] & 0x40) != 0, CHRArea.Area0000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Toggle02KCHR_RAM((chr_reg[1] & 0x40) != 0, CHRArea.Area0800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Toggle02KCHR_RAM((chr_reg[2] & 0x40) != 0, CHRArea.Area1000); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Toggle02KCHR_RAM((chr_reg[3] & 0x40) != 0, CHRArea.Area1400); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Toggle02KCHR_RAM((chr_reg[4] & 0x40) != 0, CHRArea.Area1800); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Toggle02KCHR_RAM((chr_reg[5] & 0x40) != 0, CHRArea.Area1C00); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Toggle02KCHR_RAM((chr_reg[0] & 0x40) != 0, CHRArea.Area1000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Toggle02KCHR_RAM((chr_reg[1] & 0x40) != 0, CHRArea.Area1800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Toggle02KCHR_RAM((chr_reg[2] & 0x40) != 0, CHRArea.Area0000); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Toggle02KCHR_RAM((chr_reg[3] & 0x40) != 0, CHRArea.Area0400); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Toggle02KCHR_RAM((chr_reg[4] & 0x40) != 0, CHRArea.Area0800); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Toggle02KCHR_RAM((chr_reg[5] & 0x40) != 0, CHRArea.Area0C00); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper133.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper133.cs deleted file mode 100644 index c907bc5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper133.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Sachen", 133)] - internal class Mapper133 : Board - { - internal override void WriteEX(ref ushort address, ref byte data) - { - Switch08KCHR(data & 3); - Switch32KPRG(data >> 2, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper140.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper140.cs deleted file mode 100644 index a6ba602..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper140.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 140)] - internal class Mapper140 : Board - { - internal override void WriteSRM(ref ushort address, ref byte data) - { - Switch08KCHR(data & 0xF); - Switch32KPRG((data >> 4) & 3, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper152.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper152.cs deleted file mode 100644 index d30281d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper152.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 152)] - internal class Mapper152 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(data & 0xF); - Switch16KPRG((data >> 4) & 7, PRGArea.Area8000); - Switch01KNMTFromMirroring(((data & 0x80) == 128) ? Mirroring.OneScB : Mirroring.OneScA); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper152.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper152.cs.meta deleted file mode 100644 index 75e1a5a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper152.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 67722d43f058e6f4a9dac4938c2f1173 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper154.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper154.cs deleted file mode 100644 index 3218916..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper154.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("NAMCOT-3453", 154)] - [HassIssues] - internal class Mapper154 : Board - { - private int address_8001; - - internal override string Issues => MNInterfaceLanguage.IssueMapper154; - - internal override void HardReset() - { - base.HardReset(); - address_8001 = 0; - Switch16KPRG(PRG_ROM_16KB_Mask, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0x8001) - { - case 32768: - address_8001 = data & 7; - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.OneScB : Mirroring.OneScA); - break; - case 32769: - switch (address_8001) - { - case 0: - Switch02KCHR((data & 0x3F) >> 1, CHRArea.Area0000); - break; - case 1: - Switch02KCHR((data & 0x3F) >> 1, CHRArea.Area0800); - break; - case 2: - Switch01KCHR(data | 0x40, CHRArea.Area1000); - break; - case 3: - Switch01KCHR(data | 0x40, CHRArea.Area1400); - break; - case 4: - Switch01KCHR(data | 0x40, CHRArea.Area1800); - break; - case 5: - Switch01KCHR(data | 0x40, CHRArea.Area1C00); - break; - case 6: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 7: - Switch08KPRG(data, PRGArea.AreaA000); - break; - } - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(address_8001); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - address_8001 = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper154.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper154.cs.meta deleted file mode 100644 index 82403ba..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper154.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 42da22d35d44cf4418466ac94e6877e1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper163.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper163.cs deleted file mode 100644 index 8441834..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper163.cs +++ /dev/null @@ -1,109 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 163)] - internal class Mapper163 : Board - { - internal byte prg_reg; - - internal byte security_reg; - - internal bool security_trigger; - - internal byte security_reg101; - - internal bool do_chr_ram; - - internal override void HardReset() - { - base.HardReset(); - security_reg101 = 1; - security_trigger = false; - do_chr_ram = true; - Switch32KPRG(15, PRGArea.Area8000); - Toggle08KCHR_RAM(ram: true); - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - if (address == 20737) - { - if (security_reg101 != 0 && data == 0) - { - security_trigger = true; - } - security_reg101 = data; - } - else - { - if (address < 20480) - { - return; - } - switch (address & 0x7300) - { - case 20480: - prg_reg = (byte)((prg_reg & 0xF0u) | (data & 0xFu)); - Switch32KPRG(prg_reg, PRGArea.Area8000); - do_chr_ram = (data & 0x80) != 0; - if (!do_chr_ram && NesEmu.ppu_clock_v < 128) - { - Switch08KCHR(0); - } - break; - case 20736: - if (data == 6) - { - Switch32KPRG(3, PRGArea.Area8000); - } - break; - case 20992: - prg_reg = (byte)((prg_reg & 0xFu) | (uint)((data & 0xF) << 4)); - Switch32KPRG(prg_reg, PRGArea.Area8000); - break; - case 21248: - security_reg = data; - break; - } - } - } - - internal override void ReadEX(ref ushort addr, out byte val) - { - val = 0; - if (addr < 20480) - { - return; - } - switch (addr & 0x1E14) - { - case 20736: - val = security_reg; - break; - case 21760: - if (security_trigger) - { - val = security_reg; - } - break; - } - } - - internal override void OnPPUScanlineTick() - { - base.OnPPUScanlineTick(); - if (do_chr_ram && NesEmu.IsRenderingOn()) - { - if (NesEmu.ppu_clock_v == 127) - { - Switch04KCHR(1, CHRArea.Area0000); - Switch04KCHR(1, CHRArea.Area1000); - } - if (NesEmu.ppu_clock_v == 237) - { - Switch04KCHR(0, CHRArea.Area0000); - Switch04KCHR(0, CHRArea.Area1000); - } - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper164.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper164.cs deleted file mode 100644 index 3fbff7f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper164.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 164)] - internal class Mapper164 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch32KPRG(255, PRGArea.Area8000); - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - if (address >= 20480 && (address & 0xF000) == 20480) - { - Switch32KPRG(data, PRGArea.Area8000); - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if ((address & 0xF000) == 53248) - { - Switch32KPRG(data, PRGArea.Area8000); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper165.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper165.cs deleted file mode 100644 index 45c79fb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper165.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 165, true, true)] - internal class Mapper165 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private byte latch_a = 254; - - private byte latch_b = 254; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - internal override void ReadCHR(ref ushort address, out byte data) - { - if ((address & 0x1FF0) == 4048 && latch_a != 253) - { - latch_a = 253; - Switch04KCHR(chr_reg[0] >> 2, CHRArea.Area0000); - } - else if ((address & 0x1FF0) == 4064 && latch_a != 254) - { - latch_a = 254; - Switch04KCHR(chr_reg[1] >> 2, CHRArea.Area0000); - } - else if ((address & 0x1FF0) == 8144 && latch_b != 253) - { - latch_b = 253; - Switch04KCHR(chr_reg[2] >> 2, CHRArea.Area1000); - } - else if ((address & 0x1FF0) == 8160 && latch_b != 254) - { - latch_b = 254; - Switch04KCHR(chr_reg[4] >> 2, CHRArea.Area1000); - } - base.ReadCHR(ref address, out data); - } - - private void SetupCHR() - { - if (latch_a == 253) - { - Switch04KCHR(chr_reg[0] >> 2, CHRArea.Area0000); - } - if (latch_a == 254) - { - Switch04KCHR(chr_reg[1] >> 2, CHRArea.Area0000); - } - if (latch_b == 253) - { - Switch04KCHR(chr_reg[2] >> 2, CHRArea.Area1000); - } - if (latch_b == 254) - { - Switch04KCHR(chr_reg[4] >> 2, CHRArea.Area1000); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(latch_a); - stream.Write(latch_b); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - latch_a = stream.ReadByte(); - latch_b = stream.ReadByte(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper180.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper180.cs deleted file mode 100644 index 4427a7e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper180.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Nihon Bussan", 180)] - [HassIssues] - internal class Mapper180 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper180; - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG(data & 7, PRGArea.AreaC000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper182.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper182.cs deleted file mode 100644 index f3554c8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper182.cs +++ /dev/null @@ -1,227 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 182, true, true)] - internal class Mapper182 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - mmc3_alt_behavior = false; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - int num = address & 0xE001; - if (num <= 40961) - { - if (num <= 32769) - { - if (num != 32768 && num == 32769 && NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - } - else if (num != 40960) - { - _ = 40961; - } - else - { - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - } - return; - } - switch (num) - { - case 49152: - switch (address_8001) - { - case 0: - chr_reg[0] = data; - SetupCHR(); - break; - case 1: - chr_reg[3] = data; - SetupCHR(); - break; - case 2: - chr_reg[1] = data; - SetupCHR(); - break; - case 3: - chr_reg[5] = data; - SetupCHR(); - break; - case 4: - prg_reg[0] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - case 5: - prg_reg[1] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - case 6: - chr_reg[2] = data; - SetupCHR(); - break; - case 7: - chr_reg[4] = data; - SetupCHR(); - break; - } - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - irq_reload = data; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper184.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper184.cs deleted file mode 100644 index ec438b3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper184.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Sunsoft", 184)] - internal class Mapper184 : Board - { - internal override void WriteSRM(ref ushort address, ref byte data) - { - Switch04KCHR(data & 7, CHRArea.Area0000); - Switch04KCHR((data >> 4) & 7, CHRArea.Area1000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper184.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper184.cs.meta deleted file mode 100644 index f10c047..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper184.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3ea85ab17c144364994c80fc92ddafe5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper185.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper185.cs deleted file mode 100644 index 04eb0d2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper185.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 185)] - internal class Mapper185 : Board - { - private bool lockchr; - - internal override void HardReset() - { - base.HardReset(); - lockchr = false; - } - - internal override void ReadCHR(ref ushort address, out byte data) - { - if (!lockchr) - { - base.ReadCHR(ref address, out data); - } - else - { - data = byte.MaxValue; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - lockchr = (data & 0xF) == 0 || data == 19; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(lockchr); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - lockchr = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper189.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper189.cs deleted file mode 100644 index 99c8915..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper189.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("MMC3 Variant", 189, true, true)] - internal class Mapper189 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = 0; - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - Switch32KPRG(((data & 0xF0) >> 4) | (data & 0xF), PRGArea.Area8000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - Switch32KPRG(((data & 0xF0) >> 4) | (data & 0xF), PRGArea.Area8000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - break; - case 32769: - { - int num = address_8001; - if ((uint)num <= 5u) - { - chr_reg[address_8001] = data; - SetupCHR(); - } - break; - } - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - stream.Write(prg_reg); - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - prg_reg = stream.ReadInt32(); - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper191.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper191.cs deleted file mode 100644 index 3ad1f6c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper191.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Pirate MMC3 variant", 191, true, true)] - [HassIssues] - internal class Mapper191 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - internal override string Issues => MNInterfaceLanguage.IssueMapper191; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Toggle02KCHR_RAM((chr_reg[0] & 0x80) == 0, CHRArea.Area0000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Toggle02KCHR_RAM((chr_reg[1] & 0x80) == 0, CHRArea.Area0800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Toggle02KCHR_RAM((chr_reg[2] & 0x80) == 0, CHRArea.Area1000); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Toggle02KCHR_RAM((chr_reg[3] & 0x80) == 0, CHRArea.Area1400); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Toggle02KCHR_RAM((chr_reg[4] & 0x80) == 0, CHRArea.Area1800); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Toggle02KCHR_RAM((chr_reg[5] & 0x80) == 0, CHRArea.Area1C00); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Toggle02KCHR_RAM((chr_reg[0] & 0x80) == 0, CHRArea.Area1000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Toggle02KCHR_RAM((chr_reg[1] & 0x80) == 0, CHRArea.Area1800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Toggle02KCHR_RAM((chr_reg[2] & 0x80) == 0, CHRArea.Area0000); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Toggle02KCHR_RAM((chr_reg[3] & 0x80) == 0, CHRArea.Area0400); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Toggle02KCHR_RAM((chr_reg[4] & 0x80) == 0, CHRArea.Area0800); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Toggle02KCHR_RAM((chr_reg[5] & 0x80) == 0, CHRArea.Area0C00); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper192.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper192.cs deleted file mode 100644 index 89084a5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper192.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Pirate MMC3 variant", 192, true, true)] - internal class Mapper192 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool isRam; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - isRam = chr_reg[0] >= 8 && chr_reg[0] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area0000); - Switch02KCHR(isRam ? (chr_reg[0] - 8 >> 1) : (chr_reg[0] >> 1), CHRArea.Area0000); - isRam = chr_reg[1] >= 8 && chr_reg[1] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area0000); - Switch02KCHR(isRam ? (chr_reg[1] - 8 >> 1) : (chr_reg[1] >> 1), CHRArea.Area0800); - isRam = chr_reg[2] >= 8 && chr_reg[2] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area1000); - Switch01KCHR(isRam ? (chr_reg[2] - 8) : chr_reg[2], CHRArea.Area1000); - isRam = chr_reg[3] >= 8 && chr_reg[3] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area1400); - Switch01KCHR(isRam ? (chr_reg[3] - 8) : chr_reg[3], CHRArea.Area1400); - isRam = chr_reg[4] >= 8 && chr_reg[4] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area1800); - Switch01KCHR(isRam ? (chr_reg[4] - 8) : chr_reg[4], CHRArea.Area1800); - isRam = chr_reg[5] >= 8 && chr_reg[5] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area1C00); - Switch01KCHR(isRam ? (chr_reg[5] - 8) : chr_reg[5], CHRArea.Area1C00); - } - else - { - isRam = chr_reg[0] >= 8 && chr_reg[0] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area1000); - Switch02KCHR(isRam ? (chr_reg[0] - 8 >> 1) : (chr_reg[0] >> 1), CHRArea.Area1000); - isRam = chr_reg[1] >= 8 && chr_reg[1] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area1800); - Switch02KCHR(isRam ? (chr_reg[1] - 8 >> 1) : (chr_reg[1] >> 1), CHRArea.Area1800); - isRam = chr_reg[2] >= 8 && chr_reg[2] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area0000); - Switch01KCHR(isRam ? (chr_reg[2] - 8) : chr_reg[2], CHRArea.Area0000); - isRam = chr_reg[3] >= 8 && chr_reg[3] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area0400); - Switch01KCHR(isRam ? (chr_reg[3] - 8) : chr_reg[3], CHRArea.Area0400); - isRam = chr_reg[4] >= 8 && chr_reg[4] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area0800); - Switch01KCHR(isRam ? (chr_reg[4] - 8) : chr_reg[4], CHRArea.Area0800); - isRam = chr_reg[5] >= 8 && chr_reg[5] <= 11; - Toggle02KCHR_RAM(isRam, CHRArea.Area0C00); - Switch01KCHR(isRam ? (chr_reg[5] - 8) : chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(isRam); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - isRam = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper193.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper193.cs deleted file mode 100644 index dc6e992..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper193.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 193, 1, 32)] - [HassIssues] - internal class Mapper193 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper193; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask - 2, PRGArea.AreaA000); - Switch08KPRG(PRG_ROM_08KB_Mask - 1, PRGArea.AreaC000); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (address & 0x6003) - { - case 24576: - Switch04KCHR(data >> 2, CHRArea.Area0000); - break; - case 24577: - Switch02KCHR(data >> 1, CHRArea.Area1000); - break; - case 24578: - Switch02KCHR(data >> 1, CHRArea.Area1800); - break; - case 24579: - Switch08KPRG(data, PRGArea.Area8000); - break; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper194.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper194.cs deleted file mode 100644 index 78fe5e4..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper194.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Pirate MMC3 variant", 194, true, true)] - internal class Mapper194 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Toggle02KCHR_RAM(chr_reg[0] > 1, CHRArea.Area0000); - Switch02KCHR((chr_reg[0] > 1) ? (chr_reg[0] - 1 >> 1) : (chr_reg[0] >> 1), CHRArea.Area0000); - Toggle02KCHR_RAM(chr_reg[1] > 1, CHRArea.Area0800); - Switch02KCHR((chr_reg[1] > 1) ? (chr_reg[1] - 1 >> 1) : (chr_reg[1] >> 1), CHRArea.Area0800); - Toggle02KCHR_RAM(chr_reg[2] > 1, CHRArea.Area1000); - Switch01KCHR((chr_reg[2] > 1) ? (chr_reg[2] - 1) : chr_reg[2], CHRArea.Area1000); - Toggle02KCHR_RAM(chr_reg[3] > 1, CHRArea.Area1400); - Switch01KCHR((chr_reg[3] > 1) ? (chr_reg[3] - 1) : chr_reg[3], CHRArea.Area1400); - Toggle02KCHR_RAM(chr_reg[4] > 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[4] > 1) ? (chr_reg[4] - 1) : chr_reg[4], CHRArea.Area1800); - Toggle02KCHR_RAM(chr_reg[5] > 1, CHRArea.Area1C00); - Switch01KCHR((chr_reg[5] > 1) ? (chr_reg[5] - 1) : chr_reg[5], CHRArea.Area1C00); - } - else - { - Toggle02KCHR_RAM(chr_reg[0] > 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Toggle02KCHR_RAM(chr_reg[1] > 1, CHRArea.Area1800); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Toggle02KCHR_RAM(chr_reg[2] > 1, CHRArea.Area0000); - Switch01KCHR((chr_reg[2] > 1) ? (chr_reg[2] - 1) : chr_reg[2], CHRArea.Area0000); - Toggle02KCHR_RAM(chr_reg[3] > 1, CHRArea.Area0400); - Switch01KCHR((chr_reg[3] > 1) ? (chr_reg[3] - 1) : chr_reg[3], CHRArea.Area0400); - Toggle02KCHR_RAM(chr_reg[4] > 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[4] > 1) ? (chr_reg[4] - 1) : chr_reg[4], CHRArea.Area0800); - Toggle02KCHR_RAM(chr_reg[5] > 1, CHRArea.Area0C00); - Switch01KCHR((chr_reg[5] > 1) ? (chr_reg[5] - 1) : chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper200.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper200.cs deleted file mode 100644 index af4effe..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper200.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 200)] - internal class Mapper200 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(address & 7); - Switch16KPRG(address & 7, PRGArea.Area8000); - Switch16KPRG(address & 7, PRGArea.AreaC000); - Switch01KNMTFromMirroring(((address & 8) == 8) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper201.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper201.cs deleted file mode 100644 index e6ccad2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper201.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 201)] - internal class Mapper201 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(address & 0xFF); - Switch32KPRG(address & 0xFF, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper202.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper202.cs deleted file mode 100644 index 2e6d0d1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper202.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("150-in-1", 202)] - [HassIssues] - internal class Mapper202 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper202; - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch01KNMTFromMirroring(((address & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - Switch08KCHR((address >> 1) & 7); - if ((address & 0xC) == 12) - { - Switch32KPRG(3, PRGArea.Area8000); - return; - } - Switch16KPRG((address >> 1) & 7, PRGArea.Area8000); - Switch16KPRG((address >> 1) & 7, PRGArea.AreaC000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper203.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper203.cs deleted file mode 100644 index 79ebe1d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper203.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 203)] - [HassIssues] - internal class Mapper203 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper203; - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(data & 3); - Switch16KPRG(data & 0x3F, PRGArea.Area8000); - Switch16KPRG(data & 0x3F, PRGArea.AreaC000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper203.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper203.cs.meta deleted file mode 100644 index 79c7332..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper203.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 16cfb93389e5f6a4084c106625e4879f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper204.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper204.cs deleted file mode 100644 index bfb4426..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper204.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("64-in-1", 204)] - internal class Mapper204 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch01KNMTFromMirroring(((address & 0x10) == 16) ? Mirroring.Horz : Mirroring.Vert); - Switch08KCHR(address & 7); - if ((address & 6) == 6) - { - Switch32KPRG(3, PRGArea.Area8000); - return; - } - Switch16KPRG(address & 7, PRGArea.Area8000); - Switch16KPRG(address & 7, PRGArea.AreaC000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper204.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper204.cs.meta deleted file mode 100644 index 6c03482..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper204.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5d5dcc6e4a9329745868b6b2ef452dc5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper205.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper205.cs deleted file mode 100644 index 86fceef..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper205.cs +++ /dev/null @@ -1,275 +0,0 @@ -using System; -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 205, true, true)] - internal class Mapper205 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private int chr_or; - - private int chr_and; - - private int prg_or; - - private int prg_and; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_and = 31; - prg_or = 0; - chr_and = 255; - chr_or = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - if (IsGameFoundOnDB) - { - switch (GameCartInfo.chip_type[0].ToLower()) - { - case "mmc3a": - mmc3_alt_behavior = true; - Console.WriteLine("Chip= MMC3 A, MMC3 IQR mode switched to RevA"); - break; - case "mmc3b": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 B, MMC3 IQR mode switched to RevB"); - break; - case "mmc3c": - mmc3_alt_behavior = false; - Console.WriteLine("Chip= MMC3 C, MMC3 IQR mode switched to RevB"); - break; - } - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (data & 3) - { - case 0: - prg_and = 31; - prg_or = 0; - chr_and = 255; - chr_or = 0; - break; - case 1: - prg_and = 31; - prg_or = 16; - chr_and = 255; - chr_or = 128; - break; - case 2: - prg_and = 15; - prg_or = 32; - chr_and = 127; - chr_or = 256; - break; - case 3: - prg_and = 15; - prg_or = 48; - chr_and = 127; - chr_or = 384; - break; - } - SetupCHR(); - SetupPRG(); - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area0000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area0800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area1000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area1400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area1800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area1C00); - } - else - { - Switch02KCHR(((chr_reg[0] & chr_and) | chr_or) >> 1, CHRArea.Area1000); - Switch02KCHR(((chr_reg[1] & chr_and) | chr_or) >> 1, CHRArea.Area1800); - Switch01KCHR((chr_reg[2] & chr_and) | chr_or, CHRArea.Area0000); - Switch01KCHR((chr_reg[3] & chr_and) | chr_or, CHRArea.Area0400); - Switch01KCHR((chr_reg[4] & chr_and) | chr_or, CHRArea.Area0800); - Switch01KCHR((chr_reg[5] & chr_and) | chr_or, CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG((prg_reg[flag_p ? 2 : 0] & prg_and) | prg_or, PRGArea.Area8000); - Switch08KPRG((prg_reg[1] & prg_and) | prg_or, PRGArea.AreaA000); - Switch08KPRG((prg_reg[(!flag_p) ? 2 : 0] & prg_and) | prg_or, PRGArea.AreaC000); - Switch08KPRG((prg_reg[3] & prg_and) | prg_or, PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(chr_or); - stream.Write(chr_and); - stream.Write(prg_or); - stream.Write(prg_and); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - chr_or = stream.ReadInt32(); - chr_and = stream.ReadInt32(); - prg_or = stream.ReadInt32(); - prg_and = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper205.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper205.cs.meta deleted file mode 100644 index 2108df8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper205.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 10f689fe32f13114fbc616cb3a04dd0f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper206.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper206.cs deleted file mode 100644 index a1ddd5b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper206.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 206)] - internal class Mapper206 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - SetupPRG(); - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - case 7: - prg_reg[address_8001 - 6] = data & PRG_ROM_08KB_Mask; - SetupPRG(); - break; - } - break; - } - } - - private void SetupCHR() - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - - private void SetupPRG() - { - Switch08KPRG(prg_reg[flag_p ? 2 : 0], PRGArea.Area8000); - Switch08KPRG(prg_reg[1], PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0], PRGArea.AreaC000); - Switch08KPRG(prg_reg[3], PRGArea.AreaE000); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper206.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper206.cs.meta deleted file mode 100644 index ae26717..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper206.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dd0ebc01d4ccb5144be2ae2380e63a4b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper207.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper207.cs deleted file mode 100644 index 54de6c3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper207.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 207)] - [HassIssues] - internal class Mapper207 : Board - { - private int mirroring0; - - private int mirroring1; - - internal override string Issues => MNInterfaceLanguage.IssueMapper207; - - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - switch (address) - { - case 32496: - Switch02KCHR(data & 0x3F, CHRArea.Area0000); - mirroring0 = (data >> 7) & 1; - break; - case 32497: - Switch02KCHR(data & 0x3F, CHRArea.Area0800); - mirroring1 = (data >> 7) & 1; - break; - case 32498: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 32499: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 32500: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 32501: - Switch01KCHR(data, CHRArea.Area1C00); - break; - case 32506: - case 32507: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 32508: - case 32509: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 32510: - case 32511: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 32502: - case 32503: - case 32504: - case 32505: - break; - } - } - - internal override void ReadNMT(ref ushort address, out byte data) - { - switch ((address >> 10) & 3) - { - case 0: - case 1: - data = NMT_RAM[mirroring0][address & 0x3FF]; - break; - case 2: - case 3: - data = NMT_RAM[mirroring1][address & 0x3FF]; - break; - default: - data = 0; - break; - } - } - - internal override void WriteNMT(ref ushort address, ref byte data) - { - switch ((address >> 10) & 3) - { - case 0: - case 1: - NMT_RAM[mirroring0][address & 0x3FF] = data; - break; - case 2: - case 3: - NMT_RAM[mirroring1][address & 0x3FF] = data; - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(mirroring0); - stream.Write(mirroring1); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - mirroring0 = stream.ReadInt32(); - mirroring1 = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper207.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper207.cs.meta deleted file mode 100644 index 8905a37..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper207.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8120e93e983c6a240aa549981107c6f9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper209.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper209.cs deleted file mode 100644 index fae5b6e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper209.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Pirate MMC5-style", 209)] - internal class Mapper209 : Mapper090 - { - internal override void HardReset() - { - MAPPER90MODE = false; - base.HardReset(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper209.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper209.cs.meta deleted file mode 100644 index a769ed7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper209.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6e1cfeabf90d9d241a85d23d367fd146 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper212.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper212.cs deleted file mode 100644 index 4300ebf..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper212.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Super HIK 300-in-1 (1994)", 212)] - internal class Mapper212 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(address & 7); - Switch01KNMTFromMirroring(((address & 8) == 8) ? Mirroring.Horz : Mirroring.Vert); - if ((address & 0x4000) == 16384) - { - Switch32KPRG((address >> 1) & 3, PRGArea.Area8000); - return; - } - Switch16KPRG(address & 7, PRGArea.Area8000); - Switch16KPRG(address & 7, PRGArea.AreaC000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper212.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper212.cs.meta deleted file mode 100644 index f4712ea..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper212.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9b0a6452db095d64d9b655ea1a70de61 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper213.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper213.cs deleted file mode 100644 index 624b079..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper213.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("9999999-in-1", 213)] - internal class Mapper213 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR((address >> 3) & 7); - Switch32KPRG((address >> 1) & 3, PRGArea.Area8000); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper213.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper213.cs.meta deleted file mode 100644 index 0b17a90..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper213.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5f55d2933322aa24986e3c886539b729 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper214.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper214.cs deleted file mode 100644 index 0014c9b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper214.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("X-in-1", 214)] - internal class Mapper214 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG(address >> 2, PRGArea.Area8000); - Switch16KPRG(address >> 2, PRGArea.AreaC000); - Switch08KCHR(address); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper214.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper214.cs.meta deleted file mode 100644 index ab69bd1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper214.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c7b5c32585db1e640b6b297c40f0df87 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper216.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper216.cs deleted file mode 100644 index 6b75a91..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper216.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 216)] - internal class Mapper216 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch32KPRG(address, PRGArea.Area8000); - Switch08KCHR(address >> 1); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper222.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper222.cs deleted file mode 100644 index 4ce322d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper222.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 222)] - internal class Mapper222 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper222; - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF003) - { - case 32768: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 36864: - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - break; - case 40960: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 45056: - Switch01KCHR(data, CHRArea.Area0000); - break; - case 45058: - Switch01KCHR(data, CHRArea.Area0400); - break; - case 49152: - Switch01KCHR(data, CHRArea.Area0800); - break; - case 49154: - Switch01KCHR(data, CHRArea.Area0C00); - break; - case 53248: - Switch01KCHR(data, CHRArea.Area1000); - break; - case 53250: - Switch01KCHR(data, CHRArea.Area1400); - break; - case 57344: - Switch01KCHR(data, CHRArea.Area1800); - break; - case 57346: - Switch01KCHR(data, CHRArea.Area1C00); - break; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper225.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper225.cs deleted file mode 100644 index d1e09b1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper225.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 225)] - internal class Mapper225 : Board - { - private byte[] RAM; - - internal override void HardReset() - { - base.HardReset(); - RAM = new byte[4]; - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - if (address >= 22528) - { - RAM[address & 3] = (byte)(data & 0xFu); - } - } - - internal override void ReadEX(ref ushort address, out byte value) - { - if (address >= 22528) - { - value = RAM[address & 3]; - } - else - { - value = 0; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(address & 0x3F); - if ((address & 0x1000) == 4096) - { - Switch16KPRG((address >> 6) & 0x3F, PRGArea.Area8000); - Switch16KPRG((address >> 6) & 0x3F, PRGArea.AreaC000); - } - else - { - Switch32KPRG(((address >> 6) & 0x3F) >> 1, PRGArea.Area8000); - } - Switch01KNMTFromMirroring(((address & 0x2000) == 8192) ? Mirroring.Horz : Mirroring.Vert); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(RAM); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - stream.Read(RAM, 0, RAM.Length); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper226.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper226.cs deleted file mode 100644 index bee16ad..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper226.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 226)] - internal class Mapper226 : Board - { - private int prg_reg; - - private bool prg_mode; - - internal override void HardReset() - { - base.HardReset(); - prg_reg = 0; - prg_mode = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0x8001) - { - case 32768: - prg_reg = (data & 0x1F) | ((data & 0x80) >> 2) | (prg_reg & 0xC0); - prg_mode = (data & 0x20) == 32; - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Vert : Mirroring.Horz); - if (prg_mode) - { - Switch16KPRG(prg_reg, PRGArea.Area8000); - Switch16KPRG(prg_reg, PRGArea.AreaC000); - } - else - { - Switch32KPRG(prg_reg >> 1, PRGArea.Area8000); - } - break; - case 32769: - prg_reg = ((data & 1) << 6) | (prg_reg & 0x3F); - if (prg_mode) - { - Switch16KPRG(prg_reg, PRGArea.Area8000); - Switch16KPRG(prg_reg, PRGArea.AreaC000); - } - else - { - Switch32KPRG(prg_reg >> 1, PRGArea.Area8000); - } - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_reg); - stream.Write(prg_mode); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_reg = stream.ReadInt32(); - prg_mode = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper227.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper227.cs deleted file mode 100644 index fdc5e76..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper227.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 227)] - internal class Mapper227 : Board - { - private bool flag_o; - - private bool flag_s; - - private bool flag_l; - - private int prg_reg; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(0, PRGArea.AreaC000); - flag_o = false; - flag_s = false; - flag_l = false; - prg_reg = 0; - ToggleCHRRAMWritableEnable(enable: true); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - flag_s = (address & 1) == 1; - flag_o = (address & 0x80) == 128; - flag_l = (address & 0x200) == 512; - prg_reg = ((address >> 2) & 0x1F) | ((address >> 3) & 0x20); - Switch01KNMTFromMirroring(((address & 2) == 2) ? Mirroring.Horz : Mirroring.Vert); - ToggleCHRRAMWritableEnable(!flag_o); - if (flag_o) - { - if (!flag_s) - { - Switch16KPRG(prg_reg, PRGArea.Area8000); - Switch16KPRG(prg_reg, PRGArea.AreaC000); - } - else - { - Switch32KPRG(prg_reg >> 1, PRGArea.Area8000); - } - } - else if (!flag_l) - { - if (!flag_s) - { - Switch16KPRG(prg_reg, PRGArea.Area8000); - Switch16KPRG(prg_reg & 0x38, PRGArea.AreaC000); - } - else - { - Switch16KPRG(prg_reg & 0x3E, PRGArea.Area8000); - Switch16KPRG(prg_reg & 0x38, PRGArea.AreaC000); - } - } - else if (!flag_s) - { - Switch16KPRG(prg_reg, PRGArea.Area8000); - Switch16KPRG(prg_reg | 7, PRGArea.AreaC000); - } - else - { - Switch16KPRG(prg_reg & 0x3E, PRGArea.Area8000); - Switch16KPRG(prg_reg | 7, PRGArea.AreaC000); - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_o); - stream.Write(flag_s); - stream.Write(flag_l); - stream.Write(prg_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_o = stream.ReadBoolean(); - flag_s = stream.ReadBoolean(); - flag_l = stream.ReadBoolean(); - prg_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper228.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper228.cs deleted file mode 100644 index ccbcdc3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper228.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 228)] - [HassIssues] - internal class Mapper228 : Board - { - private byte[] RAM; - - private int bank; - - internal override string Issues => MNInterfaceLanguage.IssueMapper228; - - internal override void HardReset() - { - base.HardReset(); - RAM = new byte[4]; - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - RAM[address & 3] = (byte)(data & 0xFu); - } - - internal override void ReadEX(ref ushort address, out byte data) - { - data = RAM[address & 3]; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(((address & 0xF) << 2) | (data & 3)); - Switch01KNMTFromMirroring(((address & 0x2000) == 8192) ? Mirroring.Horz : Mirroring.Vert); - bank = ((address >> 7) & 0x1F) + ((address >> 7) & (address >> 8) & 0x10); - if ((address & 0x20) == 32) - { - Switch16KPRG((bank << 2) | ((address >> 5) & 2), PRGArea.Area8000); - Switch16KPRG((bank << 2) | ((address >> 5) & 2), PRGArea.AreaC000); - } - else - { - Switch32KPRG(bank, PRGArea.Area8000); - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(RAM); - stream.Write(bank); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - stream.Read(RAM, 0, RAM.Length); - bank = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper229.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper229.cs deleted file mode 100644 index 17f8ce9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper229.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 229)] - [HassIssues] - internal class Mapper229 : Board - { - internal override string Issues => MNInterfaceLanguage.IssueMapper229; - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch01KNMTFromMirroring(((address & 0x20) == 32) ? Mirroring.Horz : Mirroring.Vert); - Switch16KPRG(((address & 0x1E) == 30) ? (address & 0x1F) : 0, PRGArea.Area8000); - Switch16KPRG(((address & 0x1E) != 30) ? 1 : (address & 0x1F), PRGArea.AreaC000); - Switch08KCHR(address); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper230.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper230.cs deleted file mode 100644 index 0f73e75..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper230.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 230)] - [HassIssues] - internal class Mapper230 : Board - { - private bool contraMode; - - internal override string Issues => MNInterfaceLanguage.IssueMapper230; - - internal override void HardReset() - { - base.HardReset(); - contraMode = true; - Switch16KPRG(0, PRGArea.Area8000); - Switch16KPRG(7, PRGArea.AreaC000); - } - - internal override void SoftReset() - { - base.SoftReset(); - contraMode = !contraMode; - if (contraMode) - { - Switch16KPRG(0, PRGArea.Area8000); - Switch16KPRG(7, PRGArea.AreaC000); - Switch01KNMTFromMirroring(Mirroring.Vert); - } - else - { - Switch08KCHR(0); - Switch16KPRG(8, PRGArea.Area8000); - Switch16KPRG(39, PRGArea.AreaC000); - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (contraMode) - { - Switch16KPRG(data & 7, PRGArea.Area8000); - Switch16KPRG(7, PRGArea.AreaC000); - Switch01KNMTFromMirroring(Mirroring.Vert); - return; - } - Switch01KNMTFromMirroring(((data & 0x40) == 64) ? Mirroring.Vert : Mirroring.Horz); - if ((data & 0x20) == 32) - { - Switch16KPRG((data & 0x1F) + 8, PRGArea.Area8000); - Switch16KPRG((data & 0x1F) + 8, PRGArea.AreaC000); - } - else - { - Switch32KPRG(((data & 0x1F) >> 1) + 4, PRGArea.Area8000); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper231.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper231.cs deleted file mode 100644 index 35cf150..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper231.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 231)] - internal class Mapper231 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch16KPRG(address & 0x1E, PRGArea.Area8000); - Switch16KPRG((address & 0x1E) | ((address >> 5) & 1), PRGArea.AreaC000); - Switch01KNMTFromMirroring(((address & 0x80) == 128) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper232.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper232.cs deleted file mode 100644 index 94ae499..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper232.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 232)] - internal class Mapper232 : Board - { - private int prg_reg; - - internal override void HardReset() - { - base.HardReset(); - Switch16KPRG(3, PRGArea.AreaC000); - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - if (address < 49152) - { - prg_reg = ((data & 0x18) >> 1) | (prg_reg & 3); - } - else - { - prg_reg = (prg_reg & 0xC) | (data & 3); - } - Switch16KPRG(prg_reg, PRGArea.Area8000); - Switch16KPRG(3 | (prg_reg & 0xC), PRGArea.AreaC000); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(prg_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - prg_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper233.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper233.cs deleted file mode 100644 index 6cefdfc..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper233.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 233)] - internal class Mapper233 : Board - { - private int title; - - private int bank; - - internal override void HardReset() - { - base.HardReset(); - bank = (title = 0); - } - - internal override void SoftReset() - { - base.SoftReset(); - bank = 0; - title ^= 32; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - bank = data & 0x1F; - if ((data & 0x20) == 32) - { - Switch16KPRG(title | bank, PRGArea.Area8000); - Switch16KPRG(title | bank, PRGArea.AreaC000); - } - else - { - Switch32KPRG((title >> 1) | (bank >> 1), PRGArea.Area8000); - } - switch ((data >> 6) & 3) - { - case 0: - Switch01KNMT(128); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 2: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(title); - stream.Write(bank); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - title = stream.ReadInt32(); - bank = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper240.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper240.cs deleted file mode 100644 index 6dc9804..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper240.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 240)] - internal class Mapper240 : Board - { - internal override void WriteEX(ref ushort address, ref byte data) - { - Switch32KPRG((data >> 4) & 0xF, PRGArea.Area8000); - Switch08KCHR(data & 0xF); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper242.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper242.cs deleted file mode 100644 index 3ce5a23..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper242.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 242)] - internal class Mapper242 : Board - { - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch32KPRG((address >> 3) & 0xF, PRGArea.Area8000); - Switch01KNMTFromMirroring(((address & 2) == 2) ? Mirroring.Horz : Mirroring.Vert); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper243.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper243.cs deleted file mode 100644 index 2fd28e6..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper243.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Sachen Poker", 243)] - [HassIssues] - internal class Mapper243 : Board - { - private int addr; - - private int chr_reg; - - internal override string Issues => MNInterfaceLanguage.IssueMapper243; - - internal override void HardReset() - { - base.HardReset(); - addr = (chr_reg = 0); - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - if (address >= 20480 || address < 16416) - { - return; - } - switch (address & 0x4101) - { - case 16640: - addr = data & 7; - break; - case 16641: - switch (addr) - { - case 2: - chr_reg = ((data << 3) & 8) | (chr_reg & 7); - Switch08KCHR(chr_reg); - break; - case 4: - chr_reg = (data & 1) | (chr_reg & 0xE); - Switch08KCHR(chr_reg); - break; - case 5: - Switch32KPRG(data & 7, PRGArea.Area8000); - break; - case 6: - chr_reg = ((data & 3) << 1) | (chr_reg & 9); - Switch08KCHR(chr_reg); - break; - case 7: - switch ((data >> 1) & 3) - { - case 0: - Switch01KNMTFromMirroring(Mirroring.Horz); - break; - case 1: - Switch01KNMTFromMirroring(Mirroring.Vert); - break; - case 2: - Switch01KNMT(14); - break; - case 3: - Switch01KNMTFromMirroring(Mirroring.OneScB); - break; - } - break; - case 3: - break; - } - break; - } - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(addr); - stream.Write(chr_reg); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - addr = stream.ReadInt32(); - chr_reg = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper245.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper245.cs deleted file mode 100644 index 4bdbd03..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper245.cs +++ /dev/null @@ -1,229 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("C&E", 245, true, true)] - [HassIssues] - internal class Mapper245 : Board - { - private bool flag_c; - - private bool flag_p; - - private int address_8001; - - private int[] chr_reg; - - private int[] prg_reg; - - private int prg_or; - - private bool irq_enabled; - - private byte irq_counter; - - private int old_irq_counter; - - private byte irq_reload; - - private bool irq_clear; - - private bool mmc3_alt_behavior; - - internal override string Issues => MNInterfaceLanguage.IssueMapper245; - - internal override void HardReset() - { - base.HardReset(); - flag_c = (flag_p = false); - address_8001 = 0; - prg_reg = new int[4]; - prg_or = 0; - prg_reg[0] = 0; - prg_reg[1] = 1; - prg_reg[2] = PRG_ROM_08KB_Mask - 1; - prg_reg[3] = PRG_ROM_08KB_Mask; - chr_reg = new int[6]; - for (int i = 0; i < 6; i++) - { - chr_reg[i] = 0; - } - SetupPRG(); - SetupCHR(); - irq_enabled = false; - irq_counter = 0; - irq_reload = byte.MaxValue; - old_irq_counter = 0; - irq_clear = false; - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xE001) - { - case 32768: - address_8001 = data & 7; - flag_c = (data & 0x80) != 0; - flag_p = (data & 0x40) != 0; - SetupCHR(); - SetupPRG(); - break; - case 32769: - switch (address_8001) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chr_reg[address_8001] = data; - SetupCHR(); - break; - case 6: - prg_reg[0] = data & 0x3F; - SetupPRG(); - break; - case 7: - prg_reg[1] = data & 0x3F; - SetupPRG(); - break; - } - break; - case 40960: - if (NMT_DEFAULT_MIRROR != Mirroring.Full) - { - Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert); - } - break; - case 40961: - TogglePRGRAMEnable((data & 0x80) != 0); - TogglePRGRAMWritableEnable((data & 0x40) == 0); - break; - case 49152: - irq_reload = data; - break; - case 49153: - if (mmc3_alt_behavior) - { - irq_clear = true; - } - irq_counter = 0; - break; - case 57344: - irq_enabled = false; - NesEmu.IRQFlags &= -9; - break; - case 57345: - irq_enabled = true; - break; - } - } - - private void SetupCHR() - { - if (CHR_ROM_01KB_Count > 0) - { - if (!flag_c) - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area0000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area0800); - Switch01KCHR(chr_reg[2], CHRArea.Area1000); - Switch01KCHR(chr_reg[3], CHRArea.Area1400); - Switch01KCHR(chr_reg[4], CHRArea.Area1800); - Switch01KCHR(chr_reg[5], CHRArea.Area1C00); - } - else - { - Switch02KCHR(chr_reg[0] >> 1, CHRArea.Area1000); - Switch02KCHR(chr_reg[1] >> 1, CHRArea.Area1800); - Switch01KCHR(chr_reg[2], CHRArea.Area0000); - Switch01KCHR(chr_reg[3], CHRArea.Area0400); - Switch01KCHR(chr_reg[4], CHRArea.Area0800); - Switch01KCHR(chr_reg[5], CHRArea.Area0C00); - } - } - else if (!flag_c) - { - Switch04KCHR(0, CHRArea.Area0000); - Switch04KCHR(1, CHRArea.Area1000); - } - else - { - Switch04KCHR(1, CHRArea.Area0000); - Switch04KCHR(0, CHRArea.Area1000); - } - } - - private void SetupPRG() - { - prg_or = (chr_reg[0] & 2) << 5; - Switch08KPRG(prg_reg[flag_p ? 2 : 0] | prg_or, PRGArea.Area8000); - Switch08KPRG(prg_reg[1] | prg_or, PRGArea.AreaA000); - Switch08KPRG(prg_reg[(!flag_p) ? 2 : 0] | prg_or, PRGArea.AreaC000); - Switch08KPRG(prg_reg[3] | prg_or, PRGArea.AreaE000); - } - - internal override void OnPPUA12RaisingEdge() - { - old_irq_counter = irq_counter; - if (irq_counter == 0 || irq_clear) - { - irq_counter = irq_reload; - } - else - { - irq_counter--; - } - if ((!mmc3_alt_behavior || old_irq_counter != 0 || irq_clear) && irq_counter == 0 && irq_enabled) - { - NesEmu.IRQFlags |= 8; - } - irq_clear = false; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(flag_c); - stream.Write(flag_p); - stream.Write(address_8001); - for (int i = 0; i < chr_reg.Length; i++) - { - stream.Write(chr_reg[i]); - } - for (int j = 0; j < prg_reg.Length; j++) - { - stream.Write(prg_reg[j]); - } - stream.Write(irq_enabled); - stream.Write(irq_counter); - stream.Write(old_irq_counter); - stream.Write(irq_reload); - stream.Write(irq_clear); - stream.Write(prg_or); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - flag_c = stream.ReadBoolean(); - flag_p = stream.ReadBoolean(); - address_8001 = stream.ReadInt32(); - for (int i = 0; i < chr_reg.Length; i++) - { - chr_reg[i] = stream.ReadInt32(); - } - for (int j = 0; j < prg_reg.Length; j++) - { - prg_reg[j] = stream.ReadInt32(); - } - irq_enabled = stream.ReadBoolean(); - irq_counter = stream.ReadByte(); - old_irq_counter = stream.ReadInt32(); - irq_reload = stream.ReadByte(); - irq_clear = stream.ReadBoolean(); - prg_or = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper246.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper246.cs deleted file mode 100644 index c352f41..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper246.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace MyNes.Core -{ - [BoardInfo("Unknown", 246)] - internal class Mapper246 : Board - { - internal override void HardReset() - { - base.HardReset(); - Switch08KPRG(255, PRGArea.AreaE000); - } - - internal override void WriteSRM(ref ushort address, ref byte data) - { - if (address < 26624) - { - switch (address) - { - case 24576: - Switch08KPRG(data, PRGArea.Area8000); - break; - case 24577: - Switch08KPRG(data, PRGArea.AreaA000); - break; - case 24578: - Switch08KPRG(data, PRGArea.AreaC000); - break; - case 24579: - Switch08KPRG(data, PRGArea.AreaE000); - break; - case 24580: - Switch02KCHR(data, CHRArea.Area0000); - break; - case 24581: - Switch02KCHR(data, CHRArea.Area0800); - break; - case 24582: - Switch02KCHR(data, CHRArea.Area1000); - break; - case 24583: - Switch02KCHR(data, CHRArea.Area1800); - break; - } - } - else - { - base.WriteSRM(ref address, ref data); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper255.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper255.cs deleted file mode 100644 index 043df54..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper255.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - [BoardInfo("Unknown", 255)] - [HassIssues] - internal class Mapper255 : Board - { - private byte[] RAM; - - internal override string Issues => MNInterfaceLanguage.IssueMapper255; - - internal override void HardReset() - { - base.HardReset(); - RAM = new byte[4]; - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - if (address >= 22528) - { - RAM[address & 3] = (byte)(data & 0xFu); - } - } - - internal override void ReadEX(ref ushort address, out byte data) - { - if (address >= 22528) - { - data = RAM[address & 3]; - } - else - { - data = 0; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - Switch08KCHR(address & 0x3F); - if ((address & 0x1000) == 4096) - { - Switch16KPRG((address >> 6) & 0x3F, PRGArea.Area8000); - Switch16KPRG((address >> 6) & 0x3F, PRGArea.AreaC000); - } - else - { - Switch32KPRG(((address >> 6) & 0x3F) >> 1, PRGArea.Area8000); - } - Switch01KNMTFromMirroring(((address & 0x2000) == 8192) ? Mirroring.Horz : Mirroring.Vert); - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(RAM); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - stream.Read(RAM, 0, RAM.Length); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemReadAccess.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MemReadAccess.cs deleted file mode 100644 index 35e5474..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemReadAccess.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MyNes.Core -{ - internal delegate void MemReadAccess(ref ushort addr, out byte value); -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemReadAccess.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MemReadAccess.cs.meta deleted file mode 100644 index 93f9e4f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemReadAccess.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 71b28062ea32d1f41bc7a9b990155078 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemWriteAccess.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MemWriteAccess.cs deleted file mode 100644 index 2263c65..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemWriteAccess.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MyNes.Core -{ - internal delegate void MemWriteAccess(ref ushort addr, ref byte value); -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemWriteAccess.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MemWriteAccess.cs.meta deleted file mode 100644 index 1b3d5aa..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MemWriteAccess.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d731f056b42a0974bbee54ffc9333053 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mirroring.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mirroring.cs deleted file mode 100644 index 88547c9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mirroring.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MyNes.Core -{ - public enum Mirroring : byte - { - Horz = 80, - Vert = 68, - OneScA = 0, - OneScB = 85, - Full = 228 - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mirroring.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Mirroring.cs.meta deleted file mode 100644 index c033bb3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mirroring.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f22679fb7ecffc440a9aaea88226619d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNesMain.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNesMain.cs deleted file mode 100644 index eeb781b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNesMain.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class MyNesMain - { - public static EmuSettings EmuSettings { get; private set; } - public static RendererSettings RendererSettings { get; private set; } - public static IExternalSupporter Supporter { get; private set; } - public static string WorkingFolder { get; private set; } - - internal static List Boards { get; private set; } - - public static IVideoProvider VideoProvider { get; private set; } - - public static IAudioProvider AudioProvider { get; private set; } - - public static WaveRecorder WaveRecorder { get; private set; } - - public static void Initialize(IExternalSupporter fileManager, IVideoProvider videoProvider, IAudioProvider audioProvider) - { - Tracer.WriteLine("Initializing My Nes Core ...."); - Supporter = fileManager; - WorkingFolder = fileManager.GetWorkingFolderPath(); - Tracer.WriteLine("Loading emu settings ..."); - EmuSettings = new EmuSettings(Path.Combine(WorkingFolder, "emusettings.ini")); - EmuSettings.LoadSettings(); - Tracer.WriteLine("Emu settings loaded successfully."); - Tracer.WriteLine("Loading renderer settings ..."); - RendererSettings = new RendererSettings(Path.Combine(WorkingFolder, "renderersettings.ini")); - RendererSettings.LoadSettings(); - Tracer.WriteLine("Renderer settings loaded successfully."); - Tracer.WriteLine("Locating boards and providers ..."); - WaveRecorder = new WaveRecorder(); - Boards = new List(); - - var allTypes = AppDomain.CurrentDomain - .GetAssemblies() - .SelectMany(ass => ass.GetTypes()); - - VideoProvider = videoProvider; - AudioProvider = audioProvider; - foreach (var type in allTypes) - { - if (type.IsSubclassOf(typeof(Board)) && !type.IsAbstract) - { - Board board = Activator.CreateInstance(type) as Board; - Boards.Add(board); - Tracer.WriteLine("Board added: " + board.Name + " [ Mapper " + board.MapperNumber + "]"); - } - } - - Tracer.WriteInformation("Done."); - Tracer.WriteInformation("Total of " + Boards.Count + " board found."); - SetVideoProvider(); - SetAudioProvider(); - SetRenderingMethods(); - - NesEmu.Initialize(); - } - - public static void Shutdown() - { - if (NesEmu.ON) - { - NesEmu.ShutDown(); - } - if (VideoProvider != null) - { - VideoProvider.ShutDown(); - } - if (AudioProvider != null) - { - AudioProvider.ShutDown(); - } - Tracer.WriteLine("Saving settings ..."); - EmuSettings.SaveSettings(); - RendererSettings.SaveSettings(); - Tracer.WriteLine("Settings saved successfully."); - Tracer.WriteLine("Exiting My Nes."); - } - - internal static bool IsBoardExist(int mapper) - { - foreach (Board board in Boards) - { - if (board.MapperNumber == mapper) - { - return true; - } - } - return false; - } - - internal static Board GetBoard(int mapper) - { - foreach (Board board in Boards) - { - if (board.MapperNumber == mapper) - { - return board; - } - } - return null; - } - - public static void MakeWorkingFolder() - { - WorkingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyNes"); - Directory.CreateDirectory(WorkingFolder); - } - - public static BoardInfoObject[] GetBoardsList(bool includeUnsupportedMappers) - { - List list = new List(); - if (includeUnsupportedMappers) - { - for (int i = 0; i < 256; i++) - { - bool flag = false; - foreach (Board board in Boards) - { - if (board.MapperNumber == i) - { - BoardInfoObject boardInfoObject = new BoardInfoObject(); - boardInfoObject.Name = board.Name; - boardInfoObject.MapperNumber = board.MapperNumber; - boardInfoObject.IsSupported = true; - boardInfoObject.HasIssues = board.HasIssues; - boardInfoObject.Issues = board.Issues; - list.Add(boardInfoObject); - flag = true; - break; - } - } - if (!flag) - { - BoardInfoObject boardInfoObject2 = new BoardInfoObject(); - boardInfoObject2.Name = "N/A"; - boardInfoObject2.MapperNumber = i; - boardInfoObject2.IsSupported = false; - boardInfoObject2.HasIssues = false; - boardInfoObject2.Issues = ""; - list.Add(boardInfoObject2); - } - } - } - else - { - foreach (Board board2 in Boards) - { - if (board2.MapperNumber >= 0) - { - BoardInfoObject boardInfoObject3 = new BoardInfoObject(); - boardInfoObject3.Name = board2.Name; - boardInfoObject3.MapperNumber = board2.MapperNumber; - boardInfoObject3.IsSupported = true; - boardInfoObject3.HasIssues = board2.HasIssues; - boardInfoObject3.Issues = board2.Issues; - list.Add(boardInfoObject3); - } - } - } - return list.ToArray(); - } - - static void SetVideoProvider() - { - if (VideoProvider != null) VideoProvider.Initialize(); - else Tracer.WriteError("VideoProvider is null"); - } - - static void SetAudioProvider() - { - Tracer.WriteLine("Looking for the audio provider that set in the settings..."); - if (AudioProvider != null) AudioProvider.Initialize(); - else Tracer.WriteError("AudioProvider is null"); - } - - static void SetRenderingMethods() - { - if (VideoProvider != null && AudioProvider != null) - { - NesEmu.SetupRenderingMethods(VideoProvider.SubmitFrame, AudioProvider.SubmitSamples, AudioProvider.TogglePause, AudioProvider.GetIsPlaying); - } - else - { - Tracer.WriteError("ERROR: unable to setup rendering methods, one (or both) of the providers is not set (video and/or audio provider)"); - } - } - - public static void RecordWave() - { - if (NesEmu.ON && NesEmu.SoundEnabled) - { - string text = Path.Combine(EmuSettings.WavesFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath) + ".wav"); - int num = 0; - while (File.Exists(text)) - { - text = Path.Combine(EmuSettings.WavesFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath) + "_" + num + ".wav"); - num++; - } - WaveRecorder.Record(text, 1, 16, RendererSettings.Audio_Frequency); - } - else if (VideoProvider != null) - { - VideoProvider.WriteErrorNotification("Cannot record sound when the emu is off/sound is not enabled.", instant: false); - } - } - } - -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNesMain.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNesMain.cs.meta deleted file mode 100644 index 7be0a54..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNesMain.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2ef58a78e1bd9734bb820da2c5e1e471 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTArea.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/NTArea.cs deleted file mode 100644 index d829d58..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTArea.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MyNes.Core -{ - internal enum NTArea : byte - { - Area2000NT0, - Area2400NT1, - Area2800NT2, - Area2C00NT3 - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTArea.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/NTArea.cs.meta deleted file mode 100644 index 13480cb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTArea.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c3f55745b33b3de4992cb06a69a1bbce -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTSCPaletteGenerator.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/NTSCPaletteGenerator.cs deleted file mode 100644 index 356d7c2..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTSCPaletteGenerator.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; - -namespace MyNes.Core -{ - public class NTSCPaletteGenerator - { - public const float default_saturation = 1.496f; - - public const float default_hue_tweak = 0f; - - public const float default_contrast = 1.016f; - - public const float default_brightness = 1.075f; - - public const float default_gamma = 1.975f; - - private const float black = 0.518f; - - private const float white = 1.962f; - - private const float attenuation = 0.746f; - - public static float saturation = 2f; - - public static float hue_tweak = 0f; - - public static float contrast = 1.4f; - - public static float brightness = 1.07f; - - public static float gamma = 2f; - - private static float[] levels = new float[8] { 0.35f, 0.518f, 0.962f, 1.55f, 1.094f, 1.506f, 1.962f, 1.962f }; - - private static int wave(int p, int color) - { - if ((color + p + 8) % 12 >= 6) - { - return 0; - } - return 1; - } - - private static float gammafix(float f, float gamma) - { - return (float)((f < 0f) ? 0.0 : Math.Pow(f, 2.2f / gamma)); - } - - private static int clamp(float v) - { - return (int)((v < 0f) ? 0f : ((v > 255f) ? 255f : v)); - } - - public static int MakeRGBcolor(int pixel) - { - int num = pixel & 0xF; - int num2 = ((num >= 14) ? 1 : ((pixel >> 4) & 3)); - float[] array = new float[2] - { - levels[num2 + ((num == 0) ? 4 : 0)], - levels[num2 + ((num <= 12) ? 4 : 0)] - }; - float num3 = 0f; - float num4 = 0f; - float num5 = 0f; - for (int i = 0; i < 12; i++) - { - float num6 = array[wave(i, num)]; - if ((((uint)pixel & 0x40u) != 0 && wave(i, 12) == 1) || (((uint)pixel & 0x80u) != 0 && wave(i, 4) == 1) || (((uint)pixel & 0x100u) != 0 && wave(i, 8) == 1)) - { - num6 *= 0.746f; - } - float num7 = (num6 - 0.518f) / 1.444f; - num7 = (num7 - 0.5f) * contrast + 0.5f; - num7 *= brightness / 12f; - num3 += num7; - num4 += (float)((double)num7 * Math.Cos(Math.PI / 6.0 * (double)((float)i + hue_tweak))); - num5 += (float)((double)num7 * Math.Sin(Math.PI / 6.0 * (double)((float)i + hue_tweak))); - } - num4 *= saturation; - num5 *= saturation; - return 65536 * clamp(255f * gammafix(num3 + 0.946882f * num4 + 0.623557f * num5, gamma)) + 256 * clamp(255f * gammafix(num3 - 245f / (328f * (float)Math.E) * num4 - 0.635691f * num5, gamma)) + clamp(255f * gammafix(num3 - 1.108545f * num4 + 1.709007f * num5, gamma)); - } - - public static int[] GeneratePalette() - { - int[] array = new int[512]; - for (int i = 0; i < 512; i++) - { - array[i] = MakeRGBcolor(i) | -16777216; - } - return array; - } - - public static int[] GeneratePaletteGBR() - { - int[] array = new int[512]; - for (int i = 0; i < 512; i++) - { - int num = MakeRGBcolor(i); - byte b = (byte)((num & 0xFF0000) >> 16); - byte b2 = (byte)((num & 0xFF00) >> 8); - byte b3 = (byte)((uint)num & 0xFFu); - array[i] = -16777216 | (b3 << 16) | (b2 << 8) | b; - } - return array; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTSCPaletteGenerator.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/NTSCPaletteGenerator.cs.meta deleted file mode 100644 index e5cadd3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NTSCPaletteGenerator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 29be0f25cd887b349ab47194ae46b123 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106.cs deleted file mode 100644 index 9a44427..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106.cs +++ /dev/null @@ -1,557 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - [WithExternalSound] - internal abstract class Namcot106 : Board - { - private int irq_counter; - - private bool irq_enable; - - private bool disables_chr_ram_A; - - private bool disables_chr_ram_B; - - private bool enable_mirroring_switch; - - private bool enable_N106_sound; - - private int temp_nmt; - - private Namcot106Chnl[] sound_channels; - - private byte soundReg; - - public int enabledChannels; - - private int enabledChannels1; - - private int channelIndex; - - private byte temp_val; - - private byte temp_i; - - public byte[] EXRAM; - - private bool[] sound_channels_enable; - - private double soundOut; - - private int sound_out_div; - - internal override void HardReset() - { - base.HardReset(); - EXRAM = new byte[128]; - Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000); - enable_mirroring_switch = (enable_N106_sound = base.MapperNumber == 19); - switch (SHA1.ToUpper()) - { - case "97E7E61EECB73CB1EA0C15AE51E65EA56301A685": - case "3D554F55411AB2DDD1A87E7583E643970DB784F3": - case "7FA51058307DB50825C2D3A3A98C0DA554BC3C92": - case "1C476C795CFC17E987C22FFD6F09BAF1396ED2C9": - enable_mirroring_switch = false; - enable_N106_sound = false; - break; - } - if (enable_N106_sound) - { - sound_channels = new Namcot106Chnl[8]; - sound_channels_enable = new bool[8]; - for (int i = 0; i < 8; i++) - { - sound_channels[i] = new Namcot106Chnl(this); - sound_channels[i].HardReset(); - } - soundReg = 0; - enabledChannels = 0; - channelIndex = 0; - APUApplyChannelsSettings(); - } - } - - internal override void WriteEX(ref ushort address, ref byte data) - { - switch (address & 0xF800) - { - case 18432: - if (soundReg >= 64) - { - switch (soundReg & 0x7F) - { - case 64: - sound_channels[0].WriteA(ref data); - break; - case 66: - sound_channels[0].WriteB(ref data); - break; - case 68: - sound_channels[0].WriteC(ref data); - break; - case 70: - sound_channels[0].WriteD(ref data); - break; - case 71: - sound_channels[0].WriteE(ref data); - break; - case 72: - sound_channels[1].WriteA(ref data); - break; - case 74: - sound_channels[1].WriteB(ref data); - break; - case 76: - sound_channels[1].WriteC(ref data); - break; - case 78: - sound_channels[1].WriteD(ref data); - break; - case 79: - sound_channels[1].WriteE(ref data); - break; - case 80: - sound_channels[2].WriteA(ref data); - break; - case 82: - sound_channels[2].WriteB(ref data); - break; - case 84: - sound_channels[2].WriteC(ref data); - break; - case 86: - sound_channels[2].WriteD(ref data); - break; - case 87: - sound_channels[2].WriteE(ref data); - break; - case 88: - sound_channels[3].WriteA(ref data); - break; - case 90: - sound_channels[3].WriteB(ref data); - break; - case 92: - sound_channels[3].WriteC(ref data); - break; - case 94: - sound_channels[3].WriteD(ref data); - break; - case 95: - sound_channels[3].WriteE(ref data); - break; - case 96: - sound_channels[4].WriteA(ref data); - break; - case 98: - sound_channels[4].WriteB(ref data); - break; - case 100: - sound_channels[4].WriteC(ref data); - break; - case 102: - sound_channels[4].WriteD(ref data); - break; - case 103: - sound_channels[4].WriteE(ref data); - break; - case 104: - sound_channels[5].WriteA(ref data); - break; - case 106: - sound_channels[5].WriteB(ref data); - break; - case 108: - sound_channels[5].WriteC(ref data); - break; - case 110: - sound_channels[5].WriteD(ref data); - break; - case 111: - sound_channels[5].WriteE(ref data); - break; - case 112: - sound_channels[6].WriteA(ref data); - break; - case 114: - sound_channels[6].WriteB(ref data); - break; - case 116: - sound_channels[6].WriteC(ref data); - break; - case 118: - sound_channels[6].WriteD(ref data); - break; - case 119: - sound_channels[6].WriteE(ref data); - break; - case 120: - sound_channels[7].WriteA(ref data); - break; - case 122: - sound_channels[7].WriteB(ref data); - break; - case 124: - sound_channels[7].WriteC(ref data); - break; - case 126: - sound_channels[7].WriteD(ref data); - break; - case 127: - sound_channels[7].WriteE(ref data); - enabledChannels = (data & 0x70) >> 4; - channelIndex = 0; - enabledChannels1 = enabledChannels + 1; - temp_i = 7; - while (temp_i >= 0 && enabledChannels1 > 0) - { - sound_channels[temp_i].Enabled = true; - enabledChannels1--; - temp_i--; - } - break; - } - } - EXRAM[soundReg & 0x7F] = data; - if ((soundReg & 0x80) == 128) - { - soundReg = (byte)(((uint)(soundReg + 1) & 0x7Fu) | 0x80u); - } - break; - case 20480: - NesEmu.IRQFlags &= -9; - irq_counter = (irq_counter & 0x7F00) | data; - break; - case 22528: - NesEmu.IRQFlags &= -9; - irq_counter = (irq_counter & 0xFF) | ((data & 0x7F) << 8); - irq_enable = (data & 0x80) == 128; - break; - } - } - - internal override void ReadEX(ref ushort address, out byte value) - { - switch (address & 0xF800) - { - case 18432: - value = EXRAM[soundReg & 0x7F]; - if ((soundReg & 0x80) == 128) - { - soundReg = (byte)(((uint)(soundReg + 1) & 0x7Fu) | 0x80u); - } - break; - case 20480: - NesEmu.IRQFlags &= -9; - value = (byte)((uint)irq_counter & 0xFFu); - break; - case 22528: - NesEmu.IRQFlags &= -9; - value = (byte)((irq_enable ? 128u : 0u) | (uint)((irq_counter & 0x7F00) >> 8)); - break; - default: - value = 0; - break; - } - } - - internal override void WritePRG(ref ushort address, ref byte data) - { - switch (address & 0xF800) - { - case 32768: - if (!disables_chr_ram_A) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area0000); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area0000); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area0000); - Switch01KCHR(data, CHRArea.Area0000); - } - break; - case 34816: - if (!disables_chr_ram_A) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area0400); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area0400); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area0400); - Switch01KCHR(data, CHRArea.Area0400); - } - break; - case 36864: - if (!disables_chr_ram_A) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area0800); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area0800); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area0800); - Switch01KCHR(data, CHRArea.Area0800); - } - break; - case 38912: - if (!disables_chr_ram_A) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area0C00); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area0C00); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area0C00); - Switch01KCHR(data, CHRArea.Area0C00); - } - break; - case 40960: - if (!disables_chr_ram_B) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area1000); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area1000); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area1000); - Switch01KCHR(data, CHRArea.Area1000); - } - break; - case 43008: - if (!disables_chr_ram_B) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area1400); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area1400); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area1400); - Switch01KCHR(data, CHRArea.Area1400); - } - break; - case 45056: - if (!disables_chr_ram_B) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area1800); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area1800); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area1800); - Switch01KCHR(data, CHRArea.Area1800); - } - break; - case 47104: - if (!disables_chr_ram_B) - { - Toggle01KCHR_RAM(data >= 224, CHRArea.Area1C00); - Switch01KCHR((data >= 224) ? (data - 224) : data, CHRArea.Area1C00); - } - else - { - Toggle01KCHR_RAM(ram: false, CHRArea.Area1C00); - Switch01KCHR(data, CHRArea.Area1C00); - } - break; - case 49152: - if (enable_mirroring_switch) - { - NMT_AREA_BLK_INDEX[0] = data; - } - break; - case 51200: - if (enable_mirroring_switch) - { - NMT_AREA_BLK_INDEX[1] = data; - } - break; - case 53248: - if (enable_mirroring_switch) - { - NMT_AREA_BLK_INDEX[2] = data; - } - break; - case 55296: - if (enable_mirroring_switch) - { - NMT_AREA_BLK_INDEX[3] = data; - } - break; - case 57344: - Switch08KPRG(data & 0x3F, PRGArea.Area8000); - break; - case 59392: - Switch08KPRG(data & 0x3F, PRGArea.AreaA000); - disables_chr_ram_A = (data & 0x40) == 64; - disables_chr_ram_B = (data & 0x80) == 128; - break; - case 61440: - Switch08KPRG(data & 0x3F, PRGArea.AreaC000); - break; - case 63488: - soundReg = data; - break; - } - } - - internal override void ReadNMT(ref ushort address, out byte data) - { - if (enable_mirroring_switch) - { - temp_nmt = NMT_AREA_BLK_INDEX[(address >> 10) & 3]; - if (temp_nmt >= 224) - { - data = NMT_RAM[(temp_nmt - 224) & 1][address & 0x3FF]; - } - else - { - data = CHR_ROM[temp_nmt][address & 0x3FF]; - } - } - else - { - base.ReadNMT(ref address, out data); - } - } - - internal override void WriteNMT(ref ushort address, ref byte data) - { - if (enable_mirroring_switch) - { - temp_nmt = NMT_AREA_BLK_INDEX[(address >> 10) & 3]; - if (temp_nmt >= 224) - { - NMT_RAM[(temp_nmt - 224) & 1][address & 0x3FF] = data; - } - } - else - { - base.WriteNMT(ref address, ref data); - } - } - - internal override void OnCPUClock() - { - if (irq_enable) - { - if (irq_counter == 32767) - { - NesEmu.IRQFlags |= 8; - irq_counter = 0; - } - else - { - irq_counter++; - } - } - } - - internal override void OnAPUClockSingle() - { - if (sound_channels != null) - { - for (int i = 0; i < sound_channels.Length; i++) - { - sound_channels[i].ClockSingle(); - } - } - } - - internal override double APUGetSample() - { - soundOut = 0.0; - sound_out_div = 0; - if (enabledChannels > 0) - { - for (int i = 0; i < sound_channels.Length; i++) - { - if (sound_channels[i].Enabled && sound_channels_enable[i]) - { - if (sound_channels[i].clocks > 0) - { - sound_channels[i].output = sound_channels[i].output_av / sound_channels[i].clocks; - } - sound_channels[i].clocks = (sound_channels[i].output_av = 0); - soundOut += sound_channels[i].output; - sound_out_div++; - } - } - soundOut = soundOut / 8.0 / 225.0; - } - return soundOut; - } - - internal override void APUApplyChannelsSettings() - { - base.APUApplyChannelsSettings(); - sound_channels_enable[0] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT1; - sound_channels_enable[1] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT2; - sound_channels_enable[2] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT3; - sound_channels_enable[3] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT4; - sound_channels_enable[4] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT5; - sound_channels_enable[5] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT6; - sound_channels_enable[6] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT7; - sound_channels_enable[7] = MyNesMain.RendererSettings.Audio_ChannelEnabled_NMT8; - } - - internal override void WriteStateData(ref BinaryWriter stream) - { - base.WriteStateData(ref stream); - stream.Write(irq_counter); - stream.Write(irq_enable); - stream.Write(disables_chr_ram_A); - stream.Write(disables_chr_ram_B); - stream.Write(enable_mirroring_switch); - stream.Write(enable_N106_sound); - stream.Write(temp_nmt); - if (enable_N106_sound) - { - for (int i = 0; i < sound_channels.Length; i++) - { - sound_channels[i].SaveState(stream); - } - } - stream.Write(soundReg); - stream.Write(enabledChannels); - stream.Write(enabledChannels1); - stream.Write(channelIndex); - stream.Write(temp_val); - stream.Write(temp_i); - stream.Write(EXRAM); - } - - internal override void ReadStateData(ref BinaryReader stream) - { - base.ReadStateData(ref stream); - irq_counter = stream.ReadInt32(); - irq_enable = stream.ReadBoolean(); - disables_chr_ram_A = stream.ReadBoolean(); - disables_chr_ram_B = stream.ReadBoolean(); - enable_mirroring_switch = stream.ReadBoolean(); - enable_N106_sound = stream.ReadBoolean(); - temp_nmt = stream.ReadInt32(); - if (enable_N106_sound) - { - for (int i = 0; i < sound_channels.Length; i++) - { - sound_channels[i].LoadState(stream); - } - } - soundReg = stream.ReadByte(); - enabledChannels = stream.ReadInt32(); - enabledChannels1 = stream.ReadInt32(); - channelIndex = stream.ReadInt32(); - temp_val = stream.ReadByte(); - temp_i = stream.ReadByte(); - stream.Read(EXRAM, 0, EXRAM.Length); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106.cs.meta deleted file mode 100644 index c0890af..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dd8e287326f773a47afba9c9ca5dac87 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106Chnl.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106Chnl.cs deleted file mode 100644 index 945e7fd..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106Chnl.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System.IO; - -namespace MyNes.Core -{ - internal class Namcot106Chnl - { - private Namcot106 namcot; - - private int freqTimer; - - private int frequency; - - public int output; - - public int output_av; - - public int clocks; - - private int cycles; - - private int InstrumentLength; - - private byte InstrumentAddress; - - private int startPoint; - - private int endPoint; - - private int readPoint; - - public int volume; - - private bool freez; - - public bool Enabled { get; set; } - - public Namcot106Chnl(Namcot106 namcot) - { - this.namcot = namcot; - } - - public void HardReset() - { - } - - private void UpdateFrequency() - { - if (frequency > 0) - { - freqTimer = 983040 * (namcot.enabledChannels + 1) / frequency; - freez = false; - } - else - { - freez = true; - output_av = 0; - } - } - - private void UpdatePlaybackParameters() - { - startPoint = InstrumentAddress; - endPoint = InstrumentAddress + 4 * (8 - InstrumentLength); - readPoint = InstrumentAddress; - } - - public void WriteA(ref byte data) - { - frequency = (frequency & 0xFFFF00) | data; - UpdateFrequency(); - } - - public void WriteB(ref byte data) - { - frequency = (frequency & 0xFF00FF) | (data << 8); - UpdateFrequency(); - } - - public void WriteC(ref byte data) - { - frequency = (frequency & 0xFFFF) | ((data & 3) << 12); - InstrumentLength = (data >> 2) & 7; - UpdateFrequency(); - UpdatePlaybackParameters(); - } - - public void WriteD(ref byte data) - { - InstrumentAddress = data; - UpdatePlaybackParameters(); - } - - public void WriteE(ref byte data) - { - volume = data & 0xF; - } - - public void ClockSingle() - { - if (freez || --cycles > 0) - { - return; - } - cycles = freqTimer; - if (readPoint >= startPoint && readPoint <= endPoint) - { - if (Enabled && !freez) - { - if ((readPoint & 1) == 0) - { - output_av += (namcot.EXRAM[readPoint] & 0xF) * volume; - } - else - { - output_av += ((namcot.EXRAM[readPoint] >> 4) & 0xF) * volume; - } - } - readPoint++; - } - else - { - readPoint = startPoint; - } - clocks++; - } - - public void SaveState(BinaryWriter stream) - { - stream.Write(freqTimer); - stream.Write(frequency); - stream.Write(output); - stream.Write(cycles); - stream.Write(InstrumentLength); - stream.Write(InstrumentAddress); - stream.Write(startPoint); - stream.Write(endPoint); - stream.Write(readPoint); - stream.Write(volume); - stream.Write(freez); - } - - public void LoadState(BinaryReader stream) - { - freqTimer = stream.ReadInt32(); - frequency = stream.ReadInt32(); - output = stream.ReadByte(); - cycles = stream.ReadInt32(); - InstrumentLength = stream.ReadInt32(); - InstrumentAddress = stream.ReadByte(); - startPoint = stream.ReadInt32(); - endPoint = stream.ReadInt32(); - readPoint = stream.ReadInt32(); - volume = stream.ReadInt32(); - freez = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106Chnl.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106Chnl.cs.meta deleted file mode 100644 index 86980e7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Namcot106Chnl.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 609941ad8b89ba84c81aab729de7eded -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabase.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabase.cs deleted file mode 100644 index cf42c2e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabase.cs +++ /dev/null @@ -1,331 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Xml; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class NesCartDatabase - { - private static List _databaseRoms = new List(); - - public static string DBVersion = ""; - - public static string DBConformance = ""; - - public static string DBAgent = ""; - - public static string DBAuthor = ""; - - public static string DBTimeStamp = ""; - - public static bool Ready = false; - - public static List DatabaseRoms => _databaseRoms; - - public static void LoadDatabase(out bool success) - { - success = false; - Ready = false; - _databaseRoms.Clear(); - - var stream = MyNesMain.Supporter.OpenDatabaseFile(); - XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); - xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore; - xmlReaderSettings.IgnoreWhitespace = true; - XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings); - NesCartDatabaseGameInfo nesCartDatabaseGameInfo = default(NesCartDatabaseGameInfo); - nesCartDatabaseGameInfo.Cartridges = new List(); - nesCartDatabaseGameInfo.Game_AltName = ""; - nesCartDatabaseGameInfo.Game_Catalog = ""; - nesCartDatabaseGameInfo.Game_Class = ""; - nesCartDatabaseGameInfo.Game_Developer = ""; - nesCartDatabaseGameInfo.Game_Name = ""; - nesCartDatabaseGameInfo.Game_Players = ""; - nesCartDatabaseGameInfo.Game_Publisher = ""; - nesCartDatabaseGameInfo.Game_Region = ""; - nesCartDatabaseGameInfo.Game_ReleaseDate = ""; - while (xmlReader.Read()) - { - if ((xmlReader.Name == "xml") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("version")) - { - DBVersion = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("conformance")) - { - DBConformance = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("agent")) - { - DBAgent = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("author")) - { - DBAuthor = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("timestamp")) - { - DBTimeStamp = xmlReader.Value; - } - } - else - { - if (!((xmlReader.Name == "game") & xmlReader.IsStartElement())) - { - continue; - } - nesCartDatabaseGameInfo = default(NesCartDatabaseGameInfo); - if (xmlReader.MoveToAttribute("name")) - { - nesCartDatabaseGameInfo.Game_Name = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("altname")) - { - nesCartDatabaseGameInfo.Game_AltName = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("class")) - { - nesCartDatabaseGameInfo.Game_Class = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("catalog")) - { - nesCartDatabaseGameInfo.Game_Catalog = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("publisher")) - { - nesCartDatabaseGameInfo.Game_Publisher = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("developer")) - { - nesCartDatabaseGameInfo.Game_Developer = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("region")) - { - nesCartDatabaseGameInfo.Game_Region = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("players")) - { - nesCartDatabaseGameInfo.Game_Players = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("date")) - { - nesCartDatabaseGameInfo.Game_ReleaseDate = xmlReader.Value; - } - NesCartDatabaseCartridgeInfo nesCartDatabaseCartridgeInfo = new NesCartDatabaseCartridgeInfo(); - nesCartDatabaseCartridgeInfo.PAD_h = ""; - nesCartDatabaseCartridgeInfo.PAD_v = ""; - nesCartDatabaseCartridgeInfo.PRG_crc = ""; - nesCartDatabaseCartridgeInfo.PRG_name = ""; - nesCartDatabaseCartridgeInfo.PRG_sha1 = ""; - nesCartDatabaseCartridgeInfo.PRG_size = ""; - nesCartDatabaseCartridgeInfo.chip_type = new List(); - nesCartDatabaseCartridgeInfo.CHR_crc = ""; - nesCartDatabaseCartridgeInfo.CHR_name = ""; - nesCartDatabaseCartridgeInfo.CHR_sha1 = ""; - nesCartDatabaseCartridgeInfo.CHR_size = ""; - nesCartDatabaseCartridgeInfo.CIC_type = ""; - nesCartDatabaseCartridgeInfo.Board_Mapper = ""; - nesCartDatabaseCartridgeInfo.Board_Pcb = ""; - nesCartDatabaseCartridgeInfo.Board_Type = ""; - nesCartDatabaseCartridgeInfo.VRAM_sizes = new List(); - nesCartDatabaseCartridgeInfo.WRAMBanks = new List(); - while (xmlReader.Read()) - { - if ((xmlReader.Name == "game") & !xmlReader.IsStartElement()) - { - _databaseRoms.Add(nesCartDatabaseGameInfo); - break; - } - if ((xmlReader.Name == "cartridge") & xmlReader.IsStartElement()) - { - if (nesCartDatabaseGameInfo.Cartridges == null) - { - nesCartDatabaseGameInfo.Cartridges = new List(); - } - nesCartDatabaseCartridgeInfo = new NesCartDatabaseCartridgeInfo(); - nesCartDatabaseCartridgeInfo.PAD_h = ""; - nesCartDatabaseCartridgeInfo.PAD_v = ""; - nesCartDatabaseCartridgeInfo.PRG_crc = ""; - nesCartDatabaseCartridgeInfo.PRG_name = ""; - nesCartDatabaseCartridgeInfo.PRG_sha1 = ""; - nesCartDatabaseCartridgeInfo.PRG_size = ""; - nesCartDatabaseCartridgeInfo.chip_type = new List(); - nesCartDatabaseCartridgeInfo.CHR_crc = ""; - nesCartDatabaseCartridgeInfo.CHR_name = ""; - nesCartDatabaseCartridgeInfo.CHR_sha1 = ""; - nesCartDatabaseCartridgeInfo.CHR_size = ""; - nesCartDatabaseCartridgeInfo.CIC_type = ""; - nesCartDatabaseCartridgeInfo.Board_Mapper = ""; - nesCartDatabaseCartridgeInfo.Board_Pcb = ""; - nesCartDatabaseCartridgeInfo.Board_Type = ""; - nesCartDatabaseCartridgeInfo.VRAM_sizes = new List(); - nesCartDatabaseCartridgeInfo.WRAMBanks = new List(); - if (xmlReader.MoveToAttribute("system")) - { - nesCartDatabaseCartridgeInfo.System = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("crc")) - { - nesCartDatabaseCartridgeInfo.CRC = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("sha1")) - { - nesCartDatabaseCartridgeInfo.SHA1 = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("dump")) - { - nesCartDatabaseCartridgeInfo.Dump = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("dumper")) - { - nesCartDatabaseCartridgeInfo.Dumper = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("datedumped")) - { - nesCartDatabaseCartridgeInfo.DateDumped = xmlReader.Value; - } - } - else if ((xmlReader.Name == "cartridge") & !xmlReader.IsStartElement()) - { - nesCartDatabaseGameInfo.Cartridges.Add(nesCartDatabaseCartridgeInfo); - } - else if ((xmlReader.Name == "board") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("type")) - { - nesCartDatabaseCartridgeInfo.Board_Type = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("pcb")) - { - nesCartDatabaseCartridgeInfo.Board_Pcb = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("mapper")) - { - nesCartDatabaseCartridgeInfo.Board_Mapper = xmlReader.Value; - } - } - else if ((xmlReader.Name == "prg") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("name")) - { - nesCartDatabaseCartridgeInfo.PRG_name = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("size")) - { - nesCartDatabaseCartridgeInfo.PRG_size = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("crc")) - { - nesCartDatabaseCartridgeInfo.PRG_crc = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("sha1")) - { - nesCartDatabaseCartridgeInfo.PRG_sha1 = xmlReader.Value; - } - } - else if ((xmlReader.Name == "chr") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("name")) - { - nesCartDatabaseCartridgeInfo.CHR_name = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("size")) - { - nesCartDatabaseCartridgeInfo.CHR_size = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("crc")) - { - nesCartDatabaseCartridgeInfo.CHR_crc = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("sha1")) - { - nesCartDatabaseCartridgeInfo.CHR_sha1 = xmlReader.Value; - } - } - else if ((xmlReader.Name == "vram") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("size")) - { - nesCartDatabaseCartridgeInfo.VRAM_sizes.Add(xmlReader.Value); - } - } - else if ((xmlReader.Name == "wram") & xmlReader.IsStartElement()) - { - string sIZE = ""; - bool bATTERY = false; - int result = 0; - if (xmlReader.MoveToAttribute("size")) - { - sIZE = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("battery")) - { - bATTERY = xmlReader.Value == "1"; - } - if (xmlReader.MoveToAttribute("id")) - { - int.TryParse(xmlReader.Value, out result); - } - nesCartDatabaseCartridgeInfo.WRAMBanks.Add(new SRAMBankInfo(result, sIZE, bATTERY)); - } - else if ((xmlReader.Name == "chip") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("type")) - { - if (nesCartDatabaseCartridgeInfo.chip_type == null) - { - nesCartDatabaseCartridgeInfo.chip_type = new List(); - } - nesCartDatabaseCartridgeInfo.chip_type.Add(xmlReader.Value); - } - } - else if ((xmlReader.Name == "cic") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("type")) - { - nesCartDatabaseCartridgeInfo.CIC_type = xmlReader.Value; - } - } - else if ((xmlReader.Name == "pad") & xmlReader.IsStartElement()) - { - if (xmlReader.MoveToAttribute("h")) - { - nesCartDatabaseCartridgeInfo.PAD_h = xmlReader.Value; - } - if (xmlReader.MoveToAttribute("v")) - { - nesCartDatabaseCartridgeInfo.PAD_v = xmlReader.Value; - } - } - } - } - } - Ready = true; - success = true; - xmlReader.Close(); - stream.Close(); - } - - public static NesCartDatabaseGameInfo Find(string Cart_sha1, out bool found) - { - found = false; - foreach (NesCartDatabaseGameInfo databaseRom in _databaseRoms) - { - foreach (NesCartDatabaseCartridgeInfo cartridge in databaseRom.Cartridges) - { - if (cartridge.SHA1.ToLower() == Cart_sha1.ToLower()) - { - found = true; - return databaseRom; - } - } - } - return default(NesCartDatabaseGameInfo); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabase.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabase.cs.meta deleted file mode 100644 index 513535b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3e7570468c0a69b41b986d9624f1e8ac -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseCartridgeInfo.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseCartridgeInfo.cs deleted file mode 100644 index 3759c2c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseCartridgeInfo.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class NesCartDatabaseCartridgeInfo - { - public string System; - - public string CRC; - - public string SHA1; - - public string Dump; - - public string Dumper; - - public string DateDumped; - - public string Board_Type; - - public string Board_Pcb; - - public string Board_Mapper; - - public List VRAM_sizes; - - public List WRAMBanks; - - public string PRG_name; - - public string PRG_size; - - public string PRG_crc; - - public string PRG_sha1; - - public string CHR_name; - - public string CHR_size; - - public string CHR_crc; - - public string CHR_sha1; - - public List chip_type; - - public string CIC_type; - - public string PAD_h; - - public string PAD_v; - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseCartridgeInfo.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseCartridgeInfo.cs.meta deleted file mode 100644 index 115630f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseCartridgeInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6bd7965d8d1e7144995a612d1a42d260 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseGameInfo.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseGameInfo.cs deleted file mode 100644 index ee111ea..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseGameInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public struct NesCartDatabaseGameInfo - { - public string Game_Name; - - public string Game_AltName; - - public string Game_Class; - - public string Game_Catalog; - - public string Game_Publisher; - - public string Game_Developer; - - public string Game_Region; - - public string Game_Players; - - public string Game_ReleaseDate; - - public List Cartridges; - - public static NesCartDatabaseGameInfo Empty => default(NesCartDatabaseGameInfo); - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseGameInfo.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseGameInfo.cs.meta deleted file mode 100644 index ea2beb7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesCartDatabaseGameInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 304f3d587a65dad48a326a1431d975e1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesEmu.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesEmu.cs deleted file mode 100644 index 8b2e57e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesEmu.cs +++ /dev/null @@ -1,5750 +0,0 @@ -using Google.Protobuf.WellKnownTypes; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Threading; -using System.Xml; -using Unity.IL2CPP.CompilerServices; -using Option = Unity.IL2CPP.CompilerServices.Option; - - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class NesEmu - { - [StructLayout(LayoutKind.Explicit)] - private struct CPURegister - { - [FieldOffset(0)] - internal byte l; - - [FieldOffset(1)] - internal byte h; - - [FieldOffset(0)] - internal ushort v; - } - - private enum RequestMode - { - None, - HardReset, - SoftReset, - LoadState, - SaveState, - TakeSnapshot - } - - private static int[][] dmc_freq_table = new int[3][] - { - new int[16] - { - 428, 380, 340, 320, 286, 254, 226, 214, 190, 160, - 142, 128, 106, 84, 72, 54 - }, - new int[16] - { - 398, 354, 316, 298, 276, 236, 210, 198, 176, 148, - 132, 118, 98, 78, 66, 50 - }, - new int[16] - { - 428, 380, 340, 320, 286, 254, 226, 214, 190, 160, - 142, 128, 106, 84, 72, 54 - } - }; - - private static int dmc_output_a; - - private static int dmc_output; - - private static int dmc_period_devider; - - private static bool dmc_irq_enabled; - - private static bool dmc_loop_flag; - - private static byte dmc_rate_index; - - private static ushort dmc_addr_refresh; - - private static int dmc_size_refresh; - - private static bool dmc_dmaEnabled; - - private static byte dmc_dmaByte; - - private static int dmc_dmaBits; - - private static bool dmc_bufferFull; - - private static byte dmc_dmaBuffer; - - private static int dmc_dmaSize; - - private static ushort dmc_dmaAddr; - - private static ushort[][] nos_freq_table = new ushort[3][] - { - new ushort[16] - { - 4, 8, 16, 32, 64, 96, 128, 160, 202, 254, - 380, 508, 762, 1016, 2034, 4068 - }, - new ushort[16] - { - 4, 7, 14, 30, 60, 88, 118, 148, 188, 236, - 354, 472, 708, 944, 1890, 3778 - }, - new ushort[16] - { - 4, 8, 16, 32, 64, 96, 128, 160, 202, 254, - 380, 508, 762, 1016, 2034, 4068 - } - }; - - private static bool nos_length_halt; - - private static bool nos_constant_volume_envelope; - - private static byte nos_volume_devider_period; - - private static ushort nos_timer; - - private static bool nos_mode; - - private static int nos_period_devider; - - private static bool nos_length_enabled; - - private static int nos_length_counter; - - private static bool nos_envelope_start_flag; - - private static byte nos_envelope_devider; - - private static byte nos_envelope_decay_level_counter; - - private static byte nos_envelope; - - private static int nos_output; - - private static int nos_shift_reg; - - private static int nos_feedback; - - private static bool nos_ignore_reload; - - private static readonly byte[][] sq_duty_cycle_sequences = new byte[4][] - { - new byte[8] { 0, 0, 0, 0, 0, 0, 0, 1 }, - new byte[8] { 0, 0, 0, 0, 0, 0, 1, 1 }, - new byte[8] { 0, 0, 0, 0, 1, 1, 1, 1 }, - new byte[8] { 1, 1, 1, 1, 1, 1, 0, 0 } - }; - - private static readonly byte[] sq_duration_table = new byte[32] - { - 10, 254, 20, 2, 40, 4, 80, 6, 160, 8, - 60, 10, 14, 12, 26, 14, 12, 16, 24, 18, - 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, - 32, 30 - }; - - private static byte sq1_duty_cycle; - - private static bool sq1_length_halt; - - private static bool sq1_constant_volume_envelope; - - private static byte sq1_volume_devider_period; - - private static bool sq1_sweep_enable; - - private static byte sq1_sweep_devider_period; - - private static bool sq1_sweep_negate; - - private static byte sq1_sweep_shift_count; - - private static int sq1_timer; - - private static int sq1_period_devider; - - private static byte sq1_seqencer; - - private static bool sq1_length_enabled; - - private static int sq1_length_counter; - - private static bool sq1_envelope_start_flag; - - private static byte sq1_envelope_devider; - - private static byte sq1_envelope_decay_level_counter; - - private static byte sq1_envelope; - - private static int sq1_sweep_counter; - - private static bool sq1_sweep_reload; - - private static int sq1_sweep_change; - - private static bool sq1_valid_freq; - - private static int sq1_output; - - private static bool sq1_ignore_reload; - - private static readonly byte[] trl_step_seq = new byte[32] - { - 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 - }; - - private static bool trl_liner_control_flag; - - private static byte trl_liner_control_reload; - - private static ushort trl_timer; - - private static bool trl_length_enabled; - - private static byte trl_length_counter; - - private static bool trl_liner_control_reload_flag; - - private static byte trl_liner_counter; - - private static int trl_output; - - private static int trl_period_devider; - - private static int trl_step; - - private static bool trl_ignore_reload; - - private static byte apu_reg_io_db; - - private static byte apu_reg_io_addr; - - private static bool apu_reg_access_happened; - - private static bool apu_reg_access_w; - - private static Action[] apu_reg_update_func; - - private static Action[] apu_reg_read_func; - - private static Action[] apu_reg_write_func; - - private static Action apu_update_playback_func; - - private static bool apu_odd_cycle; - - private static bool apu_irq_enabled; - - private static bool apu_irq_flag; - - internal static bool apu_irq_delta_occur; - - private static bool apu_seq_mode; - - private static int apu_ferq_f; - - private static int apu_ferq_l; - - private static int apu_ferq_e; - - private static int apu_cycle_f; - - private static int apu_cycle_f_t; - - private static int apu_cycle_e; - - private static int apu_cycle_l; - - private static bool apu_odd_l; - - private static bool apu_check_irq; - - private static bool apu_do_env; - - private static bool apu_do_length; - - public static bool SoundEnabled; - - public static double audio_playback_amplitude = 1.5; - - public static int audio_playback_peek_limit = 124; - - private static bool audio_playback_dac_initialized; - - public static int cpu_speed; - - private static short[] audio_samples; - - private static int audio_w_pos; - - private static int audio_samples_added; - - internal static int audio_samples_count; - - private static int[][][][][] mix_table; - - private static double audio_x; - - private static double audio_y; - - private static double audio_y_av; - - private static double audio_y_timer; - - public static double audio_timer_ratio = 40.0; - - private static double audio_timer; - - private static SoundLowPassFilter audio_low_pass_filter_14K; - - private static SoundHighPassFilter audio_high_pass_filter_90; - - private static SoundHighPassFilter audio_high_pass_filter_440; - - private static bool audio_sq1_outputable; - - private static bool audio_sq2_outputable; - - private static bool audio_nos_outputable; - - private static bool audio_trl_outputable; - - private static bool audio_dmc_outputable; - - private static bool audio_signal_outputed; - - private static bool apu_use_external_sound; - - private static CPURegister cpu_reg_pc; - - private static CPURegister cpu_reg_sp; - - private static CPURegister cpu_reg_ea; - - private static byte cpu_reg_a; - - private static byte cpu_reg_x; - - private static byte cpu_reg_y; - - private static bool cpu_flag_n; - - private static bool cpu_flag_v; - - private static bool cpu_flag_d; - - private static bool cpu_flag_i; - - private static bool cpu_flag_z; - - private static bool cpu_flag_c; - - private static byte cpu_m; - - private static byte cpu_opcode; - - private static byte cpu_byte_temp; - - private static int cpu_int_temp; - - private static int cpu_int_temp1; - - private static byte cpu_dummy; - - private static bool cpu_bool_tmp; - - private static CPURegister temp_add; - - private static bool CPU_IRQ_PIN; - - private static bool CPU_NMI_PIN; - - private static bool cpu_suspend_nmi; - - private static bool cpu_suspend_irq; - - private static Action[] cpu_addressings; - - private static Action[] cpu_instructions; - - private static int dma_DMCDMAWaitCycles; - - private static int dma_OAMDMAWaitCycles; - - private static bool dma_isOamDma; - - private static int dma_oamdma_i; - - private static bool dma_DMCOn; - - private static bool dma_OAMOn; - - private static bool dma_DMC_occurring; - - private static bool dma_OAM_occurring; - - private static int dma_OAMFinishCounter; - - private static ushort dma_Oamaddress; - - private static int dma_OAMCYCLE; - - private static byte dma_latch; - - private static byte dma_dummy; - - private static ushort reg_2004; - - internal static int IRQFlags = 0; - - private static bool PPU_NMI_Current; - - private static bool PPU_NMI_Old; - - private const int IRQ_APU = 1; - - internal const int IRQ_DMC = 2; - - internal const int IRQ_BOARD = 8; - - private static ushort InterruptVector; - - private static byte[] mem_wram; - - internal static Board mem_board; - - private static MemReadAccess[] mem_read_accesses; - - private static MemWriteAccess[] mem_write_accesses; - - private static bool BUS_RW; - - private static ushort BUS_ADDRESS; - - private static string SRAMFileName; - - public static string GMFileName; - - private static int PORT0; - - private static int PORT1; - - private static int inputStrobe; - - private static IJoypadConnecter joypad1; - - private static IJoypadConnecter joypad2; - - private static IJoypadConnecter joypad3; - - private static IJoypadConnecter joypad4; - - public static bool IsFourPlayers; - - private static readonly byte[] reverseLookup = new byte[256] - { - 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, - 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, - 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, - 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, - 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, - 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, - 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, - 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, - 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, - 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, - 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, - 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, - 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, - 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, - 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, - 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, - 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, - 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, - 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, - 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, - 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, - 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, - 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, - 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, - 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, - 95, 223, 63, 191, 127, 255 - }; - - private static Action[] ppu_v_clocks; - - private static Action[] ppu_h_clocks; - - private static Action[] ppu_bkg_fetches; - - private static Action[] ppu_spr_fetches; - - private static Action[] ppu_oam_phases; - - private static int[] ppu_bkg_pixels; - - private static int[] ppu_spr_pixels; - - private static int[] ppu_screen_pixels; - - private static int[] ppu_palette; - - private static int ppu_clock_h; - - internal static ushort ppu_clock_v; - - private static ushort ppu_clock_vblank_start; - - private static ushort ppu_clock_vblank_end; - - private static bool ppu_use_odd_cycle; - - private static bool ppu_use_odd_swap; - - private static bool ppu_odd_swap_done; - - private static bool ppu_is_nmi_time; - - private static bool ppu_frame_finished; - - private static byte[] ppu_oam_bank; - - private static byte[] ppu_oam_bank_secondary; - - private static byte[] ppu_palette_bank; - - private static byte ppu_reg_io_db; - - private static byte ppu_reg_io_addr; - - private static bool ppu_reg_access_happened; - - private static bool ppu_reg_access_w; - - private static Action[] ppu_reg_update_func; - - private static Action[] ppu_reg_read_func; - - private static byte ppu_reg_2000_vram_address_increament; - - private static ushort ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites; - - private static ushort ppu_reg_2000_background_pattern_table_address; - - internal static byte ppu_reg_2000_Sprite_size; - - private static bool ppu_reg_2000_VBI; - - private static bool ppu_reg_2001_show_background_in_leftmost_8_pixels_of_screen; - - private static bool ppu_reg_2001_show_sprites_in_leftmost_8_pixels_of_screen; - - private static bool ppu_reg_2001_show_background; - - private static bool ppu_reg_2001_show_sprites; - - private static int ppu_reg_2001_grayscale; - - private static int ppu_reg_2001_emphasis; - - private static bool ppu_reg_2002_SpriteOverflow; - - private static bool ppu_reg_2002_Sprite0Hit; - - private static bool ppu_reg_2002_VblankStartedFlag; - - private static byte ppu_reg_2003_oam_addr; - - private static ushort ppu_vram_addr; - - private static byte ppu_vram_data; - - private static ushort ppu_vram_addr_temp; - - private static ushort ppu_vram_addr_access_temp; - - private static bool ppu_vram_flip_flop; - - private static byte ppu_vram_finex; - - private static ushort ppu_bkgfetch_nt_addr; - - private static byte ppu_bkgfetch_nt_data; - - private static ushort ppu_bkgfetch_at_addr; - - private static byte ppu_bkgfetch_at_data; - - private static ushort ppu_bkgfetch_lb_addr; - - private static byte ppu_bkgfetch_lb_data; - - private static ushort ppu_bkgfetch_hb_addr; - - private static byte ppu_bkgfetch_hb_data; - - private static int ppu_sprfetch_slot; - - private static byte ppu_sprfetch_y_data; - - private static byte ppu_sprfetch_t_data; - - private static byte ppu_sprfetch_at_data; - - private static byte ppu_sprfetch_x_data; - - private static ushort ppu_sprfetch_lb_addr; - - private static byte ppu_sprfetch_lb_data; - - private static ushort ppu_sprfetch_hb_addr; - - private static byte ppu_sprfetch_hb_data; - - internal static bool ppu_is_sprfetch; - - private static int ppu_bkg_render_i; - - private static int ppu_bkg_render_pos; - - private static int ppu_bkg_render_tmp_val; - - private static int ppu_bkg_current_pixel; - - private static int ppu_spr_current_pixel; - - private static int ppu_current_pixel; - - private static int ppu_render_x; - - private static int ppu_render_y; - - private static byte ppu_oamev_n; - - private static byte ppu_oamev_m; - - private static bool ppu_oamev_compare; - - private static byte ppu_oamev_slot; - - private static byte ppu_fetch_data; - - private static byte ppu_phase_index; - - private static bool ppu_sprite0_should_hit; - - private static int ppu_temp_comparator; - - public static bool ON; - - public static bool PAUSED; - - public static bool isPaused; - - public static string CurrentFilePath; - - public static bool FrameLimiterEnabled; - - private static Thread mainThread; - - private static double fps_time_period; - - private static double emu_time_target_fps = 60.0; - - private static bool render_initialized; - - private static RenderVideoFrame render_video; - - private static RenderAudioSamples render_audio; - - private static TogglePause render_audio_toggle_pause; - - private static GetIsPlaying render_audio_get_is_playing; - - private static bool render_audio_is_playing; - - public static EmuRegion Region; - - private static int SystemIndex; - - private static RequestMode emu_request_mode = RequestMode.None; - - public static bool FrameSkipEnabled; - - public static int FrameSkipInterval; - - private static int FrameSkipCounter; - - private static byte sq2_duty_cycle; - - private static bool sq2_length_halt; - - private static bool sq2_constant_volume_envelope; - - private static byte sq2_volume_devider_period; - - private static bool sq2_sweep_enable; - - private static byte sq2_sweep_devider_period; - - private static bool sq2_sweep_negate; - - private static byte sq2_sweep_shift_count; - - private static int sq2_timer; - - private static int sq2_period_devider; - - private static byte sq2_seqencer; - - private static bool sq2_length_enabled; - - private static int sq2_length_counter; - - private static bool sq2_envelope_start_flag; - - private static byte sq2_envelope_devider; - - private static byte sq2_envelope_decay_level_counter; - - private static byte sq2_envelope; - - private static int sq2_sweep_counter; - - private static bool sq2_sweep_reload; - - private static int sq2_sweep_change; - - private static bool sq2_valid_freq; - - private static int sq2_output; - - private static bool sq2_ignore_reload; - - private static byte register_p - { - get - { - return (byte)((cpu_flag_n ? 128u : 0u) | (cpu_flag_v ? 64u : 0u) | (cpu_flag_d ? 8u : 0u) | (cpu_flag_i ? 4u : 0u) | (cpu_flag_z ? 2u : 0u) | (cpu_flag_c ? 1u : 0u) | 0x20u); - } - set - { - cpu_flag_n = (value & 0x80) != 0; - cpu_flag_v = (value & 0x40) != 0; - cpu_flag_d = (value & 8) != 0; - cpu_flag_i = (value & 4) != 0; - cpu_flag_z = (value & 2) != 0; - cpu_flag_c = (value & 1) != 0; - } - } - - public static GameGenieCode[] GameGenieCodes - { - get - { - if (mem_board != null) - { - return mem_board.GameGenieCodes; - } - return null; - } - } - - public static bool IsGameGenieActive - { - get - { - if (mem_board != null) - { - return mem_board.IsGameGenieActive; - } - return false; - } - set - { - if (mem_board != null) - { - mem_board.IsGameGenieActive = value; - } - } - } - - public static bool IsGameFoundOnDB - { - get - { - if (mem_board != null) - { - return mem_board.IsGameFoundOnDB; - } - return false; - } - } - - public static NesCartDatabaseGameInfo GameInfo - { - get - { - if (mem_board != null) - { - return mem_board.GameInfo; - } - return NesCartDatabaseGameInfo.Empty; - } - } - - public static NesCartDatabaseCartridgeInfo GameCartInfo - { - get - { - if (mem_board != null) - { - return mem_board.GameCartInfo; - } - return new NesCartDatabaseCartridgeInfo(); - } - } - - public static string SHA1 => mem_board.SHA1; - - public static event EventHandler EmuShutdown; - - private static void DMCHardReset() - { - dmc_output_a = 0; - dmc_output = 0; - dmc_period_devider = 0; - dmc_loop_flag = false; - dmc_rate_index = 0; - dmc_irq_enabled = false; - dmc_dmaAddr = 49152; - dmc_addr_refresh = 49152; - dmc_size_refresh = 0; - dmc_dmaBits = 1; - dmc_dmaByte = 1; - dmc_period_devider = 0; - dmc_dmaEnabled = false; - dmc_bufferFull = false; - dmc_dmaSize = 0; - } - - private static void DMCSoftReset() - { - DMCHardReset(); - } - - private static void DMCClock() - { - dmc_period_devider--; - if (dmc_period_devider > 0) - { - return; - } - dmc_period_devider = dmc_freq_table[SystemIndex][dmc_rate_index]; - if (dmc_dmaEnabled) - { - if (((uint)dmc_dmaByte & (true ? 1u : 0u)) != 0) - { - if (dmc_output_a <= 125) - { - dmc_output_a += 2; - } - } - else if (dmc_output_a >= 2) - { - dmc_output_a -= 2; - } - dmc_dmaByte >>= 1; - } - dmc_dmaBits--; - if (dmc_dmaBits == 0) - { - dmc_dmaBits = 8; - if (dmc_bufferFull) - { - dmc_bufferFull = false; - dmc_dmaEnabled = true; - dmc_dmaByte = dmc_dmaBuffer; - if (dmc_dmaSize > 0) - { - AssertDMCDMA(); - } - } - else - { - dmc_dmaEnabled = false; - } - } - if (audio_dmc_outputable) - { - dmc_output = dmc_output_a; - } - audio_signal_outputed = true; - } - - private static void DMCDoDMA() - { - dmc_bufferFull = true; - Read(ref dmc_dmaAddr, out dmc_dmaBuffer); - if (dmc_dmaAddr == ushort.MaxValue) - { - dmc_dmaAddr = 32768; - } - else - { - dmc_dmaAddr++; - } - if (dmc_dmaSize > 0) - { - dmc_dmaSize--; - } - if (dmc_dmaSize == 0) - { - if (dmc_loop_flag) - { - dmc_dmaSize = dmc_size_refresh; - dmc_dmaAddr = dmc_addr_refresh; - } - else if (dmc_irq_enabled) - { - IRQFlags |= 2; - apu_irq_delta_occur = true; - } - } - } - - private static void APUOnRegister4010() - { - if (apu_reg_access_w) - { - dmc_irq_enabled = (apu_reg_io_db & 0x80) != 0; - dmc_loop_flag = (apu_reg_io_db & 0x40) != 0; - if (!dmc_irq_enabled) - { - apu_irq_delta_occur = false; - IRQFlags &= -3; - } - dmc_rate_index = (byte)(apu_reg_io_db & 0xFu); - } - } - - private static void APUOnRegister4011() - { - if (apu_reg_access_w) - { - dmc_output_a = (byte)(apu_reg_io_db & 0x7F); - } - } - - private static void APUOnRegister4012() - { - if (apu_reg_access_w) - { - dmc_addr_refresh = (ushort)((uint)(apu_reg_io_db << 6) | 0xC000u); - } - } - - private static void APUOnRegister4013() - { - if (apu_reg_access_w) - { - dmc_size_refresh = (apu_reg_io_db << 4) | 1; - } - } - - private static void DMCOn4015() - { - apu_irq_delta_occur = false; - IRQFlags &= -3; - } - - private static void DMCRead4015() - { - if (dmc_dmaSize > 0) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0xEFu) | 0x10u); - } - } - - private static void DMCWriteState(ref BinaryWriter bin) - { - bin.Write(dmc_output_a); - bin.Write(dmc_output); - bin.Write(dmc_period_devider); - bin.Write(dmc_irq_enabled); - bin.Write(dmc_loop_flag); - bin.Write(dmc_rate_index); - bin.Write(dmc_addr_refresh); - bin.Write(dmc_size_refresh); - bin.Write(dmc_dmaEnabled); - bin.Write(dmc_dmaByte); - bin.Write(dmc_dmaBits); - bin.Write(dmc_bufferFull); - bin.Write(dmc_dmaBuffer); - bin.Write(dmc_dmaSize); - bin.Write(dmc_dmaAddr); - } - - private static void DMCReadState(ref BinaryReader bin) - { - dmc_output_a = bin.ReadInt32(); - dmc_output = bin.ReadInt32(); - dmc_period_devider = bin.ReadInt32(); - dmc_irq_enabled = bin.ReadBoolean(); - dmc_loop_flag = bin.ReadBoolean(); - dmc_rate_index = bin.ReadByte(); - dmc_addr_refresh = bin.ReadUInt16(); - dmc_size_refresh = bin.ReadInt32(); - dmc_dmaEnabled = bin.ReadBoolean(); - dmc_dmaByte = bin.ReadByte(); - dmc_dmaBits = bin.ReadInt32(); - dmc_bufferFull = bin.ReadBoolean(); - dmc_dmaBuffer = bin.ReadByte(); - dmc_dmaSize = bin.ReadInt32(); - dmc_dmaAddr = bin.ReadUInt16(); - } - - private static void NOSHardReset() - { - nos_length_halt = false; - nos_constant_volume_envelope = false; - nos_volume_devider_period = 0; - nos_shift_reg = 1; - nos_timer = 0; - nos_mode = false; - nos_period_devider = 0; - nos_length_enabled = false; - nos_length_counter = 0; - nos_envelope_start_flag = false; - nos_envelope_devider = 0; - nos_envelope_decay_level_counter = 0; - nos_envelope = 0; - nos_output = 0; - nos_feedback = 0; - nos_ignore_reload = false; - } - - private static void NOSSoftReset() - { - NOSHardReset(); - } - - private static void NOSClock() - { - nos_period_devider--; - if (nos_period_devider > 0) - { - return; - } - nos_period_devider = nos_timer; - if (nos_mode) - { - nos_feedback = ((nos_shift_reg >> 6) & 1) ^ (nos_shift_reg & 1); - } - else - { - nos_feedback = ((nos_shift_reg >> 1) & 1) ^ (nos_shift_reg & 1); - } - nos_shift_reg >>= 1; - nos_shift_reg = (nos_shift_reg & 0x3FFF) | ((nos_feedback & 1) << 14); - if (nos_length_counter > 0 && (nos_shift_reg & 1) == 0) - { - if (audio_nos_outputable) - { - nos_output = nos_envelope; - } - } - else - { - nos_output = 0; - } - audio_signal_outputed = true; - } - - private static void NOSClockLength() - { - if (nos_length_counter > 0 && !nos_length_halt) - { - nos_length_counter--; - if (apu_reg_access_happened && apu_reg_io_addr == 15 && apu_reg_access_w) - { - nos_ignore_reload = true; - } - } - } - - private static void NOSClockEnvelope() - { - if (nos_envelope_start_flag) - { - nos_envelope_start_flag = false; - nos_envelope_decay_level_counter = 15; - nos_envelope_devider = (byte)(nos_volume_devider_period + 1); - } - else if (nos_envelope_devider > 0) - { - nos_envelope_devider--; - } - else - { - nos_envelope_devider = (byte)(nos_volume_devider_period + 1); - if (nos_envelope_decay_level_counter > 0) - { - nos_envelope_decay_level_counter--; - } - else if (nos_length_halt) - { - nos_envelope_decay_level_counter = 15; - } - } - nos_envelope = (nos_constant_volume_envelope ? nos_volume_devider_period : nos_envelope_decay_level_counter); - } - - private static void APUOnRegister400C() - { - if (apu_reg_access_w) - { - nos_volume_devider_period = (byte)(apu_reg_io_db & 0xFu); - nos_length_halt = (apu_reg_io_db & 0x20) != 0; - nos_constant_volume_envelope = (apu_reg_io_db & 0x10) != 0; - nos_envelope = (nos_constant_volume_envelope ? nos_volume_devider_period : nos_envelope_decay_level_counter); - } - } - - private static void APUOnRegister400D() - { - } - - private static void APUOnRegister400E() - { - if (apu_reg_access_w) - { - nos_timer = (ushort)(nos_freq_table[SystemIndex][apu_reg_io_db & 0xF] / 2); - nos_mode = (apu_reg_io_db & 0x80) == 128; - } - } - - private static void APUOnRegister400F() - { - if (apu_reg_access_w) - { - if (nos_length_enabled && !nos_ignore_reload) - { - nos_length_counter = sq_duration_table[apu_reg_io_db >> 3]; - } - if (nos_ignore_reload) - { - nos_ignore_reload = false; - } - nos_envelope_start_flag = true; - } - } - - private static void NOSOn4015() - { - nos_length_enabled = (apu_reg_io_db & 8) != 0; - if (!nos_length_enabled) - { - nos_length_counter = 0; - } - } - - private static void NOSRead4015() - { - if (nos_length_counter > 0) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0xF7u) | 8u); - } - } - - private static void NOSWriteState(ref BinaryWriter bin) - { - bin.Write(nos_length_halt); - bin.Write(nos_constant_volume_envelope); - bin.Write(nos_volume_devider_period); - bin.Write(nos_timer); - bin.Write(nos_mode); - bin.Write(nos_period_devider); - bin.Write(nos_length_enabled); - bin.Write(nos_length_counter); - bin.Write(nos_envelope_start_flag); - bin.Write(nos_envelope_devider); - bin.Write(nos_envelope_decay_level_counter); - bin.Write(nos_envelope); - bin.Write(nos_output); - bin.Write(nos_shift_reg); - bin.Write(nos_feedback); - bin.Write(nos_ignore_reload); - } - - private static void NOSReadState(ref BinaryReader bin) - { - nos_length_halt = bin.ReadBoolean(); - nos_constant_volume_envelope = bin.ReadBoolean(); - nos_volume_devider_period = bin.ReadByte(); - nos_timer = bin.ReadUInt16(); - nos_mode = bin.ReadBoolean(); - nos_period_devider = bin.ReadInt32(); - nos_length_enabled = bin.ReadBoolean(); - nos_length_counter = bin.ReadInt32(); - nos_envelope_start_flag = bin.ReadBoolean(); - nos_envelope_devider = bin.ReadByte(); - nos_envelope_decay_level_counter = bin.ReadByte(); - nos_envelope = bin.ReadByte(); - nos_output = bin.ReadInt32(); - nos_shift_reg = bin.ReadInt32(); - nos_feedback = bin.ReadInt32(); - nos_ignore_reload = bin.ReadBoolean(); - } - - private static void SQ1HardReset() - { - sq1_duty_cycle = 0; - sq1_length_halt = false; - sq1_constant_volume_envelope = false; - sq1_volume_devider_period = 0; - sq1_sweep_enable = false; - sq1_sweep_devider_period = 0; - sq1_sweep_negate = false; - sq1_sweep_shift_count = 0; - sq1_timer = 0; - sq1_period_devider = 0; - sq1_seqencer = 0; - sq1_length_enabled = false; - sq1_length_counter = 0; - sq1_envelope_start_flag = false; - sq1_envelope_devider = 0; - sq1_envelope_decay_level_counter = 0; - sq1_envelope = 0; - sq1_sweep_counter = 0; - sq1_sweep_reload = false; - sq1_sweep_change = 0; - sq1_valid_freq = false; - sq1_output = 0; - sq1_ignore_reload = false; - } - - private static void SQ1SoftReset() - { - SQ1HardReset(); - } - - private static void SQ1Clock() - { - sq1_period_devider--; - if (sq1_period_devider > 0) - { - return; - } - sq1_period_devider = sq1_timer + 1; - sq1_seqencer = (byte)((uint)(sq1_seqencer + 1) & 7u); - if (sq1_length_counter > 0 && sq1_valid_freq) - { - if (audio_sq1_outputable) - { - sq1_output = sq_duty_cycle_sequences[sq1_duty_cycle][sq1_seqencer] * sq1_envelope; - } - } - else - { - sq1_output = 0; - } - audio_signal_outputed = true; - } - - private static void SQ1ClockLength() - { - if (sq1_length_counter > 0 && !sq1_length_halt) - { - sq1_length_counter--; - if (apu_reg_access_happened && apu_reg_io_addr == 3 && apu_reg_access_w) - { - sq1_ignore_reload = true; - } - } - sq1_sweep_counter--; - if (sq1_sweep_counter == 0) - { - sq1_sweep_counter = sq1_sweep_devider_period + 1; - if (sq1_sweep_enable && sq1_sweep_shift_count > 0 && sq1_valid_freq) - { - sq1_sweep_change = sq1_timer >> (int)sq1_sweep_shift_count; - sq1_timer += (sq1_sweep_negate ? (~sq1_sweep_change) : sq1_sweep_change); - SQ1CalculateValidFreq(); - } - } - if (sq1_sweep_reload) - { - sq1_sweep_counter = sq1_sweep_devider_period + 1; - sq1_sweep_reload = false; - } - } - - private static void SQ1ClockEnvelope() - { - if (sq1_envelope_start_flag) - { - sq1_envelope_start_flag = false; - sq1_envelope_decay_level_counter = 15; - sq1_envelope_devider = (byte)(sq1_volume_devider_period + 1); - } - else if (sq1_envelope_devider > 0) - { - sq1_envelope_devider--; - } - else - { - sq1_envelope_devider = (byte)(sq1_volume_devider_period + 1); - if (sq1_envelope_decay_level_counter > 0) - { - sq1_envelope_decay_level_counter--; - } - else if (sq1_length_halt) - { - sq1_envelope_decay_level_counter = 15; - } - } - sq1_envelope = (sq1_constant_volume_envelope ? sq1_volume_devider_period : sq1_envelope_decay_level_counter); - } - - private static void APUOnRegister4000() - { - if (apu_reg_access_w) - { - sq1_duty_cycle = (byte)((apu_reg_io_db & 0xC0) >> 6); - sq1_volume_devider_period = (byte)(apu_reg_io_db & 0xFu); - sq1_length_halt = (apu_reg_io_db & 0x20) != 0; - sq1_constant_volume_envelope = (apu_reg_io_db & 0x10) != 0; - sq1_envelope = (sq1_constant_volume_envelope ? sq1_volume_devider_period : sq1_envelope_decay_level_counter); - } - } - - private static void APUOnRegister4001() - { - if (apu_reg_access_w) - { - sq1_sweep_enable = (apu_reg_io_db & 0x80) == 128; - sq1_sweep_devider_period = (byte)((uint)(apu_reg_io_db >> 4) & 7u); - sq1_sweep_negate = (apu_reg_io_db & 8) == 8; - sq1_sweep_shift_count = (byte)(apu_reg_io_db & 7u); - sq1_sweep_reload = true; - SQ1CalculateValidFreq(); - } - } - - private static void APUOnRegister4002() - { - if (apu_reg_access_w) - { - sq1_timer = (sq1_timer & 0xFF00) | apu_reg_io_db; - SQ1CalculateValidFreq(); - } - } - - private static void APUOnRegister4003() - { - if (apu_reg_access_w) - { - sq1_timer = (sq1_timer & 0xFF) | ((apu_reg_io_db & 7) << 8); - if (sq1_length_enabled && !sq1_ignore_reload) - { - sq1_length_counter = sq_duration_table[apu_reg_io_db >> 3]; - } - if (sq1_ignore_reload) - { - sq1_ignore_reload = false; - } - sq1_seqencer = 0; - sq1_envelope_start_flag = true; - SQ1CalculateValidFreq(); - } - } - - private static void SQ1On4015() - { - sq1_length_enabled = (apu_reg_io_db & 1) != 0; - if (!sq1_length_enabled) - { - sq1_length_counter = 0; - } - } - - private static void SQ1Read4015() - { - if (sq1_length_counter > 0) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0xFEu) | 1u); - } - } - - private static void SQ1CalculateValidFreq() - { - sq1_valid_freq = sq1_timer >= 8 && (sq1_sweep_negate || ((sq1_timer + (sq1_timer >> (int)sq1_sweep_shift_count)) & 0x800) == 0); - } - - private static void SQ1WriteState(ref BinaryWriter bin) - { - bin.Write(sq1_duty_cycle); - bin.Write(sq1_length_halt); - bin.Write(sq1_constant_volume_envelope); - bin.Write(sq1_volume_devider_period); - bin.Write(sq1_sweep_enable); - bin.Write(sq1_sweep_devider_period); - bin.Write(sq1_sweep_negate); - bin.Write(sq1_sweep_shift_count); - bin.Write(sq1_timer); - bin.Write(sq1_period_devider); - bin.Write(sq1_seqencer); - bin.Write(sq1_length_enabled); - bin.Write(sq1_length_counter); - bin.Write(sq1_envelope_start_flag); - bin.Write(sq1_envelope_devider); - bin.Write(sq1_envelope_decay_level_counter); - bin.Write(sq1_envelope); - bin.Write(sq1_sweep_counter); - bin.Write(sq1_sweep_reload); - bin.Write(sq1_sweep_change); - bin.Write(sq1_valid_freq); - bin.Write(sq1_output); - bin.Write(sq1_ignore_reload); - } - - private static void SQ1ReadState(ref BinaryReader bin) - { - sq1_duty_cycle = bin.ReadByte(); - sq1_length_halt = bin.ReadBoolean(); - sq1_constant_volume_envelope = bin.ReadBoolean(); - sq1_volume_devider_period = bin.ReadByte(); - sq1_sweep_enable = bin.ReadBoolean(); - sq1_sweep_devider_period = bin.ReadByte(); - sq1_sweep_negate = bin.ReadBoolean(); - sq1_sweep_shift_count = bin.ReadByte(); - sq1_timer = bin.ReadInt32(); - sq1_period_devider = bin.ReadInt32(); - sq1_seqencer = bin.ReadByte(); - sq1_length_enabled = bin.ReadBoolean(); - sq1_length_counter = bin.ReadInt32(); - sq1_envelope_start_flag = bin.ReadBoolean(); - sq1_envelope_devider = bin.ReadByte(); - sq1_envelope_decay_level_counter = bin.ReadByte(); - sq1_envelope = bin.ReadByte(); - sq1_sweep_counter = bin.ReadInt32(); - sq1_sweep_reload = bin.ReadBoolean(); - sq1_sweep_change = bin.ReadInt32(); - sq1_valid_freq = bin.ReadBoolean(); - sq1_output = bin.ReadInt32(); - sq1_ignore_reload = bin.ReadBoolean(); - } - - private static void TRLHardReset() - { - trl_liner_control_flag = false; - trl_liner_control_reload = 0; - trl_timer = 0; - trl_length_enabled = false; - trl_length_counter = 0; - trl_liner_control_reload_flag = false; - trl_liner_counter = 0; - trl_output = 0; - trl_period_devider = 0; - trl_step = 0; - trl_ignore_reload = false; - } - - private static void TRLSoftReset() - { - TRLHardReset(); - } - - private static void TRLClock() - { - trl_period_devider--; - if (trl_period_devider > 0) - { - return; - } - trl_period_devider = trl_timer + 1; - if (trl_length_counter > 0 && trl_liner_counter > 0 && trl_timer >= 4) - { - trl_step++; - trl_step &= 31; - if (audio_trl_outputable) - { - trl_output = trl_step_seq[trl_step]; - } - } - audio_signal_outputed = true; - } - - private static void TRLClockLength() - { - if (trl_length_counter > 0 && !trl_liner_control_flag) - { - trl_length_counter--; - if (apu_reg_access_happened && apu_reg_io_addr == 11 && apu_reg_access_w) - { - trl_ignore_reload = true; - } - } - } - - private static void TRLClockEnvelope() - { - if (trl_liner_control_reload_flag) - { - trl_liner_counter = trl_liner_control_reload; - } - else if (trl_liner_counter > 0) - { - trl_liner_counter--; - } - if (!trl_liner_control_flag) - { - trl_liner_control_reload_flag = false; - } - } - - private static void APUOnRegister4008() - { - if (apu_reg_access_w) - { - trl_liner_control_flag = (apu_reg_io_db & 0x80) == 128; - trl_liner_control_reload = (byte)(apu_reg_io_db & 0x7Fu); - } - } - - private static void APUOnRegister4009() - { - } - - private static void APUOnRegister400A() - { - if (apu_reg_access_w) - { - trl_timer = (ushort)((trl_timer & 0x7F00u) | apu_reg_io_db); - } - } - - private static void APUOnRegister400B() - { - if (apu_reg_access_w) - { - trl_timer = (ushort)((trl_timer & 0xFFu) | (uint)((apu_reg_io_db & 7) << 8)); - if (trl_length_enabled && !trl_ignore_reload) - { - trl_length_counter = sq_duration_table[apu_reg_io_db >> 3]; - } - if (trl_ignore_reload) - { - trl_ignore_reload = false; - } - trl_liner_control_reload_flag = true; - } - } - - private static void TRLOn4015() - { - trl_length_enabled = (apu_reg_io_db & 4) != 0; - if (!trl_length_enabled) - { - trl_length_counter = 0; - } - } - - private static void TRLRead4015() - { - if (trl_length_counter > 0) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0xFBu) | 4u); - } - } - - private static void TRLWriteState(ref BinaryWriter bin) - { - bin.Write(trl_liner_control_flag); - bin.Write(trl_liner_control_reload); - bin.Write(trl_timer); - bin.Write(trl_length_enabled); - bin.Write(trl_length_counter); - bin.Write(trl_liner_control_reload_flag); - bin.Write(trl_liner_counter); - bin.Write(trl_output); - bin.Write(trl_period_devider); - bin.Write(trl_step); - bin.Write(trl_ignore_reload); - } - - private static void TRLReadState(ref BinaryReader bin) - { - trl_liner_control_flag = bin.ReadBoolean(); - trl_liner_control_reload = bin.ReadByte(); - trl_timer = bin.ReadUInt16(); - trl_length_enabled = bin.ReadBoolean(); - trl_length_counter = bin.ReadByte(); - trl_liner_control_reload_flag = bin.ReadBoolean(); - trl_liner_counter = bin.ReadByte(); - trl_output = bin.ReadInt32(); - trl_period_devider = bin.ReadInt32(); - trl_step = bin.ReadInt32(); - trl_ignore_reload = bin.ReadBoolean(); - } - - private static void APUInitialize() - { - apu_reg_update_func = new Action[32]; - apu_reg_read_func = new Action[32]; - apu_reg_write_func = new Action[32]; - for (int i = 0; i < 32; i++) - { - apu_reg_update_func[i] = APUBlankAccess; - apu_reg_read_func[i] = APUBlankAccess; - apu_reg_write_func[i] = APUBlankAccess; - } - apu_reg_update_func[0] = APUOnRegister4000; - apu_reg_update_func[1] = APUOnRegister4001; - apu_reg_update_func[2] = APUOnRegister4002; - apu_reg_update_func[3] = APUOnRegister4003; - apu_reg_update_func[4] = APUOnRegister4004; - apu_reg_update_func[5] = APUOnRegister4005; - apu_reg_update_func[6] = APUOnRegister4006; - apu_reg_update_func[7] = APUOnRegister4007; - apu_reg_update_func[8] = APUOnRegister4008; - apu_reg_update_func[9] = APUOnRegister4009; - apu_reg_update_func[10] = APUOnRegister400A; - apu_reg_update_func[11] = APUOnRegister400B; - apu_reg_update_func[12] = APUOnRegister400C; - apu_reg_update_func[13] = APUOnRegister400D; - apu_reg_update_func[14] = APUOnRegister400E; - apu_reg_update_func[15] = APUOnRegister400F; - apu_reg_update_func[16] = APUOnRegister4010; - apu_reg_update_func[17] = APUOnRegister4011; - apu_reg_update_func[18] = APUOnRegister4012; - apu_reg_update_func[19] = APUOnRegister4013; - apu_reg_update_func[21] = APUOnRegister4015; - apu_reg_update_func[22] = APUOnRegister4016; - apu_reg_update_func[23] = APUOnRegister4017; - apu_reg_read_func[21] = APURead4015; - apu_reg_read_func[22] = APURead4016; - apu_reg_read_func[23] = APURead4017; - apu_reg_write_func[20] = APUWrite4014; - apu_reg_write_func[21] = APUWrite4015; - audio_low_pass_filter_14K = new SoundLowPassFilter(0.00815686); - audio_high_pass_filter_90 = new SoundHighPassFilter(0.999835); - audio_high_pass_filter_440 = new SoundHighPassFilter(0.996039); - apu_update_playback_func = APUUpdatePlaybackWithFilters; - } - - public static void ApplyAudioSettings(bool all = true) - { - SoundEnabled = MyNesMain.RendererSettings.Audio_SoundEnabled; - audio_sq1_outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_SQ1; - audio_sq2_outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_SQ2; - audio_nos_outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_NOZ; - audio_trl_outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_TRL; - audio_dmc_outputable = MyNesMain.RendererSettings.Audio_ChannelEnabled_DMC; - if (apu_use_external_sound) - { - mem_board.APUApplyChannelsSettings(); - } - if (all) - { - CalculateAudioPlaybackValues(); - } - } - - private static void APUHardReset() - { - apu_reg_io_db = 0; - apu_reg_io_addr = 0; - apu_reg_access_happened = false; - apu_reg_access_w = false; - apu_seq_mode = false; - apu_odd_cycle = true; - apu_cycle_f_t = 0; - apu_cycle_e = 4; - apu_cycle_f = 4; - apu_cycle_l = 4; - apu_odd_l = false; - apu_check_irq = false; - apu_do_env = false; - apu_do_length = false; - switch (Region) - { - case EmuRegion.NTSC: - cpu_speed = 1789773; - apu_ferq_f = 14914; - apu_ferq_e = 3728; - apu_ferq_l = 7456; - break; - case EmuRegion.PALB: - cpu_speed = 1662607; - apu_ferq_f = 14914; - apu_ferq_e = 3728; - apu_ferq_l = 7456; - break; - case EmuRegion.DENDY: - cpu_speed = 1773448; - apu_ferq_f = 14914; - apu_ferq_e = 3728; - apu_ferq_l = 7456; - break; - } - Tracer.WriteLine("NES: cpu speed = " + cpu_speed); - SQ1HardReset(); - SQ2HardReset(); - NOSHardReset(); - DMCHardReset(); - TRLHardReset(); - apu_irq_enabled = true; - apu_irq_flag = false; - reg_2004 = 8196; - CalculateAudioPlaybackValues(); - apu_use_external_sound = mem_board.enable_external_sound; - if (apu_use_external_sound) - { - Tracer.WriteInformation("External sound channels has been enabled on apu."); - } - } - - private static void APUSoftReset() - { - apu_reg_io_db = 0; - apu_reg_io_addr = 0; - apu_reg_access_happened = false; - apu_reg_access_w = false; - apu_seq_mode = false; - apu_odd_cycle = false; - apu_cycle_f_t = 0; - apu_cycle_e = 4; - apu_cycle_f = 4; - apu_cycle_l = 4; - apu_odd_l = false; - apu_check_irq = false; - apu_do_env = false; - apu_do_length = false; - apu_irq_enabled = true; - apu_irq_flag = false; - SQ1SoftReset(); - SQ2SoftReset(); - TRLSoftReset(); - NOSSoftReset(); - DMCSoftReset(); - } - - private static void APUIORead(ref ushort addr, out byte value) - { - if (addr >= 16416) - { - mem_board.ReadEX(ref addr, out value); - return; - } - apu_reg_io_addr = (byte)(addr & 0x1Fu); - apu_reg_access_happened = true; - apu_reg_access_w = false; - apu_reg_read_func[apu_reg_io_addr](); - value = apu_reg_io_db; - } - - private static void APUIOWrite(ref ushort addr, ref byte value) - { - if (addr >= 16416) - { - mem_board.WriteEX(ref addr, ref value); - return; - } - apu_reg_io_addr = (byte)(addr & 0x1Fu); - apu_reg_io_db = value; - apu_reg_access_w = true; - apu_reg_access_happened = true; - apu_reg_write_func[apu_reg_io_addr](); - } - - private static void APUBlankAccess() - { - } - - private static void APUWrite4014() - { - dma_Oamaddress = (ushort)(apu_reg_io_db << 8); - AssertOAMDMA(); - } - - private static void APUWrite4015() - { - if ((apu_reg_io_db & 0x10u) != 0) - { - if (dmc_dmaSize == 0) - { - dmc_dmaSize = dmc_size_refresh; - dmc_dmaAddr = dmc_addr_refresh; - } - } - else - { - dmc_dmaSize = 0; - } - if (!dmc_bufferFull && dmc_dmaSize > 0) - { - AssertDMCDMA(); - } - } - - private static void APUOnRegister4015() - { - if (apu_reg_access_w) - { - SQ1On4015(); - SQ2On4015(); - NOSOn4015(); - TRLOn4015(); - DMCOn4015(); - } - else - { - apu_irq_flag = false; - IRQFlags &= -2; - } - } - - private static void APUOnRegister4016() - { - if (!apu_reg_access_w) - { - return; - } - if (inputStrobe > (apu_reg_io_db & 1)) - { - if (IsFourPlayers) - { - PORT0 = (joypad3.GetData() << 8) | joypad1.GetData() | 0x1010000; - PORT1 = (joypad4.GetData() << 8) | joypad2.GetData() | 0x2020000; - } - else - { - PORT0 = joypad1.GetData() | 0x1010100; - PORT1 = joypad2.GetData() | 0x2020200; - } - } - inputStrobe = apu_reg_io_db & 1; - } - - private static void APUOnRegister4017() - { - if (apu_reg_access_w) - { - apu_seq_mode = (apu_reg_io_db & 0x80) != 0; - apu_irq_enabled = (apu_reg_io_db & 0x40) == 0; - apu_cycle_e = -1; - apu_cycle_l = -1; - apu_cycle_f = -1; - apu_odd_l = false; - apu_do_length = apu_seq_mode; - apu_do_env = apu_seq_mode; - apu_check_irq = false; - if (!apu_irq_enabled) - { - apu_irq_flag = false; - IRQFlags &= -2; - } - } - } - - private static void APURead4015() - { - apu_reg_io_db &= 32; - SQ1Read4015(); - SQ2Read4015(); - NOSRead4015(); - TRLRead4015(); - DMCRead4015(); - if (apu_irq_flag) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0xBFu) | 0x40u); - } - if (apu_irq_delta_occur) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0x7Fu) | 0x80u); - } - } - - private static void APURead4016() - { - apu_reg_io_db = (byte)((uint)PORT0 & 1u); - PORT0 >>= 1; - } - - private static void APURead4017() - { - apu_reg_io_db = (byte)((uint)PORT1 & 1u); - PORT1 >>= 1; - } - - private static void APUClock() - { - apu_odd_cycle = !apu_odd_cycle; - if (apu_do_env) - { - APUClockEnvelope(); - } - if (apu_do_length) - { - APUClockDuration(); - } - if (apu_odd_cycle) - { - apu_cycle_f++; - if (apu_cycle_f >= apu_ferq_f) - { - apu_cycle_f = -1; - apu_check_irq = true; - apu_cycle_f_t = 3; - } - apu_cycle_e++; - if (apu_cycle_e >= apu_ferq_e) - { - apu_cycle_e = -1; - if (apu_check_irq) - { - if (!apu_seq_mode) - { - apu_do_env = true; - } - else - { - apu_cycle_e = 4; - } - } - else - { - apu_do_env = true; - } - } - apu_cycle_l++; - if (apu_cycle_l >= apu_ferq_l) - { - apu_odd_l = !apu_odd_l; - apu_cycle_l = (apu_odd_l ? (-2) : (-1)); - if (apu_check_irq && apu_seq_mode) - { - apu_cycle_l = 3730; - apu_odd_l = true; - } - else - { - apu_do_length = true; - } - } - SQ1Clock(); - SQ2Clock(); - NOSClock(); - if (apu_use_external_sound) - { - mem_board.OnAPUClock(); - } - if (apu_reg_access_happened) - { - apu_reg_access_happened = false; - apu_reg_update_func[apu_reg_io_addr](); - } - } - TRLClock(); - DMCClock(); - if (apu_check_irq) - { - if (!apu_seq_mode) - { - APUCheckIRQ(); - } - apu_cycle_f_t--; - if (apu_cycle_f_t == 0) - { - apu_check_irq = false; - } - } - if (apu_use_external_sound) - { - mem_board.OnAPUClockSingle(); - } - apu_update_playback_func(); - } - - private static void APUClockDuration() - { - SQ1ClockLength(); - SQ2ClockLength(); - NOSClockLength(); - TRLClockLength(); - if (apu_use_external_sound) - { - mem_board.OnAPUClockDuration(); - } - apu_do_length = false; - } - - private static void APUClockEnvelope() - { - SQ1ClockEnvelope(); - SQ2ClockEnvelope(); - NOSClockEnvelope(); - TRLClockEnvelope(); - if (apu_use_external_sound) - { - mem_board.OnAPUClockEnvelope(); - } - apu_do_env = false; - } - - private static void APUCheckIRQ() - { - if (apu_irq_enabled) - { - apu_irq_flag = true; - } - if (apu_irq_flag) - { - IRQFlags |= 1; - } - } - - private static void CalculateAudioPlaybackValues() - { - audio_timer_ratio = (double)cpu_speed / (double)MyNesMain.RendererSettings.Audio_Frequency; - audio_playback_peek_limit = MyNesMain.RendererSettings.Audio_InternalPeekLimit; - audio_samples_count = MyNesMain.RendererSettings.Audio_InternalSamplesCount; - audio_playback_amplitude = MyNesMain.RendererSettings.Audio_PlaybackAmplitude; - audio_samples = new short[audio_samples_count]; - audio_w_pos = 0; - audio_samples_added = 0; - audio_timer = 0.0; - audio_x = (audio_y = 0.0); - Tracer.WriteLine("AUDIO: frequency = " + MyNesMain.RendererSettings.Audio_Frequency); - Tracer.WriteLine("AUDIO: timer ratio = " + audio_timer_ratio); - Tracer.WriteLine("AUDIO: internal samples count = " + audio_samples_count); - Tracer.WriteLine("AUDIO: amplitude = " + audio_playback_amplitude); - if (MyNesMain.RendererSettings.Audio_EnableFilters) - { - apu_update_playback_func = APUUpdatePlaybackWithFilters; - audio_low_pass_filter_14K = new SoundLowPassFilter(SoundLowPassFilter.GetK((double)cpu_speed / 14000.0, 14000.0)); - audio_high_pass_filter_90 = new SoundHighPassFilter(SoundHighPassFilter.GetK((double)cpu_speed / 90.0, 90.0)); - audio_high_pass_filter_440 = new SoundHighPassFilter(SoundHighPassFilter.GetK((double)cpu_speed / 440.0, 440.0)); - } - else - { - apu_update_playback_func = APUUpdatePlaybackWithoutFilters; - } - InitializeDACTables(force_intitialize: false); - } - - public static void InitializeDACTables(bool force_intitialize) - { - if (audio_playback_dac_initialized && !force_intitialize) - { - return; - } - int[] array = new int[5]; - mix_table = new int[16][][][][]; - for (int i = 0; i < 16; i++) - { - mix_table[i] = new int[16][][][]; - for (int j = 0; j < 16; j++) - { - mix_table[i][j] = new int[16][][]; - for (int k = 0; k < 16; k++) - { - mix_table[i][j][k] = new int[16][]; - for (int l = 0; l < 16; l++) - { - mix_table[i][j][k][l] = new int[128]; - for (int m = 0; m < 128; m++) - { - if (MyNesMain.RendererSettings.Audio_UseDefaultMixer) - { - double num = 95.88 / (8128.0 / (double)(i + j) + 100.0); - double num2 = 159.79 / (1.0 / ((double)k / 8227.0 + (double)l / 12241.0 + (double)m / 22638.0) + 100.0); - mix_table[i][j][k][l][m] = (int)Math.Ceiling((num + num2) * audio_playback_amplitude); - continue; - } - GetPrec(i, 255, 2048, out array[0]); - GetPrec(j, 255, 2048, out array[1]); - GetPrec(l, 255, 2048, out array[2]); - GetPrec(k, 255, 2048, out array[3]); - GetPrec(m, 255, 2048, out array[4]); - array[4] /= 2; - int num3 = array[0] + array[1] + array[2] + array[3] + array[4]; - num3 /= 5; - mix_table[i][j][k][l][m] = num3; - } - } - } - } - } - audio_playback_dac_initialized = true; - } - - private static void APUUpdatePlaybackWithFilters() - { - if (!SoundEnabled) - { - return; - } - audio_x = mix_table[sq1_output][sq2_output][trl_output][nos_output][dmc_output]; - if (apu_use_external_sound) - { - audio_x = (audio_x + mem_board.APUGetSample() * audio_playback_amplitude) / 2.0; - } - audio_high_pass_filter_90.DoFiltering(audio_x, out audio_y); - audio_high_pass_filter_440.DoFiltering(audio_y, out audio_y); - audio_low_pass_filter_14K.DoFiltering(audio_y, out audio_y); - audio_y_av += audio_y; - audio_y_timer += 1.0; - audio_timer += 1.0; - if (!(audio_timer >= audio_timer_ratio)) - { - return; - } - if (audio_y_timer > 0.0) - { - audio_y = audio_y_av / audio_y_timer; - } - else - { - audio_y = 0.0; - } - audio_y_av = 0.0; - audio_y_timer = 0.0; - audio_timer -= audio_timer_ratio; - if (audio_w_pos < audio_samples_count) - { - if (audio_y > (double)audio_playback_peek_limit) - { - audio_y = audio_playback_peek_limit; - } - if (audio_y < (double)(-audio_playback_peek_limit)) - { - audio_y = -audio_playback_peek_limit; - } - audio_samples[audio_w_pos] = (short)audio_y; - if (MyNesMain.WaveRecorder.IsRecording) - { - MyNesMain.WaveRecorder.AddSample((short)audio_y); - } - audio_w_pos++; - audio_samples_added++; - } - audio_y = 0.0; - } - - private static void APUUpdatePlaybackWithoutFilters() - { - if (!SoundEnabled) - { - return; - } - audio_y = mix_table[sq1_output][sq2_output][trl_output][nos_output][dmc_output] / 2; - if (apu_use_external_sound) - { - audio_y = (audio_y + mem_board.APUGetSample() * audio_playback_amplitude) / 2.0; - } - audio_y_av += audio_y; - audio_y_timer += 1.0; - audio_timer += 1.0; - if (!(audio_timer >= audio_timer_ratio)) - { - return; - } - if (audio_y_timer > 0.0) - { - audio_y = audio_y_av / audio_y_timer; - } - else - { - audio_y = 0.0; - } - audio_y_av = 0.0; - audio_y_timer = 0.0; - audio_timer -= audio_timer_ratio; - if (audio_w_pos < audio_samples_count) - { - if (audio_y > (double)audio_playback_peek_limit) - { - audio_y = audio_playback_peek_limit; - } - if (audio_y < (double)(-audio_playback_peek_limit)) - { - audio_y = -audio_playback_peek_limit; - } - audio_samples[audio_w_pos] = (short)audio_y; - if (MyNesMain.WaveRecorder.IsRecording) - { - MyNesMain.WaveRecorder.AddSample((short)audio_y); - } - audio_w_pos++; - audio_samples_added++; - } - audio_y = 0.0; - } - - private static void GetPrec(int inVal, int inMax, int outMax, out int val) - { - val = outMax * inVal / inMax; - } - - private static void APUWriteState(ref BinaryWriter bin) - { - bin.Write(apu_reg_io_db); - bin.Write(apu_reg_io_addr); - bin.Write(apu_reg_access_happened); - bin.Write(apu_reg_access_w); - bin.Write(apu_odd_cycle); - bin.Write(apu_irq_enabled); - bin.Write(apu_irq_flag); - bin.Write(apu_irq_delta_occur); - bin.Write(apu_seq_mode); - bin.Write(apu_ferq_f); - bin.Write(apu_ferq_l); - bin.Write(apu_ferq_e); - bin.Write(apu_cycle_f); - bin.Write(apu_cycle_e); - bin.Write(apu_cycle_l); - bin.Write(apu_odd_l); - bin.Write(apu_cycle_f_t); - bin.Write(apu_check_irq); - bin.Write(apu_do_env); - bin.Write(apu_do_length); - SQ1WriteState(ref bin); - SQ2WriteState(ref bin); - NOSWriteState(ref bin); - TRLWriteState(ref bin); - DMCWriteState(ref bin); - } - - private static void APUReadState(ref BinaryReader bin) - { - apu_reg_io_db = bin.ReadByte(); - apu_reg_io_addr = bin.ReadByte(); - apu_reg_access_happened = bin.ReadBoolean(); - apu_reg_access_w = bin.ReadBoolean(); - apu_odd_cycle = bin.ReadBoolean(); - apu_irq_enabled = bin.ReadBoolean(); - apu_irq_flag = bin.ReadBoolean(); - apu_irq_delta_occur = bin.ReadBoolean(); - apu_seq_mode = bin.ReadBoolean(); - apu_ferq_f = bin.ReadInt32(); - apu_ferq_l = bin.ReadInt32(); - apu_ferq_e = bin.ReadInt32(); - apu_cycle_f = bin.ReadInt32(); - apu_cycle_e = bin.ReadInt32(); - apu_cycle_l = bin.ReadInt32(); - apu_odd_l = bin.ReadBoolean(); - apu_cycle_f_t = bin.ReadInt32(); - apu_check_irq = bin.ReadBoolean(); - apu_do_env = bin.ReadBoolean(); - apu_do_length = bin.ReadBoolean(); - SQ1ReadState(ref bin); - SQ2ReadState(ref bin); - NOSReadState(ref bin); - TRLReadState(ref bin); - DMCReadState(ref bin); - } - - private static byte register_pb() - { - return (byte)((cpu_flag_n ? 128u : 0u) | (cpu_flag_v ? 64u : 0u) | (cpu_flag_d ? 8u : 0u) | (cpu_flag_i ? 4u : 0u) | (cpu_flag_z ? 2u : 0u) | (cpu_flag_c ? 1u : 0u) | 0x30u); - } - - private static void CPUInitialize() - { - cpu_addressings = new Action[256] - { - Imp____, IndX_R_, ImA____, IndX_W_, Zpg_R__, Zpg_R__, Zpg_RW_, Zpg_W__, ImA____, Imm____, - ImA____, Imm____, Abs_R__, Abs_R__, Abs_RW_, Abs_W__, Imp____, IndY_R_, Imp____, IndY_W_, - ZpgX_R_, ZpgX_R_, ZpgX_RW, ZpgX_W_, ImA____, AbsY_R_, ImA____, AbsY_W_, AbsX_R_, AbsX_R_, - AbsX_RW, AbsX_W_, Imp____, IndX_R_, ImA____, IndX_W_, Zpg_R__, Zpg_R__, Zpg_RW_, Zpg_W__, - ImA____, Imm____, ImA____, Imm____, Abs_R__, Abs_R__, Abs_RW_, Abs_W__, Imp____, IndY_R_, - Imp____, IndY_W_, ZpgX_R_, ZpgX_R_, ZpgX_RW, ZpgX_W_, ImA____, AbsY_R_, ImA____, AbsY_W_, - AbsX_R_, AbsX_R_, AbsX_RW, AbsX_W_, ImA____, IndX_R_, ImA____, IndX_W_, Zpg_R__, Zpg_R__, - Zpg_RW_, Zpg_W__, ImA____, Imm____, ImA____, Imm____, Abs_W__, Abs_R__, Abs_RW_, Abs_W__, - Imp____, IndY_R_, Imp____, IndY_W_, ZpgX_R_, ZpgX_R_, ZpgX_RW, ZpgX_W_, ImA____, AbsY_R_, - ImA____, AbsY_W_, AbsX_R_, AbsX_R_, AbsX_RW, AbsX_W_, ImA____, IndX_R_, ImA____, IndX_W_, - Zpg_R__, Zpg_R__, Zpg_RW_, Zpg_W__, ImA____, Imm____, ImA____, Imm____, Imp____, Abs_R__, - Abs_RW_, Abs_W__, Imp____, IndY_R_, Imp____, IndY_W_, ZpgX_R_, ZpgX_R_, ZpgX_RW, ZpgX_W_, - ImA____, AbsY_R_, ImA____, AbsY_W_, AbsX_R_, AbsX_R_, AbsX_RW, AbsX_W_, Imm____, IndX_W_, - Imm____, IndX_W_, Zpg_W__, Zpg_W__, Zpg_W__, Zpg_W__, ImA____, Imm____, ImA____, Imm____, - Abs_W__, Abs_W__, Abs_W__, Abs_W__, Imp____, IndY_W_, Imp____, IndY_W_, ZpgX_W_, ZpgX_W_, - ZpgY_W_, ZpgY_W_, ImA____, AbsY_W_, ImA____, AbsY_W_, Abs_W__, AbsX_W_, Abs_W__, AbsY_W_, - Imm____, IndX_R_, Imm____, IndX_R_, Zpg_R__, Zpg_R__, Zpg_R__, Zpg_R__, ImA____, Imm____, - ImA____, Imm____, Abs_R__, Abs_R__, Abs_R__, Abs_R__, Imp____, IndY_R_, Imp____, IndY_R_, - ZpgX_R_, ZpgX_R_, ZpgY_R_, ZpgY_R_, ImA____, AbsY_R_, ImA____, AbsY_R_, AbsX_R_, AbsX_R_, - AbsY_R_, AbsY_R_, Imm____, IndX_R_, Imm____, IndX_R_, Zpg_R__, Zpg_R__, Zpg_RW_, Zpg_R__, - ImA____, Imm____, ImA____, Imm____, Abs_R__, Abs_R__, Abs_RW_, Abs_R__, Imp____, IndY_R_, - Imp____, IndY_RW, ZpgX_R_, ZpgX_R_, ZpgX_RW, ZpgX_RW, ImA____, AbsY_R_, ImA____, AbsY_RW, - AbsX_R_, AbsX_R_, AbsX_RW, AbsX_RW, Imm____, IndX_R_, Imm____, IndX_W_, Zpg_R__, Zpg_R__, - Zpg_RW_, Zpg_W__, ImA____, Imm____, ImA____, Imm____, Abs_R__, Abs_R__, Abs_RW_, Abs_W__, - Imp____, IndY_R_, Imp____, IndY_W_, ZpgX_R_, ZpgX_R_, ZpgX_RW, ZpgX_W_, ImA____, AbsY_R_, - ImA____, AbsY_W_, AbsX_R_, AbsX_R_, AbsX_RW, AbsX_W_ - }; - cpu_instructions = new Action[256] - { - BRK__, ORA__, NOP__, SLO__, NOP__, ORA__, ASL_M, SLO__, PHP__, ORA__, - ASL_A, ANC__, NOP__, ORA__, ASL_M, SLO__, BPL__, ORA__, NOP__, SLO__, - NOP__, ORA__, ASL_M, SLO__, CLC__, ORA__, NOP__, SLO__, NOP__, ORA__, - ASL_M, SLO__, JSR__, AND__, NOP__, RLA__, BIT__, AND__, ROL_M, RLA__, - PLP__, AND__, ROL_A, ANC__, BIT__, AND__, ROL_M, RLA__, BMI__, AND__, - NOP__, RLA__, NOP__, AND__, ROL_M, RLA__, SEC__, AND__, NOP__, RLA__, - NOP__, AND__, ROL_M, RLA__, RTI__, EOR__, NOP__, SRE__, NOP__, EOR__, - LSR_M, SRE__, PHA__, EOR__, LSR_A, ALR__, JMP__, EOR__, LSR_M, SRE__, - BVC__, EOR__, NOP__, SRE__, NOP__, EOR__, LSR_M, SRE__, CLI__, EOR__, - NOP__, SRE__, NOP__, EOR__, LSR_M, SRE__, RTS__, ADC__, NOP__, RRA__, - NOP__, ADC__, ROR_M, RRA__, PLA__, ADC__, ROR_A, ARR__, JMP_I, ADC__, - ROR_M, RRA__, BVS__, ADC__, NOP__, RRA__, NOP__, ADC__, ROR_M, RRA__, - SEI__, ADC__, NOP__, RRA__, NOP__, ADC__, ROR_M, RRA__, NOP__, STA__, - NOP__, SAX__, STY__, STA__, STX__, SAX__, DEY__, NOP__, TXA__, XAA__, - STY__, STA__, STX__, SAX__, BCC__, STA__, NOP__, AHX__, STY__, STA__, - STX__, SAX__, TYA__, STA__, TXS__, XAS__, SHY__, STA__, SHX__, AHX__, - LDY__, LDA__, LDX__, LAX__, LDY__, LDA__, LDX__, LAX__, TAY__, LDA__, - TAX__, LAX__, LDY__, LDA__, LDX__, LAX__, BCS__, LDA__, NOP__, LAX__, - LDY__, LDA__, LDX__, LAX__, CLV__, LDA__, TSX__, LAR__, LDY__, LDA__, - LDX__, LAX__, CPY__, CMP__, NOP__, DCP__, CPY__, CMP__, DEC__, DCP__, - INY__, CMP__, DEX__, AXS__, CPY__, CMP__, DEC__, DCP__, BNE__, CMP__, - NOP__, DCP__, NOP__, CMP__, DEC__, DCP__, CLD__, CMP__, NOP__, DCP__, - NOP__, CMP__, DEC__, DCP__, CPX__, SBC__, NOP__, ISC__, CPX__, SBC__, - INC__, ISC__, INX__, SBC__, NOP__, SBC__, CPX__, SBC__, INC__, ISC__, - BEQ__, SBC__, NOP__, ISC__, NOP__, SBC__, INC__, ISC__, SED__, SBC__, - NOP__, ISC__, NOP__, SBC__, INC__, ISC__ - }; - } - - private static void CPUClock() - { - Read(ref cpu_reg_pc.v, out cpu_opcode); - cpu_reg_pc.v++; - cpu_addressings[cpu_opcode](); - cpu_instructions[cpu_opcode](); - if (CPU_IRQ_PIN || CPU_NMI_PIN) - { - Read(ref cpu_reg_pc.v, out cpu_dummy); - Read(ref cpu_reg_pc.v, out cpu_dummy); - Interrupt(); - } - } - - private static void CPUHardReset() - { - cpu_reg_a = 0; - cpu_reg_x = 0; - cpu_reg_y = 0; - cpu_reg_sp.l = 253; - cpu_reg_sp.h = 1; - ushort addr = 65532; - mem_board.ReadPRG(ref addr, out cpu_reg_pc.l); - addr++; - mem_board.ReadPRG(ref addr, out cpu_reg_pc.h); - register_p = 0; - cpu_flag_i = true; - cpu_reg_ea.v = 0; - cpu_opcode = 0; - CPU_IRQ_PIN = false; - CPU_NMI_PIN = false; - cpu_suspend_nmi = false; - cpu_suspend_irq = false; - IRQFlags = 0; - } - - private static void CPUSoftReset() - { - cpu_flag_i = true; - cpu_reg_sp.v -= 3; - ushort addr = 65532; - Read(ref addr, out cpu_reg_pc.l); - addr++; - Read(ref addr, out cpu_reg_pc.h); - } - - private static void Imp____() - { - } - - private static void IndX_R_() - { - temp_add.h = 0; - Read(ref cpu_reg_pc.v, out temp_add.l); - cpu_reg_pc.v++; - Read(ref temp_add.v, out cpu_dummy); - temp_add.l += cpu_reg_x; - Read(ref temp_add.v, out cpu_reg_ea.l); - temp_add.l++; - Read(ref temp_add.v, out cpu_reg_ea.h); - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void IndX_W_() - { - temp_add.h = 0; - Read(ref cpu_reg_pc.v, out temp_add.l); - cpu_reg_pc.v++; - Read(ref temp_add.v, out cpu_dummy); - temp_add.l += cpu_reg_x; - Read(ref temp_add.v, out cpu_reg_ea.l); - temp_add.l++; - Read(ref temp_add.v, out cpu_reg_ea.h); - } - - private static void IndX_RW() - { - temp_add.h = 0; - Read(ref cpu_reg_pc.v, out temp_add.l); - cpu_reg_pc.v++; - Read(ref temp_add.v, out cpu_dummy); - temp_add.l += cpu_reg_x; - Read(ref temp_add.v, out cpu_reg_ea.l); - temp_add.l++; - Read(ref temp_add.v, out cpu_reg_ea.h); - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void IndY_R_() - { - temp_add.h = 0; - Read(ref cpu_reg_pc.v, out temp_add.l); - cpu_reg_pc.v++; - Read(ref temp_add.v, out cpu_reg_ea.l); - temp_add.l++; - Read(ref temp_add.v, out cpu_reg_ea.h); - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - } - - private static void IndY_W_() - { - temp_add.h = 0; - Read(ref cpu_reg_pc.v, out temp_add.l); - cpu_reg_pc.v++; - Read(ref temp_add.v, out cpu_reg_ea.l); - temp_add.l++; - Read(ref temp_add.v, out cpu_reg_ea.h); - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h++; - } - } - - private static void IndY_RW() - { - temp_add.h = 0; - Read(ref cpu_reg_pc.v, out temp_add.l); - cpu_reg_pc.v++; - Read(ref temp_add.v, out cpu_reg_ea.l); - temp_add.l++; - Read(ref temp_add.v, out cpu_reg_ea.h); - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_dummy); - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h++; - } - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void Zpg_R__() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void Zpg_W__() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - } - - private static void Zpg_RW_() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void ZpgX_R_() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_x; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void ZpgX_W_() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_x; - } - - private static void ZpgX_RW() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_x; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void ZpgY_R_() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void ZpgY_W_() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_y; - } - - private static void ZpgY_RW() - { - cpu_reg_ea.h = 0; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void Imm____() - { - Read(ref cpu_reg_pc.v, out cpu_m); - cpu_reg_pc.v++; - } - - private static void ImA____() - { - Read(ref cpu_reg_pc.v, out cpu_dummy); - } - - private static void Abs_R__() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void Abs_W__() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - } - - private static void Abs_RW_() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void AbsX_R_() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - cpu_reg_ea.l += cpu_reg_x; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_x) - { - cpu_reg_ea.h++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - } - - private static void AbsX_W_() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - cpu_reg_ea.l += cpu_reg_x; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_x) - { - cpu_reg_ea.h++; - } - } - - private static void AbsX_RW() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - cpu_reg_ea.l += cpu_reg_x; - Read(ref cpu_reg_ea.v, out cpu_dummy); - if (cpu_reg_ea.l < cpu_reg_x) - { - cpu_reg_ea.h++; - } - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void AbsY_R_() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h++; - Read(ref cpu_reg_ea.v, out cpu_m); - } - } - - private static void AbsY_W_() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h++; - } - } - - private static void AbsY_RW() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v++; - cpu_reg_ea.l += cpu_reg_y; - Read(ref cpu_reg_ea.v, out cpu_m); - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h++; - } - Read(ref cpu_reg_ea.v, out cpu_m); - } - - private static void Interrupt() - { - Push(ref cpu_reg_pc.h); - Push(ref cpu_reg_pc.l); - cpu_dummy = ((cpu_opcode == 0) ? register_pb() : register_p); - Push(ref cpu_dummy); - temp_add.v = InterruptVector; - cpu_suspend_nmi = true; - cpu_flag_i = true; - CPU_NMI_PIN = false; - Read(ref temp_add.v, out cpu_reg_pc.l); - temp_add.v++; - Read(ref temp_add.v, out cpu_reg_pc.h); - cpu_suspend_nmi = false; - } - - private static void Branch(ref bool condition) - { - Read(ref cpu_reg_pc.v, out cpu_byte_temp); - cpu_reg_pc.v++; - if (!condition) - { - return; - } - cpu_suspend_irq = true; - Read(ref cpu_reg_pc.v, out cpu_dummy); - cpu_reg_pc.l += cpu_byte_temp; - cpu_suspend_irq = false; - if (cpu_byte_temp >= 128) - { - if (cpu_reg_pc.l >= cpu_byte_temp) - { - Read(ref cpu_reg_pc.v, out cpu_dummy); - cpu_reg_pc.h--; - } - } - else if (cpu_reg_pc.l < cpu_byte_temp) - { - Read(ref cpu_reg_pc.v, out cpu_dummy); - cpu_reg_pc.h++; - } - } - - private static void Push(ref byte val) - { - Write(ref cpu_reg_sp.v, ref val); - cpu_reg_sp.l--; - } - - private static void Pull(out byte val) - { - cpu_reg_sp.l++; - Read(ref cpu_reg_sp.v, out val); - } - - private static void ADC__() - { - cpu_int_temp = cpu_reg_a + cpu_m + (cpu_flag_c ? 1 : 0); - cpu_flag_v = ((cpu_int_temp ^ cpu_reg_a) & (cpu_int_temp ^ cpu_m) & 0x80) != 0; - cpu_flag_n = (cpu_int_temp & 0x80) != 0; - cpu_flag_z = (cpu_int_temp & 0xFF) == 0; - cpu_flag_c = cpu_int_temp >> 8 != 0; - cpu_reg_a = (byte)((uint)cpu_int_temp & 0xFFu); - } - - private static void AHX__() - { - cpu_byte_temp = (byte)((uint)(cpu_reg_a & cpu_reg_x) & 7u); - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - } - - private static void ALR__() - { - cpu_reg_a &= cpu_m; - cpu_flag_c = (cpu_reg_a & 1) != 0; - cpu_reg_a >>= 1; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void ANC__() - { - cpu_reg_a &= cpu_m; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_z = cpu_reg_a == 0; - cpu_flag_c = (cpu_reg_a & 0x80) != 0; - } - - private static void AND__() - { - cpu_reg_a &= cpu_m; - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void ARR__() - { - cpu_reg_a = (byte)((uint)((cpu_m & cpu_reg_a) >> 1) | (cpu_flag_c ? 128u : 0u)); - cpu_flag_z = (cpu_reg_a & 0xFF) == 0; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_c = (cpu_reg_a & 0x40) != 0; - cpu_flag_v = (((cpu_reg_a << 1) ^ cpu_reg_a) & 0x40) != 0; - } - - private static void AXS__() - { - cpu_int_temp = (cpu_reg_a & cpu_reg_x) - cpu_m; - cpu_flag_n = (cpu_int_temp & 0x80) != 0; - cpu_flag_z = (cpu_int_temp & 0xFF) == 0; - cpu_flag_c = ~cpu_int_temp >> 8 != 0; - cpu_reg_x = (byte)((uint)cpu_int_temp & 0xFFu); - } - - private static void ASL_M() - { - cpu_flag_c = (cpu_m & 0x80) == 128; - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_m = (byte)((uint)(cpu_m << 1) & 0xFEu); - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_flag_n = (cpu_m & 0x80) == 128; - cpu_flag_z = cpu_m == 0; - } - - private static void ASL_A() - { - cpu_flag_c = (cpu_reg_a & 0x80) == 128; - cpu_reg_a = (byte)((uint)(cpu_reg_a << 1) & 0xFEu); - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void BCC__() - { - cpu_bool_tmp = !cpu_flag_c; - Branch(ref cpu_bool_tmp); - } - - private static void BCS__() - { - Branch(ref cpu_flag_c); - } - - private static void BEQ__() - { - Branch(ref cpu_flag_z); - } - - private static void BIT__() - { - cpu_flag_n = (cpu_m & 0x80) != 0; - cpu_flag_v = (cpu_m & 0x40) != 0; - cpu_flag_z = (cpu_m & cpu_reg_a) == 0; - } - - private static void BRK__() - { - Read(ref cpu_reg_pc.v, out cpu_dummy); - cpu_reg_pc.v++; - Interrupt(); - } - - private static void BPL__() - { - cpu_bool_tmp = !cpu_flag_n; - Branch(ref cpu_bool_tmp); - } - - private static void BNE__() - { - cpu_bool_tmp = !cpu_flag_z; - Branch(ref cpu_bool_tmp); - } - - private static void BMI__() - { - Branch(ref cpu_flag_n); - } - - private static void BVC__() - { - cpu_bool_tmp = !cpu_flag_v; - Branch(ref cpu_bool_tmp); - } - - private static void BVS__() - { - Branch(ref cpu_flag_v); - } - - private static void SED__() - { - cpu_flag_d = true; - } - - private static void CLC__() - { - cpu_flag_c = false; - } - - private static void CLD__() - { - cpu_flag_d = false; - } - - private static void CLV__() - { - cpu_flag_v = false; - } - - private static void CMP__() - { - cpu_int_temp = cpu_reg_a - cpu_m; - cpu_flag_n = (cpu_int_temp & 0x80) == 128; - cpu_flag_c = cpu_reg_a >= cpu_m; - cpu_flag_z = cpu_int_temp == 0; - } - - private static void CPX__() - { - cpu_int_temp = cpu_reg_x - cpu_m; - cpu_flag_n = (cpu_int_temp & 0x80) == 128; - cpu_flag_c = cpu_reg_x >= cpu_m; - cpu_flag_z = cpu_int_temp == 0; - } - - private static void CPY__() - { - cpu_int_temp = cpu_reg_y - cpu_m; - cpu_flag_n = (cpu_int_temp & 0x80) == 128; - cpu_flag_c = cpu_reg_y >= cpu_m; - cpu_flag_z = cpu_int_temp == 0; - } - - private static void CLI__() - { - cpu_flag_i = false; - } - - private static void DCP__() - { - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_m--; - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_int_temp = cpu_reg_a - cpu_m; - cpu_flag_n = (cpu_int_temp & 0x80) != 0; - cpu_flag_z = cpu_int_temp == 0; - cpu_flag_c = ~cpu_int_temp >> 8 != 0; - } - - private static void DEC__() - { - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_m--; - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_flag_n = (cpu_m & 0x80) == 128; - cpu_flag_z = cpu_m == 0; - } - - private static void DEY__() - { - cpu_reg_y--; - cpu_flag_z = cpu_reg_y == 0; - cpu_flag_n = (cpu_reg_y & 0x80) == 128; - } - - private static void DEX__() - { - cpu_reg_x--; - cpu_flag_z = cpu_reg_x == 0; - cpu_flag_n = (cpu_reg_x & 0x80) == 128; - } - - private static void EOR__() - { - cpu_reg_a ^= cpu_m; - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void INC__() - { - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_m++; - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_flag_n = (cpu_m & 0x80) == 128; - cpu_flag_z = cpu_m == 0; - } - - private static void INX__() - { - cpu_reg_x++; - cpu_flag_z = cpu_reg_x == 0; - cpu_flag_n = (cpu_reg_x & 0x80) == 128; - } - - private static void INY__() - { - cpu_reg_y++; - cpu_flag_n = (cpu_reg_y & 0x80) == 128; - cpu_flag_z = cpu_reg_y == 0; - } - - private static void ISC__() - { - Read(ref cpu_reg_ea.v, out cpu_byte_temp); - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_byte_temp++; - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_int_temp = cpu_byte_temp ^ 0xFF; - cpu_int_temp1 = cpu_reg_a + cpu_int_temp + (cpu_flag_c ? 1 : 0); - cpu_flag_n = (cpu_int_temp1 & 0x80) != 0; - cpu_flag_v = ((cpu_int_temp1 ^ cpu_reg_a) & (cpu_int_temp1 ^ cpu_int_temp) & 0x80) != 0; - cpu_flag_z = (cpu_int_temp1 & 0xFF) == 0; - cpu_flag_c = cpu_int_temp1 >> 8 != 0; - cpu_reg_a = (byte)((uint)cpu_int_temp1 & 0xFFu); - } - - private static void JMP__() - { - cpu_reg_pc.v = cpu_reg_ea.v; - } - - private static void JMP_I() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - Read(ref cpu_reg_ea.v, out cpu_reg_pc.l); - cpu_reg_ea.l++; - Read(ref cpu_reg_ea.v, out cpu_reg_pc.h); - } - - private static void JSR__() - { - Read(ref cpu_reg_pc.v, out cpu_reg_ea.l); - cpu_reg_pc.v++; - Write(ref cpu_reg_sp.v, ref cpu_reg_ea.l); - Push(ref cpu_reg_pc.h); - Push(ref cpu_reg_pc.l); - Read(ref cpu_reg_pc.v, out cpu_reg_ea.h); - cpu_reg_pc.v = cpu_reg_ea.v; - } - - private static void LAR__() - { - cpu_reg_sp.l &= cpu_m; - cpu_reg_a = cpu_reg_sp.l; - cpu_reg_x = cpu_reg_sp.l; - cpu_flag_n = (cpu_reg_sp.l & 0x80) != 0; - cpu_flag_z = (cpu_reg_sp.l & 0xFF) == 0; - } - - private static void LAX__() - { - cpu_reg_x = (cpu_reg_a = cpu_m); - cpu_flag_n = (cpu_reg_x & 0x80) != 0; - cpu_flag_z = (cpu_reg_x & 0xFF) == 0; - } - - private static void LDA__() - { - cpu_reg_a = cpu_m; - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void LDX__() - { - cpu_reg_x = cpu_m; - cpu_flag_n = (cpu_reg_x & 0x80) == 128; - cpu_flag_z = cpu_reg_x == 0; - } - - private static void LDY__() - { - cpu_reg_y = cpu_m; - cpu_flag_n = (cpu_reg_y & 0x80) == 128; - cpu_flag_z = cpu_reg_y == 0; - } - - private static void LSR_A() - { - cpu_flag_c = (cpu_reg_a & 1) == 1; - cpu_reg_a >>= 1; - cpu_flag_z = cpu_reg_a == 0; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - } - - private static void LSR_M() - { - cpu_flag_c = (cpu_m & 1) == 1; - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_m >>= 1; - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_flag_z = cpu_m == 0; - cpu_flag_n = (cpu_m & 0x80) != 0; - } - - private static void NOP__() - { - } - - private static void ORA__() - { - cpu_reg_a |= cpu_m; - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void PHA__() - { - Push(ref cpu_reg_a); - } - - private static void PHP__() - { - cpu_dummy = register_pb(); - Push(ref cpu_dummy); - } - - private static void PLA__() - { - Read(ref cpu_reg_sp.v, out cpu_dummy); - Pull(out cpu_reg_a); - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void PLP__() - { - Read(ref cpu_reg_sp.v, out cpu_dummy); - Pull(out cpu_dummy); - register_p = cpu_dummy; - } - - private static void RLA__() - { - Read(ref cpu_reg_ea.v, out cpu_byte_temp); - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_dummy = (byte)((uint)(cpu_byte_temp << 1) | (cpu_flag_c ? 1u : 0u)); - Write(ref cpu_reg_ea.v, ref cpu_dummy); - cpu_flag_n = (cpu_dummy & 0x80) != 0; - cpu_flag_z = (cpu_dummy & 0xFF) == 0; - cpu_flag_c = (cpu_byte_temp & 0x80) != 0; - cpu_reg_a &= cpu_dummy; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_z = (cpu_reg_a & 0xFF) == 0; - } - - private static void ROL_A() - { - cpu_byte_temp = (byte)((uint)(cpu_reg_a << 1) | (cpu_flag_c ? 1u : 0u)); - cpu_flag_n = (cpu_byte_temp & 0x80) != 0; - cpu_flag_z = (cpu_byte_temp & 0xFF) == 0; - cpu_flag_c = (cpu_reg_a & 0x80) != 0; - cpu_reg_a = cpu_byte_temp; - } - - private static void ROL_M() - { - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_byte_temp = (byte)((uint)(cpu_m << 1) | (cpu_flag_c ? 1u : 0u)); - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_flag_n = (cpu_byte_temp & 0x80) != 0; - cpu_flag_z = (cpu_byte_temp & 0xFF) == 0; - cpu_flag_c = (cpu_m & 0x80) != 0; - } - - private static void ROR_A() - { - cpu_byte_temp = (byte)((uint)(cpu_reg_a >> 1) | (cpu_flag_c ? 128u : 0u)); - cpu_flag_n = (cpu_byte_temp & 0x80) != 0; - cpu_flag_z = (cpu_byte_temp & 0xFF) == 0; - cpu_flag_c = (cpu_reg_a & 1) != 0; - cpu_reg_a = cpu_byte_temp; - } - - private static void ROR_M() - { - Write(ref cpu_reg_ea.v, ref cpu_m); - cpu_byte_temp = (byte)((uint)(cpu_m >> 1) | (cpu_flag_c ? 128u : 0u)); - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_flag_n = (cpu_byte_temp & 0x80) != 0; - cpu_flag_z = (cpu_byte_temp & 0xFF) == 0; - cpu_flag_c = (cpu_m & 1) != 0; - } - - private static void RRA__() - { - Read(ref cpu_reg_ea.v, out cpu_byte_temp); - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_dummy = (byte)((uint)(cpu_byte_temp >> 1) | (cpu_flag_c ? 128u : 0u)); - Write(ref cpu_reg_ea.v, ref cpu_dummy); - cpu_flag_n = (cpu_dummy & 0x80) != 0; - cpu_flag_z = (cpu_dummy & 0xFF) == 0; - cpu_flag_c = (cpu_byte_temp & 1) != 0; - cpu_byte_temp = cpu_dummy; - cpu_int_temp = cpu_reg_a + cpu_byte_temp + (cpu_flag_c ? 1 : 0); - cpu_flag_n = (cpu_int_temp & 0x80) != 0; - cpu_flag_v = ((cpu_int_temp ^ cpu_reg_a) & (cpu_int_temp ^ cpu_byte_temp) & 0x80) != 0; - cpu_flag_z = (cpu_int_temp & 0xFF) == 0; - cpu_flag_c = cpu_int_temp >> 8 != 0; - cpu_reg_a = (byte)cpu_int_temp; - } - - private static void RTI__() - { - Read(ref cpu_reg_sp.v, out cpu_dummy); - Pull(out cpu_dummy); - register_p = cpu_dummy; - Pull(out cpu_reg_pc.l); - Pull(out cpu_reg_pc.h); - } - - private static void RTS__() - { - Read(ref cpu_reg_sp.v, out cpu_dummy); - Pull(out cpu_reg_pc.l); - Pull(out cpu_reg_pc.h); - cpu_reg_pc.v++; - Read(ref cpu_reg_pc.v, out cpu_dummy); - } - - private static void SAX__() - { - cpu_dummy = (byte)(cpu_reg_x & cpu_reg_a); - Write(ref cpu_reg_ea.v, ref cpu_dummy); - } - - private static void SBC__() - { - cpu_m ^= byte.MaxValue; - cpu_int_temp = cpu_reg_a + cpu_m + (cpu_flag_c ? 1 : 0); - cpu_flag_n = (cpu_int_temp & 0x80) != 0; - cpu_flag_v = ((cpu_int_temp ^ cpu_reg_a) & (cpu_int_temp ^ cpu_m) & 0x80) != 0; - cpu_flag_z = (cpu_int_temp & 0xFF) == 0; - cpu_flag_c = cpu_int_temp >> 8 != 0; - cpu_reg_a = (byte)cpu_int_temp; - } - - private static void SEC__() - { - cpu_flag_c = true; - } - - private static void SEI__() - { - cpu_flag_i = true; - } - - private static void SHX__() - { - cpu_byte_temp = (byte)(cpu_reg_x & (cpu_reg_ea.h + 1)); - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_y; - if (cpu_reg_ea.l < cpu_reg_y) - { - cpu_reg_ea.h = cpu_byte_temp; - } - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - } - - private static void SHY__() - { - cpu_byte_temp = (byte)(cpu_reg_y & (cpu_reg_ea.h + 1)); - Read(ref cpu_reg_ea.v, out cpu_dummy); - cpu_reg_ea.l += cpu_reg_x; - if (cpu_reg_ea.l < cpu_reg_x) - { - cpu_reg_ea.h = cpu_byte_temp; - } - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - } - - private static void SLO__() - { - Read(ref cpu_reg_ea.v, out cpu_byte_temp); - cpu_flag_c = (cpu_byte_temp & 0x80) != 0; - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_byte_temp <<= 1; - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_flag_n = (cpu_byte_temp & 0x80) != 0; - cpu_flag_z = (cpu_byte_temp & 0xFF) == 0; - cpu_reg_a |= cpu_byte_temp; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_z = (cpu_reg_a & 0xFF) == 0; - } - - private static void SRE__() - { - Read(ref cpu_reg_ea.v, out cpu_byte_temp); - cpu_flag_c = (cpu_byte_temp & 1) != 0; - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_byte_temp >>= 1; - Write(ref cpu_reg_ea.v, ref cpu_byte_temp); - cpu_flag_n = (cpu_byte_temp & 0x80) != 0; - cpu_flag_z = (cpu_byte_temp & 0xFF) == 0; - cpu_reg_a ^= cpu_byte_temp; - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_z = (cpu_reg_a & 0xFF) == 0; - } - - private static void STA__() - { - Write(ref cpu_reg_ea.v, ref cpu_reg_a); - } - - private static void STX__() - { - Write(ref cpu_reg_ea.v, ref cpu_reg_x); - } - - private static void STY__() - { - Write(ref cpu_reg_ea.v, ref cpu_reg_y); - } - - private static void TAX__() - { - cpu_reg_x = cpu_reg_a; - cpu_flag_n = (cpu_reg_x & 0x80) == 128; - cpu_flag_z = cpu_reg_x == 0; - } - - private static void TAY__() - { - cpu_reg_y = cpu_reg_a; - cpu_flag_n = (cpu_reg_y & 0x80) == 128; - cpu_flag_z = cpu_reg_y == 0; - } - - private static void TSX__() - { - cpu_reg_x = cpu_reg_sp.l; - cpu_flag_n = (cpu_reg_x & 0x80) != 0; - cpu_flag_z = cpu_reg_x == 0; - } - - private static void TXA__() - { - cpu_reg_a = cpu_reg_x; - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void TXS__() - { - cpu_reg_sp.l = cpu_reg_x; - } - - private static void TYA__() - { - cpu_reg_a = cpu_reg_y; - cpu_flag_n = (cpu_reg_a & 0x80) == 128; - cpu_flag_z = cpu_reg_a == 0; - } - - private static void XAA__() - { - cpu_reg_a = (byte)(cpu_reg_x & cpu_m); - cpu_flag_n = (cpu_reg_a & 0x80) != 0; - cpu_flag_z = (cpu_reg_a & 0xFF) == 0; - } - - private static void XAS__() - { - cpu_reg_sp.l = (byte)(cpu_reg_a & cpu_reg_x); - Write(ref cpu_reg_ea.v, ref cpu_reg_sp.l); - } - - private static void CPUWriteState(ref BinaryWriter bin) - { - bin.Write(cpu_reg_pc.v); - bin.Write(cpu_reg_sp.v); - bin.Write(cpu_reg_ea.v); - bin.Write(cpu_reg_a); - bin.Write(cpu_reg_x); - bin.Write(cpu_reg_y); - bin.Write(cpu_flag_n); - bin.Write(cpu_flag_v); - bin.Write(cpu_flag_d); - bin.Write(cpu_flag_i); - bin.Write(cpu_flag_z); - bin.Write(cpu_flag_c); - bin.Write(cpu_m); - bin.Write(cpu_opcode); - bin.Write(cpu_byte_temp); - bin.Write(cpu_int_temp); - bin.Write(cpu_int_temp1); - bin.Write(cpu_dummy); - bin.Write(cpu_bool_tmp); - bin.Write(temp_add.v); - bin.Write(CPU_IRQ_PIN); - bin.Write(CPU_NMI_PIN); - bin.Write(cpu_suspend_nmi); - bin.Write(cpu_suspend_irq); - } - - private static void CPUReadState(ref BinaryReader bin) - { - cpu_reg_pc.v = bin.ReadUInt16(); - cpu_reg_sp.v = bin.ReadUInt16(); - cpu_reg_ea.v = bin.ReadUInt16(); - cpu_reg_a = bin.ReadByte(); - cpu_reg_x = bin.ReadByte(); - cpu_reg_y = bin.ReadByte(); - cpu_flag_n = bin.ReadBoolean(); - cpu_flag_v = bin.ReadBoolean(); - cpu_flag_d = bin.ReadBoolean(); - cpu_flag_i = bin.ReadBoolean(); - cpu_flag_z = bin.ReadBoolean(); - cpu_flag_c = bin.ReadBoolean(); - cpu_m = bin.ReadByte(); - cpu_opcode = bin.ReadByte(); - cpu_byte_temp = bin.ReadByte(); - cpu_int_temp = bin.ReadInt32(); - cpu_int_temp1 = bin.ReadInt32(); - cpu_dummy = bin.ReadByte(); - cpu_bool_tmp = bin.ReadBoolean(); - temp_add.v = bin.ReadUInt16(); - CPU_IRQ_PIN = bin.ReadBoolean(); - CPU_NMI_PIN = bin.ReadBoolean(); - cpu_suspend_nmi = bin.ReadBoolean(); - cpu_suspend_irq = bin.ReadBoolean(); - } - - private static void DMAHardReset() - { - dma_DMCDMAWaitCycles = 0; - dma_OAMDMAWaitCycles = 0; - dma_isOamDma = false; - dma_oamdma_i = 0; - dma_DMCOn = false; - dma_OAMOn = false; - dma_DMC_occurring = false; - dma_OAM_occurring = false; - dma_OAMFinishCounter = 0; - dma_Oamaddress = 0; - dma_OAMCYCLE = 0; - dma_latch = 0; - reg_2004 = 8196; - } - - private static void DMASoftReset() - { - dma_DMCDMAWaitCycles = 0; - dma_OAMDMAWaitCycles = 0; - dma_isOamDma = false; - dma_oamdma_i = 0; - dma_DMCOn = false; - dma_OAMOn = false; - dma_DMC_occurring = false; - dma_OAM_occurring = false; - dma_OAMFinishCounter = 0; - dma_Oamaddress = 0; - dma_OAMCYCLE = 0; - dma_latch = 0; - } - - internal static void AssertDMCDMA() - { - if (dma_OAM_occurring) - { - if (dma_OAMCYCLE < 508) - { - dma_DMCDMAWaitCycles = (BUS_RW ? 1 : 0); - } - else - { - dma_DMCDMAWaitCycles = 4 - (512 - dma_OAMCYCLE); - } - } - else - { - if (dma_DMC_occurring) - { - return; - } - dma_DMCDMAWaitCycles = (BUS_RW ? 3 : 2); - if (dma_OAMFinishCounter == 3) - { - dma_DMCDMAWaitCycles++; - } - } - dma_isOamDma = false; - dma_DMCOn = true; - } - - private static void AssertOAMDMA() - { - if (!dma_OAM_occurring) - { - dma_OAMDMAWaitCycles = (apu_odd_cycle ? 1 : 2); - dma_isOamDma = true; - dma_OAMOn = true; - } - } - - private static void DMAClock() - { - if (dma_OAMFinishCounter > 0) - { - dma_OAMFinishCounter--; - } - if (!BUS_RW) - { - if (dma_DMCDMAWaitCycles > 0) - { - dma_DMCDMAWaitCycles--; - } - if (dma_OAMDMAWaitCycles > 0) - { - dma_OAMDMAWaitCycles--; - } - return; - } - if (dma_DMCOn) - { - dma_DMC_occurring = true; - dma_DMCOn = false; - if (dma_DMCDMAWaitCycles > 0) - { - if (BUS_ADDRESS == 16406 || BUS_ADDRESS == 16407) - { - Read(ref BUS_ADDRESS, out dma_dummy); - dma_DMCDMAWaitCycles--; - while (dma_DMCDMAWaitCycles > 0) - { - EmuClockComponents(); - dma_DMCDMAWaitCycles--; - } - } - else - { - if (dma_DMCDMAWaitCycles > 0) - { - EmuClockComponents(); - dma_DMCDMAWaitCycles--; - } - while (dma_DMCDMAWaitCycles > 0) - { - Read(ref BUS_ADDRESS, out dma_dummy); - dma_DMCDMAWaitCycles--; - } - } - } - DMCDoDMA(); - dma_DMC_occurring = false; - } - if (!dma_OAMOn) - { - return; - } - dma_OAM_occurring = true; - dma_OAMOn = false; - if (dma_OAMDMAWaitCycles > 0) - { - if (BUS_ADDRESS == 16406 || BUS_ADDRESS == 16407) - { - Read(ref BUS_ADDRESS, out dma_dummy); - dma_OAMDMAWaitCycles--; - while (dma_OAMDMAWaitCycles > 0) - { - EmuClockComponents(); - dma_OAMDMAWaitCycles--; - } - } - else - { - if (dma_OAMDMAWaitCycles > 0) - { - EmuClockComponents(); - dma_OAMDMAWaitCycles--; - } - while (dma_OAMDMAWaitCycles > 0) - { - Read(ref BUS_ADDRESS, out dma_dummy); - dma_OAMDMAWaitCycles--; - } - } - } - dma_OAMCYCLE = 0; - for (dma_oamdma_i = 0; dma_oamdma_i < 256; dma_oamdma_i++) - { - Read(ref dma_Oamaddress, out dma_latch); - dma_OAMCYCLE++; - Write(ref reg_2004, ref dma_latch); - dma_OAMCYCLE++; - dma_Oamaddress = (ushort)(++dma_Oamaddress & 0xFFFFu); - } - dma_OAMCYCLE = 0; - dma_OAMFinishCounter = 5; - dma_OAM_occurring = false; - } - - private static void DMAWriteState(ref BinaryWriter bin) - { - bin.Write(dma_DMCDMAWaitCycles); - bin.Write(dma_OAMDMAWaitCycles); - bin.Write(dma_isOamDma); - bin.Write(dma_oamdma_i); - bin.Write(dma_DMCOn); - bin.Write(dma_OAMOn); - bin.Write(dma_DMC_occurring); - bin.Write(dma_OAM_occurring); - bin.Write(dma_OAMFinishCounter); - bin.Write(dma_Oamaddress); - bin.Write(dma_OAMCYCLE); - bin.Write(dma_latch); - bin.Write(dma_dummy); - } - - private static void DMAReadState(ref BinaryReader bin) - { - dma_DMCDMAWaitCycles = bin.ReadInt32(); - dma_OAMDMAWaitCycles = bin.ReadInt32(); - dma_isOamDma = bin.ReadBoolean(); - dma_oamdma_i = bin.ReadInt32(); - dma_DMCOn = bin.ReadBoolean(); - dma_OAMOn = bin.ReadBoolean(); - dma_DMC_occurring = bin.ReadBoolean(); - dma_OAM_occurring = bin.ReadBoolean(); - dma_OAMFinishCounter = bin.ReadInt32(); - dma_Oamaddress = bin.ReadUInt16(); - dma_OAMCYCLE = bin.ReadInt32(); - dma_latch = bin.ReadByte(); - dma_dummy = bin.ReadByte(); - } - - private static void PollInterruptStatus() - { - if (!cpu_suspend_nmi) - { - if (PPU_NMI_Current & !PPU_NMI_Old) - { - CPU_NMI_PIN = true; - } - PPU_NMI_Old = (PPU_NMI_Current = false); - } - if (!cpu_suspend_irq) - { - CPU_IRQ_PIN = !cpu_flag_i && IRQFlags != 0; - } - if (CPU_NMI_PIN) - { - InterruptVector = 65530; - } - else - { - InterruptVector = 65534; - } - } - - private static void InterruptsWriteState(ref BinaryWriter bin) - { - bin.Write(IRQFlags); - bin.Write(PPU_NMI_Current); - bin.Write(PPU_NMI_Old); - bin.Write(InterruptVector); - } - - private static void InterruptsReadState(ref BinaryReader bin) - { - IRQFlags = bin.ReadInt32(); - PPU_NMI_Current = bin.ReadBoolean(); - PPU_NMI_Old = bin.ReadBoolean(); - InterruptVector = bin.ReadUInt16(); - } - - public static void SetupGameGenie(bool IsGameGenieActive, GameGenieCode[] GameGenieCodes) - { - if (mem_board != null) - { - mem_board.SetupGameGenie(IsGameGenieActive, GameGenieCodes); - } - } - - private static void MEMInitialize(IRom rom) - { - Tracer.WriteLine("Looking for mapper # " + rom.MapperNumber + "...."); - if (MyNesMain.IsBoardExist(rom.MapperNumber)) - { - Tracer.WriteLine("Mapper # " + rom.MapperNumber + " located, assigning..."); - mem_board = MyNesMain.GetBoard(rom.MapperNumber); - Tracer.WriteInformation("Mapper # " + rom.MapperNumber + " assigned successfully."); - if (mem_board.HasIssues) - { - Tracer.WriteWarning(MNInterfaceLanguage.Mapper + " # " + mem_board.MapperNumber + " [" + mem_board.Name + "] " + MNInterfaceLanguage.Message_Error17); - MyNesMain.VideoProvider.WriteWarningNotification(MNInterfaceLanguage.Mapper + " # " + mem_board.MapperNumber + " [" + mem_board.Name + "] " + MNInterfaceLanguage.Message_Error17, instant: false); - } - } - else - { - Tracer.WriteError("Mapper # " + rom.MapperNumber + " IS NOT LOCATED, mapper is not supported or unable to find it."); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Mapper + " # " + rom.MapperNumber + " " + MNInterfaceLanguage.Message_Error14, instant: false); - mem_board = MyNesMain.GetBoard(0); - Tracer.WriteWarning("Mapper # 0 [NROM] will be used instead, assigned successfully."); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Mapper + " # 0 [NROM] " + MNInterfaceLanguage.Message_Error15, instant: false); - } - mem_read_accesses = new MemReadAccess[65536]; - mem_write_accesses = new MemWriteAccess[65536]; - MEMMap(MEMReadWRAM, new ushort[2] { 0, 4096 }); - MEMMap(MEMWriteWRAM, new ushort[2] { 0, 4096 }); - MEMMap(PPUIORead, new ushort[2] { 8192, 12288 }); - MEMMap(PPUIOWrite, new ushort[2] { 8192, 12288 }); - MEMMap(APUIORead, new ushort[1] { 16384 }); - MEMMap(APUIOWrite, new ushort[1] { 16384 }); - MEMMap(mem_board.ReadEX, new ushort[1] { 20480 }); - MEMMap(mem_board.WriteEX, new ushort[1] { 20480 }); - MEMMap(mem_board.ReadSRM, new ushort[2] { 24576, 28672 }); - MEMMap(mem_board.WriteSRM, new ushort[2] { 24576, 28672 }); - MEMMap(mem_board.ReadPRG, new ushort[8] { 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440 }); - MEMMap(mem_board.WritePRG, new ushort[8] { 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440 }); - mem_board.Initialize(rom); - mem_wram = new byte[2048]; - } - - private static void MEMHardReset() - { - mem_wram = new byte[2048]; - mem_wram[8] = 247; - mem_wram[9] = 239; - mem_wram[10] = 223; - mem_wram[15] = 191; - Tracer.WriteLine("Reading SRAM ..."); - SRAMFileName = Path.Combine(MyNesMain.EmuSettings.SRAMFolder, Path.GetFileNameWithoutExtension(CurrentFilePath) + ".srm"); - if (File.Exists(SRAMFileName)) - { - FileStream fileStream = new FileStream(SRAMFileName, FileMode.Open, FileAccess.Read); - byte[] array = new byte[fileStream.Length]; - fileStream.Read(array, 0, array.Length); - fileStream.Flush(); - fileStream.Close(); - byte[] outData = new byte[0]; - ZlipWrapper.DecompressData(array, out outData); - mem_board.LoadSRAM(outData); - Tracer.WriteLine("SRAM read successfully."); - } - else - { - Tracer.WriteLine("SRAM file not found; rom has no SRAM or file not exist."); - } - ReloadGameGenieCodes(); - mem_board.HardReset(); - } - - public static void ReloadGameGenieCodes() - { - Tracer.WriteLine("Reading game genie codes (if available)...."); - GMFileName = Path.Combine(MyNesMain.EmuSettings.GameGenieFolder, Path.GetFileNameWithoutExtension(CurrentFilePath) + ".txt"); - mem_board.GameGenieCodes = new GameGenieCode[0]; - if (File.Exists(GMFileName)) - { - XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); - xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore; - xmlReaderSettings.IgnoreWhitespace = true; - XmlReader xmlReader = XmlReader.Create(GMFileName, xmlReaderSettings); - xmlReader.Read(); - xmlReader.Read(); - if (xmlReader.Name != "MyNesGameGenieCodesList") - { - xmlReader.Close(); - return; - } - GameGenie gameGenie = new GameGenie(); - List list = new List(); - while (xmlReader.Read()) - { - if (xmlReader.Name == "Code") - { - GameGenieCode item = default(GameGenieCode); - item.Enabled = true; - xmlReader.MoveToAttribute("code"); - item.Name = xmlReader.Value.ToString(); - if (item.Name.Length == 6) - { - item.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(item.Name), 6) | 0x8000; - item.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(item.Name), 6); - item.IsCompare = false; - } - else - { - item.Address = gameGenie.GetGGAddress(gameGenie.GetCodeAsHEX(item.Name), 8) | 0x8000; - item.Value = gameGenie.GetGGValue(gameGenie.GetCodeAsHEX(item.Name), 8); - item.Compare = gameGenie.GetGGCompareValue(gameGenie.GetCodeAsHEX(item.Name)); - item.IsCompare = true; - } - list.Add(item); - } - } - xmlReader.Close(); - if (list.Count > 0) - { - mem_board.GameGenieCodes = list.ToArray(); - Tracer.WriteInformation("Game Genie codes loaded successfully, total of " + list.Count); - } - else - { - Tracer.WriteError("There is no Game Genie code in the file to load."); - } - } - else - { - Tracer.WriteWarning("No Game Genie file found for this game."); - } - } - - private static void MEMMap(MemReadAccess readAccess, ushort[] addresses) - { - for (int i = 0; i < addresses.Length; i++) - { - mem_read_accesses[(addresses[i] & 0xF000) >> 12] = readAccess; - } - } - - private static void MEMMap(MemWriteAccess writeAccess, ushort[] addresses) - { - for (int i = 0; i < addresses.Length; i++) - { - mem_write_accesses[(addresses[i] & 0xF000) >> 12] = writeAccess; - } - } - - private static void MEMReadWRAM(ref ushort addr, out byte value) - { - value = mem_wram[addr & 0x7FF]; - } - - private static void MEMWriteWRAM(ref ushort addr, ref byte value) - { - mem_wram[addr & 0x7FF] = value; - } - - internal static void Read(ref ushort addr, out byte value) - { - BUS_RW = true; - BUS_ADDRESS = addr; - EmuClockComponents(); - mem_read_accesses[(addr & 0xF000) >> 12](ref addr, out value); - } - - private static void Write(ref ushort addr, ref byte value) - { - BUS_RW = false; - BUS_ADDRESS = addr; - EmuClockComponents(); - mem_write_accesses[(addr & 0xF000) >> 12](ref addr, ref value); - } - - internal static void SaveSRAM() - { - if (mem_board != null && MyNesMain.EmuSettings.SaveSRAMAtEmuShutdown && mem_board.SRAMSaveRequired) - { - Tracer.WriteLine("Saving SRAM ..."); - byte[] outData = new byte[0]; - ZlipWrapper.CompressData(mem_board.GetSRAMBuffer(), out outData); - FileStream fileStream = new FileStream(SRAMFileName, FileMode.Create, FileAccess.Write); - fileStream.Write(outData, 0, outData.Length); - fileStream.Flush(); - fileStream.Close(); - Tracer.WriteLine("SRAM saved successfully."); - } - } - - private static void MEMWriteState(ref BinaryWriter bin) - { - mem_board.WriteStateData(ref bin); - bin.Write(mem_wram); - bin.Write(BUS_RW); - bin.Write(BUS_ADDRESS); - } - - private static void MEMReadState(ref BinaryReader bin) - { - mem_board.ReadStateData(ref bin); - bin.Read(mem_wram, 0, mem_wram.Length); - BUS_RW = bin.ReadBoolean(); - BUS_ADDRESS = bin.ReadUInt16(); - } - - private static void PORTSInitialize() - { - if (joypad1 == null) - { - joypad1 = new BlankJoypad(); - } - if (joypad2 == null) - { - joypad2 = new BlankJoypad(); - } - if (joypad3 == null) - { - joypad3 = new BlankJoypad(); - } - if (joypad4 == null) - { - joypad4 = new BlankJoypad(); - } - } - - public static void SetupControllers(IJoypadConnecter joy1, IJoypadConnecter joy2, IJoypadConnecter joy3, IJoypadConnecter joy4) - { - joypad1 = joy1; - joypad2 = joy2; - joypad3 = joy3; - joypad4 = joy4; - } - - public static void SetupVSUnisystemDIP(IVSUnisystemDIPConnecter uni) - { - } - - public static void SetupControllersP1(IJoypadConnecter joy) - { - joypad1 = joy; - } - - public static void SetupControllersP2(IJoypadConnecter joy) - { - joypad2 = joy; - } - - public static void SetupControllersP3(IJoypadConnecter joy) - { - joypad3 = joy; - } - - public static void SetupControllersP4(IJoypadConnecter joy) - { - joypad4 = joy; - } - - public static void DestroyJoypads() - { - if (joypad1 == null) - { - joypad1 = new BlankJoypad(); - } - else - { - joypad1.Destroy(); - } - if (joypad2 == null) - { - joypad2 = new BlankJoypad(); - } - else - { - joypad1.Destroy(); - } - if (joypad3 == null) - { - joypad3 = new BlankJoypad(); - } - else - { - joypad1.Destroy(); - } - if (joypad4 == null) - { - joypad4 = new BlankJoypad(); - } - else - { - joypad1.Destroy(); - } - } - - private static void PORTWriteState(ref BinaryWriter bin) - { - bin.Write(PORT0); - bin.Write(PORT1); - bin.Write(inputStrobe); - } - - private static void PORTReadState(ref BinaryReader bin) - { - PORT0 = bin.ReadInt32(); - PORT1 = bin.ReadInt32(); - inputStrobe = bin.ReadInt32(); - } - - public static void SetupPalette(int[] pal) - { - ppu_palette = pal; - } - - private static void PPUInitialize() - { - ppu_reg_update_func = new Action[8] { PPUOnRegister2000, PPUOnRegister2001, PPUOnRegister2002, PPUOnRegister2003, PPUOnRegister2004, PPUOnRegister2005, PPUOnRegister2006, PPUOnRegister2007 }; - ppu_reg_read_func = new Action[8] { PPURead2000, PPURead2001, PPURead2002, PPURead2003, PPURead2004, PPURead2005, PPURead2006, PPURead2007 }; - ppu_bkg_fetches = new Action[8] { PPUBKFetch0, PPUBKFetch1, PPUBKFetch2, PPUBKFetch3, PPUBKFetch4, PPUBKFetch5, PPUBKFetch6, PPUBKFetch7 }; - ppu_spr_fetches = new Action[8] { PPUBKFetch0, PPUBKFetch1, PPUBKFetch2, PPUBKFetch3, PPUSPRFetch0, PPUSPRFetch1, PPUSPRFetch2, PPUSPRFetch3 }; - ppu_oam_phases = new Action[9] { PPUOamPhase0, PPUOamPhase1, PPUOamPhase2, PPUOamPhase3, PPUOamPhase4, PPUOamPhase5, PPUOamPhase6, PPUOamPhase7, PPUOamPhase8 }; - ppu_h_clocks = new Action[341]; - ppu_h_clocks[0] = PPUHClock_000_Idle; - for (int i = 1; i < 257; i++) - { - ppu_h_clocks[i] = PPUHClock_1_256_BKGClocks; - } - for (int j = 257; j < 321; j++) - { - ppu_h_clocks[j] = PPUHClock_257_320_SPRClocks; - } - for (int k = 321; k < 337; k++) - { - ppu_h_clocks[k] = PPUHClock_321_336_DUMClocks; - } - for (int l = 337; l < 341; l++) - { - ppu_h_clocks[l] = PPUHClock_337_340_DUMClocks; - } - ppu_v_clocks = new Action[320]; - for (int m = 0; m < 240; m++) - { - ppu_v_clocks[m] = PPUScanlineRender; - } - ppu_v_clocks[240] = PPUScanlineVBLANK; - ppu_oam_bank = new byte[256]; - ppu_oam_bank_secondary = new byte[32]; - ppu_palette_bank = new byte[32]; - ppu_bkg_pixels = new int[512]; - ppu_spr_pixels = new int[512]; - ppu_screen_pixels = new int[61440]; - ppu_palette = NTSCPaletteGenerator.GeneratePalette(); - } - - private static void PPUHardReset() - { - ppu_reg_2001_grayscale = 243; - switch (Region) - { - case EmuRegion.NTSC: - ppu_clock_vblank_start = 241; - ppu_clock_vblank_end = 261; - ppu_use_odd_cycle = true; - break; - case EmuRegion.PALB: - ppu_clock_vblank_start = 241; - ppu_clock_vblank_end = 311; - ppu_use_odd_cycle = false; - break; - case EmuRegion.DENDY: - { - ppu_clock_vblank_start = 291; - ppu_clock_vblank_end = 311; - for (int i = 241; i <= 290; i++) - { - ppu_v_clocks[i] = PPUScanlineVBLANK; - } - ppu_use_odd_cycle = false; - break; - } - } - ppu_v_clocks[ppu_clock_vblank_start] = PPUScanlineVBLANKStart; - for (int j = ppu_clock_vblank_start + 1; j <= ppu_clock_vblank_end - 1; j++) - { - ppu_v_clocks[j] = PPUScanlineVBLANK; - } - ppu_v_clocks[ppu_clock_vblank_end] = PPUScanlineVBLANKEnd; - ppu_oam_bank = new byte[256]; - ppu_oam_bank_secondary = new byte[32]; - PPUOamReset(); - ppu_palette_bank = new byte[32] - { - 9, 1, 0, 1, 0, 2, 2, 13, 8, 16, - 8, 36, 0, 0, 4, 44, 9, 1, 52, 3, - 0, 4, 0, 20, 8, 58, 0, 2, 0, 32, - 44, 8 - }; - ppu_reg_io_db = 0; - ppu_reg_io_addr = 0; - ppu_reg_access_happened = false; - ppu_reg_access_w = false; - ppu_reg_2000_vram_address_increament = 1; - ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites = 0; - ppu_reg_2000_background_pattern_table_address = 0; - ppu_reg_2000_Sprite_size = 0; - ppu_reg_2000_VBI = false; - ppu_reg_2001_show_background_in_leftmost_8_pixels_of_screen = false; - ppu_reg_2001_show_sprites_in_leftmost_8_pixels_of_screen = false; - ppu_reg_2001_show_background = false; - ppu_reg_2001_show_sprites = false; - ppu_reg_2001_grayscale = 63; - ppu_reg_2001_emphasis = 0; - ppu_reg_2002_SpriteOverflow = false; - ppu_reg_2002_Sprite0Hit = false; - ppu_reg_2002_VblankStartedFlag = false; - ppu_reg_2003_oam_addr = 0; - ppu_is_sprfetch = false; - ppu_use_odd_swap = false; - ppu_clock_h = 0; - ppu_clock_v = 0; - } - - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - private static void PPUClock() - { - mem_board.OnPPUClock(); - ppu_v_clocks[ppu_clock_v](); - ppu_clock_h++; - if (ppu_clock_h >= 341) - { - mem_board.OnPPUScanlineTick(); - if (ppu_clock_v == ppu_clock_vblank_end) - { - ppu_clock_v = 0; - ppu_frame_finished = true; - } - else - { - ppu_clock_v++; - } - ppu_clock_h -= 341; - } - if (ppu_reg_access_happened) - { - ppu_reg_access_happened = false; - ppu_reg_update_func[ppu_reg_io_addr](); - } - } - - public static int GetPixel(int x, int y) - { - return ppu_screen_pixels[y * 256 + x]; - } - - private static void PPUScanlineRender() - { - ppu_h_clocks[ppu_clock_h](); - } - - private static void PPUScanlineVBLANKStart() - { - ppu_is_nmi_time = (ppu_clock_h >= 1) & (ppu_clock_h <= 3); - if (ppu_is_nmi_time) - { - if (ppu_clock_h == 1) - { - ppu_reg_2002_VblankStartedFlag = true; - } - PPU_NMI_Current = ppu_reg_2002_VblankStartedFlag & ppu_reg_2000_VBI; - } - } - - private static void PPUScanlineVBLANKEnd() - { - ppu_is_nmi_time = (ppu_clock_h >= 1) & (ppu_clock_h <= 3); - if (ppu_clock_h == 1) - { - ppu_reg_2002_Sprite0Hit = false; - ppu_reg_2002_VblankStartedFlag = false; - ppu_reg_2002_SpriteOverflow = false; - } - PPUScanlineRender(); - if (ppu_use_odd_cycle && ppu_clock_h == 339) - { - ppu_use_odd_swap = !ppu_use_odd_swap; - if (!ppu_use_odd_swap & (ppu_reg_2001_show_background || ppu_reg_2001_show_sprites)) - { - ppu_odd_swap_done = true; - ppu_clock_h++; - } - } - } - - private static void PPUScanlineVBLANK() - { - } - - private static void PPUHClock_000_Idle() - { - if (ppu_odd_swap_done) - { - ppu_bkg_fetches[1](); - ppu_odd_swap_done = false; - } - } - - private static void PPUHClock_1_256_BKGClocks() - { - if (ppu_reg_2001_show_background || ppu_reg_2001_show_sprites) - { - if (ppu_clock_v != ppu_clock_vblank_end) - { - if (ppu_clock_h > 0 && ppu_clock_h < 65) - { - ppu_oam_bank_secondary[(ppu_clock_h - 1) & 0x1F] = byte.MaxValue; - } - else - { - if (ppu_clock_h == 65) - { - PPUOamReset(); - } - if (((ppu_clock_h - 1) & 1) == 0) - { - PPUOamEvFetch(); - } - else - { - ppu_oam_phases[ppu_phase_index](); - } - if (ppu_clock_h == 256) - { - PPUOamClear(); - } - } - } - ppu_bkg_fetches[(ppu_clock_h - 1) & 7](); - if (ppu_clock_v < 240) - { - RenderPixel(); - } - } - else - { - if (ppu_clock_v >= 240) - { - return; - } - if ((ppu_vram_addr & 0x3F00) == 16128) - { - if ((ppu_vram_addr & 3) == 0) - { - ppu_screen_pixels[ppu_clock_h - 1 + ppu_clock_v * 256] = ppu_palette[(ppu_palette_bank[ppu_vram_addr & 0xC] & ppu_reg_2001_grayscale) | ppu_reg_2001_emphasis]; - } - else - { - ppu_screen_pixels[ppu_clock_h - 1 + ppu_clock_v * 256] = ppu_palette[(ppu_palette_bank[ppu_vram_addr & 0x1F] & ppu_reg_2001_grayscale) | ppu_reg_2001_emphasis]; - } - } - else - { - ppu_screen_pixels[ppu_clock_h - 1 + ppu_clock_v * 256] = ppu_palette[(ppu_palette_bank[0] & ppu_reg_2001_grayscale) | ppu_reg_2001_emphasis]; - } - } - } - - private static void PPUHClock_257_320_SPRClocks() - { - if (ppu_reg_2001_show_background || ppu_reg_2001_show_sprites) - { - ppu_spr_fetches[(ppu_clock_h - 1) & 7](); - if (ppu_clock_h == 257) - { - ppu_vram_addr = (ushort)((ppu_vram_addr & 0x7BE0u) | (ppu_vram_addr_temp & 0x41Fu)); - } - if (ppu_clock_v == ppu_clock_vblank_end && ppu_clock_h >= 280 && ppu_clock_h <= 304) - { - ppu_vram_addr = (ushort)((ppu_vram_addr & 0x41Fu) | (ppu_vram_addr_temp & 0x7BE0u)); - } - } - } - - private static void PPUHClock_321_336_DUMClocks() - { - if (ppu_reg_2001_show_background || ppu_reg_2001_show_sprites) - { - ppu_bkg_fetches[(ppu_clock_h - 1) & 7](); - } - } - - private static void PPUHClock_337_340_DUMClocks() - { - if (ppu_reg_2001_show_background || ppu_reg_2001_show_sprites) - { - ppu_bkg_fetches[(ppu_clock_h - 1) & 1](); - } - } - - private static void PPUBKFetch0() - { - ppu_bkgfetch_nt_addr = (ushort)(0x2000u | (ppu_vram_addr & 0xFFFu)); - mem_board.OnPPUAddressUpdate(ref ppu_bkgfetch_nt_addr); - } - - private static void PPUBKFetch1() - { - mem_board.ReadNMT(ref ppu_bkgfetch_nt_addr, out ppu_bkgfetch_nt_data); - } - - private static void PPUBKFetch2() - { - ppu_bkgfetch_at_addr = (ushort)(0x23C0u | (ppu_vram_addr & 0xC00u) | ((uint)(ppu_vram_addr >> 4) & 0x38u) | ((uint)(ppu_vram_addr >> 2) & 7u)); - mem_board.OnPPUAddressUpdate(ref ppu_bkgfetch_at_addr); - } - - private static void PPUBKFetch3() - { - mem_board.ReadNMT(ref ppu_bkgfetch_at_addr, out ppu_bkgfetch_at_data); - ppu_bkgfetch_at_data = (byte)(ppu_bkgfetch_at_data >> (((ppu_vram_addr >> 4) & 4) | (ppu_vram_addr & 2))); - } - - private static void PPUBKFetch4() - { - ppu_bkgfetch_lb_addr = (ushort)((uint)(ppu_reg_2000_background_pattern_table_address | (ppu_bkgfetch_nt_data << 4)) | ((uint)(ppu_vram_addr >> 12) & 7u)); - mem_board.OnPPUAddressUpdate(ref ppu_bkgfetch_lb_addr); - } - - private static void PPUBKFetch5() - { - mem_board.ReadCHR(ref ppu_bkgfetch_lb_addr, out ppu_bkgfetch_lb_data); - } - - private static void PPUBKFetch6() - { - ppu_bkgfetch_hb_addr = (ushort)((uint)(ppu_reg_2000_background_pattern_table_address | (ppu_bkgfetch_nt_data << 4)) | 8u | ((uint)(ppu_vram_addr >> 12) & 7u)); - mem_board.OnPPUAddressUpdate(ref ppu_bkgfetch_hb_addr); - } - - private static void PPUBKFetch7() - { - mem_board.ReadCHR(ref ppu_bkgfetch_hb_addr, out ppu_bkgfetch_hb_data); - ppu_bkg_render_pos = ppu_clock_h + 8; - ppu_bkg_render_pos %= 336; - if (ppu_clock_h == 256) - { - if ((ppu_vram_addr & 0x7000) != 28672) - { - ppu_vram_addr += 4096; - } - else - { - ppu_vram_addr ^= 28672; - switch (ppu_vram_addr & 0x3E0) - { - case 928: - ppu_vram_addr ^= 2976; - break; - case 992: - ppu_vram_addr ^= 992; - break; - default: - ppu_vram_addr += 32; - break; - } - } - } - else if ((ppu_vram_addr & 0x1F) == 31) - { - ppu_vram_addr ^= 1055; - } - else - { - ppu_vram_addr++; - } - for (ppu_bkg_render_i = 0; ppu_bkg_render_i < 8; ppu_bkg_render_i++) - { - ppu_bkg_render_tmp_val = ((ppu_bkgfetch_at_data << 2) & 0xC) | ((ppu_bkgfetch_lb_data >> 7) & 1) | ((ppu_bkgfetch_hb_data >> 6) & 2); - ppu_bkg_pixels[ppu_bkg_render_i + ppu_bkg_render_pos] = ppu_bkg_render_tmp_val; - ppu_bkgfetch_lb_data <<= 1; - ppu_bkgfetch_hb_data <<= 1; - } - } - - private static void PPUSPRFetch0() - { - ppu_sprfetch_slot = (ppu_clock_h - 1 >> 3) & 7; - ppu_sprfetch_slot = 7 - ppu_sprfetch_slot; - ppu_sprfetch_y_data = ppu_oam_bank_secondary[ppu_sprfetch_slot * 4]; - ppu_sprfetch_t_data = ppu_oam_bank_secondary[ppu_sprfetch_slot * 4 + 1]; - ppu_sprfetch_at_data = ppu_oam_bank_secondary[ppu_sprfetch_slot * 4 + 2]; - ppu_sprfetch_x_data = ppu_oam_bank_secondary[ppu_sprfetch_slot * 4 + 3]; - ppu_temp_comparator = (ppu_clock_v - ppu_sprfetch_y_data) ^ (((ppu_sprfetch_at_data & 0x80u) != 0) ? 15 : 0); - if (ppu_reg_2000_Sprite_size == 16) - { - ppu_sprfetch_lb_addr = (ushort)(((uint)(ppu_sprfetch_t_data << 12) & 0x1000u) | ((uint)(ppu_sprfetch_t_data << 4) & 0xFE0u) | ((uint)(ppu_temp_comparator << 1) & 0x10u) | ((uint)ppu_temp_comparator & 7u)); - } - else - { - ppu_sprfetch_lb_addr = (ushort)((uint)(ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites | (ppu_sprfetch_t_data << 4)) | ((uint)ppu_temp_comparator & 7u)); - } - mem_board.OnPPUAddressUpdate(ref ppu_sprfetch_lb_addr); - } - - private static void PPUSPRFetch1() - { - ppu_is_sprfetch = true; - mem_board.ReadCHR(ref ppu_sprfetch_lb_addr, out ppu_sprfetch_lb_data); - ppu_is_sprfetch = false; - if ((ppu_sprfetch_at_data & 0x40u) != 0) - { - ppu_sprfetch_lb_data = reverseLookup[ppu_sprfetch_lb_data]; - } - } - - private static void PPUSPRFetch2() - { - ppu_sprfetch_hb_addr = (ushort)(ppu_sprfetch_lb_addr | 8u); - mem_board.OnPPUAddressUpdate(ref ppu_sprfetch_hb_addr); - } - - private static void PPUSPRFetch3() - { - ppu_is_sprfetch = true; - mem_board.ReadCHR(ref ppu_sprfetch_hb_addr, out ppu_sprfetch_hb_data); - ppu_is_sprfetch = false; - if ((ppu_sprfetch_at_data & 0x40u) != 0) - { - ppu_sprfetch_hb_data = reverseLookup[ppu_sprfetch_hb_data]; - } - if (ppu_sprfetch_x_data == byte.MaxValue) - { - return; - } - for (ppu_bkg_render_i = 0; ppu_bkg_render_i < 8; ppu_bkg_render_i++) - { - if (ppu_sprfetch_x_data < byte.MaxValue) - { - ppu_bkg_render_tmp_val = ((ppu_sprfetch_at_data << 2) & 0xC) | ((ppu_sprfetch_lb_data >> 7) & 1) | ((ppu_sprfetch_hb_data >> 6) & 2); - if (((uint)ppu_bkg_render_tmp_val & 3u) != 0) - { - ppu_spr_pixels[ppu_sprfetch_x_data] = ppu_bkg_render_tmp_val; - if (ppu_sprfetch_slot == 0 && ppu_sprite0_should_hit) - { - ppu_spr_pixels[ppu_sprfetch_x_data] |= 16384; - } - if ((ppu_sprfetch_at_data & 0x20) == 0) - { - ppu_spr_pixels[ppu_sprfetch_x_data] |= 32768; - } - } - ppu_sprfetch_lb_data <<= 1; - ppu_sprfetch_hb_data <<= 1; - ppu_sprfetch_x_data++; - } - } - } - - private static void PPUOamReset() - { - ppu_oamev_n = 0; - ppu_oamev_m = 0; - ppu_oamev_slot = 0; - ppu_phase_index = 0; - ppu_sprite0_should_hit = false; - } - - private static void PPUOamClear() - { - for (int i = 0; i < ppu_spr_pixels.Length; i++) - { - ppu_spr_pixels[i] = 0; - } - } - - private static void PPUOamEvFetch() - { - ppu_fetch_data = ppu_oam_bank[ppu_oamev_n * 4 + ppu_oamev_m]; - } - - private static void PPUOamPhase0() - { - ppu_oamev_compare = ppu_clock_v >= ppu_fetch_data && ppu_clock_v < ppu_fetch_data + ppu_reg_2000_Sprite_size; - if (ppu_oamev_compare) - { - ppu_oam_bank_secondary[ppu_oamev_slot * 4] = ppu_fetch_data; - ppu_oamev_m = 1; - ppu_phase_index++; - if (ppu_oamev_n == 0) - { - ppu_sprite0_should_hit = true; - } - } - else - { - ppu_oamev_m = 0; - ppu_oamev_n++; - if (ppu_oamev_n == 64) - { - ppu_oamev_n = 0; - ppu_phase_index = 8; - } - } - } - - private static void PPUOamPhase1() - { - ppu_oam_bank_secondary[ppu_oamev_slot * 4 + ppu_oamev_m] = ppu_fetch_data; - ppu_oamev_m = 2; - ppu_phase_index++; - } - - private static void PPUOamPhase2() - { - ppu_oam_bank_secondary[ppu_oamev_slot * 4 + ppu_oamev_m] = ppu_fetch_data; - ppu_oamev_m = 3; - ppu_phase_index++; - } - - private static void PPUOamPhase3() - { - ppu_oam_bank_secondary[ppu_oamev_slot * 4 + ppu_oamev_m] = ppu_fetch_data; - ppu_oamev_m = 0; - ppu_oamev_n++; - ppu_oamev_slot++; - if (ppu_oamev_n == 64) - { - ppu_oamev_n = 0; - ppu_phase_index = 8; - } - else if (ppu_oamev_slot < 8) - { - ppu_phase_index = 0; - } - else if (ppu_oamev_slot == 8) - { - ppu_phase_index = 4; - } - } - - private static void PPUOamPhase4() - { - ppu_oamev_compare = ppu_clock_v >= ppu_fetch_data && ppu_clock_v < ppu_fetch_data + ppu_reg_2000_Sprite_size; - if (ppu_oamev_compare) - { - ppu_oamev_m = 1; - ppu_phase_index++; - ppu_reg_2002_SpriteOverflow = true; - return; - } - ppu_oamev_m++; - if (ppu_oamev_m == 4) - { - ppu_oamev_m = 0; - } - ppu_oamev_n++; - if (ppu_oamev_n == 64) - { - ppu_oamev_n = 0; - ppu_phase_index = 8; - } - else - { - ppu_phase_index = 4; - } - } - - private static void PPUOamPhase5() - { - ppu_oamev_m = 2; - ppu_phase_index++; - } - - private static void PPUOamPhase6() - { - ppu_oamev_m = 3; - ppu_phase_index++; - } - - private static void PPUOamPhase7() - { - ppu_oamev_m = 0; - ppu_oamev_n++; - if (ppu_oamev_n == 64) - { - ppu_oamev_n = 0; - } - ppu_phase_index = 8; - } - - private static void PPUOamPhase8() - { - ppu_oamev_n++; - if (ppu_oamev_n >= 64) - { - ppu_oamev_n = 0; - } - } - - private static void RenderPixel() - { - if (ppu_clock_v == ppu_clock_vblank_end) - { - return; - } - ppu_render_x = ppu_clock_h - 1; - ppu_render_y = ppu_clock_v * 256; - if (ppu_render_x < 8) - { - if (ppu_reg_2001_show_background_in_leftmost_8_pixels_of_screen) - { - ppu_bkg_current_pixel = 0x3F00 | ppu_bkg_pixels[ppu_render_x + ppu_vram_finex]; - } - else - { - ppu_bkg_current_pixel = 16128; - } - if (ppu_reg_2001_show_sprites_in_leftmost_8_pixels_of_screen) - { - ppu_spr_current_pixel = 0x3F10 | ppu_spr_pixels[ppu_render_x]; - } - else - { - ppu_spr_current_pixel = 16144; - } - } - else - { - if (!ppu_reg_2001_show_background) - { - ppu_bkg_current_pixel = 16128; - } - else - { - ppu_bkg_current_pixel = 0x3F00 | ppu_bkg_pixels[ppu_render_x + ppu_vram_finex]; - } - if (!ppu_reg_2001_show_sprites || ppu_clock_v == 0) - { - ppu_spr_current_pixel = 16144; - } - else - { - ppu_spr_current_pixel = 0x3F10 | ppu_spr_pixels[ppu_render_x]; - } - } - ppu_current_pixel = 0; - if (((uint)ppu_spr_current_pixel & 0x8000u) != 0) - { - ppu_current_pixel = ppu_spr_current_pixel; - } - else - { - ppu_current_pixel = ppu_bkg_current_pixel; - } - if ((ppu_bkg_current_pixel & 3) == 0) - { - ppu_current_pixel = ppu_spr_current_pixel; - } - else if ((ppu_spr_current_pixel & 3) == 0) - { - ppu_current_pixel = ppu_bkg_current_pixel; - } - else if (((uint)ppu_spr_pixels[ppu_render_x] & 0x4000u) != 0) - { - ppu_reg_2002_Sprite0Hit = true; - } - if ((ppu_current_pixel & 3) == 0) - { - ppu_screen_pixels[ppu_render_x + ppu_render_y] = ppu_palette[(ppu_palette_bank[ppu_current_pixel & 0xC] & ppu_reg_2001_grayscale) | ppu_reg_2001_emphasis]; - } - else - { - ppu_screen_pixels[ppu_render_x + ppu_render_y] = ppu_palette[(ppu_palette_bank[ppu_current_pixel & 0x1F] & ppu_reg_2001_grayscale) | ppu_reg_2001_emphasis]; - } - } - - private static void PPUIORead(ref ushort addr, out byte value) - { - ppu_reg_io_addr = (byte)(addr & 7u); - ppu_reg_access_happened = true; - ppu_reg_access_w = false; - ppu_reg_read_func[ppu_reg_io_addr](); - value = ppu_reg_io_db; - } - - private static void PPUIOWrite(ref ushort addr, ref byte value) - { - ppu_reg_io_addr = (byte)(addr & 7u); - ppu_reg_io_db = value; - ppu_reg_access_w = true; - ppu_reg_access_happened = true; - } - - private static void PPUOnRegister2000() - { - if (ppu_reg_access_w) - { - ppu_vram_addr_temp = (ushort)((ppu_vram_addr_temp & 0x73FFu) | (uint)((ppu_reg_io_db & 3) << 10)); - if ((ppu_reg_io_db & 4u) != 0) - { - ppu_reg_2000_vram_address_increament = 32; - } - else - { - ppu_reg_2000_vram_address_increament = 1; - } - if ((ppu_reg_io_db & 8u) != 0) - { - ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites = 4096; - } - else - { - ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites = 0; - } - if ((ppu_reg_io_db & 0x10u) != 0) - { - ppu_reg_2000_background_pattern_table_address = 4096; - } - else - { - ppu_reg_2000_background_pattern_table_address = 0; - } - if ((ppu_reg_io_db & 0x20u) != 0) - { - ppu_reg_2000_Sprite_size = 16; - } - else - { - ppu_reg_2000_Sprite_size = 8; - } - if (!ppu_reg_2000_VBI && (ppu_reg_io_db & 0x80u) != 0 && ppu_reg_2002_VblankStartedFlag) - { - PPU_NMI_Current = true; - } - ppu_reg_2000_VBI = (ppu_reg_io_db & 0x80) != 0; - if (!ppu_reg_2000_VBI && ppu_is_nmi_time) - { - PPU_NMI_Current = false; - } - } - } - - private static void PPUOnRegister2001() - { - if (ppu_reg_access_w) - { - ppu_reg_2001_show_background_in_leftmost_8_pixels_of_screen = (ppu_reg_io_db & 2) != 0; - ppu_reg_2001_show_sprites_in_leftmost_8_pixels_of_screen = (ppu_reg_io_db & 4) != 0; - ppu_reg_2001_show_background = (ppu_reg_io_db & 8) != 0; - ppu_reg_2001_show_sprites = (ppu_reg_io_db & 0x10) != 0; - ppu_reg_2001_grayscale = ((((uint)ppu_reg_io_db & (true ? 1u : 0u)) != 0) ? 48 : 63); - ppu_reg_2001_emphasis = (ppu_reg_io_db & 0xE0) << 1; - } - } - - private static void PPUOnRegister2002() - { - if (!ppu_reg_access_w) - { - ppu_vram_flip_flop = false; - ppu_reg_2002_VblankStartedFlag = false; - if (ppu_clock_v == ppu_clock_vblank_start) - { - PPU_NMI_Current = ppu_reg_2002_VblankStartedFlag & ppu_reg_2000_VBI; - } - } - } - - private static void PPUOnRegister2003() - { - if (ppu_reg_access_w) - { - ppu_reg_2003_oam_addr = ppu_reg_io_db; - } - } - - private static void PPUOnRegister2004() - { - if (ppu_reg_access_w) - { - if (ppu_clock_v < 240 && IsRenderingOn()) - { - ppu_reg_io_db = byte.MaxValue; - } - if ((ppu_reg_2003_oam_addr & 3) == 2) - { - ppu_reg_io_db &= 227; - } - ppu_oam_bank[ppu_reg_2003_oam_addr] = ppu_reg_io_db; - ppu_reg_2003_oam_addr = (byte)((uint)(ppu_reg_2003_oam_addr + 1) & 0xFFu); - } - } - - private static void PPUOnRegister2005() - { - if (ppu_reg_access_w) - { - if (!ppu_vram_flip_flop) - { - ppu_vram_addr_temp = (ushort)((ppu_vram_addr_temp & 0x7FE0u) | (uint)((ppu_reg_io_db & 0xF8) >> 3)); - ppu_vram_finex = (byte)(ppu_reg_io_db & 7u); - } - else - { - ppu_vram_addr_temp = (ushort)((ppu_vram_addr_temp & 0xC1Fu) | (uint)((ppu_reg_io_db & 7) << 12) | (uint)((ppu_reg_io_db & 0xF8) << 2)); - } - ppu_vram_flip_flop = !ppu_vram_flip_flop; - } - } - - private static void PPUOnRegister2006() - { - if (ppu_reg_access_w) - { - if (!ppu_vram_flip_flop) - { - ppu_vram_addr_temp = (ushort)((ppu_vram_addr_temp & 0xFFu) | (uint)((ppu_reg_io_db & 0x3F) << 8)); - } - else - { - ppu_vram_addr_temp = (ushort)((ppu_vram_addr_temp & 0x7F00u) | ppu_reg_io_db); - ppu_vram_addr = ppu_vram_addr_temp; - mem_board.OnPPUAddressUpdate(ref ppu_vram_addr); - } - ppu_vram_flip_flop = !ppu_vram_flip_flop; - } - } - - private static void PPUOnRegister2007() - { - if (ppu_reg_access_w) - { - ppu_vram_addr_access_temp = (ushort)(ppu_vram_addr & 0x3FFFu); - if (ppu_vram_addr_access_temp < 8192) - { - mem_board.WriteCHR(ref ppu_vram_addr_access_temp, ref ppu_reg_io_db); - } - else if (ppu_vram_addr_access_temp < 16128) - { - mem_board.WriteNMT(ref ppu_vram_addr_access_temp, ref ppu_reg_io_db); - } - else if ((ppu_vram_addr_access_temp & 3u) != 0) - { - ppu_palette_bank[ppu_vram_addr_access_temp & 0x1F] = ppu_reg_io_db; - } - else - { - ppu_palette_bank[ppu_vram_addr_access_temp & 0xC] = ppu_reg_io_db; - } - } - else - { - if ((ppu_vram_addr & 0x3F00) == 16128) - { - ppu_vram_addr_access_temp = (ushort)(ppu_vram_addr & 0x2FFFu); - } - else - { - ppu_vram_addr_access_temp = (ushort)(ppu_vram_addr & 0x3FFFu); - } - if (ppu_vram_addr_access_temp < 8192) - { - mem_board.ReadCHR(ref ppu_vram_addr_access_temp, out ppu_vram_data); - } - else if (ppu_vram_addr_access_temp < 16128) - { - mem_board.ReadNMT(ref ppu_vram_addr_access_temp, out ppu_vram_data); - } - } - ppu_vram_addr = (ushort)((uint)(ppu_vram_addr + ppu_reg_2000_vram_address_increament) & 0x7FFFu); - mem_board.OnPPUAddressUpdate(ref ppu_vram_addr); - } - - private static void PPURead2000() - { - } - - private static void PPURead2001() - { - } - - private static void PPURead2002() - { - ppu_reg_io_db = (byte)((ppu_reg_io_db & 0xDFu) | (ppu_reg_2002_SpriteOverflow ? 32u : 0u)); - ppu_reg_io_db = (byte)((ppu_reg_io_db & 0xBFu) | (ppu_reg_2002_Sprite0Hit ? 64u : 0u)); - ppu_reg_io_db = (byte)((ppu_reg_io_db & 0x7Fu) | (ppu_reg_2002_VblankStartedFlag ? 128u : 0u)); - } - - private static void PPURead2003() - { - } - - private static void PPURead2004() - { - ppu_reg_io_db = ppu_oam_bank[ppu_reg_2003_oam_addr]; - if (ppu_clock_v < 240 && IsRenderingOn()) - { - if (ppu_clock_h < 64) - { - ppu_reg_io_db = byte.MaxValue; - } - else if (ppu_clock_h < 192) - { - ppu_reg_io_db = ppu_oam_bank[(ppu_clock_h - 64 << 1) & 0xFC]; - } - else if (ppu_clock_h < 256) - { - ppu_reg_io_db = (((ppu_clock_h & 1) == 1) ? ppu_oam_bank[252] : ppu_oam_bank[(ppu_clock_h - 192 << 1) & 0xFC]); - } - else if (ppu_clock_h < 320) - { - ppu_reg_io_db = byte.MaxValue; - } - else - { - ppu_reg_io_db = ppu_oam_bank[0]; - } - } - } - - private static void PPURead2005() - { - } - - private static void PPURead2006() - { - } - - private static void PPURead2007() - { - ppu_vram_addr_access_temp = (ushort)(ppu_vram_addr & 0x3FFFu); - if (ppu_vram_addr_access_temp < 16128) - { - ppu_reg_io_db = ppu_vram_data; - } - else if ((ppu_vram_addr_access_temp & 3u) != 0) - { - ppu_reg_io_db = ppu_palette_bank[ppu_vram_addr_access_temp & 0x1F]; - } - else - { - ppu_reg_io_db = ppu_palette_bank[ppu_vram_addr_access_temp & 0xC]; - } - } - - internal static bool IsRenderingOn() - { - if (!ppu_reg_2001_show_background) - { - return ppu_reg_2001_show_sprites; - } - return true; - } - - internal static bool IsInRender() - { - if (ppu_clock_v >= 240) - { - return ppu_clock_v == ppu_clock_vblank_end; - } - return true; - } - - private static void PPUWriteState(ref BinaryWriter bin) - { - bin.Write(ppu_clock_h); - bin.Write(ppu_clock_v); - bin.Write(ppu_clock_vblank_start); - bin.Write(ppu_clock_vblank_end); - bin.Write(ppu_use_odd_cycle); - bin.Write(ppu_use_odd_swap); - bin.Write(ppu_is_nmi_time); - bin.Write(ppu_frame_finished); - bin.Write(ppu_oam_bank); - bin.Write(ppu_oam_bank_secondary); - bin.Write(ppu_palette_bank); - bin.Write(ppu_reg_io_db); - bin.Write(ppu_reg_io_addr); - bin.Write(ppu_reg_access_happened); - bin.Write(ppu_reg_access_w); - bin.Write(ppu_reg_2000_vram_address_increament); - bin.Write(ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites); - bin.Write(ppu_reg_2000_background_pattern_table_address); - bin.Write(ppu_reg_2000_Sprite_size); - bin.Write(ppu_reg_2000_VBI); - bin.Write(ppu_reg_2001_show_background_in_leftmost_8_pixels_of_screen); - bin.Write(ppu_reg_2001_show_sprites_in_leftmost_8_pixels_of_screen); - bin.Write(ppu_reg_2001_show_background); - bin.Write(ppu_reg_2001_show_sprites); - bin.Write(ppu_reg_2001_grayscale); - bin.Write(ppu_reg_2001_emphasis); - bin.Write(ppu_reg_2002_SpriteOverflow); - bin.Write(ppu_reg_2002_Sprite0Hit); - bin.Write(ppu_reg_2002_VblankStartedFlag); - bin.Write(ppu_reg_2003_oam_addr); - bin.Write(ppu_vram_addr); - bin.Write(ppu_vram_data); - bin.Write(ppu_vram_addr_temp); - bin.Write(ppu_vram_addr_access_temp); - bin.Write(ppu_vram_flip_flop); - bin.Write(ppu_vram_finex); - bin.Write(ppu_bkgfetch_nt_addr); - bin.Write(ppu_bkgfetch_nt_data); - bin.Write(ppu_bkgfetch_at_addr); - bin.Write(ppu_bkgfetch_at_data); - bin.Write(ppu_bkgfetch_lb_addr); - bin.Write(ppu_bkgfetch_lb_data); - bin.Write(ppu_bkgfetch_hb_addr); - bin.Write(ppu_bkgfetch_hb_data); - bin.Write(ppu_sprfetch_slot); - bin.Write(ppu_sprfetch_y_data); - bin.Write(ppu_sprfetch_t_data); - bin.Write(ppu_sprfetch_at_data); - bin.Write(ppu_sprfetch_x_data); - bin.Write(ppu_sprfetch_lb_addr); - bin.Write(ppu_sprfetch_lb_data); - bin.Write(ppu_sprfetch_hb_addr); - bin.Write(ppu_sprfetch_hb_data); - bin.Write(ppu_bkg_render_i); - bin.Write(ppu_bkg_render_pos); - bin.Write(ppu_bkg_render_tmp_val); - bin.Write(ppu_bkg_current_pixel); - bin.Write(ppu_spr_current_pixel); - bin.Write(ppu_current_pixel); - bin.Write(ppu_render_x); - bin.Write(0); - bin.Write(ppu_oamev_n); - bin.Write(ppu_oamev_m); - bin.Write(ppu_oamev_compare); - bin.Write(ppu_oamev_slot); - bin.Write(ppu_fetch_data); - bin.Write(ppu_phase_index); - bin.Write(ppu_sprite0_should_hit); - } - - private static void PPUReadState(ref BinaryReader bin) - { - ppu_clock_h = bin.ReadInt32(); - ppu_clock_v = bin.ReadUInt16(); - ppu_clock_vblank_start = bin.ReadUInt16(); - ppu_clock_vblank_end = bin.ReadUInt16(); - ppu_use_odd_cycle = bin.ReadBoolean(); - ppu_use_odd_swap = bin.ReadBoolean(); - ppu_is_nmi_time = bin.ReadBoolean(); - ppu_frame_finished = bin.ReadBoolean(); - bin.Read(ppu_oam_bank, 0, ppu_oam_bank.Length); - bin.Read(ppu_oam_bank_secondary, 0, ppu_oam_bank_secondary.Length); - bin.Read(ppu_palette_bank, 0, ppu_palette_bank.Length); - ppu_reg_io_db = bin.ReadByte(); - ppu_reg_io_addr = bin.ReadByte(); - ppu_reg_access_happened = bin.ReadBoolean(); - ppu_reg_access_w = bin.ReadBoolean(); - ppu_reg_2000_vram_address_increament = bin.ReadByte(); - ppu_reg_2000_sprite_pattern_table_address_for_8x8_sprites = bin.ReadUInt16(); - ppu_reg_2000_background_pattern_table_address = bin.ReadUInt16(); - ppu_reg_2000_Sprite_size = bin.ReadByte(); - ppu_reg_2000_VBI = bin.ReadBoolean(); - ppu_reg_2001_show_background_in_leftmost_8_pixels_of_screen = bin.ReadBoolean(); - ppu_reg_2001_show_sprites_in_leftmost_8_pixels_of_screen = bin.ReadBoolean(); - ppu_reg_2001_show_background = bin.ReadBoolean(); - ppu_reg_2001_show_sprites = bin.ReadBoolean(); - ppu_reg_2001_grayscale = bin.ReadInt32(); - ppu_reg_2001_emphasis = bin.ReadInt32(); - ppu_reg_2002_SpriteOverflow = bin.ReadBoolean(); - ppu_reg_2002_Sprite0Hit = bin.ReadBoolean(); - ppu_reg_2002_VblankStartedFlag = bin.ReadBoolean(); - ppu_reg_2003_oam_addr = bin.ReadByte(); - ppu_vram_addr = bin.ReadUInt16(); - ppu_vram_data = bin.ReadByte(); - ppu_vram_addr_temp = bin.ReadUInt16(); - ppu_vram_addr_access_temp = bin.ReadUInt16(); - ppu_vram_flip_flop = bin.ReadBoolean(); - ppu_vram_finex = bin.ReadByte(); - ppu_bkgfetch_nt_addr = bin.ReadUInt16(); - ppu_bkgfetch_nt_data = bin.ReadByte(); - ppu_bkgfetch_at_addr = bin.ReadUInt16(); - ppu_bkgfetch_at_data = bin.ReadByte(); - ppu_bkgfetch_lb_addr = bin.ReadUInt16(); - ppu_bkgfetch_lb_data = bin.ReadByte(); - ppu_bkgfetch_hb_addr = bin.ReadUInt16(); - ppu_bkgfetch_hb_data = bin.ReadByte(); - ppu_sprfetch_slot = bin.ReadInt32(); - ppu_sprfetch_y_data = bin.ReadByte(); - ppu_sprfetch_t_data = bin.ReadByte(); - ppu_sprfetch_at_data = bin.ReadByte(); - ppu_sprfetch_x_data = bin.ReadByte(); - ppu_sprfetch_lb_addr = bin.ReadUInt16(); - ppu_sprfetch_lb_data = bin.ReadByte(); - ppu_sprfetch_hb_addr = bin.ReadUInt16(); - ppu_sprfetch_hb_data = bin.ReadByte(); - ppu_bkg_render_i = bin.ReadInt32(); - ppu_bkg_render_pos = bin.ReadInt32(); - ppu_bkg_render_tmp_val = bin.ReadInt32(); - ppu_bkg_current_pixel = bin.ReadInt32(); - ppu_spr_current_pixel = bin.ReadInt32(); - ppu_current_pixel = bin.ReadInt32(); - ppu_render_x = bin.ReadInt32(); - bin.ReadInt32(); - ppu_oamev_n = bin.ReadByte(); - ppu_oamev_m = bin.ReadByte(); - ppu_oamev_compare = bin.ReadBoolean(); - ppu_oamev_slot = bin.ReadByte(); - ppu_fetch_data = bin.ReadByte(); - ppu_phase_index = bin.ReadByte(); - ppu_sprite0_should_hit = bin.ReadBoolean(); - } - - internal static void CheckGame(string fileName, out bool valid) - { - string text = Path.GetExtension(fileName).ToLower(); - if (text != null && text == ".nes") - { - Tracer.WriteLine("Checking INES header ..."); - INes nes = new INes(); - nes.Load(fileName, loadDumps: false); - valid = nes.IsValid; - Tracer.WriteLine("INES header is valid."); - } - else - { - Tracer.WriteWarning("File format is not supported. Format: " + Path.GetExtension(fileName)); - valid = false; - } - } - - internal static void Initialize() - { - Tracer.WriteLine("Loading database file ..."); - NesCartDatabase.LoadDatabase(out bool success); - - if (success) - { - Tracer.WriteInformation("Nes Cart database file loaded successfully."); - } - else - { - Tracer.WriteError("Error loading Nes Cart database file."); - } - - FrameLimiterEnabled = true; - CPUInitialize(); - PPUInitialize(); - APUInitialize(); - PORTSInitialize(); - } - - internal static void SetupRenderingMethods(RenderVideoFrame renderVideo, RenderAudioSamples renderAudio, TogglePause renderTogglePause, GetIsPlaying renderGetIsPlaying) - { - render_initialized = false; - render_video = renderVideo; - render_audio = renderAudio; - render_audio_toggle_pause = renderTogglePause; - render_audio_get_is_playing = renderGetIsPlaying; - render_initialized = render_video != null && render_audio != null && render_audio_toggle_pause != null && render_audio_get_is_playing != null; - if (render_initialized) - { - Tracer.WriteInformation("Renderer methods initialized successfully."); - return; - } - Tracer.WriteError("ERROR RENDERER INITIALIZING !!"); - Tracer.WriteError("Faild to initialize the renderers methods. Please use the method 'SetupRenderingMethods' to initialize the renderers methods before you can run the emulation."); - } - - public static void LoadGame(string fileName, out bool success, bool useThread) - { - if (!render_initialized) - { - Tracer.WriteError("NO RENDERER INITIALIZED !! EMU CANNOT BE INTIALIZED WITHOUT A RENDERER !!"); - Tracer.WriteError("Please use the method 'SetupRenderingMethods' to initialize the renderers methods before you can run the emulation."); - success = false; - return; - } - Tracer.WriteLine("Checking INES header ..."); - INes nes = new INes(); - nes.Load(fileName, loadDumps: true); - if (nes.IsValid) - { - emu_request_mode = RequestMode.None; - CurrentFilePath = fileName; - if (ON) - { - ShutDown(); - } - Tracer.WriteLine("INES header is valid, loading game ..."); - ApplyRegionSetting(); - MEMInitialize(nes); - ApplyAudioSettings(); - ApplyFrameSkipSettings(); - ApplyPaletteSetting(); - PORTSInitialize(); - hardReset(); - Tracer.WriteLine("EMU is ready."); - success = true; - ON = true; - PAUSED = false; - if (useThread) - { - Tracer.WriteLine("Running in a thread ... using custom frame limiter."); - FrameLimiterEnabled = true; - currentFrame = 0; - mainThread = new Thread(EmuClock); - mainThread.Start(); - } - MyNesMain.VideoProvider.SignalToggle(started: true); - MyNesMain.AudioProvider.SignalToggle(started: true); - } - else - { - success = false; - } - } - - public static void HardReset() - { - PAUSED = true; - emu_request_mode = RequestMode.HardReset; - } - - private static void hardReset() - { - if (MyNesMain.WaveRecorder.IsRecording) - { - MyNesMain.WaveRecorder.Stop(); - } - render_audio_toggle_pause(paused: true); - switch (Region) - { - case EmuRegion.NTSC: - emu_time_target_fps = 60.0988; - break; - case EmuRegion.PALB: - case EmuRegion.DENDY: - emu_time_target_fps = 50.0; - break; - } - fps_time_period = 1.0 / emu_time_target_fps; - MEMHardReset(); - CPUHardReset(); - PPUHardReset(); - APUHardReset(); - DMAHardReset(); - render_audio_toggle_pause(paused: false); - MyNesMain.VideoProvider.WriteWarningNotification(MNInterfaceLanguage.Message_HardReset, instant: false); - } - - public static void SoftReset() - { - PAUSED = true; - emu_request_mode = RequestMode.SoftReset; - } - - private static void softReset() - { - CPUSoftReset(); - APUSoftReset(); - MyNesMain.VideoProvider.WriteWarningNotification(MNInterfaceLanguage.Message_SoftReset, instant: false); - } - - public static void SaveState() - { - PAUSED = true; - emu_request_mode = RequestMode.SaveState; - } - - public static void LoadState() - { - PAUSED = true; - emu_request_mode = RequestMode.LoadState; - } - - internal static void TakeSnapshot() - { - PAUSED = true; - emu_request_mode = RequestMode.TakeSnapshot; - } - - public static void ShutDown() - { - MyNesMain.VideoProvider.SignalToggle(started: false); - MyNesMain.AudioProvider.SignalToggle(started: false); - if (MyNesMain.WaveRecorder.IsRecording) - { - MyNesMain.WaveRecorder.Stop(); - } - render_audio_get_is_playing(out render_audio_is_playing); - if (render_audio_is_playing) - { - render_audio_toggle_pause(paused: true); - } - Tracer.WriteLine("Shutting down the emulation core..."); - ON = false; - if (mainThread != null) - { - Tracer.WriteLine("Aborting thread .."); - mainThread.Abort(); - mainThread = null; - } - SaveSRAM(); - Tracer.WriteInformation("Emulation core shutdown successfully."); - NesEmu.EmuShutdown?.Invoke(null, new EventArgs()); - } - - private static Stopwatch sw = new Stopwatch(); - private static double fixTime; - public static ulong currentFrame; - private static void EmuClock() - { - while (ON) - { - if (!PAUSED) - { - var waitTime = GetTime() + fps_time_period + fixTime; - - while (!ppu_frame_finished) - CPUClock(); - - FrameFinished(); - - fixTime = waitTime - GetTime(); - while (fixTime > 0) - { - fixTime = waitTime - GetTime(); - }; - - currentFrame++; - - continue; - } - render_audio_get_is_playing(out render_audio_is_playing); - if (render_audio_is_playing) - { - render_audio_toggle_pause(paused: true); - } - Thread.Sleep(100); - switch (emu_request_mode) - { - case RequestMode.HardReset: - hardReset(); - PAUSED = false; - emu_request_mode = RequestMode.None; - break; - case RequestMode.SoftReset: - softReset(); - PAUSED = false; - emu_request_mode = RequestMode.None; - break; - case RequestMode.SaveState: - StateHandler.SaveState(); - PAUSED = false; - emu_request_mode = RequestMode.None; - break; - case RequestMode.LoadState: - StateHandler.LoadState(); - PAUSED = false; - emu_request_mode = RequestMode.None; - break; - case RequestMode.TakeSnapshot: - MyNesMain.VideoProvider.TakeSnapshot(); - PAUSED = false; - emu_request_mode = RequestMode.None; - break; - } - isPaused = true; - } - } - - internal static void EmuClockComponents() - { - PPUClock(); - PollInterruptStatus(); - PPUClock(); - PPUClock(); - APUClock(); - DMAClock(); - mem_board.OnCPUClock(); - } - - internal static void ApplyFrameSkipSettings() - { - FrameSkipEnabled = MyNesMain.RendererSettings.FrameSkipEnabled; - FrameSkipInterval = MyNesMain.RendererSettings.FrameSkipInterval; - } - - private static void FrameFinished() - { - if (!FrameSkipEnabled) - { - render_video(ref ppu_screen_pixels); - } - else - { - FrameSkipCounter++; - if (FrameSkipCounter >= FrameSkipInterval) - { - render_video(ref ppu_screen_pixels); - FrameSkipCounter = 0; - } - } - isPaused = false; - ppu_frame_finished = false; - joypad1.Update(); - joypad2.Update(); - if (IsFourPlayers) - { - joypad3.Update(); - joypad4.Update(); - } - if (SoundEnabled) - { - render_audio_get_is_playing(out render_audio_is_playing); - if (!render_audio_is_playing) - { - render_audio_toggle_pause(paused: false); - } - render_audio(ref audio_samples, ref audio_samples_added); - audio_w_pos = 0; - audio_samples_added = 0; - audio_timer = 0.0; - } - } - - private static double GetTime() - { - return (double)Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency; - } - - - public static void SetFramePeriod(ref double period) - { - fps_time_period = period; - } - - public static void RevertFramePeriod() - { - fps_time_period = 1 / emu_time_target_fps; - } - - public static void ApplyRegionSetting() - { - switch ((RegionSetting)MyNesMain.EmuSettings.RegionSetting) - { - case RegionSetting.AUTO: - Tracer.WriteLine("REGION = AUTO"); - Region = EmuRegion.NTSC; - if (CurrentFilePath.Contains("(E)")) - { - Region = EmuRegion.PALB; - } - Tracer.WriteLine("REGION SELECTED: " + Region); - break; - case RegionSetting.ForceNTSC: - Tracer.WriteLine("REGION: FORCE NTSC"); - Region = EmuRegion.NTSC; - break; - case RegionSetting.ForcePALB: - Tracer.WriteLine("REGION: FORCE PALB"); - Region = EmuRegion.PALB; - break; - case RegionSetting.ForceDENDY: - Tracer.WriteLine("REGION: FORCE DENDY"); - Region = EmuRegion.DENDY; - break; - } - SystemIndex = (int)Region; - } - - public static void ApplyPaletteSetting() - { - Tracer.WriteLine("Loading palette generators values from settings..."); - NTSCPaletteGenerator.brightness = MyNesMain.RendererSettings.Palette_NTSC_brightness; - NTSCPaletteGenerator.contrast = MyNesMain.RendererSettings.Palette_NTSC_contrast; - NTSCPaletteGenerator.gamma = MyNesMain.RendererSettings.Palette_NTSC_gamma; - NTSCPaletteGenerator.hue_tweak = MyNesMain.RendererSettings.Palette_NTSC_hue_tweak; - NTSCPaletteGenerator.saturation = MyNesMain.RendererSettings.Palette_NTSC_saturation; - PALBPaletteGenerator.brightness = MyNesMain.RendererSettings.Palette_PALB_brightness; - PALBPaletteGenerator.contrast = MyNesMain.RendererSettings.Palette_PALB_contrast; - PALBPaletteGenerator.gamma = MyNesMain.RendererSettings.Palette_PALB_gamma; - PALBPaletteGenerator.hue_tweak = MyNesMain.RendererSettings.Palette_PALB_hue_tweak; - PALBPaletteGenerator.saturation = MyNesMain.RendererSettings.Palette_PALB_saturation; - Tracer.WriteLine("Setting up palette ...."); - switch ((PaletteSelectSetting)MyNesMain.RendererSettings.Palette_PaletteSetting) - { - case PaletteSelectSetting.AUTO: - Tracer.WriteLine("Palette set to auto detect depending on region."); - switch (Region) - { - case EmuRegion.NTSC: - SetupPalette(NTSCPaletteGenerator.GeneratePalette()); - Tracer.WriteLine("Region is NTSC, Palette set from NTSC generator."); - break; - case EmuRegion.PALB: - case EmuRegion.DENDY: - SetupPalette(PALBPaletteGenerator.GeneratePalette()); - Tracer.WriteLine("Region is PALB/DENDY, Palette set from PALB generator."); - break; - } - break; - case PaletteSelectSetting.ForceNTSC: - Tracer.WriteLine("Palette set to always use NTSC palette generator."); - SetupPalette(NTSCPaletteGenerator.GeneratePalette()); - Tracer.WriteLine("Palette set from NTSC generator."); - break; - case PaletteSelectSetting.ForcePALB: - Tracer.WriteLine("Palette set to always use PALB palette generator."); - SetupPalette(NTSCPaletteGenerator.GeneratePalette()); - Tracer.WriteLine("Palette set from PALB generator."); - break; - case PaletteSelectSetting.File: - { - Tracer.WriteLine("Palette set to load from file."); - - var paletteFileStream = MyNesMain.Supporter.OpenPaletteFile(); - if (paletteFileStream != null) - { - PaletteFileWrapper.LoadFile(paletteFileStream, out var palette); - SetupPalette(palette); - Tracer.WriteLine("Palette set from file"); - break; - } - Tracer.WriteError("Palette from file is not exist is not exist. Setting up palette from generators."); - switch (Region) - { - case EmuRegion.NTSC: - SetupPalette(NTSCPaletteGenerator.GeneratePalette()); - Tracer.WriteLine("Region is NTSC, Palette set from NTSC generator."); - break; - case EmuRegion.PALB: - case EmuRegion.DENDY: - SetupPalette(PALBPaletteGenerator.GeneratePalette()); - Tracer.WriteLine("Region is PALB/DENDY, Palette set from PALB generator."); - break; - } - break; - } - } - } - - internal static void WriteStateData(ref BinaryWriter bin) - { - APUWriteState(ref bin); - CPUWriteState(ref bin); - DMAWriteState(ref bin); - InterruptsWriteState(ref bin); - MEMWriteState(ref bin); - PORTWriteState(ref bin); - PPUWriteState(ref bin); - } - - internal static void ReadStateData(ref BinaryReader bin) - { - APUReadState(ref bin); - CPUReadState(ref bin); - DMAReadState(ref bin); - InterruptsReadState(ref bin); - MEMReadState(ref bin); - PORTReadState(ref bin); - PPUReadState(ref bin); - } - - private static void SQ2HardReset() - { - sq2_duty_cycle = 0; - sq2_length_halt = false; - sq2_constant_volume_envelope = false; - sq2_volume_devider_period = 0; - sq2_sweep_enable = false; - sq2_sweep_devider_period = 0; - sq2_sweep_negate = false; - sq2_sweep_shift_count = 0; - sq2_timer = 0; - sq2_period_devider = 0; - sq2_seqencer = 0; - sq2_length_enabled = false; - sq2_length_counter = 0; - sq2_envelope_start_flag = false; - sq2_envelope_devider = 0; - sq2_envelope_decay_level_counter = 0; - sq2_envelope = 0; - sq2_sweep_counter = 0; - sq2_sweep_reload = false; - sq2_sweep_change = 0; - sq2_valid_freq = false; - sq2_output = 0; - sq2_ignore_reload = false; - } - - private static void SQ2SoftReset() - { - SQ2HardReset(); - } - - private static void SQ2Clock() - { - sq2_period_devider--; - if (sq2_period_devider > 0) - { - return; - } - sq2_period_devider = sq2_timer + 1; - sq2_seqencer = (byte)((uint)(sq2_seqencer + 1) & 7u); - if (sq2_length_counter > 0 && sq2_valid_freq) - { - if (audio_sq2_outputable) - { - sq2_output = sq_duty_cycle_sequences[sq2_duty_cycle][sq2_seqencer] * sq2_envelope; - } - } - else - { - sq2_output = 0; - } - audio_signal_outputed = true; - } - - private static void SQ2ClockLength() - { - if (sq2_length_counter > 0 && !sq2_length_halt) - { - sq2_length_counter--; - if (apu_reg_access_happened && apu_reg_io_addr == 7 && apu_reg_access_w) - { - sq2_ignore_reload = true; - } - } - sq2_sweep_counter--; - if (sq2_sweep_counter == 0) - { - sq2_sweep_counter = sq2_sweep_devider_period + 1; - if (sq2_sweep_enable && sq2_sweep_shift_count > 0 && sq2_valid_freq) - { - sq2_sweep_change = sq2_timer >> (int)sq2_sweep_shift_count; - sq2_timer += (sq2_sweep_negate ? (-sq2_sweep_change) : sq2_sweep_change); - SQ2CalculateValidFreq(); - } - } - else if (sq2_sweep_reload) - { - sq2_sweep_counter = sq2_sweep_devider_period + 1; - sq2_sweep_reload = false; - } - } - - private static void SQ2ClockEnvelope() - { - if (sq2_envelope_start_flag) - { - sq2_envelope_start_flag = false; - sq2_envelope_decay_level_counter = 15; - sq2_envelope_devider = (byte)(sq2_volume_devider_period + 1); - } - else if (sq2_envelope_devider > 0) - { - sq2_envelope_devider--; - } - else - { - sq2_envelope_devider = (byte)(sq2_volume_devider_period + 1); - if (sq2_envelope_decay_level_counter > 0) - { - sq2_envelope_decay_level_counter--; - } - else if (sq2_length_halt) - { - sq2_envelope_decay_level_counter = 15; - } - } - sq2_envelope = (sq2_constant_volume_envelope ? sq2_volume_devider_period : sq2_envelope_decay_level_counter); - } - - private static void APUOnRegister4004() - { - if (apu_reg_access_w) - { - sq2_duty_cycle = (byte)((apu_reg_io_db & 0xC0) >> 6); - sq2_volume_devider_period = (byte)(apu_reg_io_db & 0xFu); - sq2_length_halt = (apu_reg_io_db & 0x20) != 0; - sq2_constant_volume_envelope = (apu_reg_io_db & 0x10) != 0; - sq2_envelope = (sq2_constant_volume_envelope ? sq2_volume_devider_period : sq2_envelope_decay_level_counter); - } - } - - private static void APUOnRegister4005() - { - if (apu_reg_access_w) - { - sq2_sweep_enable = (apu_reg_io_db & 0x80) == 128; - sq2_sweep_devider_period = (byte)((uint)(apu_reg_io_db >> 4) & 7u); - sq2_sweep_negate = (apu_reg_io_db & 8) == 8; - sq2_sweep_shift_count = (byte)(apu_reg_io_db & 7u); - sq2_sweep_reload = true; - SQ2CalculateValidFreq(); - } - } - - private static void APUOnRegister4006() - { - if (apu_reg_access_w) - { - sq2_timer = (sq2_timer & 0xFF00) | apu_reg_io_db; - SQ2CalculateValidFreq(); - } - } - - private static void APUOnRegister4007() - { - if (apu_reg_access_w) - { - sq2_timer = (sq2_timer & 0xFF) | ((apu_reg_io_db & 7) << 8); - if (sq2_length_enabled && !sq2_ignore_reload) - { - sq2_length_counter = sq_duration_table[apu_reg_io_db >> 3]; - } - if (sq2_ignore_reload) - { - sq2_ignore_reload = false; - } - sq2_seqencer = 0; - sq2_envelope_start_flag = true; - SQ2CalculateValidFreq(); - } - } - - private static void SQ2On4015() - { - sq2_length_enabled = (apu_reg_io_db & 2) != 0; - if (!sq2_length_enabled) - { - sq2_length_counter = 0; - } - } - - private static void SQ2Read4015() - { - if (sq2_length_counter > 0) - { - apu_reg_io_db = (byte)((apu_reg_io_db & 0xFDu) | 2u); - } - } - - private static void SQ2CalculateValidFreq() - { - sq2_valid_freq = sq2_timer >= 8 && (sq2_sweep_negate || ((sq2_timer + (sq2_timer >> (int)sq2_sweep_shift_count)) & 0x800) == 0); - } - - private static void SQ2WriteState(ref BinaryWriter bin) - { - bin.Write(sq2_duty_cycle); - bin.Write(sq2_length_halt); - bin.Write(sq2_constant_volume_envelope); - bin.Write(sq2_volume_devider_period); - bin.Write(sq2_sweep_enable); - bin.Write(sq2_sweep_devider_period); - bin.Write(sq2_sweep_negate); - bin.Write(sq2_sweep_shift_count); - bin.Write(sq2_timer); - bin.Write(sq2_period_devider); - bin.Write(sq2_seqencer); - bin.Write(sq2_length_enabled); - bin.Write(sq2_length_counter); - bin.Write(sq2_envelope_start_flag); - bin.Write(sq2_envelope_devider); - bin.Write(sq2_envelope_decay_level_counter); - bin.Write(sq2_envelope); - bin.Write(sq2_sweep_counter); - bin.Write(sq2_sweep_reload); - bin.Write(sq2_sweep_change); - bin.Write(sq2_valid_freq); - bin.Write(sq2_output); - bin.Write(sq2_ignore_reload); - } - - private static void SQ2ReadState(ref BinaryReader bin) - { - sq2_duty_cycle = bin.ReadByte(); - sq2_length_halt = bin.ReadBoolean(); - sq2_constant_volume_envelope = bin.ReadBoolean(); - sq2_volume_devider_period = bin.ReadByte(); - sq2_sweep_enable = bin.ReadBoolean(); - sq2_sweep_devider_period = bin.ReadByte(); - sq2_sweep_negate = bin.ReadBoolean(); - sq2_sweep_shift_count = bin.ReadByte(); - sq2_timer = bin.ReadInt32(); - sq2_period_devider = bin.ReadInt32(); - sq2_seqencer = bin.ReadByte(); - sq2_length_enabled = bin.ReadBoolean(); - sq2_length_counter = bin.ReadInt32(); - sq2_envelope_start_flag = bin.ReadBoolean(); - sq2_envelope_devider = bin.ReadByte(); - sq2_envelope_decay_level_counter = bin.ReadByte(); - sq2_envelope = bin.ReadByte(); - sq2_sweep_counter = bin.ReadInt32(); - sq2_sweep_reload = bin.ReadBoolean(); - sq2_sweep_change = bin.ReadInt32(); - sq2_valid_freq = bin.ReadBoolean(); - sq2_output = bin.ReadInt32(); - sq2_ignore_reload = bin.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesEmu.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/NesEmu.cs.meta deleted file mode 100644 index 7482bdc..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/NesEmu.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0ec9e5a66367f0e47b07118c94860367 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PALBPaletteGenerator.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/PALBPaletteGenerator.cs deleted file mode 100644 index 873a4bd..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PALBPaletteGenerator.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class PALBPaletteGenerator - { - public const float default_saturation = 1.496f; - - public const float default_hue_tweak = 0f; - - public const float default_contrast = 1.016f; - - public const float default_brightness = 1.075f; - - public const float default_gamma = 1.975f; - - private const float black = 0.518f; - - private const float white = 1.962f; - - private const float attenuation = 0.746f; - - public static float saturation = 2f; - - public static float hue_tweak = 0f; - - public static float contrast = 1.4f; - - public static float brightness = 1.07f; - - public static float gamma = 2f; - - private static float[] levels = new float[8] { 0.35f, 0.518f, 0.962f, 1.55f, 1.094f, 1.506f, 1.962f, 1.962f }; - - private static int wave(int p, int color) - { - if ((color + p + 8) % 12 >= 6) - { - return 0; - } - return 1; - } - - private static float gammafix(float f, float gamma) - { - return (float)((f < 0f) ? 0.0 : Math.Pow(f, 2.2f / gamma)); - } - - private static int clamp(float v) - { - return (int)((v < 0f) ? 0f : ((v > 255f) ? 255f : v)); - } - - public static int MakeRGBcolor(int pixel) - { - int num = pixel & 0xF; - int num2 = ((num >= 14) ? 1 : ((pixel >> 4) & 3)); - float[] array = new float[2] - { - levels[num2 + ((num == 0) ? 4 : 0)], - levels[num2 + ((num <= 12) ? 4 : 0)] - }; - float num3 = 0f; - float num4 = 0f; - float num5 = 0f; - for (int i = 0; i < 12; i++) - { - float num6 = array[wave(i, num)]; - if ((((uint)pixel & 0x40u) != 0 && wave(i, 12) == 1) || (((uint)pixel & 0x80u) != 0 && wave(i, 4) == 1) || (((uint)pixel & 0x100u) != 0 && wave(i, 8) == 1)) - { - num6 *= 0.746f; - } - float num7 = (num6 - 0.518f) / 1.444f; - num7 = (num7 - 0.5f) * contrast + 0.5f; - num7 *= brightness / 12f; - num3 += num7; - num4 += (float)((double)num7 * Math.Cos(Math.PI / 6.0 * (double)((float)i + 0.5f + hue_tweak))); - num5 += (float)((double)num7 * Math.Sin(Math.PI / 6.0 * (double)((float)i + 0.5f + hue_tweak))); - } - num4 *= saturation; - num5 *= saturation; - return 65536 * clamp(255f * gammafix(num3 + 0.946882f * num4 + 0.623557f * num5, gamma)) + 256 * clamp(255f * gammafix(num3 - 245f / (328f * (float)Math.E) * num4 - 0.635691f * num5, gamma)) + clamp(255f * gammafix(num3 - 1.108545f * num4 + 1.709007f * num5, gamma)); - } - - public static int[] GeneratePalette() - { - int[] array = new int[512]; - for (int i = 0; i < 512; i++) - { - array[i] = MakeRGBcolor(i) | -16777216; - } - return array; - } - - public static int[] GeneratePaletteGBR() - { - int[] array = new int[512]; - for (int i = 0; i < 512; i++) - { - int num = MakeRGBcolor(i); - byte b = (byte)((num & 0xFF0000) >> 16); - byte b2 = (byte)((num & 0xFF00) >> 8); - byte b3 = (byte)((uint)num & 0xFFu); - array[i] = -16777216 | (b3 << 16) | (b2 << 8) | b; - } - return array; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PALBPaletteGenerator.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/PALBPaletteGenerator.cs.meta deleted file mode 100644 index ff8e34b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PALBPaletteGenerator.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3a50696d24d84244db471bd77c8e8ace -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PRGArea.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/PRGArea.cs deleted file mode 100644 index 38619bd..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PRGArea.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace MyNes.Core -{ - internal enum PRGArea : byte - { - Area4000 = 4, - Area5000, - Area6000, - Area7000, - Area8000, - Area9000, - AreaA000, - AreaB000, - AreaC000, - AreaD000, - AreaE000, - AreaF000 - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PRGArea.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/PRGArea.cs.meta deleted file mode 100644 index 32839e3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PRGArea.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dd5f1d06c4c4b974992327c971b3e73c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteFileWrapper.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteFileWrapper.cs deleted file mode 100644 index 7436c77..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteFileWrapper.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class PaletteFileWrapper - { - public static bool LoadFile(Stream fileStream, out int[] palette) - { - Stream stream = fileStream; - if (stream.Length == 192 || stream.Length == 1536) - { - int[] array = new int[512]; - byte[] array2 = new byte[stream.Length]; - stream.Read(array2, 0, array2.Length); - int num = 0; - for (int i = 0; i < 512; i++) - { - byte b = array2[num]; - num++; - if (num == array2.Length) - { - num = 0; - } - byte b2 = array2[num]; - num++; - if (num == array2.Length) - { - num = 0; - } - byte b3 = array2[num]; - num++; - if (num == array2.Length) - { - num = 0; - } - array[i] = -16777216 | (b << 16) | (b2 << 8) | b3; - } - stream.Close(); - palette = array; - return true; - } - palette = null; - return false; - } - - public static void SaveFile(string file, int[] palette) - { - Stream stream = new FileStream(file, FileMode.Create, FileAccess.Write); - List list = new List(); - foreach (int num in palette) - { - list.Add((byte)((uint)(num >> 16) & 0xFFu)); - list.Add((byte)((uint)(num >> 8) & 0xFFu)); - list.Add((byte)((uint)num & 0xFFu)); - } - stream.Write(list.ToArray(), 0, list.Count); - stream.Close(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteFileWrapper.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteFileWrapper.cs.meta deleted file mode 100644 index 5006743..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteFileWrapper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f15f9fdbee4f6704ebf4de045e49573c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteSelectSetting.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteSelectSetting.cs deleted file mode 100644 index 2deeba8..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteSelectSetting.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MyNes.Core -{ - public enum PaletteSelectSetting - { - AUTO, - ForceNTSC, - ForcePALB, - File - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteSelectSetting.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteSelectSetting.cs.meta deleted file mode 100644 index 13d79b9..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/PaletteSelectSetting.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1288fd99cf9cd5b49a99b7de9ac5b778 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RegionSetting.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/RegionSetting.cs deleted file mode 100644 index de9bedc..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RegionSetting.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MyNes.Core -{ - public enum RegionSetting - { - AUTO, - ForceNTSC, - ForcePALB, - ForceDENDY - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RegionSetting.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/RegionSetting.cs.meta deleted file mode 100644 index 10a2dee..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RegionSetting.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4e8c869e43765a14cb6c803a65bdf3fe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderAudioSamples.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderAudioSamples.cs deleted file mode 100644 index 0cb619c..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderAudioSamples.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MyNes.Core -{ - internal delegate void RenderAudioSamples(ref short[] buffer, ref int samples_added); -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderAudioSamples.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderAudioSamples.cs.meta deleted file mode 100644 index 6d259fd..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderAudioSamples.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2c87ada4318a5b54eb32c459316a236c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderVideoFrame.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderVideoFrame.cs deleted file mode 100644 index 635f9e1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderVideoFrame.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MyNes.Core -{ - internal delegate void RenderVideoFrame(ref int[] buffer); -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderVideoFrame.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderVideoFrame.cs.meta deleted file mode 100644 index a77008a..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RenderVideoFrame.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 368bc7a67bdd3134781f923b3685629c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RendererSettings.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/RendererSettings.cs deleted file mode 100644 index 086d0ec..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RendererSettings.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class RendererSettings : ISettings - { - public string Video_ProviderID = ""; - - public bool Vid_AutoStretch = true; - - public int Vid_StretchMultiply = 3; - - public bool Vid_KeepAspectRatio; - - public bool Vid_ShowFPS; - - public bool Vid_HideLines = true; - - public bool Vid_Fullscreen; - - public bool Vid_HardwareVertexProcessing; - - public bool Vid_VSync; - - public bool Vid_ShowNotifications = true; - - public int Vid_Filter = 1; - - public bool FrameSkipEnabled; - - public int FrameSkipInterval = 2; - - public string Audio_ProviderID = ""; - - public bool Audio_EnableFilters = true; - - public int Audio_Volume = 100; - - public bool Audio_SoundEnabled = true; - - public int Audio_Frequency = 48000; - - public int Audio_InternalSamplesCount = 1024; - - public int Audio_InternalPeekLimit = 124; - - public int Audio_PlaybackAmplitude = 200; - - public int Audio_PlaybackBufferSizeInKB = 16; - - public bool Audio_UseDefaultMixer; - - public bool Audio_ChannelEnabled_SQ1 = true; - - public bool Audio_ChannelEnabled_SQ2 = true; - - public bool Audio_ChannelEnabled_NOZ = true; - - public bool Audio_ChannelEnabled_TRL = true; - - public bool Audio_ChannelEnabled_DMC = true; - - public bool Audio_ChannelEnabled_MMC5_SQ1 = true; - - public bool Audio_ChannelEnabled_MMC5_SQ2 = true; - - public bool Audio_ChannelEnabled_MMC5_PCM = true; - - public bool Audio_ChannelEnabled_VRC6_SQ1 = true; - - public bool Audio_ChannelEnabled_VRC6_SQ2 = true; - - public bool Audio_ChannelEnabled_VRC6_SAW = true; - - public bool Audio_ChannelEnabled_SUN1 = true; - - public bool Audio_ChannelEnabled_SUN2 = true; - - public bool Audio_ChannelEnabled_SUN3 = true; - - public bool Audio_ChannelEnabled_NMT1 = true; - - public bool Audio_ChannelEnabled_NMT2 = true; - - public bool Audio_ChannelEnabled_NMT3 = true; - - public bool Audio_ChannelEnabled_NMT4 = true; - - public bool Audio_ChannelEnabled_NMT5 = true; - - public bool Audio_ChannelEnabled_NMT6 = true; - - public bool Audio_ChannelEnabled_NMT7 = true; - - public bool Audio_ChannelEnabled_NMT8 = true; - - public int Palette_PaletteSetting; - - public float Palette_NTSC_brightness = 1.075f; - - public float Palette_NTSC_contrast = 1.016f; - - public float Palette_NTSC_gamma = 1.975f; - - public float Palette_NTSC_hue_tweak; - - public float Palette_NTSC_saturation = 1.496f; - - public float Palette_PALB_brightness = 1.075f; - - public float Palette_PALB_contrast = 1.016f; - - public float Palette_PALB_gamma = 1.975f; - - public float Palette_PALB_hue_tweak; - - public float Palette_PALB_saturation = 1.496f; - - public RendererSettings(string path) - : base(path) - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/RendererSettings.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/RendererSettings.cs.meta deleted file mode 100644 index f8ecf0f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/RendererSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 65409a509e1cd8343b1a67971176f0df -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SRAMBankInfo.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/SRAMBankInfo.cs deleted file mode 100644 index 68a1e70..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SRAMBankInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace MyNes.Core -{ - public struct SRAMBankInfo - { - public int id; - - public string SIZE; - - public bool BATTERY; - - public SRAMBankInfo(int id, string SIZE, bool BATTERY) - { - this.SIZE = SIZE; - if (SIZE == "0kb") - { - SIZE = "8kb"; - } - this.BATTERY = BATTERY; - this.id = id; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SRAMBankInfo.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/SRAMBankInfo.cs.meta deleted file mode 100644 index e836822..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SRAMBankInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 712dc9b2310b1de45b4136197e974a90 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundDCBlockerFilter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundDCBlockerFilter.cs deleted file mode 100644 index da849fe..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundDCBlockerFilter.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class SoundDCBlockerFilter - { - private double R; - - private double y; - - private double y_1; - - private double x; - - private double x_1; - - public SoundDCBlockerFilter(double R) - { - this.R = R; - } - - public void Reset() - { - y = (y_1 = (x = (x_1 = 0.0))); - } - - public void DoFiltering(double sample, out double filtered) - { - x = sample; - filtered = (y = x - x_1 + R * y_1); - x_1 = x; - y_1 = y; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundDCBlockerFilter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundDCBlockerFilter.cs.meta deleted file mode 100644 index fe30c28..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundDCBlockerFilter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45a36044c5210bb498dc54c616867e2a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundHighPassFilter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundHighPassFilter.cs deleted file mode 100644 index c83ced1..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundHighPassFilter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class SoundHighPassFilter - { - private double K; - - private double y_1; - - private double x_1; - - public SoundHighPassFilter(double k) - { - K = k; - } - - public void Reset() - { - y_1 = (x_1 = 0.0); - } - - public void DoFiltering(double sample, out double filtered) - { - filtered = K * y_1 + K * (sample - x_1); - x_1 = sample; - y_1 = filtered; - } - - public static double GetK(double dt, double fc) - { - double num = Math.PI * 2.0 * dt * fc; - return num / (num + 1.0); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundHighPassFilter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundHighPassFilter.cs.meta deleted file mode 100644 index 3edbcd6..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundHighPassFilter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 57d536cd18a24114691257432ce2b8b9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundLowPassFilter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundLowPassFilter.cs deleted file mode 100644 index 2d52392..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundLowPassFilter.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class SoundLowPassFilter - { - private double K; - - private double K_1; - - private double y; - - private double y_1; - - private double x; - - private double x_1; - - public SoundLowPassFilter(double k) - { - K = k; - K_1 = 1.0 - k; - } - - public void Reset(double k) - { - y = (y_1 = (x = (x_1 = 0.0))); - K = k; - K_1 = 1.0 - k; - } - - public void DoFiltering(double sample, out double filtered) - { - filtered = K * sample + K_1 * y_1; - x_1 = sample; - y_1 = filtered; - } - - public static double GetK(double dt, double fc) - { - double num = Math.PI * 2.0 * dt * fc; - return num / (num + 1.0); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundLowPassFilter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundLowPassFilter.cs.meta deleted file mode 100644 index aeb419f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/SoundLowPassFilter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0556466d0c6a1ef44a16c28d90524615 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/StateHandler.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/StateHandler.cs deleted file mode 100644 index fc02bac..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/StateHandler.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.IO; -using System.Text; - -namespace MyNes.Core -{ - public class StateHandler - { - public static int Slot = 0; - - internal static string StateFolder = "States"; - - private const byte state_version = 7; - - private static bool IsSavingState = false; - - private static bool IsLoadingState = false; - - public static void SaveState(string fileName, bool saveImage) - { - if (!NesEmu.ON) - { - Tracer.WriteError("Can't save state, emu is off."); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error1, instant: false); - return; - } - if (!File.Exists(NesEmu.CurrentFilePath)) - { - Tracer.WriteError("Can't save state, no rom file is loaded."); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error2, instant: false); - return; - } - if (IsLoadingState) - { - Tracer.WriteError("Can't save state while loading a state !"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error3, instant: false); - return; - } - if (IsSavingState) - { - Tracer.WriteError("Already saving state !!"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error4, instant: false); - return; - } - IsSavingState = true; - BinaryWriter bin = new BinaryWriter(new MemoryStream()); - bin.Write(Encoding.ASCII.GetBytes("MNS")); - bin.Write((byte)7); - for (int i = 0; i < NesEmu.SHA1.Length; i += 2) - { - string value = NesEmu.SHA1.Substring(i, 2).ToUpper(); - bin.Write(Convert.ToByte(value, 16)); - } - NesEmu.WriteStateData(ref bin); - byte[] outData = new byte[0]; - ZlipWrapper.CompressData(((MemoryStream)bin.BaseStream).GetBuffer(), out outData); - FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write); - fileStream.Write(outData, 0, outData.Length); - MyNesMain.VideoProvider.TakeSnapshotAs(fileName.Replace(".mns", ".jpg"), ".jpg"); - bin.Flush(); - bin.Close(); - fileStream.Flush(); - fileStream.Close(); - IsSavingState = false; - Tracer.WriteInformation("State saved at slot " + Slot); - MyNesMain.VideoProvider.WriteInfoNotification(MNInterfaceLanguage.Message_Info1 + " " + Slot, instant: false); - } - - public static void SaveState(int Slot) - { - if (StateFolder == "States") - { - StateFolder = Path.Combine(MyNesMain.WorkingFolder, "States"); - } - Directory.CreateDirectory(StateFolder); - SaveState(Path.Combine(StateFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath)) + "_" + Slot + ".mns", saveImage: false); - } - - public static void SaveState() - { - SaveState(Slot); - } - - public static void LoadState() - { - LoadState(Slot); - } - - public static void LoadState(string fileName) - { - if (!NesEmu.ON) - { - Tracer.WriteError("Can't load state, emu is off."); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error5, instant: false); - return; - } - if (!File.Exists(NesEmu.CurrentFilePath)) - { - Tracer.WriteError("Can't load state, no rom file is loaded."); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error6, instant: false); - return; - } - if (IsSavingState) - { - Tracer.WriteError("Can't load state while saving a state !"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error7, instant: false); - return; - } - if (IsLoadingState) - { - Tracer.WriteError("Already loading state !!"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error8, instant: false); - return; - } - if (!File.Exists(fileName)) - { - Tracer.WriteError("No state found in slot " + Slot); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error9 + " " + Slot, instant: false); - return; - } - IsLoadingState = true; - FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - byte[] array = new byte[fileStream.Length]; - byte[] outData = new byte[0]; - fileStream.Read(array, 0, array.Length); - fileStream.Close(); - ZlipWrapper.DecompressData(array, out outData); - BinaryReader bin = new BinaryReader(new MemoryStream(outData)); - byte[] array2 = new byte[3]; - bin.Read(array2, 0, array2.Length); - if (Encoding.ASCII.GetString(array2) != "MNS") - { - Tracer.WriteError("Unable load state at slot " + Slot + "; Not My Nes State File !"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error10 + " " + Slot + "; " + MNInterfaceLanguage.Message_Error11, instant: false); - IsLoadingState = false; - return; - } - if (bin.ReadByte() != 7) - { - Tracer.WriteError("Unable load state at slot " + Slot + "; Not compatible state file version !"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error10 + " " + Slot + "; " + MNInterfaceLanguage.Message_Error12, instant: false); - IsLoadingState = false; - return; - } - string text = ""; - for (int i = 0; i < NesEmu.SHA1.Length; i += 2) - { - text += bin.ReadByte().ToString("X2"); - } - if (text.ToLower() != NesEmu.SHA1.ToLower()) - { - Tracer.WriteError("Unable load state at slot " + Slot + "; This state file is not for this game; not same SHA1 !"); - MyNesMain.VideoProvider.WriteErrorNotification(MNInterfaceLanguage.Message_Error10 + " " + Slot + "; " + MNInterfaceLanguage.Message_Error13, instant: false); - IsLoadingState = false; - } - else - { - NesEmu.ReadStateData(ref bin); - bin.Close(); - IsLoadingState = false; - Tracer.WriteInformation("State loaded from slot " + Slot); - MyNesMain.VideoProvider.WriteInfoNotification(MNInterfaceLanguage.Message_Info2 + " " + Slot, instant: false); - } - } - - public static void LoadState(int Slot) - { - if (StateFolder == "States") - { - StateFolder = Path.Combine(MyNesMain.WorkingFolder, "States"); - } - Directory.CreateDirectory(StateFolder); - LoadState(Path.Combine(StateFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath)) + "_" + Slot + ".mns"); - } - - public static string GetStateFile(int slot) - { - if (File.Exists(NesEmu.CurrentFilePath)) - { - return Path.Combine(StateFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath)) + "_" + slot + ".mns"; - } - return ""; - } - - public static string GetStateImageFile(int slot) - { - if (File.Exists(NesEmu.CurrentFilePath)) - { - return Path.Combine(StateFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath)) + "_" + slot + ".jpg"; - } - return ""; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/StateHandler.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/StateHandler.cs.meta deleted file mode 100644 index 005d25d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/StateHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bfc53d94a1834ed4d9206ff9f45d7d74 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Sunsoft5BChnl.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Sunsoft5BChnl.cs deleted file mode 100644 index cebef8b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Sunsoft5BChnl.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class Sunsoft5BChnl - { - internal bool Enabled; - - internal byte Volume; - - private int dutyStep; - - private int freqTimer; - - private int frequency; - - private int cycles; - - internal int output; - - internal bool Outputable; - - internal void HardReset() - { - } - - internal void SoftReset() - { - } - - internal void Write0(ref byte data) - { - frequency = (frequency & 0xF00) | data; - freqTimer = (frequency + 1) * 2; - } - - internal void Write1(ref byte data) - { - frequency = (frequency & 0xFF) | ((data & 0xF) << 8); - freqTimer = (frequency + 1) * 2; - } - - internal void ClockSingle() - { - if (--cycles > 0) - { - return; - } - cycles = freqTimer; - dutyStep = (dutyStep + 1) & 0x1F; - if (dutyStep <= 15) - { - if (Enabled) - { - if (Outputable) - { - output = Volume; - } - else - { - output = 0; - } - } - else - { - output = 0; - } - } - else - { - output = 0; - } - } - - internal void SaveState(ref BinaryWriter stream) - { - stream.Write(Enabled); - stream.Write(Volume); - stream.Write(dutyStep); - stream.Write(freqTimer); - stream.Write(frequency); - stream.Write(cycles); - } - - internal void LoadState(ref BinaryReader stream) - { - Enabled = stream.ReadBoolean(); - Volume = stream.ReadByte(); - dutyStep = stream.ReadInt32(); - freqTimer = stream.ReadInt32(); - frequency = stream.ReadInt32(); - cycles = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Sunsoft5BChnl.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Sunsoft5BChnl.cs.meta deleted file mode 100644 index 885619b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Sunsoft5BChnl.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 539fe437ee1b9e14eadfb0477280528d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumJoyIndex.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumJoyIndex.cs deleted file mode 100644 index 69acb95..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumJoyIndex.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - public enum EnumJoyIndex : byte - { - P1, P2, P3, P4 - } -} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumJoyIndex.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumJoyIndex.cs.meta deleted file mode 100644 index fdcbd8d..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumJoyIndex.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d0185abce4b430d478095a8d5621aef1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumKeyKind.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumKeyKind.cs deleted file mode 100644 index 2a04034..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumKeyKind.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MyNes.Core -{ - public enum EnumKeyKind - { - Up, Down, Left, Right, Select, Start, B, A, TurboB, TurboA - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumKeyKind.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumKeyKind.cs.meta deleted file mode 100644 index f7b10f7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/EnumKeyKind.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b25aa577a22fb0046afd4f72cd99daff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/IExternalSuppoter.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/IExternalSuppoter.cs deleted file mode 100644 index 1586928..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/IExternalSuppoter.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.IO; -namespace MyNes.Core -{ - - public interface IExternalSupporter - { - string GetWorkingFolderPath(); - public Stream OpenDatabaseFile(); - public Stream OpenPaletteFile(); - public Stream OpenRomFile(string path); - public bool IsKeyPressing(EnumJoyIndex index,EnumKeyKind key); - } -} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/IExternalSuppoter.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/IExternalSuppoter.cs.meta deleted file mode 100644 index e7bf3e5..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support/IExternalSuppoter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c9fd20bbd0bd8ff46b6ddef7dfb345a3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/TogglePause.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/TogglePause.cs deleted file mode 100644 index 2d74a30..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/TogglePause.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MyNes.Core -{ - internal delegate void TogglePause(bool paused); -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/TogglePause.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/TogglePause.cs.meta deleted file mode 100644 index f8e8b65..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/TogglePause.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1371973a9935de4192a2d7b9556184c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs deleted file mode 100644 index 2fc0264..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs +++ /dev/null @@ -1,80 +0,0 @@ -#define TRACE -using System; -using Unity.IL2CPP.CompilerServices; -using UnityEngine; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public sealed class Tracer - { - public static event EventHandler EventRaised; - - public static void WriteLine(string message) - { - Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, TracerStatus.Normal)); - //Debug.Log(message); - } - - public static void WriteLine(string message, string category) - { - Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", TracerStatus.Normal)); - //Debug.Log(message); - } - - public static void WriteLine(string message, TracerStatus status) - { - Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status)); - switch (status) - { - case TracerStatus.Error: Debug.LogError(message); break; - case TracerStatus.Infromation: - case TracerStatus.Normal: - Debug.Log(message); - break; - case TracerStatus.Warning: - Debug.LogWarning(message); - break; - } - - } - - public static void WriteLine(string message, string category, TracerStatus status) - { - Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", status)); - WriteLine($"{category}:{message}", status); - } - - public static void WriteError(string message) - { - WriteLine(message, TracerStatus.Error); - } - - public static void WriteError(string message, string category) - { - WriteLine(message, category, TracerStatus.Error); - } - - public static void WriteWarning(string message) - { - WriteLine(message, TracerStatus.Warning); - } - - public static void WriteWarning(string message, string category) - { - WriteLine(message, category, TracerStatus.Warning); - } - - public static void WriteInformation(string message) - { - WriteLine(message, TracerStatus.Infromation); - } - - public static void WriteInformation(string message, string category) - { - WriteLine(message, category, TracerStatus.Infromation); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs.meta deleted file mode 100644 index 92463c3..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4a65f5b3f03ae904e99821cebd149964 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerEventArgs.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerEventArgs.cs deleted file mode 100644 index 0c8a68b..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerEventArgs.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class TracerEventArgs : EventArgs - { - public string Message { get; private set; } - - public TracerStatus Status { get; private set; } - - public TracerEventArgs(string message, TracerStatus status) - { - Message = message; - Status = status; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerEventArgs.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerEventArgs.cs.meta deleted file mode 100644 index 22ecc60..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerEventArgs.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1aabf28e631b0dc42bf07ea3700eaa1c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerStatus.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerStatus.cs deleted file mode 100644 index c3ab5eb..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerStatus.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MyNes.Core -{ - public enum TracerStatus - { - Normal, - Error, - Warning, - Infromation - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerStatus.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerStatus.cs.meta deleted file mode 100644 index e846c1e..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/TracerStatus.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 52a5cc3ce27c2a04cb04aa200cc3c798 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Pulse.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Pulse.cs deleted file mode 100644 index 07cd398..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Pulse.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class VRC6Pulse - { - private int dutyForm; - - private int dutyStep; - - private bool enabled = true; - - internal bool Outputable; - - private bool mode; - - private byte volume; - - private int freqTimer; - - private int frequency; - - private int cycles; - - internal int output; - - internal void HardReset() - { - dutyForm = 0; - dutyStep = 15; - enabled = true; - mode = false; - output = 0; - } - - internal void Write0(ref byte data) - { - mode = (data & 0x80) == 128; - dutyForm = (data & 0x70) >> 4; - volume = (byte)(data & 0xFu); - } - - internal void Write1(ref byte data) - { - frequency = (frequency & 0xF00) | data; - } - - internal void Write2(ref byte data) - { - frequency = (frequency & 0xFF) | ((data & 0xF) << 8); - enabled = (data & 0x80) == 128; - } - - internal void ClockSingle() - { - if (--cycles > 0) - { - return; - } - cycles = (frequency << 1) + 2; - if (!enabled) - { - return; - } - if (mode) - { - output = volume; - return; - } - dutyStep--; - if (dutyStep < 0) - { - dutyStep = 15; - } - if (dutyStep <= dutyForm) - { - if (Outputable) - { - output = volume; - } - else - { - output = 0; - } - } - else - { - output = 0; - } - } - - internal void SaveState(ref BinaryWriter stream) - { - stream.Write(dutyForm); - stream.Write(dutyStep); - stream.Write(enabled); - stream.Write(mode); - stream.Write(volume); - stream.Write(freqTimer); - stream.Write(frequency); - stream.Write(cycles); - } - - internal void LoadState(ref BinaryReader stream) - { - dutyForm = stream.ReadInt32(); - dutyStep = stream.ReadInt32(); - enabled = stream.ReadBoolean(); - mode = stream.ReadBoolean(); - volume = stream.ReadByte(); - freqTimer = stream.ReadInt32(); - frequency = stream.ReadInt32(); - cycles = stream.ReadInt32(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Pulse.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Pulse.cs.meta deleted file mode 100644 index 82f6312..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Pulse.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 74455848e758856438177d90dada5bd7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Sawtooth.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Sawtooth.cs deleted file mode 100644 index 3d06632..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Sawtooth.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System.IO; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class VRC6Sawtooth - { - private byte AccumRate; - - private int accumClock; - - private byte accumulationRegister; - - private int frequency; - - private int freqTimer; - - private int cycles; - - private bool enabled; - - internal int output; - - internal bool Outputable; - - internal void HardReset() - { - } - - private void UpdateFrequency() - { - freqTimer = (frequency + 1) * 2; - } - - internal void Write0(ref byte data) - { - AccumRate = (byte)(data & 0x3Fu); - } - - internal void Write1(ref byte data) - { - frequency = (frequency & 0xF00) | data; - UpdateFrequency(); - } - - internal void Write2(ref byte data) - { - frequency = (frequency & 0xFF) | ((data & 0xF) << 8); - enabled = (data & 0x80) == 128; - UpdateFrequency(); - } - - internal void ClockSingle() - { - if (--cycles > 0) - { - return; - } - cycles = freqTimer; - if (enabled) - { - accumClock++; - switch (++accumClock) - { - case 2: - case 4: - case 6: - case 8: - case 10: - case 12: - accumulationRegister += AccumRate; - break; - case 14: - accumulationRegister = 0; - accumClock = 0; - break; - } - if (Outputable) - { - output = (accumulationRegister >> 3) & 0x1F; - } - else - { - output = 0; - } - } - else - { - output = 0; - } - } - - internal void SaveState(ref BinaryWriter stream) - { - stream.Write(AccumRate); - stream.Write(accumClock); - stream.Write(accumulationRegister); - stream.Write(frequency); - stream.Write(freqTimer); - stream.Write(cycles); - stream.Write(enabled); - } - - internal void LoadState(ref BinaryReader stream) - { - AccumRate = stream.ReadByte(); - accumClock = stream.ReadInt32(); - accumulationRegister = stream.ReadByte(); - frequency = stream.ReadInt32(); - freqTimer = stream.ReadInt32(); - cycles = stream.ReadInt32(); - enabled = stream.ReadBoolean(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Sawtooth.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Sawtooth.cs.meta deleted file mode 100644 index 1578d02..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/VRC6Sawtooth.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 382f7496025cd8846bf6459a0ad7f45f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/WaveRecorder.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/WaveRecorder.cs deleted file mode 100644 index a117145..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/WaveRecorder.cs +++ /dev/null @@ -1,306 +0,0 @@ -using System; -using System.IO; -using System.Text; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - public class WaveRecorder - { - private string _fileName; - - private Stream STR; - - private bool _IsRecording; - - private int SIZE; - - private int NoOfSamples; - - private int _Time; - - private int TimeSamples; - - private short channels; - - private short bitsPerSample; - - private int Frequency; - - public int Time => _Time; - - public bool IsRecording => _IsRecording; - - public void Record(string FilePath, short channels, short bitsPerSample, int Frequency) - { - _fileName = FilePath; - this.channels = channels; - this.bitsPerSample = bitsPerSample; - this.Frequency = Frequency; - _Time = 0; - STR = new FileStream(FilePath, FileMode.Create); - ASCIIEncoding aSCIIEncoding = new ASCIIEncoding(); - STR.Write(aSCIIEncoding.GetBytes("RIFF"), 0, 4); - STR.WriteByte(0); - STR.WriteByte(0); - STR.WriteByte(0); - STR.WriteByte(0); - STR.Write(aSCIIEncoding.GetBytes("WAVE"), 0, 4); - STR.Write(aSCIIEncoding.GetBytes("fmt "), 0, 4); - STR.WriteByte(16); - STR.WriteByte(0); - STR.WriteByte(0); - STR.WriteByte(0); - STR.WriteByte(1); - STR.WriteByte(0); - STR.WriteByte((byte)((uint)channels & 0xFFu)); - STR.WriteByte((byte)((channels & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Frequency & 0xFFu)); - STR.WriteByte((byte)((Frequency & 0xFF00) >> 8)); - STR.WriteByte((byte)((Frequency & 0xFF0000) >> 16)); - STR.WriteByte((byte)((Frequency & 0xFF000000u) >> 24)); - int num = Frequency * channels * (bitsPerSample / 8); - STR.WriteByte((byte)((uint)num & 0xFFu)); - STR.WriteByte((byte)((num & 0xFF00) >> 8)); - STR.WriteByte((byte)((num & 0xFF0000) >> 16)); - STR.WriteByte((byte)((num & 0xFF000000u) >> 24)); - short num2 = (short)(channels * (bitsPerSample / 8)); - STR.WriteByte((byte)((uint)num2 & 0xFFu)); - STR.WriteByte((byte)((num2 & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)bitsPerSample & 0xFFu)); - STR.WriteByte((byte)((bitsPerSample & 0xFF00) >> 8)); - STR.Write(aSCIIEncoding.GetBytes("data"), 0, 4); - STR.WriteByte(0); - STR.WriteByte(0); - STR.WriteByte(0); - STR.WriteByte(0); - _IsRecording = true; - } - - public void AddBuffer(ref byte[] buffer) - { - for (int i = 0; i < buffer.Length; i++) - { - switch (channels) - { - case 1: - switch (bitsPerSample) - { - case 8: - STR.WriteByte(buffer[i]); - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - break; - case 16: - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - break; - case 32: - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - break; - } - break; - case 2: - switch (bitsPerSample) - { - case 8: - STR.WriteByte(buffer[i]); - STR.WriteByte(buffer[i]); - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - break; - case 16: - STR.WriteByte(buffer[i]); - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - STR.WriteByte(buffer[i]); - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - break; - case 32: - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - STR.WriteByte(buffer[i]); - i++; - STR.WriteByte(buffer[i]); - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - break; - } - break; - } - } - } - - public void AddSample(int Sample) - { - if (!_IsRecording) - { - return; - } - switch (channels) - { - case 1: - switch (bitsPerSample) - { - case 8: - AddSample_mono_08(Sample); - break; - case 16: - AddSample_mono_16(Sample); - break; - case 32: - AddSample_mono_32(Sample); - break; - } - break; - case 2: - switch (bitsPerSample) - { - case 8: - AddSample_stereo_08(Sample); - break; - case 16: - AddSample_stereo_16(Sample); - break; - case 32: - AddSample_stereo_32(Sample); - break; - } - break; - } - NoOfSamples++; - TimeSamples++; - if (TimeSamples >= Frequency) - { - _Time++; - TimeSamples = 0; - } - } - - private void AddSample_mono_08(int Sample) - { - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - } - - private void AddSample_mono_16(int Sample) - { - STR.WriteByte((byte)((Sample & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - } - - private void AddSample_mono_32(int Sample) - { - STR.WriteByte((byte)((Sample & 0xFF000000u) >> 24)); - STR.WriteByte((byte)((Sample & 0xFF0000) >> 16)); - STR.WriteByte((byte)((Sample & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - } - - private void AddSample_stereo_08(int Sample) - { - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - } - - private void AddSample_stereo_16(int Sample) - { - STR.WriteByte((byte)((Sample & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - STR.WriteByte((byte)((Sample & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - } - - private void AddSample_stereo_32(int Sample) - { - STR.WriteByte((byte)((Sample & 0xFF000000u) >> 24)); - STR.WriteByte((byte)((Sample & 0xFF0000) >> 16)); - STR.WriteByte((byte)((Sample & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - STR.WriteByte((byte)((Sample & 0xFF000000u) >> 24)); - STR.WriteByte((byte)((Sample & 0xFF0000) >> 16)); - STR.WriteByte((byte)((Sample & 0xFF00) >> 8)); - STR.WriteByte((byte)((uint)Sample & 0xFFu)); - } - - public void Stop() - { - if (_IsRecording & (STR != null)) - { - NoOfSamples *= channels * (bitsPerSample / 8); - SIZE = NoOfSamples + 36; - byte[] array = new byte[4]; - byte[] array2 = new byte[4]; - array = BitConverter.GetBytes(SIZE); - if (!BitConverter.IsLittleEndian) - { - Array.Reverse(array); - } - array2 = BitConverter.GetBytes(NoOfSamples); - if (!BitConverter.IsLittleEndian) - { - Array.Reverse(array2); - } - _IsRecording = false; - STR.Position = 4L; - STR.Write(array, 0, 4); - STR.Position = 40L; - STR.Write(array2, 0, 4); - STR.Close(); - MyNesMain.VideoProvider.WriteInfoNotification("Sound file saved at " + Path.GetFileName(_fileName), instant: false); - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/WaveRecorder.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/WaveRecorder.cs.meta deleted file mode 100644 index 6ea774f..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/WaveRecorder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 889c64e645ae5744e9af609edb7b2db8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/WithExternalSoundAttribute.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/WithExternalSoundAttribute.cs deleted file mode 100644 index 0ed7069..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/WithExternalSoundAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using Unity.IL2CPP.CompilerServices; - -namespace MyNes.Core -{ - [Il2CppSetOption(Option.NullChecks, false)] - [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - [Il2CppSetOption(Option.DivideByZeroChecks, false)] - internal class WithExternalSoundAttribute : Attribute - { - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/WithExternalSoundAttribute.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/WithExternalSoundAttribute.cs.meta deleted file mode 100644 index b6aed36..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/WithExternalSoundAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8939062f5478c624088de22b10b3dda5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ZlipWrapper.cs b/AxibugEmuOnline.Client/Assets/MyNes.Core/ZlipWrapper.cs deleted file mode 100644 index 29343f7..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ZlipWrapper.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.IO; -using ComponentAce.Compression.Libs.zlib; - -namespace MyNes.Core -{ - internal class ZlipWrapper - { - internal static void CompressData(byte[] inData, out byte[] outData) - { - using MemoryStream memoryStream = new MemoryStream(); - using ZOutputStream zOutputStream = new ZOutputStream(memoryStream, -1); - using Stream input = new MemoryStream(inData); - CopyStream(input, zOutputStream); - zOutputStream.finish(); - outData = memoryStream.ToArray(); - } - - internal static void DecompressData(byte[] inData, out byte[] outData) - { - using MemoryStream memoryStream = new MemoryStream(); - using ZOutputStream zOutputStream = new ZOutputStream(memoryStream); - using Stream input = new MemoryStream(inData); - CopyStream(input, zOutputStream); - zOutputStream.finish(); - outData = memoryStream.ToArray(); - } - - internal static void CopyStream(Stream input, Stream output) - { - byte[] buffer = new byte[2000]; - int count; - while ((count = input.Read(buffer, 0, 2000)) > 0) - { - output.Write(buffer, 0, count); - } - output.Flush(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ZlipWrapper.cs.meta b/AxibugEmuOnline.Client/Assets/MyNes.Core/ZlipWrapper.cs.meta deleted file mode 100644 index 107f3ee..0000000 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ZlipWrapper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e1fde431f4bc3d548b77ff7467e14bc0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes.meta deleted file mode 100644 index 07ccdad..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8e5e5b73f8ff71745806799d6c3a97b6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityA.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityA.pal.txt deleted file mode 100644 index 8c93587..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityA.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityB.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityB.pal.txt deleted file mode 100644 index 1d36d59..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityB.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityB.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityB.pal.txt.meta deleted file mode 100644 index 069a07b..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityB.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e7c963ec91faede48bdbc4c837d184c1 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final2.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final2.pal.txt deleted file mode 100644 index 01fd716..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final2.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final2.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final2.pal.txt.meta deleted file mode 100644 index 38cbeda..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final2.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: f90e9c85a73ad3649a73f6b5c66ee21c -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final3.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final3.pal.txt deleted file mode 100644 index d156011..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final3.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final3.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final3.pal.txt.meta deleted file mode 100644 index a7b699a..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/BMF_final3.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 79fd9783decf96349b1bbdf3cd49d01e -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-13-default_nitsuja.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-13-default_nitsuja.pal.txt deleted file mode 100644 index 9367073..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-13-default_nitsuja.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-13-default_nitsuja.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-13-default_nitsuja.pal.txt.meta deleted file mode 100644 index 8cf7af1..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-13-default_nitsuja.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: cffbaa9e5c24d7b4aa3e27fcbe59a880 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-15-nitsuja_new.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-15-nitsuja_new.pal.txt deleted file mode 100644 index 4765e54..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-15-nitsuja_new.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-15-nitsuja_new.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-15-nitsuja_new.pal.txt.meta deleted file mode 100644 index 92e54ec..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEU-15-nitsuja_new.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 4a281e2c6edff1f4a8574e1429fef097 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEUX.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEUX.pal.txt deleted file mode 100644 index 2b8ea5d..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEUX.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEUX.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEUX.pal.txt.meta deleted file mode 100644 index 19fc3a3..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/FCEUX.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: acc05b5c291ed1c4fb812b7be20b8113 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/NTSC.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/NTSC.pal.txt deleted file mode 100644 index e958862..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/NTSC.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/NTSC.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/NTSC.pal.txt.meta deleted file mode 100644 index 49ba5e8..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/NTSC.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: eae5c00585ff5ad4da5ff743aa7cb388 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/PAL.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/PAL.pal.txt deleted file mode 100644 index e958862..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/PAL.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/PAL.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/PAL.pal.txt.meta deleted file mode 100644 index ec6386f..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/PAL.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: dbea537bf3d26ef469d311366274b854 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/default_ntsc.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/default_ntsc.pal.txt deleted file mode 100644 index e16b0b1..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/default_ntsc.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/default_ntsc.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/default_ntsc.pal.txt.meta deleted file mode 100644 index 2f58f29..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/default_ntsc.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: af0c6ae054b9b8b4eb1e950615e9666d -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10.pal.txt deleted file mode 100644 index d2d3d92..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10.pal.txt.meta deleted file mode 100644 index 8699e1a..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c87310fabe238424d8bc9b8cf5e06a1a -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10emph.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10emph.pal.txt deleted file mode 100644 index 8c31437..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10emph.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10emph.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10emph.pal.txt.meta deleted file mode 100644 index b67bb27..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/pc10emph.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: cd2c5883bfccfea41adc9d73a6f509de -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001.pal.txt deleted file mode 100644 index 0a8c2a7..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001.pal.txt.meta deleted file mode 100644 index 48f7c3b..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3e8bf825b3645ab47a1e3db5f98d65f0 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001emph.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001emph.pal.txt deleted file mode 100644 index cd08b4a..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001emph.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001emph.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001emph.pal.txt.meta deleted file mode 100644 index 229e4a0..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_001emph.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ac166adb93cefee48bf472799c28f078 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002.pal.txt deleted file mode 100644 index c1226cf..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002.pal.txt.meta deleted file mode 100644 index 68faf1b..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a4866a9e921def74f88bc9c76182d4bf -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002emph.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002emph.pal.txt deleted file mode 100644 index 6f821c8..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002emph.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002emph.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002emph.pal.txt.meta deleted file mode 100644 index e027087..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_002emph.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: db03b2f58578ecb4c8af8c69a62cc6e4 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003.pal.txt deleted file mode 100644 index b386189..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003.pal.txt.meta deleted file mode 100644 index 53a0ef0..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ae891fd90c634b64aa8d3bed26c9a130 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003emph.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003emph.pal.txt deleted file mode 100644 index aac1004..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003emph.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003emph.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003emph.pal.txt.meta deleted file mode 100644 index b2f17f7..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_003emph.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9a6da4c0ffb86d749b681f8a9d4403fd -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004.pal.txt deleted file mode 100644 index 23d44ac..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004.pal.txt.meta deleted file mode 100644 index 40b51a0..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: f1d9aa9ac67469d49b197ce086e00b86 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004emph.pal.txt b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004emph.pal.txt deleted file mode 100644 index edb82ef..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004emph.pal.txt and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004emph.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004emph.pal.txt.meta deleted file mode 100644 index 101d9c0..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/vs_004emph.pal.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1dc183e92926f564a90573e275d7b470 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/database.xml b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/database.xml deleted file mode 100644 index 39c4861..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/database.xml and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/database.xml.meta b/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/database.xml.meta deleted file mode 100644 index 92e6266..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/database.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c53b7ab773a22634bbe5c6a1ac794f54 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms/Kirby.nes.bytes.meta b/AxibugEmuOnline.Client/Assets/Resources/Roms/Kirby.nes.bytes.meta deleted file mode 100644 index 97eef8d..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/Roms/Kirby.nes.bytes.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 01dd757415143ae46921461228964dd5 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms/Mario.nes.bytes.meta b/AxibugEmuOnline.Client/Assets/Resources/Roms/Mario.nes.bytes.meta deleted file mode 100644 index cfcf910..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/Roms/Mario.nes.bytes.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ecb5d904338d35c43bb3b98249b36394 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms/tortoise4.nes.bytes.meta b/AxibugEmuOnline.Client/Assets/Resources/Roms/tortoise4.nes.bytes.meta deleted file mode 100644 index db26e21..0000000 --- a/AxibugEmuOnline.Client/Assets/Resources/Roms/tortoise4.nes.bytes.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 4933f61382c34574db545f3d9e72b51d -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity b/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity index d9156af..dfb22f6 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/EmuTest.unity @@ -26,7 +26,7 @@ RenderSettings: m_AmbientIntensity: 1 m_AmbientMode: 0 m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_SkyboxMaterial: {fileID: 0} m_HaloStrength: 0.5 m_FlareStrength: 1 m_FlareFadeSpeed: 3 @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -123,99 +123,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &708549044 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 708549046} - - component: {fileID: 708549045} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &708549045 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 708549044} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &708549046 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 708549044} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &1232273651 GameObject: m_ObjectHideFlags: 0 @@ -252,7 +159,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: 1, g: 1, b: 1, a: 0} + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 @@ -297,7 +204,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1359344831 GameObject: @@ -363,74 +270,74 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &8662582775744815903 +--- !u!1001 &4232056520998800727 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 8662582775359084755, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} - propertyPath: m_AnchoredPosition.x - value: -124 - objectReference: {fileID: 0} - - target: {fileID: 8662582775359084755, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} - propertyPath: m_AnchoredPosition.y - value: 109 - objectReference: {fileID: 0} - - target: {fileID: 8662582775359084756, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_RootOrder - value: 3 + value: 2 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487076, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536011, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 8662582775964487077, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + - target: {fileID: 4232056521131536013, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} propertyPath: m_Name - value: NesCoreProxy + value: NesEmulator + objectReference: {fileID: 0} + - target: {fileID: 4232056521759880274, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4232056521759880274, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} + propertyPath: m_Texture + value: + objectReference: {fileID: 0} + - target: {fileID: 4232056521759880276, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} + propertyPath: m_IsActive + value: 1 objectReference: {fileID: 0} m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: d75df7d1f5a2c824ab5013cbd79da7a4, type: 3} + m_SourcePrefab: {fileID: 100100000, guid: f8bea3f8aa351bb46ada33b2274729ea, type: 3} diff --git a/AxibugEmuOnline.Client/Assets/Script/AxibugEmuOnline.Client.asmdef b/AxibugEmuOnline.Client/Assets/Script/AxibugEmuOnline.Client.asmdef index afae401..46da217 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AxibugEmuOnline.Client.asmdef +++ b/AxibugEmuOnline.Client/Assets/Script/AxibugEmuOnline.Client.asmdef @@ -2,7 +2,7 @@ "name": "AxibugEmuOnline.Client", "rootNamespace": "AxibugEmuOnline.Client", "references": [ - "GUID:0c194730510bd1b4fad0398ccfe4235b" + "GUID:390a2c4058e5c304a87e8be70c84d80b" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu.meta b/AxibugEmuOnline.Client/Assets/Script/Emu.meta deleted file mode 100644 index 92efcfb..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 481b76fe04e7dcd4c9d5c89eab10343d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/AudioProvider.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/AudioProvider.cs deleted file mode 100644 index 8580c1c..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/AudioProvider.cs +++ /dev/null @@ -1,138 +0,0 @@ -using MyNes.Core; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using UnityEngine; - -namespace AxibugEmuOnline.Client -{ - public class AudioProvider : MonoBehaviour, IAudioProvider - { - public string Name => nameof(AudioProvider); - - public string ID => Name.GetHashCode().ToString(); - - public bool AllowBufferChange => true; - - public bool AllowFrequencyChange => true; - - private bool m_isPlaying; - private bool m_started; - [SerializeField] - private NesCoreProxy m_coreProxy; - [SerializeField] - private AudioSource m_as; - - private Stopwatch sw = Stopwatch.StartNew(); - private RingBuffer _buffer = new RingBuffer(4096); - - public double FPS { get; private set; } - - public void Initialize() - { - var dummy = AudioClip.Create("dummy", 1, 1, AudioSettings.outputSampleRate, false); - - dummy.SetData(new float[] { 1 }, 0); - m_as.clip = dummy; //just to let unity play the audiosource - m_as.loop = true; - m_as.spatialBlend = 1; - m_as.Play(); - } - - float lastData = 0; - void OnAudioFilterRead(float[] data, int channels) - { - if (!m_started) return; - - int step = channels; - - var bufferCount = _buffer.Available(); - if (bufferCount < 4096) - { - NesEmu.SetFramePeriod(ref fps_nes_missle); - } - else if (bufferCount > 8124) - { - NesEmu.SetFramePeriod(ref fps_pl_faster); - } - else - { - NesEmu.RevertFramePeriod(); - } - for (int i = 0; i < data.Length; i += step) - { - float rawFloat = lastData; - if (_buffer.TryRead(out short rawData)) - rawFloat = rawData / 124f; - - data[i] = rawFloat; - for (int fill = 1; fill < step; fill++) - data[i + fill] = rawFloat; - - lastData = rawFloat; - } - } - - private TimeSpan lastElapsed; - private double fps_nes_missle; - private double fps_pl_faster; - - public void SubmitSamples(ref short[] buffer, ref int samples_a) - { - var current = sw.Elapsed; - var delta = current - lastElapsed; - lastElapsed = current; - - FPS = 1d / delta.TotalSeconds; - - for (int i = 0; i < samples_a; i++) - { - _buffer.Write(buffer[i]); - } - } - - public void TogglePause(bool paused) - { - m_isPlaying = !paused; - } - - public void GetIsPlaying(out bool playing) - { - playing = m_isPlaying; - } - - public void ShutDown() - { - } - - public void Reset() - { - } - - public void SignalToggle(bool started) - { - if (started) - { - switch (NesEmu.Region) - { - case EmuRegion.NTSC: - fps_nes_missle = 1 / 60.5d; - fps_pl_faster = 1 / 59.5d; - break; - case EmuRegion.PALB: - case EmuRegion.DENDY: - fps_nes_missle = 0.0125; - fps_pl_faster = 0.02; - break; - } - - } - m_started = started; - } - - public void SetVolume(int Vol) - { - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager.meta deleted file mode 100644 index 6136b58..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cf0f3c8610629184e9c18af05d977830 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/InputManager.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/InputManager.cs deleted file mode 100644 index ff1f63f..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/InputManager.cs +++ /dev/null @@ -1,43 +0,0 @@ -using MyNes.Core; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace AxibugEmuOnline.Client.Input -{ - public class InputManager : MonoBehaviour - { - private KeyMapper m_p1Mapper = new LocalKeyMapper(); - private KeyMapper m_p2Mapper = new NetKeyMapper(); - private KeyMapper m_p3Mapper = new NetKeyMapper(); - private KeyMapper m_p4Mapper = new NetKeyMapper(); - - private void Awake() - { - m_p1Mapper.Init(); - m_p2Mapper.Init(); - m_p3Mapper.Init(); - m_p4Mapper.Init(); - } - - private void Update() - { - m_p1Mapper.Update(); - m_p2Mapper.Update(); - m_p3Mapper.Update(); - m_p4Mapper.Update(); - } - - public bool IsKeyPress(EnumJoyIndex joyIndex, EnumKeyKind keyKind) - { - switch (joyIndex) - { - case EnumJoyIndex.P1: return m_p1Mapper.IsPressing(keyKind); - case EnumJoyIndex.P2: return m_p2Mapper.IsPressing(keyKind); - case EnumJoyIndex.P3: return m_p3Mapper.IsPressing(keyKind); - case EnumJoyIndex.P4: return m_p4Mapper.IsPressing(keyKind); - default: return default; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/InputManager.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/InputManager.cs.meta deleted file mode 100644 index 4bf3dab..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/InputManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d79c33962dea7dc48b2c5fcd45afe1ad -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/KeyMapper.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/KeyMapper.cs deleted file mode 100644 index 48c6add..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/KeyMapper.cs +++ /dev/null @@ -1,15 +0,0 @@ -using MyNes.Core; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -namespace AxibugEmuOnline.Client.Input -{ - public abstract class KeyMapper - { - public abstract void Init(); - public abstract void Update(); - public abstract bool IsPressing(EnumKeyKind keyKind); - - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/KeyMapper.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/KeyMapper.cs.meta deleted file mode 100644 index 7322f54..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/KeyMapper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 61e49dbcce97ff74fb117da5d69f844d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/LocalKeyMapper.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/LocalKeyMapper.cs deleted file mode 100644 index 2a61db2..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/LocalKeyMapper.cs +++ /dev/null @@ -1,72 +0,0 @@ -using MyNes.Core; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -namespace AxibugEmuOnline.Client.Input -{ - public class LocalKeyMapper : KeyMapper - { - private Dictionary m_mapper = new Dictionary(); - private Dictionary m_mapperOpp = new Dictionary(); - private Dictionary m_keyIndexTable = new Dictionary(); - private EnumKeyKind[] m_focusKeys; - private bool[] m_keyStates; - - public override void Init() - { - SetKeyMapper(KeyCode.W, EnumKeyKind.Up); - SetKeyMapper(KeyCode.S, EnumKeyKind.Down); - SetKeyMapper(KeyCode.A, EnumKeyKind.Left); - SetKeyMapper(KeyCode.D, EnumKeyKind.Right); - SetKeyMapper(KeyCode.V, EnumKeyKind.Select); - SetKeyMapper(KeyCode.B, EnumKeyKind.Start); - SetKeyMapper(KeyCode.J, EnumKeyKind.B); - SetKeyMapper(KeyCode.K, EnumKeyKind.A); - SetKeyMapper(KeyCode.U, EnumKeyKind.TurboB); - SetKeyMapper(KeyCode.I, EnumKeyKind.TurboA); - SetComplete(); - } - - void SetKeyMapper(KeyCode inputKeycode, EnumKeyKind joyKey) - { - if (m_mapperOpp.TryGetValue(joyKey, out KeyCode keyCode))//Èç¹û¸ÃÓ³ÉäÒÑÉèÖùý,ÒƳý֮ǰµÄÓ³Éä - { - m_mapperOpp.Remove(joyKey); - m_mapper.Remove(keyCode); - } - m_mapper[inputKeycode] = joyKey; - m_mapperOpp[joyKey] = inputKeycode; - } - - void SetComplete() - { - m_focusKeys = m_mapperOpp.Keys.ToArray(); - m_keyStates = new bool[m_focusKeys.Length]; - - m_keyIndexTable.Clear(); - for (int i = 0; i < m_focusKeys.Length; i++) - { - m_keyIndexTable[m_focusKeys[i]] = i; - } - } - - public override void Update() - { - if (m_focusKeys == null) return; - - for (int i = 0; i < m_focusKeys.Length; i++) - { - var keyCode = m_mapperOpp[m_focusKeys[i]]; - m_keyStates[i] = UnityEngine.Input.GetKey(keyCode); - } - } - - public override bool IsPressing(EnumKeyKind keyKind) - { - if (!m_keyIndexTable.TryGetValue(keyKind, out int index)) return false;//ûÓÐÉèÖÃÓ³Éä,Ö±½Ófalse - - return m_keyStates[index]; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/LocalKeyMapper.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/LocalKeyMapper.cs.meta deleted file mode 100644 index 550160a..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/LocalKeyMapper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f5ed9df7bb0a5ed4096219829b4e2f6e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NesJoyController.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NesJoyController.cs deleted file mode 100644 index e2666e0..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NesJoyController.cs +++ /dev/null @@ -1,61 +0,0 @@ -using MyNes.Core; - -namespace AxibugEmuOnline.Client -{ - public class NesJoyController : IJoypadConnecter - { - private EnumJoyIndex m_joyIndex; - private bool turbo; - - public NesJoyController(EnumJoyIndex joyIndex) - { - m_joyIndex = joyIndex; - } - public override void Update() - { - turbo = !turbo; - DATA = 0; - var state = MyNesMain.Supporter; - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.A)) - { - DATA |= 1; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.B)) - { - DATA |= 2; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.TurboA) && turbo) - { - DATA |= 1; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.TurboB) && turbo) - { - DATA |= 2; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.Select)) - { - DATA |= 4; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.Start)) - { - DATA |= 8; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.Up)) - { - DATA |= 16; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.Down)) - { - DATA |= 32; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.Left)) - { - DATA |= 64; - } - if (state.IsKeyPressing(m_joyIndex, EnumKeyKind.Right)) - { - DATA |= 128; - } - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NesJoyController.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NesJoyController.cs.meta deleted file mode 100644 index c7c1737..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NesJoyController.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a4c763168d739ee409c2723564c2113b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NetKeyMapper.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NetKeyMapper.cs deleted file mode 100644 index 66a65a1..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NetKeyMapper.cs +++ /dev/null @@ -1,24 +0,0 @@ -using AxibugEmuOnline.Client.Input; -using MyNes.Core; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace AxibugEmuOnline.Client -{ - public class NetKeyMapper : KeyMapper - { - public override void Init() - { - } - - public override void Update() - { - } - - public override bool IsPressing(EnumKeyKind keyKind) - { - return false; - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NetKeyMapper.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NetKeyMapper.cs.meta deleted file mode 100644 index a721ba3..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/InputManager/NetKeyMapper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 266dac4486104b64cb089b6898b46cfc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/UguiVideoProvider.cs b/AxibugEmuOnline.Client/Assets/Script/Emu/UguiVideoProvider.cs deleted file mode 100644 index 1470ff6..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/UguiVideoProvider.cs +++ /dev/null @@ -1,142 +0,0 @@ -using MyNes.Core; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.Video; - -namespace AxibugEmuOnline.Client -{ - public class UguiVideoProvider : MonoBehaviour, IVideoProvider - { - - public string Name => "Unity UI Video"; - - public string ID => nameof(UguiVideoProvider).GetHashCode().ToString(); - - [SerializeField] - private NesCoreProxy m_coreProxy; - [SerializeField] - private RawImage m_drawCanvas; - [SerializeField] - private Text m_fpsText; - [SerializeField] - private Text m_nofity; - - private Color[] m_texRawBuffer = new Color[256 * 240]; - private Texture2D m_rawBufferWarper; - private RenderTexture m_drawRT; - private Color temp = Color.white; - - private bool toggleOn; - - public void Initialize() - { - m_rawBufferWarper = new Texture2D(256, 240); - } - - public void GetColor(uint value, ref Color res) - { - var r = 0xFF0000 & value; - r >>= 16; - var b = 0xFF & value; - var g = 0xFF00 & value; - g >>= 8; - res.r = r / 255f; - res.g = g / 255f; - res.b = b / 255f; - } - - public void Update() - { - if (toggleOn) - { - if (!m_drawCanvas.enabled) m_drawCanvas.enabled = true; - var colors = m_texRawBuffer; - m_rawBufferWarper.SetPixels(colors); - m_rawBufferWarper.Apply(); - Graphics.Blit(m_rawBufferWarper, m_drawCanvas.texture as RenderTexture); - - m_fpsText.text = $"fps:{m_coreProxy.AudioCom.FPS:00.00}"; - } - else - { - if (m_drawCanvas.enabled) m_drawCanvas.enabled = false; - } - } - - public void WriteErrorNotification(string message, bool instant) - { - m_nofity.text = message; - } - - public void WriteInfoNotification(string message, bool instant) - { - m_nofity.text = message; - } - - public void WriteWarningNotification(string message, bool instant) - { - m_nofity.text = message; - } - - public void TakeSnapshotAs(string path, string format) - { - - } - - public void TakeSnapshot() - { - - } - - public void ShutDown() - { - } - - public void SignalToggle(bool started) - { - toggleOn = started; - } - - public void SubmitFrame(ref int[] buffer) - { - for (int i = 0; i < buffer.Length; i++) - { - GetColor((uint)buffer[i], ref temp); - m_texRawBuffer[i] = temp; - } - } - - public void ResizeBegin() - { - } - - public void ResizeEnd() - { - } - - public void ApplyRegionChanges() - { - } - - public void Resume() - { - } - - public void ToggleAspectRatio(bool keep_aspect) - { - } - - public void ToggleFPS(bool show_fps) - { - } - - public void ApplyFilter() - { - } - - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/UguiVideoProvider.cs.meta b/AxibugEmuOnline.Client/Assets/Script/Emu/UguiVideoProvider.cs.meta deleted file mode 100644 index 249242e..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/UguiVideoProvider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f2632911774df3c488ec24b39651c4de -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppEmu.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/AppEmu.cs index aee4b3c..46f3d2c 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/AppEmu.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppEmu.cs @@ -1,67 +1,10 @@ -using AxibugEmuOnline.Client.Input; -using MyNes.Core; -using System.IO; +using System.IO; using UnityEngine; namespace AxibugEmuOnline.Client.Manager { - public class AppEmu : IExternalSupporter + public class AppEmu { - private InputManager m_inputMgr; - - public void Init(IVideoProvider videoCom, IAudioProvider audioCom, InputManager inputManager) - { - m_inputMgr = inputManager; - - MyNesMain.Initialize(this, videoCom, audioCom); - NesEmu.SetupControllers( - new NesJoyController(EnumJoyIndex.P1), - new NesJoyController(EnumJoyIndex.P2), - new NesJoyController(EnumJoyIndex.P3), - new NesJoyController(EnumJoyIndex.P4)); - - } - - public bool LoadGame(string romName) - { - NesEmu.LoadGame(romName, out var successed, true); - return successed; - } - - public void Dispose() - { - MyNesMain.Shutdown(); - } - - public Stream OpenDatabaseFile() - { - var databaseFile = Resources.Load("NesCoreRes/database"); - MemoryStream ms = new MemoryStream(databaseFile.bytes); - return ms; - } - - public Stream OpenPaletteFile() - { - var defaultPalett = Resources.Load("NesCoreRes/Palettes/default_ntsc.pal"); - MemoryStream ms = new MemoryStream(defaultPalett.bytes); - return ms; - } - - public string GetWorkingFolderPath() - { - return $"{Application.persistentDataPath}/MyNes"; - } - - public Stream OpenRomFile(string path) - { - var ta = Resources.Load($"Roms/{path}"); - MemoryStream ms = new MemoryStream(ta.bytes); - return ms; - } - - public bool IsKeyPressing(EnumJoyIndex index, EnumKeyKind key) - { - return m_inputMgr.IsKeyPress(index, key); - } + } } diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppNetGame.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/AppNetGame.cs index 17e1300..a576bc8 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/AppNetGame.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppNetGame.cs @@ -3,7 +3,6 @@ using AxibugEmuOnline.Client.Common; using AxibugEmuOnline.Client.Network; using AxibugProtobuf; using Google.Protobuf; -using MyNes.Core; using System.IO; using System.IO.Compression; using System.Linq; @@ -18,7 +17,6 @@ namespace AxibugEmuOnline.Client.Manager public AppNetGame() { NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdScreen, OnScreen); - _palette = NTSCPaletteGenerator.GeneratePalette(); } Protobuf_Screnn_Frame _Protobuf_Screnn_Frame = new Protobuf_Screnn_Frame(); diff --git a/AxibugEmuOnline.Client/Assets/Script/NesCoreProxy.cs b/AxibugEmuOnline.Client/Assets/Script/NesCoreProxy.cs deleted file mode 100644 index 122b411..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/NesCoreProxy.cs +++ /dev/null @@ -1,30 +0,0 @@ -using AxibugEmuOnline.Client.Input; -using AxibugEmuOnline.Client.Manager; -using MyNes.Core; -using System.IO; -using UnityEngine; -using UnityEngine.UI; - -namespace AxibugEmuOnline.Client -{ - public class NesCoreProxy : MonoBehaviour - { - public UguiVideoProvider VideoCom; - public AudioProvider AudioCom; - public InputManager InputManager; - - private AppEmu m_appEnum = new AppEmu(); - - private void Start() - { - m_appEnum.Init(VideoCom, AudioCom, InputManager); - - m_appEnum.LoadGame("kirby.nes"); - } - - private void OnDestroy() - { - m_appEnum.Dispose(); - } - } -} diff --git a/AxibugEmuOnline.Client/Assets/Script/NesCoreProxy.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesCoreProxy.cs.meta deleted file mode 100644 index 5487bae..0000000 --- a/AxibugEmuOnline.Client/Assets/Script/NesCoreProxy.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ac8cd27a180bf3e489b2ca27c821bffe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator.meta similarity index 77% rename from AxibugEmuOnline.Client/Assets/MyNes.Core.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator.meta index 433ca4b..49f52ed 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 42793fd3c4b41384983c8c2551603557 +guid: 5ff32bd86cd0f8245811007dc4e50768 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/AudioProvider.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/AudioProvider.cs new file mode 100644 index 0000000..d637b2c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/AudioProvider.cs @@ -0,0 +1,47 @@ +using System; +using System.Diagnostics; +using UnityEngine; +using VirtualNes.Core; + +public class AudioProvider : MonoBehaviour +{ + [SerializeField] + private AudioSource m_as; + + private SoundBuffer _buffer = new SoundBuffer(4096); + + public void Initialize() + { + var dummy = AudioClip.Create("dummy", 1, 1, AudioSettings.outputSampleRate, false); + + dummy.SetData(new float[] { 1 }, 0); + m_as.clip = dummy; //just to let unity play the audiosource + m_as.loop = true; + m_as.spatialBlend = 1; + m_as.Play(); + } + + void OnAudioFilterRead(float[] data, int channels) + { + int step = channels; + + var bufferCount = _buffer.Available(); + + for (int i = 0; i < data.Length; i += step) + { + float rawFloat = 0; + if (_buffer.TryRead(out byte rawData)) + rawFloat = rawData / 255f; + + data[i] = rawFloat; + for (int fill = 1; fill < step; fill++) + data[i + fill] = rawFloat; + + } + } + + public void ProcessSound(NES nes) + { + nes.apu.Process(_buffer, (uint)(Supporter.Config.sound.nRate * Time.deltaTime)); + } +} diff --git a/AxibugEmuOnline.Client/Assets/Script/Emu/AudioProvider.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/AudioProvider.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/Script/Emu/AudioProvider.cs.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator/AudioProvider.cs.meta index 8a0fe31..2ec068d 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Emu/AudioProvider.cs.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/AudioProvider.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 765129d4fad76714191795975893ea9c +guid: a6a09b6a4cf4c2d4f994a13fd7e89d6f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreDebuger.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreDebuger.cs new file mode 100644 index 0000000..cdf1191 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreDebuger.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using VirtualNes.Core.Debug; + +namespace AxibugEmuOnline.Client +{ + public class CoreDebuger : IDebugerImpl + { + + public void Log(string message) + { + Debug.Log(message); + } + + public void LogError(string message) + { + Debug.LogError(message); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankJoypad.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreDebuger.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/BlankJoypad.cs.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreDebuger.cs.meta index afba8a6..b7a7572 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BlankJoypad.cs.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreDebuger.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d122941c868588e4e9fdb758ff7bd340 +guid: 06357866273334741b885e5a1ad23afd MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs new file mode 100644 index 0000000..7cb639b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using UnityEngine; +using VirtualNes.Core; + +namespace AxibugEmuOnline.Client +{ + public class CoreSupporter : ISupporterImpl + { + private static string RomDirectoryPath + { + get + { +#if UNITY_EDITOR + return "Assets/StreamingAssets/Roms"; +#else + return $"{Application.streamingAssetsPath}/Roms"; +#endif + } + } + + public Stream OpenRom(string fname) + { + try + { + var stream = File.Open($"{RomDirectoryPath}/{fname}", FileMode.Open); + return stream; + } + catch (Exception ex) + { + Debug.LogError(ex); + return null; + } + } + + public void GetRomPathInfo(string fname, out string fullPath, out string directPath) + { + directPath = RomDirectoryPath; + fullPath = $"{directPath}/{fname}"; + } + + public Stream OpenFile_DISKSYS() + { + return File.Open($"{Application.streamingAssetsPath}/Disksys.rom", FileMode.Open, FileAccess.Read); + } + + public void SaveSRAMToFile(byte[] sramContent, string romName) + { + string sramDirectoryPath = $"{Application.persistentDataPath}/sav"; + Directory.CreateDirectory(sramDirectoryPath); + romName = Path.GetFileNameWithoutExtension(romName); + File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent); + } + + public void SaveDISKToFile(byte[] diskFileContent, string romName) + { + string diskFileDirectoryPath = $"{Application.persistentDataPath}/dsv"; + Directory.CreateDirectory(diskFileDirectoryPath); + romName = Path.GetFileNameWithoutExtension(romName); + File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent); + } + + public EmulatorConfig Config { get; private set; } = new EmulatorConfig(); + + public void PrepareDirectory(string directPath) + { + Directory.CreateDirectory($"{Application.persistentDataPath}/{directPath}"); + } + + public void SaveFile(byte[] fileData, string directPath, string fileName) + { + PrepareDirectory(directPath); + + var fileFullpath = $"{Application.persistentDataPath}/{directPath}/{fileName}"; + File.WriteAllBytes(fileFullpath, fileData); + } + + public Stream OpenFile(string directPath, string fileName) + { + try + { + var data = File.ReadAllBytes($"{Application.persistentDataPath}/{directPath}/{fileName}"); + if (data == null) return null; + return new MemoryStream(data); + } + catch + { + return null; + } + + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfo.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfo.cs.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs.meta index cc2618b..5bad9b0 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfo.cs.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e9cec9f263a14d640885246190006795 +guid: 8207d923313517f448d7b4d54756e993 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs new file mode 100644 index 0000000..1f081bc --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs @@ -0,0 +1,60 @@ +using System; +using UnityEngine; +using VirtualNes.Core; +using VirtualNes.Core.Debug; + +namespace AxibugEmuOnline.Client +{ + public class NesEmulator : MonoBehaviour + { + private NES m_nesIns; + + public VideoProvider VideoProvider; + public AudioProvider AudioProvider; + + private void Start() + { + Application.targetFrameRate = 60; + StartGame("tstd2.nes"); + } + + public void StartGame(string romName) + { + StopGame(); + + Supporter.Setup(new CoreSupporter()); + Debuger.Setup(new CoreDebuger()); + + try + { + m_nesIns = new NES(romName); + } + catch (Exception ex) + { + m_nesIns = null; + Debug.LogError(ex); + } + } + + public void StopGame() + { + m_nesIns?.Dispose(); + m_nesIns = null; + } + + + private void Update() + { + if (m_nesIns != null) + { + m_nesIns.EmulateFrame(true); + + var screenBuffer = m_nesIns.ppu.GetScreenPtr(); + var lineColorMode = m_nesIns.ppu.GetLineColorMode(); + VideoProvider.SetDrawData(screenBuffer, lineColorMode, 256, 240); + + AudioProvider.ProcessSound(m_nesIns); + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Bandai.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Bandai.cs.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs.meta index 44f5f1c..d178f30 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Bandai.cs.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 449c08ab39c9dd440b660ac2d12fb8ff +guid: 39557e19783acee499ace6c68549e8f8 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.prefab b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.prefab new file mode 100644 index 0000000..841a651 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.prefab @@ -0,0 +1,407 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &9760340517325694 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4785916497946256520} + - component: {fileID: 9003897287163669553} + - component: {fileID: 7558824780418593440} + m_Layer: 0 + m_Name: AudioProvider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4785916497946256520 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9760340517325694} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4232056521131536011} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &9003897287163669553 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9760340517325694} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a6a09b6a4cf4c2d4f994a13fd7e89d6f, type: 3} + m_Name: + m_EditorClassIdentifier: + m_as: {fileID: 7558824780418593440} +--- !u!82 &7558824780418593440 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9760340517325694} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 +--- !u!1 &4232056520112715746 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4232056520112715745} + - component: {fileID: 4232056520112715744} + m_Layer: 0 + m_Name: VideoProvider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4232056520112715745 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056520112715746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4232056520494431727} + m_Father: {fileID: 4232056521131536011} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &4232056520112715744 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056520112715746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 83fbe375412d1af4482ae76e81c1dda2, type: 3} + m_Name: + m_EditorClassIdentifier: + Image: {fileID: 4232056521759880274} +--- !u!1 &4232056520494431712 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4232056520494431727} + - component: {fileID: 4232056520494431724} + - component: {fileID: 4232056520494431725} + - component: {fileID: 4232056520494431726} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4232056520494431727 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056520494431712} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 4232056521759880275} + m_Father: {fileID: 4232056520112715745} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!223 &4232056520494431724 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056520494431712} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!114 &4232056520494431725 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056520494431712} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!114 &4232056520494431726 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056520494431712} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!1 &4232056521131536013 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4232056521131536011} + - component: {fileID: 4232056521131536012} + m_Layer: 0 + m_Name: NesEmulator + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4232056521131536011 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056521131536013} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4232056520112715745} + - {fileID: 4785916497946256520} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &4232056521131536012 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056521131536013} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 39557e19783acee499ace6c68549e8f8, type: 3} + m_Name: + m_EditorClassIdentifier: + VideoProvider: {fileID: 4232056520112715744} + AudioProvider: {fileID: 9003897287163669553} +--- !u!1 &4232056521759880276 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4232056521759880275} + - component: {fileID: 4232056521759880273} + - component: {fileID: 4232056521759880274} + m_Layer: 5 + m_Name: RawImage + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4232056521759880275 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056521759880276} + m_LocalRotation: {x: 1, y: 0, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4232056520494431727} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 272, y: 240} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &4232056521759880273 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056521759880276} + m_CullTransparentMesh: 1 +--- !u!114 &4232056521759880274 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4232056521759880276} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Texture: {fileID: 8400000, guid: ffe34aaf87e4b9942b4c2ac05943d444, type: 2} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityA.pal.txt.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.prefab.meta similarity index 62% rename from AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityA.pal.txt.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.prefab.meta index 89da682..6e48698 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes/Palettes/ASQ_realityA.pal.txt.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.prefab.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 66c9b7bb9e78e2149a8c6b884e7814dc -TextScriptImporter: +guid: f8bea3f8aa351bb46ada33b2274729ea +PrefabImporter: externalObjects: {} userData: assetBundleName: diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/PaletteDefine.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/PaletteDefine.cs new file mode 100644 index 0000000..4cb4fd3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/PaletteDefine.cs @@ -0,0 +1,242 @@ +using Codice.CM.Client.Differences; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using VirtualNes.Core; + +namespace AxibugEmuOnline.Client.Assets.Script.NesEmulator +{ + public static class PaletteDefine + { + public class PALBUF + { + public byte r; + public byte g; + public byte b; + + public PALBUF(byte r, byte g, byte b) + { + this.r = r; + this.g = g; + this.b = b; + } + } + + // スキャンラインカラー + private static int m_nScanlineColor => Supporter.Config.graphics.nScanlineColor; + + public static float[][] PalConvTbl = new float[8][] + { + new float[3]{1.00f, 1.00f, 1.00f}, + new float[3]{1.00f, 0.80f, 0.73f}, + new float[3]{0.73f, 1.00f, 0.70f}, + new float[3]{0.76f, 0.78f, 0.58f}, + new float[3]{0.86f, 0.80f, 1.00f}, + new float[3]{0.83f, 0.68f, 0.85f}, + new float[3]{0.67f, 0.77f, 0.83f}, + new float[3]{0.68f, 0.68f, 0.68f}, + }; + + public static PALBUF[] m_PaletteBuf = new PALBUF[64] + { + new PALBUF(0x7F, 0x7F, 0x7F), + new PALBUF(0x20, 0x00, 0xB0), + new PALBUF(0x28, 0x00, 0xB8), + new PALBUF(0x60, 0x10, 0xA0), + new PALBUF(0x98, 0x20, 0x78), + new PALBUF(0xB0, 0x10, 0x30), + new PALBUF(0xA0, 0x30, 0x00), + new PALBUF(0x78, 0x40, 0x00), + new PALBUF(0x48, 0x58, 0x00), + new PALBUF(0x38, 0x68, 0x00), + new PALBUF(0x38, 0x6C, 0x00), + new PALBUF(0x30, 0x60, 0x40), + new PALBUF(0x30, 0x50, 0x80), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0xBC, 0xBC, 0xBC), + new PALBUF(0x40, 0x60, 0xF8), + new PALBUF(0x40, 0x40, 0xFF), + new PALBUF(0x90, 0x40, 0xF0), + new PALBUF(0xD8, 0x40, 0xC0), + new PALBUF(0xD8, 0x40, 0x60), + new PALBUF(0xE0, 0x50, 0x00), + new PALBUF(0xC0, 0x70, 0x00), + new PALBUF(0x88, 0x88, 0x00), + new PALBUF(0x50, 0xA0, 0x00), + new PALBUF(0x48, 0xA8, 0x10), + new PALBUF(0x48, 0xA0, 0x68), + new PALBUF(0x40, 0x90, 0xC0), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0xFF, 0xFF, 0xFF), + new PALBUF(0x60, 0xA0, 0xFF), + new PALBUF(0x50, 0x80, 0xFF), + new PALBUF(0xA0, 0x70, 0xFF), + new PALBUF(0xF0, 0x60, 0xFF), + new PALBUF(0xFF, 0x60, 0xB0), + new PALBUF(0xFF, 0x78, 0x30), + new PALBUF(0xFF, 0xA0, 0x00), + new PALBUF(0xE8, 0xD0, 0x20), + new PALBUF(0x98, 0xE8, 0x00), + new PALBUF(0x70, 0xF0, 0x40), + new PALBUF(0x70, 0xE0, 0x90), + new PALBUF(0x60, 0xD0, 0xE0), + new PALBUF(0x60, 0x60, 0x60), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0xFF, 0xFF, 0xFF), + new PALBUF(0x90, 0xD0, 0xFF), + new PALBUF(0xA0, 0xB8, 0xFF), + new PALBUF(0xC0, 0xB0, 0xFF), + new PALBUF(0xE0, 0xB0, 0xFF), + new PALBUF(0xFF, 0xB8, 0xE8), + new PALBUF(0xFF, 0xC8, 0xB8), + new PALBUF(0xFF, 0xD8, 0xA0), + new PALBUF(0xFF, 0xF0, 0x90), + new PALBUF(0xC8, 0xF0, 0x80), + new PALBUF(0xA0, 0xF0, 0xA0), + new PALBUF(0xA0, 0xFF, 0xC8), + new PALBUF(0xA0, 0xFF, 0xF0), + new PALBUF(0xA0, 0xA0, 0xA0), + new PALBUF(0x00, 0x00, 0x00), + new PALBUF(0x00, 0x00, 0x00), + }; + + #region ピクセルフォーマットã«å¤‰æ›ã—ãŸãƒ‘レット + // Color + public static uint[][] m_cnPalette = new uint[8][] + { + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + }; + // Color/Scanline + public static uint[][] m_csPalette = new uint[8][] + { + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + }; + + // Monochrome + public static uint[][] m_mnPalette = new uint[8][] + { + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + }; + + // Monochrome/Scanline + public static uint[][] m_msPalette = new uint[8][] + { + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + new uint[256], + }; + #endregion + + static PaletteDefine() + { + int Rbit = 0, Gbit = 0, Bbit = 0; + int Rsft = 0, Gsft = 0, Bsft = 0; + + GetBitMask(0xFF0000, ref Rsft, ref Rbit); + GetBitMask(0x00FF00, ref Gsft, ref Gbit); + GetBitMask(0x0000FF, ref Bsft, ref Bbit); + + for (int j = 0; j < 8; j++) + { + for (int i = 0; i < 64; i++) + { + uint Rn, Gn, Bn; + uint Rs, Gs, Bs; + + // Normal + Rn = (uint)(PalConvTbl[j][0] * m_PaletteBuf[i].r); + Gn = (uint)(PalConvTbl[j][1] * m_PaletteBuf[i].g); + Bn = (uint)(PalConvTbl[j][2] * m_PaletteBuf[i].b); + // Scanline + Rs = (uint)(PalConvTbl[j][0] * m_PaletteBuf[i].r * m_nScanlineColor / 100.0f); + Gs = (uint)(PalConvTbl[j][1] * m_PaletteBuf[i].g * m_nScanlineColor / 100.0f); + Bs = (uint)(PalConvTbl[j][2] * m_PaletteBuf[i].b * m_nScanlineColor / 100.0f); + + m_cnPalette[j][i] = ((Rn >> (8 - Rbit)) << Rsft) | ((Gn >> (8 - Gbit)) << Gsft) | ((Bn >> (8 - Bbit)) << Bsft); + m_csPalette[j][i] = ((Rs >> (8 - Rbit)) << Rsft) | ((Gs >> (8 - Gbit)) << Gsft) | ((Bs >> (8 - Bbit)) << Bsft); + + // Monochrome + Rn = (uint)(m_PaletteBuf[i & 0x30].r); + Gn = (uint)(m_PaletteBuf[i & 0x30].g); + Bn = (uint)(m_PaletteBuf[i & 0x30].b); + Rn = + Gn = + Bn = (uint)(0.299f * Rn + 0.587f * Gn + 0.114f * Bn); + Rn = (uint)(PalConvTbl[j][0] * Rn); + Gn = (uint)(PalConvTbl[j][1] * Gn); + Bn = (uint)(PalConvTbl[j][2] * Bn); + if (Rn > 0xFF) Rs = 0xFF; + if (Gn > 0xFF) Gs = 0xFF; + if (Bn > 0xFF) Bs = 0xFF; + // Scanline + Rs = (uint)(m_PaletteBuf[i & 0x30].r * m_nScanlineColor / 100.0f); + Gs = (uint)(m_PaletteBuf[i & 0x30].g * m_nScanlineColor / 100.0f); + Bs = (uint)(m_PaletteBuf[i & 0x30].b * m_nScanlineColor / 100.0f); + Rs = + Gs = + Bs = (uint)(0.299f * Rs + 0.587f * Gs + 0.114f * Bs); + Rs = (uint)(PalConvTbl[j][0] * Rs); + Gs = (uint)(PalConvTbl[j][1] * Gs); + Bs = (uint)(PalConvTbl[j][2] * Bs); + if (Rs > 0xFF) Rs = 0xFF; + if (Gs > 0xFF) Gs = 0xFF; + if (Bs > 0xFF) Bs = 0xFF; + + m_mnPalette[j][i] = ((Rn >> (8 - Rbit)) << Rsft) | ((Gn >> (8 - Gbit)) << Gsft) | ((Bn >> (8 - Bbit)) << Bsft); + m_msPalette[j][i] = ((Rs >> (8 - Rbit)) << Rsft) | ((Gs >> (8 - Gbit)) << Gsft) | ((Bs >> (8 - Bbit)) << Bsft); + } + } + } + + // ビットä½ç½®ã®å–å¾— + static void GetBitMask(uint val, ref int shift, ref int bits) + { + shift = 0; + while (((val & (1 << shift)) == 0) && (shift < 32)) + { + shift++; + } + + bits = 32; + while (((val & (1 << (bits - 1))) == 0) && (bits > 0)) + { + bits--; + } + bits = bits - shift; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfoSorter.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/PaletteDefine.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfoSorter.cs.meta rename to AxibugEmuOnline.Client/Assets/Script/NesEmulator/PaletteDefine.cs.meta index 8278d2a..d93c9c2 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/BankInfoSorter.cs.meta +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/PaletteDefine.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2d41e03bf8974044fadc0b1cbcf7811e +guid: bbd3f54279eb4ae45831a914b13d1cec MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs new file mode 100644 index 0000000..70abda6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs @@ -0,0 +1,67 @@ +using AxibugEmuOnline.Client.Assets.Script.NesEmulator; +using System; +using System.Runtime.InteropServices; +using UnityEngine; +using UnityEngine.UI; +using VirtualNes.Core; + +namespace AxibugEmuOnline.Client +{ + public class VideoProvider : MonoBehaviour + { + public RawImage Image; + + private UInt32[] wrapTexBuffer; + private IntPtr wrapTexBufferPointer; + private Texture2D wrapTex; + private int TexBufferSize; + + private uint[] pPal; + public void SetDrawData(byte[] screenData, byte[] lineColorMode, int screenWidth, int screenHeight) + { + if (wrapTex == null) + { + wrapTex = new Texture2D(screenWidth, screenHeight, TextureFormat.BGRA32, false); + wrapTexBuffer = new UInt32[screenWidth * screenHeight]; + // ¹Ì¶¨Êý×飬·ÀÖ¹À¬»ø»ØÊÕÆ÷Òƶ¯Ëü + GCHandle handle = GCHandle.Alloc(wrapTexBuffer, GCHandleType.Pinned); + // »ñÈ¡Êý×éµÄÖ¸Õë + wrapTexBufferPointer = handle.AddrOfPinnedObject(); + + Image.texture = wrapTex; + pPal = PaletteDefine.m_cnPalette[0]; + + TexBufferSize = wrapTexBuffer.Length * 4; + } + + int pScn = 0; + int width; + + var Dst = wrapTexBuffer; + var pDst = 0; + + for (int line = 0; line < screenHeight; line++) + { + width = screenWidth; + + while (width > 0) + { + var edx = screenData[pScn + 8]; + + int index = edx & 0xFF; + var colorData = pPal[index]; + Dst[pDst] = 0xFF000000 | colorData; + + pScn += 1; + pDst += 1; + width -= 1; + } + + pScn += 16;// PPU.SCREEN_WIDTH - screenWidth; + } + + wrapTex.LoadRawTextureData(wrapTexBufferPointer, TexBufferSize); + wrapTex.Apply(); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs.meta b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs.meta new file mode 100644 index 0000000..a7c1dff --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 83fbe375412d1af4482ae76e81c1dda2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/RingBuffer.cs b/AxibugEmuOnline.Client/Assets/Script/RingBuffer.cs index 20f5613..2c92e49 100644 --- a/AxibugEmuOnline.Client/Assets/Script/RingBuffer.cs +++ b/AxibugEmuOnline.Client/Assets/Script/RingBuffer.cs @@ -1,4 +1,3 @@ -using System; using System.Threading; public class RingBuffer diff --git a/AxibugEmuOnline.Client/Assets/Script/SoundBuffer.cs b/AxibugEmuOnline.Client/Assets/Script/SoundBuffer.cs new file mode 100644 index 0000000..b647384 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/SoundBuffer.cs @@ -0,0 +1,11 @@ +using VirtualNes.Core; + +public class SoundBuffer : RingBuffer, ISoundDataBuffer +{ + public SoundBuffer(int capacity) : base(capacity) { } + + public void WriteByte(byte value) + { + Write(value); + } +} diff --git a/AxibugEmuOnline.Client/Assets/Script/SoundBuffer.cs.meta b/AxibugEmuOnline.Client/Assets/Script/SoundBuffer.cs.meta new file mode 100644 index 0000000..128c170 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/SoundBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5f491c577bed63478340426f7698563 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets.meta similarity index 77% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib.meta rename to AxibugEmuOnline.Client/Assets/StreamingAssets.meta index 05c18cf..a8658aa 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/ComponentAce.Compression.Libs.zlib.meta +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d8b8249d0e1fe314787bfc6d8a22318f +guid: 353264361911f2f43bb2c088c7e73fec folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Disksys.rom b/AxibugEmuOnline.Client/Assets/StreamingAssets/Disksys.rom new file mode 100644 index 0000000..93a8d93 Binary files /dev/null and b/AxibugEmuOnline.Client/Assets/StreamingAssets/Disksys.rom differ diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Disksys.rom.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Disksys.rom.meta new file mode 100644 index 0000000..bfab4b0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets/Disksys.rom.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 588a6a32c9d46b943b4909b1757f4572 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms.meta similarity index 100% rename from AxibugEmuOnline.Client/Assets/Resources/Roms.meta rename to AxibugEmuOnline.Client/Assets/StreamingAssets/Roms.meta diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms/Kirby.nes.bytes b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Kirby.nes similarity index 100% rename from AxibugEmuOnline.Client/Assets/Resources/Roms/Kirby.nes.bytes rename to AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Kirby.nes diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Kirby.nes.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Kirby.nes.meta new file mode 100644 index 0000000..803c960 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Kirby.nes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 41cd7684d8de61f4499c3aa27a6c5b3a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms/Mario.nes.bytes b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Mario.nes similarity index 100% rename from AxibugEmuOnline.Client/Assets/Resources/Roms/Mario.nes.bytes rename to AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Mario.nes diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Mario.nes.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Mario.nes.meta new file mode 100644 index 0000000..66eb8f2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/Mario.nes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 50dfce75937af2a44bafd221a0163501 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/ff1.NES b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/ff1.NES new file mode 100644 index 0000000..1665b6d Binary files /dev/null and b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/ff1.NES differ diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/ff1.NES.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/ff1.NES.meta new file mode 100644 index 0000000..2681206 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/ff1.NES.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 091b4306faaa8fc4084836c5237b76c8 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Roms/tortoise4.nes.bytes b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tortoise4.nes similarity index 100% rename from AxibugEmuOnline.Client/Assets/Resources/Roms/tortoise4.nes.bytes rename to AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tortoise4.nes diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tortoise4.nes.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tortoise4.nes.meta new file mode 100644 index 0000000..206dbb7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tortoise4.nes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7abf09a3e3fd84648852e5d972dfd260 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tstd2.nes b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tstd2.nes new file mode 100644 index 0000000..68461fd Binary files /dev/null and b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tstd2.nes differ diff --git a/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tstd2.nes.meta b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tstd2.nes.meta new file mode 100644 index 0000000..0d85e01 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/StreamingAssets/Roms/tstd2.nes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0fcf57d6e248ead4a874daa51181ec5f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core.meta similarity index 77% rename from AxibugEmuOnline.Client/Assets/Resources/NesCoreRes.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core.meta index 8030677..e529317 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/NesCoreRes.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e2c2fc792e914ba4da5671edcb233994 +guid: 2c5bcc6d5df67f04d93e0ab812c36b4e folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/APU.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/APU.cs new file mode 100644 index 0000000..1558bf2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/APU.cs @@ -0,0 +1,550 @@ +using Codice.CM.Client.Differences; +using System; +using System.IO; +using System.Security.Principal; +using UnityEngine; +using VirtualNes.Core; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class APU + { + public const uint QUEUE_LENGTH = 8192; + + // Volume adjust + // Internal sounds + public const uint RECTANGLE_VOL = 0x0F0; + public const uint TRIANGLE_VOL = 0x130; + public const uint NOISE_VOL = 0x0C0; + public const uint DPCM_VOL = 0x0F0; + // Extra sounds + public const uint VRC6_VOL = 0x0F0; + public const uint VRC7_VOL = 0x130; + public const uint FDS_VOL = 0x0F0; + public const uint MMC5_VOL = 0x0F0; + public const uint N106_VOL = 0x088; + public const uint FME7_VOL = 0x130; + + private NES nes; + private byte exsound_select; + private APU_INTERNAL @internal = new APU_INTERNAL(); + private APU_VRC6 vrc6 = new APU_VRC6(); + private APU_VRC7 vrc7 = new APU_VRC7(); + private APU_MMC5 mmc5 = new APU_MMC5(); + private APU_FDS fds = new APU_FDS(); + private APU_N106 n106 = new APU_N106(); + private APU_FME7 fme7 = new APU_FME7(); + private int last_data; + private int last_diff; + protected short[] m_SoundBuffer = new short[256]; + protected int[] lowpass_filter = new int[4]; + protected QUEUE queue = new QUEUE(); + protected QUEUE exqueue = new QUEUE(); + protected bool[] m_bMute = new bool[16]; + protected double elapsed_time; + + public APU(NES parent) + { + exsound_select = 0; + + nes = parent; + @internal.SetParent(parent); + + last_data = last_diff = 0; + + Array.Clear(m_SoundBuffer, 0, m_SoundBuffer.Length); + Array.Clear(lowpass_filter, 0, lowpass_filter.Length); + + for (int i = 0; i < m_bMute.Length; i++) + m_bMute[i] = true; + } + + public void Dispose() { } + + private int[] vol = new int[24]; + static double cutofftemp = (2.0 * 3.141592653579 * 40.0); + static double tmp = 0.0; + + public void Process(ISoundDataBuffer lpBuffer, uint dwSize) + { + int nBits = Supporter.Config.sound.nBits; + uint dwLength = (uint)(dwSize / (nBits / 8)); + int output; + QUEUEDATA q = default; + uint writetime; + + var pSoundBuf = m_SoundBuffer; + int nCcount = 0; + + int nFilterType = Supporter.Config.sound.nFilterType; + + if (!Supporter.Config.sound.bEnable) + { + byte empty = (byte)(Supporter.Config.sound.nRate == 8 ? 128 : 0); + for (int i = 0; i < dwSize; i++) + lpBuffer.WriteByte(empty); + return; + } + + // Volume setup + // 0:Master + // 1:Rectangle 1 + // 2:Rectangle 2 + // 3:Triangle + // 4:Noise + // 5:DPCM + // 6:VRC6 + // 7:VRC7 + // 8:FDS + // 9:MMC5 + // 10:N106 + // 11:FME7 + MemoryUtility.ZEROMEMORY(vol, vol.Length); + + var bMute = m_bMute; + var nVolume = Supporter.Config.sound.nVolume; + + int nMasterVolume = bMute[0] ? nVolume[0] : 0; + + // Internal + vol[0] = (int)(bMute[1] ? (RECTANGLE_VOL * nVolume[1] * nMasterVolume) / (100 * 100) : 0); + vol[1] = (int)(bMute[2] ? (RECTANGLE_VOL * nVolume[2] * nMasterVolume) / (100 * 100) : 0); + vol[2] = (int)(bMute[3] ? (TRIANGLE_VOL * nVolume[3] * nMasterVolume) / (100 * 100) : 0); + vol[3] = (int)(bMute[4] ? (NOISE_VOL * nVolume[4] * nMasterVolume) / (100 * 100) : 0); + vol[4] = (int)(bMute[5] ? (DPCM_VOL * nVolume[5] * nMasterVolume) / (100 * 100) : 0); + + // VRC6 + vol[5] = (int)(bMute[6] ? (VRC6_VOL * nVolume[6] * nMasterVolume) / (100 * 100) : 0); + vol[6] = (int)(bMute[7] ? (VRC6_VOL * nVolume[6] * nMasterVolume) / (100 * 100) : 0); + vol[7] = (int)(bMute[8] ? (VRC6_VOL * nVolume[6] * nMasterVolume) / (100 * 100) : 0); + + // VRC7 + vol[8] = (int)(bMute[6] ? (VRC7_VOL * nVolume[7] * nMasterVolume) / (100 * 100) : 0); + + // FDS + vol[9] = (int)(bMute[6] ? (FDS_VOL * nVolume[8] * nMasterVolume) / (100 * 100) : 0); + + // MMC5 + vol[10] = (int)(bMute[6] ? (MMC5_VOL * nVolume[9] * nMasterVolume) / (100 * 100) : 0); + vol[11] = (int)(bMute[7] ? (MMC5_VOL * nVolume[9] * nMasterVolume) / (100 * 100) : 0); + vol[12] = (int)(bMute[8] ? (MMC5_VOL * nVolume[9] * nMasterVolume) / (100 * 100) : 0); + + // N106 + vol[13] = (int)(bMute[6] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[14] = (int)(bMute[7] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[15] = (int)(bMute[8] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[16] = (int)(bMute[9] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[17] = (int)(bMute[10] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[18] = (int)(bMute[11] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[19] = (int)(bMute[12] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + vol[20] = (int)(bMute[13] ? (N106_VOL * nVolume[10] * nMasterVolume) / (100 * 100) : 0); + + // FME7 + vol[21] = (int)(bMute[6] ? (FME7_VOL * nVolume[11] * nMasterVolume) / (100 * 100) : 0); + vol[22] = (int)(bMute[7] ? (FME7_VOL * nVolume[11] * nMasterVolume) / (100 * 100) : 0); + vol[23] = (int)(bMute[8] ? (FME7_VOL * nVolume[11] * nMasterVolume) / (100 * 100) : 0); + + // double cycle_rate = ((double)FRAME_CYCLES*60.0/12.0)/(double)Config.sound.nRate; + double cycle_rate = (nes.nescfg.FrameCycles * 60.0 / 12.0) / Supporter.Config.sound.nRate; + + // CPUサイクル数ãŒãƒ«ãƒ¼ãƒ—ã—ã¦ã—ã¾ã£ãŸæ™‚ã®å¯¾ç­–å‡¦ç† + if (elapsed_time > nes.cpu.GetTotalCycles()) + { + QueueFlush(); + } + + while ((dwLength--) != 0) + { + writetime = (uint)elapsed_time; + + while (GetQueue((int)writetime, ref q)) + { + WriteProcess(q.addr, q.data); + } + + while (GetExQueue((int)writetime, ref q)) + { + WriteExProcess(q.addr, q.data); + } + + // 0-4:internal 5-7:VRC6 8:VRC7 9:FDS 10-12:MMC5 13-20:N106 21-23:FME7 + output = 0; + output += @internal.Process(0) * vol[0]; + output += @internal.Process(1) * vol[1]; + output += @internal.Process(2) * vol[2]; + output += @internal.Process(3) * vol[3]; + output += @internal.Process(4) * vol[4]; + + if ((exsound_select & 0x01) != 0) + { + output += vrc6.Process(0) * vol[5]; + output += vrc6.Process(1) * vol[6]; + output += vrc6.Process(2) * vol[7]; + } + if ((exsound_select & 0x02) != 0) + { + output += vrc7.Process(0) * vol[8]; + } + if ((exsound_select & 0x04) != 0) + { + output += fds.Process(0) * vol[9]; + } + if ((exsound_select & 0x08) != 0) + { + output += mmc5.Process(0) * vol[10]; + output += mmc5.Process(1) * vol[11]; + output += mmc5.Process(2) * vol[12]; + } + if ((exsound_select & 0x10) != 0) + { + output += n106.Process(0) * vol[13]; + output += n106.Process(1) * vol[14]; + output += n106.Process(2) * vol[15]; + output += n106.Process(3) * vol[16]; + output += n106.Process(4) * vol[17]; + output += n106.Process(5) * vol[18]; + output += n106.Process(6) * vol[19]; + output += n106.Process(7) * vol[20]; + } + if ((exsound_select & 0x20) != 0) + { + fme7.Process(3); // Envelope & Noise + output += fme7.Process(0) * vol[21]; + output += fme7.Process(1) * vol[22]; + output += fme7.Process(2) * vol[23]; + } + + output >>= 8; + + if (nFilterType == 1) + { + //ローパスフィルターTYPE 1(Simple) + output = (lowpass_filter[0] + output) / 2; + lowpass_filter[0] = output; + } + else if (nFilterType == 2) + { + //ローパスフィルターTYPE 2(Weighted type 1) + output = (lowpass_filter[1] + lowpass_filter[0] + output) / 3; + lowpass_filter[1] = lowpass_filter[0]; + lowpass_filter[0] = output; + } + else if (nFilterType == 3) + { + //ローパスフィルターTYPE 3(Weighted type 2) + output = (lowpass_filter[2] + lowpass_filter[1] + lowpass_filter[0] + output) / 4; + lowpass_filter[2] = lowpass_filter[1]; + lowpass_filter[1] = lowpass_filter[0]; + lowpass_filter[0] = output; + } + else if (nFilterType == 4) + { + //ローパスフィルターTYPE 4(Weighted type 3) + output = (lowpass_filter[1] + lowpass_filter[0] * 2 + output) / 4; + lowpass_filter[1] = lowpass_filter[0]; + lowpass_filter[0] = output; + } + // DCæˆåˆ†ã®ã‚«ãƒƒãƒˆ(HPF TEST) + { + // static double cutoff = (2.0*3.141592653579*40.0/44100.0); + double cutoff = cutofftemp / Supporter.Config.sound.nRate; + double @in, @out; + + @in = output; + @out = (@in - tmp); + tmp = tmp + cutoff * @out; + + output = (int)@out; + } + + // Limit + if (output > 0x7FFF) + { + output = 0x7FFF; + } + else if (output < -0x8000) + { + output = -0x8000; + } + + if (nBits != 8) + { + byte highByte = (byte)(output >> 8); // 获å–高8ä½ + byte lowByte = (byte)(output & 0xFF); // 获å–低8ä½ + lpBuffer.WriteByte(highByte); + lpBuffer.WriteByte(lowByte); + } + else + { + lpBuffer.WriteByte((byte)((output >> 8) ^ 0x80)); + } + + if (nCcount < 0x0100) + pSoundBuf[nCcount++] = (short)output; + + // elapsedtime += cycle_rate; + elapsed_time += cycle_rate; + } + + + if (elapsed_time > ((nes.nescfg.FrameCycles / 24) + nes.cpu.GetTotalCycles())) + { + elapsed_time = nes.cpu.GetTotalCycles(); + } + if ((elapsed_time + (nes.nescfg.FrameCycles / 6)) < nes.cpu.GetTotalCycles()) + { + elapsed_time = nes.cpu.GetTotalCycles(); + } + } + + private bool GetExQueue(int writetime, ref QUEUEDATA ret) + { + if (exqueue.wrptr == exqueue.rdptr) + { + return false; + } + if (exqueue.data[exqueue.rdptr].time <= writetime) + { + ret = exqueue.data[exqueue.rdptr]; + exqueue.rdptr++; + exqueue.rdptr = (int)(exqueue.rdptr & (QUEUE_LENGTH - 1)); + return true; + } + return false; + } + + private void QueueFlush() + { + while (queue.wrptr != queue.rdptr) + { + WriteProcess(queue.data[queue.rdptr].addr, queue.data[queue.rdptr].data); + queue.rdptr++; + queue.rdptr = (int)(queue.rdptr & (QUEUE_LENGTH - 1)); + } + + while (exqueue.wrptr != exqueue.rdptr) + { + WriteExProcess(exqueue.data[exqueue.rdptr].addr, exqueue.data[exqueue.rdptr].data); + exqueue.rdptr++; + exqueue.rdptr = (int)(exqueue.rdptr & (QUEUE_LENGTH - 1)); + } + } + + private void WriteExProcess(ushort addr, byte data) + { + if ((exsound_select & 0x01) != 0) + { + vrc6.Write(addr, data); + } + if ((exsound_select & 0x02) != 0) + { + vrc7.Write(addr, data); + } + if ((exsound_select & 0x04) != 0) + { + fds.Write(addr, data); + } + if ((exsound_select & 0x08) != 0) + { + mmc5.Write(addr, data); + } + if ((exsound_select & 0x10) != 0) + { + if (addr == 0x0000) + { + byte dummy = n106.Read(addr); + } + else + { + n106.Write(addr, data); + } + } + if ((exsound_select & 0x20) != 0) + { + fme7.Write(addr, data); + } + } + + private void WriteProcess(ushort addr, byte data) + { + // $4018ã¯VirtuaNES固有ãƒãƒ¼ãƒˆ + if (addr >= 0x4000 && addr <= 0x401F) + { + @internal.Write(addr, data); + } + } + + internal void SyncDPCM(int cycles) + { + @internal.Sync(cycles); + } + + internal byte Read(ushort addr) + { + return @internal.SyncRead(addr); + } + + internal void Write(ushort addr, byte data) + { + // $4018å¼VirtuaNES屌桳億乕僩 + if (addr >= 0x4000 && addr <= 0x401F) + { + @internal.SyncWrite(addr, data); + SetQueue(nes.cpu.GetTotalCycles(), addr, data); + } + } + + private void SetQueue(int writetime, ushort addr, byte data) + { + queue.data[queue.wrptr].time = writetime; + queue.data[queue.wrptr].addr = addr; + queue.data[queue.wrptr].data = data; + queue.wrptr++; + + var newwrptr = (int)(queue.wrptr & (QUEUE_LENGTH - 1)); + queue.wrptr = newwrptr; + + if (queue.wrptr == queue.rdptr) + { + Debuger.LogError("queue overflow."); + } + } + + private bool GetQueue(int writetime, ref QUEUEDATA ret) + { + if (queue.wrptr == queue.rdptr) + { + return false; + } + if (queue.data[queue.rdptr].time <= writetime) + { + ret = queue.data[queue.rdptr]; + queue.rdptr++; + var newrdptr = (int)(queue.rdptr & (QUEUE_LENGTH - 1)); + queue.rdptr = newrdptr; + return true; + } + return false; + } + + public void SoundSetup() + { + float fClock = nes.nescfg.CpuClock; + int nRate = Supporter.Config.sound.nRate; + + @internal.Setup(fClock, nRate); + vrc6.Setup(fClock, nRate); + vrc7.Setup(fClock, nRate); + mmc5.Setup(fClock, nRate); + fds.Setup(fClock, nRate); + n106.Setup(fClock, nRate); + fme7.Setup(fClock, nRate); + } + + internal void SelectExSound(byte data) + { + exsound_select = data; + } + + internal void Reset() + { + queue = new QUEUE(); + exqueue = new QUEUE(); + + elapsed_time = 0; + + float fClock = nes.nescfg.CpuClock; + int nRate = Supporter.Config.sound.nRate; + + @internal.Reset(fClock, nRate); + vrc6.Reset(fClock, nRate); + vrc7.Reset(fClock, nRate); + mmc5.Reset(fClock, nRate); + fds.Reset(fClock, nRate); + n106.Reset(fClock, nRate); + fme7.Reset(fClock, nRate); + + SoundSetup(); + } + + internal void ExWrite(ushort addr, byte data) + { + SetExQueue(nes.cpu.GetTotalCycles(), addr, data); + + if ((exsound_select & 0x04) != 0) + { + if (addr >= 0x4040 && addr < 0x4100) + { + fds.SyncWrite(addr, data); + } + } + + if ((exsound_select & 0x08) != 0) + { + if (addr >= 0x5000 && addr <= 0x5015) + { + mmc5.SyncWrite(addr, data); + } + } + } + + private void SetExQueue(int writetime, ushort addr, byte data) + { + exqueue.data[exqueue.wrptr].time = writetime; + exqueue.data[exqueue.wrptr].addr = addr; + exqueue.data[exqueue.wrptr].data = data; + exqueue.wrptr++; + var temp = QUEUE_LENGTH - 1; + exqueue.wrptr = (int)(exqueue.wrptr & temp); + if (exqueue.wrptr == exqueue.rdptr) + { + Debuger.LogError("exqueue overflow."); + } + } + + internal byte ExRead(ushort addr) + { + byte data = 0; + + if ((exsound_select & 0x10) != 0) + { + if (addr == 0x4800) + { + SetExQueue(nes.cpu.GetTotalCycles(), 0, 0); + } + } + if ((exsound_select & 0x04) != 0) + { + if (addr >= 0x4040 && addr < 0x4100) + { + data = fds.SyncRead(addr); + } + } + if ((exsound_select & 0x08) != 0) + { + if (addr >= 0x5000 && addr <= 0x5015) + { + data = mmc5.SyncRead(addr); + } + } + + return data; + } + } + + public struct QUEUEDATA + { + public int time; + public ushort addr; + public byte data; + public byte reserved; + } + + public class QUEUE + { + public int rdptr; + public int wrptr; + public QUEUEDATA[] data = new QUEUEDATA[8192]; + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/APU.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/APU.cs.meta new file mode 100644 index 0000000..220749a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/APU.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cb5a8e579d35b9a4ca7966225235265a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX.meta similarity index 77% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Support.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX.meta index a57e788..1ce615d 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Support.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f2c1e2b9170060a4081ad7befba87bc0 +guid: e6179c4bc7e6fa744901b21b63e98aba folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs new file mode 100644 index 0000000..7cdea83 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs @@ -0,0 +1,99 @@ +using System; + +namespace VirtualNes.Core +{ + public class APU_FDS : APU_INTERFACE + { + private FDSSOUND fds = new FDSSOUND(); + private FDSSOUND fds_sync = new FDSSOUND(); + + public override void Reset(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Setup(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Write(ushort addr, byte data) + { + //todo : 实现 + } + + public override int Process(int channel) + { + //todo : 实现 + return 0; + } + + internal void SyncWrite(ushort addr, byte data) + { + WriteSub(addr, data, fds_sync, 1789772.5d); + } + + private void WriteSub(ushort addr, byte data, FDSSOUND ch, double rate) + { + //todo : 实现 + } + + internal byte SyncRead(ushort addr) + { + byte data = (byte)(addr >> 8); + + if (addr >= 0x4040 && addr <= 0x407F) + { + data = (byte)(fds_sync.main_wavetable[addr & 0x3F] | 0x40); + } + else + if (addr == 0x4090) + { + data = (byte)((fds_sync.volenv_gain & 0x3F) | 0x40); + } + else + if (addr == 0x4092) + { + data = (byte)((fds_sync.swpenv_gain & 0x3F) | 0x40); + } + + return data; + } + + private class FDSSOUND + { + public byte[] reg = new byte[0x80]; + public byte volenv_mode; // Volume Envelope + public byte volenv_gain; + public byte volenv_decay; + public double volenv_phaseacc; + public byte swpenv_mode; // Sweep Envelope + public byte swpenv_gain; + public byte swpenv_decay; + public double swpenv_phaseacc; + // For envelope unit + public byte envelope_enable; // $4083 bit6 + public byte envelope_speed; // $408A + // For $4089 + public byte wave_setup; // bit7 + public int master_volume; // bit1-0 + // For Main unit + public int[] main_wavetable = new int[64]; + public byte main_enable; + public int main_frequency; + public int main_addr; + // For Effector(LFO) unit + public byte[] lfo_wavetable = new byte[64]; + public byte lfo_enable; // 0:Enable 1:Wavetable setup + public int lfo_frequency; + public int lfo_addr; + public double lfo_phaseacc; + // For Sweep unit + public int sweep_bias; + // Misc + public int now_volume; + public int now_freq; + public int output; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs.meta new file mode 100644 index 0000000..5580ec2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5e16912525198924a860e53ab4ef0c81 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FME7.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FME7.cs new file mode 100644 index 0000000..2871744 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FME7.cs @@ -0,0 +1,28 @@ +using System; + +namespace VirtualNes.Core +{ + public class APU_FME7 : APU_INTERFACE + { + public override void Reset(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Setup(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Write(ushort addr, byte data) + { + //todo : 实现 + } + + public override int Process(int channel) + { + //todo : 实现 + return 0; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FME7.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FME7.cs.meta new file mode 100644 index 0000000..4edc65e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FME7.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 03e0258857a7134438a497aec27ea607 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERFACE.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERFACE.cs new file mode 100644 index 0000000..b4ff65f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERFACE.cs @@ -0,0 +1,36 @@ +namespace VirtualNes.Core +{ + public abstract class APU_INTERFACE + { + public const float APU_CLOCK = 1789772.5f; + + public virtual void Dispose() { } + + public abstract void Reset(float fClock, int nRate); + public abstract void Setup(float fClock, int nRate); + public abstract void Write(ushort addr, byte data); + public abstract int Process(int channel); + public virtual byte Read(ushort addr) + { + return (byte)(addr >> 8); + } + public virtual void WriteSync(ushort addr, byte data) { } + public virtual byte ReadSync(ushort addr) { return 0; } + public virtual void VSync() { } + public virtual bool Sync(int cycles) { return false; } + public virtual int GetFreq(int channel) { return 0; } + public virtual int GetStateSize() { return 0; } + public virtual void SaveState(byte[] p) { } + public virtual void LoadState(byte[] p) { } + + public static int INT2FIX(int x) + { + return x << 16; + } + + public static int FIX2INT(int x) + { + return x >> 16; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERFACE.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERFACE.cs.meta new file mode 100644 index 0000000..fdd8b0c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERFACE.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cc44be42b66d6ac4aade437e81960274 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERNAL.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERNAL.cs new file mode 100644 index 0000000..49ad681 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERNAL.cs @@ -0,0 +1,1196 @@ +using Codice.CM.Client.Differences; +using System; +using System.Runtime.CompilerServices; +using UnityEngine; + +namespace VirtualNes.Core +{ + public class APU_INTERNAL : APU_INTERFACE + { + // Volume shift + public const int RECTANGLE_VOL_SHIFT = 8; + public const int TRIANGLE_VOL_SHIFT = 9; + public const int NOISE_VOL_SHIFT = 8; + public const int DPCM_VOL_SHIFT = 8; + + // Tables + static public int[] freq_limit = new int[8] + { + 0x03FF, 0x0555, 0x0666, 0x071C, 0x0787, 0x07C1, 0x07E0, 0x07F0 + }; + static public int[] duty_lut = new int[4] + { + 2, 4, 8, 12 + }; + static public int[] noise_freq = new int[16]{ + 4, 8, 16, 32, 64, 96, 128, 160, + 202, 254, 380, 508, 762, 1016, 2034, 4068 + }; + + private static int[] vbl_length = new int[32] + { + 5, 127, 10, 1, 19, 2, 40, 3, + 80, 4, 30, 5, 7, 6, 13, 7, + 6, 8, 12, 9, 24, 10, 48, 11, + 96, 12, 36, 13, 8, 14, 16, 15, + }; + + private static int[] dpcm_cycles_pal = new int[16] + { + 397, 353, 315, 297, 265, 235, 209, 198, + 176, 148, 131, 118, 98, 78, 66, 50, + }; + + private static int[] dpcm_cycles = new int[16] + { + 428, 380, 340, 320, 286, 254, 226, 214, + 190, 160, 142, 128, 106, 85, 72, 54, + }; + + private NES nes; + // Frame Counter + private int FrameCycle; + private int FrameCount; + private int FrameType; + private byte FrameIRQ; + private byte FrameIRQoccur; + + // Channels + private RECTANGLE ch0 = new RECTANGLE(); + private RECTANGLE ch1 = new RECTANGLE(); + private TRIANGLE ch2 = new TRIANGLE(); + private NOISE ch3 = new NOISE(); + private DPCM ch4 = new DPCM(); + + // Sound + private float cpu_clock; + private int sampling_rate; + private int cycle_rate; + + // $4015 Reg + private byte reg4015, sync_reg4015; + + private const int TONEDATA_MAX = 16; + private const int TONEDATA_LEN = 32; + private const int CHANNEL_MAX = 3; + private const int TONE_MAX = 4; + + bool[] bToneTableEnable = new bool[TONEDATA_MAX]; + int[,] ToneTable = new int[TONEDATA_MAX, TONEDATA_LEN]; + int[,] ChannelTone = new int[CHANNEL_MAX, TONE_MAX]; + + public void SetParent(NES parent) + { + nes = parent; + } + + public override bool Sync(int cycles) + { + FrameCycle -= cycles * 2; + if (FrameCycle <= 0) + { + FrameCycle += 14915; + + UpdateFrame(); + } + + var result = FrameIRQoccur | (SyncUpdateDPCM(cycles) ? 1 : 0); + return result != 0; + } + + private bool SyncUpdateDPCM(int cycles) + { + bool bIRQ = false; + + if (ch4.sync_enable != 0) + { + ch4.sync_cycles -= cycles; + while (ch4.sync_cycles < 0) + { + ch4.sync_cycles += ch4.sync_cache_cycles; + if (ch4.sync_dmalength != 0) + { + // if( !(--ch4.sync_dmalength) ) { + if (--ch4.sync_dmalength < 2) + { + if (ch4.sync_looping != 0) + { + ch4.sync_dmalength = ch4.sync_cache_dmalength; + } + else + { + ch4.sync_dmalength = 0; + + if (ch4.sync_irq_gen != 0) + { + ch4.sync_irq_enable = 0xFF; + nes.cpu.SetIRQ(CPU.IRQ_DPCM); + } + } + } + } + } + } + if (ch4.sync_irq_enable != 0) + { + bIRQ = true; + } + + return bIRQ; + } + + private void UpdateFrame() + { + if (FrameCount == 0) + { + if ((FrameIRQ & 0xC0) == 0 && nes.GetFrameIRQmode()) + { + FrameIRQoccur = 0xFF; + nes.cpu.SetIRQ(CPU.IRQ_FRAMEIRQ); + } + } + + if (FrameCount == 3) + { + if ((FrameIRQ & 0x80) != 0) + { + FrameCycle += 14915; + } + } + + // Counters Update + nes.Write(0x4018, (byte)FrameCount); + + FrameCount = (FrameCount + 1) & 3; + } + + public override void Reset(float fClock, int nRate) + { + ch0.ZeroMemory(); + ch1.ZeroMemory(); + ch2.ZeroMemory(); + ch3.ZeroMemory(); + + Array.Clear(bToneTableEnable, 0, bToneTableEnable.Length); + Array.Clear(ToneTable, 0, ToneTable.Length); + Array.Clear(ChannelTone, 0, ChannelTone.Length); + + reg4015 = sync_reg4015 = 0; + + // Sweep complement + ch0.complement = 0x00; + ch1.complement = 0xFF; + + // Noise shift register + ch3.shift_reg = 0x4000; + + Setup(fClock, nRate); + + // $4011¤Ï³õÆÚ»¯¤·¤Ê¤¤ + ushort addr; + for (addr = 0x4000; addr <= 0x4010; addr++) + { + Write(addr, 0x00); + SyncWrite(addr, 0x00); + } + // Write( 0x4001, 0x08 ); // Reset•r¤Ïinc¥â©`¥É¤Ë¤Ê¤ë? + // Write( 0x4005, 0x08 ); // Reset•r¤Ïinc¥â©`¥É¤Ë¤Ê¤ë? + Write(0x4012, 0x00); + Write(0x4013, 0x00); + Write(0x4015, 0x00); + SyncWrite(0x4012, 0x00); + SyncWrite(0x4013, 0x00); + SyncWrite(0x4015, 0x00); + + // $4017¤Ï•ø¤­Þz¤ß¤Ç³õÆÚ»¯¤·¤Ê¤¤(³õÆÚ¥â©`¥É¤¬0¤Ç¤¢¤ë¤Î¤òÆÚ´ý¤·¤¿¥½¥Õ¥È¤¬¤¢¤ëžé) + FrameIRQ = 0xC0; + FrameCycle = 0; + FrameIRQoccur = 0; + FrameCount = 0; + FrameType = 0; + } + + public override void Setup(float fClock, int nRate) + { + cpu_clock = fClock; + sampling_rate = nRate; + + cycle_rate = (int)(fClock * 65536.0f / nRate); + } + + public override void Write(ushort addr, byte data) + { + switch (addr) + { + // CH0,1 rectangle + case 0x4000: + case 0x4001: + case 0x4002: + case 0x4003: + case 0x4004: + case 0x4005: + case 0x4006: + case 0x4007: + WriteRectangle((addr < 0x4004) ? 0 : 1, addr, data); + break; + + // CH2 triangle + case 0x4008: + case 0x4009: + case 0x400A: + case 0x400B: + WriteTriangle(addr, data); + break; + + // CH3 noise + case 0x400C: + case 0x400D: + case 0x400E: + case 0x400F: + WriteNoise(addr, data); + break; + + // CH4 DPCM + case 0x4010: + case 0x4011: + case 0x4012: + case 0x4013: + WriteDPCM(addr, data); + break; + + case 0x4015: + reg4015 = data; + + if ((data & (1 << 0)) == 0) + { + ch0.enable = 0; + ch0.len_count = 0; + } + if ((data & (1 << 1)) == 0) + { + ch1.enable = 0; + ch1.len_count = 0; + } + if ((data & (1 << 2)) == 0) + { + ch2.enable = 0; + ch2.len_count = 0; + ch2.lin_count = 0; + ch2.counter_start = 0; + } + if ((data & (1 << 3)) == 0) + { + ch3.enable = 0; + ch3.len_count = 0; + } + if ((data & (1 << 4)) == 0) + { + ch4.enable = 0; + ch4.dmalength = 0; + } + else + { + ch4.enable = 0xFF; + if (ch4.dmalength == 0) + { + ch4.address = ch4.cache_addr; + ch4.dmalength = ch4.cache_dmalength; + ch4.phaseacc = 0; + } + } + break; + + case 0x4017: + break; + + // VirtuaNES¹ÌÓХݩ`¥È + case 0x4018: + UpdateRectangle(ch0, data); + UpdateRectangle(ch1, data); + UpdateTriangle(data); + UpdateNoise(data); + break; + + default: + break; + } + } + + private void UpdateNoise(int type) + { + if (ch3.enable == 0 || ch3.len_count <= 0) + return; + + // Update Length + if (ch3.holdnote == 0) + { + // Holdnote + if ((type & 1) == 0 && ch3.len_count != 0) + { + ch3.len_count--; + } + } + + // Update Envelope + if (ch3.env_count != 0) + { + ch3.env_count--; + } + if (ch3.env_count == 0) + { + ch3.env_count = ch3.env_decay; + + // Holdnote + if (ch3.holdnote != 0) + { + ch3.env_vol = (ch3.env_vol - 1) & 0x0F; + } + else if (ch3.env_vol != 0) + { + ch3.env_vol--; + } + } + + if (ch3.env_fixed == 0) + { + ch3.nowvolume = ch3.env_vol << RECTANGLE_VOL_SHIFT; + } + } + + private void UpdateTriangle(int type) + { + if (ch2.enable == 0) + return; + + if ((type & 1) == 0 && ch2.holdnote == 0) + { + if (ch2.len_count != 0) + { + ch2.len_count--; + } + } + + // if( !ch2.len_count ) { + // ch2.lin_count = 0; + // } + + // Update Length/Linear + if (ch2.counter_start != 0) + { + ch2.lin_count = ch2.reg[0] & 0x7F; + } + else if (ch2.lin_count != 0) + { + ch2.lin_count--; + } + if (ch2.holdnote == 0 && ch2.lin_count != 0) + { + ch2.counter_start = 0; + } + } + + private void UpdateRectangle(RECTANGLE ch, int type) + { + if (ch.enable == 0 || ch.len_count <= 0) + return; + + // Update Length/Sweep + if ((type & 1) == 0) + { + // Update Length + if (ch.len_count != 0 && ch.holdnote == 0) + { + // Holdnote + if (ch.len_count != 0) + { + ch.len_count--; + } + } + + // Update Sweep + if (ch.swp_on != 0 && ch.swp_shift != 0) + { + if (ch.swp_count != 0) + { + ch.swp_count--; + } + if (ch.swp_count == 0) + { + ch.swp_count = ch.swp_decay; + if (ch.swp_inc != 0) + { + // Sweep increment(to higher frequency) + if (ch.complement == 0) + ch.freq += ~(ch.freq >> ch.swp_shift); // CH 0 + else + ch.freq -= (ch.freq >> ch.swp_shift); // CH 1 + } + else + { + // Sweep decrement(to lower frequency) + ch.freq += (ch.freq >> ch.swp_shift); + } + } + } + } + + // Update Envelope + if (ch.env_count != 0) + { + ch.env_count--; + } + if (ch.env_count == 0) + { + ch.env_count = ch.env_decay; + + // Holdnote + if (ch.holdnote != 0) + { + ch.env_vol = (ch.env_vol - 1) & 0x0F; + } + else if (ch.env_vol != 0) + { + ch.env_vol--; + } + } + + if (ch.env_fixed == 0) + { + ch.nowvolume = ch.env_vol << RECTANGLE_VOL_SHIFT; + } + } + + private void WriteDPCM(ushort addr, byte data) + { + ch4.reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch4.freq = INT2FIX(nes.GetVideoMode() ? dpcm_cycles_pal[data & 0x0F] : dpcm_cycles[data & 0x0F]); + // ch4.freq = INT2FIX( dpcm_cycles[data&0x0F] ); + //// ch4.freq = INT2FIX( (dpcm_cycles[data&0x0F]-((data&0x0F)^0x0F)*2-2) ); + ch4.looping = (byte)(data & 0x40); + break; + case 1: + ch4.dpcm_value = (byte)((data & 0x7F) >> 1); + break; + case 2: + ch4.cache_addr = (ushort)(0xC000 + (ushort)(data << 6)); + break; + case 3: + ch4.cache_dmalength = ((data << 4) + 1) << 3; + break; + } + } + + private void WriteNoise(ushort addr, byte data) + { + ch3.reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch3.holdnote = (byte)(data & 0x20); + ch3.volume = (byte)(data & 0x0F); + ch3.env_fixed = (byte)(data & 0x10); + ch3.env_decay = (byte)((data & 0x0F) + 1); + break; + case 1: // Unused + break; + case 2: + ch3.freq = INT2FIX(noise_freq[data & 0x0F]); + ch3.xor_tap = (byte)((data & 0x80) != 0 ? 0x40 : 0x02); + break; + case 3: // Master + ch3.len_count = vbl_length[data >> 3] * 2; + ch3.env_vol = 0x0F; + ch3.env_count = (byte)(ch3.env_decay + 1); + + if ((reg4015 & (1 << 3)) != 0) + ch3.enable = 0xFF; + break; + } + } + + private void WriteTriangle(ushort addr, byte data) + { + ch2.reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch2.holdnote = (byte)(data & 0x80); + break; + case 1: // Unused + break; + case 2: + ch2.freq = INT2FIX(((ch2.reg[3] & 0x07) << 8) + data + 1); + break; + case 3: // Master + ch2.freq = INT2FIX((((data & 0x07) << 8) + ch2.reg[2] + 1)); + ch2.len_count = vbl_length[data >> 3] * 2; + ch2.counter_start = 0x80; + + if ((reg4015 & (1 << 2)) != 0) + ch2.enable = 0xFF; + break; + } + } + + private void WriteRectangle(int no, ushort addr, byte data) + { + RECTANGLE ch = (no == 0) ? ch0 : ch1; + + ch.reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch.holdnote = (byte)(data & 0x20); + ch.volume = (byte)(data & 0x0F); + ch.env_fixed = (byte)(data & 0x10); + ch.env_decay = (byte)((data & 0x0F) + 1); + ch.duty = duty_lut[data >> 6]; + break; + case 1: + ch.swp_on = (byte)(data & 0x80); + ch.swp_inc = (byte)(data & 0x08); + ch.swp_shift = (byte)(data & 0x07); + ch.swp_decay = (byte)(((data >> 4) & 0x07) + 1); + ch.freqlimit = freq_limit[data & 0x07]; + break; + case 2: + ch.freq = (ch.freq & (~0xFF)) + data; + break; + case 3: // Master + ch.freq = ((data & 0x07) << 8) + (ch.freq & 0xFF); + ch.len_count = vbl_length[data >> 3] * 2; + ch.env_vol = 0x0F; + ch.env_count = (byte)(ch.env_decay + 1); + ch.adder = 0; + + if ((reg4015 & (1 << no)) != 0) + ch.enable = 0xFF; + break; + } + } + + public override int Process(int channel) + { + switch (channel) + { + case 0: + return RenderRectangle(ch0); + case 1: + return RenderRectangle(ch1); + case 2: + return RenderTriangle(); + case 3: + return RenderNoise(); + case 4: + return RenderDPCM(); + default: + return 0; + } + } + + private int RenderDPCM() + { + if (ch4.dmalength != 0) + { + ch4.phaseacc -= cycle_rate; + + while (ch4.phaseacc < 0) + { + ch4.phaseacc += ch4.freq; + if ((ch4.dmalength & 7) == 0) + { + ch4.cur_byte = nes.Read(ch4.address); + if (0xFFFF == ch4.address) + ch4.address = 0x8000; + else + ch4.address++; + } + + if ((--ch4.dmalength) == 0) + { + if (ch4.looping != 0) + { + ch4.address = ch4.cache_addr; + ch4.dmalength = ch4.cache_dmalength; + } + else + { + ch4.enable = 0; + break; + } + } + // positive delta + if ((ch4.cur_byte & (1 << ((ch4.dmalength & 7) ^ 7))) != 0) + { + if (ch4.dpcm_value < 0x3F) + ch4.dpcm_value += 1; + } + else + { + // negative delta + if (ch4.dpcm_value > 1) + ch4.dpcm_value -= 1; + } + } + } + + // ¥¤¥ó¥Á¥­³ô¤¤¥×¥Á¥Î¥¤¥º¥«¥Ã¥È(TEST) + ch4.dpcm_output_real = ((ch4.reg[1] & 0x01) + ch4.dpcm_value * 2) - 0x40; + if (Math.Abs(ch4.dpcm_output_real - ch4.dpcm_output_fake) <= 8) + { + ch4.dpcm_output_fake = ch4.dpcm_output_real; + ch4.output = ch4.dpcm_output_real << DPCM_VOL_SHIFT; + } + else + { + if (ch4.dpcm_output_real > ch4.dpcm_output_fake) + ch4.dpcm_output_fake += 8; + else + ch4.dpcm_output_fake -= 8; + ch4.output = ch4.dpcm_output_fake << DPCM_VOL_SHIFT; + } + return ch4.output; + } + + private int RenderNoise() + { + if (ch3.enable == 0 || ch3.len_count <= 0) + return 0; + + if (ch3.env_fixed != 0) + { + ch3.nowvolume = ch3.volume << RECTANGLE_VOL_SHIFT; + } + + int vol = 256 - ((ch4.reg[1] & 0x01) + ch4.dpcm_value * 2); + + ch3.phaseacc -= cycle_rate; + if (ch3.phaseacc >= 0) + return ch3.output * vol / 256; + + if (ch3.freq > cycle_rate) + { + ch3.phaseacc += ch3.freq; + if (NoiseShiftreg(ch3.xor_tap)) + ch3.output = ch3.nowvolume; + else + ch3.output = -ch3.nowvolume; + + return ch3.output * vol / 256; + } + + int num_times, total; + num_times = total = 0; + while (ch3.phaseacc < 0) + { + ch3.phaseacc += ch3.freq; + if (NoiseShiftreg(ch3.xor_tap)) + ch3.output = ch3.nowvolume; + else + ch3.output = -ch3.nowvolume; + + total += ch3.output; + num_times++; + } + + return (total / num_times) * vol / 256; + } + + private bool NoiseShiftreg(byte xor_tap) + { + int bit0, bit14; + + bit0 = ch3.shift_reg & 1; + if ((ch3.shift_reg & xor_tap) != 0) bit14 = bit0 ^ 1; + else bit14 = bit0 ^ 0; + ch3.shift_reg >>= 1; + ch3.shift_reg |= (bit14 << 14); + return (bit0 ^ 1) != 0; + } + + private int RenderTriangle() + { + int vol; + if (Supporter.Config.sound.bDisableVolumeEffect) + { + vol = 256; + } + else + { + vol = 256 - ((ch4.reg[1] & 0x01) + ch4.dpcm_value * 2); + } + + if (ch2.enable == 0 || (ch2.len_count <= 0) || (ch2.lin_count <= 0)) + { + return ch2.nowvolume * vol / 256; + } + + if (ch2.freq < INT2FIX(8)) + { + return ch2.nowvolume * vol / 256; + } + + if (!(Supporter.Config.sound.bChangeTone && ChannelTone[2, 0] != 0)) + { + ch2.phaseacc -= cycle_rate; + if (ch2.phaseacc >= 0) + { + return ch2.nowvolume * vol / 256; + } + + if (ch2.freq > cycle_rate) + { + ch2.phaseacc += ch2.freq; + ch2.adder = (ch2.adder + 1) & 0x1F; + + if (ch2.adder < 0x10) + { + ch2.nowvolume = (ch2.adder & 0x0F) << TRIANGLE_VOL_SHIFT; + } + else + { + ch2.nowvolume = (0x0F - (ch2.adder & 0x0F)) << TRIANGLE_VOL_SHIFT; + } + + return ch2.nowvolume * vol / 256; + } + + // ¼ÓÖØƽ¾ù + int num_times, total; + num_times = total = 0; + while (ch2.phaseacc < 0) + { + ch2.phaseacc += ch2.freq; + ch2.adder = (ch2.adder + 1) & 0x1F; + + if (ch2.adder < 0x10) + { + ch2.nowvolume = (ch2.adder & 0x0F) << TRIANGLE_VOL_SHIFT; + } + else + { + ch2.nowvolume = (0x0F - (ch2.adder & 0x0F)) << TRIANGLE_VOL_SHIFT; + } + + total += ch2.nowvolume; + num_times++; + } + + return (total / num_times) * vol / 256; + } + else + { + int x = ChannelTone[2, 0] - 1; + int pTone = 0; + + ch2.phaseacc -= cycle_rate; + if (ch2.phaseacc >= 0) + { + return ch2.nowvolume * vol / 256; + } + + if (ch2.freq > cycle_rate) + { + ch2.phaseacc += ch2.freq; + ch2.adder = (ch2.adder + 1) & 0x1F; + var temp = ToneTable[x, pTone + (ch2.adder & 0x1F)]; + ch2.nowvolume = temp * 0x0F; + return ch2.nowvolume * vol / 256; + } + + // ¼ÓÖØƽ¾ù + int num_times, total; + num_times = total = 0; + while (ch2.phaseacc < 0) + { + ch2.phaseacc += ch2.freq; + ch2.adder = (ch2.adder + 1) & 0x1F; + var temp = ToneTable[x, pTone + (ch2.adder & 0x1F)]; + total += temp * 0x0F; + num_times++; + } + + return (total / num_times) * vol / 256; + } + } + + private int RenderRectangle(RECTANGLE ch) + { + if (ch.enable == 0 || ch.len_count <= 0) + return 0; + + // Channel disable? + if ((ch.freq < 8) || (ch.swp_inc == 0 && ch.freq > ch.freqlimit)) + { + return 0; + } + + if (ch.env_fixed != 0) + { + ch.nowvolume = ch.volume << RECTANGLE_VOL_SHIFT; + } + int volume = ch.nowvolume; + + if (!(Supporter.Config.sound.bChangeTone && (ChannelTone[(ch.complement == 0) ? 0 : 1, ch.reg[0] >> 6]) != 0)) + { + // Ñaég„IÀí + double total; + double sample_weight = ch.phaseacc; + if (sample_weight > cycle_rate) + { + sample_weight = cycle_rate; + } + total = (ch.adder < ch.duty) ? sample_weight : -sample_weight; + + int freq = INT2FIX(ch.freq + 1); + ch.phaseacc -= cycle_rate; + while (ch.phaseacc < 0) + { + ch.phaseacc += freq; + ch.adder = (ch.adder + 1) & 0x0F; + + sample_weight = freq; + if (ch.phaseacc > 0) + { + sample_weight -= ch.phaseacc; + } + total += (ch.adder < ch.duty) ? sample_weight : -sample_weight; + } + return (int)(volume * total / cycle_rate + 0.5); + } + else + { + int x = ChannelTone[(ch.complement == 0) ? 0 : 1, ch.reg[0] >> 6] - 1; + int pTone = 0; + + // ¸üПo¤· + ch.phaseacc -= cycle_rate * 2; + if (ch.phaseacc >= 0) + { + var temp = ToneTable[x, pTone + (ch.adder & 0x1F)]; + return temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2); + } + + // 1¥¹¥Æ¥Ã¥×¤À¤±¸üР+ int freq = INT2FIX(ch.freq + 1); + if (freq > cycle_rate * 2) + { + ch.phaseacc += freq; + ch.adder = (ch.adder + 1) & 0x1F; + var temp = ToneTable[x, pTone + (ch.adder & 0x1F)]; + return temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2); + } + + // ¼ÓÖØƽ¾ù + int num_times, total; + num_times = total = 0; + while (ch.phaseacc < 0) + { + ch.phaseacc += freq; + ch.adder = (ch.adder + 1) & 0x1F; + var temp = ToneTable[x, pTone + (ch.adder & 0x1F)]; + total += temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2); + num_times++; + } + return total / num_times; + } + } + + internal byte SyncRead(ushort addr) + { + byte data = (byte)(addr >> 8); + + if (addr == 0x4015) + { + data = 0; + if ((ch0.sync_enable != 0) && ch0.sync_len_count > 0) data |= (1 << 0); + if ((ch1.sync_enable != 0) && ch1.sync_len_count > 0) data |= (1 << 1); + if ((ch2.sync_enable != 0) && ch2.sync_len_count > 0) data |= (1 << 2); + if ((ch3.sync_enable != 0) && ch3.sync_len_count > 0) data |= (1 << 3); + if ((ch4.sync_enable != 0) && (ch4.sync_dmalength != 0)) data |= (1 << 4); + if (FrameIRQoccur != 0) data |= (1 << 6); + if (ch4.sync_irq_enable != 0) data |= (1 << 7); + FrameIRQoccur = 0; + + nes.cpu.ClrIRQ(CPU.IRQ_FRAMEIRQ); + } + if (addr == 0x4017) + { + if (FrameIRQoccur != 0) + { + data = 0; + } + else + { + data |= (1 << 6); + } + } + return data; + } + + internal void SyncWrite(ushort addr, byte data) + { + switch (addr) + { + // CH0,1 rectangle + case 0x4000: + case 0x4001: + case 0x4002: + case 0x4003: + case 0x4004: + case 0x4005: + case 0x4006: + case 0x4007: + SyncWriteRectangle((addr < 0x4004) ? 0 : 1, addr, data); + break; + // CH2 triangle + case 0x4008: + case 0x4009: + case 0x400A: + case 0x400B: + SyncWriteTriangle(addr, data); + break; + // CH3 noise + case 0x400C: + case 0x400D: + case 0x400E: + case 0x400F: + SyncWriteNoise(addr, data); + break; + // CH4 DPCM + case 0x4010: + case 0x4011: + case 0x4012: + case 0x4013: + SyncWriteDPCM(addr, data); + break; + + case 0x4015: + sync_reg4015 = data; + + if ((data & (1 << 0)) == 0) + { + ch0.sync_enable = 0; + ch0.sync_len_count = 0; + } + if ((data & (1 << 1)) == 0) + { + ch1.sync_enable = 0; + ch1.sync_len_count = 0; + } + if ((data & (1 << 2)) == 0) + { + ch2.sync_enable = 0; + ch2.sync_len_count = 0; + ch2.sync_lin_count = 0; + ch2.sync_counter_start = 0; + } + if ((data & (1 << 3)) == 0) + { + ch3.sync_enable = 0; + ch3.sync_len_count = 0; + } + if ((data & (1 << 4)) == 0) + { + ch4.sync_enable = 0; + ch4.sync_dmalength = 0; + ch4.sync_irq_enable = 0; + + nes.cpu.ClrIRQ(CPU.IRQ_DPCM); + } + else + { + ch4.sync_enable = 0xFF; + if (ch4.sync_dmalength == 0) + { + // ch4.sync_cycles = ch4.sync_cache_cycles; + ch4.sync_dmalength = ch4.sync_cache_dmalength; + ch4.sync_cycles = 0; + } + } + break; + + case 0x4017: + SyncWrite4017(data); + break; + + // VirtuaNESŒÅ—Lƒ|[ƒg + case 0x4018: + SyncUpdateRectangle(ch0, data); + SyncUpdateRectangle(ch1, data); + SyncUpdateTriangle(data); + SyncUpdateNoise(data); + break; + default: + break; + } + } + + private void SyncUpdateNoise(int type) + { + if (ch3.sync_enable == 0 || ch3.sync_len_count <= 0) + return; + + // Update Length + if (ch3.sync_len_count != 0 && ch3.sync_holdnote == 0) + { + if ((type & 1) == 0 && ch3.sync_len_count != 0) + { + ch3.sync_len_count--; + } + } + } + + private void SyncUpdateTriangle(int type) + { + if (ch2.sync_enable == 0) + return; + + if ((type & 1) == 0 && ch2.sync_holdnote == 0) + { + if (ch2.sync_len_count != 0) + { + ch2.sync_len_count--; + } + } + + // Update Length/Linear + if (ch2.sync_counter_start != 0) + { + ch2.sync_lin_count = ch2.sync_reg[0] & 0x7F; + } + else if (ch2.sync_lin_count != 0) + { + ch2.sync_lin_count--; + } + if (ch2.sync_holdnote == 0 && ch2.sync_lin_count != 0) + { + ch2.sync_counter_start = 0; + } + } + + private void SyncUpdateRectangle(RECTANGLE ch, int type) + { + if (ch.sync_enable == 0 || ch.sync_len_count <= 0) + return; + + // Update Length + if (ch.sync_len_count != 0 && ch.sync_holdnote == 0) + { + if ((type & 1) == 0 && ch.sync_len_count != 0) + { + ch.sync_len_count--; + } + } + } + + private void SyncWrite4017(byte data) + { + FrameCycle = 0; + FrameIRQ = data; + FrameIRQoccur = 0; + + nes.cpu.ClrIRQ(CPU.IRQ_FRAMEIRQ); + + FrameType = (data & 0x80) != 0 ? 1 : 0; + FrameCount = 0; + if ((data & 0x80) > 0) + { + UpdateFrame(); + } + FrameCount = 1; + FrameCycle = 14915; + } + + private void SyncWriteDPCM(ushort addr, byte data) + { + ch4.reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch4.sync_cache_cycles = nes.GetVideoMode() ? dpcm_cycles_pal[data & 0x0F] * 8 : dpcm_cycles[data & 0x0F] * 8; + ch4.sync_looping = (byte)(data & 0x40); + ch4.sync_irq_gen = (byte)(data & 0x80); + if (ch4.sync_irq_gen == 0) + { + ch4.sync_irq_enable = 0; + nes.cpu.ClrIRQ(CPU.IRQ_DPCM); + } + break; + case 1: + break; + case 2: + break; + case 3: + ch4.sync_cache_dmalength = (data << 4) + 1; + break; + } + } + + private void SyncWriteNoise(ushort addr, byte data) + { + ch3.sync_reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch3.sync_holdnote = (byte)(data & 0x20); + break; + case 1: + break; + case 2: + break; + case 3: // Master + ch3.sync_len_count = vbl_length[data >> 3] * 2; + if ((sync_reg4015 & (1 << 3)) != 0) + ch3.sync_enable = 0xFF; + break; + } + } + + private void SyncWriteTriangle(ushort addr, byte data) + { + ch2.sync_reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch2.sync_holdnote = (byte)(data & 0x80); + break; + case 1: + break; + case 2: + break; + case 3: // Master + ch2.sync_len_count = vbl_length[ch2.sync_reg[3] >> 3] * 2; + ch2.sync_counter_start = 0x80; + + if ((sync_reg4015 & (1 << 2)) != 0) + ch2.sync_enable = 0xFF; + break; + } + } + + private void SyncWriteRectangle(int no, ushort addr, byte data) + { + RECTANGLE ch = (no == 0) ? ch0 : ch1; + + ch.sync_reg[addr & 3] = data; + switch (addr & 3) + { + case 0: + ch.sync_holdnote = (byte)(data & 0x20); + break; + case 1: + case 2: + break; + case 3: // Master + ch.sync_len_count = vbl_length[data >> 3] * 2; + if ((sync_reg4015 & (1 << no)) != 0) + ch.sync_enable = 0xFF; + break; + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERNAL.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERNAL.cs.meta new file mode 100644 index 0000000..116b105 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_INTERNAL.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d5f443ad7d5ef1d4394c7fe540f2e3e4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_MMC5.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_MMC5.cs new file mode 100644 index 0000000..0f9c16d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_MMC5.cs @@ -0,0 +1,59 @@ +using System; + +namespace VirtualNes.Core +{ + public class APU_MMC5 : APU_INTERFACE + { + SYNCRECTANGLE sch0 = new SYNCRECTANGLE(); + SYNCRECTANGLE sch1 = new SYNCRECTANGLE(); + + public override void Reset(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Setup(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Write(ushort addr, byte data) + { + //todo : 实现 + } + + public override int Process(int channel) + { + //todo : 实现 + return 0; + } + + internal void SyncWrite(ushort addr, byte data) + { + //todo : 实现 + } + + internal byte SyncRead(ushort addr) + { + byte data = 0; + + if (addr == 0x5015) + { + if ((sch0.enable != 0) && sch0.vbl_length > 0) data |= (1 << 0); + if ((sch1.enable != 0) && sch1.vbl_length > 0) data |= (1 << 1); + } + + return data; + } + + public class SYNCRECTANGLE + { + // For sync + public byte[] reg = new byte[4]; + public byte enable; + public byte holdnote; + public byte[] dummy = new byte[2]; + public int vbl_length; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_MMC5.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_MMC5.cs.meta new file mode 100644 index 0000000..250e590 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_MMC5.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 15b983a12234c3c47baefb9fa2751351 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_N106.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_N106.cs new file mode 100644 index 0000000..2fe943e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_N106.cs @@ -0,0 +1,26 @@ +namespace VirtualNes.Core +{ + public class APU_N106 : APU_INTERFACE + { + public override void Reset(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Setup(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Write(ushort addr, byte data) + { + //todo : 实现 + } + + public override int Process(int channel) + { + //todo : 实现 + return 0; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_N106.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_N106.cs.meta new file mode 100644 index 0000000..692dc26 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_N106.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a47ed257e942d4478215338d8fe4c35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC6.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC6.cs new file mode 100644 index 0000000..0c42555 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC6.cs @@ -0,0 +1,310 @@ +using System; + +namespace VirtualNes.Core +{ + public class APU_VRC6 : APU_INTERFACE + { + public const int RECTANGLE_VOL_SHIFT = 8; + public const int SAWTOOTH_VOL_SHIFT = 6; + + private RECTANGLE ch0 = new RECTANGLE(); + private RECTANGLE ch1 = new RECTANGLE(); + private SAWTOOTH ch2 = new SAWTOOTH(); + + private int cycle_rate; + private float cpu_clock; + + public APU_VRC6() + { + Reset(APU_CLOCK, 22050); + } + + public override void Reset(float fClock, int nRate) + { + ch0.ZeroMemory(); + ch1.ZeroMemory(); + ch2.ZeroMemory(); + + Setup(fClock, nRate); + } + + public override void Setup(float fClock, int nRate) + { + cpu_clock = fClock; + cycle_rate = (int)(fClock * 65536.0f / nRate); + } + + public override void Write(ushort addr, byte data) + { + switch (addr) + { + // VRC6 CH0 rectangle + case 0x9000: + ch0.reg[0] = data; + ch0.gate = (byte)(data & 0x80); + ch0.volume = (byte)(data & 0x0F); + ch0.duty_pos = (byte)((data >> 4) & 0x07); + break; + case 0x9001: + ch0.reg[1] = data; + ch0.freq = INT2FIX((((ch0.reg[2] & 0x0F) << 8) | data) + 1); + break; + case 0x9002: + ch0.reg[2] = data; + ch0.enable = (byte)(data & 0x80); + ch0.freq = INT2FIX((((data & 0x0F) << 8) | ch0.reg[1]) + 1); + break; + // VRC6 CH1 rectangle + case 0xA000: + ch1.reg[0] = data; + ch1.gate = (byte)(data & 0x80); + ch1.volume = (byte)(data & 0x0F); + ch1.duty_pos = (byte)((data >> 4) & 0x07); + break; + case 0xA001: + ch1.reg[1] = data; + ch1.freq = INT2FIX((((ch1.reg[2] & 0x0F) << 8) | data) + 1); + break; + case 0xA002: + ch1.reg[2] = data; + ch1.enable = (byte)(data & 0x80); + ch1.freq = INT2FIX((((data & 0x0F) << 8) | ch1.reg[1]) + 1); + break; + // VRC6 CH2 sawtooth + case 0xB000: + ch2.reg[1] = data; + ch2.phaseaccum = (byte)(data & 0x3F); + break; + case 0xB001: + ch2.reg[1] = data; + ch2.freq = INT2FIX((((ch2.reg[2] & 0x0F) << 8) | data) + 1); + break; + case 0xB002: + ch2.reg[2] = data; + ch2.enable = (byte)(data & 0x80); + ch2.freq = INT2FIX((((data & 0x0F) << 8) | ch2.reg[1]) + 1); + // ch2.adder = 0; // 僋儕傾å¡å‚žå²åƒ²åƒ€åƒ˜åºå°¨å ´åµå´å‚ž + // ch2.accum = 0; // 僋儕傾å¡å‚žå²åƒ²åƒ€åƒ˜åºå°¨å ´åµå´å‚ž + break; + } + } + + public override int Process(int channel) + { + switch (channel) + { + case 0: + return RectangleRender(ch0); + case 1: + return RectangleRender(ch1); + case 2: + return SawtoothRender(ch2); + } + + return 0; + } + + public override int GetFreq(int channel) + { + if (channel == 0 || channel == 1) + { + RECTANGLE ch = null; + if (channel == 0) ch = ch0; + else ch = ch1; + if (ch.enable == 0 || ch.gate != 0 || ch.volume == 0) + return 0; + if (ch.freq < INT2FIX(8)) + return 0; + return (int)(256.0f * cpu_clock / (FIX2INT(ch.freq) * 16.0f)); + } + if (channel == 2) + { + SAWTOOTH ch = ch2; + if (ch.enable == 0 || ch.phaseaccum == 0) + return 0; + if (ch.freq < INT2FIX(8)) + return 0; + return (int)(256.0f * cpu_clock / (FIX2INT(ch.freq) * 14.0f)); + } + + return 0; + } + + private int RectangleRender(RECTANGLE ch) + { + // Enable? + if (ch.enable == 0) + { + ch.output_vol = 0; + ch.adder = 0; + return ch.output_vol; + } + + // Digitized output + if (ch.gate != 0) + { + ch.output_vol = ch.volume << RECTANGLE_VOL_SHIFT; + return ch.output_vol; + } + + // 堦掕埲忋åºå»ƒæ”‡æ‚¢å¼å¼µæ£ŸåŸå´å„(æŸæ‡¯) + if (ch.freq < INT2FIX(8)) + { + ch.output_vol = 0; + return ch.output_vol; + } + + ch.phaseacc -= cycle_rate; + if (ch.phaseacc >= 0) + return ch.output_vol; + + int output = ch.volume << RECTANGLE_VOL_SHIFT; + + if (ch.freq > cycle_rate) + { + // add 1 step + ch.phaseacc += ch.freq; + ch.adder = (byte)((ch.adder + 1) & 0x0F); + if (ch.adder <= ch.duty_pos) + ch.output_vol = output; + else + ch.output_vol = -output; + } + else + { + // average calculate + int num_times, total; + num_times = total = 0; + while (ch.phaseacc < 0) + { + ch.phaseacc += ch.freq; + ch.adder = (byte)((ch.adder + 1) & 0x0F); + if (ch.adder <= ch.duty_pos) + total += output; + else + total += -output; + num_times++; + } + ch.output_vol = total / num_times; + } + + return ch.output_vol; + } + + private int SawtoothRender(SAWTOOTH ch) + { + // Digitized output + if (ch.enable == 0) + { + ch.output_vol = 0; + return ch.output_vol; + } + + // 堦掕埲忋åºå»ƒæ”‡æ‚¢å¼å¼µæ£ŸåŸå´å„(æŸæ‡¯) + if (ch.freq < INT2FIX(9)) + { + return ch.output_vol; + } + + ch.phaseacc -= cycle_rate / 2; + if (ch.phaseacc >= 0) + return ch.output_vol; + + if (ch.freq > cycle_rate / 2) + { + // add 1 step + ch.phaseacc += ch.freq; + if (++ch.adder >= 7) + { + ch.adder = 0; + ch.accum = 0; + } + ch.accum += ch.phaseaccum; + ch.output_vol = ch.accum << SAWTOOTH_VOL_SHIFT; + } + else + { + // average calculate + int num_times, total; + num_times = total = 0; + while (ch.phaseacc < 0) + { + ch.phaseacc += ch.freq; + if (++ch.adder >= 7) + { + ch.adder = 0; + ch.accum = 0; + } + ch.accum += ch.phaseaccum; + total += ch.accum << SAWTOOTH_VOL_SHIFT; + num_times++; + } + ch.output_vol = (total / num_times); + } + + return ch.output_vol; + } + + private class RECTANGLE + { + public byte[] reg = new byte[3]; + + public byte enable; + public byte gate; + public byte volume; + + public int phaseacc; + public int freq; + public int output_vol; + + public byte adder; + public byte duty_pos; + + public void ZeroMemory() + { + Array.Clear(reg, 0, reg.Length); + enable = default; + gate = default; + volume = default; + + phaseacc = default; + freq = default; + output_vol = default; + + adder = default; + duty_pos = default; + } + } + + private class SAWTOOTH + { + public byte[] reg = new byte[3]; + + public byte enable; + public byte volume; + + public int phaseacc; + public int freq; + public int output_vol; + + public byte adder; + public byte accum; + public byte phaseaccum; + + public void ZeroMemory() + { + Array.Clear(reg, 0, reg.Length); + enable = default; + volume = default; + + phaseacc = default; + freq = default; + output_vol = default; + + adder = default; + accum = default; + phaseaccum = default; + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC6.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC6.cs.meta new file mode 100644 index 0000000..e9b6f8a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC6.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 190f3271accd30f4eb5b13590417d265 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC7.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC7.cs new file mode 100644 index 0000000..448ddd0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC7.cs @@ -0,0 +1,26 @@ +namespace VirtualNes.Core +{ + public class APU_VRC7 : APU_INTERFACE + { + public override void Reset(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Setup(float fClock, int nRate) + { + //todo : 实现 + } + + public override void Write(ushort addr, byte data) + { + //todo : 实现 + } + + public override int Process(int channel) + { + //todo : 实现 + return 0; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC7.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC7.cs.meta new file mode 100644 index 0000000..15e1c81 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_VRC7.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 180a87918f9d49e4fad978014f1d594f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/DPCM.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/DPCM.cs new file mode 100644 index 0000000..35835b3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/DPCM.cs @@ -0,0 +1,28 @@ +namespace VirtualNes.Core +{ + public class DPCM + { + public byte[] reg = new byte[4]; + public byte enable; + public byte looping; + public byte cur_byte; + public byte dpcm_value; + + public int freq; + public int phaseacc; + public int output; + + public ushort address, cache_addr; + public int dmalength, cache_dmalength; + public int dpcm_output_real, dpcm_output_fake, dpcm_output_old, dpcm_output_offset; + + // For sync + public byte[] sync_reg = new byte[4]; + public byte sync_enable; + public byte sync_looping; + public byte sync_irq_gen; + public byte sync_irq_enable; + public int sync_cycles, sync_cache_cycles; + public int sync_dmalength, sync_cache_dmalength; + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/DPCM.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/DPCM.cs.meta new file mode 100644 index 0000000..08b468c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/DPCM.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e6289a516ac91b541b2b1807bb07e2b0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/NOISE.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/NOISE.cs new file mode 100644 index 0000000..0fa41a4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/NOISE.cs @@ -0,0 +1,68 @@ +using System; + +namespace VirtualNes.Core +{ + public class NOISE + { + public byte[] reg = new byte[4]; // register + + public byte enable; // enable + public byte holdnote; // holdnote + public byte volume; // volume + public byte xor_tap; + public int shift_reg; + + // For Render + public int phaseacc; + public int freq; + public int len_count; + + public int nowvolume; + public int output; + + // For Envelope + public byte env_fixed; + public byte env_decay; + public byte env_count; + public byte dummy0; + public int env_vol; + + // For sync; + public byte[] sync_reg = new byte[4]; + public byte sync_output_enable; + public byte sync_enable; + public byte sync_holdnote; + public byte dummy1; + public int sync_len_count; + + internal void ZeroMemory() + { + Array.Clear(reg, 0, reg.Length); + + enable = 0; + holdnote = 0; + volume = 0; + xor_tap = 0; + shift_reg = 0; + + phaseacc = 0; + freq = 0; + len_count = 0; + nowvolume = 0; + output = 0; + + env_fixed = 0; + env_decay = 0; + env_count = 0; + dummy0 = 0; + env_vol = 0; + + Array.Clear(sync_reg, 0, sync_reg.Length); + sync_output_enable = 0; + sync_enable = 0; + sync_holdnote = 0; + dummy1 = 0; + sync_len_count = 0; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/NOISE.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/NOISE.cs.meta new file mode 100644 index 0000000..69ea5b5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/NOISE.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8680ce7dbdceb504dbda3b98dbdb1297 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/RECTANGLE.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/RECTANGLE.cs new file mode 100644 index 0000000..8d3688e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/RECTANGLE.cs @@ -0,0 +1,85 @@ +using System; + +namespace VirtualNes.Core +{ + public class RECTANGLE + { + public byte[] reg = new byte[4]; // register + + public byte enable; // enable + public byte holdnote; // holdnote + public byte volume; // volume + public byte complement; + + // For Render + public int phaseacc; + public int freq; + public int freqlimit; + public int adder; + public int duty; + public int len_count; + + public int nowvolume; + + // For Envelope + public byte env_fixed; + public byte env_decay; + public byte env_count; + public byte dummy0; + public int env_vol; + + // For Sweep + public byte swp_on; + public byte swp_inc; + public byte swp_shift; + public byte swp_decay; + public byte swp_count; + public byte[] dummy1 = new byte[3]; + + // For sync; + public byte[] sync_reg = new byte[4]; + public byte sync_output_enable; + public byte sync_enable; + public byte sync_holdnote; + public byte dummy2; + public int sync_len_count; + + public void ZeroMemory() + { + Array.Clear(reg, 0, reg.Length); + enable = 0; + holdnote = 0; + volume = 0; + complement = 0; + + phaseacc = 0; + freq = 0; + freqlimit = 0; + adder = 0; + duty = 0; + len_count = 0; + + nowvolume = 0; + + env_fixed = 0; + env_decay = 0; + env_count = 0; + dummy0 = 0; + env_vol = 0; + + swp_on = 0; + swp_inc = 0; + swp_shift = 0; + swp_decay = 0; + swp_count = 0; + Array.Clear(dummy1, 0, dummy1.Length); + + Array.Clear(sync_reg, 0, sync_reg.Length); + sync_output_enable = 0; + sync_enable = 0; + sync_holdnote = 0; + dummy2 = 0; + sync_len_count = 0; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/RECTANGLE.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/RECTANGLE.cs.meta new file mode 100644 index 0000000..9cbc24b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/RECTANGLE.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6e50831f6c445fe489d7e1737269296e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/TRIANGLE.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/TRIANGLE.cs new file mode 100644 index 0000000..191a619 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/TRIANGLE.cs @@ -0,0 +1,54 @@ +using System; + +namespace VirtualNes.Core +{ + public class TRIANGLE + { + public byte[] reg = new byte[4]; + + public byte enable; + public byte holdnote; + public byte counter_start; + public byte dummy0; + + public int phaseacc; + public int freq; + public int len_count; + public int lin_count; + public int adder; + + public int nowvolume; + + // For sync; + public byte[] sync_reg = new byte[4]; + public byte sync_enable; + public byte sync_holdnote; + public byte sync_counter_start; + // public byte dummy1; + public int sync_len_count; + public int sync_lin_count; + + internal void ZeroMemory() + { + Array.Clear(reg, 0, reg.Length); + + enable = 0; + holdnote = 0; + counter_start = 0; + dummy0 = 0; + phaseacc = 0; + freq = 0; + len_count = 0; + lin_count = 0; + adder = 0; + nowvolume = 0; + Array.Clear(sync_reg, 0, sync_reg.Length); + sync_enable = 0; + sync_holdnote = 0; + sync_counter_start = 0; + + sync_len_count = 0; + sync_lin_count = 0; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/TRIANGLE.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/TRIANGLE.cs.meta new file mode 100644 index 0000000..4cfe6b6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/TRIANGLE.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ed2788da33fe474facc1d7ce1b34d03 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CPU.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CPU.cs new file mode 100644 index 0000000..835c758 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CPU.cs @@ -0,0 +1,2070 @@ +#undef DPCM_SYNCCLOCK + +using System; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class CPU + { + private static int nmicount; + + // 6502 status flags + public const byte C_FLAG = 0x01; // 1: Carry + public const byte Z_FLAG = 0x02; // 1: Zero + public const byte I_FLAG = 0x04; // 1: Irq disabled + public const byte D_FLAG = 0x08; // 1: Decimal mode flag (NES unused) + public const byte B_FLAG = 0x10; // 1: Break + public const byte R_FLAG = 0x20; // 1: Reserved (Always 1) + public const byte V_FLAG = 0x40; // 1: Overflow + public const byte N_FLAG = 0x80; // 1: Negative + + // Interrupt + public const byte NMI_FLAG = 0x01; + public const byte IRQ_FLAG = 0x02; + + public const byte IRQ_FRAMEIRQ = 0x04; + public const byte IRQ_DPCM = 0x08; + public const byte IRQ_MAPPER = 0x10; + public const byte IRQ_MAPPER2 = 0x20; + public const byte IRQ_TRIGGER = 0x40; // one shot(媽IRQ()) + public const byte IRQ_TRIGGER2 = 0x80; // one shot(媽IRQ_NotPending()) + + public static readonly byte IRQ_MASK = unchecked((byte)(~(NMI_FLAG | IRQ_FLAG))); + + // Vector + public const ushort NMI_VECTOR = 0xFFFA; + public const ushort RES_VECTOR = 0xFFFC; + public const ushort IRQ_VECTOR = 0xFFFE; + + private NES nes; + private bool m_bClockProcess; + private int TOTAL_cycles; + private int DMA_cycles; + private Mapper mapper; + private APU apu; + internal R6502 R = new R6502(); + private byte[] ZN_Table = new byte[256]; + private ByteArrayRef STACK; + + public CPU(NES parent) + { + nes = parent; + m_bClockProcess = false; + + } + + public void Dispose() { } + + ushort EA = 0; + ushort ET = 0; + ushort WT = 0; + byte DT = 0; + int exec_cycles = 0; + + internal long EXEC(int request_cycles) + { + byte opcode = 0; + int OLD_cycles = TOTAL_cycles; + byte nmi_request = 0, irq_request = 0; + bool bClockProcess = m_bClockProcess; + + exec_cycles = 0; + EA = 0; + ET = 0; + WT = 0; + DT = 0; + + while (request_cycles > 0) + { + exec_cycles = 0; + if (DMA_cycles > 0) + { + if (request_cycles <= DMA_cycles) + { + DMA_cycles -= request_cycles; + TOTAL_cycles += request_cycles; + + mapper.Clock(request_cycles); +#if DPCM_SYNCCLOCK + apu.SyncDPCM(request_cycles); +#endif + if (m_bClockProcess) + { + nes.Clock(request_cycles); + } + + goto _execute_exit; + } + else + { + exec_cycles += DMA_cycles; + DMA_cycles = 0; + } + } + + nmi_request = irq_request = 0; + opcode = OP6502(R.PC++); + + if (R.INT_pending != 0) + { + if ((R.INT_pending & NMI_FLAG) != 0) + { + nmi_request = 0xFF; + byte temp = unchecked((byte)(~NMI_FLAG)); + R.INT_pending &= temp; + } + else if ((R.INT_pending & IRQ_MASK) != 0) + { + byte temp = unchecked((byte)(~IRQ_TRIGGER2)); + R.INT_pending &= temp; + if ( + ((R.P & I_FLAG) == 0) + && + (opcode != 0x40) + ) + { + irq_request = 0xFF; + temp = unchecked((byte)(~IRQ_TRIGGER)); + R.INT_pending &= temp; + } + } + } + + switch (opcode) + { + case 0x69: // ADC #$?? + MR_IM(); ADC(); + ADD_CYCLE(2); + break; + case 0x65: // ADC $?? + MR_ZP(); ADC(); + ADD_CYCLE(3); + break; + case 0x75: // ADC $??,X + MR_ZX(); ADC(); + ADD_CYCLE(4); + break; + case 0x6D: // ADC $???? + MR_AB(); ADC(); + ADD_CYCLE(4); + break; + case 0x7D: // ADC $????,X + MR_AX(); ADC(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x79: // ADC $????,Y + MR_AY(); ADC(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x61: // ADC ($??,X) + MR_IX(); ADC(); + ADD_CYCLE(6); + break; + case 0x71: // ADC ($??),Y + MR_IY(); ADC(); CHECK_EA(); + ADD_CYCLE(4); + break; + + case 0xE9: // SBC #$?? + MR_IM(); SBC(); + ADD_CYCLE(2); + break; + case 0xE5: // SBC $?? + MR_ZP(); SBC(); + ADD_CYCLE(3); + break; + case 0xF5: // SBC $??,X + MR_ZX(); SBC(); + ADD_CYCLE(4); + break; + case 0xED: // SBC $???? + MR_AB(); SBC(); + ADD_CYCLE(4); + break; + case 0xFD: // SBC $????,X + MR_AX(); SBC(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xF9: // SBC $????,Y + MR_AY(); SBC(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xE1: // SBC ($??,X) + MR_IX(); SBC(); + ADD_CYCLE(6); + break; + case 0xF1: // SBC ($??),Y + MR_IY(); SBC(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0xC6: // DEC $?? + MR_ZP(); DEC(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0xD6: // DEC $??,X + MR_ZX(); DEC(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0xCE: // DEC $???? + MR_AB(); DEC(); MW_EA(); + ADD_CYCLE(6); + break; + case 0xDE: // DEC $????,X + MR_AX(); DEC(); MW_EA(); + ADD_CYCLE(7); + break; + + case 0xCA: // DEX + DEX(); + ADD_CYCLE(2); + break; + case 0x88: // DEY + DEY(); + ADD_CYCLE(2); + break; + + case 0xE6: // INC $?? + MR_ZP(); INC(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0xF6: // INC $??,X + MR_ZX(); INC(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0xEE: // INC $???? + MR_AB(); INC(); MW_EA(); + ADD_CYCLE(6); + break; + case 0xFE: // INC $????,X + MR_AX(); INC(); MW_EA(); + ADD_CYCLE(7); + break; + + case 0xE8: // INX + INX(); + ADD_CYCLE(2); + break; + case 0xC8: // INY + INY(); + ADD_CYCLE(2); + break; + + case 0x29: // AND #$?? + MR_IM(); AND(); + ADD_CYCLE(2); + break; + case 0x25: // AND $?? + MR_ZP(); AND(); + ADD_CYCLE(3); + break; + case 0x35: // AND $??,X + MR_ZX(); AND(); + ADD_CYCLE(4); + break; + case 0x2D: // AND $???? + MR_AB(); AND(); + ADD_CYCLE(4); + break; + case 0x3D: // AND $????,X + MR_AX(); AND(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x39: // AND $????,Y + MR_AY(); AND(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x21: // AND ($??,X) + MR_IX(); AND(); + ADD_CYCLE(6); + break; + case 0x31: // AND ($??),Y + MR_IY(); AND(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0x0A: // ASL A + ASL_A(); + ADD_CYCLE(2); + break; + case 0x06: // ASL $?? + MR_ZP(); ASL(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x16: // ASL $??,X + MR_ZX(); ASL(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x0E: // ASL $???? + MR_AB(); ASL(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x1E: // ASL $????,X + MR_AX(); ASL(); MW_EA(); + ADD_CYCLE(7); + break; + + case 0x24: // BIT $?? + MR_ZP(); BIT(); + ADD_CYCLE(3); + break; + case 0x2C: // BIT $???? + MR_AB(); BIT(); + ADD_CYCLE(4); + break; + + case 0x49: // EOR #$?? + MR_IM(); EOR(); + ADD_CYCLE(2); + break; + case 0x45: // EOR $?? + MR_ZP(); EOR(); + ADD_CYCLE(3); + break; + case 0x55: // EOR $??,X + MR_ZX(); EOR(); + ADD_CYCLE(4); + break; + case 0x4D: // EOR $???? + MR_AB(); EOR(); + ADD_CYCLE(4); + break; + case 0x5D: // EOR $????,X + MR_AX(); EOR(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x59: // EOR $????,Y + MR_AY(); EOR(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x41: // EOR ($??,X) + MR_IX(); EOR(); + ADD_CYCLE(6); + break; + case 0x51: // EOR ($??),Y + MR_IY(); EOR(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0x4A: // LSR A + LSR_A(); + ADD_CYCLE(2); + break; + case 0x46: // LSR $?? + MR_ZP(); LSR(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x56: // LSR $??,X + MR_ZX(); LSR(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x4E: // LSR $???? + MR_AB(); LSR(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x5E: // LSR $????,X + MR_AX(); LSR(); MW_EA(); + ADD_CYCLE(7); + break; + + case 0x09: // ORA #$?? + MR_IM(); ORA(); + ADD_CYCLE(2); + break; + case 0x05: // ORA $?? + MR_ZP(); ORA(); + ADD_CYCLE(3); + break; + case 0x15: // ORA $??,X + MR_ZX(); ORA(); + ADD_CYCLE(4); + break; + case 0x0D: // ORA $???? + MR_AB(); ORA(); + ADD_CYCLE(4); + break; + case 0x1D: // ORA $????,X + MR_AX(); ORA(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x19: // ORA $????,Y + MR_AY(); ORA(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0x01: // ORA ($??,X) + MR_IX(); ORA(); + ADD_CYCLE(6); + break; + case 0x11: // ORA ($??),Y + MR_IY(); ORA(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0x2A: // ROL A + ROL_A(); + ADD_CYCLE(2); + break; + case 0x26: // ROL $?? + MR_ZP(); ROL(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x36: // ROL $??,X + MR_ZX(); ROL(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x2E: // ROL $???? + MR_AB(); ROL(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x3E: // ROL $????,X + MR_AX(); ROL(); MW_EA(); + ADD_CYCLE(7); + break; + + case 0x6A: // ROR A + ROR_A(); + ADD_CYCLE(2); + break; + case 0x66: // ROR $?? + MR_ZP(); ROR(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x76: // ROR $??,X + MR_ZX(); ROR(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x6E: // ROR $???? + MR_AB(); ROR(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x7E: // ROR $????,X + MR_AX(); ROR(); MW_EA(); + ADD_CYCLE(7); + break; + + case 0xA9: // LDA #$?? + MR_IM(); LDA(); + ADD_CYCLE(2); + break; + case 0xA5: // LDA $?? + MR_ZP(); LDA(); + ADD_CYCLE(3); + break; + case 0xB5: // LDA $??,X + MR_ZX(); LDA(); + ADD_CYCLE(4); + break; + case 0xAD: // LDA $???? + MR_AB(); LDA(); + ADD_CYCLE(4); + break; + case 0xBD: // LDA $????,X + MR_AX(); LDA(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xB9: // LDA $????,Y + MR_AY(); LDA(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xA1: // LDA ($??,X) + MR_IX(); LDA(); + ADD_CYCLE(6); + break; + case 0xB1: // LDA ($??),Y + MR_IY(); LDA(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0xA2: // LDX #$?? + MR_IM(); LDX(); + ADD_CYCLE(2); + break; + case 0xA6: // LDX $?? + MR_ZP(); LDX(); + ADD_CYCLE(3); + break; + case 0xB6: // LDX $??,Y + MR_ZY(); LDX(); + ADD_CYCLE(4); + break; + case 0xAE: // LDX $???? + MR_AB(); LDX(); + ADD_CYCLE(4); + break; + case 0xBE: // LDX $????,Y + MR_AY(); LDX(); CHECK_EA(); + ADD_CYCLE(4); + break; + + case 0xA0: // LDY #$?? + MR_IM(); LDY(); + ADD_CYCLE(2); + break; + case 0xA4: // LDY $?? + MR_ZP(); LDY(); + ADD_CYCLE(3); + break; + case 0xB4: // LDY $??,X + MR_ZX(); LDY(); + ADD_CYCLE(4); + break; + case 0xAC: // LDY $???? + MR_AB(); LDY(); + ADD_CYCLE(4); + break; + case 0xBC: // LDY $????,X + MR_AX(); LDY(); CHECK_EA(); + ADD_CYCLE(4); + break; + + case 0x85: // STA $?? + EA_ZP(); STA(); MW_ZP(); + ADD_CYCLE(3); + break; + case 0x95: // STA $??,X + EA_ZX(); STA(); MW_ZP(); + ADD_CYCLE(4); + break; + case 0x8D: // STA $???? + EA_AB(); STA(); MW_EA(); + ADD_CYCLE(4); + break; + case 0x9D: // STA $????,X + EA_AX(); STA(); MW_EA(); + ADD_CYCLE(5); + break; + case 0x99: // STA $????,Y + EA_AY(); STA(); MW_EA(); + ADD_CYCLE(5); + break; + case 0x81: // STA ($??,X) + EA_IX(); STA(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x91: // STA ($??),Y + EA_IY(); STA(); MW_EA(); + ADD_CYCLE(6); + break; + + case 0x86: // STX $?? + EA_ZP(); STX(); MW_ZP(); + ADD_CYCLE(3); + break; + case 0x96: // STX $??,Y + EA_ZY(); STX(); MW_ZP(); + ADD_CYCLE(4); + break; + case 0x8E: // STX $???? + EA_AB(); STX(); MW_EA(); + ADD_CYCLE(4); + break; + + case 0x84: // STY $?? + EA_ZP(); STY(); MW_ZP(); + ADD_CYCLE(3); + break; + case 0x94: // STY $??,X + EA_ZX(); STY(); MW_ZP(); + ADD_CYCLE(4); + break; + case 0x8C: // STY $???? + EA_AB(); STY(); MW_EA(); + ADD_CYCLE(4); + break; + + case 0xAA: // TAX + TAX(); + ADD_CYCLE(2); + break; + case 0x8A: // TXA + TXA(); + ADD_CYCLE(2); + break; + case 0xA8: // TAY + TAY(); + ADD_CYCLE(2); + break; + case 0x98: // TYA + TYA(); + ADD_CYCLE(2); + break; + case 0xBA: // TSX + TSX(); + ADD_CYCLE(2); + break; + case 0x9A: // TXS + TXS(); + ADD_CYCLE(2); + break; + + case 0xC9: // CMP #$?? + MR_IM(); CMP_(); + ADD_CYCLE(2); + break; + case 0xC5: // CMP $?? + MR_ZP(); CMP_(); + ADD_CYCLE(3); + break; + case 0xD5: // CMP $??,X + MR_ZX(); CMP_(); + ADD_CYCLE(4); + break; + case 0xCD: // CMP $???? + MR_AB(); CMP_(); + ADD_CYCLE(4); + break; + case 0xDD: // CMP $????,X + MR_AX(); CMP_(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xD9: // CMP $????,Y + MR_AY(); CMP_(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xC1: // CMP ($??,X) + MR_IX(); CMP_(); + ADD_CYCLE(6); + break; + case 0xD1: // CMP ($??),Y + MR_IY(); CMP_(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0xE0: // CPX #$?? + MR_IM(); CPX(); + ADD_CYCLE(2); + break; + case 0xE4: // CPX $?? + MR_ZP(); CPX(); + ADD_CYCLE(3); + break; + case 0xEC: // CPX $???? + MR_AB(); CPX(); + ADD_CYCLE(4); + break; + + case 0xC0: // CPY #$?? + MR_IM(); CPY(); + ADD_CYCLE(2); + break; + case 0xC4: // CPY $?? + MR_ZP(); CPY(); + ADD_CYCLE(3); + break; + case 0xCC: // CPY $???? + MR_AB(); CPY(); + ADD_CYCLE(4); + break; + + case 0x90: // BCC + MR_IM(); BCC(); + ADD_CYCLE(2); + break; + case 0xB0: // BCS + MR_IM(); BCS(); + ADD_CYCLE(2); + break; + case 0xF0: // BEQ + MR_IM(); BEQ(); + ADD_CYCLE(2); + break; + case 0x30: // BMI + MR_IM(); BMI(); + ADD_CYCLE(2); + break; + case 0xD0: // BNE + MR_IM(); BNE(); + ADD_CYCLE(2); + break; + case 0x10: // BPL + MR_IM(); BPL(); + ADD_CYCLE(2); + break; + case 0x50: // BVC + MR_IM(); BVC(); + ADD_CYCLE(2); + break; + case 0x70: // BVS + MR_IM(); BVS(); + ADD_CYCLE(2); + break; + + case 0x4C: // JMP $???? + JMP(); + ADD_CYCLE(3); + break; + case 0x6C: // JMP ($????) + JMP_ID(); + ADD_CYCLE(5); + break; + + case 0x20: // JSR + JSR(); + ADD_CYCLE(6); + break; + + case 0x40: // RTI + RTI(); + ADD_CYCLE(6); + break; + case 0x60: // RTS + RTS(); + ADD_CYCLE(6); + break; + + // フラグ制御系 + case 0x18: // CLC + CLC(); + ADD_CYCLE(2); + break; + case 0xD8: // CLD + CLD(); + ADD_CYCLE(2); + break; + case 0x58: // CLI + CLI(); + ADD_CYCLE(2); + break; + case 0xB8: // CLV + CLV(); + ADD_CYCLE(2); + break; + + case 0x38: // SEC + SEC(); + ADD_CYCLE(2); + break; + case 0xF8: // SED + SED(); + ADD_CYCLE(2); + break; + case 0x78: // SEI + SEI(); + ADD_CYCLE(2); + break; + + // スタック系 + case 0x48: // PHA + PUSH(R.A); + ADD_CYCLE(3); + break; + case 0x08: // PHP + PUSH((byte)(R.P | B_FLAG)); + ADD_CYCLE(3); + break; + case 0x68: // PLA (N-----Z-) + R.A = POP(); + SET_ZN_FLAG(R.A); + ADD_CYCLE(4); + break; + case 0x28: // PLP + R.P = (byte)(POP() | R_FLAG); + ADD_CYCLE(4); + break; + + // ãã®ä»– + case 0x00: // BRK + BRK(); + ADD_CYCLE(7); + break; + + case 0xEA: // NOP + ADD_CYCLE(2); + break; + + // 未公開命令群 + case 0x0B: // ANC #$?? + case 0x2B: // ANC #$?? + MR_IM(); ANC(); + ADD_CYCLE(2); + break; + + case 0x8B: // ANE #$?? + MR_IM(); ANE(); + ADD_CYCLE(2); + break; + + case 0x6B: // ARR #$?? + MR_IM(); ARR(); + ADD_CYCLE(2); + break; + + case 0x4B: // ASR #$?? + MR_IM(); ASR(); + ADD_CYCLE(2); + break; + + case 0xC7: // DCP $?? + MR_ZP(); DCP(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0xD7: // DCP $??,X + MR_ZX(); DCP(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0xCF: // DCP $???? + MR_AB(); DCP(); MW_EA(); + ADD_CYCLE(6); + break; + case 0xDF: // DCP $????,X + MR_AX(); DCP(); MW_EA(); + ADD_CYCLE(7); + break; + case 0xDB: // DCP $????,Y + MR_AY(); DCP(); MW_EA(); + ADD_CYCLE(7); + break; + case 0xC3: // DCP ($??,X) + MR_IX(); DCP(); MW_EA(); + ADD_CYCLE(8); + break; + case 0xD3: // DCP ($??),Y + MR_IY(); DCP(); MW_EA(); + ADD_CYCLE(8); + break; + + case 0xE7: // ISB $?? + MR_ZP(); ISB(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0xF7: // ISB $??,X + MR_ZX(); ISB(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0xEF: // ISB $???? + MR_AB(); ISB(); MW_EA(); + ADD_CYCLE(5); + break; + case 0xFF: // ISB $????,X + MR_AX(); ISB(); MW_EA(); + ADD_CYCLE(5); + break; + case 0xFB: // ISB $????,Y + MR_AY(); ISB(); MW_EA(); + ADD_CYCLE(5); + break; + case 0xE3: // ISB ($??,X) + MR_IX(); ISB(); MW_EA(); + ADD_CYCLE(5); + break; + case 0xF3: // ISB ($??),Y + MR_IY(); ISB(); MW_EA(); + ADD_CYCLE(5); + break; + + case 0xBB: // LAS $????,Y + MR_AY(); LAS(); CHECK_EA(); + ADD_CYCLE(4); + break; + + + case 0xA7: // LAX $?? + MR_ZP(); LAX(); + ADD_CYCLE(3); + break; + case 0xB7: // LAX $??,Y + MR_ZY(); LAX(); + ADD_CYCLE(4); + break; + case 0xAF: // LAX $???? + MR_AB(); LAX(); + ADD_CYCLE(4); + break; + case 0xBF: // LAX $????,Y + MR_AY(); LAX(); CHECK_EA(); + ADD_CYCLE(4); + break; + case 0xA3: // LAX ($??,X) + MR_IX(); LAX(); + ADD_CYCLE(6); + break; + case 0xB3: // LAX ($??),Y + MR_IY(); LAX(); CHECK_EA(); + ADD_CYCLE(5); + break; + + case 0xAB: // LXA #$?? + MR_IM(); LXA(); + ADD_CYCLE(2); + break; + + case 0x27: // RLA $?? + MR_ZP(); RLA(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x37: // RLA $??,X + MR_ZX(); RLA(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x2F: // RLA $???? + MR_AB(); RLA(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x3F: // RLA $????,X + MR_AX(); RLA(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x3B: // RLA $????,Y + MR_AY(); RLA(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x23: // RLA ($??,X) + MR_IX(); RLA(); MW_EA(); + ADD_CYCLE(8); + break; + case 0x33: // RLA ($??),Y + MR_IY(); RLA(); MW_EA(); + ADD_CYCLE(8); + break; + + case 0x67: // RRA $?? + MR_ZP(); RRA(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x77: // RRA $??,X + MR_ZX(); RRA(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x6F: // RRA $???? + MR_AB(); RRA(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x7F: // RRA $????,X + MR_AX(); RRA(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x7B: // RRA $????,Y + MR_AY(); RRA(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x63: // RRA ($??,X) + MR_IX(); RRA(); MW_EA(); + ADD_CYCLE(8); + break; + case 0x73: // RRA ($??),Y + MR_IY(); RRA(); MW_EA(); + ADD_CYCLE(8); + break; + + case 0x87: // SAX $?? + MR_ZP(); SAX(); MW_ZP(); + ADD_CYCLE(3); + break; + case 0x97: // SAX $??,Y + MR_ZY(); SAX(); MW_ZP(); + ADD_CYCLE(4); + break; + case 0x8F: // SAX $???? + MR_AB(); SAX(); MW_EA(); + ADD_CYCLE(4); + break; + case 0x83: // SAX ($??,X) + MR_IX(); SAX(); MW_EA(); + ADD_CYCLE(6); + break; + + case 0xCB: // SBX #$?? + MR_IM(); SBX(); + ADD_CYCLE(2); + break; + + case 0x9F: // SHA $????,Y + MR_AY(); SHA(); MW_EA(); + ADD_CYCLE(5); + break; + case 0x93: // SHA ($??),Y + MR_IY(); SHA(); MW_EA(); + ADD_CYCLE(6); + break; + + case 0x9B: // SHS $????,Y + MR_AY(); SHS(); MW_EA(); + ADD_CYCLE(5); + break; + + case 0x9E: // SHX $????,Y + MR_AY(); SHX(); MW_EA(); + ADD_CYCLE(5); + break; + + case 0x9C: // SHY $????,X + MR_AX(); SHY(); MW_EA(); + ADD_CYCLE(5); + break; + + case 0x07: // SLO $?? + MR_ZP(); SLO(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x17: // SLO $??,X + MR_ZX(); SLO(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x0F: // SLO $???? + MR_AB(); SLO(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x1F: // SLO $????,X + MR_AX(); SLO(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x1B: // SLO $????,Y + MR_AY(); SLO(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x03: // SLO ($??,X) + MR_IX(); SLO(); MW_EA(); + ADD_CYCLE(8); + break; + case 0x13: // SLO ($??),Y + MR_IY(); SLO(); MW_EA(); + ADD_CYCLE(8); + break; + + case 0x47: // SRE $?? + MR_ZP(); SRE(); MW_ZP(); + ADD_CYCLE(5); + break; + case 0x57: // SRE $??,X + MR_ZX(); SRE(); MW_ZP(); + ADD_CYCLE(6); + break; + case 0x4F: // SRE $???? + MR_AB(); SRE(); MW_EA(); + ADD_CYCLE(6); + break; + case 0x5F: // SRE $????,X + MR_AX(); SRE(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x5B: // SRE $????,Y + MR_AY(); SRE(); MW_EA(); + ADD_CYCLE(7); + break; + case 0x43: // SRE ($??,X) + MR_IX(); SRE(); MW_EA(); + ADD_CYCLE(8); + break; + case 0x53: // SRE ($??),Y + MR_IY(); SRE(); MW_EA(); + ADD_CYCLE(8); + break; + + case 0xEB: // SBC #$?? (Unofficial) + MR_IM(); SBC(); + ADD_CYCLE(2); + break; + + case 0x1A: // NOP (Unofficial) + case 0x3A: // NOP (Unofficial) + case 0x5A: // NOP (Unofficial) + case 0x7A: // NOP (Unofficial) + case 0xDA: // NOP (Unofficial) + case 0xFA: // NOP (Unofficial) + ADD_CYCLE(2); + break; + case 0x80: // DOP (CYCLES 2) + case 0x82: // DOP (CYCLES 2) + case 0x89: // DOP (CYCLES 2) + case 0xC2: // DOP (CYCLES 2) + case 0xE2: // DOP (CYCLES 2) + R.PC++; + ADD_CYCLE(2); + break; + case 0x04: // DOP (CYCLES 3) + case 0x44: // DOP (CYCLES 3) + case 0x64: // DOP (CYCLES 3) + R.PC++; + ADD_CYCLE(3); + break; + case 0x14: // DOP (CYCLES 4) + case 0x34: // DOP (CYCLES 4) + case 0x54: // DOP (CYCLES 4) + case 0x74: // DOP (CYCLES 4) + case 0xD4: // DOP (CYCLES 4) + case 0xF4: // DOP (CYCLES 4) + R.PC++; + ADD_CYCLE(4); + break; + case 0x0C: // TOP + case 0x1C: // TOP + case 0x3C: // TOP + case 0x5C: // TOP + case 0x7C: // TOP + case 0xDC: // TOP + case 0xFC: // TOP + R.PC += 2; + ADD_CYCLE(4); + break; + + case 0x02: /* JAM */ + case 0x12: /* JAM */ + case 0x22: /* JAM */ + case 0x32: /* JAM */ + case 0x42: /* JAM */ + case 0x52: /* JAM */ + case 0x62: /* JAM */ + case 0x72: /* JAM */ + case 0x92: /* JAM */ + case 0xB2: /* JAM */ + case 0xD2: /* JAM */ + case 0xF2: /* JAM */ + default: + if (!Supporter.Config.emulator.bIllegalOp) + { + throw new Exception("IllegalOp"); + } + else + { + R.PC--; + ADD_CYCLE(4); + } + break; + // default: + // __assume(0); + } + + if (nmi_request != 0) + { + _NMI(); + } + else + if (irq_request != 0) + { + _IRQ(); + } + + request_cycles -= exec_cycles; + TOTAL_cycles += exec_cycles; + + mapper.Clock(exec_cycles); +#if DPCM_SYNCCLOCK + apu->SyncDPCM( exec_cycles ); +#endif + if (bClockProcess) + { + nes.Clock(exec_cycles); + } + } + _execute_exit: +#if !DPCM_SYNCCLOCK + apu.SyncDPCM(TOTAL_cycles - OLD_cycles); +#endif + return TOTAL_cycles - OLD_cycles; + } + private void _IRQ() + { + PUSH((byte)(R.PC >> 8)); + PUSH((byte)(R.PC & 0xFF)); + CLR_FLAG(B_FLAG); + PUSH(R.P); + SET_FLAG(I_FLAG); + R.PC = RD6502W(IRQ_VECTOR); + exec_cycles += 7; + } + + + private ushort RD6502W(ushort addr) + { + if (addr < 0x2000) + { + // RAM (Mirror $0800, $1000, $1800) + return BitConverter.ToUInt16(MMU.RAM, addr & 0x07FF); + } + else if (addr < 0x8000) + { + // Others + return (ushort)(nes.Read(addr) + nes.Read((ushort)(addr + 1)) * 0x100); + } + + var temp = MMU.CPU_MEM_BANK[addr >> 13]; + shortTemp[0] = temp[addr & 0x1FFF]; + shortTemp[1] = temp[(addr & 0x1FFF) + 1]; + return BitConverter.ToUInt16(shortTemp, 0); + } + + private void SET_FLAG(byte V) + { + R.P |= (V); + } + + private void CLR_FLAG(byte V) + { + var temp = (byte)(~V); + R.P &= temp; + } + + private void _NMI() + { + PUSH((byte)(R.PC >> 8)); + PUSH((byte)(R.PC & 0xFF)); + CLR_FLAG(B_FLAG); + PUSH(R.P); + SET_FLAG(I_FLAG); + R.PC = RD6502W(NMI_VECTOR); + exec_cycles += 7; + } + + private void SRE() + { + TST_FLAG((DT & 0x01) != 0, C_FLAG); + DT >>= 1; + R.A ^= DT; + SET_ZN_FLAG(R.A); + } + + private void SLO() + { + TST_FLAG((DT & 0x80) != 0, C_FLAG); + DT <<= 1; + R.A |= DT; + SET_ZN_FLAG(R.A); + } + + private void SHY() + { + DT = (byte)(R.Y & ((EA >> 8) + 1)); + } + + private void SHX() + { + DT = (byte)(R.X & ((EA >> 8) + 1)); + } + + private void SHS() + { + R.S = (byte)(R.A & R.X); + DT = (byte)(R.S & ((EA >> 8) + 1)); + } + + private void SHA() + { + DT = (byte)(R.A & R.X & ((EA >> 8) + 1)); + } + + private void SBX() + { + WT = (ushort)((R.A & R.X) - DT); + TST_FLAG(WT < 0x100, C_FLAG); + R.X = (byte)(WT & 0xFF); + SET_ZN_FLAG(R.X); + } + + private void SAX() + { + DT = (byte)(R.A & R.X); + } + + private void RRA() + { + if ((R.P & C_FLAG) != 0) + { + TST_FLAG((DT & 0x01) != 0, C_FLAG); + DT = (byte)((DT >> 1) | 0x80); + } + else + { + TST_FLAG((DT & 0x01) != 0, C_FLAG); + DT >>= 1; + } + ADC(); + } + + private void RLA() + { + if ((R.P & C_FLAG) != 0) + { + TST_FLAG((DT & 0x80) != 0, C_FLAG); + DT = (byte)((DT << 1) | 1); + } + else + { + TST_FLAG((DT & 0x80) != 0, C_FLAG); + DT <<= 1; + } + R.A &= DT; + SET_ZN_FLAG(R.A); + } + + private void LXA() + { + R.A = R.X = (byte)((R.A | 0xEE) & DT); + SET_ZN_FLAG(R.A); + } + + private void LAX() + { + R.A = DT; + R.X = R.A; + SET_ZN_FLAG(R.A); + } + + private void LAS() + { + R.A = R.X = R.S = (byte)(R.S & DT); + SET_ZN_FLAG(R.A); + } + + private void ISB() + { + DT++; + SBC(); + } + + private void DCP() + { + DT--; + CMP_(); + } + + private void ASR() + { + DT &= R.A; + TST_FLAG((DT & 0x01) != 0, C_FLAG); + R.A = (byte)(DT >> 1); + SET_ZN_FLAG(R.A); + } + + private void ARR() + { + DT &= R.A; + R.A = (byte)((DT >> 1) | ((R.P & C_FLAG) << 7)); + SET_ZN_FLAG(R.A); + TST_FLAG((R.A & 0x40) != 0, C_FLAG); + TST_FLAG(((R.A >> 6) ^ (R.A >> 5)) != 0, V_FLAG); + } + + private void ANE() + { + R.A = (byte)((R.A | 0xEE) & R.X & DT); + SET_ZN_FLAG(R.A); + } + + private void ANC() + { + R.A &= DT; + SET_ZN_FLAG(R.A); + TST_FLAG((R.P & N_FLAG) != 0, C_FLAG); + } + + private void BRK() + { + R.PC++; + PUSH((byte)(R.PC >> 8)); + PUSH((byte)(R.PC & 0xFF)); + SET_FLAG(B_FLAG); + PUSH(R.P); + SET_FLAG(I_FLAG); + R.PC = RD6502W(IRQ_VECTOR); + } + + private byte POP() + { + return STACK[(++R.S) & 0xFF]; + } + + private void PUSH(byte V) + { + STACK[(R.S--) & 0xFF] = V; + } + + private void SEI() + { + R.P |= I_FLAG; + } + + private void SED() + { + R.P |= D_FLAG; + } + + private void SEC() + { + R.P |= C_FLAG; + } + + private void CLV() + { + var temp = unchecked((byte)(~V_FLAG)); + R.P &= temp; + } + + private void CLI() + { + var temp = unchecked((byte)(~I_FLAG)); + R.P &= temp; + } + + private void CLD() + { + var temp = unchecked((byte)(~D_FLAG)); + R.P &= temp; + } + + private void CLC() + { + var temp = unchecked((byte)(~C_FLAG)); + R.P &= temp; + } + + private void RTS() + { + R.PC = POP(); + R.PC |= (ushort)(POP() * 0x0100); + R.PC++; + } + + private void RTI() + { + R.P = (byte)(POP() | R_FLAG); + R.PC = POP(); + R.PC |= (ushort)(POP() * 0x0100); + } + + private void JSR() + { + EA = OP6502W(R.PC); + R.PC++; + PUSH((byte)(R.PC >> 8)); + PUSH((byte)(R.PC & 0xFF)); + R.PC = EA; + } + + private void JMP_ID() + { + WT = OP6502W(R.PC); + EA = RD6502(WT); + WT = (ushort)((WT & 0xFF00) | ((WT + 1) & 0x00FF)); + R.PC = (ushort)(EA + RD6502(WT) * 0x100); + } + + private void JMP() + { + R.PC = OP6502W(R.PC); + } + + private void BVS() + { + if ((R.P & V_FLAG) != 0) + REL_JUMP(); + } + + private void REL_JUMP() + { + ET = R.PC; + EA = (ushort)(R.PC + (sbyte)DT); + R.PC = EA; + ADD_CYCLE(1); + CHECK_EA(); + } + + private void BVC() + { + if ((R.P & V_FLAG) == 0) REL_JUMP(); + } + + private void BPL() + { + if ((R.P & N_FLAG) == 0) REL_JUMP(); + } + + private void BNE() + { + if ((R.P & Z_FLAG) == 0) REL_JUMP(); + } + + private void BMI() + { + if ((R.P & N_FLAG) != 0) REL_JUMP(); + } + + private void BEQ() + { + if ((R.P & Z_FLAG) != 0) REL_JUMP(); + } + + private void BCS() + { + if ((R.P & C_FLAG) != 0) REL_JUMP(); + } + + private void BCC() + { + if ((R.P & C_FLAG) == 0) REL_JUMP(); + } + + private void CPY() + { + WT = (ushort)(R.Y - DT); + TST_FLAG((WT & 0x8000) == 0, C_FLAG); + SET_ZN_FLAG((byte)WT); + } + + private void CPX() + { + WT = (ushort)(R.X - DT); + TST_FLAG((WT & 0x8000) == 0, C_FLAG); + SET_ZN_FLAG((byte)WT); + } + + private void CMP_() + { + WT = (ushort)(R.A - DT); + TST_FLAG((WT & 0x8000) == 0, C_FLAG); + SET_ZN_FLAG((byte)WT); + } + + private void TXS() + { + R.S = R.X; + } + + private void TSX() + { + R.X = R.S; SET_ZN_FLAG(R.X); + } + + private void TYA() + { + R.A = R.Y; SET_ZN_FLAG(R.A); + } + + private void TAY() + { + R.Y = R.A; SET_ZN_FLAG(R.Y); + } + + private void TXA() + { + R.A = R.X; SET_ZN_FLAG(R.A); + } + + private void TAX() + { + R.X = R.A; SET_ZN_FLAG(R.X); + } + + private void STY() + { + DT = R.Y; + } + + private void EA_ZY() + { + DT = OP6502(R.PC++); + EA = (byte)(DT + R.Y); + } + + private void STX() + { + DT = R.X; + } + + private void EA_IY() + { + DT = OP6502(R.PC++); + ET = ZPRDW(DT); + EA = (ushort)(ET + R.Y); + } + + private void EA_IX() + { + DT = OP6502(R.PC++); + EA = ZPRDW(DT + R.X); + } + + private void EA_AY() + { + ET = OP6502W(R.PC); + R.PC += 2; + EA = (ushort)(ET + R.Y); + } + + private void EA_AX() + { + ET = OP6502W(R.PC); + R.PC += 2; + EA = (ushort)(ET + R.X); + } + + private void EA_AB() + { + EA = OP6502W(R.PC); + R.PC += 2; + } + + private void EA_ZX() + { + DT = OP6502(R.PC++); + EA = (byte)(DT + R.X); + } + + private void STA() + { + DT = R.A; + } + + private void EA_ZP() + { + EA = OP6502(R.PC++); + } + + private void LDY() + { + R.Y = DT; SET_ZN_FLAG(R.Y); + } + + private void MR_ZY() + { + DT = OP6502(R.PC++); + EA = (byte)(DT + R.Y); + DT = ZPRD(EA); + } + + private void LDX() + { + R.X = DT; SET_ZN_FLAG(R.X); + } + + private void LDA() + { + R.A = DT; SET_ZN_FLAG(R.A); + } + + private void ROR() + { + if ((R.P & C_FLAG) != 0) + { + TST_FLAG((DT & 0x01) != 0, C_FLAG); + DT = (byte)((DT >> 1) | 0x80); + } + else + { + TST_FLAG((DT & 0x01) != 0, C_FLAG); + DT >>= 1; + } + SET_ZN_FLAG(DT); + } + + private void ROR_A() + { + if ((R.P & C_FLAG) != 0) + { + TST_FLAG((R.A & 0x01) != 0, C_FLAG); + R.A = (byte)((R.A >> 1) | 0x80); + } + else + { + TST_FLAG((R.A & 0x01) != 0, C_FLAG); + R.A >>= 1; + } + SET_ZN_FLAG(R.A); + } + + private void ROL() + { + if ((R.P & C_FLAG) != 0) + { + TST_FLAG((DT & 0x80) != 0, C_FLAG); + DT = (byte)((DT << 1) | 0x01); + } + else + { + TST_FLAG((DT & 0x80) != 0, C_FLAG); + DT <<= 1; + } + SET_ZN_FLAG(DT); + } + + private void ROL_A() + { + if ((R.P & C_FLAG) != 0) + { + TST_FLAG((R.A & 0x80) != 0, C_FLAG); + R.A = (byte)((R.A << 1) | 0x01); + } + else + { + TST_FLAG((R.A & 0x80) != 0, C_FLAG); + R.A <<= 1; + } + SET_ZN_FLAG(R.A); + } + + private void ORA() + { + R.A |= DT; + SET_ZN_FLAG(R.A); + } + + private void LSR_A() + { + TST_FLAG((R.A & 0x01) != 0, C_FLAG); + R.A >>= 1; + SET_ZN_FLAG(R.A); + } + + private void LSR() + { + TST_FLAG((DT & 0x01) != 0, C_FLAG); + DT >>= 1; + SET_ZN_FLAG(DT); + } + + private void EOR() + { + R.A ^= DT; + SET_ZN_FLAG(R.A); + } + + internal void SetClockProcess(bool bEnable) + { + m_bClockProcess = bEnable; + } + + internal byte OP6502(ushort addr) + { + return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + + private byte[] shortTemp = new byte[2]; + internal ushort OP6502W(ushort addr) + { + var bytePage = MMU.CPU_MEM_BANK[addr >> 13]; + var spanByte = bytePage; + shortTemp[0] = spanByte[addr & 0x1FFF]; + shortTemp[1] = spanByte[(addr & 0x1FFF) + 1]; + return BitConverter.ToUInt16(shortTemp, 0); + } + + internal byte RD6502(ushort addr) + { + if (addr < 0x2000) + { + // RAM (Mirror $0800, $1000, $1800) + return MMU.RAM[addr & 0x07FF]; + } + else if (addr < 0x8000) + { + // Others + return nes.Read(addr); + } + else + { + // Dummy access + mapper.Read(addr, MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]); + } + + // Quick bank read + return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + + private void AND() + { + R.A &= DT; + SET_ZN_FLAG(R.A); + } + + private void MR_IM() + { + DT = OP6502(R.PC++); + } + + private void BIT() + { + TST_FLAG((DT & R.A) == 0, Z_FLAG); + TST_FLAG((DT & 0x80) != 0, N_FLAG); + TST_FLAG((DT & 0x40) != 0, V_FLAG); + } + + private void MR_ZP() + { + EA = OP6502(R.PC++); + DT = ZPRD(EA); + } + + private byte ZPRD(ushort A) + { + return MMU.RAM[A]; + } + + private ushort ZPRDW(int A) + { + ushort ram1 = MMU.RAM[A]; + ushort ram2 = MMU.RAM[A + 1]; + ram2 <<= 8; + return (ushort)(ram1 + ram2); + } + + private void ADC() + { + WT = (ushort)(R.A + DT + (R.P & C_FLAG)); + TST_FLAG(WT > 0xFF, C_FLAG); + var temp = ((~(R.A ^ DT)) & (R.A ^ WT) & 0x80); + TST_FLAG(temp != 0, V_FLAG); + R.A = (byte)WT; + SET_ZN_FLAG(R.A); + } + + private void TST_FLAG(bool F, byte V) + { + byte temp = (byte)~V; + R.P &= temp; + + if (F) R.P |= V; + } + + private void SET_ZN_FLAG(byte A) + { + byte temp = unchecked((byte)(~(Z_FLAG | N_FLAG))); + R.P &= temp; + R.P |= ZN_Table[A]; + } + + private void ADD_CYCLE(int V) + { + exec_cycles += V; + } + + private void MR_ZX() + { + DT = OP6502(R.PC++); + EA = (ushort)(DT + R.X); + DT = ZPRD(EA); + } + + private void MR_AB() + { + EA = OP6502W(R.PC); + R.PC += 2; + DT = RD6502(EA); + } + + private void MR_AX() + { + ET = OP6502W(R.PC); + R.PC += 2; + EA = (ushort)(ET + R.X); + DT = RD6502(EA); + } + + private void CHECK_EA() + { + if ((ET & 0xFF00) != (EA & 0xFF00)) ADD_CYCLE(1); + } + + private void MR_AY() + { + ET = OP6502W(R.PC); + R.PC += 2; + EA = (ushort)(ET + R.Y); + DT = RD6502(EA); + } + + private void MR_IX() + { + DT = OP6502(R.PC++); + EA = ZPRDW(DT + R.X); + DT = RD6502(EA); + } + + private void MR_IY() + { + DT = OP6502(R.PC++); + ET = ZPRDW(DT); + EA = (ushort)(ET + R.Y); + DT = RD6502(EA); + } + private void ASL_A() + { + TST_FLAG((R.A & 0x80) != 0, C_FLAG); + R.A <<= 1; + SET_ZN_FLAG(R.A); + } + + private void ASL() + { + TST_FLAG((DT & 0x80) != 0, C_FLAG); + DT <<= 1; + SET_ZN_FLAG(DT); + } + + private void SBC() + { + WT = (ushort)(R.A - DT - (~R.P & C_FLAG)); + bool f = ((R.A ^ DT) & (R.A ^ WT) & (0x80)) != 0; + TST_FLAG(f, V_FLAG); + TST_FLAG(WT < 0x100, C_FLAG); + R.A = (byte)WT; + SET_ZN_FLAG(R.A); + } + + private void DEC() + { + DT--; + SET_ZN_FLAG(DT); + } + + private void DEX() + { + R.X--; + SET_ZN_FLAG(R.X); + } + + private void DEY() + { + R.Y--; + SET_ZN_FLAG(R.Y); + } + + private void INC() + { + DT++; + SET_ZN_FLAG(DT); + } + + private void INX() + { + R.X++; + SET_ZN_FLAG(R.X); + } + + private void INY() + { + R.Y++; + SET_ZN_FLAG(R.Y); + } + + private void MW_ZP() + { + ZPWR(EA, DT); + } + + private void ZPWR(ushort a, byte v) + { + MMU.RAM[a] = v; + } + + private void MW_EA() + { + WR6502(EA, DT); + } + + internal void ClrIRQ(byte mask) + { + byte temp = (byte)~mask; + R.INT_pending &= temp; + } + + internal void WR6502(ushort addr, byte data) + { + if (addr < 0x2000) + { + // RAM (Mirror $0800, $1000, $1800) + MMU.RAM[addr & 0x07FF] = data; + } + else + { + // Others + nes.Write(addr, data); + } + } + + internal void NMI() + { + R.INT_pending |= NMI_FLAG; + nmicount = 0; + } + + internal void SetIRQ(byte mask) + { + R.INT_pending |= mask; + } + + internal int GetTotalCycles() + { + return TOTAL_cycles; + } + + internal void DMA(int cycles) + { + DMA_cycles += cycles; + } + + internal void Reset() + { + apu = nes.apu; + mapper = nes.mapper; + + R.A = 0x00; + R.X = 0x00; + R.Y = 0x00; + R.S = 0xFF; + R.P = Z_FLAG | R_FLAG; + R.PC = RD6502W(RES_VECTOR); + + R.INT_pending = 0; + + TOTAL_cycles = 0; + DMA_cycles = 0; + + // STACK quick access + STACK = new ByteArrayRef(MMU.RAM, 0x0100, MMU.RAM.Length - 0x100); + + // Zero/Negative FLAG + ZN_Table[0] = Z_FLAG; + for (int i = 1; i < 256; i++) + ZN_Table[i] = (byte)((i & 0x80) != 0 ? N_FLAG : 0); + } + + internal void GetContext(ref R6502 r) + { + r = R; + } + } + + public enum StatusFlag6502 : int + { + C_FLAG = 0x01, + Z_FLAG = 0x02, + I_FLAG = 0x04, + D_FLAG = 0x08, + B_FLAG = 0x10, + R_FLAG = 0x20, + V_FLAG = 0x40, + N_FLAG = 0x80 + } + + public enum Interrupt : int + { + NMI_FLAG = 0x01, + IRQ_FLAG = 0x02, + IRQ_FRAMEIRQ = 0x04, + IRQ_DPCM = 0x08, + IRQ_MAPPER = 0x10, + IRQ_MAPPER2 = 0x20, + IRQ_TRIGGER = 0x40, + IRQ_TRIGGER2 = 0x80, + IRQ_MASK = (~(NMI_FLAG | IRQ_FLAG)), + } + + public enum Vector : int + { + NMI_VECTOR = 0xFFFA, + RES_VECTOR = 0xFFFC, + IRQ_VECTOR = 0xFFFE + } + + public class R6502 + { + public ushort PC; + public byte A; + public byte P; + public byte X; + public byte Y; + public byte S; + + public byte INT_pending; + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CPU.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CPU.cs.meta new file mode 100644 index 0000000..c59b49a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CPU.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 055e668755423bf4dabeb6cc007bce76 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Cheat.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Cheat.cs new file mode 100644 index 0000000..5778026 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Cheat.cs @@ -0,0 +1,36 @@ +namespace VirtualNes.Core +{ + public class CHEATCODE + { + // 埲壓åºä¿€å®å¼OR儅僗僋 + public const int CHEAT_ENABLE = 1 << 0; + public const int CHEAT_KEYDISABLE = 1 << 1; + + // 彂å’崬傒庬椶 + public const int CHEAT_TYPE_ALWAYS = 0; // å¿¢åµå½‚å’崬傒 + public const int CHEAT_TYPE_ONCE = 1; // 侾夞å©å—彂å’崬傒 + public const int CHEAT_TYPE_GREATER = 2; // 僨乕僞傛å‚æˆå’å„帪 + public const int CHEAT_TYPE_LESS = 3; // 僨乕僞傛å‚彫åå„帪 + + // 僨乕僞挿 + public const int CHEAT_LENGTH_1BYTE = 0; + public const int CHEAT_LENGTH_2BYTE = 1; + public const int CHEAT_LENGTH_3BYTE = 2; + public const int CHEAT_LENGTH_4BYTE = 3; + + public byte enable; + public byte type; + public byte length; + public ushort address; + public uint data; + + public string comment; + } + + class GENIECODE + { + public ushort address; + public byte data; + public byte cmp; + }; +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Cheat.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Cheat.cs.meta new file mode 100644 index 0000000..6f40389 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Cheat.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5494fe2d7f568c5498880bcb5625e21e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs.meta new file mode 100644 index 0000000..7a2e409 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b37fc906e6cec64eb2608762f7f80bf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ByteArrayRef.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ByteArrayRef.cs new file mode 100644 index 0000000..a2327d6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ByteArrayRef.cs @@ -0,0 +1,59 @@ +using System; + +namespace VirtualNes.Core +{ + public class ByteArrayRef + { + private byte[] m_rawArray; + private int m_offset; + private int m_length; + + public int Offset + { + get => m_offset; + set + { + var gap = value - m_offset; + m_length -= gap; + } + } + + public ByteArrayRef() { } + public ByteArrayRef(byte[] array, int offset, int length) + { + SetArray(array, offset, length); + } + + public ByteArrayRef(byte[] array) : this(array, 0, array.Length) { } + public ByteArrayRef(byte[] array, int offset) : this(array, offset, array.Length - offset) { } + + public void SetArray(byte[] array, int offset, int length) + { + m_rawArray = array; + m_offset = offset; + m_length = length; + } + + public byte this[int index] + { + get + { + return m_rawArray[m_offset + index]; + } + set + { + m_rawArray[(m_offset + index)] = value; + } + } + + public static implicit operator ByteArrayRef(byte[] array) + { + return new ByteArrayRef(array); + } + + public static implicit operator Span(ByteArrayRef array) + { + return new Span(array.m_rawArray, array.Offset, array.m_length); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ByteArrayRef.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ByteArrayRef.cs.meta new file mode 100644 index 0000000..eba7e42 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ByteArrayRef.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe59f85b299db6f498a7e87a5125df58 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/CRC.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/CRC.cs new file mode 100644 index 0000000..c6dfd65 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/CRC.cs @@ -0,0 +1,87 @@ +using System; + +namespace VirtualNes.Core +{ + public static class CRC + { + const int CHAR_BIT = 8; + const uint CRCPOLY1 = 0x04C11DB7U; + const uint CRCPOLY2 = 0xEDB88320U; + + static bool m_Init; + static bool m_InitRev; + static uint[] m_CrcTable = new uint[byte.MaxValue + 1]; + static uint[] m_CrcTableRev = new uint[byte.MaxValue + 1]; + + public static ulong Crc(int size, Span c) + { + if (!m_Init) + { + MakeTable(); + m_Init = true; + } + + ulong r = 0xFFFFFFFFUL; + int step = 0; + while (--size >= 0) + { + r = (r << CHAR_BIT) ^ m_CrcTable[(byte)(r >> (32 - CHAR_BIT)) ^ c[step]]; + step++; + } + return ~r & 0xFFFFFFFFUL; + } + public static uint CrcRev(int size, Span c) + { + if (!m_InitRev) + { + MakeTableRev(); + m_InitRev = true; + } + + uint r = 0xFFFFFFFFU; + int step = 0; + while (--size >= 0) + { + r = (r >> CHAR_BIT) ^ m_CrcTableRev[(byte)r ^ c[step]]; + step++; + } + return r ^ 0xFFFFFFFFU; + } + + static void MakeTable() + { + int i, j; + uint r; + + for (i = 0; i <= byte.MaxValue; i++) + { + r = (uint)i << (32 - CHAR_BIT); + for (j = 0; j < CHAR_BIT; j++) + { + if ((r & 0x80000000UL) > 0) r = (r << 1) ^ CRCPOLY1; + else r <<= 1; + } + m_CrcTable[i] = r & 0xFFFFFFFFU; + } + + } + static void MakeTableRev() + { + int i, j; + uint r; + + for (i = 0; i <= byte.MaxValue; i++) + { + r = (uint)i; + for (j = 0; j < CHAR_BIT; j++) + { + if ((r & 1) > 0) r = (r >> 1) ^ CRCPOLY2; + else r >>= 1; + } + m_CrcTableRev[i] = r; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/CRC.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/CRC.cs.meta new file mode 100644 index 0000000..e8aecd4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/CRC.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1939f721bc0cab42add18338dbff333 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/Emu2413.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/Emu2413.cs new file mode 100644 index 0000000..964fa3b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/Emu2413.cs @@ -0,0 +1,145 @@ +using System; + +namespace VirtualNes.Core +{ + public class OPLL_PATCH + { + public uint TL, FB, EG, ML, AR, DR, SL, RR, KR, KL, AM, PM, WF; + } + + public class OPLL_SLOT + { + public OPLL_PATCH patch; + + public int type; /* 0 : modulator 1 : carrier */ + + /* OUTPUT */ + public Int32 feedback; + public Int32[] output = new Int32[5]; /* Output value of slot */ + + /* for Phase Generator (PG) */ + public UInt32 sintbl; /* Wavetable */ + public UInt32 phase; /* Phase */ + public UInt32 dphase; /* Phase increment amount */ + public UInt32 pgout; /* output */ + + /* for Envelope Generator (EG) */ + public int fnum; /* F-Number */ + public int block; /* Block */ + public int volume; /* Current volume */ + public int sustine; /* Sustine 1 = ON, 0 = OFF */ + public UInt32 tll; /* Total Level + Key scale level*/ + public UInt32 rks; /* Key scale offset (Rks) */ + public int eg_mode; /* Current state */ + public UInt32 eg_phase; /* Phase */ + public UInt32 eg_dphase; /* Phase increment amount */ + public UInt32 egout; /* output */ + + + /* refer to opll-> */ + public UInt32 plfo_pm; + public UInt32 plfo_am; + } + + public class OPLL_CH + { + public int patch_number; + public int key_status; + public OPLL_SLOT mod; + public OPLL_SLOT car; + } + + public class OPLL + { + public UInt32 adr; + public Int32[] output = new Int32[2]; + + /* Register */ + public byte[] reg = new byte[0x40]; + public int[] slot_on_flag = new int[18]; + + /* Rythm Mode : 0 = OFF, 1 = ON */ + public int rythm_mode; + + /* Pitch Modulator */ + public UInt32 pm_phase; + public Int32 lfo_pm; + + /* Amp Modulator */ + public Int32 am_phase; + public Int32 lfo_am; + + /* Noise Generator */ + public UInt32 noise_seed; + public UInt32 whitenoise; + public UInt32 noiseA; + public UInt32 noiseB; + public UInt32 noiseA_phase; + public UInt32 noiseB_phase; + public UInt32 noiseA_idx; + public UInt32 noiseB_idx; + public UInt32 noiseA_dphase; + public UInt32 noiseB_dphase; + } + + public static class Emu2413API + { + public static void OPLL_init(UInt32 c, UInt32 r) + { + makePmTable(); + makeAmTable(); + makeDB2LinTable(); + makeAdjustTable(); + makeTllTable(); + makeRksTable(); + makeSinTable(); + makeDefaultPatch(); + OPLL_setClock(c, r); + } + + private static void OPLL_setClock(uint c, uint r) + { + throw new NotImplementedException(); + } + + private static void makeDefaultPatch() + { + throw new NotImplementedException(); + } + + private static void makeSinTable() + { + throw new NotImplementedException(); + } + + private static void makeRksTable() + { + throw new NotImplementedException(); + } + + private static void makeTllTable() + { + throw new NotImplementedException(); + } + + private static void makeAdjustTable() + { + throw new NotImplementedException(); + } + + private static void makeDB2LinTable() + { + throw new NotImplementedException(); + } + + private static void makeAmTable() + { + throw new NotImplementedException(); + } + + private static void makePmTable() + { + throw new NotImplementedException(); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/Emu2413.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/Emu2413.cs.meta new file mode 100644 index 0000000..c25181d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/Emu2413.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f5ecddbb6b69204478d799a484d8c47c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/EnumRenderMethod.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/EnumRenderMethod.cs new file mode 100644 index 0000000..ae8adf4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/EnumRenderMethod.cs @@ -0,0 +1,12 @@ +namespace VirtualNes.Core +{ + // 昤夋曽幃 + public enum EnumRenderMethod + { + POST_ALL_RENDER = 0, // 僗僉å„儞儔僀儞暘åºæŸ¦æ¤·å¹šå³´å±»ä¸†å„—儞僟儕儞僌 + PRE_ALL_RENDER = 1, // 儗儞僟儕儞僌åºå¹šå³´å±»ä¸†åƒ—僉å„儞儔僀儞暘åºæŸ¦æ¤·å¹šå³´ + POST_RENDER = 2, // 昞帵婜娫暘åºæŸ¦æ¤·å¹šå³´å±»ä¸†å„—儞僟儕儞僌 + PRE_RENDER = 3, // 儗儞僟儕儞僌幚峴屻丆昞帵婜娫暘åºæŸ¦æ¤·å¹šå³´ + TILE_RENDER = 4 // 僞僀儖儀乕僗儗儞僟儕儞僌 + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/EnumRenderMethod.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/EnumRenderMethod.cs.meta new file mode 100644 index 0000000..396fe6d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/EnumRenderMethod.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c379fb6535bd23449474dee5018652c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ISoundDataBuffer.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ISoundDataBuffer.cs new file mode 100644 index 0000000..7994134 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ISoundDataBuffer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VirtualNes.Core +{ + public interface ISoundDataBuffer + { + void WriteByte(byte value); + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ISoundDataBuffer.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ISoundDataBuffer.cs.meta new file mode 100644 index 0000000..71ba7b0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ISoundDataBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4585a754599519b48bfe50294600818f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/MemoryUtility.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/MemoryUtility.cs new file mode 100644 index 0000000..691ec13 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/MemoryUtility.cs @@ -0,0 +1,30 @@ +using System; +using System.Runtime.CompilerServices; + +namespace VirtualNes.Core +{ + public static class MemoryUtility + { + public static void ZEROMEMORY(byte[] array, int length) + { + Array.Clear(array, 0, array.Length); + } + public static void ZEROMEMORY(int[] array, int length) + { + Array.Clear(array, 0, array.Length); + } + + public static void memset(byte[] array, byte value, int length) + { + memset(array, 0, value, length); + } + + public static void memset(byte[] array, int offset, byte value, int length) + { + for (int i = offset; i < length; i++) + { + array[i] = value; + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/MemoryUtility.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/MemoryUtility.cs.meta new file mode 100644 index 0000000..a9afc7a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/MemoryUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8586eb710dc81124593eb5adfa08d73b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NESCOMMAND.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NESCOMMAND.cs new file mode 100644 index 0000000..e6ed2f8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NESCOMMAND.cs @@ -0,0 +1,23 @@ +namespace VirtualNes.Core +{ + public enum NESCOMMAND + { + NESCMD_NONE = 0, + NESCMD_HWRESET, + NESCMD_SWRESET, + NESCMD_EXCONTROLLER, // Commandparam + NESCMD_DISK_THROTTLE_ON, + NESCMD_DISK_THROTTLE_OFF, + NESCMD_DISK_EJECT, + NESCMD_DISK_0A, + NESCMD_DISK_0B, + NESCMD_DISK_1A, + NESCMD_DISK_1B, + NESCMD_DISK_2A, + NESCMD_DISK_2B, + NESCMD_DISK_3A, + NESCMD_DISK_3B, + + NESCMD_SOUND_MUTE, // CommandParam + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NESCOMMAND.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NESCOMMAND.cs.meta new file mode 100644 index 0000000..db767eb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NESCOMMAND.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d7e8126382c9728429056ba33afc85eb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NesConfig.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NesConfig.cs new file mode 100644 index 0000000..b23149f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NesConfig.cs @@ -0,0 +1,51 @@ +namespace VirtualNes.Core +{ + public class NesConfig + { + public float BaseClock; // NTSC:21477270.0 PAL:21281364.0 + public float CpuClock; // NTSC: 1789772.5 PAL: 1773447.0 + + public int TotalScanlines; // NTSC: 262 PAL: 312 + + public int ScanlineCycles; // NTSC:1364 PAL:1362 + + public int HDrawCycles; // NTSC:1024 PAL:1024 + public int HBlankCycles; // NTSC: 340 PAL: 338 + public int ScanlineEndCycles; // NTSC: 4 PAL: 2 + + public int FrameCycles; // NTSC:29829.52 PAL:35468.94 + public int FrameIrqCycles; // NTSC:29829.52 PAL:35468.94 + + public int FrameRate; // NTSC:60(59.94) PAL:50 + public float FramePeriod; // NTSC:16.683 PAL:20.0 + + public static NesConfig NESCONFIG_NTSC = new NesConfig + { + BaseClock = 21477270.0f, + CpuClock = 1789772.5f, + TotalScanlines = 262, + ScanlineCycles = 1364, + HDrawCycles = 1024, + HBlankCycles = 340, + ScanlineEndCycles = 4, + FrameCycles = 1364 * 262, + FrameIrqCycles = 29830, + FrameRate = 60, + FramePeriod = 1000.0f / 60.0f + }; + public static NesConfig NESCONFIG_PAL = new NesConfig + { + BaseClock = 26601714.0f, + CpuClock = 1662607.125f, + TotalScanlines = 312, + ScanlineCycles = 1278, + HDrawCycles = 960, + HBlankCycles = 318, + ScanlineEndCycles = 2, + FrameCycles = 1278 * 312, + FrameIrqCycles = 33252, + FrameRate = 50, + FramePeriod = 1000.0f / 50.0f + }; + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NesConfig.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NesConfig.cs.meta new file mode 100644 index 0000000..d583d21 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/NesConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4865f8871b37b0041b77060cf3c62664 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ROMClasses.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ROMClasses.cs new file mode 100644 index 0000000..bf81c40 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ROMClasses.cs @@ -0,0 +1,140 @@ +using System; + +namespace VirtualNes.Core +{ + public enum EnumRomControlByte1 : byte + { + ROM_VMIRROR = 0x01, + ROM_SAVERAM = 0x02, + ROM_TRAINER = 0x04, + ROM_4SCREEN = 0x08, + } + + public enum EnumRomControlByte2 : byte + { + ROM_VSUNISYSTEM = 0x01 + } + + public enum EnumRomType + { + InValid, + NES, + /// Nintendo Disk System + FDS, + NSF + } + + public class NSFHEADER + { + byte[] ID; + byte Version; + byte TotalSong; + byte StartSong; + ushort LoadAddress; + ushort InitAddress; + ushort PlayAddress; + byte[] SongName; + byte[] ArtistName; + byte[] CopyrightName; + ushort SpeedNTSC; + byte[] BankSwitch; + ushort SpeedPAL; + byte NTSC_PALbits; + public byte ExtraChipSelect; + byte[] Expansion; // must be 0 + + + public static int SizeOf() + { + return 128; + } + + public static NSFHEADER GetDefault() + { + var res = new NSFHEADER(); + res.ID = new byte[5]; + res.SongName = new byte[32]; + res.ArtistName = new byte[32]; + res.CopyrightName = new byte[32]; + res.BankSwitch = new byte[8]; + res.Expansion = new byte[4]; + return res; + } + } + + public class NESHEADER + { + public byte[] ID; + public byte PRG_PAGE_SIZE; + public byte CHR_PAGE_SIZE; + public byte control1; + public byte control2; + public byte[] reserved; + + public bool CheckValid() + { + return GetRomType() != EnumRomType.InValid; + } + + public static int SizeOf() + { + return 16; + } + + public EnumRomType GetRomType() + { + if (ID[0] == 'N' && ID[1] == 'E' && ID[2] == 'S' && ID[3] == 0x1A) + return EnumRomType.NES; + if (ID[0] == 'F' && ID[1] == 'D' && ID[2] == 'S' && ID[3] == 0x1A) + return EnumRomType.FDS; + if (ID[0] == 'N' && ID[1] == 'E' && ID[2] == 'S' && ID[3] == 'M') + return EnumRomType.NSF; + + return EnumRomType.InValid; + } + + public static NESHEADER GetDefault() + { + var res = new NESHEADER(); + res.ID = new byte[4]; + res.reserved = new byte[8]; + return res; + } + + public static NESHEADER Read(Span data) + { + var res = new NESHEADER(); + res.ID = data.Slice(0, 4).ToArray(); + res.PRG_PAGE_SIZE = data[4]; + res.CHR_PAGE_SIZE = data[5]; + res.control1 = data[6]; + res.control2 = data[7]; + res.reserved = data.Slice(8, 8).ToArray(); + + return res; + } + + public byte[] DataToBytes() + { + byte[] res = new byte[16]; + res[0] = ID[0]; + res[1] = ID[1]; + res[2] = ID[2]; + res[3] = ID[3]; + res[4] = PRG_PAGE_SIZE; + res[5] = CHR_PAGE_SIZE; + res[6] = control1; + res[7] = control2; + res[8] = reserved[0]; + res[9] = reserved[1]; + res[10] = reserved[2]; + res[11] = reserved[3]; + res[12] = reserved[4]; + res[13] = reserved[5]; + res[14] = reserved[6]; + res[15] = reserved[7]; + + return res; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ROMClasses.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ROMClasses.cs.meta new file mode 100644 index 0000000..da4c0eb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/ROMClasses.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65b1ea91f79171f4f82ab91106909f86 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/RomPatch.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/RomPatch.cs new file mode 100644 index 0000000..ec9e03a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/RomPatch.cs @@ -0,0 +1,426 @@ +namespace VirtualNes.Core +{ + public static class RomPatch + { + public static void DoPatch(ref uint crc, ref byte[] lpPRG, ref byte[] lpCHR, ref int mapper, ref NESHEADER header) + { + // Mapper 000 + if (crc == 0x57970078) + { // F-1 Race(J) + lpPRG[0x078C] = 0x6C; + lpPRG[0x3FE1] = 0xFF; + lpPRG[0x3FE6] = 0x00; + } + if (crc == 0xaf2bbcbc // Mach Rider(JU) + || crc == 0x3acd4bf1 // Mach Rider(Alt)(JU) –³—–î—ƒpƒbƒ`(^^; + || crc == 0x8bbe9bec) + { + lpPRG[0x090D] = 0x6E; + lpPRG[0x7FDF] = 0xFF; + lpPRG[0x7FE4] = 0x00; + + header.control1 = (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + if (crc == 0xe16bb5fe) + { // Zippy Race(J) + header.control1 &= 0xf6; + } + if (crc == 0x85534474) + { // Lode Runner(J) + lpPRG[0x29E9] = 0xEA; // ƒZ[ƒuƒƒjƒ…[‚ðo‚·ƒpƒbƒ` + lpPRG[0x29EA] = 0xEA; + lpPRG[0x29F8] = 0xEA; + lpPRG[0x29F9] = 0xEA; + } + + // Mapper 001 + if (crc == 0x7831b2ff // America Daitouryou Senkyo(J) + || crc == 0x190a3e11 // Be-Bop-Highschool - Koukousei Gokuraku Densetsu(J) + || crc == 0x52449508 // Home Run Nighter - Pennant League!!(J) + || crc == 0x0973f714 // Jangou(J) + || crc == 0x7172f3d4 // Kabushiki Doujou(J) + || crc == 0xa5781280 // Kujaku Ou 2(J) + || crc == 0x8ce9c87b // Money Game, The(J) + || crc == 0xec47296d // Morita Kazuo no Shougi(J) + || crc == 0xcee5857b // Ninjara Hoi!(J) + || crc == 0xe63d9193 // Tanigawa Kouji no Shougi Shinan 3(J) + || crc == 0xd54f5da9 // Tsuppari Wars(J) + || crc == 0x1e0c7ea3) + { // AD&D Dragons of Flame(J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + if (crc == 0x1995ac4e) + { // Ferrari Grand Prix Challenge(J) –³—–î—ƒpƒbƒ`(^^; + lpPRG[0x1F7AD] = 0xFF; + lpPRG[0x1F7BC] = 0x00; + } + + if (crc == 0x20d22251) + { // Top rider(J) –³—–î—ƒpƒbƒ`(^^; + lpPRG[0x1F17E] = 0xEA; + lpPRG[0x1F17F] = 0xEA; + } + + if (crc == 0x11469ce3) + { // Viva! Las Vegas(J) –³—–î—ƒpƒbƒ`(^^; + lpCHR[0x0000] = 0x01; + } + + if (crc == 0x3fccdc7b) + { // Baseball Star - Mezase Sankanou!!(J) –³—–î—ƒpƒbƒ`(^^; + lpPRG[0x0F666] = 0x9D; + } + + if (crc == 0xdb564628) + { // Mario Open Golf(J) + lpPRG[0x30195] = 0xC0; + } + + // Mapper 002 + if (crc == 0x63af202f) + { // JJ - Tobidase Daisakusen Part 2(J) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + if (crc == 0x99a62e47) + { // Black Bass 2, The(J) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + if (crc == 0x0eaa7515 // Rod Land(J) + || crc == 0x22ab9694) + { // Rod Land(E) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + if (crc == 0x2061772a) + { // Tantei Jinguji Taburou Tokino Sugiyukumamani (J) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + // Mapper 003 + if (crc == 0x29401686) + { // Minna no Taabou no Nakayoshi Dai Sakusen(J) + // lpPRG[0x2B3E] = 0x60; + } + if (crc == 0x932a077a) + { // TwinBee(J) + mapper = 87; + } + if (crc == 0x8218c637) + { // Space Hunter(J) + // header.control1 &= 0xf6; + // header.control1 |= ROM_4SCREEN; + header.control1 = (byte)EnumRomControlByte1.ROM_VMIRROR; + } + if (crc == 0x2bb6a0f8 // Sherlock Holmes - Hakushaku Reijou Yuukai Jiken(J) + || crc == 0x28c11d24 // Sukeban Deka 3(J) + || crc == 0x02863604) + { // Sukeban Deka 3(J)(Alt) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + // Mapper 004 + if (crc == 0x58581770) + { // Rasaaru Ishii no Childs Quest(J) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + if (crc == 0xf3feb3ab // Kunio Kun no Jidaigeki Dayo Zenin Shuugou! (J) + || crc == 0xa524ae9b // Otaku no Seiza - An Adventure in the Otaku Galaxy (J) + || crc == 0x46dc6e57 // SD Gundam - Gachapon Senshi 2 - Capsule Senki (J) + || crc == 0x66b2dec7 // SD Gundam - Gachapon Senshi 3 - Eiyuu Senki (J) + || crc == 0x92b07fd9 // SD Gundam - Gachapon Senshi 4 - New Type Story (J) + || crc == 0x8ee6463a // SD Gundam - Gachapon Senshi 5 - Battle of Universal Century (J) + || crc == 0xaf754426 // Ultraman Club 3 (J) + || crc == 0xfe4e5b11 // Ushio to Tora - Shinen no Daiyou (J) + || crc == 0x57c12c17) + { // Yamamura Misa Suspense - Kyouto Zaiteku Satsujin Jiken (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + if (crc == 0x42e03e4a) + { // RPG Jinsei Game (J) + mapper = 118; + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + if (crc == 0xfd0299c3) + { // METAL MAX(J) + lpPRG[0x3D522] = 0xA9; + lpPRG[0x3D523] = 0x19; + } + if (crc == 0x1d2e5018 // Rockman 3(J) + || crc == 0x6b999aaf) + { // Mega Man 3(U) + // lpPRG[0x3C179] = 0xBA;// + // lpPRG[0x3C9CC] = 0x9E; + } + + // Mapper 005 + if (crc == 0xe91548d8) + { // Shin 4 Nin Uchi Mahjong - Yakuman Tengoku (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + if (crc == 0x255b129c) + { // Gun Sight (J) / Gun Sight (J)[a1] + lpPRG[0x02D0B] = 0x01; + lpPRG[0x0BEC0] = 0x01; + } + + + // Mapper 010 + if (crc == 0xc9cce8f2) + { // Famicom Wars (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 016 + if (crc == 0x983d8175 // Datach - Battle Rush - Build Up Robot Tournament (J) + || crc == 0x894efdbc // Datach - Crayon Shin Chan - Ora to Poi Poi (J) + || crc == 0x19e81461 // Datach - Dragon Ball Z - Gekitou Tenkaichi Budou Kai (J) + || crc == 0xbe06853f // Datach - J League Super Top Players (J) + || crc == 0x0be0a328 // Datach - SD Gundam - Gundam Wars (J) + || crc == 0x5b457641 // Datach - Ultraman Club - Supokon Fight! (J) + || crc == 0xf51a7f46 // Datach - Yuu Yuu Hakusho - Bakutou Ankoku Bujutsu Kai (J) + || crc == 0x31cd9903 // Dragon Ball Z - Kyoushuu! Saiya Jin (J) + || crc == 0xe49fc53e // Dragon Ball Z 2 - Gekishin Freeza!! (J) + || crc == 0x09499f4d // Dragon Ball Z 3 - Ressen Jinzou Ningen (J) + || crc == 0x2e991109 // Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (J) + || crc == 0x170250de) + { // Rokudenashi Blues(J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 019 + if (crc == 0x3296ff7a // Battle Fleet (J) + || crc == 0x429fd177 // Famista '90 (J) + || crc == 0xdd454208 // Hydlide 3 - Yami Kara no Houmonsha (J) + || crc == 0xb1b9e187 // Kaijuu Monogatari (J) + || crc == 0xaf15338f) + { // Mindseeker (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 026 + if (crc == 0x836cc1ab) + { // Mouryou Senki Madara (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 033 + if (crc == 0x547e6cc1) + { // Flintstones - The Rescue of Dino & Hoppy, The(J) + mapper = 48; + } + + // Mapper 065 + if (crc == 0xfd3fc292) + { // Ai Sensei no Oshiete - Watashi no Hoshi (J) + mapper = 32; + } + + // Mapper 068 + if (crc == 0xfde79681) + { // Maharaja (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 069 + if (crc == 0xfeac6916 // Honoo no Toukyuuji - Dodge Danpei 2(J) + || crc == 0x67898319) + { // Barcode World(J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 080 + if (crc == 0x95aaed34 // Mirai Shinwa Jarvas (J) + || crc == 0x17627d4b) + { // Taito Grand Prix - Eikou heno License (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 082 + if (crc == 0x4819a595) + { // Kyuukyoku Harikiri Stadium - Heisei Gannen Ban (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 086 + if (crc == 0xe63f7d0b) + { // Urusei Yatsura - Lum no Wedding Bell(J) + mapper = 101; + } + + // Mapper 118 + if (crc == 0x3b0fb600) + { // Ys 3 - Wonderers From Ys (J) + header.control1 |= (byte)EnumRomControlByte1.ROM_SAVERAM; + } + + // Mapper 180 + if (crc == 0xc68363f6) + { // Crazy Climber(J) + header.control1 &= 0xf6; + } + + // VS-Unisystem + if (crc == 0x70901b25) + { // VS Slalom + mapper = 99; + } + + if (crc == 0xd5d7eac4) + { // VS Dr. Mario + mapper = 1; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0xffbef374 // VS Castlevania + || crc == 0x8c0c2df5) + { // VS Top Gun + mapper = 2; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0xeb2dba63 // VS TKO Boxing + || crc == 0x98cfe016 // VS TKO Boxing (Alt) + || crc == 0x9818f656) + { // VS TKO Boxing (f1) + mapper = 4; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0x135adf7c) + { // VS Atari RBI Baseball + mapper = 4; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0xf9d3b0a3 // VS Super Xevious + || crc == 0x9924980a // VS Super Xevious (b1) + || crc == 0x66bb838f) + { // VS Super Xevious (b2) + mapper = 4; + header.control1 &= 0xF6; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0x17ae56be) + { // VS Freedom Force + mapper = 4; + header.control1 &= 0xF6; + header.control1 |= (byte)EnumRomControlByte1.ROM_4SCREEN; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0xe2c0a2be) + { // VS Platoon + mapper = 68; + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (crc == 0xcbe85490 // VS Excitebike + || crc == 0x29155e0c // VS Excitebike (Alt) + || crc == 0xff5135a3) + { // VS Hogan's Alley + header.control1 &= 0xF6; + header.control1 |= (byte)EnumRomControlByte1.ROM_4SCREEN; + } + + if (crc == 0x0b65a917) + { // VS Mach Rider(Endurance Course) + lpPRG[0x7FDF] = 0xFF; + lpPRG[0x7FE4] = 0x00; + } + + if (crc == 0x8a6a9848 // VS Mach Rider(Endurance Course)(Alt) + || crc == 0xae8063ef) + { // VS Mach Rider(Japan, Fighting Course) + lpPRG[0x7FDD] = 0xFF; + lpPRG[0x7FE2] = 0x00; + } + + if (crc == 0x16d3f469) + { // VS Ninja Jajamaru Kun (J) + header.control1 &= 0xf6; + header.control1 |= (byte)EnumRomControlByte1.ROM_VMIRROR; + } + + if (crc == 0xc99ec059) + { // VS Raid on Bungeling Bay(J) + mapper = 99; + header.control1 &= 0xF6; + header.control1 |= (byte)EnumRomControlByte1.ROM_4SCREEN; + } + if (crc == 0xca85e56d) + { // VS Mighty Bomb Jack(J) + mapper = 99; + header.control1 &= 0xF6; + header.control1 |= (byte)EnumRomControlByte1.ROM_4SCREEN; + } + + + if (crc == 0xeb2dba63 // VS TKO Boxing + || crc == 0x9818f656 // VS TKO Boxing + || crc == 0xed588f00 // VS Duck Hunt + || crc == 0x8c0c2df5 // VS Top Gun + || crc == 0x16d3f469 // VS Ninja Jajamaru Kun + || crc == 0x8850924b // VS Tetris + || crc == 0xcf36261e // VS Sky Kid + || crc == 0xe1aa8214 // VS Star Luster + || crc == 0xec461db9 // VS Pinball + || crc == 0xe528f651 // VS Pinball (alt) + || crc == 0x17ae56be // VS Freedom Force + || crc == 0xe2c0a2be // VS Platoon + || crc == 0xff5135a3 // VS Hogan's Alley + || crc == 0x70901b25 // VS Slalom + || crc == 0x0b65a917 // VS Mach Rider(Endurance Course) + || crc == 0x8a6a9848 // VS Mach Rider(Endurance Course)(Alt) + || crc == 0xae8063ef // VS Mach Rider(Japan, Fighting Course) + || crc == 0xcc2c4b5d // VS Golf + || crc == 0xa93a5aee // VS Stroke and Match Golf + || crc == 0x86167220 // VS Lady Golf + || crc == 0xffbef374 // VS Castlevania + || crc == 0x135adf7c // VS Atari RBI Baseball + || crc == 0xd5d7eac4 // VS Dr. Mario + || crc == 0x46914e3e // VS Soccer + || crc == 0x70433f2c // VS Battle City + || crc == 0x8d15a6e6 // VS bad .nes + || crc == 0x1e438d52 // VS Goonies + || crc == 0xcbe85490 // VS Excitebike + || crc == 0x29155e0c // VS Excitebike (alt) + || crc == 0x07138c06 // VS Clu Clu Land + || crc == 0x43a357ef // VS Ice Climber + || crc == 0x737dd1bf // VS Super Mario Bros + || crc == 0x4bf3972d // VS Super Mario Bros + || crc == 0x8b60cc58 // VS Super Mario Bros + || crc == 0x8192c804 // VS Super Mario Bros + || crc == 0xd99a2087 // VS Gradius + || crc == 0xf9d3b0a3 // VS Super Xevious + || crc == 0x9924980a // VS Super Xevious + || crc == 0x66bb838f // VS Super Xevious + || crc == 0xc99ec059 // VS Raid on Bungeling Bay(J) + || crc == 0xca85e56d) + { // VS Mighty Bomb Jack(J) + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + if (mapper == 99 || mapper == 151) + { + header.control2 |= (byte)EnumRomControlByte2.ROM_VSUNISYSTEM; + } + + //ÍÌʳÌìµØ2 ºÀ»ªÖÐÎÄ°æ + if (crc == 0x19B9E732) + { + mapper = 199; + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/RomPatch.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/RomPatch.cs.meta new file mode 100644 index 0000000..1670952 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/RomPatch.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 953873ef00535544abd9591708c8e7a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/State.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/State.cs new file mode 100644 index 0000000..2bbf1f0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/State.cs @@ -0,0 +1,54 @@ +using System; + +namespace VirtualNes.Core +{ + public class DISKFILEHDR + { + public byte[] ID = new byte[12]; // "VirtuaNES DI" + public ushort BlockVersion; // 0x0200:0.30 0x0210:0.31 + public ushort Reserved; + public ulong ProgID; // 僾儘僌儔儉ID + public ushort MakerID; // 儊乕僇乕ID + public ushort DiskNo; // 僨傿僗僋悢 + public ulong DifferentSize; // 憡堘悢 + + + public byte[] ToBytes() + { + byte[] res = new byte[36]; + Array.Copy(ID, res, ID.Length); + var temp = BitConverter.GetBytes(BlockVersion); + res[12] = temp[0]; + res[13] = temp[1]; + temp = BitConverter.GetBytes(Reserved); + res[14] = temp[0]; + res[15] = temp[1]; + temp = BitConverter.GetBytes(ProgID); + res[16] = temp[0]; + res[17] = temp[1]; + res[18] = temp[2]; + res[19] = temp[3]; + res[20] = temp[4]; + res[21] = temp[5]; + res[22] = temp[6]; + res[23] = temp[7]; + temp = BitConverter.GetBytes(MakerID); + res[24] = temp[0]; + res[25] = temp[1]; + temp = BitConverter.GetBytes(DiskNo); + res[26] = temp[0]; + res[27] = temp[1]; + temp = BitConverter.GetBytes(ProgID); + res[28] = temp[0]; + res[29] = temp[1]; + res[30] = temp[2]; + res[31] = temp[3]; + res[32] = temp[4]; + res[33] = temp[5]; + res[34] = temp[6]; + res[35] = temp[7]; + + return res; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/State.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/State.cs.meta new file mode 100644 index 0000000..4557eb3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/CoreLibs/State.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 447095b8c8ae4c74885562c127998e9e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Debuger.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Debuger.cs new file mode 100644 index 0000000..21ab49a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Debuger.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; + +namespace VirtualNes.Core.Debug +{ + public static class Debuger + { + private static IDebugerImpl s_debuger; + public static void Setup(IDebugerImpl debuger) + { + s_debuger = debuger; + } + public static void Log(string message) + { + s_debuger.Log(message); + } + + public static void LogError(string message) + { + s_debuger.LogError(message); + } + } + + public interface IDebugerImpl + { + void Log(string message); + void LogError(string message); + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Debuger.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Debuger.cs.meta new file mode 100644 index 0000000..5ad16c9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Debuger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7dbca4403bc49f347a8b36f230364226 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/MMU.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/MMU.cs new file mode 100644 index 0000000..2ce14c8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/MMU.cs @@ -0,0 +1,240 @@ +using System; +using VirtualNes.Core; + +namespace VirtualNes +{ + public static class MMU + { + // CPU 儊儌儕僶儞僋 + public static ByteArrayRef[] CPU_MEM_BANK = new ByteArrayRef[8]; // 8K扨埵 + public static byte[] CPU_MEM_TYPE = new byte[8]; + public static int[] CPU_MEM_PAGE = new int[8]; // 僗僥乕僩僙乕僽梡 + // PPU 儊儌儕僶儞僋 + public static ByteArrayRef[] PPU_MEM_BANK = new ByteArrayRef[12]; // 1K扨埵 + public static byte[] PPU_MEM_TYPE = new byte[12]; + public static int[] PPU_MEM_PAGE = new int[12]; // 僗僥乕僩僙乕僽梡 + public static byte[] CRAM_USED = new byte[16]; // 僗僥乕僩僙乕僽梡 + + // NES儊儌儕 + public static byte[] RAM = new byte[8 * 1024]; // NES撪憻RAM + public static byte[] WRAM = new byte[128 * 1024]; // 儚乕僋/僶僢僋傾僢僾RAM + public static byte[] DRAM = new byte[40 * 1024]; // 僨傿僗僋僔僗僥儉RAM + public static byte[] XRAM = new byte[8 * 1024]; // 僟儈乕僶儞僋 + public static byte[] ERAM = new byte[32 * 1024]; // 奼挘婡å©æ¢¡RAM + + public static byte[] CRAM = new byte[32 * 1024]; // 僉å„儔僋僞僷僞乕儞RAM + public static byte[] VRAM = new byte[4 * 1024]; // 僱乕儉僥乕僽儖/傾僩儕價å„乕僩RAM + + public static byte[] SPRAM = new byte[0x100]; // 僗僾儔僀僩RAM + public static byte[] BGPAL = new byte[0x10]; // BG僷儗僢僩 + public static byte[] SPPAL = new byte[0x10]; // SP僷儗僢僩 + // 儗僕僗僞 + public static byte[] CPUREG = new byte[0x18]; // Nes $4000-$4017 + public static byte[] PPUREG = new byte[0x04]; // Nes $2000-$2003 + + // PPU撪晹儗僕僗僞 + public static byte PPU56Toggle; // $2005-$2006 Toggle + public static byte PPU7_Temp; // $2007 read buffer + public static ushort loopy_t; // same as $2005/$2006 + public static ushort loopy_v; // same as $2005/$2006 + public static ushort loopy_x; // tile x offset + + // ROM僨乕僞億僀儞僞 + public static byte[] PROM; // PROM ptr + public static byte[] VROM; // VROM ptr + + // For dis... + public static byte PROM_ACCESS; + + // ROM 僶儞僋僒僀僘 + public static int PROM_8K_SIZE, PROM_16K_SIZE, PROM_32K_SIZE; + public static int VROM_1K_SIZE, VROM_2K_SIZE, VROM_4K_SIZE, VROM_8K_SIZE; + + // 儊儌儕僞僀僾 + // For PROM (CPU) + public const byte BANKTYPE_ROM = 0x00; + public const byte BANKTYPE_RAM = 0xFF; + public const byte BANKTYPE_DRAM = 0x01; + public const byte BANKTYPE_MAPPER = 0x80; + // For VROM/VRAM=/CRAM (PPU) + public const byte BANKTYPE_VROM = 0x00; + public const byte BANKTYPE_CRAM = 0x01; + public const byte BANKTYPE_VRAM = 0x80; + + // 儈儔乕僞僀僾 + public const byte VRAM_HMIRROR = 0x00; // Horizontal + public const byte VRAM_VMIRROR = 0x01; // Virtical + public const byte VRAM_MIRROR4 = 0x02; // All screen + public const byte VRAM_MIRROR4L = 0x03; // PA10 L屌掕 $2000-$23FFåºå„ˆå„”乕 + public const byte VRAM_MIRROR4H = 0x04; // PA10 H屌掕 $2400-$27FFåºå„ˆå„”乕 + + // Frame-IRQ儗僕僗僞($4017) + public static int FrameIRQ; + + internal static void SetPROM_Bank(byte page, byte[] ptr, byte type) + { + CPU_MEM_BANK[page] = new ByteArrayRef(ptr, 0, ptr.Length); + CPU_MEM_TYPE[page] = type; + CPU_MEM_PAGE[page] = 0; + } + + internal static void SetPROM_8K_Bank(byte page, int bank) + { + bank %= PROM_8K_SIZE; + CPU_MEM_BANK[page] = new ByteArrayRef(MMU.PROM, 0x2000 * bank, MMU.PROM.Length - 0x2000 * bank); + CPU_MEM_TYPE[page] = BANKTYPE_ROM; + CPU_MEM_PAGE[page] = bank; + } + + internal static void SetPROM_16K_Bank(byte page, int bank) + { + SetPROM_8K_Bank((byte)(page + 0), bank * 2 + 0); + SetPROM_8K_Bank((byte)(page + 1), bank * 2 + 1); + } + + internal static void SetPROM_32K_Bank(int bank) + { + SetPROM_8K_Bank(4, bank * 4 + 0); + SetPROM_8K_Bank(5, bank * 4 + 1); + SetPROM_8K_Bank(6, bank * 4 + 2); + SetPROM_8K_Bank(7, bank * 4 + 3); + } + + internal static void SetPROM_32K_Bank(int bank0, int bank1, int bank2, int bank3) + { + SetPROM_8K_Bank(4, bank0); + SetPROM_8K_Bank(5, bank1); + SetPROM_8K_Bank(6, bank2); + SetPROM_8K_Bank(7, bank3); + } + + // PPU VROM bank + internal static void SetVROM_Bank(byte page, ByteArrayRef ptr, byte type) + { + PPU_MEM_BANK[page] = ptr; + PPU_MEM_TYPE[page] = type; + PPU_MEM_PAGE[page] = 0; + } + + internal static void SetVROM_1K_Bank(byte page, int bank) + { + bank %= VROM_1K_SIZE; + PPU_MEM_BANK[page] = new ByteArrayRef(VROM, 0x0400 * bank, VROM.Length - (0x0400 * bank)); + PPU_MEM_TYPE[page] = BANKTYPE_VROM; + PPU_MEM_PAGE[page] = bank; + } + + internal static void SetVROM_2K_Bank(byte page, int bank) + { + SetVROM_1K_Bank((byte)(page + 0), bank * 2 + 0); + SetVROM_1K_Bank((byte)(page + 1), bank * 2 + 1); + } + + internal static void SetVROM_4K_Bank(byte page, int bank) + { + SetVROM_1K_Bank((byte)(page + 0), bank * 4 + 0); + SetVROM_1K_Bank((byte)(page + 1), bank * 4 + 1); + SetVROM_1K_Bank((byte)(page + 2), bank * 4 + 2); + SetVROM_1K_Bank((byte)(page + 3), bank * 4 + 3); + } + + internal static void SetVROM_8K_Bank(int bank) + { + for (byte i = 0; i < 8; i++) + { + SetVROM_1K_Bank(i, bank * 8 + i); + } + } + + internal static void SetVROM_8K_Bank(int bank0, int bank1, int bank2, int bank3, + int bank4, int bank5, int bank6, int bank7) + { + SetVROM_1K_Bank(0, bank0); + SetVROM_1K_Bank(1, bank1); + SetVROM_1K_Bank(2, bank2); + SetVROM_1K_Bank(3, bank3); + SetVROM_1K_Bank(4, bank4); + SetVROM_1K_Bank(5, bank5); + SetVROM_1K_Bank(6, bank6); + SetVROM_1K_Bank(7, bank7); + } + + internal static void SetCRAM_1K_Bank(byte page, int bank) + { + bank &= 0x1F; + PPU_MEM_BANK[page] = new ByteArrayRef(MMU.CRAM, 0x0400 * bank, MMU.CRAM.Length - 0x0400 * bank); + PPU_MEM_TYPE[page] = BANKTYPE_CRAM; + PPU_MEM_PAGE[page] = bank; + + CRAM_USED[bank >> 2] = 0xFF; // CRAM巊梡僼儔僌 + } + + internal static void SetCRAM_2K_Bank(byte page, int bank) + { + SetCRAM_1K_Bank((byte)(page + 0), bank * 2 + 0); + SetCRAM_1K_Bank((byte)(page + 1), bank * 2 + 1); + } + + internal static void SetCRAM_4K_Bank(byte page, int bank) + { + SetCRAM_1K_Bank((byte)(page + 0), bank * 4 + 0); + SetCRAM_1K_Bank((byte)(page + 1), bank * 4 + 1); + SetCRAM_1K_Bank((byte)(page + 2), bank * 4 + 2); + SetCRAM_1K_Bank((byte)(page + 3), bank * 4 + 3); + } + + internal static void SetCRAM_8K_Bank(int bank) + { + for (byte i = 0; i < 8; i++) + { + SetCRAM_1K_Bank(i, bank * 8 + 1); + } + } + + internal static void SetVRAM_1K_Bank(byte page, int bank) + { + bank &= 3; + PPU_MEM_BANK[page] = new ByteArrayRef(VRAM, 0x0400 * bank, VRAM.Length - 0x0400 * bank); + PPU_MEM_TYPE[page] = BANKTYPE_VRAM; + PPU_MEM_PAGE[page] = bank; + } + + internal static void SetVRAM_Bank(int bank0, int bank1, int bank2, int bank3) + { + SetVRAM_1K_Bank(8, bank0); + SetVRAM_1K_Bank(9, bank1); + SetVRAM_1K_Bank(10, bank2); + SetVRAM_1K_Bank(11, bank3); + } + + internal static void SetVRAM_Mirror(int type) + { + switch (type) + { + case VRAM_HMIRROR: + SetVRAM_Bank(0, 0, 1, 1); + break; + case VRAM_VMIRROR: + SetVRAM_Bank(0, 1, 0, 1); + break; + case VRAM_MIRROR4L: + SetVRAM_Bank(0, 0, 0, 0); + break; + case VRAM_MIRROR4H: + SetVRAM_Bank(1, 1, 1, 1); + break; + case VRAM_MIRROR4: + SetVRAM_Bank(0, 1, 2, 3); + break; + } + } + + internal static void SetVRAM_Mirror(int bank0, int bank1, int bank2, int bank3) + { + SetVRAM_1K_Bank(8, bank0); + SetVRAM_1K_Bank(9, bank1); + SetVRAM_1K_Bank(10, bank2); + SetVRAM_1K_Bank(11, bank3); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/MMU.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/MMU.cs.meta new file mode 100644 index 0000000..a77dd40 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/MMU.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 863989820a4fb1d49a7c0c883c5a7078 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper.meta new file mode 100644 index 0000000..5aa92e7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 351e90d17a844b44f869f7c59fd1efb6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs new file mode 100644 index 0000000..7f6c4a0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs @@ -0,0 +1,455 @@ +using System; + +namespace VirtualNes.Core +{ + + + public class X24C01 + { + public const int X24C01_IDLE = 0; // Idle + public const int X24C01_ADDRESS = 1; // Address set + public const int X24C01_READ = 2; // Read + public const int X24C01_WRITE = 3; // Write + public const int X24C01_ACK = 4; // Acknowledge + public const int X24C01_ACK_WAIT = 5; // Acknowledge wait + + int now_state, next_state; + int bitcnt; + byte addr, data; + byte sda; + byte scl_old, sda_old; + + ByteArrayRef pEEPDATA; + + public X24C01() + { + now_state = X24C01_IDLE; + next_state = X24C01_IDLE; + addr = 0; + data = 0; + sda = 0xFF; + scl_old = 0; + sda_old = 0; + + pEEPDATA = null; + } + + public void Reset(ByteArrayRef ptr) + { + now_state = X24C01_IDLE; + next_state = X24C01_IDLE; + addr = 0; + data = 0; + sda = 0xFF; + scl_old = 0; + sda_old = 0; + + pEEPDATA = ptr; + } + + public void Write(byte scl_in, byte sda_in) + { + // Clock line + byte scl_rise = (byte)(~scl_old & scl_in); + byte scl_fall = (byte)(scl_old & ~scl_in); + // Data line + byte sda_rise = (byte)(~sda_old & sda_in); + byte sda_fall = (byte)(sda_old & ~sda_in); + + byte scl_old_temp = scl_old; + byte sda_old_temp = sda_old; + + scl_old = scl_in; + sda_old = sda_in; + + // Start condition? + if (scl_old_temp != 0 && sda_fall != 0) + { + now_state = X24C01_ADDRESS; + bitcnt = 0; + addr = 0; + sda = 0xFF; + return; + } + + // Stop condition? + if (scl_old_temp != 0 && sda_rise != 0) + { + now_state = X24C01_IDLE; + sda = 0xFF; + return; + } + + // SCL ____---- RISE + if (scl_rise != 0) + { + switch (now_state) + { + case X24C01_ADDRESS: + if (bitcnt < 7) + { + // 本æ¥ã¯MSB->LSB + addr = (byte)(addr & (~(1 << bitcnt))); + addr = (byte)(addr | ((sda_in != 0 ? 1 : 0) << bitcnt)); + } + else + { + if (sda_in != 0) + { + next_state = X24C01_READ; + data = pEEPDATA[addr & 0x7F]; + } + else + { + next_state = X24C01_WRITE; + } + } + bitcnt++; + break; + case X24C01_ACK: + sda = 0; // ACK + break; + case X24C01_READ: + if (bitcnt < 8) + { + // 本æ¥ã¯MSB->LSB + sda = (byte)((data & (1 << bitcnt)) != 0 ? 1 : 0); + } + bitcnt++; + break; + case X24C01_WRITE: + if (bitcnt < 8) + { + // 本æ¥ã¯MSB->LSB + data = (byte)(data & (~(1 << bitcnt))); + data = (byte)(data | ((sda_in != 0 ? 1 : 0) << bitcnt)); + } + bitcnt++; + break; + + case X24C01_ACK_WAIT: + if (sda_in == 0) + { + next_state = X24C01_IDLE; + } + break; + } + } + + // SCL ----____ FALL + if (scl_fall != 0) + { + switch (now_state) + { + case X24C01_ADDRESS: + if (bitcnt >= 8) + { + now_state = X24C01_ACK; + sda = 0xFF; + } + break; + case X24C01_ACK: + now_state = next_state; + bitcnt = 0; + sda = 0xFF; + break; + case X24C01_READ: + if (bitcnt >= 8) + { + now_state = X24C01_ACK_WAIT; + addr = (byte)((addr + 1) & 0x7F); + } + break; + case X24C01_WRITE: + if (bitcnt >= 8) + { + now_state = X24C01_ACK; + next_state = X24C01_IDLE; + pEEPDATA[addr & 0x7F] = data; + addr = (byte)((addr + 1) & 0x7F); + } + break; + } + } + } + + public byte Read() + { + return sda; + } + + public void Load(byte[] p) + { + //now_state = *((INT*)&p[0]); + //next_state = *((INT*)&p[4]); + //bitcnt = *((INT*)&p[8]); + //addr = p[12]; + //data = p[13]; + //sda = p[14]; + //scl_old = p[15]; + //sda_old = p[16]; + } + + public void Save(byte[] p) + { + //*((INT*)&p[0]) = now_state; + //*((INT*)&p[4]) = next_state; + //*((INT*)&p[8]) = bitcnt; + //p[12] = addr; + //p[13] = data; + //p[14] = sda; + //p[15] = scl_old; + //p[16] = sda_old; + } + } + + public class X24C02 + { + public const int X24C02_IDLE = 0; // Idle + public const int X24C02_DEVADDR = 1; // Device address set + public const int X24C02_ADDRESS = 2; // Address set + public const int X24C02_READ = 3; // Read + public const int X24C02_WRITE = 4; // Write + public const int X24C02_ACK = 5; // Acknowledge + public const int X24C02_NAK = 6; // Not Acknowledge + public const int X24C02_ACK_WAIT = 7; // Acknowledge wait + + int now_state, next_state; + int bitcnt; + byte addr, data, rw; + byte sda; + byte scl_old, sda_old; + + ByteArrayRef pEEPDATA; + + public X24C02() + { + now_state = X24C02_IDLE; + next_state = X24C02_IDLE; + addr = 0; + data = 0; + rw = 0; + sda = 0xFF; + scl_old = 0; + sda_old = 0; + + pEEPDATA = null; + } + + public void Reset(ByteArrayRef ptr) + { + now_state = X24C02_IDLE; + next_state = X24C02_IDLE; + addr = 0; + data = 0; + rw = 0; + sda = 0xFF; + scl_old = 0; + sda_old = 0; + + pEEPDATA = ptr; + } + + public void Write(byte scl_in, byte sda_in) + { + // Clock line + byte scl_rise = (byte)(~scl_old & scl_in); + byte scl_fall = (byte)(scl_old & ~scl_in); + // Data line + byte sda_rise = (byte)(~sda_old & sda_in); + byte sda_fall = (byte)(sda_old & ~sda_in); + + byte scl_old_temp = scl_old; + byte sda_old_temp = sda_old; + + scl_old = scl_in; + sda_old = sda_in; + + // Start condition? + if (scl_old_temp != 0 && sda_fall != 0) + { + now_state = X24C02_DEVADDR; + bitcnt = 0; + sda = 0xFF; + return; + } + + // Stop condition? + if (scl_old_temp != 0 && sda_rise != 0) + { + now_state = X24C02_IDLE; + sda = 0xFF; + return; + } + + // SCL ____---- RISE + if (scl_rise != 0) + { + switch (now_state) + { + case X24C02_DEVADDR: + if (bitcnt < 8) + { + data = (byte)(data & (~(1 << (7 - bitcnt)))); + data = (byte)(data | ((sda_in != 0 ? 1 : 0) << (7 - bitcnt))); + } + bitcnt++; + break; + case X24C02_ADDRESS: + if (bitcnt < 8) + { + addr = (byte)(addr & (~(1 << (7 - bitcnt)))); + addr = (byte)(addr | ((sda_in != 0 ? 1 : 0) << (7 - bitcnt))); + } + bitcnt++; + break; + case X24C02_READ: + if (bitcnt < 8) + { + sda = (byte)((data & (1 << (7 - bitcnt))) != 0 ? 1 : 0); + } + bitcnt++; + break; + case X24C02_WRITE: + if (bitcnt < 8) + { + data = (byte)(data & (~(1 << (7 - bitcnt)))); + data = (byte)(data | ((sda_in != 0 ? 1 : 0) << (7 - bitcnt))); + } + bitcnt++; + break; + case X24C02_NAK: + sda = 0xFF; // NAK + break; + case X24C02_ACK: + sda = 0; // ACK + break; + case X24C02_ACK_WAIT: + if (sda_in == 0) + { + next_state = X24C02_READ; + data = pEEPDATA[addr]; + } + break; + } + } + + // SCL ----____ FALL + if (scl_fall != 0) + { + switch (now_state) + { + case X24C02_DEVADDR: + if (bitcnt >= 8) + { + if ((data & 0xA0) == 0xA0) + { + now_state = X24C02_ACK; + rw = (byte)(data & 0x01); + sda = 0xFF; + if (rw != 0) + { + // Now address read + next_state = X24C02_READ; + data = pEEPDATA[addr]; + } + else + { + next_state = X24C02_ADDRESS; + } + bitcnt = 0; + } + else + { + now_state = X24C02_NAK; + next_state = X24C02_IDLE; + sda = 0xFF; + } + } + break; + case X24C02_ADDRESS: + if (bitcnt >= 8) + { + now_state = X24C02_ACK; + sda = 0xFF; + if (rw != 0) + { + // Readã§ã¯çµ¶å¯¾æ¥ãªã„ãŒå¿µã®ç‚º + next_state = X24C02_IDLE; + } + else + { + // to Data Write + next_state = X24C02_WRITE; + } + bitcnt = 0; + } + break; + case X24C02_READ: + if (bitcnt >= 8) + { + now_state = X24C02_ACK_WAIT; + addr = (byte)((addr + 1) & 0xFF); + } + break; + case X24C02_WRITE: + if (bitcnt >= 8) + { + pEEPDATA[addr] = data; + now_state = X24C02_ACK; + next_state = X24C02_WRITE; + addr = (byte)((addr + 1) & 0xFF); + bitcnt = 0; + } + break; + case X24C02_NAK: + now_state = X24C02_IDLE; + bitcnt = 0; + sda = 0xFF; + break; + case X24C02_ACK: + now_state = next_state; + bitcnt = 0; + sda = 0xFF; + break; + case X24C02_ACK_WAIT: + now_state = next_state; + bitcnt = 0; + sda = 0xFF; + break; + } + } + } + + public byte Read() + { + return sda; + } + + public void Load(byte[] p) + { + //now_state = *((INT*)&p[0]); + //next_state = *((INT*)&p[4]); + //bitcnt = *((INT*)&p[8]); + //addr = p[12]; + //data = p[13]; + //rw = p[14]; + //sda = p[15]; + //scl_old = p[16]; + //sda_old = p[17]; + } + + public void Save(byte[] p) + { + //*((INT*)&p[0]) = now_state; + //*((INT*)&p[4]) = next_state; + //*((INT*)&p[8]) = bitcnt; + //p[12] = addr; + //p[13] = data; + //p[14] = rw; + //p[15] = sda; + //p[16] = scl_old; + //p[17] = sda_old; + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs.meta new file mode 100644 index 0000000..f305afa --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: be5901dc72f4b6045a7c33edba28145f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper.cs new file mode 100644 index 0000000..40043ba --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper.cs @@ -0,0 +1,233 @@ +using System; + +namespace VirtualNes.Core +{ + public abstract class Mapper + { + protected NES nes; + + public Mapper(NES parent) + { + nes = parent; + } + + public virtual void Dispose() { } + + public abstract void Reset(); + + // $8000-$FFFF Memory write + public virtual void Write(ushort addr, byte data) { } + // $8000-$FFFF Memory read(Dummy) + public virtual void Read(ushort addr, byte data) { } + + // $4100-$7FFF Lower Memory read/write + public virtual byte ReadLow(ushort addr) + { + // $6000-$7FFF WRAM + if (addr >= 0x6000 && addr <= 0x7FFF) + { + return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + + return (byte)(addr >> 8); + } + public virtual void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000 && addr <= 0x7FFF) + { + MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + } + + // $4018-$40FF Extention register read/write + public virtual byte ExRead(ushort addr) { return 0x00; } + public virtual void ExWrite(ushort addr, byte data) { } + + public virtual byte ExCmdRead(EXCMDRD cmd) { return 0x00; } + public virtual void ExCmdWrite(EXCMDWR cmd, byte data) { } + + // H sync/V sync/Clock sync + public virtual void HSync(int scanline) { } + public virtual void VSync() { } + public virtual void Clock(int cycles) { } + // PPU address bus latch + public virtual void PPU_Latch(ushort addr) { } + // PPU Character latch + public virtual void PPU_ChrLatch(ushort addr) { } + // PPU Extension character/palette + public virtual void PPU_ExtLatchX(int x) { } + public virtual void PPU_ExtLatch(ushort addr, ref byte chr_l, ref byte chr_h, ref byte attr) { } + // For State save + public virtual bool IsStateSave() { return false; } + public virtual void SaveState(byte[] p) { } + public virtual void LoadState(byte[] p) { } + + // Extension commands + // For ExCmdRead command + public enum EXCMDRD + { + EXCMDRD_NONE = 0, + EXCMDRD_DISKACCESS, + } + // For ExCmdWrite command + public enum EXCMDWR + { + EXCMDWR_NONE = 0, + EXCMDWR_DISKINSERT, + EXCMDWR_DISKEJECT, + } + + public static Mapper CreateMapper(NES parent, int no) + { + //todo : 实现加载mapper + switch (no) + { + case 4: return new Mapper004(parent); + case 16: return new Mapper016(parent); + case 17: return new Mapper017(parent); + case 18: return new Mapper018(parent); + case 19: return new Mapper019(parent); + case 21: return new Mapper021(parent); + case 22: return new Mapper022(parent); + case 23: return new Mapper023(parent); + case 24: return new Mapper024(parent); + case 25: return new Mapper025(parent); + case 26: return new Mapper026(parent); + case 27: return new Mapper027(parent); + case 32: return new Mapper032(parent); + case 33: return new Mapper033(parent); + case 34: return new Mapper034(parent); + case 35: return new Mapper035(parent); + case 40: return new Mapper040(parent); + case 41: return new Mapper041(parent); + case 42: return new Mapper042(parent); + case 43: return new Mapper043(parent); + case 44: return new Mapper044(parent); + case 45: return new Mapper045(parent); + case 46: return new Mapper046(parent); + case 47: return new Mapper047(parent); + case 48: return new Mapper048(parent); + case 50: return new Mapper050(parent); + case 51: return new Mapper051(parent); + case 57: return new Mapper057(parent); + case 58: return new Mapper058(parent); + case 60: return new Mapper060(parent); + case 61: return new Mapper061(parent); + case 62: return new Mapper062(parent); + case 64: return new Mapper064(parent); + case 65: return new Mapper065(parent); + case 66: return new Mapper066(parent); + case 67: return new Mapper067(parent); + case 68: return new Mapper068(parent); + case 69: return new Mapper069(parent); + case 70: return new Mapper070(parent); + case 71: return new Mapper071(parent); + case 72: return new Mapper072(parent); + case 73: return new Mapper073(parent); + case 74: return new Mapper074(parent); + case 75: return new Mapper075(parent); + case 76: return new Mapper076(parent); + case 77: return new Mapper077(parent); + case 78: return new Mapper078(parent); + case 79: return new Mapper079(parent); + case 80: return new Mapper080(parent); + case 82: return new Mapper082(parent); + case 83: return new Mapper083(parent); + case 85: return new Mapper085(parent); + case 86: return new Mapper086(parent); + case 87: return new Mapper087(parent); + case 88: return new Mapper088(parent); + case 89: return new Mapper089(parent); + case 90: return new Mapper090(parent); + case 91: return new Mapper091(parent); + case 92: return new Mapper092(parent); + case 93: return new Mapper093(parent); + case 94: return new Mapper094(parent); + case 95: return new Mapper095(parent); + case 96: return new Mapper096(parent); + case 97: return new Mapper097(parent); + case 99: return new Mapper099(parent); + case 100: return new Mapper100(parent); + case 101: return new Mapper101(parent); + case 105: return new Mapper105(parent); + case 108: return new Mapper108(parent); + case 109: return new Mapper109(parent); + case 110: return new Mapper110(parent); + case 111: return new Mapper111(parent); + case 112: return new Mapper112(parent); + case 113: return new Mapper113(parent); + case 114: return new Mapper114(parent); + case 115: return new Mapper115(parent); + case 116: return new Mapper116(parent); + case 117: return new Mapper117(parent); + case 118: return new Mapper118(parent); + case 119: return new Mapper119(parent); + case 122: return new Mapper122(parent); + case 133: return new Mapper133(parent); + case 134: return new Mapper134(parent); + case 135: return new Mapper135(parent); + case 140: return new Mapper140(parent); + case 142: return new Mapper142(parent); + case 151: return new Mapper151(parent); + case 160: return new Mapper160(parent); + case 162: return new Mapper162(parent); + case 163: return new Mapper163(parent); + case 164: return new Mapper164(parent); + case 165: return new Mapper165(parent); + case 167: return new Mapper167(parent); + case 175: return new Mapper175(parent); + case 176: return new Mapper176(parent); + case 178: return new Mapper178(parent); + case 180: return new Mapper180(parent); + case 181: return new Mapper181(parent); + case 182: return new Mapper182(parent); + case 183: return new Mapper183(parent); + case 185: return new Mapper185(parent); + case 187: return new Mapper187(parent); + case 188: return new Mapper188(parent); + case 189: return new Mapper189(parent); + case 190: return new Mapper190(parent); + case 191: return new Mapper191(parent); + case 192: return new Mapper192(parent); + case 193: return new Mapper193(parent); + case 194: return new Mapper194(parent); + case 195: return new Mapper195(parent); + case 198: return new Mapper198(parent); + case 199: return new Mapper199(parent); + case 200: return new Mapper200(parent); + case 201: return new Mapper201(parent); + case 202: return new Mapper202(parent); + case 216: return new Mapper216(parent); + case 222: return new Mapper222(parent); + case 225: return new Mapper225(parent); + case 226: return new Mapper226(parent); + case 227: return new Mapper227(parent); + case 228: return new Mapper228(parent); + case 229: return new Mapper229(parent); + case 230: return new Mapper230(parent); + case 231: return new Mapper231(parent); + case 232: return new Mapper232(parent); + case 233: return new Mapper233(parent); + case 234: return new Mapper234(parent); + case 235: return new Mapper235(parent); + case 236: return new Mapper236(parent); + case 240: return new Mapper240(parent); + case 241: return new Mapper241(parent); + case 242: return new Mapper242(parent); + case 243: return new Mapper243(parent); + case 244: return new Mapper244(parent); + case 245: return new Mapper245(parent); + case 246: return new Mapper246(parent); + case 248: return new Mapper248(parent); + case 249: return new Mapper249(parent); + case 251: return new Mapper251(parent); + case 252: return new Mapper252(parent); + case 254: return new Mapper254(parent); + case 255: return new Mapper255(parent); + + default: + throw new NotImplementedException($"Mapper#{no:000} is not Impl"); + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper.cs.meta new file mode 100644 index 0000000..dac6129 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c095219b80f9234fb1a9a87f6fbf004 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper004.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper004.cs new file mode 100644 index 0000000..0106263 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper004.cs @@ -0,0 +1,576 @@ +using Codice.CM.Client.Differences; +using System; + +namespace VirtualNes.Core +{ + public class Mapper004 : Mapper + { + private const int MMC3_IRQ_KLAX = 1; + private const int MMC3_IRQ_SHOUGIMEIKAN = 2; + private const int MMC3_IRQ_DAI2JISUPER = 3; + private const int MMC3_IRQ_DBZ2 = 4; + private const int MMC3_IRQ_ROCKMAN3 = 5; + + protected byte[] reg = new byte[8]; + protected byte prg0, prg1; + protected byte chr01, chr23, chr4, chr5, chr6, chr7; + protected byte we_sram; + + protected byte irq_type; + protected byte irq_enable; + protected byte irq_counter; + protected byte irq_latch; + protected byte irq_request; + protected byte irq_preset; + protected byte irq_preset_vbl; + + protected byte vs_patch; + protected byte vs_index; + + private byte[] VS_TKO_Security = new byte[32] + { + 0xff, 0xbf, 0xb7, 0x97, 0x97, 0x17, 0x57, 0x4f, + 0x6f, 0x6b, 0xeb, 0xa9, 0xb1, 0x90, 0x94, 0x14, + 0x56, 0x4e, 0x6f, 0x6b, 0xeb, 0xa9, 0xb1, 0x90, + 0xd4, 0x5c, 0x3e, 0x26, 0x87, 0x83, 0x13, 0x00 + }; + + public Mapper004(NES parent) : base(parent) { } + + public override void Reset() + { + for (int i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0xFF; + irq_request = 0; + irq_preset = 0; + irq_preset_vbl = 0; + + // IRQ僞僀僾æ„掕 + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + irq_type = 0; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0x5c707ac4) + { // Mother(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0xcb106f49) + { // F-1 Sensation(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x1170392a) + { // Karakuri Kengou Den - Musashi Road - Karakuri Nin Hashiru!(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x14a01c70) + { // Gun-Dec(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0xeffeea40) + { // For Klax(J) + irq_type = MMC3_IRQ_KLAX; + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0xc17ae2dc) + { // God Slayer - Haruka Tenkuu no Sonata(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x126ea4a0) + { // Summer Carnival '92 - Recca(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x1f2f4861) + { // J League Fighting Soccer - The King of Ace Strikers(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x5a6860f1) + { // Shougi Meikan '92(J) + irq_type = MMC3_IRQ_SHOUGIMEIKAN; + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0xae280e20) + { // Shougi Meikan '93(J) + irq_type = MMC3_IRQ_SHOUGIMEIKAN; + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0xe19a2473) + { // Sugoro Quest - Dice no Senshi Tachi(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x702d9b33) + { // Star Wars - The Empire Strikes Back(Victor)(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0xa9a0d729) + { // Dai Kaijuu - Deburas(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0xc5fea9f2) + { // Dai 2 Ji - Super Robot Taisen(J) + irq_type = MMC3_IRQ_DAI2JISUPER; + } + if (crc == 0xd852c2f7) + { // Time Zone(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0xecfd3c69) + { // Taito Chase H.Q.(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x7a748058) + { // Tom & Jerry (and Tuffy)(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0xaafe699c) + { // Ninja Ryukenden 3 - Yomi no Hakobune(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x6cc62c06) + { // Hoshi no Kirby - Yume no Izumi no Monogatari(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x877dba77) + { // My Life My Love - Boku no Yume - Watashi no Negai(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x6f96ed15) + { // Max Warrior - Wakusei Kaigenrei(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x8685f366) + { // Matendouji(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x8635fed1) + { // Mickey Mouse 3 - Yume Fuusen(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x26ff3ea2) + { // Yume Penguin Monogatari(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x7671bc51) + { // Red Ariimaa 2(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0xade11141) + { // Wanpaku Kokkun no Gourmet World(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0x7c7ab58e) + { // Walkuere no Bouken - Toki no Kagi Densetsu(J) + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + if (crc == 0x26ff3ea2) + { // Yume Penguin Monogatari(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x126ea4a0) + { // Summer Carnival '92 Recca(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + + if (crc == 0x1d2e5018 // Rockman 3(J) + || crc == 0x6b999aaf) + { // Megaman 3(U) + irq_type = MMC3_IRQ_ROCKMAN3; + } + + if (crc == 0xd88d48d7) + { // Kick Master(U) + irq_type = MMC3_IRQ_ROCKMAN3; + } + + if (crc == 0xA67EA466) + { // Alien 3(U) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + + if (crc == 0xe763891b) + { // DBZ2 + irq_type = MMC3_IRQ_DBZ2; + } + + // VS-Unisystem + vs_patch = 0; + vs_index = 0; + + if (crc == 0xeb2dba63 // VS TKO Boxing + || crc == 0x98cfe016) + { // VS TKO Boxing (Alt) + vs_patch = 1; + } + if (crc == 0x135adf7c) + { // VS Atari RBI Baseball + vs_patch = 2; + } + if (crc == 0xf9d3b0a3 // VS Super Xevious + || crc == 0x9924980a // VS Super Xevious (b1) + || crc == 0x66bb838f) + { // VS Super Xevious (b2) + vs_patch = 3; + } + } + + private void SetBank_PPU() + { + if (MMU.VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + MMU.SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + MMU.SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + MMU.SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); + MMU.SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); + MMU.SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); + MMU.SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); + MMU.SetCRAM_1K_Bank(0, chr4 & 0x07); + MMU.SetCRAM_1K_Bank(1, chr5 & 0x07); + MMU.SetCRAM_1K_Bank(2, chr6 & 0x07); + MMU.SetCRAM_1K_Bank(3, chr7 & 0x07); + } + else + { + MMU.SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); + MMU.SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); + MMU.SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); + MMU.SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); + MMU.SetCRAM_1K_Bank(4, chr4 & 0x07); + MMU.SetCRAM_1K_Bank(5, chr5 & 0x07); + MMU.SetCRAM_1K_Bank(6, chr6 & 0x07); + MMU.SetCRAM_1K_Bank(7, chr7 & 0x07); + } + } + } + + public override byte ReadLow(ushort addr) + { + if (vs_patch == 0) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + return MMU.XRAM[addr - 0x4000]; + } + } + else if (vs_patch == 1) + { + // VS TKO Boxing Security + if (addr == 0x5E00) + { + vs_index = 0; + return 0x00; + } + else if (addr == 0x5E01) + { + return VS_TKO_Security[(vs_index++) & 0x1F]; + } + } + else if (vs_patch == 2) + { + // VS Atari RBI Baseball Security + if (addr == 0x5E00) + { + vs_index = 0; + return 0x00; + } + else if (addr == 0x5E01) + { + if (vs_index++ == 9) + return 0x6F; + else + return 0xB4; + } + } + else if (vs_patch == 3) + { + // VS Super Xevious + switch (addr) + { + case 0x54FF: + return 0x05; + case 0x5678: + if (vs_index != 0) + return 0x00; + else + return 0x01; + case 0x578f: + if (vs_index != 0) + return 0xD1; + else + return 0x89; + case 0x5567: + if (vs_index != 0) + { + vs_index = 0; + return 0x3E; + } + else + { + vs_index = 1; + return 0x37; + } + default: + break; + } + } + + return base.ReadLow(addr); + } + + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + MMU.XRAM[addr - 0x4000] = data; + } + else + { + base.WriteLow(addr, data); + } + } + + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) MMU.SetVRAM_Mirror(MMU.VRAM_HMIRROR); + else MMU.SetVRAM_Mirror(MMU.VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes->GetScanline(), nes->cpu->GetTotalCycles() ); + break; + case 0xC000: + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes->GetScanline(), nes->cpu->GetTotalCycles() ); + reg[4] = data; + if (irq_type == MMC3_IRQ_KLAX || irq_type == MMC3_IRQ_ROCKMAN3) + { + irq_counter = data; + } + else + { + irq_latch = data; + } + if (irq_type == MMC3_IRQ_DBZ2) + { + irq_latch = 0x07; + } + break; + case 0xC001: + reg[5] = data; + if (irq_type == MMC3_IRQ_KLAX || irq_type == MMC3_IRQ_ROCKMAN3) + { + irq_latch = data; + } + else + { + if ((nes.GetScanline() < 240) || (irq_type == MMC3_IRQ_SHOUGIMEIKAN)) + { + irq_counter |= 0x80; + irq_preset = 0xFF; + } + else + { + irq_counter |= 0x80; + irq_preset_vbl = 0xFF; + irq_preset = 0; + } + } + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + + nes.cpu.ClrIRQ(CPU.IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + + // nes->cpu->ClrIRQ( IRQ_MAPPER ); + break; + } + } + + public override void Clock(int cycles) + { + + } + + public override void HSync(int scanline) + { + if (irq_type == MMC3_IRQ_KLAX) + { + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if (irq_counter == 0) + { + irq_counter = irq_latch; + irq_request = 0xFF; + } + if (irq_counter > 0) + { + irq_counter--; + } + } + } + if (irq_request != 0) + { + nes.cpu.SetIRQ(CPU.IRQ_MAPPER); + } + } + else if (irq_type == MMC3_IRQ_ROCKMAN3) + { + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((--irq_counter) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + } + } + } + if (irq_request != 0) + { + nes.cpu.SetIRQ(CPU.IRQ_MAPPER); + } + } + else + { + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if (irq_preset_vbl != 0) + { + irq_counter = irq_latch; + irq_preset_vbl = 0; + } + if (irq_preset != 0) + { + irq_counter = irq_latch; + irq_preset = 0; + if (irq_type == MMC3_IRQ_DAI2JISUPER && scanline == 0) + { + irq_counter--; + } + } + else if (irq_counter > 0) + { + irq_counter--; + } + + if (irq_counter == 0) + { + if (irq_enable != 0) + { + irq_request = 0xFF; + + nes.cpu.SetIRQ(CPU.IRQ_MAPPER); + } + irq_preset = 0xFF; + } + } + } + } + + private void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + MMU.SetPROM_32K_Bank(MMU.PROM_8K_SIZE - 2, prg1, prg0, MMU.PROM_8K_SIZE - 1); + } + else + { + MMU.SetPROM_32K_Bank(prg0, prg1, MMU.PROM_8K_SIZE - 2, MMU.PROM_8K_SIZE - 1); + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper004.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper004.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper004.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper004.cs.meta index 656b91e..cdf97fb 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper004.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper004.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e2b6fcc80f0fa6941bdd8fd3fb33c886 +guid: 1be6fcc00c619e84cbf0d5d92701b2e3 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs new file mode 100644 index 0000000..4b9bce8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs @@ -0,0 +1,429 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper016 Bandai Standard // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.Core.CPU; +using static VirtualNes.MMU; +using BYTE = System.Byte; +using INT = System.Int32; + +namespace VirtualNes.Core +{ + public class Mapper016 : Mapper + { + BYTE patch; // For Famicom Jump 2 + BYTE eeprom_type; // EEPROM type + + BYTE[] reg = new byte[3]; + + BYTE irq_enable; + INT irq_counter; + INT irq_latch; + BYTE irq_type; + + X24C01 x24c01; + X24C02 x24c02; + public Mapper016(NES parent) : base(parent) + { + } + + + public override void Reset() + { + patch = 0; + + reg[0] = reg[1] = reg[2] = 0; + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + + irq_type = 0; + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + + eeprom_type = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0x3f15d20d // Famicom Jump 2(J) + || crc == 0xf76aa523) + { // Famicom Jump 2(J)(alt) + patch = 1; + eeprom_type = 0xFF; + + WRAM[0x0BBC] = 0xFF; // SRAM対策 + } + + if (crc == 0x1d6f27f7) + { // Dragon Ball Z 2(Korean Hack) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + eeprom_type = 1; + } + if (crc == 0x6f7247c8) + { // Dragon Ball Z 3(Korean Hack) + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + eeprom_type = 1; + } + + if (crc == 0x7fb799fd) + { // Dragon Ball 2 - Dai Maou Fukkatsu(J) + } + if (crc == 0x6c6c2feb // Dragon Ball 3 - Gokuu Den(J) + || crc == 0x8edeb257) + { // Dragon Ball 3 - Gokuu Den(J)(Alt) + } + if (crc == 0x31cd9903) + { // Dragon Ball Z - Kyoushuu! Saiya Jin(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + } + if (crc == 0xe49fc53e // Dragon Ball Z 2 - Gekishin Freeza!!(J) + || crc == 0x1582fee0) + { // Dragon Ball Z 2 - Gekishin Freeza!!(J) [alt] + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + eeprom_type = 1; + } + if (crc == 0x09499f4d) + { // Dragon Ball Z 3 - Ressen Jinzou Ningen(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + eeprom_type = 1; + } + if (crc == 0x2e991109) + { // Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + eeprom_type = 1; + } + if (crc == 0x146fb9c3) + { // SD Gundam Gaiden - Knight Gundam Monogatari(J) + } + + if (crc == 0x73ac76db // SD Gundam Gaiden - Knight Gundam Monogatari 2 - Hikari no Kishi(J) + || crc == 0x81a15eb8) + { // SD Gundam Gaiden - Knight Gundam Monogatari 3 - Densetsu no Kishi Dan(J) + eeprom_type = 1; + } + if (crc == 0x170250de) + { // Rokudenashi Blues(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + eeprom_type = 1; + } + + // DATACHç³» + if (crc == 0x0be0a328 // Datach - SD Gundam - Gundam Wars(J) + || crc == 0x19e81461 // Datach - Dragon Ball Z - Gekitou Tenkaichi Budou Kai(J) + || crc == 0x5b457641 // Datach - Ultraman Club - Supokon Fight!(J) + || crc == 0x894efdbc // Datach - Crayon Shin Chan - Ora to Poi Poi(J) + || crc == 0x983d8175 // Datach - Battle Rush - Build Up Robot Tournament(J) + || crc == 0xbe06853f) + { // Datach - J League Super Top Players(J) + eeprom_type = 2; + } + if (crc == 0xf51a7f46) + { // Datach - Yuu Yuu Hakusho - Bakutou Ankoku Bujutsu Kai(J) + nes.SetIrqType(NES.IRQMETHOD.IRQ_HSYNC); + eeprom_type = 2; + } + + if (eeprom_type == 0) + { + nes.SetSAVERAM_SIZE(128); + x24c01.Reset(WRAM); + } + else + if (eeprom_type == 1) + { + nes.SetSAVERAM_SIZE(256); + x24c02.Reset(WRAM); + } + else + if (eeprom_type == 2) + { + nes.SetSAVERAM_SIZE(384); + x24c02.Reset(WRAM); + x24c01.Reset(new ByteArrayRef(WRAM, 256)); + } + } + + //BYTE Mapper016::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (patch != 0) + { + return base.ReadLow(addr); + } + else + { + if ((addr & 0x00FF) == 0x0000) + { + BYTE ret = 0; + if (eeprom_type == 0) + { + ret = x24c01.Read(); + } + else + if (eeprom_type == 1) + { + ret = x24c02.Read(); + } + else + if (eeprom_type == 2) + { + ret = (byte)(x24c02.Read() & x24c01.Read()); + } + return (byte)((ret != 0 ? 0x10 : 0) | (nes.GetBarcodeStatus())); + } + } + return 0x00; + } + + //void Mapper016::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (patch == 0) + { + WriteSubA(addr, data); + } + else + { + base.WriteLow(addr, data); + } + } + + public override void Write(ushort addr, byte data) + { + if (patch == 0) + { + WriteSubA(addr, data); + } + else + { + WriteSubB(addr, data); + } + } + + static BYTE eeprom_addinc; + + // Normal mapper #16 + void WriteSubA(ushort addr, BYTE data) + { + switch (addr & 0x000F) + { + case 0x0000: + case 0x0001: + case 0x0002: + case 0x0003: + case 0x0004: + case 0x0005: + case 0x0006: + case 0x0007: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank((byte)(addr & 0x0007), data); + } + if (eeprom_type == 2) + { + reg[0] = data; + x24c01.Write((byte)((data & 0x08) != 0 ? 0xFF : 0), (byte)((reg[1] & 0x40) != 0 ? 0xFF : 0)); + } + break; + + case 0x0008: + SetPROM_16K_Bank(4, data); + break; + + case 0x0009: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x000A: + irq_enable = (byte)(data & 0x01); + irq_counter = irq_latch; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0x000B: + irq_latch = (irq_latch & 0xFF00) | data; + irq_counter = (irq_counter & 0xFF00) | data; + break; + case 0x000C: + irq_latch = (data << 8) | (irq_latch & 0x00FF); + irq_counter = (data << 8) | (irq_counter & 0x00FF); + break; + + case 0x000D: + // EEPTYPE0(DragonBallZ) + if (eeprom_type == 0) + { + x24c01.Write((byte)((data & 0x20) != 0 ? 0xFF : 0), (byte)((data & 0x40) != 0 ? 0xFF : 0)); + } + // EEPTYPE1(DragonBallZ2,Z3,Z Gaiden) + if (eeprom_type == 1) + { + x24c02.Write((byte)((data & 0x20) != 0 ? 0xFF : 0), (byte)((data & 0x40) != 0 ? 0xFF : 0)); + } + // EEPTYPE2(DATACH) + if (eeprom_type == 2) + { + reg[1] = data; + x24c02.Write((byte)((data & 0x20) != 0 ? 0xFF : 0), (byte)((data & 0x40) != 0 ? 0xFF : 0)); + x24c01.Write((byte)((reg[0] & 0x08) != 0 ? 0xFF : 0), (byte)((data & 0x40) != 0 ? 0xFF : 0)); + } + break; + } + } + + // Famicom Jump 2 + void WriteSubB(ushort addr, BYTE data) + { + switch (addr) + { + case 0x8000: + case 0x8001: + case 0x8002: + case 0x8003: + reg[0] = (byte)(data & 0x01); + SetPROM_8K_Bank(4, reg[0] * 0x20 + reg[2] * 2 + 0); + SetPROM_8K_Bank(5, reg[0] * 0x20 + reg[2] * 2 + 1); + break; + case 0x8004: + case 0x8005: + case 0x8006: + case 0x8007: + reg[1] = (byte)(data & 0x01); + SetPROM_8K_Bank(6, reg[1] * 0x20 + 0x1E); + SetPROM_8K_Bank(7, reg[1] * 0x20 + 0x1F); + break; + case 0x8008: + reg[2] = data; + SetPROM_8K_Bank(4, reg[0] * 0x20 + reg[2] * 2 + 0); + SetPROM_8K_Bank(5, reg[0] * 0x20 + reg[2] * 2 + 1); + SetPROM_8K_Bank(6, reg[1] * 0x20 + 0x1E); + SetPROM_8K_Bank(7, reg[1] * 0x20 + 0x1F); + break; + + case 0x8009: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x800A: + irq_enable = (byte)(data & 0x01); + irq_counter = irq_latch; + + // if( !irq_enable ) { + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + // } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0x800B: + irq_latch = (irq_latch & 0xFF00) | data; + break; + case 0x800C: + irq_latch = (data << 8) | (irq_latch & 0x00FF); + break; + + case 0x800D: + break; + } + } + + public override void HSync(int scanline) + { + if (irq_enable != 0 && (nes.GetIrqType() == (int)NES.IRQMETHOD.IRQ_HSYNC)) + { + if (irq_counter <= 113) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + // nes.cpu.IRQ(); + //// nes.cpu.IRQ_NotPending(); + // irq_enable = 0; + // irq_counter = 0; + irq_counter &= 0xFFFF; + } + else + { + irq_counter -= 113; + } + } + } + + public override void Clock(int cycles) + { + if (irq_enable != 0 && (nes.GetIrqType() == (int)NES.IRQMETHOD.IRQ_CLOCK)) + { + if ((irq_counter -= cycles) <= 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + // nes.cpu.IRQ(); + //// nes.cpu.IRQ_NotPending(); + // irq_enable = 0; + // irq_counter = 0; + irq_counter &= 0xFFFF; + } + } + } + + public override void SaveState(byte[] p) + { + //p[0] = reg[0]; + //p[1] = reg[1]; + //p[2] = reg[2]; + //p[3] = irq_enable; + //*(INT*)&p[4] = irq_counter; + //*(INT*)&p[8] = irq_latch; + + //if (eeprom_type == 0) + //{ + // x24c01.Save(&p[16]); + //} + //else + //if (eeprom_type == 1) + //{ + // x24c02.Save(&p[16]); + //} + //else + //if (eeprom_type == 2) + //{ + // x24c02.Save(&p[16]); + // x24c01.Save(&p[48]); + //} + } + + public override void LoadState(byte[] p) + { + //reg[0] = p[0]; + //reg[1] = p[1]; + //reg[2] = p[2]; + //irq_enable = p[3]; + //irq_counter = *(INT*)&p[4]; + //irq_latch = *(INT*)&p[8]; + //if (eeprom_type == 0) + //{ + // x24c01.Load(&p[16]); + //} + //else + //if (eeprom_type == 1) + //{ + // x24c02.Load(&p[16]); + //} + //else + //if (eeprom_type == 2) + //{ + // x24c02.Load(&p[16]); + // x24c01.Load(&p[48]); + //} + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper016.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper016.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs.meta index 52881ef..cace94d 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper016.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0a10f96e86bb11143ba3f4bc30388390 +guid: 6dc87b177aa092e4e98c49eb5b9e0bfb MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs new file mode 100644 index 0000000..d1344c1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs @@ -0,0 +1,127 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper017 : Mapper + { + BYTE irq_enable; + INT irq_counter; + INT irq_latch; + public Mapper017(NES parent) : base(parent) + { + } + + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + } + + //void Mapper017::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x42FE: + if ((data & 0x10) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + break; + case 0x42FF: + if ((data & 0x10) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + + case 0x4501: + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0x4502: + irq_latch = (irq_latch & 0xFF00) | data; + break; + case 0x4503: + irq_latch = (irq_latch & 0x00FF) | ((INT)data << 8); + irq_counter = irq_latch; + irq_enable = 0xFF; + break; + + case 0x4504: + case 0x4505: + case 0x4506: + case 0x4507: + SetPROM_8K_Bank((byte)(addr & 0x07), data); + break; + + case 0x4510: + case 0x4511: + case 0x4512: + case 0x4513: + case 0x4514: + case 0x4515: + case 0x4516: + case 0x4517: + SetVROM_1K_Bank((byte)(addr & 0x07), data); + break; + + default: + base.WriteLow(addr, data); + break; + } + } + + //void Mapper017::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if (irq_counter >= 0xFFFF - 113) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + // nes.cpu.IRQ(); + // irq_counter = 0; + // irq_enable = 0; + irq_counter &= 0xFFFF; + } + else + { + irq_counter += 113; + } + } + } + + //void Mapper017::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //*(INT*)&p[1] = irq_counter; + //*(INT*)&p[5] = irq_latch; + } + + //void Mapper017::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = *(INT*)&p[1]; + //irq_latch = *(INT*)&p[5]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper017.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper017.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs.meta index 601a986..6b34a7d 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper017.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a53431c37c141204e9148d581878b56e +guid: 776d527e770087845a767df931da9af6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs new file mode 100644 index 0000000..c476644 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs @@ -0,0 +1,278 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper018 Jaleco SS8806 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper018 : Mapper + { + BYTE[] reg = new byte[11]; + + BYTE irq_enable; + BYTE irq_mode; + INT irq_latch; + INT irq_counter; + public Mapper018(NES parent) : base(parent) + { + } + + + public override void Reset() + { + for (INT i = 0; i < 11; i++) + { + reg[i] = 0; + } + reg[2] = (byte)(PROM_8K_SIZE - 2); + reg[3] = (byte)(PROM_8K_SIZE - 1); + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + irq_enable = 0; + irq_mode = 0; + irq_counter = 0xFFFF; + irq_latch = 0xFFFF; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xefb1df9e) + { // The Lord of King(J) + nes.SetRenderMethod(EnumRenderMethod.PRE_ALL_RENDER); + } + if (crc == 0x3746f951) + { // Pizza Pop!(J) + nes.SetRenderMethod(EnumRenderMethod.PRE_ALL_RENDER); + } + + // nes.SetRenderMethod( NES::PRE_ALL_RENDER ); + // nes.SetRenderMethod( NES::POST_ALL_RENDER ); + } + + //void Mapper018::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetPROM_8K_Bank(4, reg[0]); + break; + case 0x8001: + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4)); + SetPROM_8K_Bank(4, reg[0]); + break; + case 0x8002: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetPROM_8K_Bank(5, reg[1]); + break; + case 0x8003: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetPROM_8K_Bank(5, reg[1]); + break; + case 0x9000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetPROM_8K_Bank(6, reg[2]); + break; + case 0x9001: + reg[2] = (byte)((reg[2] & 0x0F) | ((data & 0x0F) << 4)); + SetPROM_8K_Bank(6, reg[2]); + break; + + case 0xA000: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[3]); + break; + case 0xA001: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(0, reg[3]); + break; + case 0xA002: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[4]); + break; + case 0xA003: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[4]); + break; + + case 0xB000: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[5]); + break; + case 0xB001: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(2, reg[5]); + break; + case 0xB002: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[6]); + break; + case 0xB003: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[6]); + break; + + case 0xC000: + reg[7] = (byte)((reg[7] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[7]); + break; + case 0xC001: + reg[7] = (byte)((reg[7] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[7]); + break; + case 0xC002: + reg[8] = (byte)((reg[8] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[8]); + break; + case 0xC003: + reg[8] = (byte)((reg[8] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[8]); + break; + + case 0xD000: + reg[9] = (byte)((reg[9] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[9]); + break; + case 0xD001: + reg[9] = (byte)((reg[9] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[9]); + break; + case 0xD002: + reg[10] = (byte)((reg[10] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[10]); + break; + case 0xD003: + reg[10] = (byte)((reg[10] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(7, reg[10]); + break; + + case 0xE000: + irq_latch = (irq_latch & 0xFFF0) | (data & 0x0F); + break; + case 0xE001: + irq_latch = (irq_latch & 0xFF0F) | ((data & 0x0F) << 4); + break; + case 0xE002: + irq_latch = (irq_latch & 0xF0FF) | ((data & 0x0F) << 8); + break; + case 0xE003: + irq_latch = (irq_latch & 0x0FFF) | ((data & 0x0F) << 12); + break; + + case 0xF000: + // if( data & 0x01 ) { + irq_counter = irq_latch; + // } else { + // irq_counter = 0; + // } + break; + case 0xF001: + irq_mode = (byte)((data >> 1) & 0x07); + irq_enable = ((byte)(data & 0x01)); + // if( !irq_enable ) { + nes.cpu.ClrIRQ(IRQ_MAPPER); + // } + break; + + case 0xF002: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_MIRROR4L); + break; + } + } + + //void Mapper018::Clock(INT cycles) + public override void Clock(int cycles) + { + bool bIRQ = false; + INT irq_counter_old = irq_counter; + + if (irq_enable != 0 && irq_counter != 0) + { + irq_counter -= cycles; + + switch (irq_mode) + { + case 0: + if (irq_counter <= 0) + { + bIRQ = true; + } + break; + case 1: + if ((irq_counter & 0xF000) != (irq_counter_old & 0xF000)) + { + bIRQ = true; + } + break; + case 2: + case 3: + if ((irq_counter & 0xFF00) != (irq_counter_old & 0xFF00)) + { + bIRQ = true; + } + break; + case 4: + case 5: + case 6: + case 7: + if ((irq_counter & 0xFFF0) != (irq_counter_old & 0xFFF0)) + { + bIRQ = true; + } + break; + } + + if (bIRQ) + { + //// irq_enable = 0; + // irq_counter = irq_latch; + irq_counter = 0; + irq_enable = 0; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper018::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 11; i++) + //{ + // p[i] = reg[i]; + //} + //p[11] = irq_enable; + //p[12] = irq_mode; + //*(INT*)&p[13] = irq_counter; + //*(INT*)&p[17] = irq_latch; + } + + //void Mapper018::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 11; i++) + //{ + // p[i] = reg[i]; + //} + //irq_enable = p[11]; + //irq_mode = p[12]; + //irq_counter = *(INT*)&p[13]; + //irq_latch = *(INT*)&p[17]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper018.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper018.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs.meta index 3fc21f0..1e6d762 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper018.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b9409e3543eded64ba7d391f604d4157 +guid: d9f306005d0826a4e96ceec780568bb3 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs new file mode 100644 index 0000000..24bd3d0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs @@ -0,0 +1,417 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper019 Namcot 106 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper019 : Mapper + { + BYTE patch; + BYTE exsound_enable; + + BYTE[] reg = new byte[3]; + BYTE[] exram = new byte[128]; + + BYTE irq_enable; + ushort irq_counter; + public Mapper019(NES parent) : base(parent) + { + } + + + public override void Reset() + { + patch = 0; + + reg[0] = reg[1] = reg[2] = 0; + + MemoryUtility.ZEROMEMORY(exram, exram.Length); + + irq_enable = 0; + irq_counter = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE >= 8) + { + SetVROM_8K_Bank(VROM_8K_SIZE - 1); + } + + exsound_enable = 0xFF; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xb62a7b71) + { // Family Circuit '91(J) + patch = 1; + } + + if (crc == 0x02738c68) + { // Wagan Land 2(J) + patch = 3; + } + if (crc == 0x14942c06) + { // Wagan Land 3(J) + patch = 2; + } + + if (crc == 0x968dcf09) + { // Final Lap(J) + nes.SetRenderMethod(EnumRenderMethod.PRE_ALL_RENDER); + } + if (crc == 0x3deac303) + { // Rolling Thunder(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + + if (crc == 0xb1b9e187) + { // For Kaijuu Monogatari(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + + if (crc == 0x6901346e) + { // For Sangokushi 2 - Haou no Tairiku(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + + // if( crc == 0xdd454208 ) { // Hydlide 3(J) + // nes.SetRenderMethod( NES::PRE_ALL_RENDER ); + // } + + if (crc == 0xaf15338f // For Mindseeker(J) + || crc == 0xb1b9e187 // For Kaijuu Monogatari(J) + || crc == 0x96533999 // Dokuganryuu Masamune(J) + // || crc == 0x2b825ce1 // Namco Classic(J) + // || crc == 0x9a2b0641 // Namco Classic 2(J) + || crc == 0x3296ff7a // Battle Fleet(J) + || crc == 0xdd454208) + { // Hydlide 3(J) + exsound_enable = 0; + } + + if (crc == 0x429fd177) + { // Famista '90(J) + exsound_enable = 0; + } + + if (exsound_enable != 0) + { + nes.apu.SelectExSound(0x10); + } + } + + //BYTE Mapper019::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + BYTE data = 0; + + switch (addr & 0xF800) + { + case 0x4800: + if (addr == 0x4800) + { + if (exsound_enable != 0) + { + nes.apu.ExRead(addr); + data = exram[reg[2] & 0x7F]; + } + else + { + data = WRAM[reg[2] & 0x7F]; + } + if ((reg[2] & 0x80) != 0) + reg[2] = (byte)((reg[2] + 1) | 0x80); + return data; + } + break; + case 0x5000: + return (byte)((BYTE)irq_counter & 0x00FF); + case 0x5800: + return (BYTE)((irq_counter >> 8) & 0x7F); + case 0x6000: + case 0x6800: + case 0x7000: + case 0x7800: + return base.ReadLow(addr); + } + + return (BYTE)(addr >> 8); + } + + //void Mapper019::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr & 0xF800) + { + case 0x4800: + if (addr == 0x4800) + { + if (exsound_enable != 0) + { + nes.apu.ExWrite(addr, data); + exram[reg[2] & 0x7F] = data; + } + else + { + WRAM[reg[2] & 0x7F] = data; + } + if ((reg[2] & 0x80) != 0) + reg[2] = (byte)((reg[2] + 1) | 0x80); + } + break; + case 0x5000: + irq_counter = (byte)((irq_counter & 0xFF00) | (ushort)data); + // if( irq_enable ) { + // irq_counter++; + // } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0x5800: + irq_counter = (byte)((irq_counter & 0x00FF) | ((ushort)(data & 0x7F) << 8)); + irq_enable = (byte)(data & 0x80); + // if( irq_enable ) { + // irq_counter++; + // } + // if( !irq_enable ) { + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + // } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0x6000: + case 0x6800: + case 0x7000: + case 0x7800: + base.WriteLow(addr, data); + break; + } + } + + //void Mapper019::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //if( addr >= 0xC000 ) { + //DEBUGOUT( "W %04X %02X L:%3d\n", addr, data, nes.GetScanline() ); + //} + switch (addr & 0xF800) + { + case 0x8000: + if ((data < 0xE0) || (reg[0] != 0)) + { + SetVROM_1K_Bank(0, data); + } + else + { + SetCRAM_1K_Bank(0, data & 0x1F); + } + break; + case 0x8800: + if ((data < 0xE0) || (reg[0] != 0)) + { + SetVROM_1K_Bank(1, data); + } + else + { + SetCRAM_1K_Bank(1, data & 0x1F); + } + break; + case 0x9000: + if ((data < 0xE0) || (reg[0] != 0)) + { + SetVROM_1K_Bank(2, data); + } + else + { + SetCRAM_1K_Bank(2, data & 0x1F); + } + break; + case 0x9800: + if ((data < 0xE0) || (reg[0] != 0)) + { + SetVROM_1K_Bank(3, data); + } + else + { + SetCRAM_1K_Bank(3, data & 0x1F); + } + break; + case 0xA000: + if ((data < 0xE0) || (reg[1] != 0)) + { + SetVROM_1K_Bank(4, data); + } + else + { + SetCRAM_1K_Bank(4, data & 0x1F); + } + break; + case 0xA800: + if ((data < 0xE0) || (reg[1] != 0)) + { + SetVROM_1K_Bank(5, data); + } + else + { + SetCRAM_1K_Bank(5, data & 0x1F); + } + break; + case 0xB000: + if ((data < 0xE0) || (reg[1] != 0)) + { + SetVROM_1K_Bank(6, data); + } + else + { + SetCRAM_1K_Bank(6, data & 0x1F); + } + break; + case 0xB800: + if ((data < 0xE0) || (reg[1] != 0)) + { + SetVROM_1K_Bank(7, data); + } + else + { + SetCRAM_1K_Bank(7, data & 0x1F); + } + break; + case 0xC000: + if (patch == 0) + { + if (data <= 0xDF) + { + SetVROM_1K_Bank(8, data); + } + else + { + SetVRAM_1K_Bank(8, data & 0x01); + } + } + break; + case 0xC800: + if (patch == 0) + { + if (data <= 0xDF) + { + SetVROM_1K_Bank(9, data); + } + else + { + SetVRAM_1K_Bank(9, data & 0x01); + } + } + break; + case 0xD000: + if (patch == 0) + { + if (data <= 0xDF) + { + SetVROM_1K_Bank(10, data); + } + else + { + SetVRAM_1K_Bank(10, data & 0x01); + } + } + break; + case 0xD800: + if (patch == 0) + { + if (data <= 0xDF) + { + SetVROM_1K_Bank(11, data); + } + else + { + SetVRAM_1K_Bank(11, data & 0x01); + } + } + break; + case 0xE000: + SetPROM_8K_Bank(4, data & 0x3F); + if (patch == 2) + { + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + if (patch == 3) + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xE800: + reg[0] = (byte)(data & 0x40); + reg[1] = (byte)(data & 0x80); + SetPROM_8K_Bank(5, data & 0x3F); + break; + case 0xF000: + SetPROM_8K_Bank(6, data & 0x3F); + break; + case 0xF800: + if (addr == 0xF800) + { + if (exsound_enable != 0) + { + nes.apu.ExWrite(addr, data); + } + reg[2] = data; + } + break; + } + } + + //void Mapper019::Clock(INT cycles) + public override void Clock(int cycles) + { + if (irq_enable != 0) + { + irq_counter = (ushort)(irq_counter + cycles); + if (irq_counter >= 0x7FFF) + { + // irq_counter = 0x7FFF; + // nes.cpu.IRQ_NotPending(); + + irq_enable = 0; + // irq_counter &= 0x7FFF; + irq_counter = 0x7FFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper019::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + // p[0] = reg[0]; + // p[1] = reg[1]; + // p[2] = reg[2]; + // p[3] = irq_enable; + // *(WORD*)&p[4] = irq_counter; + + //::memcpy(&p[8], exram, sizeof(exram)); + } + + //void Mapper019::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + // reg[0] = p[0]; + // reg[1] = p[1]; + // reg[2] = p[2]; + // irq_enable = p[3]; + // irq_counter = *(WORD*)&p[4]; + + //::memcpy(exram, &p[8], sizeof(exram)); + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper019.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper019.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs.meta index 86d96db..1204e14 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper019.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e12370c4d1f15a246ad180d702f92a1a +guid: e0d99073c4ae1444bbf4fa05498aecb8 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs new file mode 100644 index 0000000..5e367f5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs @@ -0,0 +1,255 @@ +////////////////// +// Mapper021 Konami VRC4 (Address mask $F006 or $F0C0) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper021 : Mapper + { + BYTE[] reg = new byte[9]; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper021(NES parent) : base(parent) + { + } + + + public override void Reset() + { + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + reg[8] = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper021::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF0CF) + { + case 0x8000: + if ((reg[8] & 0x02) != 0) + { + SetPROM_8K_Bank(6, data); + } + else + { + SetPROM_8K_Bank(4, data); + } + break; + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + + case 0x9000: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x9002: + case 0x9080: + reg[8] = data; + break; + + case 0xB000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB002: + case 0xB040: + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(0, reg[0]); + break; + + case 0xB001: + case 0xB004: + case 0xB080: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + case 0xB003: + case 0xB006: + case 0xB0C0: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC002: + case 0xC040: + reg[2] = (byte)((reg[2] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(2, reg[2]); + break; + + case 0xC001: + case 0xC004: + case 0xC080: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + case 0xC003: + case 0xC006: + case 0xC0C0: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD002: + case 0xD040: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + + case 0xD001: + case 0xD004: + case 0xD080: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + case 0xD003: + case 0xD006: + case 0xD0C0: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE002: + case 0xE040: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + + case 0xE001: + case 0xE004: + case 0xE080: + reg[7] = (byte)((reg[7] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + case 0xE003: + case 0xE006: + case 0xE0C0: + reg[7] = (byte)((reg[7] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0xF000: + irq_latch = (byte)((irq_latch & 0xF0) | (data & 0x0F)); + break; + case 0xF002: + case 0xF040: + irq_latch = (byte)((irq_latch & 0x0F) | ((data & 0x0F) << 4)); + break; + + case 0xF003: + case 0xF0C0: + case 0xF006: + irq_enable = (byte)((irq_enable & 0x01) * 3); + irq_clock = 0; + + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF004: + case 0xF080: + irq_enable = (byte)(data & 0x03); + if ((irq_enable & 0x02) != 0) + { + irq_counter = irq_latch; + irq_clock = 0; + } + + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + // case 0xF006: + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + // break; + } + } + + //void Mapper021::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + if ((irq_clock -= cycles) < 0) + { + irq_clock += 0x72; + if (irq_counter == 0xFF) + { + irq_counter = irq_latch; + // irq_enable = (irq_enable & 0x01) * 3; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter++; + } + } + } + } + + //void Mapper021::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 9; i++) + //{ + // p[i] = reg[i]; + //} + //p[9] = irq_enable; + //p[10] = irq_counter; + //p[11] = irq_latch; + //*(INT*)&p[12] = irq_clock; + } + + //void Mapper021::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 9; i++) + //{ + // reg[i] = p[i]; + //} + //irq_enable = p[9]; + //irq_counter = p[10]; + //irq_latch = p[11]; + //irq_clock = *(INT*)&p[12]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper021.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper021.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs.meta index 59f7ada..db8c641 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper021.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0579b5a05fd8d6f4e8351ee140dda132 +guid: 6082f7bf68f41f6439e13610e7766887 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper022.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper022.cs new file mode 100644 index 0000000..6b20420 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper022.cs @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper022 Konami VRC2 type A // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper022 : Mapper + { + public Mapper022(NES parent) : base(parent) + { + } + + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper022::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + + case 0x9000: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + break; + + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + + case 0xB000: + SetVROM_1K_Bank(0, data >> 1); + break; + + case 0xB001: + SetVROM_1K_Bank(1, data >> 1); + break; + + case 0xC000: + SetVROM_1K_Bank(2, data >> 1); + break; + + case 0xC001: + SetVROM_1K_Bank(3, data >> 1); + break; + + case 0xD000: + SetVROM_1K_Bank(4, data >> 1); + break; + + case 0xD001: + SetVROM_1K_Bank(5, data >> 1); + break; + + case 0xE000: + SetVROM_1K_Bank(6, data >> 1); + break; + + case 0xE001: + SetVROM_1K_Bank(7, data >> 1); + break; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper022.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper022.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper022.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper022.cs.meta index ddd31b1..989544d 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper022.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper022.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 37f7c4432f871c64287860405074e0cb +guid: b618d4b61b1e6ed48ad8ab3a38947424 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs new file mode 100644 index 0000000..894259b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs @@ -0,0 +1,271 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper023 Konami VRC2 type B // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper023 : Mapper + { + + ushort addrmask; + + BYTE[] reg = new byte[9]; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper023(NES parent) : base(parent) + { + } + + + public override void Reset() + { + addrmask = 0xFFFF; + + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + reg[8] = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + reg[9] = 1; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + + // nes.SetRenderMethod( NES::POST_RENDER ); + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0x93794634 // Akumajou Special Boku Dracula Kun(J) + || crc == 0xc7829dae // Akumajou Special Boku Dracula Kun(T-Eng) + || crc == 0xf82dc02f) + { // Akumajou Special Boku Dracula Kun(T-Eng v1.02) + addrmask = 0xF00C; + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + if (crc == 0xdd53c4ae) + { // Tiny Toon Adventures(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + } + + //void Mapper023::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + switch (addr & addrmask) + { + case 0x8000: + case 0x8004: + case 0x8008: + case 0x800C: + if (reg[8] != 0) + { + SetPROM_8K_Bank(6, data); + } + else + { + SetPROM_8K_Bank(4, data); + } + break; + + case 0x9000: + if (data != 0xFF) + { + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + } + break; + + case 0x9008: + reg[8] = (byte)(data & 0x02); + break; + + case 0xA000: + case 0xA004: + case 0xA008: + case 0xA00C: + SetPROM_8K_Bank(5, data); + break; + + case 0xB000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB001: + case 0xB004: + reg[0] = ((byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4))); + SetVROM_1K_Bank(0, reg[0]); + break; + + case 0xB002: + case 0xB008: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xB003: + case 0xB00C: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + + case 0xC001: + case 0xC004: + reg[2] = (byte)((reg[2] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(2, reg[2]); + break; + + case 0xC002: + case 0xC008: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xC003: + case 0xC00C: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + + case 0xD001: + case 0xD004: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + + case 0xD002: + case 0xD008: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xD003: + case 0xD00C: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + + case 0xE001: + case 0xE004: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + + case 0xE002: + case 0xE008: + reg[7] = (byte)((reg[7] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0xE003: + case 0xE00C: + reg[7] = ((byte)((reg[7] & 0x0F) | ((data & 0x0F) << 4))); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0xF000: + irq_latch = (byte)((irq_latch & 0xF0) | (data & 0x0F)); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xF004: + irq_latch = (byte)((irq_latch & 0x0F) | ((data & 0x0F) << 4)); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF008: + irq_enable = (byte)(data & 0x03); + irq_counter = irq_latch; + irq_clock = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF00C: + irq_enable = (byte)((irq_enable & 0x01) * 3); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper023::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + irq_clock += cycles * 3; + while (irq_clock >= 341) + { + irq_clock -= 341; + irq_counter++; + if (irq_counter == 0) + { + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + //void Mapper023::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 9; i++) + //{ + // p[i] = reg[i]; + //} + //p[9] = irq_enable; + //p[10] = irq_counter; + //p[11] = irq_latch; + //*(INT*)&p[12] = irq_clock; + } + + //void Mapper023::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 9; i++) + //{ + // reg[i] = p[i]; + //} + //irq_enable = p[9]; + //irq_counter = p[10]; + //irq_latch = p[11]; + //irq_clock = *(INT*)&p[12]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper023.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper023.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs.meta index 11e063f..0b14e76 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper023.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ad20b02baf8d45749a5f2ffffcba13f5 +guid: d201617d198186e41b362ea94be5533c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs new file mode 100644 index 0000000..77d31af --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs @@ -0,0 +1,174 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper024 Konami VRC6 (Normal) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper024 : Mapper + { + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper024(NES parent) : base(parent) + { + } + + + public override void Reset() + { + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + // nes.SetRenderMethod( NES::PRE_RENDER ); + + nes.apu.SelectExSound(1); + } + + //void Mapper024::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF003) + { + case 0x8000: + SetPROM_16K_Bank(4, data); + break; + + case 0x9000: + case 0x9001: + case 0x9002: + case 0xA000: + case 0xA001: + case 0xA002: + case 0xB000: + case 0xB001: + case 0xB002: + nes.apu.ExWrite(addr, data); + break; + + case 0xB003: + data = (byte)(data & 0x0C); + if (data == 0x00) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 0x04) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 0x08) SetVRAM_Mirror(VRAM_MIRROR4L); + else if (data == 0x0C) SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0xC000: + SetPROM_8K_Bank(6, data); + break; + + case 0xD000: + SetVROM_1K_Bank(0, data); + break; + + case 0xD001: + SetVROM_1K_Bank(1, data); + break; + + case 0xD002: + SetVROM_1K_Bank(2, data); + break; + + case 0xD003: + SetVROM_1K_Bank(3, data); + break; + + case 0xE000: + SetVROM_1K_Bank(4, data); + break; + + case 0xE001: + SetVROM_1K_Bank(5, data); + break; + + case 0xE002: + SetVROM_1K_Bank(6, data); + break; + + case 0xE003: + SetVROM_1K_Bank(7, data); + break; + + case 0xF000: + irq_latch = data; + break; + case 0xF001: + irq_enable = (byte)(data & 0x03); + if ((irq_enable & 0x02) != 0) + { + irq_counter = irq_latch; + irq_clock = 0; + } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xF002: + irq_enable = (byte)((irq_enable & 0x01) * 3); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper024::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + if ((irq_clock += cycles) >= 0x72) + { + irq_clock -= 0x72; + if (irq_counter == 0xFF) + { + irq_counter = irq_latch; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter++; + } + } + } + } + + //void Mapper024::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //p[1] = irq_counter; + //p[2] = irq_latch; + //*(INT*)&p[3] = irq_clock; + } + + //void Mapper024::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = p[1]; + //irq_latch = p[2]; + //irq_clock = *(INT*)&p[3]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper024.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper024.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs.meta index 5dbecfc..d1dce11 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper024.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 555beee22dceafd4598f922cfd1aca63 +guid: 6e319508c6222744dbb48902f10ab3df MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs new file mode 100644 index 0000000..20a74ff --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs @@ -0,0 +1,278 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper025 Konami VRC4 (Normal) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper025 : Mapper + { + BYTE[] reg = new byte[11]; + BYTE irq_enable; + BYTE irq_latch; + BYTE irq_occur; + BYTE irq_counter; + INT irq_clock; + public Mapper025(NES parent) : base(parent) + { + } + + + public override void Reset() + { + for (INT i = 0; i < 11; i++) + { + reg[i] = 0; + } + reg[9] = (byte)(PROM_8K_SIZE - 2); + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_occur = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0xc71d4ce7) + { // Gradius II(J) + // nes.SetRenderMethod( NES::POST_RENDER ); + } + if (crc == 0xa2e68da8) + { // For Racer Mini Yonku - Japan Cup(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0xea74c587) + { // For Teenage Mutant Ninja Turtles(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x5f82cb7d) + { // For Teenage Mutant Ninja Turtles 2(J) + } + if (crc == 0x0bbd85ff) + { // For Bio Miracle Bokutte Upa(J) + nes.SetRenderMethod(EnumRenderMethod.PRE_ALL_RENDER); + } + } + + //void Mapper025::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //if( addr >= 0xF000 ) + //DEBUGOUT( "M25 WR $%04X=$%02X L=%3d\n", addr, data, nes.GetScanline() ); + + switch (addr & 0xF000) + { + case 0x8000: + if ((reg[10] & 0x02) != 0) + { + reg[9] = data; + SetPROM_8K_Bank(6, data); + } + else + { + reg[8] = data; + SetPROM_8K_Bank(4, data); + } + break; + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + } + + switch (addr & 0xF00F) + { + case 0x9000: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x9001: + case 0x9004: + if ((reg[10] & 0x02) != (data & 0x02)) + { + BYTE swap = reg[8]; + reg[8] = reg[9]; + reg[9] = swap; + + SetPROM_8K_Bank(4, reg[8]); + SetPROM_8K_Bank(6, reg[9]); + } + reg[10] = data; + break; + + case 0xB000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB002: + case 0xB008: + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(0, reg[0]); + break; + + case 0xB001: + case 0xB004: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + case 0xB003: + case 0xB00C: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC002: + case 0xC008: + reg[2] = (byte)((reg[2] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(2, reg[2]); + break; + + case 0xC001: + case 0xC004: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + case 0xC003: + case 0xC00C: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD002: + case 0xD008: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + + case 0xD001: + case 0xD004: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + case 0xD003: + case 0xD00C: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE002: + case 0xE008: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + + case 0xE001: + case 0xE004: + reg[7] = (byte)((reg[7] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + case 0xE003: + case 0xE00C: + reg[7] = (byte)((reg[7] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0xF000: + irq_latch = (byte)((irq_latch & 0xF0) | (data & 0x0F)); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF002: + case 0xF008: + irq_latch = (byte)((irq_latch & 0x0F) | ((data & 0x0F) << 4)); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF001: + case 0xF004: + irq_enable = (byte)(data & 0x03); + // irq_counter = 0x100 - irq_latch; + irq_counter = irq_latch; + irq_clock = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF003: + case 0xF00C: + irq_enable = (byte)((irq_enable & 0x01) * 3); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper025::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + irq_clock += cycles * 3; + while (irq_clock >= 341) + { + irq_clock -= 341; + irq_counter++; + if (irq_counter == 0) + { + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + //void Mapper025::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 11; i++) + //{ + // p[i] = reg[i]; + //} + //p[11] = irq_enable; + //p[12] = irq_occur; + //p[13] = irq_latch; + //p[14] = irq_counter; + //*((INT*)&p[15]) = irq_clock; + } + + //void Mapper025::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 11; i++) + //{ + // reg[i] = p[i]; + //} + //irq_enable = p[11]; + //irq_occur = p[12]; + //irq_latch = p[13]; + //irq_counter = p[14]; + //irq_clock = *((INT*)&p[15]); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper025.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper025.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs.meta index 35a992b..dd1a8a4 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper025.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c486d1b95f6d6fb4a922255ec293358e +guid: 6d065f0d406a26d4da372c16493e5bb9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs new file mode 100644 index 0000000..e677177 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs @@ -0,0 +1,185 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper026 Konami VRC6 (PA0,PA1 reverse) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper026 : Mapper + { + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper026(NES parent) : base(parent) + { + } + + + public override void Reset() + { + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0x30e64d03) + { // Esper Dream 2 - Aratanaru Tatakai(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + if (crc == 0x836cc1ab) + { // Mouryou Senki Madara(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + nes.apu.SelectExSound(1); + } + + //void Mapper026::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF003) + { + case 0x8000: + SetPROM_16K_Bank(4, data); + break; + + case 0x9000: + case 0x9001: + case 0x9002: + case 0x9003: + case 0xA000: + case 0xA001: + case 0xA002: + case 0xA003: + case 0xB000: + case 0xB001: + case 0xB002: + addr = (ushort)((addr & 0xfffc) | ((addr & 1) << 1) | ((addr & 2) >> 1)); + nes.apu.ExWrite(addr, data); + break; + + case 0xB003: + data = (byte)(data & 0x7F); + if (data == 0x08 || data == 0x2C) SetVRAM_Mirror(VRAM_MIRROR4H); + else if (data == 0x20) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 0x24) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 0x28) SetVRAM_Mirror(VRAM_MIRROR4L); + break; + + case 0xC000: + SetPROM_8K_Bank(6, data); + break; + + case 0xD000: + SetVROM_1K_Bank(0, data); + break; + + case 0xD001: + SetVROM_1K_Bank(2, data); + break; + + case 0xD002: + SetVROM_1K_Bank(1, data); + break; + + case 0xD003: + SetVROM_1K_Bank(3, data); + break; + + case 0xE000: + SetVROM_1K_Bank(4, data); + break; + + case 0xE001: + SetVROM_1K_Bank(6, data); + break; + + case 0xE002: + SetVROM_1K_Bank(5, data); + break; + + case 0xE003: + SetVROM_1K_Bank(7, data); + break; + + case 0xF000: + irq_latch = data; + break; + case 0xF001: + irq_enable = (byte)((irq_enable & 0x01) * 3); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xF002: + irq_enable = (byte)(data & 0x03); + if ((irq_enable & 0x02) != 0) + { + irq_counter = irq_latch; + irq_clock = 0; + } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper026::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + if ((irq_clock += cycles) >= 0x72) + { + irq_clock -= 0x72; + if (irq_counter >= 0xFF) + { + irq_counter = irq_latch; + // nes.cpu.IRQ_NotPending(); + //// nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter++; + } + } + } + } + + //void Mapper026::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //p[1] = irq_counter; + //p[2] = irq_latch; + //*(INT*)&p[3] = irq_clock; + } + + //void Mapper026::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = p[1]; + //irq_latch = p[2]; + //irq_clock = *(INT*)&p[3]; + } + + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper026.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper026.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs.meta index dcf8632..e517984 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper026.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: db4baec7ce5fb7143a58e2698f6a5e31 +guid: 96c606c490146244789d313ca2cf55a4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs new file mode 100644 index 0000000..994c4f7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs @@ -0,0 +1,228 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper027 Konami VRC4 (World Hero) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper027 : Mapper + { + ushort[] reg = new ushort[9]; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper027(NES parent) : base(parent) + { + } + + + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = (byte)i; + } + reg[8] = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0x47DCBCC4) + { // Gradius II(sample) + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + if (crc == 0x468F21FC) + { // Racer Mini 4 ku(sample) + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + } + + //void Mapper027::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF0CF) + { + case 0x8000: + if ((reg[8] & 0x02) != 0) + { + SetPROM_8K_Bank(6, data); + } + else + { + SetPROM_8K_Bank(4, data); + } + break; + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + + case 0x9000: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x9002: + case 0x9080: + reg[8] = data; + break; + + case 0xB000: + reg[0] = (ushort)((reg[0] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB001: + reg[0] = (ushort)((reg[0] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(0, reg[0]); + break; + + case 0xB002: + reg[1] = (ushort)((reg[1] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + case 0xB003: + reg[1] = (ushort)((reg[1] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (ushort)((reg[2] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC001: + reg[2] = (ushort)((reg[2] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(2, reg[2]); + break; + + case 0xC002: + reg[3] = (ushort)((reg[3] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + case 0xC003: + reg[3] = (ushort)((reg[3] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (ushort)((reg[4] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD001: + reg[4] = (ushort)((reg[4] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + + case 0xD002: + reg[5] = (ushort)((reg[5] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + case 0xD003: + reg[5] = (ushort)((reg[5] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (ushort)((reg[6] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE001: + reg[6] = (ushort)((reg[6] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + + case 0xE002: + reg[7] = (ushort)((reg[7] & 0xFF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + case 0xE003: + reg[7] = (ushort)((reg[7] & 0x0F) | (data << 4)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0xF000: + irq_latch = (byte)((irq_latch & 0xF0) | (data & 0x0F)); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xF001: + irq_latch = (byte)((irq_latch & 0x0F) | ((data & 0x0F) << 4)); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF003: + irq_enable = (byte)((irq_enable & 0x01) * 3); + irq_clock = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF002: + irq_enable = (byte)(data & 0x03); + if ((irq_enable & 0x02) != 0) + { + irq_counter = irq_latch; + irq_clock = 0; + } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper027::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((irq_enable & 0x02) != 0) + { + if (irq_counter == 0xFF) + { + irq_counter = irq_latch; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter++; + } + } + } + + //void Mapper027::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 9; i++) + //{ + // p[i] = reg[i]; + //} + //p[9] = irq_enable; + //p[10] = irq_counter; + //p[11] = irq_latch; + //*(INT*)&p[12] = irq_clock; + } + + //void Mapper027::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 9; i++) + //{ + // reg[i] = p[i]; + //} + //irq_enable = p[9]; + //irq_counter = p[10]; + //irq_latch = p[11]; + //irq_clock = *(INT*)&p[12]; + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs.meta new file mode 100644 index 0000000..a6e847b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 764ca4c42dfc3714e99ff2bbaf56c272 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper032.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper032.cs new file mode 100644 index 0000000..8c843af --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper032.cs @@ -0,0 +1,123 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper032 Irem G101 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper032 : Mapper + { + BYTE patch; + + BYTE reg; + public Mapper032(NES parent) : base(parent) + { + } + + + public override void Reset() + { + patch = 0; + reg = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + uint crc = nes.rom.GetPROM_CRC(); + + // For Major League(J) + if (crc == 0xc0fed437) + { + patch = 1; + } + // For Ai Sensei no Oshiete - Watashi no Hoshi(J) + if (crc == 0xfd3fc292) + { + SetPROM_32K_Bank(30, 31, 30, 31); + } + } + + //void Mapper032::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x8000: + if ((reg & 0x02) != 0) + { + SetPROM_8K_Bank(6, data); + } + else + { + SetPROM_8K_Bank(4, data); + } + break; + + case 0x9000: + reg = data; + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + } + + switch (addr & 0xF007) + { + case 0xB000: + case 0xB001: + case 0xB002: + case 0xB003: + case 0xB004: + case 0xB005: + SetVROM_1K_Bank((byte)(addr & 0x0007), data); + break; + case 0xB006: + SetVROM_1K_Bank(6, data); + + if (patch != 0 && ((data & 0x40) != 0)) + { + SetVRAM_Mirror(0, 0, 0, 1); + } + break; + case 0xB007: + SetVROM_1K_Bank(7, data); + + if (patch != 0 && ((data & 0x40) != 0)) + { + SetVRAM_Mirror(0, 0, 0, 0); + } + break; + } + } + + //void Mapper032::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper032::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper032.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper032.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper032.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper032.cs.meta index 9991fdc..72e1982 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper032.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper032.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e87da889f2fa51f49a00fb850557d445 +guid: 124a427e842cc7d4f879e27d559edfc7 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper033.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper033.cs new file mode 100644 index 0000000..f2ac3ba --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper033.cs @@ -0,0 +1,260 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper033 Taito TC0190 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper033 : Mapper + { + BYTE[] reg = new byte[7]; + + BYTE patch; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + public Mapper033(NES parent) : base(parent) + { + } + + + public override void Reset() + { + patch = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + + reg[0] = 0; + reg[1] = 2; + reg[2] = 4; + reg[3] = 5; + reg[4] = 6; + reg[5] = 7; + reg[6] = 1; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetBank(); + } + + uint crc = nes.rom.GetPROM_CRC(); + // Check For Old #33 games.... (CRC code by NesToy) + if (crc == 0x5e9bc161 // Akira(J) + || crc == 0xecdbafa4 // Bakushou!! Jinsei Gekijou(J) + || crc == 0x59cd0c31 // Don Doko Don(J) + || crc == 0x837c1342 // Golf Ko Open(J) + || crc == 0x42d893e4 // Operation Wolf(J) + || crc == 0x1388aeb9 // Operation Wolf(U) + || crc == 0x07ee6d8f // Power Blazer(J) + || crc == 0x5193fb54 // Takeshi no Sengoku Fuuunji(J) + || crc == 0xa71c3452) + { // Insector X(J) + patch = 1; + } + + nes.SetRenderMethod(EnumRenderMethod.PRE_RENDER); + + if (crc == 0x202df297) + { // Captain Saver(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + if (crc == 0x63bb86b5) + { // The Jetsons(J) + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + } + + //void Mapper033::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + // LOG( "Mapper033 addr=%04X data=%02X", addr&0xFFFF, data&0xFF ); + + switch (addr) + { + case 0x8000: + if (patch != 0) + { + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + SetPROM_8K_Bank(4, data & 0x1F); + } + else + { + SetPROM_8K_Bank(4, data); + } + break; + case 0x8001: + if (patch != 0) + { + SetPROM_8K_Bank(5, data & 0x1F); + } + else + { + SetPROM_8K_Bank(5, data); + } + break; + + case 0x8002: + reg[0] = data; + SetBank(); + break; + case 0x8003: + reg[1] = data; + SetBank(); + break; + case 0xA000: + reg[2] = data; + SetBank(); + break; + case 0xA001: + reg[3] = data; + SetBank(); + break; + case 0xA002: + reg[4] = data; + SetBank(); + break; + case 0xA003: + reg[5] = data; + SetBank(); + break; + +#if FLASE//0 + case 0xC003: + case 0xE003: + reg[6] = data; + SetBank(); + break; + + case 0xC000: + irq_counter = data; +// nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + + case 0xC001: + case 0xC002: + case 0xE001: + case 0xE002: + irq_enable = data; +// nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; +#else + case 0xC000: + irq_latch = data; + irq_counter = irq_latch; + break; + case 0xC001: + irq_counter = irq_latch; + break; + case 0xC002: + irq_enable = 1; + break; + case 0xC003: + irq_enable = 0; + break; + + case 0xE001: + case 0xE002: + case 0xE003: + break; +#endif + + case 0xE000: + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + } + } + + //void Mapper033::HSync(INT scanline) + public override void HSync(int scanline) + { +#if FALSE//0 +// nes.cpu.ClrIRQ( IRQ_MAPPER ); + if( scanline >= 0 && scanline <= 239 ) { + if( nes.ppu.IsDispON() ) { + if( irq_enable ) { + if( irq_counter == 0xFF ) { + irq_enable = 0; + irq_counter = 0; +// nes.cpu.SetIRQ( IRQ_MAPPER ); + nes.cpu.SetIRQ( IRQ_TRIGGER ); + } else { + irq_counter++; + } + } + } + } +#else + if (scanline >= 0 && scanline <= 239 && nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if (++irq_counter == 0) + { + irq_enable = 0; + irq_counter = 0; + nes.cpu.SetIRQ(IRQ_TRIGGER); + } + } + } +#endif + } + + void SetBank() + { + SetVROM_2K_Bank(0, reg[0]); + SetVROM_2K_Bank(2, reg[1]); + + // if( reg[6] & 0x01 ) { + SetVROM_1K_Bank(4, reg[2]); + SetVROM_1K_Bank(5, reg[3]); + SetVROM_1K_Bank(6, reg[4]); + SetVROM_1K_Bank(7, reg[5]); + // } else { + // SetVROM_2K_Bank( 4, reg[0] ); + // SetVROM_2K_Bank( 6, reg[1] ); + // } + } + + //void Mapper033::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 7; i++) + { + p[i] = reg[i]; + } + + p[7] = irq_enable; + p[8] = irq_counter; + p[9] = irq_latch; + } + + //void Mapper033::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 7; i++) + { + reg[i] = p[i]; + } + + irq_enable = p[7]; + irq_counter = p[8]; + irq_latch = p[9]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper033.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper033.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper033.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper033.cs.meta index 2076edf..0938cbf 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper033.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper033.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0d361d388950f6c4780d369471cd60d6 +guid: 8c7bedd1ba634c14fa3532bb9524cf80 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper034.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper034.cs new file mode 100644 index 0000000..6b4231e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper034.cs @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper034 Nina-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper034 : Mapper + { + public Mapper034(NES parent) : base(parent) + { + } + + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper034::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x7FFD: + SetPROM_32K_Bank(data); + break; + case 0x7FFE: + SetVROM_4K_Bank(0, data); + break; + case 0x7FFF: + SetVROM_4K_Bank(4, data); + break; + } + } + + //void Mapper034::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_32K_Bank(data); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper034.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper034.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper034.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper034.cs.meta index f25520f..cd0633b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper034.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper034.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d2c0d2bbce836014c834aa850db5c74e +guid: 647e21ec144715c45bbcf44a6b5757b1 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper035.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper035.cs new file mode 100644 index 0000000..74d50a3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper035.cs @@ -0,0 +1,124 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper035 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper035 : Mapper + { + + BYTE[] reg = new byte[8]; + BYTE[] chr = new byte[8]; + ushort IRQCount, IRQa; + public Mapper035(NES parent) : base(parent) + { + } + + + public override void Reset() + { + for (int i = 0; i < 8; i++) + reg[i] = chr[i] = 0; + + IRQCount = IRQa = 0; + + //SetPROM_32K_Bank( 0, 1, PROM_8K_SIZE-2, PROM_8K_SIZE-1 ); + + Sync(); + //setprg8r(0x10,0x6000,0); + SetPROM_8K_Bank(7, PROM_8K_SIZE - 1); + } + + void Sync() + { + int i; + SetPROM_8K_Bank(4, reg[0]); + SetPROM_8K_Bank(5, reg[1]); + SetPROM_8K_Bank(6, reg[2]); + for (i = 0; i < 8; i++) + SetVROM_1K_Bank((byte)i, chr[i]); + SetVRAM_Mirror(reg[3] ^ 1); + } + + //void Mapper035::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000 && addr <= 0x7FFF) + { + XRAM[addr - 0x6000] = data; + } + else + { + base.WriteLow(addr, data); + } + } + //BYTE Mapper035::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (addr >= 0x6000 && addr <= 0x7FFF) + { + return XRAM[addr - 0x6000]; + } + else + { + return base.ReadLow(addr); + } + } + + //void Mapper035::Write(WORD A, BYTE V) + public override void Write(ushort A, byte V) + { + switch (A) + { + case 0x8000: reg[0] = V; break; + case 0x8001: reg[1] = V; break; + case 0x8002: reg[2] = V; break; + case 0x9000: chr[0] = V; break; + case 0x9001: chr[1] = V; break; + case 0x9002: chr[2] = V; break; + case 0x9003: chr[3] = V; break; + case 0x9004: chr[4] = V; break; + case 0x9005: chr[5] = V; break; + case 0x9006: chr[6] = V; break; + case 0x9007: chr[7] = V; break; + case 0xC002: + IRQa = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); break; + case 0xC005: IRQCount = V; break; + case 0xC003: IRQa = 1; break; + case 0xD001: reg[3] = V; break; + } + Sync(); + } + + //void Mapper035::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (IRQa!=0) + { + IRQCount--; + if (IRQCount == 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + IRQa = 0; + } + } + } + } + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper035.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper035.cs.meta new file mode 100644 index 0000000..0c2f28a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper035.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a56d9f749be056e4b9ccf087899369ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs new file mode 100644 index 0000000..584a6ff --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs @@ -0,0 +1,90 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper040 SMB2J // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper040 : Mapper + { + BYTE irq_enable; + INT irq_line; + public Mapper040(NES parent) : base(parent) + { + } + + + public override void Reset() + { + irq_enable = 0; + irq_line = 0; + + SetPROM_8K_Bank(3, 6); + SetPROM_32K_Bank(4, 5, 0, 7); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper040::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE000) + { + case 0x8000: + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xA000: + irq_enable = 0xFF; + irq_line = 37; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC000: + break; + case 0xE000: + SetPROM_8K_Bank(6, data & 0x07); + break; + } + } + + //void Mapper040::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if (--irq_line <= 0) + { + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper040::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //*(INT*)&p[1] = irq_line; + } + + //void Mapper040::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_line = *(INT*)&p[1]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs.meta new file mode 100644 index 0000000..38ae7af --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: de917ab62c02ecc4b87138b609896ce7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper041.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper041.cs new file mode 100644 index 0000000..2a5df03 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper041.cs @@ -0,0 +1,78 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper041 Caltron 6-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper041 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper041(NES parent) : base(parent) + { + } + + + public override void Reset() + { + reg[0] = reg[1] = 0; + + SetPROM_32K_Bank(0, 1, 2, 3); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper041::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000 && addr < 0x6800) + { + SetPROM_32K_Bank(addr & 0x07); + reg[0] = (byte)(addr & 0x04); + reg[1] &= 0x03; + reg[1] |= (byte)((addr >> 1) & 0x0C); + SetVROM_8K_Bank(reg[1]); + if ((addr & 0x20) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + } + + //void Mapper041::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (reg[0] != 0) + { + reg[1] &= 0x0C; + reg[1] |= (byte)(addr & 0x03); + SetVROM_8K_Bank(reg[1]); + } + } + + //void Mapper041::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper041::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper041.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper041.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper041.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper041.cs.meta index a70d39f..f4a1119 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper041.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper041.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d7289b55e4c007a4c926f7b572f2469c +guid: fc0a11d806679d94da60252475da5996 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper042.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper042.cs new file mode 100644 index 0000000..a9c8be4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper042.cs @@ -0,0 +1,103 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper042 Mario Baby // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper042 : Mapper + { + BYTE irq_enable; + BYTE irq_counter; + public Mapper042(NES parent) : base(parent) + { + } + + + public override void Reset() + { + irq_enable = 0; + irq_counter = 0; + + SetPROM_8K_Bank(3, 0); + SetPROM_32K_Bank(PROM_8K_SIZE - 4, PROM_8K_SIZE - 3, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper042::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE003) + { + case 0xE000: + SetPROM_8K_Bank(3, data & 0x0F); + break; + + case 0xE001: + if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + + case 0xE002: + if ((data & 0x02) != 0) + { + irq_enable = 0xFF; + } + else + { + irq_enable = 0; + irq_counter = 0; + } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper042::HSync(INT scanline) + public override void HSync(int scanline) + { + nes.cpu.ClrIRQ(IRQ_MAPPER); + if (irq_enable != 0) + { + if (irq_counter < 215) + { + irq_counter++; + } + if (irq_counter == 215) + { + irq_enable = 0; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper042::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_enable; + p[1] = irq_counter; + } + + //void Mapper042::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_enable = p[0]; + irq_counter = p[1]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper042.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper042.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper042.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper042.cs.meta index d26c363..5a79206 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper042.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper042.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8d14e7ff8c821fd40a2583903904425c +guid: 0645c16b7e182fa4094ef038567fd95b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs new file mode 100644 index 0000000..97894ac --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs @@ -0,0 +1,138 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper043 SMB2J // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper043 : Mapper + { + BYTE irq_enable; + INT irq_counter; + public Mapper043(NES parent) : base(parent) + { + } + + + public override void Reset() + { + irq_enable = 0xFF; + irq_counter = 0; + + SetPROM_8K_Bank(3, 2); + SetPROM_32K_Bank(1, 0, 4, 9); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //BYTE Mapper043::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (0x5000 <= addr && addr < 0x6000) + { + byte[] pPtr = nes.rom.GetPROM(); + return pPtr[0x2000 * 8 + 0x1000 + (addr - 0x5000)]; + } + return (BYTE)(addr >> 8); + } + + //void Mapper043::ExWrite(WORD addr, BYTE data) + public override void ExWrite(ushort addr, byte data) + { + if ((addr & 0xF0FF) == 0x4022) + { + switch (data & 0x07) + { + case 0x00: + case 0x02: + case 0x03: + case 0x04: + SetPROM_8K_Bank(6, 4); + break; + case 0x01: + SetPROM_8K_Bank(6, 3); + break; + case 0x05: + SetPROM_8K_Bank(6, 7); + break; + case 0x06: + SetPROM_8K_Bank(6, 5); + break; + case 0x07: + SetPROM_8K_Bank(6, 6); + break; + } + } + } + + //void Mapper043::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xF0FF) == 0x4022) + { + ExWrite(addr, data); + } + } + + //void Mapper043::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr == 0x8122) + { + if ((data & 0x03) != 0) + { + irq_enable = 1; + } + else + { + irq_counter = 0; + irq_enable = 0; + } + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + } + + //void Mapper043::HSync(INT scanline) + public override void HSync(int scanline) + { + nes.cpu.ClrIRQ(IRQ_MAPPER); + if (irq_enable != 0) + { + irq_counter += 341; + if (irq_counter >= 12288) + { + irq_counter = 0; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper043::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //*(INT*)&p[1] = irq_counter; + } + + //void Mapper043::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = *(INT*)&p[1]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs.meta new file mode 100644 index 0000000..c4e0641 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2867bd866aa4459469bc4f3506ac516f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper044.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper044.cs new file mode 100644 index 0000000..b1736ee --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper044.cs @@ -0,0 +1,289 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper044 Super HiK 7-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper044 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE patch; + BYTE bank; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + public Mapper044(NES parent) : base(parent) + { + } + + + public override void Reset() + { + patch = 0; + + if (nes.rom.GetPROM_CRC() == 0x7eef434c) + { + patch = 1; + } + + for (INT i = 0; i < 8; i++) + { + reg[i] = 0; + } + + bank = 0; + prg0 = 0; + prg1 = 1; + + // set VROM banks + if (VROM_1K_SIZE!=0) + { + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + } + else + { + chr01 = chr23 = chr4 = chr5 = chr6 = chr7 = 0; + } + + SetBank_CPU(); + SetBank_PPU(); + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + } + + //void Mapper044::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x6000) + { + if (patch!=0) + { + bank = (byte)((data & 0x06) >> 1); + } + else + { + bank = (byte)((data & 0x01) << 1); + } + SetBank_CPU(); + SetBank_PPU(); + } + } + + //void Mapper044::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01)!=0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + bank = (byte)(data & 0x07); + if (bank == 7) + { + bank = 6; + } + SetBank_CPU(); + SetBank_PPU(); + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + } + } + + //void Mapper044::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable!=0) + { + if ((--irq_counter)==0) + { + irq_counter = irq_latch; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40)!=0) + { + SetPROM_8K_Bank(4, ((bank == 6) ? 0x1e : 0x0e) | (bank << 4)); + SetPROM_8K_Bank(5, ((bank == 6) ? 0x1f & prg1 : 0x0f & prg1) | (bank << 4)); + SetPROM_8K_Bank(6, ((bank == 6) ? 0x1f & prg0 : 0x0f & prg0) | (bank << 4)); + SetPROM_8K_Bank(7, ((bank == 6) ? 0x1f : 0x0f) | (bank << 4)); + } + else + { + SetPROM_8K_Bank(4, ((bank == 6) ? 0x1f & prg0 : 0x0f & prg0) | (bank << 4)); + SetPROM_8K_Bank(5, ((bank == 6) ? 0x1f & prg1 : 0x0f & prg1) | (bank << 4)); + SetPROM_8K_Bank(6, ((bank == 6) ? 0x1e : 0x0e) | (bank << 4)); + SetPROM_8K_Bank(7, ((bank == 6) ? 0x1f : 0x0f) | (bank << 4)); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE!=0) + { + if ((reg[0] & 0x80)!=0) + { + SetVROM_1K_Bank(0, ((bank == 6) ? 0xff & chr4 : 0x7f & chr4) | (bank << 7)); + SetVROM_1K_Bank(1, ((bank == 6) ? 0xff & chr5 : 0x7f & chr5) | (bank << 7)); + SetVROM_1K_Bank(2, ((bank == 6) ? 0xff & chr6 : 0x7f & chr6) | (bank << 7)); + SetVROM_1K_Bank(3, ((bank == 6) ? 0xff & chr7 : 0x7f & chr7) | (bank << 7)); + SetVROM_1K_Bank(4, ((bank == 6) ? 0xff & chr01 : 0x7f & chr01) | (bank << 7)); + SetVROM_1K_Bank(5, ((bank == 6) ? 0xff & (chr01 + 1) : 0x7f & (chr01 + 1)) | (bank << 7)); + SetVROM_1K_Bank(6, ((bank == 6) ? 0xff & chr23 : 0x7f & chr23) | (bank << 7)); + SetVROM_1K_Bank(7, ((bank == 6) ? 0xff & (chr23 + 1) : 0x7f & (chr23 + 1)) | (bank << 7)); + } + else + { + SetVROM_1K_Bank(0, ((bank == 6) ? 0xff & chr01 : 0x7f & chr01) | (bank << 7)); + SetVROM_1K_Bank(1, ((bank == 6) ? 0xff & (chr01 + 1) : 0x7f & (chr01 + 1)) | (bank << 7)); + SetVROM_1K_Bank(2, ((bank == 6) ? 0xff & chr23 : 0x7f & chr23) | (bank << 7)); + SetVROM_1K_Bank(3, ((bank == 6) ? 0xff & (chr23 + 1) : 0x7f & (chr23 + 1)) | (bank << 7)); + SetVROM_1K_Bank(4, ((bank == 6) ? 0xff & chr4 : 0x7f & chr4) | (bank << 7)); + SetVROM_1K_Bank(5, ((bank == 6) ? 0xff & chr5 : 0x7f & chr5) | (bank << 7)); + SetVROM_1K_Bank(6, ((bank == 6) ? 0xff & chr6 : 0x7f & chr6) | (bank << 7)); + SetVROM_1K_Bank(7, ((bank == 6) ? 0xff & chr7 : 0x7f & chr7) | (bank << 7)); + } + } + } + + //void Mapper044::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + p[19] = bank; + } + + //void Mapper044::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + bank = p[19]; + } + + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper044.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper044.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper044.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper044.cs.meta index a8a9ae7..310e8dd 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper044.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper044.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5454ce1b5791e5c4bbf39820d9fd4bac +guid: 4cc48452689c58d4b9272c29c9a812b6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs new file mode 100644 index 0000000..8e8a136 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs @@ -0,0 +1,387 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper045 1000000-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper045 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE patch; + BYTE prg0, prg1, prg2, prg3; + BYTE chr0, chr1, chr2, chr3, chr4, chr5, chr6, chr7; + BYTE[] p = new byte[4]; + INT[] c = new int[8]; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_latched; + BYTE irq_reset; + public Mapper045(NES parent) : base(parent) + { + } + + + public override void Reset() + { + patch = 0; + for (INT i = 0; i < 8; i++) + { + reg[i] = 0; + } + + prg0 = 0; + prg1 = 1; + prg2 = (byte)(PROM_8K_SIZE - 2); + prg3 = (byte)(PROM_8K_SIZE - 1); + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0x58bcacf6 // Kunio 8-in-1 (Pirate Cart) + || crc == 0x9103cfd6 // HIK 7-in-1 (Pirate Cart) + || crc == 0xc082e6d3) + { // Super 8-in-1 (Pirate Cart) + patch = 1; + prg2 = 62; + prg3 = 63; + } + if (crc == 0xe0dd259d) + { // Super 3-in-1 (Pirate Cart) + patch = 2; + } + SetPROM_32K_Bank(prg0, prg1, prg2, prg3); + p[0] = prg0; + p[1] = prg1; + p[2] = prg2; + p[3] = prg3; + + SetVROM_8K_Bank(0); + + // chr0 = c[0] = 0; + // chr1 = c[1] = 0 + // chr2 = c[2] = 0; + // chr3 = c[3] = 0; + // chr4 = c[4] = 0; + // chr5 = c[5] = 0; + // chr6 = c[6] = 0; + // chr7 = c[7] = 0; + + c[0] = chr0 = 0; + c[1] = chr1 = 1; + c[2] = chr2 = 2; + c[3] = chr3 = 3; + c[4] = chr4 = 4; + c[5] = chr5 = 5; + c[6] = chr6 = 6; + c[7] = chr7 = 7; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_latched = 0; + irq_reset = 0; + } + + //void Mapper045::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + // if( addr == 0x6000 ) { + // if( addr == 0x6000 && !(reg[3]&0x40) ) { + if ((reg[3] & 0x40) == 0) + { + reg[reg[5]] = data; + reg[5] = (byte)((reg[5] + 1) & 0x03); + + SetBank_CPU_4(prg0); + SetBank_CPU_5(prg1); + SetBank_CPU_6(prg2); + SetBank_CPU_7(prg3); + SetBank_PPU(); + } + } + + //void Mapper045::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + if ((data & 0x40) != (reg[6] & 0x40)) + { + BYTE swp; + swp = prg0; prg0 = prg2; prg2 = swp; + swp = p[0]; p[0] = p[2]; p[2] = swp; + SetBank_CPU_4(p[0]); + SetBank_CPU_5(p[1]); + } + if (VROM_1K_SIZE != 0) + { + if ((data & 0x80) != (reg[6] & 0x80)) + { + INT swp; + swp = chr4; chr4 = chr0; chr0 = (byte)swp; + swp = chr5; chr5 = chr1; chr1 = (byte)swp; + swp = chr6; chr6 = chr2; chr2 = (byte)swp; + swp = chr7; chr7 = chr3; chr3 = (byte)swp; + swp = c[4]; c[4] = c[0]; c[0] = swp; + swp = c[5]; c[5] = c[1]; c[1] = swp; + swp = c[6]; c[6] = c[2]; c[2] = swp; + swp = c[7]; c[7] = c[3]; c[3] = swp; + SetVROM_8K_Bank(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); + } + } + reg[6] = data; + break; + case 0x8001: + switch (reg[6] & 0x07) + { + case 0x00: + chr0 = (byte)((data & 0xFE) + 0); + chr1 = (byte)((data & 0xFE) + 1); + SetBank_PPU(); + break; + case 0x01: + chr2 = (byte)((data & 0xFE) + 0); + chr3 = (byte)((data & 0xFE) + 1); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + if ((reg[6] & 0x40) != 0) + { + prg2 = (byte)(data & 0x3F); + SetBank_CPU_6(data); + } + else + { + prg0 = (byte)(data & 0x3F); + SetBank_CPU_4(data); + } + break; + case 0x07: + prg1 = (byte)(data & 0x3F); + SetBank_CPU_5(data); + break; + } + break; + case 0xA000: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xC000: + if (patch == 2) + { + if (data == 0x29 || data == 0x70) + data = 0x07; + } + irq_latch = data; + irq_latched = 1; + if (irq_reset != 0) + { + irq_counter = data; + irq_latched = 0; + } + // irq_counter = data; + break; + case 0xC001: + // irq_latch = data; + irq_counter = irq_latch; + break; + case 0xE000: + irq_enable = 0; + irq_reset = 1; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + irq_enable = 1; + if (irq_latched != 0) + { + irq_counter = irq_latch; + } + break; + } + } + + //void Mapper045::HSync(INT scanline) + public override void HSync(int scanline) + { + irq_reset = 0; + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if (irq_counter != 0) + { + irq_counter--; + if (irq_counter == 0) + { + if (irq_enable != 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU_4(INT data) + { + data &= (reg[3] & 0x3F) ^ 0xFF; + data &= 0x3F; + data |= reg[1]; + SetPROM_8K_Bank(4, data); + p[0] = (byte)data; + } + + void SetBank_CPU_5(INT data) + { + data &= (reg[3] & 0x3F) ^ 0xFF; + data &= 0x3F; + data |= reg[1]; + SetPROM_8K_Bank(5, data); + p[1] = (byte)data; + } + + void SetBank_CPU_6(INT data) + { + data &= (reg[3] & 0x3F) ^ 0xFF; + data &= 0x3F; + data |= reg[1]; + SetPROM_8K_Bank(6, data); + p[2] = (byte)data; + } + + void SetBank_CPU_7(INT data) + { + data &= (reg[3] & 0x3F) ^ 0xFF; + data &= 0x3F; + data |= reg[1]; + SetPROM_8K_Bank(7, data); + p[3] = (byte)data; + } + + void SetBank_PPU() + { + BYTE[] table = new byte[] { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF + }; + + c[0] = chr0; + c[1] = chr1; + c[2] = chr2; + c[3] = chr3; + c[4] = chr4; + c[5] = chr5; + c[6] = chr6; + c[7] = chr7; + + for (INT i = 0; i < 8; i++) + { + c[i] &= table[reg[2] & 0x0F]; + c[i] |= reg[0] & ((patch != 1) ? 0xFF : 0xC0); + c[i] += (reg[2] & ((patch != 1) ? 0x10 : 0x30)) << 4; + } + + if ((reg[6] & 0x80) != 0) + { + SetVROM_8K_Bank(c[4], c[5], c[6], c[7], c[0], c[1], c[2], c[3]); + } + else + { + SetVROM_8K_Bank(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); + } + } + + //void Mapper045::SaveState(LPBYTE ps) + public override void SaveState(byte[] p) + { + //INT i; + //for (i = 0; i < 8; i++) + //{ + // ps[i] = reg[i]; + //} + //for (i = 0; i < 4; i++) + //{ + // ps[i + 8] = p[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // *(INT*)&ps[i * 4 + 64] = c[i]; + //} + //ps[20] = prg0; + //ps[21] = prg1; + //ps[22] = prg2; + //ps[23] = prg3; + //ps[24] = chr0; + //ps[25] = chr1; + //ps[26] = chr2; + //ps[27] = chr3; + //ps[28] = chr4; + //ps[29] = chr5; + //ps[30] = chr6; + //ps[31] = chr7; + //ps[32] = irq_enable; + //ps[33] = irq_counter; + //ps[34] = irq_latch; + } + + //void Mapper045::LoadState(LPBYTE ps) + public override void LoadState(byte[] p) + { + //INT i; + //for (i = 0; i < 8; i++) + //{ + // reg[i] = ps[i]; + //} + //for (i = 0; i < 4; i++) + //{ + // p[i] = ps[i + 8]; + //} + //for (i = 0; i < 8; i++) + //{ + // c[i] = *(INT*)&ps[i * 4 + 64]; + //} + //prg0 = ps[20]; + //prg1 = ps[21]; + //prg2 = ps[22]; + //prg3 = ps[23]; + //chr0 = ps[24]; + //chr1 = ps[25]; + //chr2 = ps[26]; + //chr3 = ps[27]; + //chr4 = ps[28]; + //chr5 = ps[29]; + //chr6 = ps[30]; + //chr7 = ps[31]; + //irq_enable = ps[32]; + //irq_counter = ps[33]; + //irq_latch = ps[34]; + } + + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper045.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper045.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs.meta index cf9dbfc..6a679e8 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper045.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 06873d727dc7ca6468474a46df099612 +guid: ddce49834ab1fac44bde0b09928875e0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper046.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper046.cs new file mode 100644 index 0000000..fdf5ee7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper046.cs @@ -0,0 +1,88 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper046 Rumble Station // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper046 : Mapper + { + int[] reg = new int[4]; + public Mapper046(NES parent) : base(parent) + { + } + + + public override void Reset() + { + reg[0] = 0; + reg[1] = 0; + reg[2] = 0; + reg[3] = 0; + + SetBank(); + SetVRAM_Mirror(VRAM_VMIRROR); + } + + //void Mapper046::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + reg[0] = data & 0x0F; + reg[1] = (data & 0xF0) >> 4; + SetBank(); + } + + //void Mapper046::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + reg[2] = data & 0x01; + reg[3] = (data & 0x70) >> 4; + SetBank(); + } + + void SetBank() + { + SetPROM_8K_Bank(4, reg[0] * 8 + reg[2] * 4 + 0); + SetPROM_8K_Bank(5, reg[0] * 8 + reg[2] * 4 + 1); + SetPROM_8K_Bank(6, reg[0] * 8 + reg[2] * 4 + 2); + SetPROM_8K_Bank(7, reg[0] * 8 + reg[2] * 4 + 3); + + SetVROM_1K_Bank(0, reg[1] * 64 + reg[3] * 8 + 0); + SetVROM_1K_Bank(1, reg[1] * 64 + reg[3] * 8 + 1); + SetVROM_1K_Bank(2, reg[1] * 64 + reg[3] * 8 + 2); + SetVROM_1K_Bank(3, reg[1] * 64 + reg[3] * 8 + 3); + SetVROM_1K_Bank(4, reg[1] * 64 + reg[3] * 8 + 4); + SetVROM_1K_Bank(5, reg[1] * 64 + reg[3] * 8 + 5); + SetVROM_1K_Bank(6, reg[1] * 64 + reg[3] * 8 + 6); + SetVROM_1K_Bank(7, reg[1] * 64 + reg[3] * 8 + 7); + } + + //void Mapper046::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = (byte)reg[0]; + p[1] = (byte)reg[1]; + p[2] = (byte)reg[2]; + p[3] = (byte)reg[3]; + } + + //void Mapper046::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; + reg[3] = p[3]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper046.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper046.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper046.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper046.cs.meta index 4780190..fa1f592 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper046.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper046.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ae6badd4ec9ec79468957a52726ef1ca +guid: 869faf0ac5d44c14eacb8e913bdcc1af MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper047.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper047.cs new file mode 100644 index 0000000..ac03477 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper047.cs @@ -0,0 +1,275 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper047 NES-QJ // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper047 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE patch; + BYTE bank; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + public Mapper047(NES parent) : base(parent) + { + } + + public override void Reset() + { + patch = 0; + + if (nes.rom.GetPROM_CRC() == 0x7eef434c) + { + patch = 1; + } + + for (INT i = 0; i < 8; i++) + { + reg[i] = 0; + } + + bank = 0; + prg0 = 0; + prg1 = 1; + + // set VROM banks + if (VROM_1K_SIZE != 0) + { + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + } + else + { + chr01 = chr23 = chr4 = chr5 = chr6 = chr7 = 0; + } + + SetBank_CPU(); + SetBank_PPU(); + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + } + + //void Mapper047::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x6000) + { + if (patch != 0) + { + bank = (byte)((data & 0x06) >> 1); + } + else + { + bank = (byte)((data & 0x01) << 1); + } + SetBank_CPU(); + SetBank_PPU(); + } + } + + //void Mapper047::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + break; + } + } + + //void Mapper047::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((--irq_counter) == 0) + { + irq_counter = irq_latch; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_8K_Bank(4, bank * 8 + ((patch != 0 && bank != 2) ? 6 : 14)); + SetPROM_8K_Bank(5, bank * 8 + prg1); + SetPROM_8K_Bank(6, bank * 8 + prg0); + SetPROM_8K_Bank(7, bank * 8 + ((patch != 0 && bank != 2) ? 7 : 15)); + } + else + { + SetPROM_8K_Bank(4, bank * 8 + prg0); + SetPROM_8K_Bank(5, bank * 8 + prg1); + SetPROM_8K_Bank(6, bank * 8 + ((patch != 0 && bank != 2) ? 6 : 14)); + SetPROM_8K_Bank(7, bank * 8 + ((patch != 0 && bank != 2) ? 7 : 15)); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_1K_Bank(0, (bank & 0x02) * 64 + chr4); + SetVROM_1K_Bank(1, (bank & 0x02) * 64 + chr5); + SetVROM_1K_Bank(2, (bank & 0x02) * 64 + chr6); + SetVROM_1K_Bank(3, (bank & 0x02) * 64 + chr7); + SetVROM_1K_Bank(4, (bank & 0x02) * 64 + chr01 + 0); + SetVROM_1K_Bank(5, (bank & 0x02) * 64 + chr01 + 1); + SetVROM_1K_Bank(6, (bank & 0x02) * 64 + chr23 + 0); + SetVROM_1K_Bank(7, (bank & 0x02) * 64 + chr23 + 1); + } + else + { + SetVROM_1K_Bank(0, (bank & 0x02) * 64 + chr01 + 0); + SetVROM_1K_Bank(1, (bank & 0x02) * 64 + chr01 + 1); + SetVROM_1K_Bank(2, (bank & 0x02) * 64 + chr23 + 0); + SetVROM_1K_Bank(3, (bank & 0x02) * 64 + chr23 + 1); + SetVROM_1K_Bank(4, (bank & 0x02) * 64 + chr4); + SetVROM_1K_Bank(5, (bank & 0x02) * 64 + chr5); + SetVROM_1K_Bank(6, (bank & 0x02) * 64 + chr6); + SetVROM_1K_Bank(7, (bank & 0x02) * 64 + chr7); + } + } + } + + //void Mapper047::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + p[19] = bank; + } + + //void Mapper047::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + bank = p[19]; + } + + + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper047.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper047.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper047.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper047.cs.meta index 218f3ce..2babab8 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper047.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper047.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2279e07deeabd9645a738f56d0b1a9d0 +guid: b35280f1894671747ba810b657054e8e MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper048.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper048.cs new file mode 100644 index 0000000..2ac028e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper048.cs @@ -0,0 +1,143 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper048 Taito TC190V // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper048 : Mapper + { + BYTE reg; + BYTE irq_enable; + BYTE irq_counter; + public Mapper048(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg = 0; + irq_enable = 0; + irq_counter = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + + uint crc = nes.rom.GetPROM_CRC(); + // if( crc == 0x547e6cc1 ) { // Flintstones - The Rescue of Dino & Hoppy(J) + // nes.SetRenderMethod( NES::POST_RENDER ); + // } + } + + //void Mapper048::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + if (reg == 0) + { + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + SetPROM_8K_Bank(4, data); + break; + case 0x8001: + SetPROM_8K_Bank(5, data); + break; + + case 0x8002: + SetVROM_2K_Bank(0, data); + break; + case 0x8003: + SetVROM_2K_Bank(2, data); + break; + case 0xA000: + SetVROM_1K_Bank(4, data); + break; + case 0xA001: + SetVROM_1K_Bank(5, data); + break; + case 0xA002: + SetVROM_1K_Bank(6, data); + break; + case 0xA003: + SetVROM_1K_Bank(7, data); + break; + + case 0xC000: + irq_counter = data; + irq_enable = 0; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + + case 0xC001: + irq_counter = data; + irq_enable = 1; + // irq_enable = data & 0x01; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + + case 0xC002: + break; + case 0xC003: + break; + + case 0xE000: + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + reg = 1; + break; + } + } + + //void Mapper048::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if (irq_counter == 0xFF) + { + // nes.cpu.IRQ_NotPending(); + // nes.cpu.SetIRQ( IRQ_MAPPER ); + nes.cpu.SetIRQ(IRQ_TRIGGER2); + } + irq_counter++; + } + } + } + } + + //void Mapper048::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + p[1] = irq_enable; + p[2] = irq_counter; + } + + //void Mapper048::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + irq_enable = p[1]; + irq_counter = p[2]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper048.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper048.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper048.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper048.cs.meta index caa1e26..61333f9 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper048.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper048.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 208670702cbdc4541894f8509f031ef3 +guid: e83144b10b1ec0546b0d4f40b8d5f305 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper050.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper050.cs new file mode 100644 index 0000000..1445939 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper050.cs @@ -0,0 +1,100 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper050 SMB2J // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper050 : Mapper + { + BYTE irq_enable; + public Mapper050(NES parent) : base(parent) + { + } + + public override void Reset() + { + irq_enable = 0; + SetPROM_8K_Bank(3, 15); + SetPROM_8K_Bank(4, 8); + SetPROM_8K_Bank(5, 9); + SetPROM_8K_Bank(6, 0); + SetPROM_8K_Bank(7, 11); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper050::ExWrite(WORD addr, BYTE data) + public override void ExWrite(ushort addr, byte data) + { + if ((addr & 0xE060) == 0x4020) + { + if ((addr & 0x0100) != 0) + { + irq_enable = (byte)(data & 0x01); + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + else + { + SetPROM_8K_Bank(6, (data & 0x08) | ((data & 0x01) << 2) | ((data & 0x06) >> 1)); + } + } + } + + //void Mapper050::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xE060) == 0x4020) + { + if ((addr & 0x0100) != 0) + { + irq_enable = (byte)(data & 0x01); + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + else + { + SetPROM_8K_Bank(6, (data & 0x08) | ((data & 0x01) << 2) | ((data & 0x06) >> 1)); + } + } + } + + //void Mapper050::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if (scanline == 21) + { + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper050::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_enable; + } + + //void Mapper050::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_enable = p[0]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper050.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper050.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper050.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper050.cs.meta index 9b6523c..36e89af 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper050.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper050.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bb91df250655ebb4f873fc1084576301 +guid: 189113b0ca31017448ec750a72e57ddc MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper051.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper051.cs new file mode 100644 index 0000000..5bda884 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper051.cs @@ -0,0 +1,109 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper051 11-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper051 : Mapper + { + int mode, bank; + public Mapper051(NES parent) : base(parent) + { + } + + public override void Reset() + { + bank = 0; + mode = 1; + + SetBank_CPU(); + SetCRAM_8K_Bank(0); + } + + //void Mapper051::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000) + { + mode = ((data & 0x10) >> 3) | ((data & 0x02) >> 1); + SetBank_CPU(); + } + } + + //void Mapper051::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + bank = (data & 0x0f) << 2; + if (0xC000 <= addr && addr <= 0xDFFF) + { + mode = (mode & 0x01) | ((data & 0x10) >> 3); + } + SetBank_CPU(); + } + + void SetBank_CPU() + { + switch (mode) + { + case 0: + SetVRAM_Mirror(VRAM_VMIRROR); + SetPROM_8K_Bank(3, (bank | 0x2c | 3)); + SetPROM_8K_Bank(4, (bank | 0x00 | 0)); + SetPROM_8K_Bank(5, (bank | 0x00 | 1)); + SetPROM_8K_Bank(6, (bank | 0x0c | 2)); + SetPROM_8K_Bank(7, (bank | 0x0c | 3)); + break; + case 1: + SetVRAM_Mirror(VRAM_VMIRROR); + SetPROM_8K_Bank(3, (bank | 0x20 | 3)); + SetPROM_8K_Bank(4, (bank | 0x00 | 0)); + SetPROM_8K_Bank(5, (bank | 0x00 | 1)); + SetPROM_8K_Bank(6, (bank | 0x00 | 2)); + SetPROM_8K_Bank(7, (bank | 0x00 | 3)); + break; + case 2: + SetVRAM_Mirror(VRAM_VMIRROR); + SetPROM_8K_Bank(3, (bank | 0x2e | 3)); + SetPROM_8K_Bank(4, (bank | 0x02 | 0)); + SetPROM_8K_Bank(5, (bank | 0x02 | 1)); + SetPROM_8K_Bank(6, (bank | 0x0e | 2)); + SetPROM_8K_Bank(7, (bank | 0x0e | 3)); + break; + case 3: + SetVRAM_Mirror(VRAM_HMIRROR); + SetPROM_8K_Bank(3, (bank | 0x20 | 3)); + SetPROM_8K_Bank(4, (bank | 0x00 | 0)); + SetPROM_8K_Bank(5, (bank | 0x00 | 1)); + SetPROM_8K_Bank(6, (bank | 0x00 | 2)); + SetPROM_8K_Bank(7, (bank | 0x00 | 3)); + break; + } + } + + //void Mapper051::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = (byte)mode; + p[1] = (byte)bank; + } + + //void Mapper051::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + mode = p[0]; + bank = p[1]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper051.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper051.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper051.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper051.cs.meta index 2e474c0..1b8836c 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper051.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper051.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e399d70fe48a5db4ba1c813a6e7b46fa +guid: 571fbd114543cf2498b886722d4db2c9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper057.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper057.cs new file mode 100644 index 0000000..a142d08 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper057.cs @@ -0,0 +1,87 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper057 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper057 : Mapper + { + + BYTE reg; + public Mapper057(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 0, 1); + SetVROM_8K_Bank(0); + reg = 0; + } + + //void Mapper057::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + case 0x8001: + case 0x8002: + case 0x8003: + if ((data & 0x40) != 0) + { + SetVROM_8K_Bank((data & 0x03) + ((reg & 0x10) >> 1) + (reg & 0x07)); + } + break; + case 0x8800: + reg = data; + + if ((data & 0x80) != 0) + { + SetPROM_8K_Bank(4, ((data & 0x40) >> 6) * 4 + 8 + 0); + SetPROM_8K_Bank(5, ((data & 0x40) >> 6) * 4 + 8 + 1); + SetPROM_8K_Bank(6, ((data & 0x40) >> 6) * 4 + 8 + 2); + SetPROM_8K_Bank(7, ((data & 0x40) >> 6) * 4 + 8 + 3); + } + else + { + SetPROM_8K_Bank(4, ((data & 0x60) >> 5) * 2 + 0); + SetPROM_8K_Bank(5, ((data & 0x60) >> 5) * 2 + 1); + SetPROM_8K_Bank(6, ((data & 0x60) >> 5) * 2 + 0); + SetPROM_8K_Bank(7, ((data & 0x60) >> 5) * 2 + 1); + } + + SetVROM_8K_Bank((data & 0x07) + ((data & 0x10) >> 1)); + + if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + + break; + } + } + + //void Mapper057::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper057::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper057.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper057.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper057.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper057.cs.meta index 6d6fe5e..070fcb2 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper057.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper057.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bf918deb9af239143bd0e1fbcad64911 +guid: 4e308cd2cba2bd046b2174191bd85e40 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper058.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper058.cs new file mode 100644 index 0000000..bb7275c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper058.cs @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper058 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper058 : Mapper + { + public Mapper058(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 0, 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper058::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0x40) != 0) + { + SetPROM_16K_Bank(4, addr & 0x07); + SetPROM_16K_Bank(6, addr & 0x07); + } + else + { + SetPROM_32K_Bank((addr & 0x06) >> 1); + } + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank((addr & 0x38) >> 3); + } + + if ((data & 0x02) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + } + + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper058.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper058.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper058.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper058.cs.meta index 3fff511..eb626ae 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper058.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper058.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d5f3c51f1ab08764aa3af28f3048bfa5 +guid: 1aa707df3277a794ca6410f942a25620 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper060.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper060.cs new file mode 100644 index 0000000..2781466 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper060.cs @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper060 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper060 : Mapper + { + BYTE patch; + BYTE game_sel; + public Mapper060(NES parent) : base(parent) + { + } + + public override void Reset() + { + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0xf9c484a0) + { // Reset Based 4-in-1(Unl) + SetPROM_16K_Bank(4, game_sel); + SetPROM_16K_Bank(6, game_sel); + SetVROM_8K_Bank(game_sel); + game_sel++; + game_sel &= 3; + } + else + { + patch = 1; + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + } + + //void Mapper060::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (patch != 0) + { + if ((addr & 0x80) != 0) + { + SetPROM_16K_Bank(4, (addr & 0x70) >> 4); + SetPROM_16K_Bank(6, (addr & 0x70) >> 4); + } + else + { + SetPROM_32K_Bank((addr & 0x70) >> 5); + } + + SetVROM_8K_Bank(addr & 0x07); + + if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper060.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper060.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper060.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper060.cs.meta index 14648f0..cbcd5d3 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper060.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper060.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6f5e014a4df93af4db13624605f4e7f5 +guid: ec235304463428e49bf1df24c3e82799 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper061.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper061.cs new file mode 100644 index 0000000..e960050 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper061.cs @@ -0,0 +1,47 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper061 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper061 : Mapper + { + public Mapper061(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper061::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0x30) + { + case 0x00: + case 0x30: + SetPROM_32K_Bank(addr & 0x0F); + break; + case 0x10: + case 0x20: + SetPROM_16K_Bank(4, ((addr & 0x0F) << 1) | ((addr & 0x20) >> 4)); + SetPROM_16K_Bank(6, ((addr & 0x0F) << 1) | ((addr & 0x20) >> 4)); + break; + } + + if ((addr & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper061.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper061.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper061.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper061.cs.meta index 990dcd5..2ab1bde 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper061.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper061.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d371dd307b7ac2044893482d5eb2c28e +guid: 99e17dde8c75db54f9ece9eeb0767f7a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper062.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper062.cs new file mode 100644 index 0000000..500e9e1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper062.cs @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper062 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper062 : Mapper + { + public Mapper062(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper062::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xFF00) + { + case 0x8100: + SetPROM_8K_Bank(4, data); + SetPROM_8K_Bank(5, data + 1); + break; + case 0x8500: + SetPROM_8K_Bank(4, data); + break; + case 0x8700: + SetPROM_8K_Bank(5, data); + break; + SetVROM_1K_Bank(0, data + 0); + SetVROM_1K_Bank(1, data + 1); + SetVROM_1K_Bank(2, data + 2); + SetVROM_1K_Bank(3, data + 3); + SetVROM_1K_Bank(4, data + 4); + SetVROM_1K_Bank(5, data + 5); + SetVROM_1K_Bank(6, data + 6); + SetVROM_1K_Bank(7, data + 7); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper062.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper062.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper062.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper062.cs.meta index b32919e..ef227aa 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper062.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper062.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ea3055fddea86eb47b1bbbc8c0c9c873 +guid: 939ee4b96ee5c424bba241dc62b5f6d4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs new file mode 100644 index 0000000..d9849aa --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs @@ -0,0 +1,283 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper064 Tengen Rambo-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper064 : Mapper + { + BYTE[] reg = new byte[3]; + BYTE irq_enable; + BYTE irq_mode; + INT irq_counter; + INT irq_counter2; + BYTE irq_latch; + BYTE irq_reset; + public Mapper064(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_8K_SIZE - 1, PROM_8K_SIZE - 1, PROM_8K_SIZE - 1, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + reg[0] = reg[1] = reg[2] = 0; + + irq_enable = 0; + irq_mode = 0; + irq_counter = 0; + irq_counter2 = 0; + irq_latch = 0; + irq_reset = 0; + } + + //void Mapper064::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "$%04X:$%02X\n", addr, data ); + switch (addr & 0xF003) + { + case 0x8000: + reg[0] = (byte)(data & 0x0F); + reg[1] = (byte)(data & 0x40); + reg[2] = (byte)(data & 0x80); + break; + + case 0x8001: + switch (reg[0]) + { + case 0x00: + if (reg[2] != 0) + { + SetVROM_1K_Bank(4, data + 0); + SetVROM_1K_Bank(5, data + 1); + } + else + { + SetVROM_1K_Bank(0, data + 0); + SetVROM_1K_Bank(1, data + 1); + } + break; + case 0x01: + if (reg[2] != 0) + { + SetVROM_1K_Bank(6, data + 0); + SetVROM_1K_Bank(7, data + 1); + } + else + { + SetVROM_1K_Bank(2, data + 0); + SetVROM_1K_Bank(3, data + 1); + } + break; + case 0x02: + if (reg[2] != 0) + { + SetVROM_1K_Bank(0, data); + } + else + { + SetVROM_1K_Bank(4, data); + } + break; + case 0x03: + if (reg[2] != 0) + { + SetVROM_1K_Bank(1, data); + } + else + { + SetVROM_1K_Bank(5, data); + } + break; + case 0x04: + if (reg[2] != 0) + { + SetVROM_1K_Bank(2, data); + } + else + { + SetVROM_1K_Bank(6, data); + } + break; + case 0x05: + if (reg[2] != 0) + { + SetVROM_1K_Bank(3, data); + } + else + { + SetVROM_1K_Bank(7, data); + } + break; + case 0x06: + if (reg[1] != 0) + { + SetPROM_8K_Bank(5, data); + } + else + { + SetPROM_8K_Bank(4, data); + } + break; + case 0x07: + if (reg[1] != 0) + { + SetPROM_8K_Bank(6, data); + } + else + { + SetPROM_8K_Bank(5, data); + } + break; + case 0x08: + SetVROM_1K_Bank(1, data); + break; + case 0x09: + SetVROM_1K_Bank(3, data); + break; + case 0x0F: + if (reg[1] != 0) + { + SetPROM_8K_Bank(4, data); + } + else + { + SetPROM_8K_Bank(6, data); + } + break; + } + break; + + case 0xA000: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + + case 0xC000: + irq_latch = data; + if (irq_reset != 0) + { + irq_counter = irq_latch; + } + break; + case 0xC001: + irq_reset = 0xFF; + irq_counter = irq_latch; + irq_mode = (byte)(data & 0x01); + break; + case 0xE000: + irq_enable = 0; + if (irq_reset != 0) + { + irq_counter = irq_latch; + } + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + irq_enable = 0xFF; + if (irq_reset != 0) + { + irq_counter = irq_latch; + } + break; + } + } + + //void Mapper064::Clock(INT cycles) + public override void Clock(int cycles) + { + if (irq_mode == 0) + return; + + irq_counter2 += cycles; + while (irq_counter2 >= 4) + { + irq_counter2 -= 4; + if (irq_counter >= 0) + { + irq_counter--; + if (irq_counter < 0) + { + if (irq_enable != 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + //void Mapper064::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_mode != 0) + return; + + irq_reset = 0; + + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_counter >= 0) + { + irq_counter--; + if (irq_counter < 0) + { + if (irq_enable != 0) + { + irq_reset = 1; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + } + + //void Mapper064::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg[0]; + //p[1] = reg[1]; + //p[2] = reg[2]; + //p[3] = irq_enable; + //p[4] = irq_mode; + //p[5] = irq_latch; + //p[6] = irq_reset; + //*((INT*)&p[8]) = irq_counter; + //*((INT*)&p[12]) = irq_counter2; + } + + //void Mapper064::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //reg[0] = p[0]; + //reg[1] = p[1]; + //reg[2] = p[2]; + //irq_enable = p[3]; + //irq_mode = p[4]; + //irq_latch = p[5]; + //irq_reset = p[6]; + //irq_counter = *((INT*)&p[8]); + //irq_counter2 = *((INT*)&p[12]); + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper064.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper064.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs.meta index a5b7a76..523c548 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper064.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a696f836221fe3646b3200f3e6bcb87c +guid: e265ca28ccd66d948996bae491315162 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs new file mode 100644 index 0000000..b7d0b32 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs @@ -0,0 +1,189 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper065 Irem H3001 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper065 : Mapper + { + BYTE patch; + + BYTE irq_enable; + INT irq_counter; + INT irq_latch; + public Mapper065(NES parent) : base(parent) + { + } + + public override void Reset() + { + patch = 0; + + // Kaiketsu Yanchamaru 3(J) + if (nes.rom.GetPROM_CRC() == 0xe30b7f64) + { + patch = 1; + } + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + irq_enable = 0; + irq_counter = 0; + } + + //void Mapper065::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + + case 0x9000: + if (patch == 0) + { + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + } + break; + + case 0x9001: + if (patch != 0) + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + + case 0x9003: + if (patch == 0) + { + irq_enable = (byte)(data & 0x8); + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + break; + case 0x9004: + if (patch == 0) + { + irq_counter = irq_latch; + } + break; + case 0x9005: + if (patch != 0) + { + irq_counter = (BYTE)(data << 1); + irq_enable = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + else + { + irq_latch = (irq_latch & 0x00FF) | ((INT)data << 8); + } + break; + + case 0x9006: + if (patch != 0) + { + irq_enable = 1; + } + else + { + irq_latch = (irq_latch & 0xFF00) | data; + } + break; + + case 0xB000: + case 0xB001: + case 0xB002: + case 0xB003: + case 0xB004: + case 0xB005: + case 0xB006: + case 0xB007: + SetVROM_1K_Bank((byte)(addr & 0x0007), data); + break; + + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + case 0xC000: + SetPROM_8K_Bank(6, data); + break; + } + } + + //void Mapper065::HSync(INT scanline) + public override void HSync(int scanline) + { + if (patch != 0) + { + if (irq_enable != 0) + { + if (irq_counter == 0) + { + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter--; + } + } + } + } + + //void Mapper065::Clock(INT cycles) + public override void Clock(int cycles) + { + if (patch == 0) + { + if (irq_enable != 0) + { + if (irq_counter <= 0) + { + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter -= cycles; + } + } + } + } + + //void Mapper065::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //*(INT*)&p[1] = irq_counter; + //*(INT*)&p[5] = irq_latch; + } + + //void Mapper065::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = *(INT*)&p[1]; + //irq_latch = *(INT*)&p[5]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper065.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper065.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs.meta index 767b280..b40f5f3 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper065.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 314d0c6b3f522d84fb090126194b88f9 +guid: 953f2e26ba82ff64b9aac6ad4476afb5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper066.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper066.cs new file mode 100644 index 0000000..1458c26 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper066.cs @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper066 Bandai 74161 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper066 : Mapper + { + public Mapper066(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + + // if( nes->rom->GetPROM_CRC() == 0xe30552db ) { // Paris-Dakar Rally Special + // nes->SetFrameIRQmode( FALSE ); + // } + } + + //void Mapper066::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000) + { + SetPROM_32K_Bank((data & 0xF0) >> 4); + SetVROM_8K_Bank(data & 0x0F); + } + } + + //void Mapper066::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_32K_Bank((data & 0xF0) >> 4); + SetVROM_8K_Bank(data & 0x0F); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper066.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper066.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper066.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper066.cs.meta index 8698e8d..ff72f90 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper066.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper066.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1fc42abf998812f40b3ab620cb1cae65 +guid: de0206b3dc89c224b89aa969c373434c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs new file mode 100644 index 0000000..3d6b2fb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs @@ -0,0 +1,140 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper067 SunSoft Mapper 3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper067 : Mapper + { + BYTE irq_enable; + BYTE irq_occur; + BYTE irq_toggle; + INT irq_counter; + public Mapper067(NES parent) : base(parent) + { + } + + public override void Reset() + + { + irq_enable = 0; + irq_toggle = 0; + irq_counter = 0; + irq_occur = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + SetVROM_4K_Bank(0, 0); + SetVROM_4K_Bank(4, VROM_4K_SIZE - 1); + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0x7f2a04bf) + { // For Fantasy Zone 2(J) + nes.SetRenderMethod(EnumRenderMethod.PRE_ALL_RENDER); + } + } + + //void Mapper067::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF800) + { + case 0x8800: + SetVROM_2K_Bank(0, data); + break; + case 0x9800: + SetVROM_2K_Bank(2, data); + break; + case 0xA800: + SetVROM_2K_Bank(4, data); + break; + case 0xB800: + SetVROM_2K_Bank(6, data); + break; + + case 0xC800: + if (irq_toggle == 0) + { + irq_counter = (irq_counter & 0x00FF) | ((INT)data << 8); + } + else + { + irq_counter = (irq_counter & 0xFF00) | ((INT)data & 0xFF); + } + irq_toggle ^= 1; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xD800: + irq_enable = (byte)(data & 0x10); + irq_toggle = 0; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xE800: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0xF800: + SetPROM_16K_Bank(4, data); + break; + } + } + + //void Mapper067::Clock(INT cycles) + public override void Clock(int cycles) + { + if (irq_enable != 0) + { + if ((irq_counter -= cycles) <= 0) + { + irq_enable = 0; + irq_occur = 0xFF; + irq_counter = 0xFFFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + + // if( irq_occur ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + //void Mapper067::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //p[1] = irq_occur; + //p[2] = irq_toggle; + //*((INT*)&p[3]) = irq_counter; + } + + //void Mapper067::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_occur = p[1]; + //irq_toggle = p[2]; + //irq_counter = *((INT*)&p[3]); + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper067.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper067.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs.meta index 68a00d4..8757815 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper067.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6ce6078bf7001f448b966f6e9d3a9ff8 +guid: 5a6da4cd8de113e4c915b45d95b21e48 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper068.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper068.cs new file mode 100644 index 0000000..7e035c8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper068.cs @@ -0,0 +1,164 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper068 SunSoft Mapper 4 (After Burner II) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper068 : Mapper + { + BYTE[] reg = new byte[4]; + BYTE coin; + public Mapper068(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg[0] = reg[1] = reg[2] = reg[3] = 0; + coin = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + +#if FALSE //0 +BYTE Mapper068::ExRead( WORD addr ) +{ + if( addr == 0x4020 ) { +DEBUGOUT( "RD $4020:%02X\n", coin ); + return coin; + } + + return addr>>8; +} + +void Mapper068::ExWrite( WORD addr, BYTE data ) +{ + if( addr == 0x4020 ) { +DEBUGOUT( "WR $4020:%02X\n", data ); + coin = data; + } +} +#endif + + //void Mapper068::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x8000: + SetVROM_2K_Bank(0, data); + break; + case 0x9000: + SetVROM_2K_Bank(2, data); + break; + case 0xA000: + SetVROM_2K_Bank(4, data); + break; + case 0xB000: + SetVROM_2K_Bank(6, data); + break; + + case 0xC000: + reg[2] = data; + SetBank(); + break; + case 0xD000: + reg[3] = data; + SetBank(); + break; + case 0xE000: + reg[0] = (byte)((data & 0x10) >> 4); + reg[1] = (byte)(data & 0x03); + SetBank(); + break; + + case 0xF000: + SetPROM_16K_Bank(4, data); + break; + } + } + + void SetBank() + { + if (reg[0] != 0) + { + switch (reg[1]) + { + case 0: + SetVROM_1K_Bank(8, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(9, (INT)reg[3] + 0x80); + SetVROM_1K_Bank(10, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(11, (INT)reg[3] + 0x80); + break; + case 1: + SetVROM_1K_Bank(8, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(9, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(10, (INT)reg[3] + 0x80); + SetVROM_1K_Bank(11, (INT)reg[3] + 0x80); + break; + case 2: + SetVROM_1K_Bank(8, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(9, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(10, (INT)reg[2] + 0x80); + SetVROM_1K_Bank(11, (INT)reg[2] + 0x80); + break; + case 3: + SetVROM_1K_Bank(8, (INT)reg[3] + 0x80); + SetVROM_1K_Bank(9, (INT)reg[3] + 0x80); + SetVROM_1K_Bank(10, (INT)reg[3] + 0x80); + SetVROM_1K_Bank(11, (INT)reg[3] + 0x80); + break; + } + } + else + { + switch (reg[1]) + { + case 0: + SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 1: + SetVRAM_Mirror(VRAM_HMIRROR); + break; + case 2: + SetVRAM_Mirror(VRAM_MIRROR4L); + break; + case 3: + SetVRAM_Mirror(VRAM_MIRROR4H); + break; + } + } + } + + //void Mapper068::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = reg[2]; + p[3] = reg[3]; + } + + //void Mapper068::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; + reg[3] = p[3]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper068.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper068.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper068.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper068.cs.meta index d0ac7f7..7033718 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper068.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper068.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 22f5878561b23c24badfb5a921bd895e +guid: d94fb8248e814774caf84e3c8e2c508d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs new file mode 100644 index 0000000..f386f82 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs @@ -0,0 +1,177 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper069 SunSoft FME-7 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper069 : Mapper + { + BYTE patch; + + BYTE reg; + BYTE irq_enable; + INT irq_counter; + public Mapper069(NES parent) : base(parent) + { + } + + public override void Reset() + + { + reg = 0; + irq_enable = 0; + irq_counter = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + nes.apu.SelectExSound(32); + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xfeac6916) + { // Honoo no Toukyuuji - Dodge Danpei 2(J) + // nes.SetIrqType( NES::IRQ_HSYNC ); + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + + if (crc == 0xad28aef6) + { // Dynamite Batman(J) / Dynamite Batman - Return of the Joker(U) + patch = 1; + } + } + + //void Mapper069::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE000) + { + case 0x8000: + reg = data; + break; + + case 0xA000: + switch (reg & 0x0F) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + SetVROM_1K_Bank((byte)(reg & 0x07), data); + break; + case 0x08: + if (patch == 0 && (data & 0x40) == 0) + { + SetPROM_8K_Bank(3, data); + } + break; + case 0x09: + SetPROM_8K_Bank(4, data); + break; + case 0x0A: + SetPROM_8K_Bank(5, data); + break; + case 0x0B: + SetPROM_8K_Bank(6, data); + break; + + case 0x0C: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x0D: + irq_enable = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0x0E: + irq_counter = (irq_counter & 0xFF00) | data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0x0F: + irq_counter = (irq_counter & 0x00FF) | (data << 8); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + break; + + case 0xC000: + case 0xE000: + nes.apu.ExWrite(addr, data); + break; + } + } + + //void Mapper069::Clock(INT cycles) + public override void Clock(int cycles) + { + //if (irq_enable && (nes.GetIrqType() == NES::IRQ_CLOCK)) + if (irq_enable != 0 && (nes.GetIrqType() == (int)NES.IRQMETHOD.IRQ_HSYNC)) + { + irq_counter -= cycles; + if (irq_counter <= 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + irq_enable = 0; + irq_counter = 0xFFFF; + } + } + } + + //void Mapper069::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0 && (nes.GetIrqType() == (int)NES.IRQMETHOD.IRQ_HSYNC)) + { + irq_counter -= 114; + if (irq_counter <= 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + irq_enable = 0; + irq_counter = 0xFFFF; + } + } + } + + //void Mapper069::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg; + //p[1] = irq_enable; + //*(INT*)&p[2] = irq_counter; + } + + //void Mapper069::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //reg = p[0]; + //irq_enable = p[1]; + //irq_counter = *(INT*)&p[2]; + } + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper069.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper069.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs.meta index 5ea6723..2b2cb79 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper069.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3aa95ff6ff61dbe4da50f18baa928fe4 +guid: 280c64d4deb538a448bba3eb071b3aef MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs new file mode 100644 index 0000000..04153e2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs @@ -0,0 +1,64 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper070 Bandai 74161 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper070 : Mapper + { + BYTE patch; + public Mapper070(NES parent) : base(parent) + { + } + + public override void Reset() + { + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xa59ca2ef) + { // Kamen Rider Club(J) + patch = 1; + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + if (crc == 0x10bb8f9a) + { // Family Trainer - Manhattan Police(J) + patch = 1; + } + if (crc == 0x0cd00488) + { // Space Shadow(J) + patch = 1; + } + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + } + + //void Mapper070::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_16K_Bank(4, (data & 0x70) >> 4); + SetVROM_8K_Bank(data & 0x0F); + + if (patch != 0) + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper070.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper070.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs.meta index a734c67..393d52c 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper070.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0e3aaa8620d44434b941fe8fc0580ca1 +guid: 0202c8b68faec5a4ea96ec3fc07aebae MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs new file mode 100644 index 0000000..5d07deb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper071 Camerica // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper071 : Mapper + { + public Mapper071(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper071::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xE000) == 0x6000) + { + SetPROM_16K_Bank(4, data); + } + } + + //void Mapper071::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x9000: + if ((data & 0x10) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + break; + + case 0xC000: + case 0xD000: + case 0xE000: + case 0xF000: + SetPROM_16K_Bank(4, data); + break; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper071.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper071.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs.meta index 09beb83..e173f6f 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper071.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5c123475e1ad66a4f839b1768a5a0d07 +guid: 379a8d27ad5b5854ba2bc0db093734f2 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs new file mode 100644 index 0000000..f3dbc62 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper072 Jaleco/Type1 lower bank switch // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class Mapper072 : Mapper + { + public Mapper072(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper072::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((data & 0x80) != 0) + { + SetPROM_16K_Bank(4, data & 0x0F); + } + else if ((data & 0x40) != 0) + { + SetVROM_8K_Bank(data & 0x0F); + } + else + { + if (addr >= 0xC100 && addr <= 0xC11F && data == 0x20) + { + Debuger.Log($"SOUND CODE:{addr & 0x1F:X2}"); + + // OSDã«ã™ã‚‹ã¹ãã‹â€¦ + if (Supporter.Config.sound.bExtraSoundEnable) + { + //TODO : 似乎VirtuaNES有直接播放æŸä¸ªéŸ³é¢‘文件的功能 + //DirectSound.EsfAllStop(); + //DirectSound.EsfPlay(ESF_MOETENNIS_00 + (addr & 0x1F)); + } + } + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper072.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper072.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs.meta index ab97a4e..27c73ba 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper072.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2523f31241f5556429834dbf0281aa69 +guid: 556683ab44781ae41b79420d171afb0d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs new file mode 100644 index 0000000..ce69fe0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs @@ -0,0 +1,94 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper073 Konami VRC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper073 : Mapper + { + BYTE irq_enable; + INT irq_counter; + public Mapper073(NES parent) : base(parent) + { + } + + public override void Reset() + { + irq_enable = 0; + irq_counter = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper073::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0xF000: + SetPROM_16K_Bank(4, data); + break; + + case 0x8000: + irq_counter = (irq_counter & 0xFFF0) | (data & 0x0F); + break; + case 0x9000: + irq_counter = (irq_counter & 0xFF0F) | ((data & 0x0F) << 4); + break; + case 0xA000: + irq_counter = (irq_counter & 0xF0FF) | ((data & 0x0F) << 8); + break; + case 0xB000: + irq_counter = (irq_counter & 0x0FFF) | ((data & 0x0F) << 12); + break; + case 0xC000: + irq_enable = (byte)(data & 0x02); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xD000: + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper073::Clock(INT cycles) + public override void Clock(int cycles) + { + if (irq_enable != 0) + { + if ((irq_counter += cycles) >= 0xFFFF) + { + irq_enable = 0; + irq_counter &= 0xFFFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper073::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //*(INT*)&p[1] = irq_counter; + } + + //void Mapper073::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = *(INT*)&p[1]; + } + + public override bool IsStateSave() + { + return true; + } + } +} + diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper073.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper073.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs.meta index 6a0a43c..f90c467 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper073.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 07ac7400d8c8fc74991b21d6733ba3f4 +guid: 47872c8286a0123479efa9809f188d62 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs new file mode 100644 index 0000000..26602d9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs @@ -0,0 +1,312 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper074 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper074 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + + BYTE patch; + public Mapper074(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + uint crc = nes.rom.GetPROM_CRC(); + + patch = 0; + if (crc == 0x37ae04a8) + { + patch = 1; + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + } + + //void Mapper074::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + break; + } + + } + + //void Mapper074::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + // SetVROM_8K_Bank( chr4, chr5, chr6, chr7, + // chr01, chr01+1, chr23, chr23+1 ); + SetBank_PPUSUB(4, chr01 + 0); + SetBank_PPUSUB(5, chr01 + 1); + SetBank_PPUSUB(6, chr23 + 0); + SetBank_PPUSUB(7, chr23 + 1); + SetBank_PPUSUB(0, chr4); + SetBank_PPUSUB(1, chr5); + SetBank_PPUSUB(2, chr6); + SetBank_PPUSUB(3, chr7); + } + else + { + // SetVROM_8K_Bank( chr01, chr01+1, chr23, chr23+1, + // chr4, chr5, chr6, chr7 ); + SetBank_PPUSUB(0, chr01 + 0); + SetBank_PPUSUB(1, chr01 + 1); + SetBank_PPUSUB(2, chr23 + 0); + SetBank_PPUSUB(3, chr23 + 1); + SetBank_PPUSUB(4, chr4); + SetBank_PPUSUB(5, chr5); + SetBank_PPUSUB(6, chr6); + SetBank_PPUSUB(7, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(0, chr4 & 0x07); + SetCRAM_1K_Bank(1, chr5 & 0x07); + SetCRAM_1K_Bank(2, chr6 & 0x07); + SetCRAM_1K_Bank(3, chr7 & 0x07); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(4, chr4 & 0x07); + SetCRAM_1K_Bank(5, chr5 & 0x07); + SetCRAM_1K_Bank(6, chr6 & 0x07); + SetCRAM_1K_Bank(7, chr7 & 0x07); + } + } + } + + void SetBank_PPUSUB(int bank, int page) + { + if (patch == 0 && (page == 8 || page == 9)) + { + SetCRAM_1K_Bank((byte)bank, page & 7); + } + else if (patch == 1 && page >= 128) + { + SetCRAM_1K_Bank((byte)bank, page & 7); + } + else + { + SetVROM_1K_Bank((byte)bank, page); + } + } + + //void Mapper074::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + p[19] = irq_request; + } + + //void Mapper074::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + irq_request = p[19]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper074.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper074.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs.meta index 1ee12b9..751c217 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper074.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: de1bb7ed83cdb22499c854992fae8e27 +guid: 45d37052d02fe374d8ba3c4e2a631cfd MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs new file mode 100644 index 0000000..b5f57ce --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs @@ -0,0 +1,90 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper075 Konami VRC1/Jaleco D65005 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper075 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper075(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + reg[0] = 0; + reg[1] = 1; + } + + //void Mapper075::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + + case 0x9000: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x02) << 3)); + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x04) << 2)); + SetVROM_4K_Bank(0, reg[0]); + SetVROM_4K_Bank(4, reg[1]); + break; + + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + case 0xC000: + SetPROM_8K_Bank(6, data); + break; + + case 0xE000: + reg[0] = (byte)((reg[0] & 0x10) | (data & 0x0F)); + SetVROM_4K_Bank(0, reg[0]); + break; + + case 0xF000: + reg[1] = (byte)((reg[1] & 0x10) | (data & 0x0F)); + SetVROM_4K_Bank(4, reg[1]); + break; + } + } + + //void Mapper075::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper075::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper075.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper075.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs.meta index 128672e..1107729 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper075.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 96976ae7823c77e4d99355570ab4ff15 +guid: a9e28ba92f769664690091c1434038a6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs new file mode 100644 index 0000000..d654835 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs @@ -0,0 +1,82 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper076 Namcot 109 (女神転生) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper076 : Mapper + { + BYTE reg; + public Mapper076(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE >= 8) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper076::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + reg = data; + break; + case 0x8001: + switch (reg & 0x07) + { + case 2: + SetVROM_2K_Bank(0, data); + break; + case 3: + SetVROM_2K_Bank(2, data); + break; + case 4: + SetVROM_2K_Bank(4, data); + break; + case 5: + SetVROM_2K_Bank(6, data); + break; + case 6: + SetPROM_8K_Bank(4, data); + break; + case 7: + SetPROM_8K_Bank(5, data); + break; + } + break; + } + } + + //void Mapper076::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper076::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs.meta index 7484165..5cc1aab 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: eaed30d1f6adc7f4dbb3092f65b7b614 +guid: 672c100cc4c4c70448bb51f3a9b62d5b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs new file mode 100644 index 0000000..017025f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper077 Irem Early Mapper #0 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper077 : Mapper + { + public Mapper077(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + SetVROM_2K_Bank(0, 0); + SetCRAM_2K_Bank(2, 1); + SetCRAM_2K_Bank(4, 2); + SetCRAM_2K_Bank(6, 3); + } + + //void Mapper077::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_32K_Bank(data & 0x07); + + SetVROM_2K_Bank(0, (data & 0xF0) >> 4); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper077.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper077.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs.meta index 7cecfd2..5b15e65 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper077.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e75ccafc4c3062a48bf1344deff1c242 +guid: 7ad6987edcff779409890da9965d4891 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs new file mode 100644 index 0000000..2fbd0ba --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs @@ -0,0 +1,45 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper078 Jaleco(Cosmo Carrier) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper078 : Mapper + { + public Mapper078(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper078::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MAP78 WR $%04X=$%02X L=%d\n", addr, data, nes->GetScanline() ); + SetPROM_16K_Bank(4, data & 0x0F); + SetVROM_8K_Bank((data & 0xF0) >> 4); + + if ((addr & 0xFE00) != 0xFE00) + { + if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper078.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper078.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs.meta index f49e71b..d9c5bda 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper078.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 194bdddd89a72a641840f7ef60b36f75 +guid: 5be432aeb39d2d24e98b2bb52e85cbe9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs new file mode 100644 index 0000000..f4db416 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs @@ -0,0 +1,41 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper079 Nina-3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper079 : Mapper + { + public Mapper079(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper079::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0x0100) != 0) + { + SetPROM_32K_Bank((data >> 3) & 0x01); + SetVROM_8K_Bank(data & 0x07); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper079.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper079.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs.meta index 16e89a3..b023f72 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper079.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 239bf400a91a2ad42b07c18327d7ab73 +guid: c81e9813295f4434aa6e54baec3e0752 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs new file mode 100644 index 0000000..9e1fd76 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs @@ -0,0 +1,106 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper080 Taito X1-005 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper080 : Mapper + { + public Mapper080(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper080::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x7EF0: + SetVROM_2K_Bank(0, (data >> 1) & 0x3F); + if (PROM_8K_SIZE == 32) + { + if ((data & 0x80) != 0) + { + SetVRAM_1K_Bank(8, 1); + SetVRAM_1K_Bank(9, 1); + } + else + { + SetVRAM_1K_Bank(8, 0); + SetVRAM_1K_Bank(9, 0); + } + } + break; + + case 0x7EF1: + SetVROM_2K_Bank(2, (data >> 1) & 0x3F); + if (PROM_8K_SIZE == 32) + { + if ((data & 0x80) != 0) + { + SetVRAM_1K_Bank(10, 1); + SetVRAM_1K_Bank(11, 1); + } + else + { + SetVRAM_1K_Bank(10, 0); + SetVRAM_1K_Bank(11, 0); + } + } + break; + + case 0x7EF2: + SetVROM_1K_Bank(4, data); + break; + case 0x7EF3: + SetVROM_1K_Bank(5, data); + break; + case 0x7EF4: + SetVROM_1K_Bank(6, data); + break; + case 0x7EF5: + SetVROM_1K_Bank(7, data); + break; + + case 0x7EF6: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + break; + + case 0x7EFA: + case 0x7EFB: + SetPROM_8K_Bank(4, data); + break; + case 0x7EFC: + case 0x7EFD: + SetPROM_8K_Bank(5, data); + break; + case 0x7EFE: + case 0x7EFF: + SetPROM_8K_Bank(6, data); + break; + default: + base.WriteLow(addr, data); + break; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper080.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper080.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs.meta index e9ca94b..bb697cf 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper080.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 80c33ae23427747408bafc4c5a86721a +guid: 233bc8a8511fd30458e7e8c01e43f9fe MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs new file mode 100644 index 0000000..43266b3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs @@ -0,0 +1,119 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper082 Taito C075 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper082 : Mapper + { + BYTE reg; + + public Mapper082(NES parent) : base(parent) + { + } + + public override void Reset() + + { + reg = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE!=0) + { + SetVROM_8K_Bank(0); + } + + SetVRAM_Mirror(VRAM_VMIRROR); + } + + //void Mapper082::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x7EF0: + if (reg!=0) + { + SetVROM_2K_Bank(4, data >> 1); + } + else + { + SetVROM_2K_Bank(0, data >> 1); + } + break; + + case 0x7EF1: + if (reg!=0) + { + SetVROM_2K_Bank(6, data >> 1); + } + else + { + SetVROM_2K_Bank(2, data >> 1); + } + break; + + case 0x7EF2: + if (reg!=0) SetVROM_1K_Bank(0, data); + else SetVROM_1K_Bank(4, data); + break; + case 0x7EF3: + if (reg!=0) SetVROM_1K_Bank(1, data); + else SetVROM_1K_Bank(5, data); + break; + case 0x7EF4: + if (reg!=0) SetVROM_1K_Bank(2, data); + else SetVROM_1K_Bank(6, data); + break; + case 0x7EF5: + if (reg!=0) SetVROM_1K_Bank(3, data); + else SetVROM_1K_Bank(7, data); + break; + + case 0x7EF6: + reg = (byte)(data & 0x02); + if ((data & 0x01)!=0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + break; + + case 0x7EFA: + SetPROM_8K_Bank(4, data >> 2); + break; + case 0x7EFB: + SetPROM_8K_Bank(5, data >> 2); + break; + case 0x7EFC: + SetPROM_8K_Bank(6, data >> 2); + break; + default: + base.WriteLow(addr, data); + break; + } + } + + //void Mapper082::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper082::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper082.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper082.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs.meta index f5c8b1a..4b02e06 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper082.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 62b681ec1c812a64e8ebb96cc8c47d01 +guid: 826a6bd0c5ff43b4e907171f2a901343 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs new file mode 100644 index 0000000..c6b3077 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs @@ -0,0 +1,243 @@ +///////////////////////////// +// Mapper083 Cony // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper083 : Mapper + { + BYTE[] reg = new byte[3]; + INT chr_bank; + BYTE irq_enable; + INT irq_counter; + + BYTE patch; + public Mapper083(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 3; i++) + { + reg[i] = 0x00; + } + + if (PROM_8K_SIZE >= 32) + { + SetPROM_32K_Bank(0, 1, 30, 31); + reg[1] = 0x30; + } + else + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + chr_bank = 0; + + irq_enable = 0; // Disable + irq_counter = 0; + + patch = 0; + if (nes.rom.GetPROM_CRC() == 0x1461D1F8) + { + patch = 1; + } + } + + //BYTE Mapper083::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if ((addr & 0x5100) == 0x5100) + { + return reg[2]; + } + else if (addr >= 0x6000) + { + return base.ReadLow(addr); + } + return (BYTE)(addr >> 8); + } + + //void Mapper083::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + switch (addr) + { + case 0x5101: + case 0x5102: + case 0x5103: + reg[2] = data; + break; + } + + if (addr >= 0x6000) + { + base.WriteLow(addr, data); + } + } + + //void Mapper083::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + switch (addr) + { + case 0x8000: + case 0xB000: + case 0xB0FF: + case 0xB1FF: + reg[0] = data; + chr_bank = (data & 0x30) << 4; + SetPROM_16K_Bank(4, data); + SetPROM_16K_Bank(6, (data & 0x30) | 0x0F); + break; + + case 0x8100: + reg[1] = (byte)(data & 0x80); + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0x8200: + irq_counter = (irq_counter & 0xFF00) | (INT)data; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + case 0x8201: + irq_counter = (irq_counter & 0x00FF) | ((INT)data << 8); + irq_enable = reg[1]; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + + case 0x8300: + SetPROM_8K_Bank(4, data); + break; + case 0x8301: + SetPROM_8K_Bank(5, data); + break; + case 0x8302: + SetPROM_8K_Bank(6, data); + break; + + case 0x8310: + if (patch != 0) + { + SetVROM_2K_Bank(0, chr_bank | data); + } + else + { + SetVROM_1K_Bank(0, chr_bank | data); + } + break; + case 0x8311: + if (patch != 0) + { + SetVROM_2K_Bank(2, chr_bank | data); + } + else + { + SetVROM_1K_Bank(1, chr_bank | data); + } + break; + case 0x8312: + SetVROM_1K_Bank(2, chr_bank | data); + break; + case 0x8313: + SetVROM_1K_Bank(3, chr_bank | data); + break; + case 0x8314: + SetVROM_1K_Bank(4, chr_bank | data); + break; + case 0x8315: + SetVROM_1K_Bank(5, chr_bank | data); + break; + case 0x8316: + if (patch != 0) + { + SetVROM_2K_Bank(4, chr_bank | data); + } + else + { + SetVROM_1K_Bank(6, chr_bank | data); + } + break; + case 0x8317: + if (patch != 0) + { + SetVROM_2K_Bank(6, chr_bank | data); + } + else + { + SetVROM_1K_Bank(7, chr_bank | data); + } + break; + + case 0x8318: + SetPROM_16K_Bank(4, (reg[0] & 0x30) | data); + break; + } + } + + //void Mapper083::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if (irq_counter <= 113) + { + // nes.cpu.IRQ(); + irq_enable = 0; + // nes.cpu.SetIRQ( IRQ_MAPPER ); + nes.cpu.SetIRQ(IRQ_TRIGGER); + } + else + { + irq_counter -= 113; + } + } + } + + //void Mapper083::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg[0]; + //p[1] = reg[1]; + //p[2] = reg[2]; + //*(INT*)&p[3] = chr_bank; + //p[7] = irq_enable; + //*(INT*)&p[8] = irq_counter; + } + + //void Mapper083::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //reg[0] = p[0]; + //reg[1] = p[1]; + //reg[2] = p[2]; + //chr_bank = *(INT*)&p[3]; + //irq_enable = p[7]; + //irq_counter = *(INT*)&p[8]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs.meta new file mode 100644 index 0000000..39796bd --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a5c413bf733d7fa4d96862f1324ff4ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs new file mode 100644 index 0000000..b359ff0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs @@ -0,0 +1,238 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper085 Konami VRC7 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper085 : Mapper + { + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper085(NES parent) : base(parent) + { + } + + public override void Reset() + + { + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + else + { + SetCRAM_8K_Bank(0); + } + +#if FALSE//0 +// DWORD crc = nes.rom.GetPROM_CRC(); +// if( crc == 0x1aa0479c ) { // For Tiny Toon Adventures 2 - Montana Land he Youkoso(J) +// nes.SetRenderMethod( NES::PRE_RENDER ); +// } +// if( crc == 0x33ce3ff0 ) { // For Lagrange Point(J) +// nes.SetRenderMethod( NES::TILE_RENDER ); +// } +#endif + nes.apu.SelectExSound(2); + } + + //void Mapper085::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF038) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + case 0x8008: + case 0x8010: + SetPROM_8K_Bank(5, data); + break; + case 0x9000: + SetPROM_8K_Bank(6, data); + break; + + case 0x9010: + case 0x9030: + nes.apu.ExWrite(addr, data); + break; + + case 0xA000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(0, data); + } + else + { + SetCRAM_1K_Bank(0, data); + } + break; + + case 0xA008: + case 0xA010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(1, data); + } + else + { + SetCRAM_1K_Bank(1, data); + } + break; + + case 0xB000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(2, data); + } + else + { + SetCRAM_1K_Bank(2, data); + } + break; + + case 0xB008: + case 0xB010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(3, data); + } + else + { + SetCRAM_1K_Bank(3, data); + } + break; + + case 0xC000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(4, data); + } + else + { + SetCRAM_1K_Bank(4, data); + } + break; + + case 0xC008: + case 0xC010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(5, data); + } + else + { + SetCRAM_1K_Bank(5, data); + } + break; + + case 0xD000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(6, data); + } + else + { + SetCRAM_1K_Bank(6, data); + } + break; + + case 0xD008: + case 0xD010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(7, data); + } + else + { + SetCRAM_1K_Bank(7, data); + } + break; + + case 0xE000: + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0xE008: + case 0xE010: + irq_latch = data; + break; + + case 0xF000: + irq_enable = (byte)(data & 0x03); + irq_counter = irq_latch; + irq_clock = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF008: + case 0xF010: + irq_enable = (byte)((irq_enable & 0x01) * 3); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper085::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + irq_clock += cycles * 4; + while (irq_clock >= 455) + { + irq_clock -= 455; + irq_counter++; + if (irq_counter == 0) + { + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + //void Mapper085::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //p[1] = irq_counter; + //p[2] = irq_latch; + //*((INT*)&p[4]) = irq_clock; + } + + //void Mapper085::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = p[1]; + //irq_latch = p[2]; + //irq_clock = *((INT*)&p[4]); + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper085.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper085.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs.meta index 032fd66..bd6681a 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper085.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6afe7d8088d58b1418070fa2e6f42cff +guid: 18265e8a35d3835459de279c318124ce MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper086.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper086.cs new file mode 100644 index 0000000..1452d92 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper086.cs @@ -0,0 +1,72 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper086 Jaleco Early Mapper #2 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper086 : Mapper + { + BYTE reg, cnt; + public Mapper086(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 2, 3); + SetVROM_8K_Bank(0); + reg = 0xFF; + cnt = 0; + } + + //void Mapper086::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x6000) + { + SetPROM_32K_Bank((data & 0x30) >> 4); + + SetVROM_8K_Bank((data & 0x03) | ((data & 0x40) >> 4)); + } + if (addr == 0x7000) + { + if ((reg & 0x10) == 0 && ((data & 0x10) != 0) && cnt == 0) + { + //DEBUGOUT( "WR:$%02X\n", data ); + if ((data & 0x0F) == 0 // Strike + || (data & 0x0F) == 5) + { // Foul + cnt = 60; // 次ã®ç™ºå£°ã‚’1秒程ç¦æ­¢ã™ã‚‹ + } + + // OSDã«ã™ã‚‹ã¹ãã‹â€¦ + if (Supporter.Config.sound.bExtraSoundEnable) + { + //TODO : 似乎VirtuaNES有直接播放æŸä¸ªéŸ³é¢‘文件的功能 + //DirectSound.EsfAllStop(); + //DirectSound.EsfPlay(ESF_MOEPRO_STRIKE + (data & 0x0F)); + } + } + reg = data; + } + } + + //void Mapper086::VSync() + public override void VSync() + { + if (cnt != 0) + { + cnt--; + } + } + + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper086.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper086.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper086.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper086.cs.meta index 34a3cb1..1dfe14f 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper086.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper086.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 57129c0244d9b7246a087748b41fdc5b +guid: 8ffee57db5575d740b29c509d43d90bf MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper087.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper087.cs new file mode 100644 index 0000000..71838e9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper087.cs @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper087 Konami 74161/32 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper087 : Mapper + { + public Mapper087(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 2, 3); + SetVROM_8K_Bank(0); + } + + //void Mapper087::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x6000) + { + SetVROM_8K_Bank((data & 0x02) >> 1); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper087.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper087.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper087.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper087.cs.meta index 7b9cd58..7fdd8e7 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper087.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper087.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6340ee74cbb8f2d46a4bc6954246758a +guid: e1e9e68d405123c42a2abb920690d4f5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper088.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper088.cs new file mode 100644 index 0000000..8389c82 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper088.cs @@ -0,0 +1,107 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper088 : Mapper + { + BYTE reg; + BYTE patch; + public Mapper088(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE >= 8) + { + SetVROM_8K_Bank(0); + } + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0xc1b6b2a6) + { // Devil Man(J) + patch = 1; + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + if (crc == 0xd9803a35) + { // Quinty(J) + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + } + + //void Mapper088::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + reg = data; + if (patch != 0) + { + if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + break; + case 0x8001: + switch (reg & 0x07) + { + case 0: + SetVROM_2K_Bank(0, data >> 1); + break; + case 1: + SetVROM_2K_Bank(2, data >> 1); + break; + case 2: + SetVROM_1K_Bank(4, data + 0x40); + break; + case 3: + SetVROM_1K_Bank(5, data + 0x40); + break; + case 4: + SetVROM_1K_Bank(6, data + 0x40); + break; + case 5: + SetVROM_1K_Bank(7, data + 0x40); + break; + case 6: + SetPROM_8K_Bank(4, data); + break; + case 7: + SetPROM_8K_Bank(5, data); + break; + } + break; + case 0xC000: + if (data != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + break; + } + } + + //void Mapper088::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper088::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper088.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper088.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper088.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper088.cs.meta index d9e387c..ddb7e2b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper088.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper088.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 12caa8670cf3a6d468dd168c39fef9b6 +guid: 10a2fd49bb318d348842e3c6f339ce96 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper089.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper089.cs new file mode 100644 index 0000000..880093c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper089.cs @@ -0,0 +1,41 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper089 SunSoft (水戸黄門) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper089 : Mapper + { + public Mapper089(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + } + + //void Mapper089::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0xFF00) == 0xC000) + { + SetPROM_16K_Bank(4, (data & 0x70) >> 4); + + SetVROM_8K_Bank(((data & 0x80) >> 4) | (data & 0x07)); + + if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper089.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper089.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper089.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper089.cs.meta index daf4860..02f1a7f 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper089.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper089.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 84e15b9d69ed162448c7748a15d700ba +guid: 233ec761824cdf442ababb569ced547d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper090.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper090.cs new file mode 100644 index 0000000..d6fd17d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper090.cs @@ -0,0 +1,483 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper090 PC-JY-?? // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class Mapper090 : Mapper + { + BYTE patch; + + BYTE[] prg_reg = new byte[4]; + BYTE[] nth_reg = new byte[4]; + BYTE[] ntl_reg = new byte[4]; + BYTE[] chh_reg = new byte[8]; + BYTE[] chl_reg = new byte[8]; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_occur; + BYTE irq_preset; + BYTE irq_offset; + + BYTE prg_6000, prg_E000; + BYTE prg_size, chr_size; + BYTE mir_mode, mir_type; + + BYTE key_val; + BYTE mul_val1, mul_val2; + BYTE sw_val; + public Mapper090(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_8K_SIZE - 4, PROM_8K_SIZE - 3, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0x2a268152) + { + patch = 1; + } + if (crc == 0x2224b882) + { + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_occur = 0; + irq_preset = 0; + irq_offset = 0; + + prg_6000 = 0; + prg_E000 = 0; + prg_size = 0; + chr_size = 0; + mir_mode = 0; + mir_type = 0; + + key_val = 0; + mul_val1 = mul_val2 = 0; + + for (byte i = 0; i < 4; i++) + { + prg_reg[i] = (byte)(PROM_8K_SIZE - 4 + i); + ntl_reg[i] = 0; + nth_reg[i] = 0; + chl_reg[i] = i; + chh_reg[i] = 0; + chl_reg[i + 4] = (byte)(i + 4); + chh_reg[i + 4] = 0; + } + + if (sw_val != 0) + sw_val = 0x00; + else + sw_val = 0xFF; + + // nes.SetRenderMethod( NES::PRE_ALL_RENDER ); + } + + //BYTE Mapper090::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + Debuger.Log($"RD:{addr:X4}"); + + switch (addr) + { + case 0x5000: + return (byte)((sw_val != 0) ? 0x00 : 0xFF); + case 0x5800: + return (BYTE)(mul_val1 * mul_val2); + case 0x5801: + return (BYTE)((mul_val1 * mul_val2) >> 8); + case 0x5803: + return key_val; + } + + if (addr >= 0x6000) + { + return base.ReadLow(addr); + } + + // return sw_val?0x00:0xFF; + return (BYTE)(addr >> 8); + } + + //void Mapper090::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + Debuger.Log($"WR:{addr:X4} {data:X2}"); + + if (addr == 0x5800) + { + mul_val1 = data; + } + else + if (addr == 0x5801) + { + mul_val2 = data; + } + else + if (addr == 0x5803) + { + key_val = data; + } + } + + //void Mapper090::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF007) + { + case 0x8000: + case 0x8001: + case 0x8002: + case 0x8003: + prg_reg[addr & 3] = data; + SetBank_CPU(); + break; + + case 0x9000: + case 0x9001: + case 0x9002: + case 0x9003: + case 0x9004: + case 0x9005: + case 0x9006: + case 0x9007: + chl_reg[addr & 7] = data; + SetBank_PPU(); + break; + + case 0xA000: + case 0xA001: + case 0xA002: + case 0xA003: + case 0xA004: + case 0xA005: + case 0xA006: + case 0xA007: + chh_reg[addr & 7] = data; + SetBank_PPU(); + break; + + case 0xB000: + case 0xB001: + case 0xB002: + case 0xB003: + ntl_reg[addr & 3] = data; + SetBank_VRAM(); + break; + + case 0xB004: + case 0xB005: + case 0xB006: + case 0xB007: + nth_reg[addr & 3] = data; + SetBank_VRAM(); + break; + + case 0xC002: + irq_enable = 0; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC003: + irq_enable = 0xFF; + irq_preset = 0xFF; + break; + case 0xC004: + break; + case 0xC005: + if ((irq_offset & 0x80) != 0) + { + irq_latch = (byte)(data ^ (irq_offset | 1)); + } + else + { + irq_latch = (byte)(data | (irq_offset & 0x27)); + } + irq_preset = 0xFF; + break; + case 0xC006: + if (patch != 0) + { + irq_offset = data; + } + break; + + case 0xD000: + prg_6000 = (byte)(data & 0x80); + prg_E000 = (byte)(data & 0x04); + prg_size = (byte)(data & 0x03); + chr_size = (byte)((data & 0x18) >> 3); + mir_mode = (byte)(data & 0x20); + SetBank_CPU(); + SetBank_PPU(); + SetBank_VRAM(); + break; + + case 0xD001: + mir_type = (byte)(data & 0x03); + SetBank_VRAM(); + break; + + case 0xD003: + break; + } + } + + //void Mapper090::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_preset != 0) + { + irq_counter = irq_latch; + irq_preset = 0; + } + if (irq_counter != 0) + { + irq_counter--; + } + if (irq_counter == 0) + { + if (irq_enable != 0) + { + // irq_occur = 0xFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + //void Mapper090::Clock(INT cycles) + public override void Clock(int cycles) + { + // if( irq_occur ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + void SetBank_CPU() + { + if (prg_size == 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 4, PROM_8K_SIZE - 3, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + else + if (prg_size == 1) + { + SetPROM_32K_Bank(prg_reg[1] * 2, prg_reg[1] * 2 + 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + else + if (prg_size == 2) + { + if (prg_E000 != 0) + { + SetPROM_32K_Bank(prg_reg[0], prg_reg[1], prg_reg[2], prg_reg[3]); + } + else + { + if (prg_6000 != 0) + { + SetPROM_8K_Bank(3, prg_reg[3]); + } + SetPROM_32K_Bank(prg_reg[0], prg_reg[1], prg_reg[2], PROM_8K_SIZE - 1); + } + } + else + { + SetPROM_32K_Bank(prg_reg[3], prg_reg[2], prg_reg[1], prg_reg[0]); + } + } + + void SetBank_PPU() + { + INT[] bank = new int[8]; + + for (INT i = 0; i < 8; i++) + { + bank[i] = ((INT)chh_reg[i] << 8) | ((INT)chl_reg[i]); + } + + if (chr_size == 0) + { + SetVROM_8K_Bank(bank[0]); + } + else + if (chr_size == 1) + { + SetVROM_4K_Bank(0, bank[0]); + SetVROM_4K_Bank(4, bank[4]); + } + else + if (chr_size == 2) + { + SetVROM_2K_Bank(0, bank[0]); + SetVROM_2K_Bank(2, bank[2]); + SetVROM_2K_Bank(4, bank[4]); + SetVROM_2K_Bank(6, bank[6]); + } + else + { + SetVROM_8K_Bank(bank[0], bank[1], bank[2], bank[3], bank[4], bank[5], bank[6], bank[7]); + } + } + + void SetBank_VRAM() + { + INT[] bank = new int[4]; + + for (INT i = 0; i < 4; i++) + { + bank[i] = ((INT)nth_reg[i] << 8) | ((INT)ntl_reg[i]); + } + + if (patch == 0 && mir_mode != 0) + { + for (INT i = 0; i < 4; i++) + { + if (nth_reg[i] == 0 && (ntl_reg[i] == (BYTE)i)) + { + mir_mode = 0; + } + } + + if (mir_mode != 0) + { + SetVROM_1K_Bank(8, bank[0]); + SetVROM_1K_Bank(9, bank[1]); + SetVROM_1K_Bank(10, bank[2]); + SetVROM_1K_Bank(11, bank[3]); + } + } + else + { + if (mir_type == 0) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else + if (mir_type == 1) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + } + + //void Mapper090::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + INT i; + + for (i = 0; i < 4; i++) + { + p[i] = prg_reg[i]; + } + for (i = 0; i < 8; i++) + { + p[i + 4] = chh_reg[i]; + } + for (i = 0; i < 8; i++) + { + p[i + 12] = chl_reg[i]; + } + for (i = 0; i < 4; i++) + { + p[i + 20] = nth_reg[i]; + } + for (i = 0; i < 4; i++) + { + p[i + 24] = ntl_reg[i]; + } + p[28] = irq_enable; + p[29] = irq_counter; + p[30] = irq_latch; + p[31] = prg_6000; + p[32] = prg_E000; + p[33] = prg_size; + p[34] = chr_size; + p[35] = mir_mode; + p[36] = mir_type; + p[37] = mul_val1; + p[38] = mul_val2; + p[39] = key_val; + p[40] = irq_occur; + p[41] = irq_preset; + p[42] = irq_offset; + } + + //void Mapper090::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + INT i; + + for (i = 0; i < 4; i++) + { + prg_reg[i] = p[i]; + } + for (i = 0; i < 8; i++) + { + chh_reg[i] = p[i + 4]; + } + for (i = 0; i < 8; i++) + { + chl_reg[i] = p[i + 12]; + } + for (i = 0; i < 4; i++) + { + nth_reg[i] = p[i + 20]; + } + for (i = 0; i < 4; i++) + { + ntl_reg[i] = p[i + 24]; + } + irq_enable = p[28]; + irq_counter = p[29]; + irq_latch = p[30]; + prg_6000 = p[31]; + prg_E000 = p[32]; + prg_size = p[33]; + chr_size = p[34]; + mir_mode = p[35]; + mir_type = p[36]; + mul_val1 = p[37]; + mul_val2 = p[38]; + key_val = p[39]; + irq_occur = p[40]; + irq_preset = p[41]; + irq_offset = p[42]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper090.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper090.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper090.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper090.cs.meta index a1534dd..0baee07 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper090.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper090.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4562c28692c896049be0384ad0e20aba +guid: 7c47f962868af9846bc36250b5054775 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper091.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper091.cs new file mode 100644 index 0000000..3143f3d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper091.cs @@ -0,0 +1,104 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper091 PC-HK-SF3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper091 : Mapper + { + BYTE irq_enable; + BYTE irq_counter; + public Mapper091(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, PROM_8K_SIZE - 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0, 0, 0, 0, 0, 0, 0, 0); + } + + irq_enable = 0; + irq_counter = 0; + + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + + //void Mapper091::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + //DEBUGOUT( "$%04X:$%02X(%3d) L=%3d\n", addr, data, data, nes.GetScanline() ); + switch (addr & 0xF003) + { + case 0x6000: + case 0x6001: + case 0x6002: + case 0x6003: + SetVROM_2K_Bank((byte)((addr & 0x03) * 2), data); + break; + + case 0x7000: + SetPROM_8K_Bank(4, data); + break; + case 0x7001: + SetPROM_8K_Bank(5, data); + break; + + case 0x7002: + irq_enable = 0; + irq_counter = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0x7003: + irq_enable = 1; + break; + } + } + + //void Mapper091::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline < 240) && nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + irq_counter++; + } + if (irq_counter >= 8) + { + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper091::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_enable; + p[1] = irq_counter; + } + + //void Mapper091::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_enable = p[0]; + irq_counter = p[1]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper091.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper091.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper091.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper091.cs.meta index d9ca0ce..631cf42 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper091.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper091.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 81a22386348f4944eb3d2efeb823456c +guid: 202340dc4e291a243913879c4b71f605 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper092.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper092.cs new file mode 100644 index 0000000..37a908a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper092.cs @@ -0,0 +1,76 @@ +///////////////////////////////// +// Mapper092 Jaleco/Type1 Higher bank switch // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class Mapper092 : Mapper + { + public Mapper092(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper092::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "A:%04X D:%02X\n", addr, data ); + + data = (byte)(addr & 0xFF); + + if (addr >= 0x9000) + { + if ((data & 0xF0) == 0xD0) + { + SetPROM_16K_Bank(6, data & 0x0F); + } + else if ((data & 0xF0) == 0xE0) + { + SetVROM_8K_Bank(data & 0x0F); + } + } + else + { + if ((data & 0xF0) == 0xB0) + { + SetPROM_16K_Bank(6, data & 0x0F); + } + else if ((data & 0xF0) == 0x70) + { + SetVROM_8K_Bank(data & 0x0F); + } + else if ((data & 0xF0) == 0xC0) + { + INT[] tbl = new int[]{ 3, 4, 5, 6, 0, 1, 2, 7, + 9,10, 8,11,13,12,14,15 }; + + // OSDã«ã™ã‚‹ã¹ãã‹â€¦ + if (Supporter.Config.sound.bExtraSoundEnable) + { + //TODO : 似乎VirtuaNES有直接播放æŸä¸ªéŸ³é¢‘文件的功能 + Debuger.Log($"CODE {data:X2}"); + //DirectSound.EsfAllStop(); + //DirectSound.EsfPlay(ESF_MOEPRO_STRIKE + tbl[data & 0x0F]); + } + } + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper092.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper092.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper092.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper092.cs.meta index 765b4a8..5d0496a 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper092.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper092.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 571f1d5188986574cb8a8b7e10b1268a +guid: 3a75e11e5e1665042bee73c29ecde0b0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper093.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper093.cs new file mode 100644 index 0000000..944ef80 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper093.cs @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper093 SunSoft (Fantasy Zone) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper093 : Mapper + { + public Mapper093(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper093::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x6000) + { + SetPROM_16K_Bank(4, data); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper093.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper093.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper093.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper093.cs.meta index 98d1fa3..1ba2d28 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper093.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper093.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e51bf4286fd1f7d4c85e8595173e5d94 +guid: d549f23df22aaca4c9196d08c290507d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper094.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper094.cs new file mode 100644 index 0000000..cebd932 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper094.cs @@ -0,0 +1,35 @@ +///////////////////////////////// +// Mapper094 Capcom 74161/32 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper094 : Mapper + { + public Mapper094(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper094::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0xFFF0) == 0xFF00) + { + SetPROM_16K_Bank(4, (data >> 2) & 0x7); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper094.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper094.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper094.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper094.cs.meta index dc7e6e4..91ca906 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper094.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper094.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8957c987f3b199c4ba6259065bd5601e +guid: 1a39d5e2c4fc6324ca1a4a1f085052d9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper095.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper095.cs new file mode 100644 index 0000000..6a65166 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper095.cs @@ -0,0 +1,186 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper095 Namcot 106M (Dragon Buster) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper095 : Mapper + { + BYTE reg; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + public Mapper095(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg = 0x00; + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + if (VROM_1K_SIZE != 0) + { + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + } + else + { + chr01 = chr23 = chr4 = chr5 = chr6 = chr7 = 0; + } + + SetBank_PPU(); + + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + + //void Mapper095::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + if (reg <= 0x05) + { + if ((data & 0x20) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + data &= 0x1F; + } + + switch (reg & 0x07) + { + case 0x00: + if (VROM_1K_SIZE != 0) + { + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + } + break; + case 0x01: + if (VROM_1K_SIZE != 0) + { + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + } + break; + case 0x02: + if (VROM_1K_SIZE != 0) + { + chr4 = data; + SetBank_PPU(); + } + break; + case 0x03: + if (VROM_1K_SIZE != 0) + { + chr5 = data; + SetBank_PPU(); + } + break; + case 0x04: + if (VROM_1K_SIZE != 0) + { + chr6 = data; + SetBank_PPU(); + } + break; + case 0x05: + if (VROM_1K_SIZE != 0) + { + chr7 = data; + SetBank_PPU(); + } + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + } + } + + void SetBank_CPU() + { + if ((reg & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + } + + //void Mapper095::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + p[1] = prg0; + p[2] = prg1; + p[3] = chr01; + p[4] = chr23; + p[5] = chr4; + p[6] = chr5; + p[7] = chr6; + p[8] = chr7; + } + + //void Mapper095::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + prg0 = p[1]; + prg1 = p[2]; + chr01 = p[3]; + chr23 = p[4]; + chr4 = p[5]; + chr5 = p[6]; + chr6 = p[7]; + chr7 = p[8]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper095.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper095.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper095.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper095.cs.meta index c4f3a1b..25db414 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper095.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper095.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b71e88068e12bd34fb195cee2cb0dc65 +guid: 9dc2dfb88e4df2a48a83078267a3499e MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs new file mode 100644 index 0000000..8975c44 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs @@ -0,0 +1,75 @@ +//////////////////////////////// +// Mapper096 Bandai 74161 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper096 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper096(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg[0] = reg[1] = 0; + + SetPROM_32K_Bank(0, 1, 2, 3); + SetBank(); + + SetVRAM_Mirror(VRAM_MIRROR4L); + } + + //void Mapper096::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_32K_Bank(data & 0x03); + + reg[0] = (byte)((data & 0x04) >> 2); + SetBank(); + } + + public override void PPU_Latch(ushort addr) + { + if ((addr & 0xF000) == 0x2000) + { + reg[1] = (byte)((addr >> 8) & 0x03); + SetBank(); + } + } + + void SetBank() + { + SetCRAM_4K_Bank(0, reg[0] * 4 + reg[1]); + SetCRAM_4K_Bank(4, reg[0] * 4 + 0x03); + } + + //void Mapper096::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper096::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper096.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper096.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs.meta index 43592ef..ab002b3 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper096.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f860cb5fe74fd8242bc105c669f9d9db +guid: 3e4ba3003173d9543aa8e29ae8802e93 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper097.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper097.cs new file mode 100644 index 0000000..58fd4d9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper097.cs @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper097 Irem 74161 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper097 : Mapper + { + public Mapper097(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, PROM_8K_SIZE - 1, 0, 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper097::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr < 0xC000) + { + SetPROM_16K_Bank(6, data & 0x0F); + + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper097.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper097.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper097.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper097.cs.meta index 664e0ca..058691b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper097.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper097.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b05cc673e685f8444a65d76550f91aa0 +guid: 42c12f8d10ca7b649a0dac124eff2f7a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper099.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper099.cs new file mode 100644 index 0000000..2d6633a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper099.cs @@ -0,0 +1,91 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper099 VS-Unisystem // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper099 : Mapper + { + BYTE coin; + public Mapper099(NES parent) : base(parent) + { + } + + public override void Reset() + { + // set CPU bank pointers + if (PROM_8K_SIZE > 2) + { + SetPROM_32K_Bank(0, 1, 2, 3); + } + else if (PROM_8K_SIZE > 1) + { + SetPROM_32K_Bank(0, 1, 0, 1); + } + else + { + SetPROM_32K_Bank(0, 0, 0, 0); + } + + // set VROM bank + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + coin = 0; + } + + //BYTE Mapper099::ExRead(WORD addr) + public override byte ExRead(ushort addr) + { + if (addr == 0x4020) + { + return coin; + } + + return (byte)(addr >> 8); + } + + //void Mapper099::ExWrite(WORD addr, BYTE data) + public override void ExWrite(ushort addr, byte data) + { + if (addr == 0x4016) + { + if ((data & 0x04) != 0) + { + SetVROM_8K_Bank(1); + } + else + { + SetVROM_8K_Bank(0); + } + + if (nes.rom.GetPROM_CRC() == 0xC99EC059) + { // VS Raid on Bungeling Bay(J) + if ((data & 0x02) != 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + } + } + + if (addr == 0x4020) + { + coin = data; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper099.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper099.cs.meta new file mode 100644 index 0000000..a7d910f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper099.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 39649dfbcf1f91d42bdcff43e912b650 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper100.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper100.cs new file mode 100644 index 0000000..a6f8261 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper100.cs @@ -0,0 +1,301 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper100 : Mapper + { + + BYTE[] reg = new byte[8]; + BYTE prg0, prg1, prg2, prg3; + BYTE chr0, chr1, chr2, chr3, chr4, chr5, chr6, chr7; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + public Mapper100(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + prg2 = (byte)(PROM_8K_SIZE - 2); + prg3 = (byte)(PROM_8K_SIZE - 1); + SetBank_CPU(); + + if (VROM_1K_SIZE != 0) + { + chr0 = 0; + chr1 = 1; + chr2 = 2; + chr3 = 3; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + } + else + { + chr0 = chr2 = chr4 = chr5 = chr6 = chr7 = 0; + chr1 = chr3 = 1; + } + + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + } + + //void Mapper100::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0xC7) + { + case 0x00: + if (VROM_1K_SIZE != 0) + { + chr0 = (byte)(data & 0xFE); + chr1 = (byte)(chr0 + 1); + SetBank_PPU(); + } + break; + case 0x01: + if (VROM_1K_SIZE != 0) + { + chr2 = (byte)(data & 0xFE); + chr3 = (byte)(chr2 + 1); + SetBank_PPU(); + } + break; + case 0x02: + if (VROM_1K_SIZE != 0) + { + chr4 = data; + SetBank_PPU(); + } + break; + case 0x03: + if (VROM_1K_SIZE != 0) + { + chr5 = data; + SetBank_PPU(); + } + break; + case 0x04: + if (VROM_1K_SIZE != 0) + { + chr6 = data; + SetBank_PPU(); + } + break; + case 0x05: + if (VROM_1K_SIZE != 0) + { + chr7 = data; + SetBank_PPU(); + } + break; + + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + case 0x46: + prg2 = data; + SetBank_CPU(); + break; + case 0x47: + prg3 = data; + SetBank_CPU(); + break; + + case 0x80: + if (VROM_1K_SIZE != 0) + { + chr4 = (byte)(data & 0xFE); + chr5 = (byte)(chr4 + 1); + SetBank_PPU(); + } + break; + case 0x81: + if (VROM_1K_SIZE != 0) + { + chr6 = (byte)(data & 0xFE); + chr7 = (byte)(chr6 + 1); + SetBank_PPU(); + } + break; + case 0x82: + if (VROM_1K_SIZE != 0) + { + chr0 = data; + SetBank_PPU(); + } + break; + case 0x83: + if (VROM_1K_SIZE != 0) + { + chr1 = data; + SetBank_PPU(); + } + break; + case 0x84: + if (VROM_1K_SIZE != 0) + { + chr2 = data; + SetBank_PPU(); + } + break; + case 0x85: + if (VROM_1K_SIZE != 0) + { + chr3 = data; + SetBank_PPU(); + } + break; + + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 0xFF; + break; + } + } + + //void Mapper100::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((irq_counter--) == 0) + { + irq_counter = irq_latch; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0, prg1, prg2, prg3); + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(chr0, chr1, chr2, chr3, chr4, chr5, chr6, chr7); + } + } + + //void Mapper100::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = prg2; + p[11] = prg3; + p[12] = chr0; + p[13] = chr1; + p[14] = chr2; + p[15] = chr3; + p[16] = chr4; + p[17] = chr5; + p[18] = chr6; + p[19] = chr7; + p[20] = irq_enable; + p[21] = irq_counter; + p[22] = irq_latch; + } + + //void Mapper100::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + prg2 = p[10]; + prg3 = p[11]; + chr0 = p[12]; + chr1 = p[13]; + chr2 = p[14]; + chr3 = p[15]; + chr4 = p[16]; + chr5 = p[17]; + chr6 = p[18]; + chr7 = p[19]; + irq_enable = p[20]; + irq_counter = p[21]; + irq_latch = p[22]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper100.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper100.cs.meta new file mode 100644 index 0000000..42a1be5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper100.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 64390927ea29e004e9acff1931eefa3d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper101.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper101.cs new file mode 100644 index 0000000..b0b462a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper101.cs @@ -0,0 +1,42 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper101 Jaleco(Urusei Yatsura) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper101 : Mapper + { + public Mapper101(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 2, 3); + SetVROM_8K_Bank(0); + } + + //void Mapper101::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000) + { + SetVROM_8K_Bank(data & 0x03); + } + } + + //void Mapper101::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetVROM_8K_Bank(data & 0x03); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper101.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper101.cs.meta new file mode 100644 index 0000000..8d63a2f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper101.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2285acef4dc998340b6c5668f01662fd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs new file mode 100644 index 0000000..2016051 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs @@ -0,0 +1,202 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper105 Nintendo World Championship // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper105 : Mapper + { + BYTE init_state; + BYTE write_count; + BYTE bits; + BYTE[] reg = new byte[4]; + + BYTE irq_enable; + INT irq_counter; + public Mapper105(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + reg[0] = 0x0C; + reg[1] = 0x00; + reg[2] = 0x00; + reg[3] = 0x10; + + bits = 0; + write_count = 0; + + irq_counter = 0; + irq_enable = 0; + init_state = 0; + } + + //void Mapper105::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //WORD reg_num = (addr & 0x7FFF) >> 13; + uint reg_num = (byte)((addr & 0x7FFF) >> 13); + + if ((data & 0x80) != 0) + { + bits = write_count = 0; + if (reg_num == 0) + { + reg[reg_num] |= 0x0C; + } + } + else + { + //bits |= (data & 1) << write_count++; + bits |= (byte)((data & 1) << write_count++); + if (write_count == 5) + { + reg[reg_num] = (byte)(bits & 0x1F); + bits = write_count = 0; + } + } + + if ((reg[0] & 0x02) != 0) + { + if ((reg[0] & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + else + { + if ((reg[0] & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_MIRROR4H); + } + else + { + SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + + switch (init_state) + { + case 0: + case 1: + init_state++; + break; + case 2: + if ((reg[1] & 0x08) != 0) + { + if ((reg[0] & 0x08) != 0) + { + if ((reg[0] & 0x04) != 0) + { + SetPROM_8K_Bank(4, ((reg[3] & 0x07) * 2 + 16)); + SetPROM_8K_Bank(5, ((reg[3] & 0x07) * 2 + 17)); + SetPROM_8K_Bank(6, 30); + SetPROM_8K_Bank(7, 31); + } + else + { + SetPROM_8K_Bank(4, 16); + SetPROM_8K_Bank(5, 17); + SetPROM_8K_Bank(6, ((reg[3] & 0x07) * 2 + 16)); + SetPROM_8K_Bank(7, ((reg[3] & 0x07) * 2 + 17)); + } + } + else + { + SetPROM_8K_Bank(4, ((reg[3] & 0x06) * 2 + 16)); + SetPROM_8K_Bank(5, ((reg[3] & 0x06) * 2 + 17)); + SetPROM_8K_Bank(6, ((reg[3] & 0x06) * 2 + 18)); + SetPROM_8K_Bank(7, ((reg[3] & 0x06) * 2 + 19)); + } + } + else + { + SetPROM_8K_Bank(4, ((reg[1] & 0x06) * 2 + 0)); + SetPROM_8K_Bank(5, ((reg[1] & 0x06) * 2 + 1)); + SetPROM_8K_Bank(6, ((reg[1] & 0x06) * 2 + 2)); + SetPROM_8K_Bank(7, ((reg[1] & 0x06) * 2 + 3)); + } + + if ((reg[1] & 0x10) != 0) + { + irq_counter = 0; + irq_enable = 0; + } + else + { + irq_enable = 1; + } + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + default: + break; + } + } + + //void Mapper105::HSync(INT scanline) + public override void HSync(int scanline) + { + if (scanline != 0) + { + if (irq_enable != 0) + { + irq_counter += 29781; + } + if (((irq_counter | 0x21FFFFFF) & 0x3E000000) == 0x3E000000) + { + // nes.cpu.IRQ_NotPending(); + // nes.cpu.SetIRQ( IRQ_MAPPER ); + nes.cpu.SetIRQ(IRQ_TRIGGER2); + } + } + } + + //void Mapper105::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 4; i++) + //{ + // p[i] = reg[i]; + //} + //p[8] = init_state; + //p[9] = write_count; + //p[10] = bits; + //p[11] = irq_enable; + //*((INT*)&p[12]) = irq_counter; + } + + //void Mapper105::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 4; i++) + //{ + // reg[i] = p[i]; + //} + //init_state = p[8]; + //write_count = p[9]; + //bits = p[10]; + //irq_enable = p[11]; + //irq_counter = *((INT*)&p[12]); + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper105.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper105.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs.meta index 9c366cb..14a38ea 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper105.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cfb3de8d2c5d1464c87dc027df07e70c +guid: 0833f87b77121f346aceaffc5e05bb1b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper107.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper107.cs new file mode 100644 index 0000000..4a673cc --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper107.cs @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper107 Magic Dragon Mapper // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper107 : Mapper + { + public Mapper107(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + } + + //void Mapper107::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_32K_Bank((data >> 1) & 0x03); + SetVROM_8K_Bank(data & 0x07); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper107.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper107.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper107.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper107.cs.meta index 7a3c039..934add7 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper107.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper107.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: fb362e4e113e6464bb7ea3f78943eeb1 +guid: 4e2d607dcc753e64a91d080c3ec557ff MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper108.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper108.cs new file mode 100644 index 0000000..222e06b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper108.cs @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper108 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper108 : Mapper + { + public Mapper108(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0xC, 0xD, 0xE, 0xF); + SetPROM_8K_Bank(3, 0); + } + + //void Mapper108::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_8K_Bank(3, data); + } + + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper108.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper108.cs.meta new file mode 100644 index 0000000..1b74c68 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper108.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: adb29a0608617bf4a927dd3334bfc23e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper109.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper109.cs new file mode 100644 index 0000000..304d59b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper109.cs @@ -0,0 +1,131 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper109 SACHEN The Great Wall SA-019 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper109 : Mapper + { + + BYTE reg; + BYTE chr0, chr1, chr2, chr3; + BYTE chrmode0, chrmode1; + public Mapper109(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg = 0; + SetPROM_32K_Bank(0); + + chr0 = 0; + chr1 = 0; + chr2 = 0; + chr3 = 0; + SetBank_PPU(); + chrmode0 = 0; + chrmode1 = 0; + } + + //void Mapper109::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x4100: + reg = data; + break; + case 0x4101: + switch (reg) + { + case 0: + chr0 = data; + SetBank_PPU(); + break; + case 1: + chr1 = data; + SetBank_PPU(); + break; + case 2: + chr2 = data; + SetBank_PPU(); + break; + case 3: + chr3 = data; + SetBank_PPU(); + break; + case 4: + chrmode0 = (byte)(data & 0x01); + SetBank_PPU(); + break; + case 5: + SetPROM_32K_Bank(data & 0x07); + break; + case 6: + chrmode1 = (byte)(data & 0x07); + SetBank_PPU(); + break; + case 7: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + } + break; + } + + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(0, chr0); + SetVROM_1K_Bank(1, chr1 | ((chrmode1 << 3) & 0x8)); + SetVROM_1K_Bank(2, chr2 | ((chrmode1 << 2) & 0x8)); + SetVROM_1K_Bank(3, chr3 | ((chrmode1 << 1) & 0x8) | (chrmode0 * 0x10)); + SetVROM_1K_Bank(4, VROM_1K_SIZE - 4); + SetVROM_1K_Bank(5, VROM_1K_SIZE - 3); + SetVROM_1K_Bank(6, VROM_1K_SIZE - 2); + SetVROM_1K_Bank(7, VROM_1K_SIZE - 1); + } + } + + //void Mapper109::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + p[1] = chr0; + p[2] = chr1; + p[3] = chr2; + p[4] = chr3; + p[5] = chrmode0; + p[6] = chrmode1; + } + + //void Mapper109::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + chr0 = p[1]; + chr1 = p[2]; + chr2 = p[3]; + chr3 = p[4]; + chrmode0 = p[5]; + chrmode1 = p[6]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper109.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper109.cs.meta new file mode 100644 index 0000000..1edada2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper109.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 577f4eaa36fb1324d8ab031f613625e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper110.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper110.cs new file mode 100644 index 0000000..41a42bd --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper110.cs @@ -0,0 +1,87 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper110 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper110 : Mapper + { + BYTE reg0, reg1; + public Mapper110(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + + reg0 = 0; + reg1 = 0; + } + //void Mapper110::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x4100: + reg1 = (byte)(data & 0x07); + break; + case 0x4101: + switch (reg1) + { + case 5: + SetPROM_32K_Bank(data); + break; + case 0: + reg0 = (byte)(data & 0x01); + SetVROM_8K_Bank(reg0); + break; + case 2: + reg0 = data; + SetVROM_8K_Bank(reg0); + break; + case 4: + reg0 = (byte)(reg0 | (data << 1)); + SetVROM_8K_Bank(reg0); + break; + case 6: + reg0 = (byte)(reg0 | (data << 2)); + SetVROM_8K_Bank(reg0); + break; + default: + break; + } + break; + default: + break; + } + } + + //void Mapper110::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg0; + p[1] = reg1; + } + + //void Mapper110::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg0 = p[0]; + reg1 = p[1]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper110.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper110.cs.meta new file mode 100644 index 0000000..243b73d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper110.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: baa9bd69c9a0e1e469de6492ca525199 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper111.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper111.cs new file mode 100644 index 0000000..58da90b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper111.cs @@ -0,0 +1,291 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper111 Nintendo MMC1 Hack // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper111 : Mapper + { + + ushort last_addr; + + BYTE patch; + BYTE wram_patch; + BYTE wram_bank; + BYTE wram_count; + + BYTE[] reg = new byte[4]; + BYTE shift, regbuf; + + public Mapper111(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg[0] = 0x0C; // D3=1,D2=1 + reg[1] = reg[2] = reg[3] = 0; + shift = regbuf = 0; + + patch = 0; + wram_patch = 0; + + if (PROM_16K_SIZE < 32) + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + else + { + // For 512K/1M byte Cartridge + SetPROM_16K_Bank(4, 0); + SetPROM_16K_Bank(6, 16 - 1); + + patch = 1; + } + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + // Ninja Ryukenden(J) + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + + //void Mapper111::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + // DEBUGOUT( "MMC1 %04X=%02X\n", addr&0xFFFF,data&0xFF ); + + if ((data & 0x80) != 0) + { + shift = regbuf = 0; + reg[0] |= 0x0C; // D3=1,D2=1 残りã¯ãƒªã‚»ãƒƒãƒˆã•ã‚Œãªã„ + return; + } + + addr = (ushort)((addr & 0x7FFF) >> 13); + reg[addr] = data; + + // DEBUGOUT( "MMC1 %d=%02X\n", addr&0xFFFF,regbuf&0xFF ); + + if (patch != 1) + { + // For Normal Cartridge + switch (addr) + { + case 0: + if ((reg[0] & 0x02) != 0) + { + if ((reg[0] & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + if ((reg[0] & 0x01) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + break; + case 1: + // Register #1 + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x10) != 0) + { + // CHR 4K bank lower($0000-$0FFF) + SetVROM_4K_Bank(0, reg[1]); + // CHR 4K bank higher($1000-$1FFF) + SetVROM_4K_Bank(4, reg[2]); + } + else + { + // CHR 8K bank($0000-$1FFF) + SetVROM_8K_Bank(reg[1] >> 1); + } + } + else + { + // For Romancia + if ((reg[0] & 0x10) != 0) + { + SetCRAM_4K_Bank(0, reg[1]); + } + } + break; + case 2: + // Register #2 + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x10) != 0) + { + // CHR 4K bank lower($0000-$0FFF) + SetVROM_4K_Bank(0, reg[1]); + // CHR 4K bank higher($1000-$1FFF) + SetVROM_4K_Bank(4, reg[2]); + } + else + { + // CHR 8K bank($0000-$1FFF) + SetVROM_8K_Bank(reg[1] >> 1); + } + } + else + { + // For Romancia + if ((reg[0] & 0x10) != 0) + { + SetCRAM_4K_Bank(4, reg[2]); + } + } + break; + case 3: + if ((reg[0] & 0x08) == 0) + { + // PRG 32K bank ($8000-$FFFF) + SetPROM_32K_Bank(reg[3] >> 1); + } + else + { + if ((reg[0] & 0x04) != 0) + { + // PRG 16K bank ($8000-$BFFF) + SetPROM_16K_Bank(4, reg[3]); + SetPROM_16K_Bank(6, PROM_16K_SIZE - 1); + } + else + { + // PRG 16K bank ($C000-$FFFF) + SetPROM_16K_Bank(6, reg[3]); + SetPROM_16K_Bank(4, 0); + } + } + break; + } + } + else + { + // For 512K/1M byte Cartridge + INT PROM_BASE = 0; + if (PROM_16K_SIZE >= 32) + { + PROM_BASE = reg[1] & 0x10; + } + + // Register #0 + if (addr == 0) + { + if ((reg[0] & 0x02) != 0) + { + if ((reg[0] & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + if ((reg[0] & 0x01) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + // Register #1 + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x10) != 0) + { + // CHR 4K bank lower($0000-$0FFF) + SetVROM_4K_Bank(0, reg[1]); + } + else + { + // CHR 8K bank($0000-$1FFF) + SetVROM_8K_Bank(reg[1] >> 1); + } + } + else + { + // For Romancia + if ((reg[0] & 0x10) != 0) + { + SetCRAM_4K_Bank(0, reg[1]); + } + } + // Register #2 + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x10) != 0) + { + // CHR 4K bank higher($1000-$1FFF) + SetVROM_4K_Bank(4, reg[2]); + } + } + else + { + // For Romancia + if ((reg[0] & 0x10) != 0) + { + SetCRAM_4K_Bank(4, reg[2]); + } + } + // Register #3 + if ((reg[0] & 0x08) == 0) + { + // PRG 32K bank ($8000-$FFFF) + SetPROM_32K_Bank((reg[3] & (0xF + PROM_BASE)) >> 1); + } + else + { + if ((reg[0] & 0x04) != 0) + { + // PRG 16K bank ($8000-$BFFF) + SetPROM_16K_Bank(4, PROM_BASE + (reg[3] & 0x0F)); + if (PROM_16K_SIZE >= 32) SetPROM_16K_Bank(6, PROM_BASE + 16 - 1); + } + else + { + // PRG 16K bank ($C000-$FFFF) + SetPROM_16K_Bank(6, PROM_BASE + (reg[3] & 0x0F)); + if (PROM_16K_SIZE >= 32) SetPROM_16K_Bank(4, PROM_BASE); + } + } + } + } + + //void Mapper111::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = reg[2]; + p[3] = reg[3]; + p[4] = shift; + p[5] = regbuf; + + p[6] = wram_bank; + p[7] = wram_count; + } + + //void Mapper111::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; + reg[3] = p[3]; + shift = p[4]; + regbuf = p[5]; + + wram_bank = p[6]; + wram_count = p[7]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper111.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper111.cs.meta new file mode 100644 index 0000000..8828a9a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper111.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 554591bf0683358478fb48fe49a84697 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper112.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper112.cs new file mode 100644 index 0000000..21215bf --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper112.cs @@ -0,0 +1,167 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper112 Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper112 : Mapper + { + BYTE[] reg = new byte[4]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + public Mapper112(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 4; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + } + + //void Mapper112::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0xA000: + reg[1] = data; + switch (reg[0] & 0x07) + { + case 0x00: + prg0 = (byte)((data & (PROM_8K_SIZE - 1))); + SetBank_CPU(); + break; + case 0x01: + prg1 = (byte)((data & (PROM_8K_SIZE - 1))); + SetBank_CPU(); + break; + case 0x02: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x03: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x04: + chr4 = data; + SetBank_PPU(); + break; + case 0x05: + chr5 = data; + SetBank_PPU(); + break; + case 0x06: + chr6 = data; + SetBank_PPU(); + break; + case 0x07: + chr7 = data; + SetBank_PPU(); + break; + } + break; + + case 0xC000: + reg[3] = data; + SetBank_PPU(); + break;//hum æºç å±…然没有break 语法差异呗 + case 0xE000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + SetBank_PPU(); + break; + } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + void SetBank_PPU() + { + if ((reg[2] & 0x02) != 0) + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, chr4, chr5, chr6, chr7); + } + else + { + SetVROM_8K_Bank(((reg[3] << 6) & 0x100) + chr01, + ((reg[3] << 6) & 0x100) + chr01 + 1, + ((reg[3] << 5) & 0x100) + chr23, + ((reg[3] << 5) & 0x100) + chr23 + 1, + ((reg[3] << 4) & 0x100) + chr4, + ((reg[3] << 3) & 0x100) + chr5, + ((reg[3] << 2) & 0x100) + chr6, + ((reg[3] << 1) & 0x100) + chr7); + } + } + + //void Mapper112::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 4; i++) + { + p[i] = reg[i]; + } + p[4] = chr01; + p[5] = chr23; + p[6] = chr4; + p[7] = chr5; + p[8] = chr6; + p[9] = chr7; + } + + //void Mapper112::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (byte i = 0; i < 4; i++) + { + reg[i] = p[i]; + } + + chr01 = p[4]; + chr23 = p[5]; + chr4 = p[6]; + chr5 = p[7]; + chr6 = p[8]; + chr7 = p[9]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper112.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper112.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper112.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper112.cs.meta index 682ebb9..c70eea6 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper112.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper112.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 95343c95a55d7de4785d4fa775ffde3b +guid: aef8742ac61ff474783909cf33b928f5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper113.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper113.cs new file mode 100644 index 0000000..8bde556 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper113.cs @@ -0,0 +1,79 @@ +//////////////////////////// +// Mapper113 PC-Sachen/Hacker // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper113 : Mapper + { + public Mapper113(NES parent) : base(parent) + { + } + + public override void Reset() + { + // SetPROM_32K_Bank( 0, 1, PROM_8K_SIZE-2, PROM_8K_SIZE-1 ); + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper113::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + //DEBUGOUT( "$%04X:$%02X L=%3d\n", addr, data, nes.GetScanline() ); + switch (addr) + { + case 0x4100: + case 0x4111: + case 0x4120: + case 0x4194: + case 0x4195: + case 0x4900: + if (nes.rom.GetPROM_CRC() == 0xA75AEDE5) + { // HES 6-in-1 + if ((data & 0x80) != 0) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + } + SetPROM_32K_Bank(data >> 3); + SetVROM_8K_Bank(((data >> 3) & 0x08) + (data & 0x07)); + break; + } + } + + //void Mapper113::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "$%04X:$%02X L=%3d\n", addr, data, nes.GetScanline() ); + switch (addr) + { + case 0x8008: + case 0x8009: + SetPROM_32K_Bank(data >> 3); + SetVROM_8K_Bank(((data >> 3) & 0x08) + (data & 0x07)); + break; + case 0x8E66: + case 0x8E67: + //SetVROM_8K_Bank((data & 0x07) ? 0 : 1); + SetVROM_8K_Bank((data & 0x07) != 0 ? 0 : 1); + break; + case 0xE00A: + SetVRAM_Mirror(VRAM_MIRROR4L); + break; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper113.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper113.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper113.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper113.cs.meta index 417f79d..1d9bf4b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper113.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper113.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4bb984682499b7b4883f1ca9a4f9bd71 +guid: 6e8958c2cccbe9d46805e08e394967f1 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper114.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper114.cs new file mode 100644 index 0000000..3bc87a3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper114.cs @@ -0,0 +1,186 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper114 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using System.Text.RegularExpressions; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper114 : Mapper + { + BYTE reg_m, reg_a; + BYTE[] reg_b = new BYTE[8]; + BYTE reg_c; + BYTE irq_counter; + BYTE irq_occur; + public Mapper114(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + reg_a = reg_c = reg_m = 0; + for (INT i = 0; i < 8; i++) + { + reg_b[i] = 0; + } + irq_counter = 0; + irq_occur = 0; + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + + //void Mapper114::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + reg_m = data; + SetBank_CPU(); + } + + //void Mapper114::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr == 0xE003) + { + irq_counter = data; + } + else + if (addr == 0xE002) + { + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + } + else + { + switch (addr & 0xE000) + { + case 0x8000: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xA000: + reg_c = 1; + reg_a = data; + break; + case 0xC000: + if (reg_c == 0) + { + break; + } + reg_b[reg_a & 0x07] = data; + switch (reg_a & 0x07) + { + case 0: + case 1: + case 2: + case 3: + case 6: + case 7: + SetBank_PPU(); + break; + case 4: + case 5: + SetBank_CPU(); + break; + } + reg_c = 0; + break; + } + } + } + + //void Mapper114::Clock(INT scanline) + public override void Clock(int cycles) + { + // if( irq_occur ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + //void Mapper114::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if (irq_counter != 0) + { + irq_counter--; + if (irq_counter == 0) + { + irq_occur = 0xFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + void SetBank_CPU() + { + if ((reg_m & 0x80) != 0) + { + SetPROM_16K_Bank(4, reg_m & 0x1F); + } + else + { + SetPROM_8K_Bank(4, reg_b[4]); + SetPROM_8K_Bank(5, reg_b[5]); + } + } + + void SetBank_PPU() + { + SetVROM_2K_Bank(0, reg_b[0] >> 1); + SetVROM_2K_Bank(2, reg_b[2] >> 1); + SetVROM_1K_Bank(4, reg_b[6]); + SetVROM_1K_Bank(5, reg_b[1]); + SetVROM_1K_Bank(6, reg_b[7]); + SetVROM_1K_Bank(7, reg_b[3]); + } + + //void Mapper114::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (int i = 0; i < 8; i++) + { + p[i] = reg_b[i]; + } + + p[8] = reg_m; + p[9] = reg_a; + p[10] = reg_c; + p[11] = irq_counter; + p[12] = irq_occur; + } + + //void Mapper114::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (int i = 0; i < 8; i++) + { + reg_b[i] = p[i]; + } + reg_m = p[8]; + reg_a = p[9]; + reg_c = p[10]; + irq_counter = p[11]; + irq_occur = p[12]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper114.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper114.cs.meta new file mode 100644 index 0000000..60ae6c6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper114.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 51657beea06191a41b34933f48417d57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper115.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper115.cs new file mode 100644 index 0000000..1b21169 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper115.cs @@ -0,0 +1,302 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper115 CartSaint : Yuu Yuu Hakusho Final // +// JusticePao(?) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper115 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1, prg2, prg3; + BYTE prg0L, prg1L; + BYTE chr0, chr1, chr2, chr3, chr4, chr5, chr6, chr7; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + + BYTE ExPrgSwitch; + BYTE ExChrSwitch; + public Mapper115(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = prg0L = 0; + prg1 = prg1L = 1; + prg2 = (byte)(PROM_8K_SIZE - 2); + prg3 = (byte)(PROM_8K_SIZE - 1); + + ExPrgSwitch = 0; + ExChrSwitch = 0; + + SetBank_CPU(); + + if (VROM_1K_SIZE!=0) + { + chr0 = 0; + chr1 = 1; + chr2 = 2; + chr3 = 3; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + } + else + { + chr0 = chr2 = chr4 = chr5 = chr6 = chr7 = 0; + chr1 = chr3 = 1; + } + + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + } + + + //void Mapper115::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x6000: + ExPrgSwitch = data; //data + SetBank_CPU(); + break; + case 0x6001: + ExChrSwitch = (byte)(data & 0x1); + SetBank_PPU(); + break; + } + //Mapper::WriteLow(addr, data); + base.WriteLow(addr, data); + } + + + //void Mapper115::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + switch (reg[0] & 0x07) + { + case 0x00: + chr0 = (byte)(data & 0xFE); + chr1 = (byte)(chr0 + 1); + SetBank_PPU(); + break; + case 0x01: + chr2 = (byte)(data & 0xFE); + chr3 = (byte)(chr2 + 1); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = prg0L = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = prg1L = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01)!=0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_enable = 0xFF; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 0xFF; + break; + } + } + + //void Mapper115::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable!=0) + { + if ((irq_counter--)==0) + { + irq_counter = irq_latch; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + + void SetBank_CPU() + { + if ((ExPrgSwitch & 0x80)!=0) + { + prg0 = (byte)(((ExPrgSwitch << 1) & 0x1e)); + prg1 = (byte)(prg0 + 1); + + SetPROM_32K_Bank(prg0, prg1, prg0 + 2, prg1 + 2); + } + else + { + prg0 = prg0L; + prg1 = prg1L; + if ((reg[0] & 0x40)!=0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE!=0) + { + if ((reg[0] & 0x80)!=0) + { + SetVROM_8K_Bank((ExChrSwitch << 8) + chr4, (ExChrSwitch << 8) + chr5, + (ExChrSwitch << 8) + chr6, (ExChrSwitch << 8) + chr7, + (ExChrSwitch << 8) + chr0, (ExChrSwitch << 8) + chr1, + (ExChrSwitch << 8) + chr2, (ExChrSwitch << 8) + chr3); + } + else + { + SetVROM_8K_Bank((ExChrSwitch << 8) + chr0, (ExChrSwitch << 8) + chr1, + (ExChrSwitch << 8) + chr2, (ExChrSwitch << 8) + chr3, + (ExChrSwitch << 8) + chr4, (ExChrSwitch << 8) + chr5, + (ExChrSwitch << 8) + chr6, (ExChrSwitch << 8) + chr7); + } + } + } + + //void Mapper115::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = prg2; + p[11] = prg3; + p[12] = chr0; + p[13] = chr1; + p[14] = chr2; + p[15] = chr3; + p[16] = chr4; + p[17] = chr5; + p[18] = chr6; + p[19] = chr7; + p[20] = irq_enable; + p[21] = irq_counter; + p[22] = irq_latch; + p[23] = ExPrgSwitch; + p[24] = prg0L; + p[25] = prg1L; + p[26] = ExChrSwitch; + + } + + //void Mapper115::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + prg2 = p[10]; + prg3 = p[11]; + chr0 = p[12]; + chr1 = p[13]; + chr2 = p[14]; + chr3 = p[15]; + chr4 = p[16]; + chr5 = p[17]; + chr6 = p[18]; + chr7 = p[19]; + irq_enable = p[20]; + irq_counter = p[21]; + irq_latch = p[22]; + ExPrgSwitch = p[23]; + prg0L = p[24]; + prg1L = p[25]; + ExChrSwitch = p[26]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper115.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper115.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper115.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper115.cs.meta index 2e6e78f..d9432ac 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper115.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper115.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cd032d0a8b03c6345b983161007e83c5 +guid: 27c78096fe71294488eed0e869047d1c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper116.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper116.cs new file mode 100644 index 0000000..e144883 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper116.cs @@ -0,0 +1,333 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper116 CartSaint : å¹½éŠAVå¼·åˆ—ä¼ // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class Mapper116 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1, prg2, prg3; + BYTE prg0L, prg1L; + BYTE chr0, chr1, chr2, chr3, chr4, chr5, chr6, chr7; + + BYTE irq_enable; + INT irq_counter; + BYTE irq_latch; + + BYTE ExPrgSwitch; + BYTE ExChrSwitch; + public Mapper116(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = prg0L = 0; + prg1 = prg1L = 1; + prg2 = (byte)(PROM_8K_SIZE - 2); + prg3 = (byte)(PROM_8K_SIZE - 1); + + ExPrgSwitch = 0; + ExChrSwitch = 0; + + SetBank_CPU(); + + if (VROM_1K_SIZE != 0) + { + chr0 = 0; + chr1 = 1; + chr2 = 2; + chr3 = 3; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + } + else + { + chr0 = chr2 = chr4 = chr5 = chr6 = chr7 = 0; + chr1 = chr3 = 1; + } + + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + + // nes.SetFrameIRQmode( FALSE ); + } + + //void Mapper116::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + Debuger.Log($"MPRWR A={addr & 0xFFFF:X4} D={data & 0xFF:X2} L={nes.GetScanline(),3} CYC={nes.cpu.GetTotalCycles()}"); + if ((addr & 0x4100) == 0x4100) + { + ExChrSwitch = data; + SetBank_PPU(); + } + } + + //void Mapper116::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + Debuger.Log($"MPRWR A={addr & 0xFFFF:X4} D={data & 0xFF:X2} L={nes.GetScanline(),3} CYC={nes.cpu.GetTotalCycles()}"); + + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + switch (reg[0] & 0x07) + { + case 0x00: + chr0 = (byte)(data & 0xFE); + chr1 = (byte)(chr0 + 1); + SetBank_PPU(); + break; + case 0x01: + chr2 = (byte)(data & 0xFE); + chr3 = (byte)(chr2 + 1); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + // irq_enable = 0xFF; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_counter = irq_latch; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 0xFF; + break; + } + } + + //void Mapper116::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (irq_counter <= 0) + { + if (irq_enable != 0) + { + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + +#if FALSE //0 +DEBUGOUT( "IRQ L=%3d\n", scanline ); +{ +LPBYTE lpScn = nes.ppu.GetScreenPtr(); + + lpScn = lpScn+(256+16)*scanline; + + for( INT i = 0; i < 64; i++ ) { + lpScn[i] = 22; + } +} +#endif + return; + } + } + + if (nes.ppu.IsDispON()) + { + irq_counter--; + } + } + +#if FALSE //0 + if( (scanline >= 0 && scanline <= 239) ) { + if( nes.ppu.IsDispON() ) { + if( irq_enable ) { + if( !(irq_counter--) ) { +// irq_counter = irq_latch; + nes.cpu.IRQ_NotPending(); + } + } + } + } +#endif + } + + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((ExChrSwitch & 0x04) != 0) + { + INT chrbank = 256; + SetVROM_8K_Bank(chrbank + chr4, chrbank + chr5, + chrbank + chr6, chrbank + chr7, + chr0, chr1, + chr2, chr3); + } + else + { + INT chrbank = 0; + SetVROM_8K_Bank(chrbank + chr4, chrbank + chr5, + chrbank + chr6, chrbank + chr7, + chr0, chr1, + chr2, chr3); + } + +#if FALSE //0 + if( reg[0] & 0x80 ) { +// SetVROM_8K_Bank( chrbank+chr4, chrbank+chr5, +// chrbank+chr6, chrbank+chr7, +// chrbank+chr0, chrbank+chr1, +// chrbank+chr2, chrbank+chr3 ); + SetVROM_8K_Bank( chrbank+chr4, chrbank+chr5, + chrbank+chr6, chrbank+chr7, + chr0, chr1, + chr2, chr3 ); + } else { + SetVROM_8K_Bank( chr0, chr1, + chr2, chr3, + chrbank+chr4, chrbank+chr5, + chrbank+chr6, chrbank+chr7 ); + } +#endif + } + } + + //void Mapper116::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = prg2; + p[11] = prg3; + p[12] = chr0; + p[13] = chr1; + p[14] = chr2; + p[15] = chr3; + p[16] = chr4; + p[17] = chr5; + p[18] = chr6; + p[19] = chr7; + p[20] = irq_enable; + p[21] = (byte)irq_counter; + p[22] = irq_latch; + p[23] = ExPrgSwitch; + p[24] = prg0L; + p[25] = prg1L; + p[26] = ExChrSwitch; + } + + //void Mapper116::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + prg2 = p[10]; + prg3 = p[11]; + chr0 = p[12]; + chr1 = p[13]; + chr2 = p[14]; + chr3 = p[15]; + chr4 = p[16]; + chr5 = p[17]; + chr6 = p[18]; + chr7 = p[19]; + irq_enable = p[20]; + irq_counter = p[21]; + irq_latch = p[22]; + ExPrgSwitch = p[23]; + prg0L = p[24]; + prg1L = p[25]; + ExChrSwitch = p[26]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper116.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper116.cs.meta new file mode 100644 index 0000000..18c699e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper116.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a958c4651f82c204fa1f88e7f59c97da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper117.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper117.cs new file mode 100644 index 0000000..59d4229 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper117.cs @@ -0,0 +1,120 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper117 Sanko Gu(Tw) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper117 : Mapper + { + BYTE irq_enable; + BYTE irq_counter; + public Mapper117(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper117::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + case 0x8001: + SetPROM_8K_Bank(5, data); + break; + case 0x8002: + SetPROM_8K_Bank(6, data); + break; + case 0xA000: + SetVROM_1K_Bank(0, data); + break; + case 0xA001: + SetVROM_1K_Bank(1, data); + break; + case 0xA002: + SetVROM_1K_Bank(2, data); + break; + case 0xA003: + SetVROM_1K_Bank(3, data); + break; + case 0xA004: + SetVROM_1K_Bank(4, data); + break; + case 0xA005: + SetVROM_1K_Bank(5, data); + break; + case 0xA006: + SetVROM_1K_Bank(6, data); + break; + case 0xA007: + SetVROM_1K_Bank(7, data); + break; + case 0xC001: + case 0xC002: + case 0xC003: + irq_counter = data; + break; + case 0xE000: + irq_enable = (byte)(data & 1); + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + } + } + //void Mapper117::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if (irq_counter == scanline) + { + irq_counter = 0; + // nes.cpu.IRQ(); + // nes.cpu.SetIRQ( IRQ_MAPPER ); + nes.cpu.SetIRQ(IRQ_TRIGGER); + } + } + } + } + } + + //void Mapper117::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_counter; + p[1] = irq_enable; + } + + //void Mapper117::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_counter = p[0]; + irq_enable = p[1]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper117.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper117.cs.meta new file mode 100644 index 0000000..c59d63e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper117.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 01bde0a4f3f20d84d961068ed452d93f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper118.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper118.cs new file mode 100644 index 0000000..1ad58f2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper118.cs @@ -0,0 +1,262 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper118 IQS MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper118 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + public Mapper118(NES parent) : base(parent) + { + } + + public override void Reset() + { + INT i; + + for (i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + if (VROM_1K_SIZE != 0) + { + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + + SetBank_PPU(); + } + else + { + chr01 = 0; + chr23 = 0; + chr4 = 0; + chr5 = 0; + chr6 = 0; + chr7 = 0; + } + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + } + + //void Mapper118::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + if ((reg[0] & 0x80) != 0) + { + if ((reg[0] & 0x07) == 2) + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + } + } + else + { + if ((reg[0] & 0x07) == 0) + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + } + } + + switch (reg[0] & 0x07) + { + case 0x00: + if (VROM_1K_SIZE != 0) + { + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + } + break; + case 0x01: + if (VROM_1K_SIZE != 0) + { + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + } + break; + case 0x02: + if (VROM_1K_SIZE != 0) + { + chr4 = data; + SetBank_PPU(); + } + break; + case 0x03: + if (VROM_1K_SIZE != 0) + { + chr5 = data; + SetBank_PPU(); + } + break; + case 0x04: + if (VROM_1K_SIZE != 0) + { + chr6 = data; + SetBank_PPU(); + } + break; + case 0x05: + if (VROM_1K_SIZE != 0) + { + chr7 = data; + SetBank_PPU(); + } + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + + case 0xC000: + reg[4] = data; + irq_counter = data; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + break; + } + } + + //void Mapper118::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((irq_counter--) == 0) + { + irq_counter = irq_latch; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + } + + //void Mapper118::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + } + + //void Mapper118::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper118.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper118.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper118.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper118.cs.meta index aca92d8..711e870 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper118.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper118.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6aa2fe8842a72ee4782e1df1077cfb77 +guid: a52f7dcc530347a4d828eb0e09829a16 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper119.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper119.cs new file mode 100644 index 0000000..34f4013 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper119.cs @@ -0,0 +1,263 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper119 Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper119 : Mapper + { + BYTE patch; + + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + public Mapper119(NES parent) : base(parent) + { + } + + public override void Reset() + + { + patch = 0; + + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + } + + //void Mapper119::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + if (VROM_1K_SIZE != 0) + { + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + } + break; + case 0x01: + if (VROM_1K_SIZE != 0) + { + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + } + break; + case 0x02: + if (VROM_1K_SIZE != 0) + { + chr4 = data; + SetBank_PPU(); + } + break; + case 0x03: + if (VROM_1K_SIZE != 0) + { + chr5 = data; + SetBank_PPU(); + } + break; + case 0x04: + if (VROM_1K_SIZE != 0) + { + chr6 = data; + SetBank_PPU(); + } + break; + case 0x05: + if (VROM_1K_SIZE != 0) + { + chr7 = data; + SetBank_PPU(); + } + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_counter = irq_latch; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + break; + } + } + + //void Mapper119::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((irq_counter--) == 0) + { + irq_counter = irq_latch; + // nes.cpu.IRQ(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if ((reg[0] & 0x80) != 0) + { + if ((chr4 & 0x40) != 0) SetCRAM_1K_Bank(0, chr4 & 0x07); else SetVROM_1K_Bank(0, chr4); + if ((chr5 & 0x40) != 0) SetCRAM_1K_Bank(1, chr5 & 0x07); else SetVROM_1K_Bank(1, chr5); + if ((chr6 & 0x40) != 0) SetCRAM_1K_Bank(2, chr6 & 0x07); else SetVROM_1K_Bank(2, chr6); + if ((chr7 & 0x40) != 0) SetCRAM_1K_Bank(3, chr7 & 0x07); else SetVROM_1K_Bank(3, chr7); + + if (((chr01 + 0) & 0x40) != 0) SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); else SetVROM_1K_Bank(4, (chr01 + 0)); + if (((chr01 + 1) & 0x40) != 0) SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); else SetVROM_1K_Bank(5, (chr01 + 1)); + if (((chr23 + 0) & 0x40) != 0) SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); else SetVROM_1K_Bank(6, (chr23 + 0)); + if (((chr23 + 1) & 0x40) != 0) SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); else SetVROM_1K_Bank(7, (chr23 + 1)); + } + else + { + if (((chr01 + 0) & 0x40) != 0) SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); else SetVROM_1K_Bank(0, (chr01 + 0)); + if (((chr01 + 1) & 0x40) != 0) SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); else SetVROM_1K_Bank(1, (chr01 + 1)); + if (((chr23 + 0) & 0x40) != 0) SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); else SetVROM_1K_Bank(2, (chr23 + 0)); + if (((chr23 + 1) & 0x40) != 0) SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); else SetVROM_1K_Bank(3, (chr23 + 1)); + + if ((chr4 & 0x40) != 0) SetCRAM_1K_Bank(4, chr4 & 0x07); else SetVROM_1K_Bank(4, chr4); + if ((chr5 & 0x40) != 0) SetCRAM_1K_Bank(5, chr5 & 0x07); else SetVROM_1K_Bank(5, chr5); + if ((chr6 & 0x40) != 0) SetCRAM_1K_Bank(6, chr6 & 0x07); else SetVROM_1K_Bank(6, chr6); + if ((chr7 & 0x40) != 0) SetCRAM_1K_Bank(7, chr7 & 0x07); else SetVROM_1K_Bank(7, chr7); + } + } + + ///void Mapper119::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + } + + //void Mapper119::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + } + + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper119.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper119.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper119.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper119.cs.meta index 1c2f177..27fd811 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper119.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper119.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7286dc403cf3750449c7c3ec5b6e8067 +guid: b64ef6cdbe294e94b9bab584acd56e9b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper122.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper122.cs new file mode 100644 index 0000000..ef53ddd --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper122.cs @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper122/184 SunSoft-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper122 : Mapper + { + public Mapper122(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 2, 3); + } + + //void Mapper122::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x6000) + { + SetVROM_4K_Bank(0, data & 0x07); + SetVROM_4K_Bank(4, (data & 0x70) >> 4); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper122.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper122.cs.meta new file mode 100644 index 0000000..6d093e6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper122.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b1cbf770cbd99df4fb728b2a73992c3f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper133.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper133.cs new file mode 100644 index 0000000..30887ca --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper133.cs @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper133 SACHEN CHEN // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper133 : Mapper + { + public Mapper133(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper133::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x4120) + { + SetPROM_32K_Bank((data & 0x04) >> 2); + SetVROM_8K_Bank(data & 0x03); + } + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper133.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper133.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper133.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper133.cs.meta index d70a1c4..0f43a73 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper133.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper133.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9b03fd27304f16b4dafa17d7d1750ee1 +guid: e3161fceb02a7c545a1fa5a655c0c489 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper134.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper134.cs new file mode 100644 index 0000000..66f2c19 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper134.cs @@ -0,0 +1,86 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper133 SACHEN CHEN // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper134 : Mapper + { + BYTE cmd, prg, chr; + public Mapper134(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0); + // SetPROM_16K_Bank( 6, 0 ); + // SetPROM_16K_Bank( 6, 1 ); + SetVROM_8K_Bank(0); + } + + //void Mapper134::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr & 0x4101) + { + case 0x4100: + cmd = (byte)(data & 0x07); + break; + case 0x4101: + switch (cmd) + { + case 0: + prg = 0; + chr = 3; + break; + case 4: + chr &= 0x3; + chr |= (byte)((data & 0x07) << 2); + break; + case 5: + prg = (byte)(data & 0x07); + break; + case 6: + chr &= 0x1C; + chr |= (byte)(data & 0x3); + break; + case 7: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + } + break; + } + SetPROM_32K_Bank(prg); + // SetPROM_16K_Bank( 4, (prg<<1)|0 ); + // SetPROM_16K_Bank( 6, (prg<<1)|1 ); + SetVROM_8K_Bank(chr); + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + + //void Mapper134::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = cmd; + p[1] = prg; + p[2] = chr; + } + + //void Mapper134::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + cmd = p[0]; + prg = p[1]; + chr = p[2]; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper134.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper134.cs.meta new file mode 100644 index 0000000..72b8f68 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper134.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d7c97443a7607d740913038bae633d03 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper135.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper135.cs new file mode 100644 index 0000000..db522e9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper135.cs @@ -0,0 +1,113 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper135 SACHEN CHEN // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper135 : Mapper + { + BYTE cmd; + BYTE chr0l, chr1l, chr0h, chr1h, chrch; + public Mapper135(NES parent) : base(parent) + { + } + + public override void Reset() + { + cmd = 0; + chr0l = chr1l = chr0h = chr1h = chrch = 0; + + SetPROM_32K_Bank(0); + SetBank_PPU(); + } + + //void Mapper135::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr & 0x4101) + { + case 0x4100: + cmd = (byte)(data & 0x07); + break; + case 0x4101: + switch (cmd) + { + case 0: + chr0l = (byte)(data & 0x07); + SetBank_PPU(); + break; + case 1: + chr0h = (byte)(data & 0x07); + SetBank_PPU(); + break; + case 2: + chr1l = (byte)(data & 0x07); + SetBank_PPU(); + break; + case 3: + chr1h = (byte)(data & 0x07); + SetBank_PPU(); + break; + case 4: + chrch = (byte)(data & 0x07); + SetBank_PPU(); + break; + case 5: + SetPROM_32K_Bank((byte)(data & 0x07)); + break; + case 6: + break; + case 7: + switch ((data >> 1) & 0x03) + { + case 0: SetVRAM_Mirror(VRAM_MIRROR4L); break; + case 1: SetVRAM_Mirror(VRAM_HMIRROR); break; + case 2: SetVRAM_Mirror(VRAM_VMIRROR); break; + case 3: SetVRAM_Mirror(VRAM_MIRROR4L); break; + } + break; + } + break; + } + + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + + void SetBank_PPU() + { + SetVROM_2K_Bank(0, 0 | (chr0l << 1) | (chrch << 4)); + SetVROM_2K_Bank(2, 1 | (chr0h << 1) | (chrch << 4)); + SetVROM_2K_Bank(4, 0 | (chr1l << 1) | (chrch << 4)); + SetVROM_2K_Bank(6, 1 | (chr1h << 1) | (chrch << 4)); + } + + //void Mapper135::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = cmd; + p[1] = chr0l; + p[2] = chr0h; + p[3] = chr1l; + p[4] = chr1h; + p[5] = chrch; + } + + //void Mapper135::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + cmd = p[0]; + chr0l = p[1]; + chr0h = p[2]; + chr0l = p[3]; + chr0h = p[4]; + chrch = p[5]; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper135.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper135.cs.meta new file mode 100644 index 0000000..2780ef7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper135.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: abc08edc7381db447a58cb32a9d062b5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper140.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper140.cs new file mode 100644 index 0000000..bf3f337 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper140.cs @@ -0,0 +1,36 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper140 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper140 : Mapper + { + public Mapper140(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper140::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + SetPROM_32K_Bank((data & 0xF0) >> 4); + SetVROM_8K_Bank(data & 0x0F); + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper140.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper140.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper140.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper140.cs.meta index d562dd2..3e2b6ad 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper140.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper140.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3cba32549a9133c49bbc34b948b557d9 +guid: b316b95bf91e5684390dde5856a878cc MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs new file mode 100644 index 0000000..5800e93 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs @@ -0,0 +1,113 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper142 SMB2J // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper142 : Mapper + { + BYTE prg_sel; + BYTE irq_enable; + INT irq_counter; + public Mapper142(NES parent) : base(parent) + { + } + + public override void Reset() + + { + prg_sel = 0; + irq_enable = 0; + irq_counter = 0; + + SetPROM_8K_Bank(3, 0); + SetPROM_8K_Bank(7, 0x0F); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper142::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x8000: + irq_counter = (irq_counter & 0xFFF0) | ((data & 0x0F) << 0); + break; + case 0x9000: + irq_counter = (irq_counter & 0xFF0F) | ((data & 0x0F) << 4); + break; + case 0xA000: + irq_counter = (irq_counter & 0xF0FF) | ((data & 0x0F) << 8); + break; + case 0xB000: + irq_counter = (irq_counter & 0x0FFF) | ((data & 0x0F) << 12); + break; + case 0xC000: + irq_enable = (byte)(data & 0x0F); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE000: + prg_sel = (byte)(data & 0x0F); + break; + case 0xF000: + switch (prg_sel) + { + case 1: SetPROM_8K_Bank(4, data & 0x0F); break; + case 2: SetPROM_8K_Bank(5, data & 0x0F); break; + case 3: SetPROM_8K_Bank(6, data & 0x0F); break; + case 4: SetPROM_8K_Bank(3, data & 0x0F); break; + } + break; + } + } + + //void Mapper142::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if (irq_counter > (0xFFFF - 113)) + { + irq_counter = 0; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter += 113; + } + } + } + + //void Mapper142::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = prg_sel; + //p[0] = irq_enable; + //*(INT*)&p[2] = irq_counter; + } + + //void Mapper142::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //prg_sel = p[0]; + //irq_enable = p[1]; + //irq_counter = *(INT*)&p[2]; + } + public override bool IsStateSave() + { + return true; + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs.meta new file mode 100644 index 0000000..96b98f4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c2a6e8164fd3e64b9e4390d1a36a86d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper151.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper151.cs new file mode 100644 index 0000000..59d9d94 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper151.cs @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper151 VS-Unisystem // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper151 : Mapper + { + public Mapper151(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); +#if FALSE//0 //hum + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0x1E438D52) + { + DirectDraw.SetVsPalette(7); //VS_Goonies + } + if (crc == 0xD99A2087) + { + DirectDraw.SetVsPalette(6); //VS_Gradius + } +#endif + } + + //void Mapper151::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + case 0xC000: + SetPROM_8K_Bank(6, data); + break; + case 0xE000: + SetVROM_4K_Bank(0, data); + break; + case 0xF000: + SetVROM_4K_Bank(4, data); + break; + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper151.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper151.cs.meta new file mode 100644 index 0000000..d6592b7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper151.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b6ad09a5fe20cdb4689f3f2ac2deaf06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper160.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper160.cs new file mode 100644 index 0000000..66a8a9b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper160.cs @@ -0,0 +1,232 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper160 PC-Aladdin // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper160 : Mapper + { + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE refresh_type; + public Mapper160(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + refresh_type = 0; + } + + //void Mapper160::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + case 0x8001: + SetPROM_8K_Bank(5, data); + break; + case 0x8002: + SetPROM_8K_Bank(6, data); + break; + + case 0x9000: + if (data == 0x2B) + { + refresh_type = 1; + } + else if (data == 0xA8) + { + refresh_type = 2; + } + else if (data == 0x1F) + { + refresh_type = 3; + } + else if (data == 0x7C) + { + refresh_type = 4; + } + else if (data == 0x18) + { + refresh_type = 5; + } + else if (data == 0x60) + { + refresh_type = 6; + } + else + { + refresh_type = 0; + } + SetVROM_1K_Bank(0, data); + break; + case 0x9001: + SetVROM_1K_Bank(1, data); + break; + + case 0x9002: + if (refresh_type == 2 && data != 0xE8) + { + refresh_type = 0; + } + SetVROM_1K_Bank(2, data); + break; + + case 0x9003: + SetVROM_1K_Bank(3, data); + break; + case 0x9004: + SetVROM_1K_Bank(4, data); + break; + case 0x9005: + SetVROM_1K_Bank(5, data); + break; + case 0x9006: + SetVROM_1K_Bank(6, data); + break; + case 0x9007: + SetVROM_1K_Bank(7, data); + break; + + case 0xC000: + irq_counter = irq_latch; + irq_enable = irq_latch; + break; + case 0xC001: + irq_latch = data; + break; + case 0xC002: + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC003: + irq_counter = data; + break; + } + } + + //void Mapper160::HSync(INT scanline) + public override void HSync(int scanline) + { + if (scanline == 0 || scanline == 239) + { + switch (refresh_type) + { + case 1: + SetVROM_8K_Bank(0x58, 0x59, 0x5A, 0x5B, 0x58, 0x59, 0x5A, 0x5B); + break; + case 2: + SetVROM_8K_Bank(0x78, 0x79, 0x7A, 0x7B, 0x78, 0x79, 0x7A, 0x7B); + break; + case 3: + SetVROM_8K_Bank(0x7C, 0x7D, 0x7E, 0x7F, 0x7C, 0x7D, 0x7E, 0x7F); + break; + case 5: + SetVROM_8K_Bank(0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77); + break; + case 6: + SetVROM_8K_Bank(0x5C, 0x5D, 0x5E, 0x5F, 0x7C, 0x7D, 0x7E, 0x7F); + break; + } + } + if (scanline == 64) + { + if (refresh_type == 4) + { + if (PPU_MEM_BANK[8][32 * 10 + 16] == 0x0A) + { + SetVROM_1K_Bank(0, 0x68); + SetVROM_1K_Bank(1, 0x69); + SetVROM_1K_Bank(2, 0x6A); + SetVROM_1K_Bank(3, 0x6B); + } + else + { + SetVROM_1K_Bank(0, 0x6C); + SetVROM_1K_Bank(1, 0x6D); + SetVROM_1K_Bank(2, 0x6E); + SetVROM_1K_Bank(3, 0x6F); + } + } + } + if (scanline == 128) + { + if (refresh_type == 4) + { + SetVROM_1K_Bank(0, 0x68); + SetVROM_1K_Bank(1, 0x69); + SetVROM_1K_Bank(2, 0x6A); + SetVROM_1K_Bank(3, 0x6B); + } + else if (refresh_type == 5) + { + SetVROM_8K_Bank(0x74, 0x75, 0x76, 0x77, 0x74, 0x75, 0x76, 0x77); + } + } + if (scanline == 160) + { + if (refresh_type == 6) + { + SetVROM_8K_Bank(0x60, 0x61, 0x5E, 0x5F, 0x7C, 0x7D, 0x7E, 0x7F); + } + } + + if (irq_enable != 0) + { + if (irq_counter == 0xFF) + { + // nes.cpu.IRQ_NotPending(); + irq_enable = 0; + irq_counter = 0; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter++; + } + } + } + + //void Mapper160::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_enable; + p[1] = irq_counter; + p[2] = irq_latch; + p[3] = refresh_type; + } + + // + //void Mapper160::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_enable = p[0]; + irq_counter = p[1]; + irq_latch = p[2]; + refresh_type = p[3]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper160.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper160.cs.meta new file mode 100644 index 0000000..911e3b4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper160.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 37cf6c466c59c7a42a7e1697cfc2ad5c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper162.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper162.cs new file mode 100644 index 0000000..42e5bc7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper162.cs @@ -0,0 +1,132 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper162 Pocket Monster Gold // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class Mapper162 : Mapper + { + BYTE reg5000; + BYTE reg5100; + BYTE reg5200; + BYTE reg5300; + public Mapper162(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg5000 = 0; + reg5100 = 0; + reg5200 = 0; + reg5300 = 7; + SetBank_CPU(); + SetBank_PPU(); + } + + //void Mapper162::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x5000) + { + reg5000 = data; + SetBank_CPU(); + SetBank_PPU(); + } + else if (addr == 0x5100) + { + reg5100 = data; + SetBank_CPU(); + SetBank_PPU(); + } + else if (addr == 0x5200) + { + reg5200 = data; + SetBank_CPU(); + SetBank_PPU(); + } + else if (addr == 0x5300) + { + reg5300 = data; + } + else if (addr >= 0x6000) + { + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + else + { + Debuger.Log($"write to {addr:X4}:{data:X2}"); + } + + } + + void SetBank_CPU() + { + BYTE bank = 0; + switch (reg5300) + { + case 4: + bank = (byte)((((reg5000 & 0xF) + ((reg5100 & 3) >> 1)) | ((reg5200 & 1) << 4))); + break; + case 7: + bank = (byte)(((reg5000 & 0xF) | ((reg5200 & 1) << 4))); + break; + } + SetPROM_32K_Bank((byte)bank); + } + + void SetBank_PPU() + { + SetCRAM_8K_Bank(0); + } + + //void Mapper162::HSync(int scanline) + public override void HSync(int scanline) + { + if ((reg5000 & 0x80) != 0 && nes.ppu.IsDispON()) + { + if (scanline < 127) + { + // SetCRAM_4K_Bank(0, 0); + SetCRAM_4K_Bank(4, 0); + } + else if (scanline < 240) + { + // SetCRAM_4K_Bank(0, 1); + SetCRAM_4K_Bank(4, 1); + } + } + } + + + //void Mapper162::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg5000; + p[1] = reg5100; + p[2] = reg5200; + p[3] = reg5300; + } + + //void Mapper162::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg5000 = p[0]; + reg5100 = p[1]; + reg5200 = p[2]; + reg5300 = p[3]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper162.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper162.cs.meta new file mode 100644 index 0000000..c62cc2a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper162.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2817bc9b8d92a134795cf9f72eff80bb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper163.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper163.cs new file mode 100644 index 0000000..71dfdba --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper163.cs @@ -0,0 +1,239 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper163 NanJing Games // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper163 : Mapper + { + //BYTE strobe; + //BYTE security; + //BYTE trigger; + //BYTE rom_type; + + //BYTE reg[2]; + BYTE laststrobe, trigger; + BYTE[] reg = new byte[8]; + public Mapper163(NES parent) : base(parent) + { + /* + reg[1] = 0xFF; + strobe = 1; + security = trigger = reg[0] = 0x00; + rom_type = 0; + SetPROM_32K_Bank(15); + + DWORD crc = nes.rom.GetPROM_CRC(); + if( crc == 0xb6a10d5d ) { // Hu Lu Jin Gang (NJ039) (Ch) [dump] + SetPROM_32K_Bank(0); + } + if( crc == 0xf52468e7 ) { // San Guo Wu Shuang - Meng Jiang Zhuan (NJ047) (Ch) [dump] + rom_type = 1; + } + */ + + MemoryUtility.ZEROMEMORY(reg, reg.Length); + laststrobe = 1; + SetPROM_32K_Bank((reg[0] << 4) | (reg[1] & 0xF)); + //SetPROM_32K_Bank(0); + SetCRAM_8K_Bank(0); + } + + //BYTE Mapper163::ReadLow(WORD A) + public override byte ReadLow(ushort A) + { + /* + if((addr>=0x5000 && addr<0x6000)) + { + switch (addr & 0x7700) + { + case 0x5100: + return security; + break; + case 0x5500: + if(trigger) + return security; + else + return 0; + break; + } + return 4; + } + else if( addr>=0x6000 ) { + return CPU_MEM_BANK[addr>>13][addr&0x1FFF]; + } + return Mapper::ReadLow( addr ); + */ + if ((A < 0x6000) && (A >= 0x5000)) + { + switch (A & 0x7700) + { + case 0x5100: return (byte)(reg[2] | reg[0] | reg[1] | reg[3] ^ 0xff); break; + case 0x5500: + if (trigger != 0) + return (byte)(reg[2] | reg[1]); // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games + else + return 0; + } + return 4; + } + else + return base.ReadLow(A); + } + + //void Mapper163::WriteLow(WORD A, BYTE V) + public override void WriteLow(ushort A, byte V) + { + /* + if((addr>=0x4020 && addr<0x6000)) + { + DEBUGOUT("W %.4X %.2X\n",addr,data); + if(addr==0x5101){ + if(strobe && !data){ + trigger ^= 1; + // trigger ^= 0xFF; + } + strobe = data; + }else if(addr==0x5100 && data==6){ + SetPROM_32K_Bank(3); + } + else{ + switch (addr & 0x7300) + { + case 0x5000: + reg[1]=data; + SetPROM_32K_Bank( (reg[1] & 0xF) | (reg[0] << 4) ); + if(!(reg[1]&0x80)&&(nes.ppu.GetScanlineNo()<128)) + SetCRAM_8K_Bank(0); + if(rom_type==1) SetCRAM_8K_Bank(0); + break; + case 0x5200: + reg[0]=data; + SetPROM_32K_Bank( (reg[1] & 0xF) | (reg[0] << 4) ); + break; + case 0x5300: + security=data; + break; + } + } + } + else if( addr>=0x6000 ) { + CPU_MEM_BANK[addr>>13][addr&0x1FFF] = data; + } + */ + if ((A < 0x6000) && (A >= 0x5000)) + { + if (A == 0x5300) + { + A = (ushort)(A + 1 - 1); + } + + if (A == 0x5101) + { + if (laststrobe != 0 && V == 0) + { + trigger ^= 1; + } + laststrobe = V; + } + else if (A == 0x5100 && V == 6) //damn thoose protected games + SetPROM_32K_Bank(3); + else + { + switch (A & 0x7300) + { + case 0x5200: reg[0] = V; SetPROM_32K_Bank((reg[0] << 4) | reg[1] & 0xF); SetCRAM_8K_Bank(0); break; + case 0x5000: reg[1] = V; SetPROM_32K_Bank((reg[0] << 4) | reg[1] & 0xF); SetCRAM_8K_Bank(0); if ((reg[1] & 0x80) == 0 && (nes.GetScanline() < 128)) SetCRAM_8K_Bank(0); break; + case 0x5300: reg[2] = V; break; + case 0x5100: reg[3] = V; SetPROM_32K_Bank((reg[0] << 4) | reg[1] & 0xF); SetCRAM_8K_Bank(0); break; + } + } + } + //071 + else if ((A & 0xFF00) == 0x4800) + { + //512KרÓà + if (PROM_8K_SIZE == 64) + { + reg[A & 3] = V; + if (A == 0x4802) + SetPROM_32K_Bank(((reg[1] >> 1) & 3) | (reg[2] << 2)); + } + } + else + base.WriteLow(A, V); + } + + //void Mapper163::HSync(int scanline) + public override void HSync(int scanline) + { + //sline = scanline; + /* + if( (reg[1]&0x80) && nes.ppu.IsDispON() ) { + if(scanline==127){ + SetCRAM_4K_Bank(0, 1); + SetCRAM_4K_Bank(4, 1); + } + if (rom_type==1){ + if(scanline<127){ + SetCRAM_4K_Bank(0, 0); + SetCRAM_4K_Bank(4, 0); + } + }else{ + if(scanline==239){ + SetCRAM_4K_Bank(0, 0); + SetCRAM_4K_Bank(4, 0); + } + } + } + */ + if ((reg[1] & 0x80) != 0) + { + if (scanline == 239) + { + SetCRAM_4K_Bank(0, 0); + SetCRAM_4K_Bank(4, 0); + } + else if (scanline == 127) + { + SetCRAM_4K_Bank(0, 1); + SetCRAM_4K_Bank(4, 1); + } + } + } + + //void Mapper163::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg[0]; + //p[1] = reg[1]; + for (byte i = 0; i < 8; i++) + p[i] = reg[i]; + p[8] = laststrobe; + p[9] = trigger; + } + + //void Mapper163::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + + //reg[0] = p[0]; + //reg[1] = p[1]; + for (byte i = 0; i < 8; i++) + reg[i] = p[i]; + laststrobe = p[8]; + trigger = p[9]; + } + + public override void Reset() + { + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper163.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper163.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper163.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper163.cs.meta index c16f6b7..5da4021 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper163.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper163.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 12f496f2eca79314b9d5bf0da4d6c9dc +guid: 843d6eb1b2987f94ea295eda54522756 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper164.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper164.cs new file mode 100644 index 0000000..2ff24d8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper164.cs @@ -0,0 +1,167 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper164 Pocket Monster Gold // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class Mapper164 : Mapper + { + BYTE reg5000; + BYTE reg5100; + BYTE a3, p_mode; + public Mapper164(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg5000 = 0; + reg5100 = 0; + SetBank_CPU(); + SetBank_PPU(); + nes.ppu.SetExtLatchMode(true); + } + + //void Mapper164::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x5000) + { + p_mode = (byte)(data >> 7); + reg5000 = data; + SetBank_CPU(); + SetBank_PPU(); + } + else if (addr == 0x5100) + { + reg5100 = data; + SetBank_CPU(); + SetBank_PPU(); + } + else if (addr >= 0x6000) + { + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + else + { + Debuger.Log($"write to {addr:X4}:{data:X2}"); + } + + } + + + void SetBank_CPU() + { + int mode, @base, bank; + + @base = (reg5100 & 1) << 5; + mode = (reg5000 >> 4) & 0x07; + + switch (mode) + { + case 0: + case 2: + case 4: + case 6: /* NORMAL MODE */ + bank = (reg5000 & 0x0f); + bank += (reg5000 & 0x20) >> 1; + SetPROM_16K_Bank(4, bank + @base); + SetPROM_16K_Bank(6, @base + 0x1f); + Debuger.Log($"-- normal mode: mode={mode}, bank={bank} --"); + break; + case 1: + case 3: /* REG MODE */ + Debuger.Log("-- reg mode --"); + break; + case 5: /* 32K MODE */ + bank = (reg5000 & 0x0f); + SetPROM_32K_Bank(bank + (@base >> 1)); + // DEBUGOUT("-- 32K MODE: bank=%02x --\n", bank); + break; + case 7: /* HALF MODE */ + bank = (reg5000 & 0x0f); + bank += (bank & 0x08) << 1; + SetPROM_16K_Bank(4, bank + @base); + bank = (bank & 0x10) + 0x0f; + SetPROM_16K_Bank(6, @base + 0x1f); + Debuger.Log("-- half mode --"); + break; + default: + break; + }; + + } + + void SetBank_PPU() + { + SetCRAM_8K_Bank(0); + } + + + //void Mapper164::PPU_ExtLatchX(INT x) + public override void PPU_ExtLatchX(int x) + { + a3 = (byte)((x & 1) << 3); + } + + //void Mapper164::PPU_ExtLatch(WORD ntbladr, BYTE& chr_l, BYTE& chr_h, BYTE& attr ) + public override void PPU_ExtLatch(ushort ntbladr, ref byte chr_l, ref byte chr_h, ref byte attr) + { + INT loopy_v = nes.ppu.GetPPUADDR(); + INT loopy_y = nes.ppu.GetTILEY(); + INT tileofs = (PPUREG[0] & PPU.PPU_BGTBL_BIT) << 8; + INT attradr = 0x23C0 + (loopy_v & 0x0C00) + ((loopy_v & 0x0380) >> 4); + INT attrsft = (ntbladr & 0x0040) >> 4; + Span pNTBL = PPU_MEM_BANK[ntbladr >> 10]; + + INT ntbl_x = ntbladr & 0x001F; + INT tileadr; + + attradr &= 0x3FF; + attr = (byte)(((pNTBL[attradr + (ntbl_x >> 2)] >> ((ntbl_x & 2) + attrsft)) & 3) << 2); + tileadr = tileofs + pNTBL[ntbladr & 0x03FF] * 0x10 + loopy_y; + + if (p_mode != 0) + { + tileadr = (tileadr & 0xfff7) | a3; + chr_l = chr_h = PPU_MEM_BANK[tileadr >> 10][tileadr & 0x03FF]; + } + else + { + chr_l = PPU_MEM_BANK[tileadr >> 10][tileadr & 0x03FF]; + chr_h = PPU_MEM_BANK[tileadr >> 10][(tileadr & 0x03FF) + 8]; + } + + } + + //void Mapper164::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg5000; + p[1] = reg5100; + p[2] = a3; + p[3] = p_mode; + } + + //void Mapper164::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg5000 = p[0]; + reg5100 = p[1]; + a3 = p[2]; + p_mode = p[3]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper164.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper164.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper164.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper164.cs.meta index ccbd059..576564d 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper164.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper164.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: da6f9ced886f85647927cc4e20e053ce +guid: 5e78f3a9cb5d7dd41a19b35004ec7e56 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs new file mode 100644 index 0000000..cfc8284 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs @@ -0,0 +1,197 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper165 Fire Emblem Chinese version // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper165 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr0, chr1, chr2, chr3; + BYTE we_sram; + BYTE latch; + public Mapper165(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr0 = 0; + chr1 = 0; + chr2 = 4; + chr3 = 4; + latch = 0xFD; + SetBank_PPU(); + + we_sram = 0; // Disable + + nes.ppu.SetChrLatchMode(true); + } + + //void Mapper165::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr0 = (byte)(data & 0xFC); + if (latch == 0xFD) + SetBank_PPU(); + break; + case 0x01: + chr1 = (byte)(data & 0xFC); + if (latch == 0xFE) + SetBank_PPU(); + break; + + case 0x02: + chr2 = (byte)(data & 0xFC); + if (latch == 0xFD) + SetBank_PPU(); + break; + case 0x04: + chr3 = (byte)(data & 0xFC); + if (latch == 0xFE) + SetBank_PPU(); + break; + + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if ((data & 0x01)!= 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + default: + break; + } + + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + void SetBank_PPU() + { + if (latch == 0xFD) + { + SetBank_PPUSUB(0, chr0); + SetBank_PPUSUB(4, chr2); + } + else + { + SetBank_PPUSUB(0, chr1); + SetBank_PPUSUB(4, chr3); + } + } + + void SetBank_PPUSUB(int bank, int page) + { + if (page == 0) + { + SetCRAM_4K_Bank((byte)bank, page >> 2); + } + else + { + SetVROM_4K_Bank((byte)bank, page >> 2); + } + } + + //void Mapper165::PPU_ChrLatch(WORD addr) + public override void PPU_ChrLatch(ushort addr) + { + ushort mask = (ushort)(addr & 0x1FF0); + + if (mask == 0x1FD0) + { + latch = 0xFD; + SetBank_PPU(); + } + else if (mask == 0x1FE0) + { + latch = 0xFE; + SetBank_PPU(); + } + + } + + //void Mapper165::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr0; + p[11] = chr1; + p[12] = chr2; + p[13] = chr3; + p[14] = latch; + } + + //void Mapper165::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr0 = p[10]; + chr1 = p[11]; + chr2 = p[12]; + chr3 = p[13]; + latch = p[14]; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper165.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper165.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta index ea827a5..371fc1b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper165.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 01df600d7fe9ad7419fea7c8fd3e3eb1 +guid: bbfe308ca0a341f439b9c6772903cde4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs new file mode 100644 index 0000000..90ef150 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs @@ -0,0 +1,137 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper004 Supor Computer V4.0 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper167 : Mapper + { + BYTE[] regs = new byte[4]; + BYTE rom_type; + public Mapper167(NES parent) : base(parent) + { + } + + public override void Reset() + { + uint crc; + + regs[0] = 0; + regs[1] = 0; + regs[2] = 0; + regs[3] = 0; + + crc = nes.rom.GetPROM_CRC(); + if (crc == 0x82F1Fb96) + { + // Subor Computer(Russia) + rom_type = 1; + } + else + { + // Subor Computer(Chinese) + rom_type = 0; + } + + SetBank_CPU(); + SetBank_PPU(); + } + + //void Mapper167::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + int idx; + + idx = (addr >> 13) & 0x03; + regs[idx] = data; + SetBank_CPU(); + SetBank_PPU(); + // DEBUGOUT("write to %04x:%02x\n", addr, data); + } + + + void SetBank_CPU() + { + int @base, bank; + + @base = ((regs[0] ^ regs[1]) & 0x10) << 1; + bank = (regs[2] ^ regs[3]) & 0x1f; + + if ((regs[1] & 0x08) != 0) + { + bank &= 0xfe; + if (rom_type == 0) + { + SetPROM_16K_Bank(4, @base + bank + 1); + SetPROM_16K_Bank(6, @base + bank + 0); + } + else + { + SetPROM_16K_Bank(6, @base + bank + 1); + SetPROM_16K_Bank(4, @base + bank + 0); + } + // DEBUGOUT("32K MODE!\n"); + } + else + { + if ((regs[1] & 0x04) != 0) + { + SetPROM_16K_Bank(4, 0x1f); + SetPROM_16K_Bank(6, @base + bank); + // DEBUGOUT("HIGH 16K MODE!\n"); + } + else + { + SetPROM_16K_Bank(4, @base + bank); + if (rom_type == 0) + { + SetPROM_16K_Bank(6, 0x20); + } + else + { + SetPROM_16K_Bank(6, 0x07); + } + // DEBUGOUT("LOW 16K MODE!\n"); + } + } + + + } + + void SetBank_PPU() + { + SetCRAM_8K_Bank(0); + } + + //void Mapper167::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = regs[0]; + p[1] = regs[1]; + p[2] = regs[2]; + p[3] = regs[3]; + p[4] = rom_type; + } + + //void Mapper167::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + regs[0] = p[0]; + regs[1] = p[1]; + regs[2] = p[2]; + regs[3] = p[3]; + rom_type = p[4]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta new file mode 100644 index 0000000..bf96ff8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cd018661871c8d34ab9fd790666e5b75 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper175.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper175.cs new file mode 100644 index 0000000..03b598f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper175.cs @@ -0,0 +1,71 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper175 15-in-1 (Kaiser) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper175 : Mapper + { + BYTE reg_dat; + public Mapper175(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_16K_Bank(4, 0); + SetPROM_16K_Bank(6, 0); + reg_dat = 0; + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper175::Read(WORD addr, BYTE data) + public override void Read(ushort addr, byte data) + { + if (addr == 0xFFFC) + { + SetPROM_16K_Bank(4, reg_dat & 0x0F); + SetPROM_8K_Bank(6, (reg_dat & 0x0F) * 2); + } + } + + //void Mapper175::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + if ((data & 0x04) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA000: + reg_dat = data; + SetPROM_8K_Bank(7, (reg_dat & 0x0F) * 2 + 1); + SetVROM_8K_Bank(reg_dat & 0x0F); + break; + } + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper175.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper175.cs.meta new file mode 100644 index 0000000..fb2ed5f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper175.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 68d93abdcd8d7774ababf7b66976ee49 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper176.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper176.cs new file mode 100644 index 0000000..758f058 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper176.cs @@ -0,0 +1,58 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; +using System.Runtime.ConstrainedExecution; + +namespace VirtualNes.Core +{ + public class Mapper176 : Mapper + { + BYTE prg, chr; + public Mapper176(NES parent) : base(parent) + { + } + + public override void Reset() + { + //prg = ~0; + prg = unchecked((byte)(~0)); + chr = 0; + Sync(); + } + + void Sync() + { + //setprg8r(0x10,0x6000,0); + SetPROM_32K_Bank(prg >> 1); + SetVROM_8K_Bank(chr); + } + + //void Mapper176::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x5ff1: + prg = data; Sync(); + break; + case 0x5ff2: + chr = data; Sync(); + break; + default: + break; + } + if (addr >= 0x6000) + { + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper176.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper176.cs.meta new file mode 100644 index 0000000..1ef5f1b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper176.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9551cda80f1ab24993914b62a660fac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper178.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper178.cs new file mode 100644 index 0000000..0cceccb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper178.cs @@ -0,0 +1,72 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper178 : Mapper + { + BYTE[] reg = new byte[3]; + BYTE banknum; + public Mapper178(NES parent) : base(parent) + { + } + + public override void Reset() + { + reg[0] = 0; + reg[1] = 0; + reg[2] = 0; + banknum = 0; + SetBank_CPU(); + } + + //void Mapper178::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x4800) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + else if (addr == 0x4801) + { + reg[0] = (byte)((data >> 1) & 0x0f); + SetBank_CPU(); + } + else if (addr == 0x4802) + { + reg[1] = (byte)((data << 2) & 0x0f); + // SetBank_CPU(); + } + else if (addr == 0x4803) + { + //unknown + } + else if (addr >= 0x6000) + { + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + } + + //void Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + // SetPROM_32K_Bank( data ); + } + + void SetBank_CPU() + { + banknum = (byte)((reg[0] + reg[1]) & 0x0f); + SetPROM_32K_Bank(banknum); + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper178.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper178.cs.meta new file mode 100644 index 0000000..ec45d92 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper178.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d281debb02f40d648b6b2d7355eec34b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs new file mode 100644 index 0000000..f6ffc29 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs @@ -0,0 +1,37 @@ +////////////////////////////////////////////// +// Mapper180 Nichibutsu // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper180 : Mapper + { + public Mapper180(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper180::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_16K_Bank(6, data & 0x07); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper180.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper180.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta index 9f1fc09..84cf64b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper180.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1ffae0c30d3a5dd48af658c47bc53a38 +guid: 0690d23936f8e3a42ad2ea112dbfb3f2 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs new file mode 100644 index 0000000..b39ae4d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////// +// Mapper181 Hacker International Type2 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper181 : Mapper + { + public Mapper181(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper181::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + //DEBUGOUT( "$%04X:$%02X\n", addr, data ); + if (addr == 0x4120) + { + SetPROM_32K_Bank((data & 0x08) >> 3); + SetVROM_8K_Bank(data & 0x07); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta new file mode 100644 index 0000000..01d975a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 62cd0f9e43adec242bc4f1ff7f2cae4f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs new file mode 100644 index 0000000..9cddc37 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs @@ -0,0 +1,123 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper182 PC-SuperDonkeyKong // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper182 : Mapper + { + BYTE reg; + BYTE irq_enable; + BYTE irq_counter; + public Mapper182(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + + reg = 0; + irq_enable = 0; + irq_counter = 0; + } + + //void Mapper182::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF003) + { + case 0x8001: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xA000: + reg = (byte)(data & 0x07); + break; + case 0xC000: + switch (reg) + { + case 0: + SetVROM_1K_Bank(0, (data & 0xFE) + 0); + SetVROM_1K_Bank(1, (data & 0xFE) + 1); + break; + case 1: + SetVROM_1K_Bank(5, data); + break; + case 2: + SetVROM_1K_Bank(2, (data & 0xFE) + 0); + SetVROM_1K_Bank(3, (data & 0xFE) + 1); + break; + case 3: + SetVROM_1K_Bank(7, data); + break; + case 4: + SetPROM_8K_Bank(4, data); + break; + case 5: + SetPROM_8K_Bank(5, data); + break; + case 6: + SetVROM_1K_Bank(4, data); + break; + case 7: + SetVROM_1K_Bank(6, data); + break; + } + break; + case 0xE003: + irq_enable = data; + irq_counter = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper182::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if ((--irq_counter) == 0) + { + irq_enable = 0; + irq_counter = 0; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + //void Mapper182::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + p[1] = irq_enable; + p[2] = irq_counter; + } + + //void Mapper182::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + irq_enable = p[1]; + irq_counter = p[2]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper182.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper182.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta index 55001c4..c78ed0c 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper182.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: db03437852d4eb942a0ea6a97e2169bf +guid: 5b5348cd0dcfc7949b576b96ee04dee9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs new file mode 100644 index 0000000..8d60d8d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs @@ -0,0 +1,197 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper183 Gimmick (Bootleg) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper183 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE irq_enable; + INT irq_counter; + public Mapper183(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + irq_enable = 0; + irq_counter = 0; + } + + //void Mapper183::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8800: + SetPROM_8K_Bank(4, data); + break; + case 0xA800: + SetPROM_8K_Bank(5, data); + break; + case 0xA000: + SetPROM_8K_Bank(6, data); + break; + + case 0xB000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB004: + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB008: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + case 0xB00C: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC004: + reg[2] = (byte)((reg[2] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC008: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + case 0xC00C: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD004: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD008: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + case 0xD00C: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE004: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE008: + reg[7] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + case 0xE00C: + reg[7] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0x9008: + if (data == 1) + { + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + } + break; + + case 0x9800: + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else if (data == 3) SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0xF000: + irq_counter = (irq_counter & 0xFF00) | data; + break; + case 0xF004: + irq_counter = (irq_counter & 0x00FF) | (data << 8); + break; + case 0xF008: + irq_enable = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper183::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((irq_enable & 0x02) != 0) + { + if (irq_counter <= 113) + { + irq_counter = 0; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter -= 113; + } + } + } + + //void Mapper183::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // p[i] = reg[i]; + //} + //p[8] = irq_enable; + //*((INT*)&p[9]) = irq_counter; + } + + //void Mapper183::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + // for (INT i = 0; i < 8; i++) + // { + // reg[i] = p[i]; + // } + // irq_enable = p[8]; + // irq_counter = *((INT*)&p[9]); + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta new file mode 100644 index 0000000..8f1e604 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a30c259cae622e40a3ffe2da26883c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs new file mode 100644 index 0000000..db8eef4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs @@ -0,0 +1,68 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper185 Character disable protect // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper185 : Mapper + { + BYTE patch; + public Mapper185(NES parent) : base(parent) + { + } + + public override void Reset() + + { + switch (PROM_16K_SIZE) + { + case 1: // 16K only + SetPROM_16K_Bank(4, 0); + SetPROM_16K_Bank(6, 0); + break; + case 2: // 32K + SetPROM_32K_Bank(0); + break; + } + + for (INT i = 0; i < 0x400; i++) + { + VRAM[0x800 + i] = 0xFF; + } + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0xb36457c7) + { // Spy vs Spy(J) + patch = 1; + } + } + + //void Mapper185::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (((patch == 0) && ((data & 0x03) != 0)) || ((patch != 0) && data == 0x21)) + { + SetVROM_8K_Bank(0); + } + else + { + SetVRAM_1K_Bank(0, 2); // use vram bank 2 + SetVRAM_1K_Bank(1, 2); + SetVRAM_1K_Bank(2, 2); + SetVRAM_1K_Bank(3, 2); + SetVRAM_1K_Bank(4, 2); + SetVRAM_1K_Bank(5, 2); + SetVRAM_1K_Bank(6, 2); + SetVRAM_1K_Bank(7, 2); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper185.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper185.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta index cd6b448..c32aa01 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper185.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8c3aabf4c02e11a4988508a35f600696 +guid: 5172897463091b440aa762737b586b67 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs new file mode 100644 index 0000000..58bfe37 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs @@ -0,0 +1,371 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper187 Street Fighter Zero 2 97 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper187 : Mapper + { + + BYTE[] prg = new byte[4]; + INT[] chr = new int[8]; + BYTE[] bank = new byte[8]; + + BYTE ext_mode; + BYTE chr_mode; + BYTE ext_enable; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_occur; + BYTE last_write; + public Mapper187(NES parent) : base(parent) + { + } + + public override void Reset() + + { + INT i; + + for (i = 0; i < 8; i++) + { + chr[i] = 0x00; + bank[i] = 0x00; + } + + prg[0] = (byte)(PROM_8K_SIZE - 4); + prg[1] = (byte)(PROM_8K_SIZE - 3); + prg[2] = (byte)(PROM_8K_SIZE - 2); + prg[3] = (byte)(PROM_8K_SIZE - 1); + SetBank_CPU(); + + ext_mode = 0; + chr_mode = 0; + ext_enable = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + + last_write = 0; + + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + + //BYTE Mapper187::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + switch (last_write & 0x03) + { + case 0: + return 0x83; + case 1: + return 0x83; + case 2: + return 0x42; + case 3: + return 0x00; + } + return 0; + } + + //void Mapper187::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + last_write = data; + if (addr == 0x5000) + { + ext_mode = data; + if ((data & 0x80) != 0) + { + if ((data & 0x20) != 0) + { + prg[0] = (byte)(((data & 0x1E) << 1) + 0); + prg[1] = (byte)(((data & 0x1E) << 1) + 1); + prg[2] = (byte)(((data & 0x1E) << 1) + 2); + prg[3] = (byte)(((data & 0x1E) << 1) + 3); + } + else + { + prg[2] = (byte)(((data & 0x1F) << 1) + 0); + prg[3] = (byte)(((data & 0x1F) << 1) + 1); + } + } + else + { + prg[0] = bank[6]; + prg[1] = bank[7]; + prg[2] = (byte)(PROM_8K_SIZE - 2); + prg[3] = (byte)(PROM_8K_SIZE - 1); + } + SetBank_CPU(); + } + } + + //void Mapper187::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + last_write = data; + switch (addr) + { + case 0x8003: + ext_enable = 0xFF; + // if( (data&0x80) != (chr_mode&0x80) ) { + // for( INT i = 0; i < 4; i++ ) { + // INT temp = chr[i]; + // chr[i] = chr[i+4]; + // chr[i+4] = temp; + // } + // SetBank_PPU(); + // } + chr_mode = data; + if ((data & 0xF0) == 0) + { + prg[2] = (byte)(PROM_8K_SIZE - 2); + SetBank_CPU(); + } + break; + + case 0x8000: + ext_enable = 0; + // if( (data&0x80) != (chr_mode&0x80) ) { + // for( INT i = 0; i < 4; i++ ) { + // INT temp = chr[i]; + // chr[i] = chr[i+4]; + // chr[i+4] = temp; + // } + // SetBank_PPU(); + // } + chr_mode = data; + break; + + case 0x8001: + if (ext_enable == 0) + { + switch (chr_mode & 7) + { + case 0: + data &= 0xFE; + chr[4] = (INT)data + 0x100; + chr[5] = (INT)data + 0x100 + 1; + // chr[0+((chr_mode&0x80)?4:0)] = data; + // chr[1+((chr_mode&0x80)?4:0)] = data+1; + SetBank_PPU(); + break; + case 1: + data &= 0xFE; + chr[6] = (INT)data + 0x100; + chr[7] = (INT)data + 0x100 + 1; + // chr[2+((chr_mode&0x80)?4:0)] = data; + // chr[3+((chr_mode&0x80)?4:0)] = data+1; + SetBank_PPU(); + break; + case 2: + chr[0] = data; + // chr[0+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 3: + chr[1] = data; + // chr[1+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 4: + chr[2] = data; + // chr[2+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 5: + chr[3] = data; + // chr[3+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 6: + if ((ext_mode & 0xA0) != 0xA0) + { + prg[0] = data; + SetBank_CPU(); + } + break; + case 7: + if ((ext_mode & 0xA0) != 0xA0) + { + prg[1] = data; + SetBank_CPU(); + } + break; + default: + break; + } + } + else + { + switch (chr_mode) + { + case 0x2A: + prg[1] = 0x0F; + break; + case 0x28: + prg[2] = 0x17; + break; + case 0x26: + break; + default: + break; + } + SetBank_CPU(); + } + bank[chr_mode & 7] = data; + break; + + case 0xA000: + if ((data & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + break; + + case 0xC000: + irq_counter = data; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC001: + irq_latch = data; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE000: + case 0xE002: + irq_enable = 0; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + case 0xE003: + irq_enable = 1; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper187::Clock(INT cycles) + public override void Clock(int cycles) + { + // if( irq_occur ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + // void Mapper187::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if (irq_counter == 0) + { + irq_counter--; + irq_enable = 0; + irq_occur = 0xFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter--; + } + } + } + } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg[0], prg[1], prg[2], prg[3]); + } + + void SetBank_PPU() + { + SetVROM_8K_Bank(chr[0], chr[1], chr[2], chr[3], + chr[4], chr[5], chr[6], chr[7]); + } + + //void Mapper187::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //INT i; + + //for (i = 0; i < 4; i++) + //{ + // p[i] = prg[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // p[4 + i] = bank[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // *((INT*)&p[12 + i * sizeof(INT)]) = chr[i]; + //} + + //p[44] = ext_mode; + //p[45] = chr_mode; + //p[46] = ext_enable; + //p[47] = irq_enable; + //p[48] = irq_counter; + //p[49] = irq_latch; + //p[50] = irq_occur; + //p[51] = last_write; + } + + //void Mapper187::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //INT i; + + //for (i = 0; i < 4; i++) + //{ + // prg[i] = p[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // bank[i] = p[4 + i]; + //} + //for (i = 0; i < 8; i++) + //{ + // chr[i] = *((INT*)&p[12 + i * sizeof(INT)]); + //} + //ext_mode = p[44]; + //chr_mode = p[45]; + //ext_enable = p[46]; + //irq_enable = p[47]; + //irq_counter = p[48]; + //irq_latch = p[49]; + //irq_occur = p[50]; + //last_write = p[51]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta new file mode 100644 index 0000000..24c87de --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: defdc0bc39e45624b958e7d2d3a40430 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs new file mode 100644 index 0000000..347e454 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper188 Bandai Karaoke Studio // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper188 : Mapper + { + public Mapper188(NES parent) : base(parent) + { + } + public override void Reset() + { + if (PROM_8K_SIZE > 16) + { + SetPROM_32K_Bank(0, 1, 14, 15); + } + else + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + //void Mapper188::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (data != 0) + { + if ((data & 0x10) != 0) + { + data &= 0x07; + SetPROM_16K_Bank(4, data); + } + else + { + SetPROM_16K_Bank(4, data + 8); + } + } + else + { + if (PROM_8K_SIZE == 0x10) + { + SetPROM_16K_Bank(4, 7); + } + else + { + SetPROM_16K_Bank(4, 8); + } + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta new file mode 100644 index 0000000..44ff8b7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30eeef1e68b38eb42b07dcb03d6f5e00 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs new file mode 100644 index 0000000..e07c677 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs @@ -0,0 +1,320 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper189 Street Fighter 2/Yoko version // +// 快打傅説 Street Fighter IV (GOUDER) // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper189 : Mapper + { + BYTE patch; + + BYTE[] reg = new BYTE[2]; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + + // SF4 + BYTE[] protect_dat = new byte[4]; + BYTE lwd; + public Mapper189(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(PROM_8K_SIZE - 4, PROM_8K_SIZE - 3, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + reg[0] = reg[1] = 0; + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + + for (INT i = 0; i < 4; i++) + { + protect_dat[i] = 0; + } + lwd = 0xFF; + + patch = 0; + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0x20ca2ad3) + { // Street Fighter IV (GOUDER) + patch = 1; + SetPROM_32K_Bank(0); + + // $4000-$5FFF + SetPROM_Bank(2, XRAM, BANKTYPE_ROM); + } + } + + //void Mapper189::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xFF00) == 0x4100) + { + // Street Fighter 2 YOKO + SetPROM_32K_Bank((data & 0x30) >> 4); + } + else if ((addr & 0xFF00) == 0x6100) + { + // Master Fighter 2 + SetPROM_32K_Bank(data & 0x03); + } + + if (patch != 0) + { + // Street Fighter IV (GOUDER) + BYTE[] a5000xordat = new byte[256]{ + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, + 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, + 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + if ((addr >= 0x4800) && (addr <= 0x4FFF)) + { + SetPROM_32K_Bank(((data & 0x10) >> 3) + (data & 0x1)); + + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x20) != 0) + SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + } + if ((addr >= 0x5000) && (addr <= 0x57FF)) + { + lwd = data; + } + if ((addr >= 0x5800) && (addr <= 0x5FFF)) + { + // XRAM[0x1000+(addr & 3)] = + // $5800 "JMP $xxxx" write + XRAM[0x1800 + (addr & 3)] = + protect_dat[addr & 3] = (byte)(data ^ a5000xordat[lwd]); + } + } + } + + //void Mapper189::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_PPU(); + break; + + case 0x8001: + reg[1] = data; + SetBank_PPU(); + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + } + break; + + case 0xA000: + if ((data & 0x01) != 0) + SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + + case 0xC000: + irq_counter = data; + break; + case 0xC001: + irq_latch = data; + break; + case 0xE000: + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + irq_enable = 0xFF; + break; + } + } + + //void Mapper189::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((--irq_counter) == 0) + { + // if( !(irq_counter--) ) { + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_PPU() + { + if (patch != 0) + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + else + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(0, chr4 & 0x07); + SetCRAM_1K_Bank(1, chr5 & 0x07); + SetCRAM_1K_Bank(2, chr6 & 0x07); + SetCRAM_1K_Bank(3, chr7 & 0x07); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(4, chr4 & 0x07); + SetCRAM_1K_Bank(5, chr5 & 0x07); + SetCRAM_1K_Bank(6, chr6 & 0x07); + SetCRAM_1K_Bank(7, chr7 & 0x07); + } + } + } + } + + //void Mapper189::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = chr01; + p[3] = chr23; + p[4] = chr4; + p[5] = chr5; + p[6] = chr6; + p[7] = chr7; + p[8] = irq_enable; + p[9] = irq_counter; + p[10] = irq_latch; + + p[16] = protect_dat[0]; + p[17] = protect_dat[1]; + p[18] = protect_dat[2]; + p[19] = protect_dat[3]; + p[20] = lwd; + } + + //void Mapper189::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + chr01 = p[2]; + chr23 = p[3]; + chr4 = p[4]; + chr5 = p[5]; + chr6 = p[6]; + chr7 = p[7]; + + irq_enable = p[8]; + irq_counter = p[9]; + irq_latch = p[10]; + + protect_dat[0] = p[16]; + protect_dat[1] = p[17]; + protect_dat[2] = p[18]; + protect_dat[3] = p[19]; + lwd = p[20]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper189.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper189.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta index 9b37abb..e131e1e 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper189.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 16049f0fed2d5614188f842c620127a9 +guid: 6cbb30a02157e92478f51fb4b8ec13e2 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs new file mode 100644 index 0000000..3e65a5b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs @@ -0,0 +1,317 @@ +////////////////////////////////////////////////////////////// +// Mapper190 Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper190 : Mapper + { + BYTE cbase; /* PowerOn OR RESET : cbase=0 */ + BYTE mp190_lcchk; /* PowerOn OR RESET */ + BYTE mp190_lcmd; + BYTE mp190_cmd; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE lowoutdata; + public Mapper190(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + // DWORD crc = nes.rom.GetPROM_CRC(); + // if( crc == 0x6F3D187A ) { + // Temp_Buf=0; //Kof96 + // } else { + // Temp_Buf=1; //ST97 + // } + + irq_enable = 0; + irq_counter = 0; + cbase = 0; /* PowerOn OR RESET : cbase=0 */ + mp190_lcchk = 0; /* PowerOn OR RESET */ + mp190_lcmd = 1; + } + + //void Mapper190::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + /* For Initial Copy Protect check (KOF'96) */ + if (addr == 0x5000) + { + mp190_lcmd = data; + switch (data) + { + case 0xE0: + SetPROM_32K_Bank(0); + break; + case 0xEE: + SetPROM_32K_Bank(3); + break; + } + } + if ((addr == 0x5001) && (mp190_lcmd == 0x00)) + { + SetPROM_32K_Bank(7); + } + if (addr == 0x5080) + { + switch (data) + { + case 0x1: lowoutdata = 0x83; break; + case 0x2: lowoutdata = 0x42; break; + case 0x3: lowoutdata = 0x00; break; + } + } + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + + //BYTE Mapper190::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + switch (addr) + { + case 0x5000: + return lowoutdata; + default: + return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + } + + //void Mapper190::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE003) + { + case 0x8000: + mp190_cmd = data; + if ((mp190_cmd & 0x80) != 0) + cbase = 1; + else + cbase = 0; + break; + case 0x8003: /* for Street Fighter Zero 2 '97 */ + mp190_lcchk = data; + switch (data) + { + case 0x28: + SetPROM_8K_Bank(4, 0x1F); + SetPROM_8K_Bank(5, 0x1F); + SetPROM_8K_Bank(6, 0x17); + SetPROM_8K_Bank(7, 0x1F); + break; + case 0x2A: + SetPROM_8K_Bank(4, 0x1F); + SetPROM_8K_Bank(5, 0x0F); + SetPROM_8K_Bank(6, 0x17); + SetPROM_8K_Bank(7, 0x1F); + break; + case 0x06: + SetPROM_8K_Bank(4, 0x1E); + SetPROM_8K_Bank(5, 0x1F); + SetPROM_8K_Bank(6, 0x1F); + SetPROM_8K_Bank(7, 0x1F); + break; + } + break; + case 0x8001: + if ((mp190_lcchk == 0x6) || (mp190_lcmd == 0x0)) + { + switch (mp190_cmd & 0x07) + { + case 0: + if (cbase == 0) + { + SetVROM_1K_Bank(0, data + 0x100); + SetVROM_1K_Bank(1, data + 0x101); + } + else + { + SetVROM_1K_Bank(4, data + 0x100); + SetVROM_1K_Bank(5, data + 0x101); + } + break; + case 1: + if (cbase == 0) + { + SetVROM_1K_Bank(2, data + 0x100); + SetVROM_1K_Bank(3, data + 0x101); + } + else + { + SetVROM_1K_Bank(6, data + 0x100); + SetVROM_1K_Bank(7, data + 0x101); + } + break; + case 2: + if (cbase == 0) + { + SetVROM_1K_Bank(4, data); + } + else + { + SetVROM_1K_Bank(0, data); + } + break; + case 3: + if (cbase == 0) + { + SetVROM_1K_Bank(5, data); + } + else + { + SetVROM_1K_Bank(1, data); + } + break; + case 4: + if (cbase == 0) + { + SetVROM_1K_Bank(6, data); + } + else + { + SetVROM_1K_Bank(2, data); + } + break; + case 5: + if (cbase == 0) + { + SetVROM_1K_Bank(7, data); + } + else + { + SetVROM_1K_Bank(3, data); + } + break; + case 6: + data = (byte)(data & ((PROM_8K_SIZE * 2) - 1)); + if ((mp190_lcmd & 0x40) != 0) + { + SetPROM_8K_Bank(6, data); + SetPROM_8K_Bank(4, (PROM_8K_SIZE - 1) * 2); + } + else + { + SetPROM_8K_Bank(4, data); + SetPROM_8K_Bank(6, (PROM_8K_SIZE - 1) * 2); + } + break; + case 7: + data = (byte)(data & ((PROM_8K_SIZE * 2) - 1)); + if ((mp190_lcmd & 0x40) != 0) + { + SetPROM_8K_Bank(5, data); + SetPROM_8K_Bank(4, (PROM_8K_SIZE - 1) * 2); + } + else + { + SetPROM_8K_Bank(5, data); + SetPROM_8K_Bank(6, (PROM_8K_SIZE - 1) * 2); + } + break; + } + } + break; + case 0xA000: + if ((data & 0x1) == 0x1) + SetVRAM_Mirror(VRAM_HMIRROR); + else + SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xA001: + break; + case 0xC000: + irq_counter = (byte)(data - 1); + break; + case 0xC001: + irq_latch = (byte)(data - 1); + break; + case 0xC002: + irq_counter = data; + break; + case 0xC003: + irq_latch = data; + break; + case 0xE000: + irq_counter = irq_latch; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + irq_enable = 1; + break; + case 0xE002: + irq_counter = irq_latch; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE003: + irq_enable = 1; + irq_counter = irq_counter; + break; + } + } + + //void Mapper190::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((irq_counter--) == 0) + { + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + //void Mapper190::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_enable; + p[1] = irq_counter; + p[2] = irq_latch; + + p[3] = cbase; + p[4] = mp190_lcchk; + p[5] = mp190_lcmd; + p[6] = mp190_cmd; + p[7] = lowoutdata; + } + + //void Mapper190::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_enable = p[0]; + irq_counter = p[1]; + irq_latch = p[2]; + + cbase = p[3]; + mp190_lcchk = p[4]; + mp190_lcmd = p[5]; + mp190_cmd = p[6]; + lowoutdata = p[7]; + } + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta new file mode 100644 index 0000000..55dcc61 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1bdbb26f8b8de51448a9703b2a9b5884 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs new file mode 100644 index 0000000..8c5fd50 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs @@ -0,0 +1,138 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper191 SACHEN Super Cartridge Xin1 (Ver.1-9) // +// SACHEN Q-BOY Support // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper191 : Mapper + { + BYTE[] reg = new BYTE[8]; + BYTE prg0, prg1; + BYTE chr0, chr1, chr2, chr3; + BYTE highbank; + public Mapper191(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + // prg1 = 1; + SetBank_CPU(); + + chr0 = 0; + chr1 = 0; + chr2 = 0; + chr3 = 0; + highbank = 0; + SetBank_PPU(); + } + + //void Mapper191::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x4100: + reg[0] = data; + break; + case 0x4101: + reg[1] = data; + switch (reg[0]) + { + case 0: + chr0 = (byte)(data & 7); + SetBank_PPU(); + break; + case 1: + chr1 = (byte)(data & 7); + SetBank_PPU(); + break; + case 2: + chr2 = (byte)(data & 7); + SetBank_PPU(); + break; + case 3: + chr3 = (byte)(data & 7); + SetBank_PPU(); + break; + case 4: + highbank = (byte)(data & 7); + SetBank_PPU(); + break; + case 5: + prg0 = (byte)(data & 7); + SetBank_CPU(); + break; + case 7: + if ((data & 0x02) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + } + break; + } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0); + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(0, (((highbank << 3) + chr0) << 2) + 0); + SetVROM_1K_Bank(1, (((highbank << 3) + chr0) << 2) + 1); + SetVROM_1K_Bank(2, (((highbank << 3) + chr1) << 2) + 2); + SetVROM_1K_Bank(3, (((highbank << 3) + chr1) << 2) + 3); + SetVROM_1K_Bank(4, (((highbank << 3) + chr2) << 2) + 0); + SetVROM_1K_Bank(5, (((highbank << 3) + chr2) << 2) + 1); + SetVROM_1K_Bank(6, (((highbank << 3) + chr3) << 2) + 2); + SetVROM_1K_Bank(7, (((highbank << 3) + chr3) << 2) + 3); + } + } + + public override bool IsStateSave() + { + return true; + } + + + + //void Mapper191::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = prg0; + p[1] = chr0; + p[2] = chr1; + p[3] = chr2; + p[4] = chr3; + p[5] = highbank; + } + + //void Mapper191::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + prg0 = p[0]; + chr0 = p[1]; + chr1 = p[2]; + chr2 = p[3]; + chr3 = p[4]; + highbank = p[5]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper191.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper191.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta index 55a5c03..9d5caf4 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper191.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0938567bea9d60e46b861a10275b4484 +guid: ae81a8958c1eb3f46a960c6319412523 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper192.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper192.cs new file mode 100644 index 0000000..97c5b37 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper192.cs @@ -0,0 +1,324 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper192 WaiXingTypeC Base ON Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper192 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + public Mapper192(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + } + + + //BYTE Mapper192::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + return XRAM[addr - 0x4000]; + } + else + { + return base.ReadLow(addr); + } + } + + //void Mapper192::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + XRAM[addr - 0x4000] = data; + } + else + { + base.WriteLow(addr, data); + } + } + + //void Mapper192::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = data; + SetBank_PPU(); + break; + case 0x01: + chr23 = data; + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + break; + } + + } + + //void Mapper192::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + // SetVROM_8K_Bank( chr4, chr5, chr6, chr7, + // chr01, chr01+1, chr23, chr23+1 ); + SetBank_PPUSUB(4, chr01 + 0); + SetBank_PPUSUB(5, chr01 + 1); + SetBank_PPUSUB(6, chr23 + 0); + SetBank_PPUSUB(7, chr23 + 1); + SetBank_PPUSUB(0, chr4); + SetBank_PPUSUB(1, chr5); + SetBank_PPUSUB(2, chr6); + SetBank_PPUSUB(3, chr7); + } + else + { + // SetVROM_8K_Bank( chr01, chr01+1, chr23, chr23+1, + // chr4, chr5, chr6, chr7 ); + SetBank_PPUSUB(0, chr01 + 0); + SetBank_PPUSUB(1, chr01 + 1); + SetBank_PPUSUB(2, chr23 + 0); + SetBank_PPUSUB(3, chr23 + 1); + SetBank_PPUSUB(4, chr4); + SetBank_PPUSUB(5, chr5); + SetBank_PPUSUB(6, chr6); + SetBank_PPUSUB(7, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0)); + SetCRAM_1K_Bank(5, (chr01 + 1)); + SetCRAM_1K_Bank(6, (chr23 + 0)); + SetCRAM_1K_Bank(7, (chr23 + 1)); + SetCRAM_1K_Bank(0, chr4); + SetCRAM_1K_Bank(1, chr5); + SetCRAM_1K_Bank(2, chr6); + SetCRAM_1K_Bank(3, chr7); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0)); + SetCRAM_1K_Bank(1, (chr01 + 1)); + SetCRAM_1K_Bank(2, (chr23 + 0)); + SetCRAM_1K_Bank(3, (chr23 + 1)); + SetCRAM_1K_Bank(4, chr4); + SetCRAM_1K_Bank(5, chr5); + SetCRAM_1K_Bank(6, chr6); + SetCRAM_1K_Bank(7, chr7); + } + } + } + + void SetBank_PPUSUB(int bank, int page) + { + if ((page & 0xFC) == 0x08) + { + SetCRAM_1K_Bank((byte)bank, page); + } + else + { + SetVROM_1K_Bank((byte)bank, page); + } + } + + //void Mapper192::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + p[19] = irq_request; + } + + //void Mapper192::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + irq_request = p[19]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper192.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper192.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper192.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper192.cs.meta index 354492c..70839d4 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper192.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper192.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4fa6279cecd943f42baf6d4e8a966cb4 +guid: ebb5af01672a4364ab26bd0ce4543f07 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs new file mode 100644 index 0000000..dbe695b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper193 MEGA SOFT (NTDEC) : Fighting Hero // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper193 : Mapper + { + public Mapper193(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_32K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper193::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x6000: + SetVROM_2K_Bank(0, ((data >> 1) & 0x7e) + 0); + SetVROM_2K_Bank(2, ((data >> 1) & 0x7e) + 1); + break; + case 0x6001: + SetVROM_2K_Bank(4, data >> 1); + break; + case 0x6002: + SetVROM_2K_Bank(6, data >> 1); + break; + case 0x6003: + SetPROM_32K_Bank(data); + break; + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper193.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper193.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta index 512e4aa..4014115 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper193.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f76460c502274ab4a8cac566ce0f0126 +guid: e56eadb9647b3b74a9267fbb5fea29d6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs new file mode 100644 index 0000000..970e5ca --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs @@ -0,0 +1,31 @@ +//////////////////////////////////////////// +// Mapper194 迷宮寺院ダãƒãƒ // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper194 : Mapper + { + public Mapper194(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_32K_SIZE - 1); + } + + //void Mapper194::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_8K_Bank(3, data); + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper194.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper194.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta index 3dc6752..94c2bf3 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper194.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 81ac03f4648c10c47b5903542095eef4 +guid: 5ac8a64a71bbbfd4db4a4dca1f57883d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper195.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper195.cs new file mode 100644 index 0000000..1e311b5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper195.cs @@ -0,0 +1,324 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper195 : Mapper + { + + BYTE[] reg = new BYTE[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + public Mapper195(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + } + + + //BYTE Mapper195::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + return XRAM[addr - 0x4000]; + } + else + { + return base.ReadLow(addr); + } + } + + //void Mapper195::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + XRAM[addr - 0x4000] = data; + } + else + { + base.WriteLow(addr, data); + } + } + + //void Mapper195::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = data; + SetBank_PPU(); + break; + case 0x01: + chr23 = data; + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + break; + } + + } + + //void Mapper195::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + // SetVROM_8K_Bank( chr4, chr5, chr6, chr7, + // chr01, chr01+1, chr23, chr23+1 ); + SetBank_PPUSUB(4, chr01 + 0); + SetBank_PPUSUB(5, chr01 + 1); + SetBank_PPUSUB(6, chr23 + 0); + SetBank_PPUSUB(7, chr23 + 1); + SetBank_PPUSUB(0, chr4); + SetBank_PPUSUB(1, chr5); + SetBank_PPUSUB(2, chr6); + SetBank_PPUSUB(3, chr7); + } + else + { + // SetVROM_8K_Bank( chr01, chr01+1, chr23, chr23+1, + // chr4, chr5, chr6, chr7 ); + SetBank_PPUSUB(0, chr01 + 0); + SetBank_PPUSUB(1, chr01 + 1); + SetBank_PPUSUB(2, chr23 + 0); + SetBank_PPUSUB(3, chr23 + 1); + SetBank_PPUSUB(4, chr4); + SetBank_PPUSUB(5, chr5); + SetBank_PPUSUB(6, chr6); + SetBank_PPUSUB(7, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0)); + SetCRAM_1K_Bank(5, (chr01 + 1)); + SetCRAM_1K_Bank(6, (chr23 + 0)); + SetCRAM_1K_Bank(7, (chr23 + 1)); + SetCRAM_1K_Bank(0, chr4); + SetCRAM_1K_Bank(1, chr5); + SetCRAM_1K_Bank(2, chr6); + SetCRAM_1K_Bank(3, chr7); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0)); + SetCRAM_1K_Bank(1, (chr01 + 1)); + SetCRAM_1K_Bank(2, (chr23 + 0)); + SetCRAM_1K_Bank(3, (chr23 + 1)); + SetCRAM_1K_Bank(4, chr4); + SetCRAM_1K_Bank(5, chr5); + SetCRAM_1K_Bank(6, chr6); + SetCRAM_1K_Bank(7, chr7); + } + } + } + + void SetBank_PPUSUB(int bank, int page) + { + if (page <= 3) + { + SetCRAM_1K_Bank((byte)bank, page); + } + else + { + SetVROM_1K_Bank((byte)bank, page); + } + } + + //void Mapper195::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + p[19] = irq_request; + } + + //void Mapper195::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (byte i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + irq_request = p[19]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper195.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper195.cs.meta new file mode 100644 index 0000000..c8d1cb8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper195.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9eac30ce838ece940b11ae5d5e5d6cfb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs new file mode 100644 index 0000000..e9a2116 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs @@ -0,0 +1,207 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper198 Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper198 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + + BYTE[] adr5000buf = new BYTE[1024 * 4]; + public Mapper198(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + } + + //void Mapper198::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr > 0x4018 && addr < 0x6000) + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + else + adr5000buf[addr & 0xFFF] = data; + } + //BYTE Mapper198::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (addr > 0x4018 && addr < 0x6000) + return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + else + return adr5000buf[addr & 0xFFF]; + } + + //void Mapper198::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + if (data >= 0x50) data &= 0x4F; + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + break; + case 0xC001: + reg[5] = data; + break; + case 0xE000: + reg[6] = data; + break; + case 0xE001: + reg[7] = data; + break; + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + } + + //void Mapper198::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + } + + //void Mapper198::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta new file mode 100644 index 0000000..91ae360 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6c148d721a4eed4599b4c4e535f9f21 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs new file mode 100644 index 0000000..ae92c41 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs @@ -0,0 +1,318 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper199 WaiXingTypeG Base ON Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper199 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE[] prg = new byte[4]; + BYTE[] chr = new byte[8]; + BYTE we_sram; + + BYTE JMaddr; + BYTE[] JMaddrDAT = new BYTE[3]; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + + public Mapper199(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (byte i = 0; i < 8; i++) + { + reg[i] = 0x00; + chr[i] = i; + } + prg[0] = 0x00; + prg[1] = 0x01; + prg[2] = (byte)(PROM_8K_SIZE - 2); + prg[3] = (byte)(PROM_8K_SIZE - 1); + SetBank_CPU(); + SetBank_PPU(); + + irq_enable = irq_counter = irq_latch = irq_request = 0; + + JMaddr = 0; + JMaddrDAT[0] = JMaddrDAT[1] = JMaddrDAT[2] = 0; + + we_sram = 0; + nes.SetSAVERAM_SIZE(32 * 1024); + nes.SetVideoMode(true); + } + + + //BYTE Mapper199::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + return XRAM[addr - 0x4000]; + } + else if (addr >= 0x6000 && addr <= 0x7FFF) + { + if (JMaddr != 0) + { + switch (addr) + { + case 0x6000: return JMaddrDAT[0]; + case 0x6010: return JMaddrDAT[1]; + case 0x6013: JMaddr = 0; return JMaddrDAT[2]; + } + } + + switch (we_sram) + { + case 0xE4: + case 0xEC: return WRAM[(addr & 0x1FFF) + 0x0000]; + case 0xE5: + case 0xED: return WRAM[(addr & 0x1FFF) + 0x2000]; + case 0xE6: + case 0xEE: return WRAM[(addr & 0x1FFF) + 0x4000]; + case 0xE7: + case 0xEF: return WRAM[(addr & 0x1FFF) + 0x6000]; + default: return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + + } + else + { + return base.ReadLow(addr); + } + } + + //void Mapper199::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x5000 && addr <= 0x5FFF) + { + XRAM[addr - 0x4000] = data; + if ((we_sram == 0xA1) || (we_sram == 0xA5) || (we_sram == 0xA9)) + { + JMaddr = 1; + switch (addr) + { + case 0x5000: JMaddrDAT[0] = data; break; + case 0x5010: JMaddrDAT[1] = data; break; + case 0x5013: JMaddrDAT[2] = data; break; + } + } + } + else if (addr >= 0x6000 && addr <= 0x7FFF) + { + + switch (we_sram) + { + case 0xE4: //CPU_MEM_BANK + case 0xEC: //CPU_MEM_BANK + WRAM[(addr & 0x1FFF) + 0x0000] = data; + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + break; + case 0xE5: //SRAM + case 0xED: //SRAM + WRAM[(addr & 0x1FFF) + 0x2000] = data; + break; + case 0xE6: + case 0xEE: + WRAM[(addr & 0x1FFF) + 0x4000] = data; + break; + case 0xE7: + case 0xEF: + WRAM[(addr & 0x1FFF) + 0x6000] = data; + break; + default: + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + break; + } + + } + else + { + base.WriteLow(addr, data); + } + } + + //void Mapper199::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + switch (reg[0] & 0x0f) + { + case 0x00: chr[0] = data; SetBank_PPU(); break; + case 0x01: chr[2] = data; SetBank_PPU(); break; + case 0x02: + case 0x03: + case 0x04: + case 0x05: chr[(reg[0] & 0x07) + 2] = data; SetBank_PPU(); break; + case 0x06: + case 0x07: + case 0x08: + case 0x09: prg[(reg[0] & 0x0f) - 6] = data; SetBank_CPU(); break; + case 0x0A: chr[1] = data; SetBank_PPU(); break; + case 0x0B: chr[3] = data; SetBank_PPU(); break; + } + break; + case 0xA000: + reg[2] = data; + data &= 0x03; + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else SetVRAM_Mirror(VRAM_MIRROR4H); + break; + case 0xA001: + // DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes->GetScanline(), nes->cpu->GetTotalCycles() ); + reg[3] = data; + we_sram = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + break; + } + + } + + //void Mapper199::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter -= 1; + } + } + if (irq_counter == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + irq_counter--; + } + } + } + } + + void SetBank_CPU() + { + SetPROM_8K_Bank(4, prg[0 ^ (reg[0] >> 5 & ~(0 << 1) & 2)]); + SetPROM_8K_Bank(5, prg[1 ^ (reg[0] >> 5 & ~(1 << 1) & 2)]); + SetPROM_8K_Bank(6, prg[2 ^ (reg[0] >> 5 & ~(2 << 1) & 2)]); + SetPROM_8K_Bank(7, prg[3 ^ (reg[0] >> 5 & ~(3 << 1) & 2)]); + } + + void SetBank_PPU() + { + uint bank = (uint)((reg[0] & 0x80) >> 5); + for (int x = 0; x < 8; x++) + { + if (chr[x] <= 7) + SetCRAM_1K_Bank((byte)(x ^ bank), chr[x]); + else + SetVROM_1K_Bank((byte)(x ^ bank), chr[x]); + } + } + + //void Mapper199::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // p[i] = reg[i]; + //} + //for (i = 8; i < 12; i++) + //{ + // p[i] = prg[i]; + //} + //for (i = 8; i < 20; i++) + //{ + // p[i] = chr[i]; + //} + //p[20] = we_sram; + //p[21] = JMaddr; + //p[22] = JMaddrDAT[0]; + //p[23] = JMaddrDAT[1]; + //p[24] = JMaddrDAT[2]; + //p[25] = irq_enable; + //p[26] = irq_counter; + //p[27] = irq_latch; + //p[28] = irq_request; + } + + //void Mapper199::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // reg[i] = p[i]; + //} + //for (i = 8; i < 12; i++) + //{ + // prg[i] = p[i]; + //} + //for (i = 8; i < 20; i++) + //{ + // chr[i] = p[i]; + //} + //we_sram = p[20]; + //JMaddr = p[21]; + //JMaddrDAT[0] = p[22]; + //JMaddrDAT[1] = p[23]; + //JMaddrDAT[2] = p[24]; + //irq_enable = p[25]; + //irq_counter = p[26]; + //irq_latch = p[27]; + //irq_request = p[28]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs.meta new file mode 100644 index 0000000..7603c91 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ef80437f6f5f07b42882cf860f0b2de6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper200.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper200.cs new file mode 100644 index 0000000..8d78049 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper200.cs @@ -0,0 +1,48 @@ +////////////////////////////////////////////// +// Mapper200 1200-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper200 : Mapper + { + public Mapper200(NES parent) : base(parent) + { + } + + public override void Reset() + { + // SetPROM_32K_Bank( 0, 1, PROM_8K_SIZE-2, PROM_8K_SIZE-1 ); + SetPROM_16K_Bank(4, 0); + SetPROM_16K_Bank(6, 0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper200::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_16K_Bank(4, addr & 0x07); + SetPROM_16K_Bank(6, addr & 0x07); + SetVROM_8K_Bank(addr & 0x07); + + if ((addr & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper200.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper200.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper200.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper200.cs.meta index 82706b1..598e1e1 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper200.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper200.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cf60a6b944a2cd646b955ef1890527fe +guid: b3d368691b1d7bb44967126b6082a921 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper201.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper201.cs new file mode 100644 index 0000000..88a3f1d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper201.cs @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper201 21-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper201 : Mapper + { + public Mapper201(NES parent) : base(parent) + { + } + + public override void Reset() + { + // SetPROM_32K_Bank( 0, 1, PROM_8K_SIZE-2, PROM_8K_SIZE-1 ); + SetPROM_16K_Bank(4, 0); + SetPROM_16K_Bank(6, 0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper201::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + BYTE bank = (byte)((BYTE)addr & 0x03); + if (!((addr & 0x08) != 0)) + bank = 0; + SetPROM_32K_Bank(bank); + SetVROM_8K_Bank(bank); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper201.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper201.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper201.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper201.cs.meta index 8978d1c..30a6ac6 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper201.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper201.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0fa34e45527799b4090d44ffa7f88235 +guid: 03513dbd4c1b907409e89d56b227afee MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper202.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper202.cs new file mode 100644 index 0000000..710b20e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper202.cs @@ -0,0 +1,77 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper202 150-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper202 : Mapper + { + public Mapper202(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_16K_Bank(4, 6); + SetPROM_16K_Bank(6, 7); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper202::ExWrite(WORD addr, BYTE data) + public override void ExWrite(ushort addr, byte data) + { + if (addr >= 0x4020) + { + WriteSub(addr, data); + } + } + + //void Mapper202::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + WriteSub(addr, data); + } + + //void Mapper202::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + WriteSub(addr, data); + } + + void WriteSub(ushort addr, BYTE data) + { + INT bank = (addr >> 1) & 0x07; + + SetPROM_16K_Bank(4, bank); + if ((addr & 0x0C) == 0x0C) + { + SetPROM_16K_Bank(6, bank + 1); + } + else + { + SetPROM_16K_Bank(6, bank); + } + SetVROM_8K_Bank(bank); + + if ((addr & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper202.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper202.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper202.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper202.cs.meta index 054b5a0..c2d49b7 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper202.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper202.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 70c735d1069ff314dbf88ff45dbdb8b2 +guid: 82ca6d213345fed4fa2be208d9a96fce MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper216.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper216.cs new file mode 100644 index 0000000..5229a99 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper216.cs @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper216 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper216 : Mapper + { + public Mapper216(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetVROM_8K_Bank(0); + SetPROM_32K_Bank(0); + } + + //void Mapper216::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetVROM_8K_Bank((addr & 0x0E) >> 1); + SetPROM_32K_Bank(addr & 1); + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper216.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper216.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper216.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper216.cs.meta index bccb44d..20844c2 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper216.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper216.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e384cf0eb5fa0b04eb8453de825d16f1 +guid: ad42621060166644b8a3d544df5dc2ae MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper222.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper222.cs new file mode 100644 index 0000000..a536f4f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper222.cs @@ -0,0 +1,70 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper222 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper222 : Mapper + { + public Mapper222(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + SetVRAM_Mirror(VRAM_VMIRROR); + } + + //void Mapper222::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF003) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + case 0xB000: + SetVROM_1K_Bank(0, data); + break; + case 0xB002: + SetVROM_1K_Bank(1, data); + break; + case 0xC000: + SetVROM_1K_Bank(2, data); + break; + case 0xC002: + SetVROM_1K_Bank(3, data); + break; + case 0xD000: + SetVROM_1K_Bank(4, data); + break; + case 0xD002: + SetVROM_1K_Bank(5, data); + break; + case 0xE000: + SetVROM_1K_Bank(6, data); + break; + case 0xE002: + SetVROM_1K_Bank(7, data); + break; + } + } + + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper222.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper222.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper222.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper222.cs.meta index fe1dc07..80ae54b 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper222.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper222.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 84f2bbbe7be8a35479c83cded3cdd0f4 +guid: a3a7e4991a3ddae4cace8ed86de9fc46 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper225.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper225.cs new file mode 100644 index 0000000..a44ca80 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper225.cs @@ -0,0 +1,82 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper225 72-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper225 : Mapper + { + public Mapper225(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 2, 3); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper225::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + BYTE prg_bank = (byte)((addr & 0x0F80) >> 7); + BYTE chr_bank = (byte)(addr & 0x003F); + + SetVROM_1K_Bank(0, (chr_bank * 8 + 0)); + SetVROM_1K_Bank(1, (chr_bank * 8 + 1)); + SetVROM_1K_Bank(2, (chr_bank * 8 + 2)); + SetVROM_1K_Bank(3, (chr_bank * 8 + 3)); + SetVROM_1K_Bank(4, (chr_bank * 8 + 4)); + SetVROM_1K_Bank(5, (chr_bank * 8 + 5)); + SetVROM_1K_Bank(6, (chr_bank * 8 + 6)); + SetVROM_1K_Bank(7, (chr_bank * 8 + 7)); + + if ((addr & 0x2000) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + + if ((addr & 0x1000) != 0) + { + // 16KBbank + if ((addr & 0x0040) != 0) + { + SetPROM_8K_Bank(4, (prg_bank * 4 + 2)); + SetPROM_8K_Bank(5, (prg_bank * 4 + 3)); + SetPROM_8K_Bank(6, (prg_bank * 4 + 2)); + SetPROM_8K_Bank(7, (prg_bank * 4 + 3)); + } + else + { + SetPROM_8K_Bank(4, (prg_bank * 4 + 0)); + SetPROM_8K_Bank(5, (prg_bank * 4 + 1)); + SetPROM_8K_Bank(6, (prg_bank * 4 + 0)); + SetPROM_8K_Bank(7, (prg_bank * 4 + 1)); + } + } + else + { + SetPROM_8K_Bank(4, (prg_bank * 4 + 0)); + SetPROM_8K_Bank(5, (prg_bank * 4 + 1)); + SetPROM_8K_Bank(6, (prg_bank * 4 + 2)); + SetPROM_8K_Bank(7, (prg_bank * 4 + 3)); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper225.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper225.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper225.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper225.cs.meta index c9bc3f1..ddbbc30 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper225.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper225.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 805833a504a7b7e44b9bc02878580e21 +guid: 01c358a2d8c225a4bb371969197e95ee MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper226.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper226.cs new file mode 100644 index 0000000..982db70 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper226.cs @@ -0,0 +1,97 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper226 76-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper226 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper226(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + reg[0] = 0; + reg[1] = 0; + } + + //void Mapper226::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0x001) != 0) + { + reg[1] = data; + } + else + { + reg[0] = data; + } + + if ((reg[0] & 0x40) != 0) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + + BYTE bank = (byte)(((reg[0] & 0x1E) >> 1) | ((reg[0] & 0x80) >> 3) | ((reg[1] & 0x01) << 5)); + + if ((reg[0] & 0x20) != 0) + { + if ((reg[0] & 0x01) != 0) + { + SetPROM_8K_Bank(4, bank * 4 + 2); + SetPROM_8K_Bank(5, bank * 4 + 3); + SetPROM_8K_Bank(6, bank * 4 + 2); + SetPROM_8K_Bank(7, bank * 4 + 3); + } + else + { + SetPROM_8K_Bank(4, bank * 4 + 0); + SetPROM_8K_Bank(5, bank * 4 + 1); + SetPROM_8K_Bank(6, bank * 4 + 0); + SetPROM_8K_Bank(7, bank * 4 + 1); + } + } + else + { + SetPROM_8K_Bank(4, bank * 4 + 0); + SetPROM_8K_Bank(5, bank * 4 + 1); + SetPROM_8K_Bank(6, bank * 4 + 2); + SetPROM_8K_Bank(7, bank * 4 + 3); + } + } + + public override bool IsStateSave() + { + return true; + } + + //void Mapper226::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper226::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper226.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper226.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper226.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper226.cs.meta index 194189b..760d445 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper226.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper226.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d2d0d6a9786e1eb488a45d8b784279b9 +guid: 195fc458164c6b444b120cf6c4fe9ee0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper227.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper227.cs new file mode 100644 index 0000000..f27bd29 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper227.cs @@ -0,0 +1,74 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper227 1200-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper227 : Mapper + { + public Mapper227(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 0, 1); + } + + //void Mapper227::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + BYTE bank = (byte)(((addr & 0x0100) >> 4) | ((addr & 0x0078) >> 3)); + + if ((addr & 0x0001) != 0) + { + SetPROM_32K_Bank(bank); + } + else + { + if ((addr & 0x0004) != 0) + { + SetPROM_8K_Bank(4, bank * 4 + 2); + SetPROM_8K_Bank(5, bank * 4 + 3); + SetPROM_8K_Bank(6, bank * 4 + 2); + SetPROM_8K_Bank(7, bank * 4 + 3); + } + else + { + SetPROM_8K_Bank(4, bank * 4 + 0); + SetPROM_8K_Bank(5, bank * 4 + 1); + SetPROM_8K_Bank(6, bank * 4 + 0); + SetPROM_8K_Bank(7, bank * 4 + 1); + } + } + + if (!((addr & 0x0080) != 0)) + { + if ((addr & 0x0200) != 0) + { + SetPROM_8K_Bank(6, (bank & 0x1C) * 4 + 14); + SetPROM_8K_Bank(7, (bank & 0x1C) * 4 + 15); + } + else + { + SetPROM_8K_Bank(6, (bank & 0x1C) * 4 + 0); + SetPROM_8K_Bank(7, (bank & 0x1C) * 4 + 1); + } + } + if ((addr & 0x0002) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper227.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper227.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper227.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper227.cs.meta index 4ac38b8..0cf6cef 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper227.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper227.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 675c53fc4556f454094683ba8b663cca +guid: e1131d8c69893f6438e3fe144cfb057b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper228.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper228.cs new file mode 100644 index 0000000..8e6b826 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper228.cs @@ -0,0 +1,74 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper228 Action 52 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper228 : Mapper + { + public Mapper228(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper228::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + BYTE prg = (byte)((addr & 0x0780) >> 7); + + switch ((addr & 0x1800) >> 11) + { + case 1: + prg |= 0x10; + break; + case 3: + prg |= 0x20; + break; + } + + if ((addr & 0x0020) != 0) + { + prg <<= 1; + if ((addr & 0x0040) != 0) + { + prg++; + } + SetPROM_8K_Bank(4, prg * 4 + 0); + SetPROM_8K_Bank(5, prg * 4 + 1); + SetPROM_8K_Bank(6, prg * 4 + 0); + SetPROM_8K_Bank(7, prg * 4 + 1); + } + else + { + SetPROM_8K_Bank(4, prg * 4 + 0); + SetPROM_8K_Bank(5, prg * 4 + 1); + SetPROM_8K_Bank(6, prg * 4 + 2); + SetPROM_8K_Bank(7, prg * 4 + 3); + } + + SetVROM_8K_Bank(((addr & 0x000F) << 2) | (data & 0x03)); + + if ((addr & 0x2000) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper228.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper228.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper228.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper228.cs.meta index 2578d37..6e8ccef 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper228.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper228.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d66a7ccd1090c894ba6919d9fa505c79 +guid: cdc061b408113c241b22d6c641ce13be MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper229.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper229.cs new file mode 100644 index 0000000..d2b1d31 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper229.cs @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper229 31-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper229 : Mapper + { + public Mapper229(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper229::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0x001E) != 0) + { + BYTE prg = (byte)(addr & 0x001F); + + SetPROM_8K_Bank(4, prg * 2 + 0); + SetPROM_8K_Bank(5, prg * 2 + 1); + SetPROM_8K_Bank(6, prg * 2 + 0); + SetPROM_8K_Bank(7, prg * 2 + 1); + + SetVROM_8K_Bank(addr & 0x0FFF); + } + else + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + if ((addr & 0x0020) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper229.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper229.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper229.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper229.cs.meta index abbb34f..a59c4e1 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper229.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper229.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8123f098f1b3113469e3407bbd436d4f +guid: 17a9f0d48f444e2429aec4d1d8f9db4d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper230.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper230.cs new file mode 100644 index 0000000..217e2a2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper230.cs @@ -0,0 +1,76 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper230 22-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper230 : Mapper + { + BYTE rom_sw; + public Mapper230(NES parent) : base(parent) + { + } + + public override void Reset() + { + if (rom_sw != 0) + { + rom_sw = 0; + } + else + { + rom_sw = 1; + } + if (rom_sw != 0) + { + SetPROM_32K_Bank(0, 1, 14, 15); + } + else + { + SetPROM_32K_Bank(16, 17, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + //void Mapper230::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (rom_sw != 0) + { + SetPROM_8K_Bank(4, (data & 0x07) * 2 + 0); + SetPROM_8K_Bank(5, (data & 0x07) * 2 + 1); + } + else + { + if ((data & 0x20) != 0) + { + SetPROM_8K_Bank(4, (data & 0x1F) * 2 + 16); + SetPROM_8K_Bank(5, (data & 0x1F) * 2 + 17); + SetPROM_8K_Bank(6, (data & 0x1F) * 2 + 16); + SetPROM_8K_Bank(7, (data & 0x1F) * 2 + 17); + } + else + { + SetPROM_8K_Bank(4, (data & 0x1E) * 2 + 16); + SetPROM_8K_Bank(5, (data & 0x1E) * 2 + 17); + SetPROM_8K_Bank(6, (data & 0x1E) * 2 + 18); + SetPROM_8K_Bank(7, (data & 0x1E) * 2 + 19); + } + if ((data & 0x40) != 0) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper230.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper230.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper230.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper230.cs.meta index cc4df39..415a6ad 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper230.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper230.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f6425637e54797c45abebe7b1c8e30dc +guid: 2aa15f3ed12b3a44882d440dc597d6fa MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper231.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper231.cs new file mode 100644 index 0000000..bcc66f8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper231.cs @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper231 20-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper231 : Mapper + { + public Mapper231(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper231::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0x0020) != 0) + { + SetPROM_32K_Bank((BYTE)(addr >> 1)); + } + else + { + BYTE bank = (byte)(addr & 0x1E); + SetPROM_8K_Bank(4, bank * 2 + 0); + SetPROM_8K_Bank(5, bank * 2 + 1); + SetPROM_8K_Bank(6, bank * 2 + 0); + SetPROM_8K_Bank(7, bank * 2 + 1); + } + + if ((addr & 0x0080) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper231.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper231.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper231.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper231.cs.meta index e4f3084..cf17bb5 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper231.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper231.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: be52d26a4ead22042b0265a6db3b2a6a +guid: 4c7681ab70d7d884280e28147c311d35 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper232.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper232.cs new file mode 100644 index 0000000..357594c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper232.cs @@ -0,0 +1,81 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper232 Quattro Games // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper232 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper232(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + reg[0] = 0x0C; + reg[1] = 0x00; + } + + //void Mapper232::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000) + { + Write(addr, data); + } + } + + //void Mapper232::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + // if( addr == 0x9000 ) { + // reg[0] = (data & 0x18)>>1; + // } else if( addr >= 0xA000 && addr <= 0xFFFF ) { + // reg[1] = data & 0x03; + // } + if (addr <= 0x9FFF) + { + reg[0] = (byte)((data & 0x18) >> 1); + } + else + { + reg[1] = (byte)(data & 0x03); + } + + SetPROM_8K_Bank(4, (reg[0] | reg[1]) * 2 + 0); + SetPROM_8K_Bank(5, (reg[0] | reg[1]) * 2 + 1); + SetPROM_8K_Bank(6, (reg[0] | 0x03) * 2 + 0); + SetPROM_8K_Bank(7, (reg[0] | 0x03) * 2 + 1); + } + + public override bool IsStateSave() + { + return true; + } + + + + //void Mapper232::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper232::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper232.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper232.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper232.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper232.cs.meta index a6090df..f5bc16a 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper232.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper232.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dafbc365bc8eb164a9fcac860585e366 +guid: fa6b23b030cd9524b974d522cd560855 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper233.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper233.cs new file mode 100644 index 0000000..9e6d7af --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper233.cs @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper233 42-in-1 // +//////////////////////////////////////////////////////////////////////////using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using static VirtualNes.MMU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper233 : Mapper + { + public Mapper233(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, 2, 3); + } + + //void Mapper233::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((data & 0x20) != 0) + { + SetPROM_8K_Bank(4, (data & 0x1F) * 2 + 0); + SetPROM_8K_Bank(5, (data & 0x1F) * 2 + 1); + SetPROM_8K_Bank(6, (data & 0x1F) * 2 + 0); + SetPROM_8K_Bank(7, (data & 0x1F) * 2 + 1); + } + else + { + BYTE bank = (byte)((data & 0x1E) >> 1); + + SetPROM_8K_Bank(4, bank * 4 + 0); + SetPROM_8K_Bank(5, bank * 4 + 1); + SetPROM_8K_Bank(6, bank * 4 + 2); + SetPROM_8K_Bank(7, bank * 4 + 3); + } + + if ((data & 0xC0) == 0x00) + { + SetVRAM_Mirror(0, 0, 0, 1); + } + else if ((data & 0xC0) == 0x40) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else if ((data & 0xC0) == 0x80) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_MIRROR4H); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper233.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper233.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper233.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper233.cs.meta index 400a17e..d7026dc 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper233.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper233.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e907b2b34ef04f145be24c3f2eada20f +guid: 5600496657b06bc4a96f701cd3c7062b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper234.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper234.cs new file mode 100644 index 0000000..c772378 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper234.cs @@ -0,0 +1,107 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper234 Maxi-15 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + + public class Mapper234 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper234(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, 2, 3); + + reg[0] = 0; + reg[1] = 0; + } + + //void Mapper234::Read(WORD addr, BYTE data) + public override void Read(ushort addr, byte data) + { + if (addr >= 0xFF80 && addr <= 0xFF9F) + { + if (reg[0] != 0) + { + reg[0] = data; + SetBank(); + } + } + + if (addr >= 0xFFE8 && addr <= 0xFFF7) + { + reg[1] = data; + SetBank(); + } + } + + //void Mapper234::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr >= 0xFF80 && addr <= 0xFF9F) + { + if (reg[0] == 0) + { + reg[0] = data; + SetBank(); + } + } + + if (addr >= 0xFFE8 && addr <= 0xFFF7) + { + reg[1] = data; + SetBank(); + } + } + + void SetBank() + { + if ((reg[0] & 0x80) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank((reg[0] & 0x0E) | (reg[1] & 0x01)); + SetVROM_8K_Bank(((reg[0] & 0x0E) << 2) | ((reg[1] >> 4) & 0x07)); + } + else + { + SetPROM_32K_Bank(reg[0] & 0x0F); + SetVROM_8K_Bank(((reg[0] & 0x0F) << 2) | ((reg[1] >> 4) & 0x03)); + } + } + public override bool IsStateSave() + { + return true; + } + //void Mapper234::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper234::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper234.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper234.cs.meta new file mode 100644 index 0000000..3714ace --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper234.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 935c2470f18c7864eb895d9684d545c4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper235.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper235.cs new file mode 100644 index 0000000..cd5640f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper235.cs @@ -0,0 +1,118 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper235 150-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper235 : Mapper + { + public Mapper235(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 0x2000; i++) + { + DRAM[i] = 0xFF; + } + + SetPROM_32K_Bank(0); + } + + //void Mapper235::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + { + BYTE prg = (byte)(((addr & 0x0300) >> 3) | (addr & 0x001F)); + BYTE bus = 0; + + if (PROM_8K_SIZE == 64 * 2) + { + // 100-in-1 + switch (addr & 0x0300) + { + case 0x0000: break; + case 0x0100: bus = 1; break; + case 0x0200: bus = 1; break; + case 0x0300: bus = 1; break; + } + } + else if (PROM_8K_SIZE == 128 * 2) + { + // 150-in-1 + switch (addr & 0x0300) + { + case 0x0000: break; + case 0x0100: bus = 1; break; + case 0x0200: prg = (byte)((prg & 0x1F) | 0x20); break; + case 0x0300: bus = 1; break; + } + } + else if (PROM_8K_SIZE == 192 * 2) + { + // 150-in-1 + switch (addr & 0x0300) + { + case 0x0000: break; + case 0x0100: bus = 1; break; + case 0x0200: prg = (byte)((prg & 0x1F) | 0x20); break; + case 0x0300: prg = (byte)((prg & 0x1F) | 0x40); break; + } + } + else if (PROM_8K_SIZE == 256 * 2) + { + } + + if ((addr & 0x0800) != 0) + { + if ((addr & 0x1000) != 0) + { + SetPROM_8K_Bank(4, prg * 4 + 2); + SetPROM_8K_Bank(5, prg * 4 + 3); + SetPROM_8K_Bank(6, prg * 4 + 2); + SetPROM_8K_Bank(7, prg * 4 + 3); + } + else + { + SetPROM_8K_Bank(4, prg * 4 + 0); + SetPROM_8K_Bank(5, prg * 4 + 1); + SetPROM_8K_Bank(6, prg * 4 + 0); + SetPROM_8K_Bank(7, prg * 4 + 1); + } + } + else + { + SetPROM_32K_Bank(prg); + } + + if (bus != 0) + { + SetPROM_Bank(4, DRAM, BANKTYPE_ROM); + SetPROM_Bank(5, DRAM, BANKTYPE_ROM); + SetPROM_Bank(6, DRAM, BANKTYPE_ROM); + SetPROM_Bank(7, DRAM, BANKTYPE_ROM); + } + + if ((addr & 0x0400) != 0) + { + SetVRAM_Mirror(VRAM_MIRROR4L); + } + else if ((addr & 0x2000) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper235.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper235.cs.meta new file mode 100644 index 0000000..a1faaf5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper235.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4af0cae483798c41992b53cbf976237 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper236.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper236.cs new file mode 100644 index 0000000..27abab7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper236.cs @@ -0,0 +1,98 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper236 800-in-1 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper236 : Mapper + { + BYTE bank, mode; + public Mapper236(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + bank = mode = 0; + } + + //void Mapper236::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr >= 0x8000 && addr <= 0xBFFF) + { + bank = (byte)(((addr & 0x03) << 4) | (bank & 0x07)); + } + else + { + bank = (byte)((addr & 0x07) | (bank & 0x30)); + mode = (byte)(addr & 0x30); + } + + if ((addr & 0x20) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + + switch (mode) + { + case 0x00: + bank |= 0x08; + SetPROM_8K_Bank(4, bank * 2 + 0); + SetPROM_8K_Bank(5, bank * 2 + 1); + SetPROM_8K_Bank(6, (bank | 0x07) * 2 + 0); + SetPROM_8K_Bank(7, (bank | 0x07) * 2 + 1); + break; + case 0x10: + bank |= 0x37; + SetPROM_8K_Bank(4, bank * 2 + 0); + SetPROM_8K_Bank(5, bank * 2 + 1); + SetPROM_8K_Bank(6, (bank | 0x07) * 2 + 0); + SetPROM_8K_Bank(7, (bank | 0x07) * 2 + 1); + break; + case 0x20: + bank |= 0x08; + SetPROM_8K_Bank(4, (bank & 0xFE) * 2 + 0); + SetPROM_8K_Bank(5, (bank & 0xFE) * 2 + 1); + SetPROM_8K_Bank(6, (bank & 0xFE) * 2 + 2); + SetPROM_8K_Bank(7, (bank & 0xFE) * 2 + 3); + break; + case 0x30: + bank |= 0x08; + SetPROM_8K_Bank(4, bank * 2 + 0); + SetPROM_8K_Bank(5, bank * 2 + 1); + SetPROM_8K_Bank(6, bank * 2 + 0); + SetPROM_8K_Bank(7, bank * 2 + 1); + break; + } + } + + + //void Mapper236::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = bank; + p[1] = mode; + } + + //void Mapper236::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + bank = p[0]; + mode = p[1]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper236.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper236.cs.meta new file mode 100644 index 0000000..db8f986 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper236.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 50be4abc74346ca48864a3bcb43a94b6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper240.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper240.cs new file mode 100644 index 0000000..5f9c268 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper240.cs @@ -0,0 +1,40 @@ +////////////////////////////// +// Mapper240 Gen Ke Le Zhuan // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper240 : Mapper + { + public Mapper240(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper240::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x4020 && addr < 0x6000) + { + SetPROM_32K_Bank((data & 0xF0) >> 4); + SetVROM_8K_Bank(data & 0xF); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper240.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper240.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper240.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper240.cs.meta index 52cd3f7..6d847ab 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper240.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper240.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: eb9d4ffbec8733541a56bc8469e2b86f +guid: da14e08bfcffc214ca9bea59eeb38d0a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper241.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper241.cs new file mode 100644 index 0000000..bc5c8fc --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper241.cs @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper241 Fon Serm Bon // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper241 : Mapper + { + public Mapper241(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper241::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr == 0x8000) + { + SetPROM_32K_Bank(data); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper241.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper241.cs.meta new file mode 100644 index 0000000..5097453 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper241.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 17ebf1bde1c31bd4d838a0297a28c5d0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper242.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper242.cs new file mode 100644 index 0000000..17c0f74 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper242.cs @@ -0,0 +1,34 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper242 Wai Xing Zhan Shi // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper242 : Mapper + { + public Mapper242(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + } + + //void Mapper242::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if ((addr & 0x01) != 0) + { + SetPROM_32K_Bank((addr & 0xF8) >> 3); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper242.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper242.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper242.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper242.cs.meta index 1334878..ba5daed 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper242.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper242.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d62ffe85351435340a8e3c42f84dee3b +guid: a37f7351801308a4e9b78625c82aa95a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs new file mode 100644 index 0000000..7fa4fc9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs @@ -0,0 +1,114 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper243 PC-Sachen/Hacker // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + + public class Mapper243 : Mapper + { + BYTE[] reg = new byte[4]; + public Mapper243(NES parent) : base(parent) + { + } + + //void Mapper243::Reset() + public override void Reset() + { + SetPROM_32K_Bank(0); + if (VROM_8K_SIZE > 4) + { + SetVROM_8K_Bank(4); + } + else if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + SetVRAM_Mirror(VRAM_HMIRROR); + + reg[0] = 0; + reg[1] = 0; + reg[2] = 3; + reg[3] = 0; + } + + //void Mapper243::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0x4101) == 0x4100) + { + reg[0] = data; + } + else if ((addr & 0x4101) == 0x4101) + { + switch (reg[0] & 0x07) + { + case 0: + reg[1] = 0; + reg[2] = 3; + break; + case 4: + reg[2] = (byte)((reg[2] & 0x06) | (data & 0x01)); + break; + case 5: + reg[1] = (byte)(data & 0x01); + break; + case 6: + reg[2] = (byte)((reg[2] & 0x01) | ((data & 0x03) << 1)); + break; + case 7: + reg[3] = (byte)(data & 0x01); + break; + default: + break; + } + + SetPROM_32K_Bank(reg[1]); + SetVROM_8K_Bank(reg[2] * 8 + 0, reg[2] * 8 + 1, reg[2] * 8 + 2, reg[2] * 8 + 3, + reg[2] * 8 + 4, reg[2] * 8 + 5, reg[2] * 8 + 6, reg[2] * 8 + 7); + + if (reg[3] != 0) + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + } + } + + public override bool IsStateSave() + { + return true; + } + + + + //void Mapper243::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg[0]; + //p[1] = reg[1]; + //p[2] = reg[2]; + //p[3] = reg[3]; + } + + //void Mapper243::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //reg[0] = p[0]; + //reg[1] = p[1]; + //reg[2] = p[2]; + //reg[3] = p[3]; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper243.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper243.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs.meta index 0e971e1..8382bdd 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper243.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d1322eaba98d208409847802768cbbc6 +guid: b726927f98443184aa25c67151da6646 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper244.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper244.cs new file mode 100644 index 0000000..0621369 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper244.cs @@ -0,0 +1,40 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper244 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper244 : Mapper + { + public Mapper244(NES parent) : base(parent) + { + } + + //void Mapper244::Reset() + public override void Reset() + { + SetPROM_32K_Bank(0); + } + + //void Mapper244::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (addr >= 0x8065 && addr <= 0x80A4) + { + SetPROM_32K_Bank((addr - 0x8065) & 0x3); + } + + if (addr >= 0x80A5 && addr <= 0x80E4) + { + SetVROM_8K_Bank((addr - 0x80A5) & 0x7); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper244.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper244.cs.meta new file mode 100644 index 0000000..43fa830 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper244.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a87f223fb44ff5f4f95d1e5096eee666 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs new file mode 100644 index 0000000..9fe7b3c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs @@ -0,0 +1,255 @@ +////////////////////////////////////////////////////////////// +// Mapper245 Yong Zhe Dou E Long // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.Core.CPU; +using static VirtualNes.MMU; +using BYTE = System.Byte; +using INT = System.Int32; + +namespace VirtualNes.Core +{ + public class Mapper245 : Mapper + { + + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + int MMC4prg, MMC4chr; + public Mapper245(NES parent) : base(parent) + { + } + + + //void Mapper245::Reset() + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + } + + //void Mapper245::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF7FF) + { + case 0x8000: + reg[0] = data; + break; + case 0x8001: + reg[1] = data; + switch (reg[0]) + { + case 0x00: + reg[3] = (byte)((data & 2) << 5); + SetPROM_8K_Bank(6, 0x3E | reg[3]); + SetPROM_8K_Bank(7, 0x3F | reg[3]); + break; + case 0x06: + prg0 = data; + break; + case 0x07: + prg1 = data; + break; + } + SetPROM_8K_Bank(4, prg0 | reg[3]); + SetPROM_8K_Bank(5, prg1 | reg[3]); + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper245::Clock(INT cycles) + public override void Clock(int cycles) + { + // if( irq_request && (nes.GetIrqType() == NES::IRQ_CLOCK) ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + //void Mapper245::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + // if( irq_request && (nes.GetIrqType() == NES::IRQ_HSYNC) ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + void SetBank_PPU() + { + if ((VROM_1K_SIZE) != 0) + { + if (((reg[0] & 0x80)! + 0) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr23 + 1, chr23, chr01 + 1, chr01); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(0, chr4 & 0x07); + SetCRAM_1K_Bank(1, chr5 & 0x07); + SetCRAM_1K_Bank(2, chr6 & 0x07); + SetCRAM_1K_Bank(3, chr7 & 0x07); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(4, chr4 & 0x07); + SetCRAM_1K_Bank(5, chr5 & 0x07); + SetCRAM_1K_Bank(6, chr6 & 0x07); + SetCRAM_1K_Bank(7, chr7 & 0x07); + } + } + } + + public override bool IsStateSave() + { + return true; + } + + + //void Mapper245::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // p[i] = reg[i]; + //} + //p[8] = prg0; + //p[9] = prg1; + //p[10] = chr01; + //p[11] = chr23; + //p[12] = chr4; + //p[13] = chr5; + //p[14] = chr6; + //p[15] = chr7; + //p[16] = irq_enable; + //p[17] = (BYTE)irq_counter; + //p[18] = irq_latch; + //p[19] = irq_request; + } + + //void Mapper245::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // reg[i] = p[i]; + //} + //prg0 = p[8]; + //prg1 = p[9]; + //chr01 = p[10]; + //chr23 = p[11]; + //chr4 = p[12]; + //chr5 = p[13]; + //chr6 = p[14]; + //chr7 = p[15]; + //irq_enable = p[16]; + //irq_counter = (INT)p[17]; + //irq_latch = p[18]; + //irq_request = p[19]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper245.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper245.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs.meta index 040ac42..088933d 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper245.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6ab59a7c8ec0352498d385808f3136a5 +guid: cb93375a5f2207e41af81add88dd6b61 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper246.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper246.cs new file mode 100644 index 0000000..6eb038a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper246.cs @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper246 Phone Serm Berm // +////////////////////////////////////////////////////////////////////////// + +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper246 : Mapper + { + public Mapper246(NES parent) : base(parent) + { + } + + + //void Mapper246::Reset() + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper246::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x6000 && addr < 0x8000) + { + switch (addr) + { + case 0x6000: + SetPROM_8K_Bank(4, data); + break; + case 0x6001: + SetPROM_8K_Bank(5, data); + break; + case 0x6002: + SetPROM_8K_Bank(6, data); + break; + case 0x6003: + SetPROM_8K_Bank(7, data); + break; + case 0x6004: + SetVROM_2K_Bank(0, data); + break; + case 0x6005: + SetVROM_2K_Bank(2, data); + break; + case 0x6006: + SetVROM_2K_Bank(4, data); + break; + case 0x6007: + SetVROM_2K_Bank(6, data); + break; + default: + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + break; + } + } + + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper246.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper246.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper246.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper246.cs.meta index 46221ca..1d01eea 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper246.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper246.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b64643bcf29c76246b9f648dea863909 +guid: 32c1242dd4ea66f4184cce314fbc958c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs new file mode 100644 index 0000000..05c11e1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs @@ -0,0 +1,232 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; + +namespace VirtualNes.Core +{ + public class Mapper248 : Mapper + { + BYTE[] reg = new BYTE[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + public Mapper248(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + } + + + + //void Mapper248::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + SetPROM_32K_Bank(2 * data, 2 * data + 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper248::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + } + break; + case 0xC000: + irq_enable = 0; + irq_latch = 0xBE; + irq_counter = 0xBE; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC001: + irq_enable = 1; + irq_latch = 0xBE; + irq_counter = 0xBE; + break; + } + + } + + //void Mapper248::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0) + { + if ((irq_counter--) == 0) + { + irq_counter = irq_latch; + // nes->cpu->IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + } + + public override bool IsStateSave() + { + return true; + } + + //void Mapper248::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // p[i] = reg[i]; + //} + //p[8] = prg0; + //p[9] = prg1; + //p[10] = chr01; + //p[11] = chr23; + //p[12] = chr4; + //p[13] = chr5; + //p[14] = chr6; + //p[15] = chr7; + //p[16] = irq_enable; + //p[17] = (BYTE)irq_counter; + //p[18] = irq_latch; + //p[19] = irq_request; + } + + //void Mapper248::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // reg[i] = p[i]; + //} + //prg0 = p[8]; + //prg1 = p[9]; + //chr01 = p[10]; + //chr23 = p[11]; + //chr4 = p[12]; + //chr5 = p[13]; + //chr6 = p[14]; + //chr7 = p[15]; + //irq_enable = p[16]; + //irq_counter = (INT)p[17]; + //irq_latch = p[18]; + //irq_request = p[19]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs.meta new file mode 100644 index 0000000..d686737 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f7d8dac2353b4dd488d814cfd36016e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs new file mode 100644 index 0000000..56b03f6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs @@ -0,0 +1,383 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper249 : Mapper + { + int MMC4prg, MMC4chr; + BYTE spdata; + BYTE[] reg = new BYTE[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + BYTE patch; + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + public Mapper249(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + prg0 = 0; + prg1 = 1; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + + SetVROM_8K_Bank(0); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + + // IRQタイプ設定 + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + spdata = 0; + } + + //void Mapper249::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr == 0x5000) + { + switch (data) + { + case 0x00: + spdata = 0; + break; + case 0x02: + spdata = 1; + break; + } + } + + if (addr >= 0x6000 && addr < 0x8000) + { + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + } + + //void Mapper249::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + BYTE m0, m1, m2, m3, m4, m5, m6, m7; + + switch (addr & 0xFF01) + { + case 0x8000: + case 0x8800: + reg[0] = data; + break; + case 0x8001: + case 0x8801: + switch (reg[0] & 0x07) + { + case 0x00: + if (spdata == 1) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + SetVROM_1K_Bank(0, data & 0xFE); + SetVROM_1K_Bank(1, data | 0x01); + break; + case 0x01: + if (spdata == 1) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + SetVROM_1K_Bank(2, data & 0xFE); + SetVROM_1K_Bank(3, data | 0x01); + break; + case 0x02: + if (spdata == 1) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + SetVROM_1K_Bank(4, data); + break; + case 0x03: + if (spdata == 1) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + SetVROM_1K_Bank(5, data); + break; + case 0x04: + if (spdata == 1) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + SetVROM_1K_Bank(6, data); + break; + case 0x05: + if (spdata == 1) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + SetVROM_1K_Bank(7, data); + break; + case 0x06: + if (spdata == 1) + { + if (data < 0x20) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = 0; + m6 = 0; + m7 = 0; + data = (byte)((m7 << 7) | (m6 << 6) | (m5 << 5) | (m2 << 4) | (m1 << 3) | (m3 << 2) | (m4 << 1) | m0); + } + else + { + data = (byte)(data - 0x20); + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + } + SetPROM_8K_Bank(4, data); + break; + case 0x07: + if (spdata == 1) + { + if (data < 0x20) + { + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = 0; + m6 = 0; + m7 = 0; + data = (byte)((m7 << 7) | (m6 << 6) | (m5 << 5) | (m2 << 4) | (m1 << 3) | (m3 << 2) | (m4 << 1) | m0); + } + else + { + data = (byte)(data - 0x20); + m0 = (byte)(data & 0x1); + m1 = (byte)((data & 0x02) >> 1); + m2 = (byte)((data & 0x04) >> 2); + m3 = (byte)((data & 0x08) >> 3); + m4 = (byte)((data & 0x10) >> 4); + m5 = (byte)((data & 0x20) >> 5); + m6 = (byte)((data & 0x40) >> 6); + m7 = (byte)((data & 0x80) >> 7); + data = (byte)((m5 << 7) | (m4 << 6) | (m2 << 5) | (m6 << 4) | (m7 << 3) | (m3 << 2) | (m1 << 1) | m0); + } + } + SetPROM_8K_Bank(5, data); + break; + } + break; + case 0xA000: + case 0xA800: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01)!= 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + case 0xA801: + reg[3] = data; + break; + case 0xC000: + case 0xC800: + reg[4] = data; + irq_counter = data; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC001: + case 0xC801: + reg[5] = data; + irq_latch = data; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE000: + case 0xE800: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + case 0xE801: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper249::Clock(INT cycles) + public override void Clock(int cycles) + { + // if( irq_request && (nes->GetIrqType() == NES::IRQ_CLOCK) ) { + // nes->cpu->IRQ_NotPending(); + // } + } + + //void Mapper249::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable !=0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + // if( irq_request && (nes->GetIrqType() == NES::IRQ_HSYNC) ) { + // nes->cpu->IRQ_NotPending(); + // } + } + + public override bool IsStateSave() + { + return true; + } + + //void Mapper249::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // p[i] = reg[i]; + //} + //p[8] = prg0; + //p[9] = prg1; + //p[10] = chr01; + //p[11] = chr23; + //p[12] = chr4; + //p[13] = chr5; + //p[14] = chr6; + //p[15] = chr7; + //p[16] = irq_enable; + //p[17] = irq_counter; + //p[18] = irq_latch; + //p[19] = irq_request; + //p[20] = spdata; + } + + //void Mapper249::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // reg[i] = p[i]; + //} + //prg0 = p[8]; + //prg1 = p[9]; + //chr01 = p[10]; + //chr23 = p[11]; + //chr4 = p[12]; + //chr5 = p[13]; + //chr6 = p[14]; + //chr7 = p[15]; + //irq_enable = p[16]; + //irq_counter = p[17]; + //irq_latch = p[18]; + //irq_request = p[19]; + //spdata = p[20]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs.meta new file mode 100644 index 0000000..f5f9eb9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41a9bc9945845ad479223ef030929e05 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs new file mode 100644 index 0000000..de5a018 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs @@ -0,0 +1,143 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class Mapper251 : Mapper + { + BYTE[] reg = new BYTE[11]; + BYTE[] breg = new BYTE[4]; + public Mapper251(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + SetVRAM_Mirror(VRAM_VMIRROR); + + INT i; + for (i = 0; i < 11; i++) + reg[i] = 0; + for (i = 0; i < 4; i++) + breg[i] = 0; + } + + //void Mapper251::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xE001) == 0x6000) + { + if (reg[9] != null) + { + breg[reg[10]++] = data; + if (reg[10] == 4) + { + reg[10] = 0; + SetBank(); + } + } + } + } + + //void Mapper251::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[8] = data; + SetBank(); + break; + case 0x8001: + reg[reg[8] & 0x07] = data; + SetBank(); + break; + case 0xA001: + if ((data & 0x80)!= 0) + { + reg[9] = 1; + reg[10] = 0; + } + else + { + reg[9] = 0; + } + break; + } + } + + //void Mapper251::SetBank() + public void SetBank() + { + INT[] chr = new INT[6]; + INT[] prg = new int[4]; + + for (INT i = 0; i < 6; i++) + { + chr[i] = (reg[i] | (breg[1] << 4)) & ((breg[2] << 4) | 0x0F); + } + + if ((reg[8] & 0x80) != 0) + { + SetVROM_8K_Bank(chr[2], chr[3], chr[4], chr[5], chr[0], chr[0] + 1, chr[1], chr[1] + 1); + } + else + { + SetVROM_8K_Bank(chr[0], chr[0] + 1, chr[1], chr[1] + 1, chr[2], chr[3], chr[4], chr[5]); + } + + prg[0] = (reg[6] & ((breg[3] & 0x3F) ^ 0x3F)) | (breg[1]); + prg[1] = (reg[7] & ((breg[3] & 0x3F) ^ 0x3F)) | (breg[1]); + prg[2] = prg[3] = ((breg[3] & 0x3F) ^ 0x3F) | (breg[1]); + prg[2] &= PROM_8K_SIZE - 1; + + if ((reg[8] & 0x40) != 0) + { + SetPROM_32K_Bank(prg[2], prg[1], prg[0], prg[3]); + } + else + { + SetPROM_32K_Bank(prg[0], prg[1], prg[2], prg[3]); + } + } + public override bool IsStateSave() + { + return true; + } + + //void Mapper251::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //INT i; + + //for (i = 0; i < 11; i++) + //{ + // p[i] = reg[i]; + //} + //for (i = 0; i < 4; i++) + //{ + // p[i + 11] = breg[i]; + //} + } + + //void Mapper251::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //INT i; + //for (i = 0; i < 11; i++) + //{ + // reg[i] = p[i]; + //} + //for (i = 0; i < 4; i++) + //{ + // reg[i] = p[i + 11]; + //} + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs.meta new file mode 100644 index 0000000..00e5eee --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 51cb43228abfedc43b3ada072b386e8c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper252.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper252.cs new file mode 100644 index 0000000..fba69a5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper252.cs @@ -0,0 +1,213 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper252 : Mapper + { + BYTE[] reg = new BYTE[9]; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_occur; + INT irq_clock; + + public Mapper252(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + + reg[8] = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + irq_occur = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + + nes.SetRenderMethod(EnumRenderMethod.POST_RENDER); + } + + public override void Write(ushort addr, byte data) + { + + if ((addr & 0xF000) == 0x8000) + { + SetPROM_8K_Bank(4, data); + return; + } + if ((addr & 0xF000) == 0xA000) + { + SetPROM_8K_Bank(5, data); + return; + } + switch (addr & 0xF00C) + { + case 0xB000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB004: + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB008: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + case 0xB00C: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC004: + reg[2] = (byte)(((reg[2] & 0x0F) | ((data & 0x0F) << 4))); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC008: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + case 0xC00C: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD004: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD008: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + case 0xD00C: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE004: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE008: + reg[7] = (byte)((reg[7] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + case 0xE00C: + reg[7] = (byte)((reg[7] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0xF000: + irq_latch = (byte)((irq_latch & 0xF0) | (data & 0x0F)); + irq_occur = 0; + break; + case 0xF004: + irq_latch = (byte)((irq_latch & 0x0F) | ((data & 0x0F) << 4)); + irq_occur = 0; + break; + + case 0xF008: + irq_enable = (byte)(data & 0x03); + if ((irq_enable & 0x02) != 0) + { + irq_counter = irq_latch; + irq_clock = 0; + } + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF00C: + irq_enable = (byte)((irq_enable & 0x01) * 3); + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper252::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + if ((irq_clock += cycles) >= 0x72) + { + irq_clock -= 0x72; + if (irq_counter == 0xFF) + { + irq_occur = 0xFF; + irq_counter = irq_latch; + irq_enable = (byte)((irq_enable & 0x01) * 3); + + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter++; + } + } + // if( irq_occur ) { + // nes->cpu->IRQ_NotPending(); + // } + } + } + public override bool IsStateSave() + { + return true; + } + //void Mapper252::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + for (INT i = 0; i < 9; i++) + { + p[i] = reg[i]; + } + p[9] = irq_enable; + p[10] = irq_counter; + p[11] = irq_latch; + + //*(INT*)&p[12] = irq_clock; + Array.Copy(p, 12, BitConverter.GetBytes(irq_clock), 0, 4); + } + + //void Mapper252::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + for (INT i = 0; i < 9; i++) + { + reg[i] = p[i]; + } + irq_enable = p[9]; + irq_counter = p[10]; + irq_latch = p[11]; + //irq_clock = *(INT*)&p[12]; + irq_clock = BitConverter.ToInt32(p,12); + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper252.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper252.cs.meta new file mode 100644 index 0000000..f415194 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper252.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b7a41c2ee41c1a4f9410d5243c67196 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper254.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper254.cs new file mode 100644 index 0000000..e4e20a6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper254.cs @@ -0,0 +1,306 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; + +namespace VirtualNes.Core +{ + public class Mapper254 : Mapper + { + BYTE[] reg = new BYTE[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + BYTE protectflag; + public Mapper254(NES parent) : base(parent) + { + } + + public override void Reset() + { + for (int i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + protectflag = 0; + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + } + + public override void WriteLow(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x6000: + case 0x7000: + MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + break; + } + } + + + public override byte ReadLow(ushort addr) + { + if (addr >= 0x6000) + { + if (protectflag != 0) + { + return (MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]); + } + else + { + return (byte)((MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]) ^ 0x1); + } + } + return base.ReadLow(addr); + } + + + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + protectflag = 0xFF; + reg[0] = data; + SetBank_CPU(); + SetBank_PPU(); + break; + case 0x8001: + reg[1] = data; + + switch (reg[0] & 0x07) + { + case 0x00: + chr01 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x01: + chr23 = (byte)(data & 0xFE); + SetBank_PPU(); + break; + case 0x02: + chr4 = data; + SetBank_PPU(); + break; + case 0x03: + chr5 = data; + SetBank_PPU(); + break; + case 0x04: + chr6 = data; + SetBank_PPU(); + break; + case 0x05: + chr7 = data; + SetBank_PPU(); + break; + case 0x06: + prg0 = data; + SetBank_CPU(); + break; + case 0x07: + prg1 = data; + SetBank_CPU(); + break; + } + break; + case 0xA000: + reg[2] = data; + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x01) != 0) MMU.SetVRAM_Mirror(MMU.VRAM_HMIRROR); + else MMU.SetVRAM_Mirror(MMU.VRAM_VMIRROR); + } + break; + case 0xA001: + reg[3] = data; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + nes.cpu.ClrIRQ(CPU.IRQ_MAPPER); + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + nes.cpu.ClrIRQ(CPU.IRQ_MAPPER); + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(CPU.IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + nes.cpu.ClrIRQ(CPU.IRQ_MAPPER); + break; + } + } + + + public override void Clock(int cycles) + { + // if( irq_request && (nes->GetIrqType() == NES::IRQ_CLOCK) ) { + // nes->cpu->IRQ_NotPending(); + // } + } + + + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(CPU.IRQ_MAPPER); + } + } + } + } + // if( irq_request && (nes->GetIrqType() == NES::IRQ_HSYNC) ) { + // nes->cpu->IRQ_NotPending(); + // } + } + + + public void SetBank_CPU() + { + if ((reg[0] & 0x40)!=0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + public void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80)!= 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(0, chr4 & 0x07); + SetCRAM_1K_Bank(1, chr5 & 0x07); + SetCRAM_1K_Bank(2, chr6 & 0x07); + SetCRAM_1K_Bank(3, chr7 & 0x07); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(4, chr4 & 0x07); + SetCRAM_1K_Bank(5, chr5 & 0x07); + SetCRAM_1K_Bank(6, chr6 & 0x07); + SetCRAM_1K_Bank(7, chr7 & 0x07); + } + } + } + public override bool IsStateSave() + { + return true; + } + + public override void SaveState(byte[] p) + { + for (int i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = prg0; + p[9] = prg1; + p[10] = chr01; + p[11] = chr23; + p[12] = chr4; + p[13] = chr5; + p[14] = chr6; + p[15] = chr7; + p[16] = irq_enable; + p[17] = irq_counter; + p[18] = irq_latch; + p[19] = irq_request; + p[20] = protectflag; + } + + public override void LoadState(byte[] p) + { + for (int i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + prg0 = p[8]; + prg1 = p[9]; + chr01 = p[10]; + chr23 = p[11]; + chr4 = p[12]; + chr5 = p[13]; + chr6 = p[14]; + chr7 = p[15]; + irq_enable = p[16]; + irq_counter = p[17]; + irq_latch = p[18]; + irq_request = p[19]; + protectflag = p[20]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper254.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper254.cs.meta new file mode 100644 index 0000000..6413c43 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper254.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e8b780ffcd95804684aaf2c421f1602 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper255.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper255.cs new file mode 100644 index 0000000..02e3e36 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper255.cs @@ -0,0 +1,129 @@ +using Codice.CM.Client.Differences; +using System; + +namespace VirtualNes.Core +{ + public class Mapper255 : Mapper + { + byte[] reg = new byte[4]; + public Mapper255(NES parent) : base(parent) + { + } + + public override void Reset() + { + MMU.SetPROM_32K_Bank(0); + MMU.SetVROM_8K_Bank(0); + MMU.SetVRAM_Mirror(MMU.VRAM_VMIRROR); + + reg[0] = 0; + reg[1] = 0; + reg[2] = 0; + reg[3] = 0; + } + + //BYTE Mapper255::ReadLow(WORD addr, BYTE data) + //{ + // if (addr >= 0x5800) + // { + // return reg[addr & 0x0003] & 0x0F; + // } + // else + // { + // return addr >> 8; + // } + //} + public override byte ReadLow(ushort addr) + { + if (addr >= 0x5800) + { + return (byte)(reg[addr & 0x0003] & 0x0F); + } + else + { + return (byte)(addr >> 8); + } + } + + + public override void WriteLow(ushort addr, byte data) + { + if (addr >= 0x5800) + { + reg[addr & 0x0003] = (byte)(data & 0x0F); + } + } + public override void Write(ushort addr, byte data) + { + byte prg = (byte)((addr & 0x0F80) >> 7); + int chr = (byte)((addr & 0x003F)); + int bank = (byte)((addr & 0x4000) >> 14); + + if ((addr & 0x2000) != 0 ) + { + MMU.SetVRAM_Mirror(MMU.VRAM_HMIRROR); + } + else + { + MMU.SetVRAM_Mirror(MMU.VRAM_VMIRROR); + } + + if ((addr & 0x1000) !=0) + { + if ((addr & 0x0040) != 0) + { + MMU.SetPROM_8K_Bank(4, 0x80 * bank + prg * 4 + 2); + MMU.SetPROM_8K_Bank(5, 0x80 * bank + prg * 4 + 3); + MMU.SetPROM_8K_Bank(6, 0x80 * bank + prg * 4 + 2); + MMU.SetPROM_8K_Bank(7, 0x80 * bank + prg * 4 + 3); + } + else + { + MMU.SetPROM_8K_Bank(4, 0x80 * bank + prg * 4 + 0); + MMU.SetPROM_8K_Bank(5, 0x80 * bank + prg * 4 + 1); + MMU.SetPROM_8K_Bank(6, 0x80 * bank + prg * 4 + 0); + MMU.SetPROM_8K_Bank(7, 0x80 * bank + prg * 4 + 1); + } + } + else + { + MMU.SetPROM_8K_Bank(4, 0x80 * bank + prg * 4 + 0); + MMU.SetPROM_8K_Bank(5, 0x80 * bank + prg * 4 + 1); + MMU.SetPROM_8K_Bank(6, 0x80 * bank + prg * 4 + 2); + MMU.SetPROM_8K_Bank(7, 0x80 * bank + prg * 4 + 3); + } + + MMU.SetVROM_1K_Bank(0, 0x200 * bank + chr * 8 + 0); + MMU.SetVROM_1K_Bank(1, 0x200 * bank + chr * 8 + 1); + MMU.SetVROM_1K_Bank(2, 0x200 * bank + chr * 8 + 2); + MMU.SetVROM_1K_Bank(3, 0x200 * bank + chr * 8 + 3); + MMU.SetVROM_1K_Bank(4, 0x200 * bank + chr * 8 + 4); + MMU.SetVROM_1K_Bank(5, 0x200 * bank + chr * 8 + 5); + MMU.SetVROM_1K_Bank(6, 0x200 * bank + chr * 8 + 6); + MMU.SetVROM_1K_Bank(7, 0x200 * bank + chr * 8 + 7); + } + + // For state save + public override bool IsStateSave() + { + return true; + } + + + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = reg[2]; + p[3] = reg[3]; + } + + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; + reg[3] = p[3]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper255.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper255.cs.meta similarity index 83% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper255.cs.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper255.cs.meta index 2014a57..bfcb419 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper255.cs.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper255.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 076b4701a252e1a4aab4efd4c5aede0b +guid: b32da776b8028bd41baee629f49fa379 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_Mapper.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_Mapper.cs new file mode 100644 index 0000000..42980c4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_Mapper.cs @@ -0,0 +1,18 @@ +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using Codice.CM.Client.Differences; + +namespace VirtualNes.Core +{ + public class _Mapper : Mapper + { + + public _Mapper(NES parent) : base(parent) { } + + public override void Reset() + { + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_Mapper.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_Mapper.cs.meta new file mode 100644 index 0000000..098e193 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_Mapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5886971893af9a84581da5bc1ff575e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/NES.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/NES.cs new file mode 100644 index 0000000..ecbfd37 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/NES.cs @@ -0,0 +1,1688 @@ +using Codice.CM.Client.Differences; +using Google.Protobuf.Collections; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Numerics; +using System.Text; +using UnityEngine.UIElements; +using UnityEngine; +using VirtualNes.Core.Debug; +using Unity.VisualScripting.Antlr3.Runtime.Tree; + +namespace VirtualNes.Core +{ + public class NES + { + public const int FETCH_CYCLES = 8; + + public CPU cpu; + public PPU ppu; + public APU apu; + public ROM rom; + public PAD pad; + public Mapper mapper; + public NesConfig nescfg; + + private List m_CheatCode = new List(); + private List m_GenieCode = new List(); + private bool m_bDiskThrottle; + private int m_CommandRequest; + private int m_nSnapNo; + private bool m_bNsfPlaying; + private bool m_bNsfInit; + private int m_nNsfSongNo; + private int m_nNsfSongMode; + private bool m_bMoviePlay; + private bool m_bMovieRec; + private Stream m_fpMovie; + private uint m_MovieControl; + private int m_MovieStepTotal; + private int m_MovieStep; + private bool m_bTapePlay; + private bool m_bTapeRec; + private Stream m_fpTape; + private double m_TapeCycles; + private byte m_TapeIn; + private byte m_TapeOut; + + // For Barcode + private bool m_bBarcode; + private byte m_BarcodeOut; + private byte m_BarcodePtr; + private int m_BarcodeCycles; + private byte[] m_BarcodeData = new byte[256]; + + // For Barcode + private bool m_bBarcode2; + private int m_Barcode2seq; + private int m_Barcode2ptr; + private int m_Barcode2cnt; + private byte m_Barcode2bit; + private byte[] m_Barcode2data = new byte[32]; + + private int m_TurboFileBank; + private int SAVERAM_SIZE; + private int nIRQtype; + private bool bFrameIRQ; + private bool bVideoMode; + private int NES_scanline; + private EnumRenderMethod RenderMethod; + private bool bZapper; + private int ZapperX; + private int ZapperY; + private long base_cycles; + private long emul_cycles; + + // For VS-Unisystem + byte m_VSDipValue; + VSDIPSWITCH[] m_VSDipTable; + + private byte[] m_PadImg = new byte[226] + { + 28, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, + 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x0F, + 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, + 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x0F, + 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + private byte[] m_KeyImg0 = new byte[6] + { + 2, 2, + 0x2A, 0x2A, + 0x2A, 0x2A, + }; + + private byte[] m_KeyImg1 = new byte[8] + { + 3, 3, + 0x2A, 0x2A, 0x2A, + 0x2A, 0x2A, 0x2A, + }; + + private byte[] m_KeyImg2 = new byte[18] + { + 4, 4, + 0xFF, 0x2A, 0x2A, 0xFF, + 0x2A, 0x2A, 0x2A, 0x2A, + 0x2A, 0x2A, 0x2A, 0x2A, + 0xFF, 0x2A, 0x2A, 0xFF, + }; + + private byte[] Font6x8 = new byte[768] + { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, + 0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x50,0xF8,0x50,0xF8,0x50,0x50,0x00, + 0x20,0x78,0xA0,0x70,0x28,0xF0,0x20,0x00,0x48,0xB0,0x50,0x20,0x50,0x68,0x90,0x00, + 0x40,0xA0,0xA8,0x68,0x90,0x90,0x68,0x00,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00, + 0x10,0x20,0x40,0x40,0x40,0x20,0x10,0x00,0x40,0x20,0x10,0x10,0x10,0x20,0x40,0x00, + 0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x20,0x40,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x08,0x10,0x10,0x20,0x40,0x40,0x80,0x00, + 0x70,0x88,0x98,0xA8,0xC8,0x88,0x70,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0xF8,0x00, + 0x70,0x88,0x08,0x30,0x40,0x80,0xF8,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00, + 0x30,0x50,0x90,0x90,0xF8,0x10,0x10,0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0xF0,0x00, + 0x70,0x88,0x80,0xF0,0x88,0x88,0x70,0x00,0xF8,0x08,0x10,0x10,0x20,0x20,0x20,0x00, + 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x70,0x88,0x88,0x78,0x08,0x88,0x70,0x00, + 0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x40,0x00, + 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0xF8,0x00,0xF8,0x00,0x00,0x00, + 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00, + 0x30,0x48,0x88,0x98,0xA8,0xA8,0x78,0x00,0x20,0x50,0x50,0x88,0xF8,0x88,0x88,0x00, + 0xF0,0x88,0x88,0xF0,0x88,0x88,0xF0,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00, + 0xF0,0x88,0x88,0x88,0x88,0x88,0xF0,0x00,0xF8,0x80,0x80,0xF0,0x80,0x80,0xF8,0x00, + 0xF8,0x80,0x80,0xF0,0x80,0x80,0x80,0x00,0x70,0x88,0x80,0xB8,0x88,0x88,0x70,0x00, + 0x88,0x88,0x88,0xF8,0x88,0x88,0x88,0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0xF8,0x00, + 0x38,0x08,0x08,0x08,0x08,0x88,0x70,0x00,0x88,0x88,0x90,0xE0,0x90,0x88,0x88,0x00, + 0x80,0x80,0x80,0x80,0x80,0x80,0xF8,0x00,0x88,0xD8,0xA8,0xA8,0xA8,0xA8,0xA8,0x00, + 0x88,0xC8,0xA8,0xA8,0xA8,0x98,0x88,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, + 0xF0,0x88,0x88,0xF0,0x80,0x80,0x80,0x00,0x70,0x88,0x88,0x88,0xA8,0x90,0x68,0x00, + 0xF0,0x88,0x88,0xF0,0x88,0x88,0x88,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00, + 0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, + 0x88,0x88,0x88,0x50,0x50,0x50,0x20,0x00,0x88,0xA8,0xA8,0xA8,0xA8,0xD8,0x88,0x00, + 0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00,0x88,0x88,0x88,0x70,0x20,0x20,0x20,0x00, + 0xF8,0x08,0x10,0x20,0x40,0x80,0xF8,0x00,0x70,0x40,0x40,0x40,0x40,0x40,0x70,0x00, + 0x88,0x50,0xF8,0x20,0xF8,0x20,0x20,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x70,0x00, + 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00, + 0x80,0xC0,0xE0,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0xF8,0x00, + 0x80,0x80,0x80,0xF0,0x88,0x88,0xF0,0x00,0x00,0x00,0x78,0x80,0x80,0x80,0x78,0x00, + 0x08,0x08,0x08,0x78,0x88,0x88,0x78,0x00,0x00,0x00,0x70,0x88,0xF8,0x80,0x78,0x00, + 0x18,0x20,0xF8,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x78,0x88,0x78,0x08,0xF0,0x00, + 0x80,0x80,0x80,0xF0,0x88,0x88,0x88,0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x00, + 0x20,0x00,0x20,0x20,0x20,0x20,0xC0,0x00,0x80,0x80,0x88,0x90,0xE0,0x90,0x88,0x00, + 0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x00,0x00,0x00,0xF0,0xA8,0xA8,0xA8,0xA8,0x00, + 0x00,0x00,0xF0,0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00, + 0x00,0x00,0xF0,0x88,0xF0,0x80,0x80,0x00,0x00,0x00,0x78,0x88,0x78,0x08,0x08,0x00, + 0x00,0x00,0xB8,0xC0,0x80,0x80,0x80,0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xF0,0x00, + 0x20,0x20,0xF8,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x70,0x00, + 0x00,0x00,0x88,0x88,0x50,0x50,0x20,0x00,0x00,0x00,0x88,0xA8,0xA8,0xD8,0x88,0x00, + 0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,0x00,0x88,0x88,0x78,0x08,0xF0,0x00, + 0x00,0x00,0xF8,0x08,0x70,0x80,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + }; + + public NES(string fname) + { + Debuger.Log("VirtuaNES - CSharpCore\n"); + + m_bDiskThrottle = false; + m_CommandRequest = 0; + + m_nSnapNo = 0; + + m_bNsfPlaying = false; + + m_bMoviePlay = m_bMovieRec = false; + m_fpMovie = null; + + m_bTapePlay = m_bTapeRec = false; + m_fpTape = null; + m_TapeCycles = 0d; + m_TapeIn = m_TapeOut = 0; + + m_bBarcode2 = false; + + m_TurboFileBank = 0; + + cpu = null; + ppu = null; + apu = null; + rom = null; + pad = null; + mapper = null; + + SAVERAM_SIZE = 8 * 1024; + + nIRQtype = 0; + + bFrameIRQ = true; + + bVideoMode = false; + + nescfg = NesConfig.NESCONFIG_NTSC; + + CheatInitial(); + + try + { + Debuger.Log("Allocating CPU..."); + cpu = new CPU(this); + + Debuger.Log("Allocating PPU..."); + ppu = new PPU(this); + + var screenBuffer = new byte[PPU.SCREEN_WIDTH * PPU.SCREEN_HEIGHT]; + var colormode = new byte[PPU.SCREEN_HEIGHT]; + + ppu.SetScreenPtr(screenBuffer, colormode); + + Debuger.Log("Allocating APU..."); + apu = new APU(this); + + Debuger.Log("Allocating PAD..."); + pad = new PAD(this); + + Debuger.Log("Loading ROM Image..."); + rom = new ROM(fname); + + mapper = Mapper.CreateMapper(this, rom.GetMapperNo()); + + Debuger.Log("OK"); + + Debuger.Log($"{rom.GetRomName()}"); + Debuger.Log($"Mapper : #{rom.GetMapperNo():D3}"); + Debuger.Log($"PROM-CRC : #{rom.GetPROM_CRC():X2}"); + Debuger.Log($"VROM-CRC : #{rom.GetVROM_CRC():X2}"); + Debuger.Log($"PRG SIZE : {16 * rom.GetPROM_SIZE():4:0000}K"); + Debuger.Log($"CHR SIZE : {8 * rom.GetVROM_SIZE():4:0000}K"); + + Debuger.Log($"V MIRROR :{rom.IsVMIRROR()}"); + Debuger.Log($"4 SCREEN :{rom.Is4SCREEN()}"); + Debuger.Log($"SAVE RAM :{rom.IsSAVERAM()}"); + Debuger.Log($"TRAINER :{rom.IsTRAINER()}"); + Debuger.Log($"VS-Unisystem :{rom.IsVSUNISYSTEM()}"); + + NesSub_MemoryInitial(); + LoadSRAM(); + LoadDISK(); + + { + // Pad¥¯¥é¥¹ÄÚ¤À¤È³õÆÚ»¯¥¿¥¤¥ß¥ó¥°¤¬ßW¤¤¤Î¤Ç¤³¤³¤Ç + uint crc = rom.GetPROM_CRC(); + if ( + crc == 0xe792de94 // Best Play - Pro Yakyuu (New) (J) + || crc == 0xf79d684a // Best Play - Pro Yakyuu (Old) (J) + || crc == 0xc2ef3422 // Best Play - Pro Yakyuu 2 (J) + || crc == 0x974e8840 // Best Play - Pro Yakyuu '90 (J) + || crc == 0xb8747abf // Best Play - Pro Yakyuu Special (J) + || crc == 0x9fa1c11f // Castle Excellent (J) + || crc == 0x0b0d4d1b // Derby Stallion - Zenkoku Ban (J) + || crc == 0x728c3d98 // Downtown - Nekketsu Monogatari (J) + || crc == 0xd68a6f33 // Dungeon Kid (J) + || crc == 0x3a51eb04 // Fleet Commander (J) + || crc == 0x7c46998b // Haja no Fuuin (J) + || crc == 0x7e5d2f1a // Itadaki Street - Watashi no Mise ni Yottette (J) + || crc == 0xcee5857b // Ninjara Hoi! (J) + || crc == 0x50ec5e8b // Wizardry - Legacy of Llylgamyn (J) + || crc == 0x343e9146 // Wizardry - Proving Grounds of the Mad Overlord (J) + || crc == 0x33d07e45) + { // Wizardry - The Knight of Diamonds (J) + pad.SetExController(EXCONTROLLER.EXCONTROLLER_TURBOFILE); + } + } + + LoadTurboFile(); + + // VS-Unisystem¤Î¥Ç¥Õ¥©¥ë¥ÈÔO¶¨ + if (rom.IsVSUNISYSTEM()) + { + uint crc = rom.GetPROM_CRC(); + + m_VSDipValue = 0; + m_VSDipTable = VsUnisystem.vsdip_default; + } + + Reset(); + + // ¥²©`¥à¹ÌÓФΥǥե©¥ë¥È¥ª¥×¥·¥ç¥ó¤òÔO¶¨(ÔO¶¨‘ø¤¹•r¤Ëʹ¤¦žé) + GameOption.defRenderMethod = (int)GetRenderMethod(); + GameOption.defIRQtype = GetIrqType(); + GameOption.defFrameIRQ = GetFrameIRQmode(); + GameOption.defVideoMode = GetVideoMode(); + + // ÔO¶¨¤ò¥í©`¥É¤·¤ÆÔO¶¨¤¹¤ë(¥¨¥ó¥È¥ê¤¬Ÿo¤±¤ì¤Ð¥Ç¥Õ¥©¥ë¥È¤¬Èë¤ë) + if (rom.GetMapperNo() != 20) + { + GameOption.Load(rom.GetPROM_CRC()); + } + else + { + GameOption.Load(rom.GetGameID(), rom.GetMakerID()); + } + + SetRenderMethod((EnumRenderMethod)GameOption.nRenderMethod); + SetIrqType((IRQMETHOD)GameOption.nIRQtype); + SetFrameIRQmode(GameOption.bFrameIRQ); + SetVideoMode(GameOption.bVideoMode); + } + catch (Exception ex) + { + Debuger.LogError(ex.ToString()); + throw ex; + } + } + + internal int GetIrqType() + { + return nIRQtype; + } + + private void LoadTurboFile() + { + MemoryUtility.ZEROMEMORY(MMU.ERAM, MMU.ERAM.Length); + + if (pad.GetExController() != (int)EXCONTROLLER.EXCONTROLLER_TURBOFILE) + return; + + var fp = Supporter.OpenFile(Supporter.Config.path.szSavePath, "TurboFile.vtf"); + try + { + if (fp == null) + { + // xxx ¥Õ¥¡¥¤¥ë¤òé_¤±¤Þ¤»¤ó + throw new Exception($"Can Not Open File [TurboFile.vtf]"); + } + + long size = fp.Length; + // ¥Õ¥¡¥¤¥ë¥µ¥¤¥ºÈ¡µÃ + if (size > 32 * 1024) + { + size = 32 * 1024; + } + + fp.Read(MMU.ERAM, 0, MMU.ERAM.Length); + fp.Close(); + } + catch (Exception ex) + { + fp?.Close(); + Debuger.LogError($"Loading TurboFile Error.\n{ex}"); + } + } + + private void LoadDISK() + { + //todo : ´Åµú»ú¶ÁÈ¡Ö§³Ö + } + + private void LoadSRAM() + { + if (rom.IsNSF()) + return; + + MemoryUtility.ZEROMEMORY(MMU.WRAM, MMU.WRAM.Length); + + if (!rom.IsSAVERAM()) + return; + + var saveFileDir = Supporter.Config.path.szSavePath; + var saveFileName = $"{rom.GetRomName()}.sav"; + + var fp = Supporter.OpenFile(saveFileDir, saveFileName); + + try + { + if (fp == null) + { + throw new Exception("not find ram file to read"); + } + + Debuger.Log("Loading SAVERAM..."); + + int size = (int)fp.Length; + if (size <= 128 * 1024) + { + fp.Read(MMU.WRAM, 0, size); + } + Debuger.Log("OK."); + fp.Close(); + } + catch (Exception ex) + { + fp?.Close(); + fp = null; + } + } + + private void NesSub_MemoryInitial() + { + int i; + + // ƒƒ‚ƒŠƒNƒŠƒA + MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length); + MemoryUtility.ZEROMEMORY(MMU.WRAM, MMU.WRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.DRAM, MMU.DRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.ERAM, MMU.ERAM.Length); + MemoryUtility.ZEROMEMORY(MMU.XRAM, MMU.XRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.CRAM, MMU.CRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.VRAM, MMU.VRAM.Length); + + MemoryUtility.ZEROMEMORY(MMU.SPRAM, MMU.SPRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.BGPAL, MMU.BGPAL.Length); + MemoryUtility.ZEROMEMORY(MMU.SPPAL, MMU.SPPAL.Length); + + MemoryUtility.ZEROMEMORY(MMU.CPUREG, MMU.CPUREG.Length); + MemoryUtility.ZEROMEMORY(MMU.PPUREG, MMU.PPUREG.Length); + + MMU.FrameIRQ = 0xC0; + + MMU.PROM = MMU.VROM = null; + + // 0 œŽZ–hŽ~‘Îô + MMU.PROM_8K_SIZE = MMU.PROM_16K_SIZE = MMU.PROM_32K_SIZE = 1; + MMU.VROM_1K_SIZE = MMU.VROM_2K_SIZE = MMU.VROM_4K_SIZE = MMU.VROM_8K_SIZE = 1; + + // ƒfƒtƒHƒ‹ƒgƒoƒ“ƒNÝ’è + for (i = 0; i < 8; i++) + { + MMU.CPU_MEM_BANK[i] = null; + MMU.CPU_MEM_TYPE[i] = MMU.BANKTYPE_ROM; + MMU.CPU_MEM_PAGE[i] = 0; + } + + // “à‘ŸRAM/WRAM + MMU.SetPROM_Bank(0, MMU.RAM, MMU.BANKTYPE_RAM); + MMU.SetPROM_Bank(3, MMU.WRAM, MMU.BANKTYPE_RAM); + + // ƒ_ƒ~[ + MMU.SetPROM_Bank(1, MMU.XRAM, MMU.BANKTYPE_ROM); + MMU.SetPROM_Bank(2, MMU.XRAM, MMU.BANKTYPE_ROM); + + for (i = 0; i < 8; i++) + { + MMU.CRAM_USED[i] = 0; + } + } + + public void Command(NESCOMMAND cmd) + { + CommandParam(cmd, 0); + } + + public bool CommandParam(NESCOMMAND cmd, int param) + { + switch (cmd) + { + case NESCOMMAND.NESCMD_NONE: break; + case NESCOMMAND.NESCMD_HWRESET: + Reset(); + m_CommandRequest = (int)cmd; + break; + case NESCOMMAND.NESCMD_SWRESET: + SoftReset(); + m_CommandRequest = (int)cmd; + break; + default: + throw new NotImplementedException($"{cmd} not impl right now"); + } + + return true; + } + + public void CheatInitial() + { + m_CheatCode.Clear(); + } + + private int FrameCount = 0; + public void EmulateFrame(bool bDraw) + { + FrameCount++; + + int scanline = 0; + if (rom.IsNSF()) + { + EmulateNSF(); + return; + } + + CheatCodeProcess(); + + NES_scanline = scanline; + bool NotTile = RenderMethod != EnumRenderMethod.TILE_RENDER; + + if (RenderMethod != EnumRenderMethod.TILE_RENDER) + { + bZapper = false; + while (true) + { + ppu.SetRenderScanline(scanline); + + if (scanline == 0) + { + if (RenderMethod < EnumRenderMethod.POST_RENDER) + { + EmulationCPU(nescfg.ScanlineCycles); + ppu.FrameStart(); + ppu.ScanlineNext(); + mapper.HSync(scanline); + ppu.ScanlineStart(); + } + else + { + EmulationCPU(nescfg.HDrawCycles); + ppu.FrameStart(); + ppu.ScanlineNext(); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 32); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + } + else if (scanline < 240) + { + if (RenderMethod < EnumRenderMethod.POST_RENDER) + { + if (RenderMethod == EnumRenderMethod.POST_ALL_RENDER) + EmulationCPU(nescfg.ScanlineCycles); + if (bDraw) + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + } + else + { + if (pad.IsZapperMode() && scanline == ZapperY) + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + } + else + { + if (!ppu.IsSprite0(scanline)) + { + ppu.DummyScanline(scanline); + } + else + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + } + } + } + ppu.ScanlineNext(); // ‚±‚ê‚̈ʒu‚щƒXƒ^[Œn‚͉æ–Ê‚ªˆá‚¤ + if (RenderMethod == EnumRenderMethod.PRE_ALL_RENDER) + EmulationCPU(nescfg.ScanlineCycles); + + mapper.HSync(scanline); + ppu.ScanlineStart(); + } + else + { + if (RenderMethod == EnumRenderMethod.POST_RENDER) + EmulationCPU(nescfg.HDrawCycles); + if (bDraw) + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + } + else + { + if (pad.IsZapperMode() && scanline == ZapperY) + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + } + else + { + if (!ppu.IsSprite0(scanline)) + { + ppu.DummyScanline(scanline); + } + else + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + } + } + } + if (RenderMethod == EnumRenderMethod.PRE_RENDER) + EmulationCPU(nescfg.HDrawCycles); + ppu.ScanlineNext(); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 32); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + } + else if (scanline == 240) + { + mapper.VSync(); + if (RenderMethod < EnumRenderMethod.POST_RENDER) + { + EmulationCPU(nescfg.ScanlineCycles); + mapper.HSync(scanline); + } + else + { + EmulationCPU(nescfg.HDrawCycles); + mapper.HSync(scanline); + EmulationCPU(nescfg.HBlankCycles); + } + } + else if (scanline <= nescfg.TotalScanlines - 1) + { + pad.VSync(); + + // VBLANKŠúŠÔ + if (scanline == nescfg.TotalScanlines - 1) + { + ppu.VBlankEnd(); + } + if (RenderMethod < EnumRenderMethod.POST_RENDER) + { + if (scanline == 241) + { + ppu.VBlankStart(); + if ((MMU.PPUREG[0] & PPU.PPU_VBLANK_BIT) != 0) + { + cpu.NMI(); + } + } + EmulationCPU(nescfg.ScanlineCycles); + mapper.HSync(scanline); + } + else + { + if (scanline == 241) + { + ppu.VBlankStart(); + if ((MMU.PPUREG[0] & PPU.PPU_VBLANK_BIT) != 0) + { + cpu.NMI(); + } + } + EmulationCPU(nescfg.HDrawCycles); + mapper.HSync(scanline); + EmulationCPU(nescfg.HBlankCycles); + } + + if (scanline == nescfg.TotalScanlines - 1) + { + break; + } + } + if (pad.IsZapperMode()) + { + if (scanline == ZapperY) + bZapper = true; + else + bZapper = false; + } + + scanline++; + NES_scanline = scanline; + } + } + else + { + bZapper = false; + while (true) + { + ppu.SetRenderScanline(scanline); + + if (scanline == 0) + { + // ƒ_ƒ~[ƒXƒLƒƒƒ“ƒ‰ƒCƒ“ + // H-Draw (4fetches*32) + EmulationCPU(FETCH_CYCLES * 128); + ppu.FrameStart(); + ppu.ScanlineNext(); + EmulationCPU(FETCH_CYCLES * 10); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 22); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + else if (scanline < 240) + { + // ƒXƒNƒŠ[ƒ“•`‰æ(Scanline 1`239) + if (bDraw) + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + ppu.ScanlineNext(); + EmulationCPU(FETCH_CYCLES * 10); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 22); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + else + { + if (pad.IsZapperMode() && scanline == ZapperY) + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + ppu.ScanlineNext(); + EmulationCPU(FETCH_CYCLES * 10); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 22); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + else + { + if (!ppu.IsSprite0(scanline)) + { + // H-Draw (4fetches*32) + EmulationCPU(FETCH_CYCLES * 128); + ppu.DummyScanline(scanline); + ppu.ScanlineNext(); + EmulationCPU(FETCH_CYCLES * 10); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 22); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + else + { + ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip); + ppu.ScanlineNext(); + EmulationCPU(FETCH_CYCLES * 10); + mapper.HSync(scanline); + EmulationCPU(FETCH_CYCLES * 22); + ppu.ScanlineStart(); + EmulationCPU(FETCH_CYCLES * 10 + nescfg.ScanlineEndCycles); + } + } + } + } + else if (scanline == 240) + { + // ƒ_ƒ~[ƒXƒLƒƒƒ“ƒ‰ƒCƒ“ (Scanline 240) + mapper.VSync(); + + EmulationCPU(nescfg.HDrawCycles); + // H-Sync + mapper.HSync(scanline); + + EmulationCPU(nescfg.HBlankCycles); + } + else if (scanline <= nescfg.TotalScanlines - 1) + { + pad.VSync(); + + // VBLANKŠúŠÔ + if (scanline == nescfg.TotalScanlines - 1) + { + ppu.VBlankEnd(); + } + if (scanline == 241) + { + ppu.VBlankStart(); + if ((MMU.PPUREG[0] & PPU.PPU_VBLANK_BIT) != 0) + { + cpu.NMI(); + } + } + EmulationCPU(nescfg.HDrawCycles); + + // H-Sync + mapper.HSync(scanline); + + EmulationCPU(nescfg.HBlankCycles); + + if (scanline == nescfg.TotalScanlines - 1) + { + break; + } + } + if (pad.IsZapperMode()) + { + if (scanline == ZapperY) + bZapper = true; + else + bZapper = false; + } + + scanline++; + NES_scanline = scanline; + } + } + + if (bDraw) + { + DrawPad(); + } + } + + private void DrawPad() + { + if (m_bMoviePlay) + { + int offset_h = 12; + int offset_v = Supporter.Config.graphics.bAllLine ? (240 - 18) : (240 - 22); + + if (Supporter.Config.movie.bPadDisplay) + { + uint dwData = pad.GetSyncData(); + for (int i = 0; i < 4; i++) + { + byte Data = (byte)(dwData >> (i * 8)); + if ((m_MovieControl & (1 << i)) != 0) + { + DrawBitmap(offset_h, offset_v, m_PadImg); + + // KEY + if ((Data & (1 << 4)) != 0) DrawBitmap(offset_h + 3, offset_v + 1, m_KeyImg0); // U + if ((Data & (1 << 5)) != 0) DrawBitmap(offset_h + 3, offset_v + 5, m_KeyImg0); // D + if ((Data & (1 << 6)) != 0) DrawBitmap(offset_h + 1, offset_v + 3, m_KeyImg0); // L + if ((Data & (1 << 7)) != 0) DrawBitmap(offset_h + 5, offset_v + 3, m_KeyImg0); // R + + // START,SELECT + if ((Data & (1 << 2)) != 0) DrawBitmap(offset_h + 9, offset_v + 5, m_KeyImg1); // SELECT + if ((Data & (1 << 3)) != 0) DrawBitmap(offset_h + 13, offset_v + 5, m_KeyImg1); // START + + // A,B + if ((Data & (1 << 0)) != 0) DrawBitmap(offset_h + 23, offset_v + 3, m_KeyImg2); // A + if ((Data & (1 << 1)) != 0) DrawBitmap(offset_h + 18, offset_v + 3, m_KeyImg2); // B + + offset_h += 30; + } + } + } + + if (Supporter.Config.movie.bTimeDisplay) + { + // Time display + int t = m_MovieStep; + int h = t / 216000; + t -= h * 216000; + int m = t / 3600; + t -= m * 3600; + int s = t / 60; + t -= s * 60; + + string szTemp = $"{h:00}:{m:00}:{s:00}.{t * 100 / 60:00}"; + DrawString(256 - 80 + 0, offset_v - 1, szTemp, 0x1F); + DrawString(256 - 80 + 0, offset_v + 1, szTemp, 0x1F); + DrawString(256 - 80 - 1, offset_v + 0, szTemp, 0x1F); + DrawString(256 - 80 + 1, offset_v + 0, szTemp, 0x1F); + DrawString(256 - 80, offset_v, szTemp, 0x30); + } + } + } + + internal void DrawString(int x, int y, string str, byte col) + { + foreach (var @char in str) + { + DrawFont(x, y, (byte)@char, col); + x += 6; + } + } + + internal void DrawFont(int x, int y, byte chr, byte col) + { + int i; + int pFnt; + int pPtr; + var Scn = ppu.GetScreenPtr(); + int pScn = 8; + + + if (chr < 0x20 || chr > 0x7F) + return; + chr -= 0x20; + pFnt = chr * 8; + pPtr = pScn + (256 + 16) * y + x; + for (i = 0; i < 8; i++) + { + if ((Font6x8[pFnt + i] & 0x80) != 0) Scn[pPtr + 0] = col; + if ((Font6x8[pFnt + i] & 0x40) != 0) Scn[pPtr + 1] = col; + if ((Font6x8[pFnt + i] & 0x20) != 0) Scn[pPtr + 2] = col; + if ((Font6x8[pFnt + i] & 0x10) != 0) Scn[pPtr + 3] = col; + if ((Font6x8[pFnt + i] & 0x08) != 0) Scn[pPtr + 4] = col; + if ((Font6x8[pFnt + i] & 0x04) != 0) Scn[pPtr + 5] = col; + pPtr += (256 + 16); + } + } + + private void DrawBitmap(int x, int y, byte[] bitMap) + { + int i, j; + int h, v; + var Scn = ppu.GetScreenPtr(); + int pScn = 8 + (256 + 16) * y + x; + int pPtr; + + int lpBitmap = 0; + h = bitMap[lpBitmap++]; + v = bitMap[lpBitmap++]; + + for (j = 0; j < v; j++) + { + pPtr = pScn; + for (i = 0; i < h; i++) + { + if (bitMap[lpBitmap] != 0xFF) + { + Scn[pPtr] = bitMap[lpBitmap]; + } + lpBitmap++; + pPtr++; + } + pScn += 256 + 16; + } + } + + int CPU_CALL_COUNT = 0; + internal void EmulationCPU(int basecycles) + { + int cycles; + + base_cycles += basecycles; + cycles = (int)((base_cycles / 12) - emul_cycles); + + if (cycles > 0) + { + var cycleAdd = cpu.EXEC(cycles); + emul_cycles += cycleAdd; + } + + CPU_CALL_COUNT++; + } + + internal void Reset() + { + SaveSRAM(); + SaveDISK(); + SaveTurboFile(); + + // RAM Clear + MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length); + if (rom.GetPROM_CRC() == 0x29401686) + { // Minna no Taabou no Nakayoshi Dai Sakusen(J) + MemoryUtility.memset(MMU.RAM, 0xFF, MMU.RAM.Length); + } + + // RAM set + if (!rom.IsSAVERAM() && rom.GetMapperNo() != 20) + { + MemoryUtility.memset(MMU.WRAM, 0xFF, MMU.WRAM.Length); + } + + MemoryUtility.ZEROMEMORY(MMU.CRAM, MMU.CRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.VRAM, MMU.VRAM.Length); + + MemoryUtility.ZEROMEMORY(MMU.SPRAM, MMU.SPRAM.Length); + MemoryUtility.ZEROMEMORY(MMU.BGPAL, MMU.BGPAL.Length); + MemoryUtility.ZEROMEMORY(MMU.SPPAL, MMU.SPPAL.Length); + + MemoryUtility.ZEROMEMORY(MMU.CPUREG, MMU.CPUREG.Length); + MemoryUtility.ZEROMEMORY(MMU.PPUREG, MMU.PPUREG.Length); + + m_bDiskThrottle = false; + + SetRenderMethod(EnumRenderMethod.PRE_RENDER); + + if (rom.IsPAL()) + { + SetVideoMode(true); + } + + MMU.PROM = rom.GetPROM(); + MMU.VROM = rom.GetVROM(); + + MMU.PROM_8K_SIZE = rom.GetPROM_SIZE() * 2; + MMU.PROM_16K_SIZE = rom.GetPROM_SIZE(); + MMU.PROM_32K_SIZE = rom.GetPROM_SIZE() / 2; + + MMU.VROM_1K_SIZE = rom.GetVROM_SIZE() * 8; + MMU.VROM_2K_SIZE = rom.GetVROM_SIZE() * 4; + MMU.VROM_4K_SIZE = rom.GetVROM_SIZE() * 2; + MMU.VROM_8K_SIZE = rom.GetVROM_SIZE(); + + // ƒfƒtƒHƒ‹ƒgƒoƒ“ƒN + if (MMU.VROM_8K_SIZE != 0) + { + MMU.SetVROM_8K_Bank(0); + } + else + { + MMU.SetCRAM_8K_Bank(0); + } + + // ƒ~ƒ‰[ + if (rom.Is4SCREEN()) + { + MMU.SetVRAM_Mirror(MMU.VRAM_MIRROR4); + } + else if (rom.IsVMIRROR()) + { + MMU.SetVRAM_Mirror(MMU.VRAM_VMIRROR); + } + else + { + MMU.SetVRAM_Mirror(MMU.VRAM_HMIRROR); + } + + apu.SelectExSound(0); + + ppu.Reset(); + mapper.Reset(); + + // Trainer + if (rom.IsTRAINER()) + { + Array.Copy(rom.GetTRAINER(), 0, MMU.WRAM, 0x1000, 512); + } + + pad.Reset(); + cpu.Reset(); + apu.Reset(); + + if (rom.IsNSF()) + { + mapper.Reset(); + } + + base_cycles = emul_cycles = 0; + } + + internal void SetVideoMode(bool bMode) + { + bVideoMode = bMode; + if (!bVideoMode) + { + nescfg = NesConfig.NESCONFIG_NTSC; + } + else + { + nescfg = NesConfig.NESCONFIG_PAL; + } + apu.SoundSetup(); + } + + + + internal void SoftReset() + { + pad.Reset(); + cpu.Reset(); + apu.Reset(); + + if (rom.IsNSF()) + { + mapper.Reset(); + } + + m_bDiskThrottle = false; + + base_cycles = emul_cycles = 0; + } + + internal void EmulateNSF() + { + R6502 reg = null; + + ppu.Reset(); + mapper.VSync(); + + //DEBUGOUT( "Frame\n" ); + + if (m_bNsfPlaying) + { + if (m_bNsfInit) + { + MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length); + if ((rom.GetNsfHeader().ExtraChipSelect & 0x04) == 0) + { + MemoryUtility.ZEROMEMORY(MMU.RAM, 0x2000); + } + + apu.Reset(); + apu.Write(0x4015, 0x0F); + apu.Write(0x4017, 0xC0); + apu.ExWrite(0x4080, 0x80); // FDS Volume 0 + apu.ExWrite(0x408A, 0xE8); // FDS Envelope Speed + + cpu.GetContext(ref reg); + reg.PC = 0x4710; // Init Address + reg.A = (byte)m_nNsfSongNo; + reg.X = (byte)m_nNsfSongMode; + reg.Y = 0; + reg.S = 0xFF; + reg.P = CPU.Z_FLAG | CPU.R_FLAG | CPU.I_FLAG; + + // ˆÀ‘S‘Îô‚ðŒ“‚Ë‚Ä‚ ‚¦‚ă‹[ƒv‚É(1•b•ª) + for (int i = 0; i < nescfg.TotalScanlines * 60; i++) + { + EmulationCPU(nescfg.ScanlineCycles); + cpu.GetContext(ref reg); + + // –³ŒÀƒ‹[ƒv‚É“ü‚Á‚½‚±‚Æ‚ðŠm”F‚µ‚½‚甲‚¯‚é + if (reg.PC == 0x4700) + { + break; + } + } + + m_bNsfInit = false; + } + + cpu.GetContext(ref reg); + // –³ŒÀƒ‹[ƒv‚É“ü‚Á‚Ä‚¢‚½‚çÄÝ’è‚·‚é + if (reg.PC == 0x4700) + { + reg.PC = 0x4720; // Play Address + reg.A = 0; + reg.S = 0xFF; + } + + for (int i = 0; i < nescfg.TotalScanlines; i++) + { + EmulationCPU(nescfg.ScanlineCycles); + } + } + else + { + cpu.GetContext(ref reg); + reg.PC = 0x4700; // –³ŒÀƒ‹[ƒv + reg.S = 0xFF; + + EmulationCPU(nescfg.ScanlineCycles * nescfg.TotalScanlines); + } + } + + internal void CheatCodeProcess() + { + foreach (var it in m_CheatCode) + { + if ((it.enable & CHEATCODE.CHEAT_ENABLE) == 0) + continue; + + switch (it.type) + { + case CHEATCODE.CHEAT_TYPE_ALWAYS: + CheatWrite(it.length, it.address, it.data); + break; + case CHEATCODE.CHEAT_TYPE_ONCE: + CheatWrite(it.length, it.address, it.data); + it.enable = 0; + break; + case CHEATCODE.CHEAT_TYPE_GREATER: + if (CheatRead(it.length, it.address) > it.data) + { + CheatWrite(it.length, it.address, it.data); + } + break; + case CHEATCODE.CHEAT_TYPE_LESS: + if (CheatRead(it.length, it.address) < it.data) + { + CheatWrite(it.length, it.address, it.data); + } + break; + } + } + } + + private uint CheatRead(byte length, ushort addr) + { + uint data = 0; + for (int i = 0; i <= length; i++) + { + data |= (uint)(Read((ushort)(addr + i)) * (1 << (i * 8))); + } + + return data; + } + + private void CheatWrite(int length, ushort addr, uint data) + { + for (int i = 0; i <= length; i++) + { + Write((ushort)(addr + i), (byte)(data & 0xFF)); + data >>= 8; + } + } + + public void Dispose() + { + cpu?.Dispose(); + ppu?.Dispose(); + apu?.Dispose(); + pad?.Dispose(); + rom?.Dispose(); + } + + private void SaveSRAM() + { + int i; + if (rom.IsNSF()) return; + if (rom.IsSAVERAM()) return; + + for (i = 0; i < SAVERAM_SIZE; i++) + { + if (MMU.WRAM[i] != 0x00) + break; + } + + if (i < SAVERAM_SIZE) + { + var romName = rom.GetRomName(); + + Debuger.Log($"Saving SAVERAM...[{romName}]"); + + Supporter.SaveSRAMToFile(MMU.WRAM, romName); + } + } + + private void SaveDISK() + { + if (rom.GetMapperNo() != 20) + return; + + int i = 0; + Stream fp = null; + DISKFILEHDR ifh; + byte[] lpDisk = rom.GetPROM(); + byte[] lpWrite = rom.GetDISK(); + long DiskSize = 16 + 65500 * rom.GetDiskNo(); + ulong data; + + try + { + ifh = new DISKFILEHDR(); + ifh.ID = ASCIIEncoding.ASCII.GetBytes("VirtuaNES DI"); + ifh.BlockVersion = 0x0210; + ifh.ProgID = rom.GetGameID(); + ifh.MakerID = (ushort)rom.GetMakerID(); + ifh.DiskNo = (ushort)rom.GetDiskNo(); + + for (i = 16; i < DiskSize; i++) + { + if (lpWrite[i] > 0) + ifh.DifferentSize++; + } + + if (ifh.DifferentSize == 0) + return; + + List contents = new List(); + contents.AddRange(ifh.ToBytes()); + + for (i = 16; i < DiskSize; i++) + { + if (lpWrite[i] > 0) + { + data = (ulong)(i & 0x00FFFFFF); + data |= ((ulong)lpDisk[i] & 0xFF) << 24; + contents.AddRange(BitConverter.GetBytes(data)); + } + } + + Supporter.SaveDISKToFile(contents.ToArray(), rom.GetRomName()); + } + catch (Exception ex) + { + Debuger.LogError(ex.ToString()); + } + } + + private void SaveTurboFile() + { + int i; + + if (pad.GetExController() != (int)EXCONTROLLER.EXCONTROLLER_TURBOFILE) + return; + + for (i = 0; i < MMU.ERAM.Length; i++) + { + if (MMU.ERAM[i] != 0x00) + break; + } + + if (i < MMU.ERAM.Length) + { + Debuger.Log("Saving TURBOFILE..."); + + Supporter.SaveFile(MMU.ERAM, Supporter.Config.path.szSavePath, "TurboFile.vtf"); + } + } + + internal void Clock(int cycles) + { + Tape(cycles); + Barcode(cycles); + } + + private void Barcode(int cycles) + { + if (m_bBarcode) + { + m_BarcodeCycles += cycles; + if (m_BarcodeCycles > 1000) + { + m_BarcodeCycles = 0; + // ’âŽ~H + if (m_BarcodeData[m_BarcodePtr] != 0xFF) + { + m_BarcodeOut = m_BarcodeData[m_BarcodePtr++]; + } + else + { + m_bBarcode = false; + m_BarcodeOut = 0; + Debuger.Log("Barcode data trasnfer complete!!"); + + if (!(IsTapePlay() || IsTapeRec())) + { + cpu.SetClockProcess(false); + } + } + } + } + } + + public bool IsTapeRec() + { + return m_bTapeRec; + } + + public bool IsTapePlay() + { + return m_bTapePlay; + } + + internal void Tape(int cycles) + { + if (!(IsTapePlay() || IsTapeRec())) + { + return; + } + + if ((m_TapeCycles -= (double)cycles) > 0) + return; + + m_TapeCycles += (nescfg.CpuClock / 32000.0); + // m_TapeCycles += (nescfg->CpuClock / 22050.0); // ’x‚·‚¬‚ă_ƒ‚Á‚Û‚¢ + + if (m_bTapePlay) + { + int data = m_fpTape.ReadByte(); + if (data != -1) //EOF + { + if ((data & 0xFF) >= 0x8C) + { + m_TapeOut = 0x02; + } + else + if ((data & 0xFF) <= 0x74) + { + m_TapeOut = 0x00; + } + } + else + { + TapeStop(); + } + } + if (m_bTapeRec) + { + m_fpTape.WriteByte((m_TapeIn & 7) == 7 ? (byte)0x90 : (byte)0x70); + } + } + + private void TapeStop() + { + if (!m_bBarcode) + { + cpu.SetClockProcess(false); + } + + m_bTapePlay = m_bTapeRec = false; + m_fpTape?.Dispose(); + m_fpTape = null; + } + + internal byte Read(ushort addr) + { + switch (addr >> 13) + { + case 0x00: // $0000-$1FFF + return MMU.RAM[addr & 0x07FF]; + case 0x01: // $2000-$3FFF + return ppu.Read((ushort)(addr & 0xE007)); + case 0x02: // $4000-$5FFF + if (addr < 0x4100) + { + return ReadReg(addr); + } + else + { + return mapper.ReadLow(addr); + } + case 0x03: // $6000-$7FFF + return mapper.ReadLow(addr); + case 0x04: // $8000-$9FFF + case 0x05: // $A000-$BFFF + case 0x06: // $C000-$DFFF + case 0x07: // $E000-$FFFF + return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + + return 0x00; // Warning—\–h + } + + private byte ReadReg(ushort addr) + { + switch (addr & 0xFF) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + return apu.Read(addr); + case 0x15: + return apu.Read(addr); + case 0x14: + return (byte)(addr & 0xFF); + case 0x16: + if (rom.IsVSUNISYSTEM()) + { + return pad.Read(addr); + } + else + { + return (byte)(pad.Read(addr) | 0x40 | m_TapeOut); + } + case 0x17: + if (rom.IsVSUNISYSTEM()) + { + return pad.Read(addr); + } + else + { + return (byte)(pad.Read(addr) | apu.Read(addr)); + } + default: + return mapper.ExRead(addr); + } + } + + internal byte Barcode2() + { + byte ret = 0x00; + + if (!m_bBarcode2 || m_Barcode2seq < 0) + return ret; + + switch (m_Barcode2seq) + { + case 0: + m_Barcode2seq++; + m_Barcode2ptr = 0; + ret = 0x04; // d3 + break; + + case 1: + m_Barcode2seq++; + m_Barcode2bit = m_Barcode2data[m_Barcode2ptr]; + m_Barcode2cnt = 0; + ret = 0x04; // d3 + break; + + case 2: + ret = (byte)((m_Barcode2bit & 0x01) != 0 ? 0x00 : 0x04); // Bit rev. + m_Barcode2bit >>= 1; + if (++m_Barcode2cnt > 7) + { + m_Barcode2seq++; + } + break; + case 3: + if (++m_Barcode2ptr > 19) + { + m_bBarcode2 = false; + m_Barcode2seq = -1; + } + else + { + m_Barcode2seq = 1; + } + break; + default: + break; + } + + return ret; + } + public void SetRenderMethod(EnumRenderMethod type) + { + RenderMethod = type; + } + internal void Write(ushort addr, byte data) + { + switch (addr >> 13) + { + case 0x00: // $0000-$1FFF + MMU.RAM[addr & 0x07FF] = data; + break; + case 0x01: // $2000-$3FFF + if (!rom.IsNSF()) + { + ppu.Write((ushort)(addr & 0xE007), data); + } + break; + case 0x02: // $4000-$5FFF + if (addr < 0x4100) + { + WriteReg(addr, data); + } + else + { + mapper.WriteLow(addr, data); + } + break; + case 0x03: // $6000-$7FFF + mapper.WriteLow(addr, data); + break; + case 0x04: // $8000-$9FFF + case 0x05: // $A000-$BFFF + case 0x06: // $C000-$DFFF + case 0x07: // $E000-$FFFF + mapper.Write(addr, data); + + GenieCodeProcess(); + break; + } + } + + private void GenieCodeProcess() + { + ushort addr; + + for (int i = 0; i < m_GenieCode.Count; i++) + { + addr = m_GenieCode[i].address; + if ((addr & 0x8000) != 0) + { + // 8character codes + if (MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] == m_GenieCode[i].cmp) + { + MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = m_GenieCode[i].data; + } + } + else + { + // 6character codes + addr |= 0x8000; + MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = m_GenieCode[i].data; + } + } + } + + private void WriteReg(ushort addr, byte data) + { + switch (addr & 0xFF) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x15: + apu.Write(addr, data); + MMU.CPUREG[addr & 0xFF] = data; + break; + case 0x14: + ppu.DMA(data); + cpu.DMA(514); // DMA Pending cycle + MMU.CPUREG[addr & 0xFF] = data; + break; + case 0x16: + mapper.ExWrite(addr, data); // For VS-Unisystem + pad.Write(addr, data); + MMU.CPUREG[addr & 0xFF] = data; + m_TapeIn = data; + break; + case 0x17: + MMU.CPUREG[addr & 0xFF] = data; + pad.Write(addr, data); + apu.Write(addr, data); + break; + // VirtuaNESŒÅ—Lƒ|[ƒg + case 0x18: + apu.Write(addr, data); + break; + default: + mapper.ExWrite(addr, data); + break; + } + } + + internal bool GetVideoMode() + { + return bVideoMode; + } + + internal void SetFrameIRQmode(bool bMode) + { + bFrameIRQ = bMode; + } + + internal bool GetFrameIRQmode() + { + return bFrameIRQ; + } + + internal EnumRenderMethod GetRenderMethod() + { + return RenderMethod; + } + + internal void SetIrqType(IRQMETHOD nType) + { + nIRQtype = (int)nType; + } + + internal int GetScanline() + { + return NES_scanline; + } + + internal void SetSAVERAM_SIZE(int size) + { + SAVERAM_SIZE = size; + } + + internal byte GetBarcodeStatus() + { + return m_BarcodeOut; + } + + public enum IRQMETHOD + { + IRQ_HSYNC = 0, IRQ_CLOCK = 1 + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/NES.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/NES.cs.meta new file mode 100644 index 0000000..291ca81 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/NES.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91459a62d37e6c049b384af2e8e6a47d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PAD.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PAD.cs new file mode 100644 index 0000000..01f5df1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PAD.cs @@ -0,0 +1,483 @@ +using Codice.CM.Client.Differences; +using System; + +namespace VirtualNes.Core +{ + public class PAD + { + private NES nes; + private int excontroller_select; + private EXPAD expad; + private bool bStrobe; + private bool bSwapButton; + private bool bSwapPlayer; + private bool bZapperMode; + private VSType nVSSwapType; + private byte[] padbit = new byte[4]; + private byte micbit; + private byte[] padbitsync = new byte[4]; + private byte micbitsync; + private bool bBarcodeWorld; + private int[][] padcnt = new int[4][] + { + new int[2],new int[2],new int[2],new int[2], + }; + + public uint pad1bit, pad2bit, pad3bit, pad4bit; + + public PAD(NES parent) + { + nes = parent; + excontroller_select = 0; + expad = null; + bStrobe = false; + bSwapButton = false; + bSwapPlayer = false; + bZapperMode = false; + nVSSwapType = VSType.VS_TYPE0; + + padbit[0] = padbit[1] = padbit[2] = padbit[3] = 0; + micbit = 0; + + padbitsync[0] = padbitsync[1] = padbitsync[2] = padbitsync[3] = 0; + micbitsync = 0; + } + + internal byte Read(ushort addr) + { + byte data = 0x00; + + if (addr == 0x4016) + { + data = (byte)(pad1bit & 1); + pad1bit >>= 1; + data |= (byte)(((pad3bit & 1)) << 1); + pad3bit >>= 1; + // Mic + if (!nes.rom.IsVSUNISYSTEM()) + { + data |= micbitsync; + } + if (expad != null) + { + data |= expad.Read4016(); + } + } + if (addr == 0x4017) + { + data = (byte)(pad2bit & 1); + pad2bit >>= 1; + data |= (byte)((pad4bit & 1) << 1); + pad4bit >>= 1; + + if (expad != null) + { + data |= expad.Read4017(); + } + + if (bBarcodeWorld) + { + data |= nes.Barcode2(); + } + } + + return data; + } + public void Dispose() { } + + internal void Write(ushort addr, byte data) + { + if (addr == 0x4016) + { + if ((data & 0x01) != 0) + { + bStrobe = true; + } + else if (bStrobe) + { + bStrobe = false; + + Strobe(); + if (expad != null) + { + expad.Strobe(); + } + } + + if (expad != null) + { + expad.Write4016(data); + } + } + if (addr == 0x4017) + { + if (expad != null) + { + expad.Write4017(data); + } + } + } + + private void Strobe() + { + // For VS-Unisystem + if (nes.rom.IsVSUNISYSTEM()) + { + uint pad1 = (uint)(padbitsync[0] & 0xF3); + uint pad2 = (uint)(padbitsync[1] & 0xF3); + uint st1 = (uint)(padbitsync[0] & 0x08) >> 3; + uint st2 = (uint)(padbitsync[1] & 0x08) >> 3; + + switch (nVSSwapType) + { + case VSType.VS_TYPE0: + pad1bit = pad1 | (st1 << 2); + pad2bit = pad2 | (st2 << 2); + break; + case VSType.VS_TYPE1: + pad1bit = pad2 | (st1 << 2); + pad2bit = pad1 | (st2 << 2); + break; + case VSType.VS_TYPE2: + pad1bit = pad1 | (st1 << 2) | (st2 << 3); + pad2bit = pad2; + break; + case VSType.VS_TYPE3: + pad1bit = pad2 | (st1 << 2) | (st2 << 3); + pad2bit = pad1; + break; + case VSType.VS_TYPE4: + pad1bit = pad1 | (st1 << 2) | 0x08; // 0x08=Start Protect + pad2bit = pad2 | (st2 << 2) | 0x08; // 0x08=Start Protect + break; + case VSType.VS_TYPE5: + pad1bit = pad2 | (st1 << 2) | 0x08; // 0x08=Start Protect + pad2bit = pad1 | (st2 << 2) | 0x08; // 0x08=Start Protect + break; + case VSType.VS_TYPE6: + pad1bit = pad1 | (st1 << 2) | (((uint)padbitsync[0] & 0x04) << 1); + pad2bit = pad2 | (st2 << 2) | (((uint)padbitsync[1] & 0x04) << 1); + break; + case VSType.VS_TYPEZ: + pad1bit = 0; + pad2bit = 0; + break; + } + + // Coin 2å²æ—å‚žå Šåµå¾šå¡ + micbit = 0; + } + else + { + if (Supporter.Config.emulator.bFourPlayer) + { + // NES type + pad1bit = padbitsync[0] | ((uint)padbitsync[2] << 8) | 0x00080000; + pad2bit = padbitsync[1] | ((uint)padbitsync[3] << 8) | 0x00040000; + } + else + { + // Famicom type + pad1bit = padbitsync[0]; + pad2bit = padbitsync[1]; + } + } + pad3bit = padbitsync[2]; + pad4bit = padbitsync[3]; + } + + internal void Reset() + { + pad1bit = pad2bit = 0; + bStrobe = false; + + bBarcodeWorld = false; + + for (int x = 0; x < 4; x++) + { + for (int y = 0; y < 2; y++) + { + padcnt[x][y] = 0; + } + } + + // Select Extension Devices + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xfbfc6a6c // Adventures of Bayou Billy, The(E) + || crc == 0xcb275051 // Adventures of Bayou Billy, The(U) + || crc == 0xfb69c131 // Baby Boomer(Unl)(U) + || crc == 0xf2641ad0 // Barker Bill's Trick Shooting(U) + || crc == 0xbc1dce96 // Chiller (Unl)(U) + || crc == 0x90ca616d // Duck Hunt(JUE) + || crc == 0x59e3343f // Freedom Force(U) + || crc == 0x242a270c // Gotcha!(U) + || crc == 0x7b5bd2de // Gumshoe(UE) + || crc == 0x255b129c // Gun Sight(J) + || crc == 0x8963ae6e // Hogan's Alley(JU) + || crc == 0x51d2112f // Laser Invasion(U) + || crc == 0x0a866c94 // Lone Ranger, The(U) + // || crc == 0xe4c04eea // Mad City(J) + || crc == 0x9eef47aa // Mechanized Attack(U) + || crc == 0xc2db7551 // Shooting Range(U) + || crc == 0x163e86c0 // To The Earth(U) + || crc == 0x42d893e4 // Operation Wolf(J) + || crc == 0x1388aeb9 // Operation Wolf(U) + || crc == 0x0d3cf705 // Wild Gunman(J) + || crc == 0x389960db) + { // Wild Gunman(JUE) + SetExController(EXCONTROLLER.EXCONTROLLER_ZAPPER); + } + if (crc == 0x35893b67 // Arkanoid(J) + || crc == 0x6267fbd1) + { // Arkanoid 2(J) + SetExController(EXCONTROLLER.EXCONTROLLER_PADDLE); + } + if (crc == 0xff6621ce // Hyper Olympic(J) + || crc == 0xdb9418e8 // Hyper Olympic(Tonosama Ban)(J) + || crc == 0xac98cd70) + { // Hyper Sports(J) + SetExController(EXCONTROLLER.EXCONTROLLER_HYPERSHOT); + } + if (crc == 0xf9def527 // Family BASIC(Ver2.0) + || crc == 0xde34526e // Family BASIC(Ver2.1a) + || crc == 0xf050b611 // Family BASIC(Ver3) + || crc == 0x3aaeed3f // Family BASIC(Ver3)(Alt) + || crc == 0x868FCD89 // Family BASIC(Ver1.0) + || crc == 0x2D6B7E5A // PLAYBOX BASIC(J) (Prototype_v0.0) + || crc == 0xDA03D908) + { // PLAYBOX BASIC (J) + SetExController(EXCONTROLLER.EXCONTROLLER_KEYBOARD); + } + if (crc == 0x589b6b0d // Supor Computer V3.0 + || crc == 0x8b265862 // Supor English + || crc == 0x41401c6d // Supor Computer V4.0 + || crc == 0x82F1Fb96 // Supor Computer(Russia) V1.0 + || crc == 0xd5d6eac4) + { // EDU(C) Computer + SetExController(EXCONTROLLER.EXCONTROLLER_SUPOR_KEYBOARD); + nes.SetVideoMode(true); + } + if (crc == 0xc68363f6 // Crazy Climber(J) + || crc == 0x2989ead6 // Smash TV(U) [!] + || crc == 0x0b8f8128) + { // Smash TV(E) [!] + SetExController(EXCONTROLLER.EXCONTROLLER_CRAZYCLIMBER); + } + if (crc == 0x20d22251) + { // Top rider(J) + SetExController(EXCONTROLLER.EXCONTROLLER_TOPRIDER); + } + if (crc == 0x0cd00488) + { // Space Shadow(J) + SetExController(EXCONTROLLER.EXCONTROLLER_SPACESHADOWGUN); + } + + if (crc == 0x8c8fa83b // Family Trainer - Athletic World (J) + || crc == 0x7e704a14 // Family Trainer - Jogging Race (J) + || crc == 0x2330a5d3) + { // Family Trainer - Rairai Kyonshiizu (J) + SetExController(EXCONTROLLER.EXCONTROLLER_FAMILYTRAINER_A); + } + if (crc == 0xf8da2506 // Family Trainer - Aerobics Studio (J) + || crc == 0xca26a0f1 // Family Trainer - Dai Undoukai (J) + || crc == 0x28068b8c // Family Trainer - Fuuun Takeshi Jou 2 (J) + || crc == 0x10bb8f9a // Family Trainer - Manhattan Police (J) + || crc == 0xad3df455 // Family Trainer - Meiro Dai Sakusen (J) + || crc == 0x8a5b72c0 // Family Trainer - Running Stadium (J) + || crc == 0x59794f2d) + { // Family Trainer - Totsugeki Fuuun Takeshi Jou (J) + SetExController(EXCONTROLLER.EXCONTROLLER_FAMILYTRAINER_B); + } + if (crc == 0x9fae4d46 // Ide Yousuke Meijin no Jissen Mahjong (J) + || crc == 0x7b44fb2a) + { // Ide Yousuke Meijin no Jissen Mahjong 2 (J) + SetExController(EXCONTROLLER.EXCONTROLLER_MAHJANG); + } + if (crc == 0x786148b6) + { // Exciting Boxing (J) + SetExController(EXCONTROLLER.EXCONTROLLER_EXCITINGBOXING); + } + if (crc == 0xc3c0811d // Oeka Kids - Anpanman no Hiragana Daisuki (J) + || crc == 0x9d048ea4) + { // Oeka Kids - Anpanman to Oekaki Shiyou!! (J) + SetExController(EXCONTROLLER.EXCONTROLLER_OEKAKIDS_TABLET); + } + + if (crc == 0x67898319) + { // Barcode World (J) + bBarcodeWorld = true; + } + + // VS-Unisystem + if (nes.rom.IsVSUNISYSTEM()) + { + if (crc == 0xff5135a3 // VS Hogan's Alley + || crc == 0xed588f00 // VS Duck Hunt + || crc == 0x17ae56be) + { // VS Freedom Force + SetExController(EXCONTROLLER.EXCONTROLLER_VSZAPPER); + } + else + { + SetExController(EXCONTROLLER.EXCONTROLLER_VSUNISYSTEM); + } + } + + if (crc == 0x21b099f3) + { // Gyromite (JUE) + SetExController(EXCONTROLLER.EXCONTROLLER_GYROMITE); + } + } + + internal void SetExController(EXCONTROLLER type) + { + excontroller_select = (int)type; + + expad?.Dispose(); + expad = null; + + bZapperMode = false; + + // ExPad Instance create + switch (type) + { + case EXCONTROLLER.EXCONTROLLER_ZAPPER: + expad = new EXPAD_Zapper(nes); + bZapperMode = true; + break; + case EXCONTROLLER.EXCONTROLLER_PADDLE: + expad = new EXPAD_Paddle(nes); + break; + case EXCONTROLLER.EXCONTROLLER_HYPERSHOT: + expad = new EXPAD_HyperShot(nes); + break; + case EXCONTROLLER.EXCONTROLLER_KEYBOARD: + expad = new EXPAD_Keyboard(nes); + break; + case EXCONTROLLER.EXCONTROLLER_SUPOR_KEYBOARD: + expad = new EXPAD_Supor_Keyboard(nes); + break; + case EXCONTROLLER.EXCONTROLLER_CRAZYCLIMBER: + expad = new EXPAD_CrazyClimber(nes); + break; + case EXCONTROLLER.EXCONTROLLER_TOPRIDER: + expad = new EXPAD_Toprider(nes); + break; + case EXCONTROLLER.EXCONTROLLER_SPACESHADOWGUN: + expad = new EXPAD_SpaceShadowGun(nes); + bZapperMode = true; + break; + case EXCONTROLLER.EXCONTROLLER_FAMILYTRAINER_A: + case EXCONTROLLER.EXCONTROLLER_FAMILYTRAINER_B: + expad = new EXPAD_FamlyTrainer(nes); + break; + case EXCONTROLLER.EXCONTROLLER_EXCITINGBOXING: + expad = new EXPAD_ExcitingBoxing(nes); + break; + case EXCONTROLLER.EXCONTROLLER_MAHJANG: + expad = new EXPAD_Mahjang(nes); + break; + case EXCONTROLLER.EXCONTROLLER_OEKAKIDS_TABLET: + expad = new EXPAD_OekakidsTablet(nes); + break; + case EXCONTROLLER.EXCONTROLLER_TURBOFILE: + expad = new EXPAD_TurboFile(nes); + break; + case EXCONTROLLER.EXCONTROLLER_VSUNISYSTEM: + expad = new EXPAD_VSUnisystem(nes); + break; + case EXCONTROLLER.EXCONTROLLER_VSZAPPER: + expad = new EXPAD_VSZapper(nes); + bZapperMode = true; + break; + + case EXCONTROLLER.EXCONTROLLER_GYROMITE: + expad = new EXPAD_Gyromite(nes); + break; + default: + break; + } + + if (expad != null) + { + expad.Reset(); + } + } + + internal bool IsZapperMode() + { + return bZapperMode; + } + + internal void VSync() + { + padbitsync[0] = padbit[0]; + padbitsync[1] = padbit[1]; + padbitsync[2] = padbit[2]; + padbitsync[3] = padbit[3]; + micbitsync = micbit; + } + + internal uint GetSyncData() + { + uint ret; + ret = (uint)(padbit[0] | (padbit[1] << 8) | (padbit[2] << 16) | (padbit[3] << 24)); + ret |= (uint)(micbit << 8); + return ret; + } + + internal void SetSyncData(uint data) + { + micbit = (byte)((data & 0x00000400) >> 8); + padbit[0] = (byte)data; + padbit[1] = (byte)(data >> 8); + padbit[2] = (byte)(data >> 16); + padbit[3] = (byte)(data >> 24); + } + + internal int GetExController() + { + return excontroller_select; + } + } + + public enum VSType + { + VS_TYPE0 = 0, // SELECT1P=START1P/SELECT2P=START2P 1P/2P No reverse + VS_TYPE1, // SELECT1P=START1P/SELECT2P=START2P 1P/2P Reverse + VS_TYPE2, // SELECT1P=START1P/START1P =START2P 1P/2P No reverse + VS_TYPE3, // SELECT1P=START1P/START1P =START2P 1P/2P Reverse + VS_TYPE4, // SELECT1P=START1P/SELECT2P=START2P 1P/2P No reverse (Protection) + VS_TYPE5, // SELECT1P=START1P/SELECT2P=START2P 1P/2P Reverse (Protection) + VS_TYPE6, // SELECT1P=START1P/SELECT2P=START2P 1P/2P Reverse (For Golf) + VS_TYPEZ, // ZAPPER + } + + public enum EXCONTROLLER + { + EXCONTROLLER_NONE = 0, + EXCONTROLLER_PADDLE, + EXCONTROLLER_HYPERSHOT, + EXCONTROLLER_ZAPPER, + EXCONTROLLER_KEYBOARD, + EXCONTROLLER_CRAZYCLIMBER, + EXCONTROLLER_TOPRIDER, + EXCONTROLLER_SPACESHADOWGUN, + + EXCONTROLLER_FAMILYTRAINER_A, + EXCONTROLLER_FAMILYTRAINER_B, + EXCONTROLLER_EXCITINGBOXING, + EXCONTROLLER_MAHJANG, + EXCONTROLLER_OEKAKIDS_TABLET, + EXCONTROLLER_TURBOFILE, + + EXCONTROLLER_VSUNISYSTEM, + EXCONTROLLER_VSZAPPER, + + EXCONTROLLER_GYROMITE, + EXCONTROLLER_STACKUP, + + EXCONTROLLER_SUPOR_KEYBOARD, + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PAD.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PAD.cs.meta new file mode 100644 index 0000000..5186f79 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PAD.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 82d5b1d9eb428ca45838e3a46515044d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PPU.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PPU.cs new file mode 100644 index 0000000..f92f690 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PPU.cs @@ -0,0 +1,1189 @@ +using System; + +namespace VirtualNes.Core +{ + public class PPU + { + public const int SCREEN_WIDTH = 256 + 16; + public const int SCREEN_HEIGHT = 240; + + private static byte[][] CreateCOLORMAP() + { + byte[][] res = new byte[5][]; + res[0] = new byte[64] + { 0x35, 0xFF, 0x16, 0x22, 0x1C, 0xFF, 0xFF, 0x15, + 0xFF, 0x00, 0x27, 0x05, 0x04, 0x27, 0x08, 0x30, + 0x21, 0xFF, 0xFF, 0x29, 0x3C, 0xFF, 0x36, 0x12, + 0xFF, 0x2B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, + 0xFF, 0x31, 0xFF, 0x2A, 0x2C, 0x0C, 0xFF, 0xFF, + 0xFF, 0x07, 0x34, 0x06, 0x13, 0xFF, 0x26, 0x0F, + 0xFF, 0x19, 0x10, 0x0A, 0xFF, 0xFF, 0xFF, 0x17, + 0xFF, 0x11, 0x09, 0xFF, 0xFF, 0x25, 0x18, 0xFF + }; + res[1] = new byte[64] + { 0xFF, 0x27, 0x18, 0xFF, 0x3A, 0x25, 0xFF, 0x31, + 0x16, 0x13, 0x38, 0x34, 0x20, 0x23, 0x31, 0x1A, + 0xFF, 0x21, 0x06, 0xFF, 0x1B, 0x29, 0xFF, 0x22, + 0xFF, 0x24, 0xFF, 0xFF, 0xFF, 0x08, 0xFF, 0x03, + 0xFF, 0x36, 0x26, 0x33, 0x11, 0xFF, 0x10, 0x02, + 0x14, 0xFF, 0x00, 0x09, 0x12, 0x0F, 0xFF, 0x30, + 0xFF, 0xFF, 0x2A, 0x17, 0x0C, 0x01, 0x15, 0x19, + 0xFF, 0x2C, 0x07, 0x37, 0xFF, 0x05, 0xFF, 0xFF + }; + res[2] = new byte[64] + { 0xFF, 0xFF, 0xFF, 0x10, 0x1A, 0x30, 0x31, 0x09, + 0x01, 0x0F, 0x36, 0x08, 0x15, 0xFF, 0xFF, 0xF0, + 0x22, 0x1C, 0xFF, 0x12, 0x19, 0x18, 0x17, 0xFF, + 0x00, 0xFF, 0xFF, 0x02, 0x16, 0x06, 0xFF, 0x35, + 0x23, 0xFF, 0x8B, 0xF7, 0xFF, 0x27, 0x26, 0x20, + 0x29, 0xFF, 0x21, 0x24, 0x11, 0xFF, 0xEF, 0xFF, + 0x2C, 0xFF, 0xFF, 0xFF, 0x07, 0xF9, 0x28, 0xFF, + 0x0A, 0xFF, 0x32, 0x37, 0x13, 0xFF, 0xFF, 0x0C + }; + res[3] = new byte[64] + { 0x18, 0xFF, 0x1C, 0x89, 0x0F, 0xFF, 0x01, 0x17, // 00-07 + 0x10, 0x0F, 0x2A, 0xFF, 0x36, 0x37, 0x1A, 0xFF, // 08-0F + 0x25, 0xFF, 0x12, 0xFF, 0x0F, 0xFF, 0xFF, 0x26, // 10-17 + 0xFF, 0xFF, 0x22, 0xFF, 0xFF, 0x0F, 0x3A, 0x21, // 18-1F + 0x05, 0x0A, 0x07, 0xC2, 0x13, 0xFF, 0x00, 0x15, // 20-27 + 0x0C, 0xFF, 0x11, 0xFF, 0xFF, 0x38, 0xFF, 0xFF, // 28-2F + 0xFF, 0xFF, 0x08, 0x16, 0xFF, 0xFF, 0x30, 0x3C, // 30-37 + 0x0F, 0x27, 0xFF, 0x60, 0x29, 0xFF, 0x30, 0x09 // 38-3F + }; + res[4] = new byte[64] + { + // Super Xevious/Gradius + 0x35, 0xFF, 0x16, 0x22, 0x1C, 0x09, 0xFF, 0x15, // 00-07 + 0x20, 0x00, 0x27, 0x05, 0x04, 0x28, 0x08, 0x30, // 08-0F + 0x21, 0xFF, 0xFF, 0x29, 0x3C, 0xFF, 0x36, 0x12, // 10-17 + 0xFF, 0x2B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, // 18-1F + 0xFF, 0x31, 0xFF, 0x2A, 0x2C, 0x0C, 0x1B, 0xFF, // 20-27 + 0xFF, 0x07, 0x34, 0x06, 0xFF, 0x25, 0x26, 0x0F, // 28-2F + 0xFF, 0x19, 0x10, 0x0A, 0xFF, 0xFF, 0xFF, 0x17, // 30-37 + 0xFF, 0x11, 0x1A, 0xFF, 0x38, 0xFF, 0x18, 0x3A, // 38-3F + }; + + return res; + } + private static byte[][] VSColorMap = CreateCOLORMAP(); + + // PPU Control Register #1 PPU #0 + public const byte PPU_VBLANK_BIT = 0x80; + public const byte PPU_SPHIT_BIT = 0x40; // å ˜å†ä¸  + public const byte PPU_SP16_BIT = 0x20; + public const byte PPU_BGTBL_BIT = 0x10; + public const byte PPU_SPTBL_BIT = 0x08; + public const byte PPU_INC32_BIT = 0x04; + public const byte PPU_NAMETBL_BIT = 0x03; + + // PPU Control Register #2 PPU #1 + public const byte PPU_BGCOLOR_BIT = 0xE0; + public const byte PPU_SPDISP_BIT = 0x10; + public const byte PPU_BGDISP_BIT = 0x08; + public const byte PPU_SPCLIP_BIT = 0x04; + public const byte PPU_BGCLIP_BIT = 0x02; + public const byte PPU_COLORMODE_BIT = 0x01; + + // PPU Status Register PPU #2 + public const byte PPU_VBLANK_FLAG = 0x80; + public const byte PPU_SPHIT_FLAG = 0x40; + public const byte PPU_SPMAX_FLAG = 0x20; + public const byte PPU_WENABLE_FLAG = 0x10; + + // SPRITE Attribute + public const byte SP_VMIRROR_BIT = 0x80; + public const byte SP_HMIRROR_BIT = 0x40; + public const byte SP_PRIORITY_BIT = 0x20; + public const byte SP_COLOR_BIT = 0x03; + + private NES nes; + + private bool bExtLatch; // For MMC5 + private bool bChrLatch; // For MMC2/MMC4 + private bool bExtNameTable; // For Super Monkey no Dai Bouken + private bool bExtMono; // For Final Fantasy + + private ushort loopy_y; + private ushort loopy_shift; + + private byte[] lpScreen; + /// 作为lpScreen数组的索引 + private int lpScanline; + private int ScanlineNo; + private byte[] lpColormode; + + private bool bVSMode; + private int nVSColorMap; + private byte VSSecurityData; + private byte[] Bit2Rev = new byte[256]; + + + public PPU(NES nes) + { + this.nes = nes; + lpScreen = null; + lpColormode = null; + + bVSMode = false; + nVSColorMap = -1; + VSSecurityData = 0; + + for (int i = 0; i < 256; i++) + { + byte m = 0x80; + byte c = 0; + for (int j = 0; j < 8; j++) + { + if ((i & (1 << j)) > 0) c |= m; + m >>= 1; + } + Bit2Rev[i] = c; + } + } + + public void Dispose() { } + + internal byte Read(ushort addr) + { + byte data = 0x00; + + switch (addr) + { + // Write only Register + case 0x2000: // PPU Control Register #1(W) + case 0x2001: // PPU Control Register #2(W) + case 0x2003: // SPR-RAM Address Register(W) + case 0x2005: // PPU Scroll Register(W2) + case 0x2006: // VRAM Address Register(W2) + data = MMU.PPU7_Temp; // 懡暘 + break; + // Read/Write Register + case 0x2002: // PPU Status Register(R) + //DEBUGOUT( "2002 RD L:%3d C:%8d\n", ScanlineNo, nes->cpu->GetTotalCycles() ); + data = (byte)(MMU.PPUREG[2] | VSSecurityData); + MMU.PPU56Toggle = 0; + byte temp = unchecked((byte)~PPU_VBLANK_FLAG); + MMU.PPUREG[2] &= temp; + break; + case 0x2004: // SPR_RAM I/O Register(RW) + data = MMU.SPRAM[MMU.PPUREG[3]++]; + break; + case 0x2007: // VRAM I/O Register(RW) + addr = (ushort)(MMU.loopy_v & 0x3FFF); + data = MMU.PPU7_Temp; + if ((MMU.PPUREG[0] & PPU_INC32_BIT) != 0) MMU.loopy_v += 32; + else MMU.loopy_v++; + if (addr >= 0x3000) + { + if (addr >= 0x3F00) + { + // data &= 0x3F; + if ((addr & 0x0010) == 0) + { + return MMU.BGPAL[addr & 0x000F]; + } + else + { + return MMU.SPPAL[addr & 0x000F]; + } + } + addr &= 0xEFFF; + } + MMU.PPU7_Temp = MMU.PPU_MEM_BANK[addr >> 10][addr & 0x03FF]; + break; + } + + return data; + } + + internal void SetRenderScanline(int scanline) + { + ScanlineNo = scanline; + if (scanline < 240) + { + lpScanline = (SCREEN_WIDTH) * scanline; + } + } + + internal void Write(ushort addr, byte data) + { + if (bVSMode && VSSecurityData != 0) + { + if (addr == 0x2000) + { + addr = 0x2001; + } + else if (addr == 0x2001) + { + addr = 0x2000; + } + } + + switch (addr) + { + // Read only Register + case 0x2002: // PPU Status register(R) + break; + // Write Register + case 0x2000: // PPU Control Register #1(W) + // NameTable select + // t:0000110000000000=d:00000011 + MMU.loopy_t = (ushort)((MMU.loopy_t & 0xF3FF) | ((data & 0x03) << 10)); + + if ((data & 0x80) != 0 && (MMU.PPUREG[0] & 0x80) == 0 && (MMU.PPUREG[2] & 0x80) != 0) + { + nes.cpu.NMI(); // hmm... + } + + MMU.PPUREG[0] = data; + break; + case 0x2001: // PPU Control Register #2(W) + MMU.PPUREG[1] = data; + break; + case 0x2003: // SPR-RAM Address Register(W) + MMU.PPUREG[3] = data; + break; + case 0x2004: // SPR_RAM I/O Register(RW) + MMU.SPRAM[MMU.PPUREG[3]++] = data; + break; + + case 0x2005: // PPU Scroll Register(W2) + //DEBUGOUT( "SCR WRT L:%3d C:%8d\n", ScanlineNo, nes->cpu->GetTotalCycles() ); + if (MMU.PPU56Toggle == 0) + { + // First write + // tile X t:0000000000011111=d:11111000 + MMU.loopy_t = (ushort)((MMU.loopy_t & 0xFFE0) | ((data) >> 3)); + // scroll offset X x=d:00000111 + MMU.loopy_x = (ushort)(data & 0x07); + } + else + { + // Second write + // tile Y t:0000001111100000=d:11111000 + MMU.loopy_t = (ushort)((MMU.loopy_t & 0xFC1F) | (((data) & 0xF8) << 2)); + // scroll offset Y t:0111000000000000=d:00000111 + MMU.loopy_t = (ushort)((MMU.loopy_t & 0x8FFF) | (((data) & 0x07) << 12)); + } + MMU.PPU56Toggle = (byte)(MMU.PPU56Toggle == 0 ? 1 : 0); + break; + case 0x2006: // VRAM Address Register(W2) + if (MMU.PPU56Toggle == 0) + { + // First write + // t:0011111100000000=d:00111111 + // t:1100000000000000=0 + MMU.loopy_t = (ushort)((MMU.loopy_t & 0x00FF) | (((data) & 0x3F) << 8)); + } + else + { + // Second write + // t:0000000011111111=d:11111111 + MMU.loopy_t = (ushort)((MMU.loopy_t & 0xFF00) | data); + // v=t + MMU.loopy_v = MMU.loopy_t; + nes.mapper.PPU_Latch(MMU.loopy_v); + } + MMU.PPU56Toggle = (byte)(MMU.PPU56Toggle == 0 ? 1 : 0); + break; + case 0x2007: // VRAM I/O Register(RW) + ushort vaddr = (ushort)(MMU.loopy_v & 0x3FFF); + if ((MMU.PPUREG[0] & PPU_INC32_BIT) != 0) MMU.loopy_v += 32; + else MMU.loopy_v++; + + if (vaddr >= 0x3000) + { + if (vaddr >= 0x3F00) + { + data &= 0x3F; + if (bVSMode && nVSColorMap != -1) + { + byte temp = VSColorMap[nVSColorMap][data]; + if (temp != 0xFF) + { + data = (byte)(temp & 0x3F); + } + } + + if ((vaddr & 0x000F) == 0) + { + MMU.BGPAL[0] = MMU.SPPAL[0] = data; + } + else if ((vaddr & 0x0010) == 0) + { + MMU.BGPAL[vaddr & 0x000F] = data; + } + else + { + MMU.SPPAL[vaddr & 0x000F] = data; + } + MMU.BGPAL[0x04] = MMU.BGPAL[0x08] = MMU.BGPAL[0x0C] = MMU.BGPAL[0x00]; + MMU.SPPAL[0x00] = MMU.SPPAL[0x04] = MMU.SPPAL[0x08] = MMU.SPPAL[0x0C] = MMU.BGPAL[0x00]; + return; + } + vaddr &= 0xEFFF; + } + if (MMU.PPU_MEM_TYPE[vaddr >> 10] != MMU.BANKTYPE_VROM) + { + MMU.PPU_MEM_BANK[vaddr >> 10][vaddr & 0x03FF] = data; + } + break; + } + } + + internal void DMA(byte data) + { + ushort addr = (ushort)(data << 8); + + for (ushort i = 0; i < 256; i++) + { + MMU.SPRAM[i] = nes.Read((ushort)(addr + i)); + } + } + + internal void Reset() + { + bExtLatch = false; + bChrLatch = false; + bExtNameTable = false; + bExtMono = false; + + MMU.PPUREG[0] = MMU.PPUREG[1] = 0; + + MMU.PPU56Toggle = 0; + + MMU.PPU7_Temp = 0xFF; // VS Excitebikeå±åååŸå”å´å‚ž($2006傪撉傒åµå³´å”僶僌å‘åå‚ž) + // PPU7_Temp = 0; + + MMU.loopy_v = MMU.loopy_t = 0; + MMU.loopy_x = loopy_y = 0; + loopy_shift = 0; + + if (lpScreen != null) + MemoryUtility.memset(lpScreen, 0x3F, SCREEN_WIDTH * SCREEN_HEIGHT); + if (lpColormode != null) + MemoryUtility.memset(lpColormode, 0, SCREEN_HEIGHT); + } + + internal void FrameStart() + { + if ((MMU.PPUREG[1] & (PPU_SPDISP_BIT | PPU_BGDISP_BIT)) != 0) + { + MMU.loopy_v = MMU.loopy_t; + loopy_shift = MMU.loopy_x; + loopy_y = (ushort)((MMU.loopy_v & 0x7000) >> 12); + } + + if (lpScreen != null) + { + MemoryUtility.memset(lpScreen, 0x3F, SCREEN_WIDTH); + } + if (lpColormode != null) + { + lpColormode[0] = 0; + } + } + + internal void ScanlineNext() + { + if ((MMU.PPUREG[1] & (PPU_BGDISP_BIT | PPU_SPDISP_BIT)) != 0) + { + if ((MMU.loopy_v & 0x7000) == 0x7000) + { + MMU.loopy_v &= 0x8FFF; + if ((MMU.loopy_v & 0x03E0) == 0x03A0) + { + MMU.loopy_v ^= 0x0800; + MMU.loopy_v &= 0xFC1F; + } + else + { + if ((MMU.loopy_v & 0x03E0) == 0x03E0) + { + MMU.loopy_v &= 0xFC1F; + } + else + { + MMU.loopy_v += 0x0020; + } + } + } + else + { + MMU.loopy_v += 0x1000; + } + loopy_y = (ushort)((MMU.loopy_v & 0x7000) >> 12); + } + } + + internal void ScanlineStart() + { + if ((MMU.PPUREG[1] & (PPU_BGDISP_BIT | PPU_SPDISP_BIT)) != 0) + { + MMU.loopy_v = (ushort)((MMU.loopy_v & 0xFBE0) | (MMU.loopy_t & 0x041F)); + loopy_shift = MMU.loopy_x; + loopy_y = (ushort)((MMU.loopy_v & 0x7000) >> 12); + nes.mapper.PPU_Latch((ushort)(0x2000 + (MMU.loopy_v & 0x0FFF))); + } + } + + private byte[] BGwrite = new byte[33 + 1]; + private byte[] BGmono = new byte[33 + 1]; + private byte[] SPwrite = new byte[33 + 1]; + + internal void Scanline(int scanline, bool bMax, bool bLeftClip) + { + int pScn = 0; + int pBGw = 0; + byte chr_h = 0, chr_l = 0, attr = 0; + + MemoryUtility.ZEROMEMORY(BGwrite, BGwrite.Length); + MemoryUtility.ZEROMEMORY(BGmono, BGmono.Length); + + // Linecolor mode + lpColormode[scanline] = (byte)(((MMU.PPUREG[1] & PPU_BGCOLOR_BIT) >> 5) | ((MMU.PPUREG[1] & PPU_COLORMODE_BIT) << 7)); + + // Render BG + if ((MMU.PPUREG[1] & PPU_BGDISP_BIT) == 0) + { + MemoryUtility.memset(lpScreen, lpScanline, MMU.BGPAL[0], SCREEN_WIDTH); + if (nes.GetRenderMethod() == EnumRenderMethod.TILE_RENDER) + { + nes.EmulationCPU(NES.FETCH_CYCLES * 4 * 32); + } + } + else + { + if (nes.GetRenderMethod() != EnumRenderMethod.TILE_RENDER) + { + if (!bExtLatch) + { + // Without Extension Latch + pScn = lpScanline + (8 - loopy_shift); + pBGw = 0; + + int tileofs = (MMU.PPUREG[0] & PPU_BGTBL_BIT) << 8; + int ntbladr = 0x2000 + (MMU.loopy_v & 0x0FFF); + int attradr = 0x23C0 + (MMU.loopy_v & 0x0C00) + ((MMU.loopy_v & 0x0380) >> 4); + int ntbl_x = ntbladr & 0x001F; + int attrsft = (ntbladr & 0x0040) >> 4; + var pNTBL = MMU.PPU_MEM_BANK[ntbladr >> 10]; + + int tileadr; + int cache_tile = unchecked((int)(0xFFFF0000)); + byte cache_attr = 0xFF; + + chr_h = chr_l = attr = 0; + + attradr &= 0x3FF; + + + for (int i = 0; i < 33; i++) + { + tileadr = tileofs + pNTBL[ntbladr & 0x03FF] * 0x10 + loopy_y; + attr = (byte)(((pNTBL[attradr + (ntbl_x >> 2)] >> ((ntbl_x & 2) + attrsft)) & 3) << 2); + + if (cache_tile == tileadr && cache_attr == attr) + { + lpScreen[pScn + 0] = lpScreen[pScn - 8]; + lpScreen[pScn + 0 + 1] = lpScreen[pScn - 8 + 1]; + lpScreen[pScn + 0 + 2] = lpScreen[pScn - 8 + 2]; + lpScreen[pScn + 0 + 3] = lpScreen[pScn - 8 + 3]; + + lpScreen[pScn + 4] = lpScreen[pScn - 4]; + lpScreen[pScn + 4 + 1] = lpScreen[pScn - 4 + 1]; + lpScreen[pScn + 4 + 2] = lpScreen[pScn - 4 + 2]; + lpScreen[pScn + 4 + 3] = lpScreen[pScn - 4 + 3]; + + BGwrite[pBGw + 0] = BGwrite[pBGw - 1]; + } + else + { + cache_tile = tileadr; + cache_attr = attr; + chr_l = MMU.PPU_MEM_BANK[tileadr >> 10][tileadr & 0x03FF]; + chr_h = MMU.PPU_MEM_BANK[tileadr >> 10][(tileadr & 0x03FF) + 8]; + BGwrite[pBGw] = (byte)(chr_h | chr_l); + + int pBGPAL = attr; + { + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + lpScreen[pScn + 0] = MMU.BGPAL[pBGPAL + (c1 >> 6)]; + lpScreen[pScn + 4] = MMU.BGPAL[pBGPAL + ((c1 >> 2) & 3)]; + lpScreen[pScn + 1] = MMU.BGPAL[pBGPAL + ((c1 >> 6))]; + lpScreen[pScn + 5] = MMU.BGPAL[pBGPAL + ((c2 >> 2) & 3)]; + lpScreen[pScn + 2] = MMU.BGPAL[pBGPAL + ((c1 >> 4) & 3)]; + lpScreen[pScn + 6] = MMU.BGPAL[pBGPAL + (c1 & 3)]; + lpScreen[pScn + 3] = MMU.BGPAL[pBGPAL + ((c2 >> 4) & 3)]; + lpScreen[pScn + 7] = MMU.BGPAL[pBGPAL + (c2 & 3)]; + } + } + pScn += 8; + pBGw++; + + // Character latch(For MMC2/MMC4) + if (bChrLatch) + { + nes.mapper.PPU_ChrLatch((ushort)(tileadr)); + } + + if (++ntbl_x == 32) + { + ntbl_x = 0; + ntbladr ^= 0x41F; + attradr = 0x03C0 + ((ntbladr & 0x0380) >> 4); + pNTBL = MMU.PPU_MEM_BANK[ntbladr >> 10]; + } + else + { + ntbladr++; + } + } + } + else + { + // With Extension Latch(For MMC5) + pScn = lpScanline + (8 - loopy_shift); + pBGw = 0; + + int ntbladr = 0x2000 + (MMU.loopy_v & 0x0FFF); + int ntbl_x = ntbladr & 0x1F; + + int cache_tile = unchecked((int)(0xFFFF0000)); + byte cache_attr = 0xFF; + + byte exattr = 0; + chr_h = chr_l = attr = 0; + + for (int i = 0; i < 33; i++) + { + nes.mapper.PPU_ExtLatchX(i); + nes.mapper.PPU_ExtLatch((ushort)ntbladr, ref chr_l, ref chr_h, ref exattr); + attr = (byte)(exattr & 0x0C); + + if (cache_tile != ((chr_h << 8) + chr_l) || cache_attr != attr) + { + cache_tile = ((chr_h << 8) + chr_l); + cache_attr = attr; + BGwrite[pBGw] = (byte)(chr_h | chr_l); + + int pBGPAL = attr; + { + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + lpScreen[pScn + 0] = MMU.BGPAL[pBGPAL + (c1 >> 6)]; + lpScreen[pScn + 4] = MMU.BGPAL[pBGPAL + ((c1 >> 2) & 3)]; + lpScreen[pScn + 1] = MMU.BGPAL[pBGPAL + (c2 >> 6)]; + lpScreen[pScn + 5] = MMU.BGPAL[pBGPAL + ((c2 >> 2) & 3)]; + lpScreen[pScn + 2] = MMU.BGPAL[pBGPAL + ((c1 >> 4) & 3)]; + lpScreen[pScn + 6] = MMU.BGPAL[pBGPAL + (c1 & 3)]; + lpScreen[pScn + 3] = MMU.BGPAL[pBGPAL + ((c2 >> 4) & 3)]; + lpScreen[pScn + 7] = MMU.BGPAL[pBGPAL + (c2 & 3)]; + } + } + else + { + lpScreen[pScn + 0] = lpScreen[pScn - 8]; + lpScreen[pScn + 0 + 1] = lpScreen[pScn - 8 + 1]; + lpScreen[pScn + 0 + 2] = lpScreen[pScn - 8 + 2]; + lpScreen[pScn + 0 + 3] = lpScreen[pScn - 8 + 3]; + + lpScreen[pScn + 4] = lpScreen[pScn - 4]; + lpScreen[pScn + 4 + 1] = lpScreen[pScn - 4 + 1]; + lpScreen[pScn + 4 + 2] = lpScreen[pScn - 4 + 2]; + lpScreen[pScn + 4 + 3] = lpScreen[pScn - 4 + 3]; + + BGwrite[pBGw + 0] = BGwrite[pBGw - 1]; + } + pScn += 8; + pBGw++; + + if (++ntbl_x == 32) + { + ntbl_x = 0; + ntbladr ^= 0x41F; + } + else + { + ntbladr++; + } + } + } + } + else + { + if (!bExtLatch) + { + // Without Extension Latch + if (!bExtNameTable) + { + pScn = lpScanline + (8 - loopy_shift); + pBGw = 0; + + int ntbladr = 0x2000 + (MMU.loopy_v & 0x0FFF); + int attradr = 0x03C0 + ((MMU.loopy_v & 0x0380) >> 4); + int ntbl_x = ntbladr & 0x001F; + int attrsft = (ntbladr & 0x0040) >> 4; + var pNTBL = MMU.PPU_MEM_BANK[ntbladr >> 10]; + + int tileadr = 0; + int cache_tile = unchecked((int)(0xFFFF0000)); + byte cache_attr = 0xFF; + + chr_h = chr_l = attr = 0; + + for (int i = 0; i < 33; i++) + { + tileadr = ((MMU.PPUREG[0] & PPU_BGTBL_BIT) << 8) + pNTBL[ntbladr & 0x03FF] * 0x10 + loopy_y; + + if (i != 0) + { + nes.EmulationCPU(NES.FETCH_CYCLES * 4); + } + + attr = (byte)(((pNTBL[attradr + (ntbl_x >> 2)] >> ((ntbl_x & 2) + attrsft)) & 3) << 2); + + if (cache_tile != tileadr || cache_attr != attr) + { + cache_tile = tileadr; + cache_attr = attr; + + chr_l = MMU.PPU_MEM_BANK[tileadr >> 10][tileadr & 0x03FF]; + chr_h = MMU.PPU_MEM_BANK[tileadr >> 10][(tileadr & 0x03FF) + 8]; + lpScreen[pBGw] = (byte)(chr_l | chr_h); + + int pBGPAL = attr; + { + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + lpScreen[pScn + 0] = MMU.BGPAL[pBGPAL + (c1 >> 6)]; + lpScreen[pScn + 4] = MMU.BGPAL[pBGPAL + ((c1 >> 2) & 3)]; + lpScreen[pScn + 1] = MMU.BGPAL[pBGPAL + ((c2 >> 6))]; + lpScreen[pScn + 5] = MMU.BGPAL[pBGPAL + ((c2 >> 2) & 3)]; + lpScreen[pScn + 2] = MMU.BGPAL[pBGPAL + ((c1 >> 4) & 3)]; + lpScreen[pScn + 6] = MMU.BGPAL[pBGPAL + (c1 & 3)]; + lpScreen[pScn + 3] = MMU.BGPAL[pBGPAL + ((c2 >> 4) & 3)]; + lpScreen[pScn + 7] = MMU.BGPAL[pBGPAL + (c2 & 3)]; + } + } + else + { + lpScreen[pScn + 0] = lpScreen[pScn - 8]; + lpScreen[pScn + 0 + 1] = lpScreen[pScn - 8 + 1]; + lpScreen[pScn + 0 + 2] = lpScreen[pScn - 8 + 2]; + lpScreen[pScn + 0 + 3] = lpScreen[pScn - 8 + 3]; + + lpScreen[pScn + 4] = lpScreen[pScn - 4]; + lpScreen[pScn + 4 + 1] = lpScreen[pScn - 4 + 1]; + lpScreen[pScn + 4 + 2] = lpScreen[pScn - 4 + 2]; + lpScreen[pScn + 4 + 3] = lpScreen[pScn - 4 + 3]; + + BGwrite[pBGw + 0] = BGwrite[pBGw - 1]; + } + pScn += 8; + pBGw++; + + // Character latch(For MMC2/MMC4) + if (bChrLatch) + { + nes.mapper.PPU_ChrLatch((ushort)(tileadr)); + } + + if (++ntbl_x == 32) + { + ntbl_x = 0; + ntbladr ^= 0x41F; + attradr = 0x03C0 + ((ntbladr & 0x0380) >> 4); + pNTBL = MMU.PPU_MEM_BANK[ntbladr >> 10]; + } + else + { + ntbladr++; + } + } + } + else + { + pScn = lpScanline + (8 - loopy_shift); + pBGw = 0; + + int ntbladr; + int tileadr; + int cache_tile = unchecked((int)(0xFFFF0000)); + byte cache_attr = 0xFF; + + chr_h = chr_l = attr = 0; + + ushort loopy_v_tmp = MMU.loopy_v; + + for (int i = 0; i < 33; i++) + { + if (i != 0) + { + nes.EmulationCPU(NES.FETCH_CYCLES * 4); + } + + ntbladr = 0x2000 + (MMU.loopy_v & 0x0FFF); + tileadr = ((MMU.PPUREG[0] & PPU_BGTBL_BIT) << 8) + MMU.PPU_MEM_BANK[ntbladr >> 10][ntbladr & 0x03FF] * 0x10 + ((MMU.loopy_v & 0x7000) >> 12); + attr = (byte)(((MMU.PPU_MEM_BANK[ntbladr >> 10][0x03C0 + ((ntbladr & 0x0380) >> 4) + ((ntbladr & 0x001C) >> 2)] >> (((ntbladr & 0x40) >> 4) + (ntbladr & 0x02))) & 3) << 2); + + if (cache_tile != tileadr || cache_attr != attr) + { + cache_tile = tileadr; + cache_attr = attr; + + chr_l = MMU.PPU_MEM_BANK[tileadr >> 10][tileadr & 0x03FF]; + chr_h = MMU.PPU_MEM_BANK[tileadr >> 10][(tileadr & 0x03FF) + 8]; + BGwrite[pBGw] = (byte)(chr_l | chr_h); + + int pBGPAL = attr; + { + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + lpScreen[pScn + 0] = MMU.BGPAL[pBGPAL + (c1 >> 6)]; + lpScreen[pScn + 4] = MMU.BGPAL[pBGPAL + ((c1 >> 2) & 3)]; + lpScreen[pScn + 1] = MMU.BGPAL[pBGPAL + (c2 >> 6)]; + lpScreen[pScn + 5] = MMU.BGPAL[pBGPAL + ((c2 >> 2) & 3)]; + lpScreen[pScn + 2] = MMU.BGPAL[pBGPAL + ((c1 >> 4) & 3)]; + lpScreen[pScn + 6] = MMU.BGPAL[pBGPAL + (c1 & 3)]; + lpScreen[pScn + 3] = MMU.BGPAL[pBGPAL + ((c2 >> 4) & 3)]; + lpScreen[pScn + 7] = MMU.BGPAL[pBGPAL + (c2 & 3)]; + } + } + else + { + lpScreen[pScn + 0] = lpScreen[pScn - 8]; + lpScreen[pScn + 0 + 1] = lpScreen[pScn - 8 + 1]; + lpScreen[pScn + 0 + 2] = lpScreen[pScn - 8 + 2]; + lpScreen[pScn + 0 + 3] = lpScreen[pScn - 8 + 3]; + + lpScreen[pScn + 4] = lpScreen[pScn - 4]; + lpScreen[pScn + 4 + 1] = lpScreen[pScn - 4 + 1]; + lpScreen[pScn + 4 + 2] = lpScreen[pScn - 4 + 2]; + lpScreen[pScn + 4 + 3] = lpScreen[pScn - 4 + 3]; + + BGwrite[pBGw + 0] = BGwrite[pBGw - 1]; + } + pScn += 8; + pBGw++; + + // Character latch(For MMC2/MMC4) + if (bChrLatch) + { + nes.mapper.PPU_ChrLatch((ushort)tileadr); + } + + if ((MMU.loopy_v & 0x1F) == 0x1F) + { + MMU.loopy_v ^= 0x041F; + } + else + { + MMU.loopy_v++; + } + } + MMU.loopy_v = loopy_v_tmp; + } + } + else + { + // With Extension Latch(For MMC5) + pScn = lpScanline + (8 - loopy_shift); + pBGw = 0; + + int ntbladr = 0x2000 + (MMU.loopy_v & 0x0FFF); + int ntbl_x = ntbladr & 0x1F; + + int cache_tile = unchecked((int)0xFFFF0000); + byte cache_attr = 0xFF; + + byte exattr = 0; + chr_h = chr_l = attr = 0; + + for (int i = 0; i < 33; i++) + { + if (i != 0) + { + nes.EmulationCPU(NES.FETCH_CYCLES * 4); + } + nes.mapper.PPU_ExtLatchX(i); + nes.mapper.PPU_ExtLatch((ushort)ntbladr, ref chr_l, ref chr_h, ref exattr); + attr = (byte)(exattr & 0x0C); + + if (cache_tile != ((chr_h << 8) + chr_l) || cache_attr != attr) + { + cache_tile = ((chr_h << 8) + chr_l); + cache_attr = attr; + BGwrite[pBGw] = (byte)(chr_l | chr_h); + + int pBGPAL = attr; + { + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + lpScreen[pScn + 0] = MMU.BGPAL[pBGPAL + ((c1 >> 6))]; + lpScreen[pScn + 4] = MMU.BGPAL[pBGPAL + ((c1 >> 2) & 3)]; + lpScreen[pScn + 1] = MMU.BGPAL[pBGPAL + ((c2 >> 6))]; + lpScreen[pScn + 5] = MMU.BGPAL[pBGPAL + ((c2 >> 2) & 3)]; + lpScreen[pScn + 2] = MMU.BGPAL[pBGPAL + ((c1 >> 4) & 3)]; + lpScreen[pScn + 6] = MMU.BGPAL[pBGPAL + (c1 & 3)]; + lpScreen[pScn + 3] = MMU.BGPAL[pBGPAL + ((c2 >> 4) & 3)]; + lpScreen[pScn + 7] = MMU.BGPAL[pBGPAL + (c2 & 3)]; + } + } + else + { + lpScreen[pScn + 0] = lpScreen[pScn - 8]; + lpScreen[pScn + 0 + 1] = lpScreen[pScn - 8 + 1]; + lpScreen[pScn + 0 + 2] = lpScreen[pScn - 8 + 2]; + lpScreen[pScn + 0 + 3] = lpScreen[pScn - 8 + 3]; + + lpScreen[pScn + 4] = lpScreen[pScn - 4]; + lpScreen[pScn + 4 + 1] = lpScreen[pScn - 4 + 1]; + lpScreen[pScn + 4 + 2] = lpScreen[pScn - 4 + 2]; + lpScreen[pScn + 4 + 3] = lpScreen[pScn - 4 + 3]; + + BGwrite[pBGw + 0] = BGwrite[pBGw - 1]; + } + pScn += 8; + pBGw++; + + if (++ntbl_x == 32) + { + ntbl_x = 0; + ntbladr ^= 0x41F; + } + else + { + ntbladr++; + } + } + } + } + if ((MMU.PPUREG[1] & PPU_BGCLIP_BIT) == 0 && bLeftClip) + { + pScn = lpScanline + 8; + for (int i = 0; i < 8; i++) + { + lpScreen[i] = MMU.BGPAL[0]; + } + } + } + + // Render sprites + var temp = ~PPU_SPMAX_FLAG; + MMU.PPUREG[2] = (byte)(MMU.PPUREG[2] & temp); + + // 昞帵婜娫奜å±åå‚Ÿå½åƒ‰å„儞僙儖 + if (scanline > 239) + return; + + if ((MMU.PPUREG[1] & PPU_SPDISP_BIT) == 0) + { + return; + } + + int spmax = 0; + int spraddr = 0, sp_y = 0, sp_h = 0; + chr_h = chr_l = 0; + + + pBGw = 0; + int pSPw = 0; + int pBit2Rev = 0; + + MemoryUtility.ZEROMEMORY(SPwrite, SPwrite.Length); + + spmax = 0; + Sprite sp = new Sprite(MMU.SPRAM, 0); + sp_h = (MMU.PPUREG[0] & PPU_SP16_BIT) != 0 ? 15 : 7; + + // Left clip + if (bLeftClip && ((MMU.PPUREG[1] & PPU_SPCLIP_BIT) == 0)) + { + SPwrite[0] = 0xFF; + } + + for (int i = 0; i < 64; i++, sp.AddOffset(1)) + { + sp_y = scanline - (sp.y + 1); + // 僗僉å„儞儔僀儞撪åµSPRITEå‘懚嵼å¡å‚žå傪僠僃僢僋 + if (sp_y != (sp_y & sp_h)) + continue; + + if ((MMU.PPUREG[0] & PPU_SP16_BIT) == 0) + { + // 8x8 Sprite + spraddr = ((MMU.PPUREG[0] & PPU_SPTBL_BIT) << 9) + (sp.tile << 4); + if ((sp.attr & SP_VMIRROR_BIT) == 0) + spraddr += sp_y; + else + spraddr += 7 - sp_y; + } + else + { + // 8x16 Sprite + spraddr = ((sp.tile & 1) << 12) + ((sp.tile & 0xFE) << 4); + if ((sp.attr & SP_VMIRROR_BIT) == 0) + spraddr += ((sp_y & 8) << 1) + (sp_y & 7); + else + spraddr += ((~sp_y & 8) << 1) + (7 - (sp_y & 7)); + } + // Character pattern + chr_l = MMU.PPU_MEM_BANK[spraddr >> 10][spraddr & 0x3FF]; + chr_h = MMU.PPU_MEM_BANK[spraddr >> 10][(spraddr & 0x3FF) + 8]; + + // Character latch(For MMC2/MMC4) + if (bChrLatch) + { + nes.mapper.PPU_ChrLatch((ushort)spraddr); + } + + // pattern mask + if ((sp.attr & SP_HMIRROR_BIT) != 0) + { + chr_l = Bit2Rev[pBit2Rev + chr_l]; + chr_h = Bit2Rev[pBit2Rev + chr_h]; + } + byte SPpat = (byte)(chr_l | chr_h); + + // Sprite hitcheck + if (i == 0 && (MMU.PPUREG[2] & PPU_SPHIT_FLAG) == 0) + { + int BGpos = ((sp.x & 0xF8) + ((loopy_shift + (sp.x & 7)) & 8)) >> 3; + int BGsft = 8 - ((loopy_shift + sp.x) & 7); + + var temp1 = BGwrite[pBGw + BGpos + 0] << 8; + var temp2 = BGwrite[pBGw + BGpos + 1]; + byte BGmsk = (byte)((temp1 | temp2) >> BGsft); + + if ((SPpat & BGmsk) != 0) + { + MMU.PPUREG[2] |= PPU_SPHIT_FLAG; + } + } + + // Sprite mask + int SPpos = sp.x / 8; + int SPsft = 8 - (sp.x & 7); + byte SPmsk = (byte)((SPwrite[pSPw + SPpos + 0] << 8 | SPwrite[pSPw + SPpos + 1]) >> SPsft); + ushort SPwrt = (ushort)(SPpat << SPsft); + SPwrite[pSPw + SPpos + 0] = (byte)(SPwrite[pSPw + SPpos + 0] | SPwrt >> 8); + SPwrite[pSPw + SPpos + 1] = (byte)(SPwrite[pSPw + SPpos + 1] | SPwrt & 0xFF); + SPpat = (byte)(SPpat & ~SPmsk); + + if ((sp.attr & SP_PRIORITY_BIT) != 0) + { + // BG > SP priority + int BGpos = ((sp.x & 0xF8) + ((loopy_shift + (sp.x & 7)) & 8)) >> 3; + int BGsft = 8 - ((loopy_shift + sp.x) & 7); + byte BGmsk = (byte)(((BGwrite[pBGw + BGpos + 0] << 8) | BGwrite[pBGw + BGpos + 1]) >> BGsft); + + SPpat = (byte)(SPpat & ~BGmsk); + } + + // Attribute + int pSPPAL = (sp.attr & SP_COLOR_BIT) << 2; + // Ptr + pScn = lpScanline + sp.x + 8; + + if (!bExtMono) + { + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + if ((SPpat & 0x80) != 0) lpScreen[pScn + 0] = MMU.SPPAL[pSPPAL + (c1 >> 6)]; + if ((SPpat & 0x08) != 0) lpScreen[pScn + 4] = MMU.SPPAL[pSPPAL + ((c1 >> 2) & 3)]; + if ((SPpat & 0x40) != 0) lpScreen[pScn + 1] = MMU.SPPAL[pSPPAL + ((c2 >> 6))]; + if ((SPpat & 0x04) != 0) lpScreen[pScn + 5] = MMU.SPPAL[pSPPAL + ((c2 >> 2) & 3)]; + if ((SPpat & 0x20) != 0) lpScreen[pScn + 2] = MMU.SPPAL[pSPPAL + ((c1 >> 4) & 3)]; + if ((SPpat & 0x02) != 0) lpScreen[pScn + 6] = MMU.SPPAL[pSPPAL + (c1 & 3)]; + if ((SPpat & 0x10) != 0) lpScreen[pScn + 3] = MMU.SPPAL[pSPPAL + ((c2 >> 4) & 3)]; + if ((SPpat & 0x01) != 0) lpScreen[pScn + 7] = MMU.SPPAL[pSPPAL + (c2 & 3)]; + } + else + { + // Monocrome effect (for Final Fantasy) + byte mono = BGmono[((sp.x & 0xF8) + ((loopy_shift + (sp.x & 7)) & 8)) >> 3]; + + int c1 = ((chr_l >> 1) & 0x55) | (chr_h & 0xAA); + int c2 = (chr_l & 0x55) | ((chr_h << 1) & 0xAA); + if ((SPpat & 0x80) != 0) lpScreen[pScn + 0] = (byte)(MMU.SPPAL[pSPPAL + (c1 >> 6)] | mono); + if ((SPpat & 0x08) != 0) lpScreen[pScn + 4] = (byte)(MMU.SPPAL[pSPPAL + ((c1 >> 2) & 3)] | mono); + if ((SPpat & 0x40) != 0) lpScreen[pScn + 1] = (byte)(MMU.SPPAL[pSPPAL + (c2 >> 6)] | mono); + if ((SPpat & 0x04) != 0) lpScreen[pScn + 5] = (byte)(MMU.SPPAL[pSPPAL + ((c2 >> 2) & 3)] | mono); + if ((SPpat & 0x20) != 0) lpScreen[pScn + 2] = (byte)(MMU.SPPAL[pSPPAL + ((c1 >> 4) & 3)] | mono); + if ((SPpat & 0x02) != 0) lpScreen[pScn + 6] = (byte)(MMU.SPPAL[pSPPAL + (c1 & 3)] | mono); + if ((SPpat & 0x10) != 0) lpScreen[pScn + 3] = (byte)(MMU.SPPAL[pSPPAL + ((c2 >> 4) & 3)] | mono); + if ((SPpat & 0x01) != 0) lpScreen[pScn + 7] = (byte)(MMU.SPPAL[pSPPAL + (c2 & 3)] | mono); + } + + if (++spmax > 8 - 1) + { + if (!bMax) + break; + } + } + if (spmax > 8 - 1) + { + MMU.PPUREG[2] |= PPU_SPMAX_FLAG; + } + } + + internal bool IsSprite0(int scanline) + { + // 僗僾儔僀僩orBG旕昞帵å¼åƒ‰å„儞僙儖(僸僢僩åŸå´å„) + if ((MMU.PPUREG[1] & (PPU_SPDISP_BIT | PPU_BGDISP_BIT)) != (PPU_SPDISP_BIT | PPU_BGDISP_BIT)) + return false; + + // å©›åµåƒ¸åƒ¢åƒ©åŸå°å„å¨å‚œåƒ‰å„儞僙儖 + if ((MMU.PPUREG[2] & PPU_SPHIT_FLAG) != 0) + return false; + + if ((MMU.PPUREG[0] & PPU_SP16_BIT) == 0) + { + // 8x8 + if ((scanline < MMU.SPRAM[0] + 1) || (scanline > (MMU.SPRAM[0] + 7 + 1))) + return false; + } + else + { + // 8x16 + if ((scanline < MMU.SPRAM[0] + 1) || (scanline > (MMU.SPRAM[0] + 15 + 1))) + return false; + } + + return true; + } + + internal void DummyScanline(int scanline) + { + int i; + int spmax; + int sp_h; + + MMU.PPUREG[2] = (byte)(MMU.PPUREG[2] & ~PPU_SPMAX_FLAG); + + // 僗僾儔僀僩旕昞帵å¼åƒ‰å„儞僙儖 + if ((MMU.PPUREG[1] & PPU_SPDISP_BIT) == 0) + return; + + // 昞帵婜娫奜å±åå‚Ÿå½åƒ‰å„儞僙儖 + if (scanline < 0 || scanline > 239) + return; + + Sprite sp = new Sprite(MMU.SPRAM, 0); + sp_h = (MMU.PPUREG[0] & PPU_SP16_BIT) != 0 ? 15 : 7; + + spmax = 0; + // Sprite Max check + for (i = 0; i < 64; i++, sp.AddOffset(1)) + { + // 僗僉å„儞儔僀儞撪åµSPRITEå‘懚嵼å¡å‚žå傪僠僃僢僋 + if ((scanline < sp.y + 1) || (scanline > (sp.y + sp_h + 1))) + { + continue; + } + + if (++spmax > 8 - 1) + { + MMU.PPUREG[2] |= PPU_SPMAX_FLAG; + break; + } + } + } + + internal void VBlankEnd() + { + MMU.PPUREG[2] = (byte)(MMU.PPUREG[2] & ~PPU_VBLANK_FLAG); + // VBlank扙弌帪åµåƒ‹å„•å‚¾åå‚Ÿå‚ž + // 僄僉僒僀僩僶僀僋å±å»³æ¢« + MMU.PPUREG[2] = (byte)(MMU.PPUREG[2] & ~PPU_SPHIT_FLAG); + } + + internal void VBlankStart() + { + MMU.PPUREG[2] |= PPU_VBLANK_FLAG; + } + + public byte[] GetScreenPtr() + { + return lpScreen; + } + + public byte[] GetLineColorMode() + { + return lpColormode; + } + + internal void SetScreenPtr(byte[] screenBuffer, byte[] colormode) + { + lpScreen = screenBuffer; + lpColormode = colormode; + } + + + internal bool IsDispON() + { + return (MMU.PPUREG[1] & (PPU_BGDISP_BIT | PPU_SPDISP_BIT)) != 0; + } + + internal void SetExtLatchMode(bool bMode) + { + bExtLatch = bMode; + } + + internal ushort GetPPUADDR() + { + return MMU.loopy_v; + } + + internal ushort GetTILEY() + { + return loopy_y; + } + + internal void SetChrLatchMode(bool bMode) + { + bChrLatch = bMode; + } + + public struct Sprite + { + public byte y + { + get => raw[offset + 0]; + set => raw[offset + 0] = value; + } + + public byte tile + { + get => raw[offset + 1]; + set => raw[offset + 1] = value; + } + public byte attr + { + get => raw[offset + 2]; + set => raw[offset + 2] = value; + } + public byte x + { + get => raw[offset + 3]; + set => raw[offset + 3] = value; + } + + private byte[] raw; + private int offset; + + public Sprite(byte[] raw, int offset) + { + this.raw = raw; + this.offset = offset * 4; + } + + public void AddOffset(int offset) + { + this.offset += offset * 4; + } + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PPU.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PPU.cs.meta new file mode 100644 index 0000000..69b6056 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PPU.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2a695378c1666b7458e1be6efe468433 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX.meta new file mode 100644 index 0000000..c9a6921 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 69e7ee7384266604db7cac0b95c6f836 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD.cs new file mode 100644 index 0000000..44105d1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD.cs @@ -0,0 +1,24 @@ +namespace VirtualNes.Core +{ + public class EXPAD + { + protected NES nes; + + public EXPAD(NES parent) + { + nes = parent; + } + + public virtual void Dispose() { } + + public virtual void Reset() { } + public virtual void Strobe() { } + public virtual byte Read4016() { return 0x00; } + public virtual byte Read4017() { return 0x00; } + public virtual void Write4016(byte data) { } + public virtual void Write4017(byte data) { } + public virtual void Sync() { } + public virtual void SetSyncData(int type, int data) { } + public virtual int GetSyncData(int type) { return 0x00; } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD.cs.meta new file mode 100644 index 0000000..cd111ca --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 93b9e4ea918e52a45aab8f87b9dc17c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_CrazyClimber.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_CrazyClimber.cs new file mode 100644 index 0000000..5c8c274 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_CrazyClimber.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_CrazyClimber : EXPAD + { + public EXPAD_CrazyClimber(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_CrazyClimber.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_CrazyClimber.cs.meta new file mode 100644 index 0000000..e3a9670 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_CrazyClimber.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d7ac655210edb74ea198ad8802cb545 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_ExcitingBoxing.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_ExcitingBoxing.cs new file mode 100644 index 0000000..9a4d47e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_ExcitingBoxing.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_ExcitingBoxing : EXPAD + { + public EXPAD_ExcitingBoxing(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_ExcitingBoxing.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_ExcitingBoxing.cs.meta new file mode 100644 index 0000000..8e05b0c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_ExcitingBoxing.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2ac6f1c51a9c1b64e970bc5fe5e00b9a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_FamlyTrainer.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_FamlyTrainer.cs new file mode 100644 index 0000000..d7ea8d6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_FamlyTrainer.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_FamlyTrainer : EXPAD + { + public EXPAD_FamlyTrainer(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_FamlyTrainer.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_FamlyTrainer.cs.meta new file mode 100644 index 0000000..7e30479 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_FamlyTrainer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5a2cfbbbe2b90bd4ba754bc9a8f014af +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Gyromite.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Gyromite.cs new file mode 100644 index 0000000..f16d93f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Gyromite.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_Gyromite : EXPAD + { + public EXPAD_Gyromite(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Gyromite.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Gyromite.cs.meta new file mode 100644 index 0000000..50334ac --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Gyromite.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c49edbe29e34f0245b621a7920d4981e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_HyperShot.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_HyperShot.cs new file mode 100644 index 0000000..e854ad6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_HyperShot.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_HyperShot : EXPAD + { + public EXPAD_HyperShot(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_HyperShot.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_HyperShot.cs.meta new file mode 100644 index 0000000..cded73b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_HyperShot.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ac43bf6e282394c46b8ea717595d8664 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Keyboard.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Keyboard.cs new file mode 100644 index 0000000..4ade50a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Keyboard.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_Keyboard : EXPAD + { + public EXPAD_Keyboard(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Keyboard.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Keyboard.cs.meta new file mode 100644 index 0000000..c894781 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Keyboard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f56b9a9d01afad4b967b5d606f7ef11 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Mahjang.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Mahjang.cs new file mode 100644 index 0000000..765c262 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Mahjang.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_Mahjang : EXPAD + { + public EXPAD_Mahjang(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Mahjang.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Mahjang.cs.meta new file mode 100644 index 0000000..b1541a1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Mahjang.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 146c88b5d0fab5b43ba7e570f0ff116b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_OekakidsTablet.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_OekakidsTablet.cs new file mode 100644 index 0000000..679ce77 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_OekakidsTablet.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_OekakidsTablet : EXPAD + { + public EXPAD_OekakidsTablet(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_OekakidsTablet.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_OekakidsTablet.cs.meta new file mode 100644 index 0000000..bdc8d51 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_OekakidsTablet.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 47337ac29c001d047a911c028e305b43 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Paddle.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Paddle.cs new file mode 100644 index 0000000..a35efbe --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Paddle.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + public class EXPAD_Paddle : EXPAD + { + public EXPAD_Paddle(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Paddle.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Paddle.cs.meta new file mode 100644 index 0000000..ab492a0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Paddle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e48f82e9b202e64fa7ebe3816804ae9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_SpaceShadowGun.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_SpaceShadowGun.cs new file mode 100644 index 0000000..2ee29b4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_SpaceShadowGun.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_SpaceShadowGun : EXPAD + { + public EXPAD_SpaceShadowGun(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_SpaceShadowGun.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_SpaceShadowGun.cs.meta new file mode 100644 index 0000000..a0bd98c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_SpaceShadowGun.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 01ac1bc69454b414cb5a9db1d12f1aac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Supor_Keyboard.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Supor_Keyboard.cs new file mode 100644 index 0000000..633ab77 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Supor_Keyboard.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_Supor_Keyboard : EXPAD + { + public EXPAD_Supor_Keyboard(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Supor_Keyboard.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Supor_Keyboard.cs.meta new file mode 100644 index 0000000..0060455 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Supor_Keyboard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5adc370589ec4bf42b7ea0c20acb2a48 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Toprider.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Toprider.cs new file mode 100644 index 0000000..58b6fd8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Toprider.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_Toprider : EXPAD + { + public EXPAD_Toprider(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Toprider.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Toprider.cs.meta new file mode 100644 index 0000000..8ec93a3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Toprider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0b1053511d6f224a840b0e9df4f9889 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_TurboFile.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_TurboFile.cs new file mode 100644 index 0000000..283a583 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_TurboFile.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_TurboFile : EXPAD + { + public EXPAD_TurboFile(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_TurboFile.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_TurboFile.cs.meta new file mode 100644 index 0000000..ac3ba2e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_TurboFile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b6b41e81a80079489f60eaa5be220cd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSUnisystem.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSUnisystem.cs new file mode 100644 index 0000000..1ba2c98 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSUnisystem.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_VSUnisystem : EXPAD + { + public EXPAD_VSUnisystem(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSUnisystem.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSUnisystem.cs.meta new file mode 100644 index 0000000..5f0b371 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSUnisystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d343a07cca05ea642be6db80607ea23a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSZapper.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSZapper.cs new file mode 100644 index 0000000..9058c4a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSZapper.cs @@ -0,0 +1,9 @@ +namespace VirtualNes.Core +{ + internal class EXPAD_VSZapper : EXPAD + { + public EXPAD_VSZapper(NES parent) : base(parent) + { + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSZapper.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSZapper.cs.meta new file mode 100644 index 0000000..34798b6 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_VSZapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6803ff5b7be6edc49ba2b71256aa16a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Zapper.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Zapper.cs new file mode 100644 index 0000000..5dd97fb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Zapper.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VirtualNes.Core +{ + /// + /// 光枪 + /// + public class EXPAD_Zapper : EXPAD + { + public EXPAD_Zapper(NES parent) : base(parent) + { + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Zapper.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Zapper.cs.meta new file mode 100644 index 0000000..75db078 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/PadEX/EXPAD_Zapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c378fd8c53bb8084f979b05d2405bb9c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ROM.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ROM.cs new file mode 100644 index 0000000..18607c9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ROM.cs @@ -0,0 +1,412 @@ +using System; +using System.IO; +using VirtualNes.Core.Debug; + +namespace VirtualNes.Core +{ + public class ROM + { + protected NESHEADER header; + protected NSFHEADER nsfheader; + protected string path; + protected string name; + protected string fullpath; + protected bool bPAL; + protected bool bNSF; + protected int NSF_PAGE_SIZE; + protected byte[] lpPRG; + protected byte[] lpCHR; + protected byte[] lpTrainer; + protected byte[] lpDiskBios; + protected byte[] lpDisk; + protected uint crc; + protected uint crcall; + protected uint crcvrom; + protected int mapper; + protected int diskno; + protected uint fdsmakerID; + protected uint fdsgameID; + + public ROM(string fname) + { + Stream fp = null; + byte[] temp = null; + byte[] bios = null; + long FileSize = 0; + + header = NESHEADER.GetDefault(); + path = string.Empty; + name = string.Empty; + + bPAL = false; + bNSF = false; + NSF_PAGE_SIZE = 0; + + lpPRG = lpCHR = lpTrainer = lpDiskBios = lpDisk = null; + + crc = crcall = 0; + mapper = 0; + diskno = 0; + + try + { + fp = Supporter.OpenRom(fname); + if (fp == null) + { + throw new System.Exception($"Open Rom Failed:[{fname}]"); + } + + FileSize = fp.Length; + if (FileSize < 17) + { + throw new System.Exception($"File too small:[{fname}]"); + } + + temp = new byte[FileSize]; + fp.Read(temp, 0, temp.Length); + + fp.Dispose(); + + header = NESHEADER.Read(temp); + + if (!header.CheckValid()) + throw new Exception($"rom file is not valid:[{fname}]"); + + ulong PRGoffset, CHRoffset; + long PRGsize = 0, CHRsize = 0; + + var romType = header.GetRomType(); + if (romType == EnumRomType.NES) + { + PRGsize = (long)header.PRG_PAGE_SIZE * 0x4000; + CHRsize = (long)header.CHR_PAGE_SIZE * 0x2000; + PRGoffset = (ulong)NESHEADER.SizeOf(); + CHRoffset = PRGoffset + (ulong)PRGsize; + + if (IsTRAINER()) + { + PRGoffset += 512; + CHRoffset += 512; + } + + if (PRGsize <= 0 || (PRGsize + CHRsize) > FileSize) + { + throw new Exception($"Invalid NesHeader:[{fname}]"); + } + + //PRG BANK + lpPRG = new byte[PRGsize]; + Array.Copy(temp, (int)PRGoffset, lpPRG, 0, PRGsize); + + //CHR BANK + if (CHRsize > 0) + { + lpCHR = new byte[CHRsize]; + if (FileSize >= (long)CHRoffset + CHRsize) + { + Array.Copy(temp, (int)CHRoffset, lpCHR, 0, CHRsize); + } + else + { + //CHR Bank太少... + CHRsize -= ((long)CHRoffset + CHRsize - FileSize); + Array.Copy(temp, (int)CHRoffset, lpCHR, 0, CHRsize); + } + } + else + { + lpCHR = null; + } + + if (IsTRAINER()) + { + lpTrainer = new byte[512]; + Array.Copy(temp, NESHEADER.SizeOf(), lpTrainer, 0, 512); + } + else + { + lpTrainer = null; + } + } + else if (romType == EnumRomType.FDS) + { + diskno = header.PRG_PAGE_SIZE; + + if (FileSize < (16 + 65500 * diskno)) + { + throw new Exception($"Illegal Disk Size:[{fname}]"); + } + if (diskno > 8) + { + throw new Exception($"Unsupport disk:[{fname}]"); + } + + header = NESHEADER.GetDefault(); + header.ID[0] = (byte)'N'; + header.ID[1] = (byte)'E'; + header.ID[2] = (byte)'S'; + header.ID[3] = 0x1A; + header.PRG_PAGE_SIZE = (byte)(diskno * 4); + header.CHR_PAGE_SIZE = 0; + header.control1 = 0x40; + header.control2 = 0x10; + + PRGsize = NESHEADER.SizeOf() + 65500 * diskno; + //PRG BANK + lpPRG = new byte[PRGsize]; + lpDisk = new byte[PRGsize]; + lpCHR = null; + + var headerBuffer = header.DataToBytes(); + Array.Copy(headerBuffer, lpPRG, headerBuffer.Length); + Array.Copy(temp, NESHEADER.SizeOf(), lpPRG, NESHEADER.SizeOf(), 65500 * diskno); + + lpPRG[0] = (byte)'F'; + lpPRG[1] = (byte)'D'; + lpPRG[2] = (byte)'S'; + lpPRG[3] = 0x1A; + lpPRG[4] = (byte)diskno; + + fp = Supporter.OpenFile_DISKSYS(); + if (fp == null) + { + throw new Exception($"Not found DISKSYS.ROM for [{fname}]"); + } + + FileSize = fp.Length; + if (FileSize < 17) + { + throw new Exception($"Small File Of DISKSYS.ROM"); + } + + bios = new byte[FileSize]; + fp.Read(bios, 0, (int)FileSize); + fp.Dispose(); + + lpDiskBios = new byte[8 * 1024]; + if (bios[0] == 'N' && bios[1] == 'E' && bios[2] == 'S' && bios[3] == 0x1A) + { + Array.Copy(bios, 0x6010, lpDiskBios, 0, lpDiskBios.Length); + } + else + { + Array.Copy(bios, lpDiskBios, lpDiskBios.Length); + } + bios = null; + } + else if (romType == EnumRomType.NSF) + { + bNSF = true; + header = NESHEADER.GetDefault(); + + nsfheader = NSFHEADER.GetDefault(); + + PRGsize = FileSize - NSFHEADER.SizeOf(); + Debuger.Log($"PRGSIZE:{PRGsize}"); + PRGsize = (PRGsize + 0x0FFF) & ~0x0FFF; + Debuger.Log($"PRGSIZE:{PRGsize}"); + + lpPRG = new byte[PRGsize]; + Array.Copy(temp, NSFHEADER.SizeOf(), lpPRG, 0, FileSize - NSFHEADER.SizeOf()); + + NSF_PAGE_SIZE = (int)(PRGsize >> 12); + Debuger.Log($"PAGESIZE:{NSF_PAGE_SIZE}"); + } + else + { + throw new Exception($"Unsupport format:[{fname}]"); + } + + Supporter.GetFilePathInfo(fname, out fullpath, out path); + name = Path.GetFileNameWithoutExtension(fullpath); + if (!bNSF) + { + mapper = (header.control1 >> 4) | (header.control2 & 0xF0); + crc = crcall = crcvrom = 0; + + if (mapper != 20) + { + Span sTemp = temp; + if (IsTRAINER()) + { + crcall = CRC.CrcRev((int)(512 + PRGsize + CHRsize), sTemp.Slice(NESHEADER.SizeOf())); + crc = CRC.CrcRev((int)(512 + PRGsize), sTemp); + if (CHRsize > 0) + crcvrom = CRC.CrcRev((int)CHRsize, sTemp.Slice((int)(PRGsize + 512 + NESHEADER.SizeOf()))); + } + else + { + crcall = CRC.CrcRev((int)(PRGsize + CHRsize), sTemp.Slice(NESHEADER.SizeOf())); + crc = CRC.CrcRev((int)(PRGsize), sTemp.Slice(NESHEADER.SizeOf())); + if (CHRsize > 0) + crcvrom = CRC.CrcRev((int)CHRsize, sTemp.Slice((int)(PRGsize + NESHEADER.SizeOf()))); + } + + FileNameCheck(fname); + + RomPatch.DoPatch(ref crc, ref lpPRG, ref lpCHR, ref mapper, ref header); + + fdsmakerID = fdsgameID = 0; + } + else //mapper==20 + { + crc = crcall = crcvrom = 0; + + fdsmakerID = lpPRG[0x1F]; + fdsgameID = (uint)((lpPRG[0x20] << 24) | (lpPRG[0x21] << 16) | (lpPRG[0x22] << 8) | (lpPRG[0x23] << 0)); + } + } + else //NSF + { + mapper = 0x0100; // Private mapper + crc = crcall = crcvrom = 0; + fdsmakerID = fdsgameID = 0; + } + + temp = null; + } + catch (Exception ex) + { + fp?.Dispose(); + temp = null; + bios = null; + lpPRG = null; + lpCHR = null; + lpTrainer = null; + lpDiskBios = null; + lpDisk = null; + + throw ex; + } + } + + public void Dispose() + { + lpPRG = null; + lpCHR = null; + lpTrainer = null; + lpDiskBios = null; + lpDisk = null; + } + + public bool IsTRAINER() + { + return (header.control1 & (byte)EnumRomControlByte1.ROM_TRAINER) > 0; + } + + public bool IsNSF() + { + return bNSF; + } + public bool IsPAL() + { + return bPAL; + } + + public bool IsSAVERAM() + { + return (header.control1 & (byte)EnumRomControlByte1.ROM_SAVERAM) > 0; + } + + protected void FileNameCheck(string fname) + { + if (fname.Contains("(E)")) + { + bPAL = true; + return; + } + } + + internal string GetRomName() + { + return name; + } + + internal int GetMapperNo() + { + return mapper; + } + + internal byte[] GetPROM() + { + return lpPRG; + } + + internal byte[] GetVROM() + { + return lpCHR; + } + + internal byte[] GetDISK() + { + return lpDisk; + } + + internal int GetDiskNo() + { + return diskno; + } + + internal uint GetGameID() + { + return fdsgameID; + } + + internal uint GetMakerID() + { + return fdsmakerID; + } + + internal bool IsVSUNISYSTEM() + { + return (header.control2 & (byte)EnumRomControlByte2.ROM_VSUNISYSTEM) != 0; + } + + internal uint GetPROM_CRC() + { + return crc; + } + + internal byte GetPROM_SIZE() + { + return header.PRG_PAGE_SIZE; + } + + internal byte GetVROM_SIZE() + { + return header.CHR_PAGE_SIZE; + } + + internal bool Is4SCREEN() + { + return (header.control1 & (byte)EnumRomControlByte1.ROM_4SCREEN) != 0; + } + + internal bool IsVMIRROR() + { + return (header.control1 & (byte)EnumRomControlByte1.ROM_VMIRROR) != 0; + } + + internal byte[] GetTRAINER() + { + return lpTrainer; + } + + internal NSFHEADER GetNsfHeader() + { + return nsfheader; + } + + internal string GetRomPath() + { + return path; + } + + internal uint GetVROM_CRC() + { + return crcvrom; + } + } + + +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ROM.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ROM.cs.meta new file mode 100644 index 0000000..3f79db9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ROM.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 391d943ceba1fa0459c3991e11bd3921 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter.meta new file mode 100644 index 0000000..1120450 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 78036d3e96a27e441b4989bb8ec174e9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig.meta new file mode 100644 index 0000000..8a060f7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fd0714f580724604da063207fe69e274 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgController.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgController.cs new file mode 100644 index 0000000..9650980 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgController.cs @@ -0,0 +1,6 @@ +namespace VirtualNes.Core +{ + public class CfgController + { + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgController.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgController.cs.meta new file mode 100644 index 0000000..750d782 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3328948cdc73baa4fb90c995f39f454f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgEmulator.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgEmulator.cs new file mode 100644 index 0000000..ac0f43d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgEmulator.cs @@ -0,0 +1,18 @@ +namespace VirtualNes.Core +{ + public class CfgEmulator + { + public bool bIllegalOp { get; set; } = false; + public bool bAutoFrameSkip { get; set; } = true; + public bool bThrottle { get; set; } = true; + public int nThrottleFPS { get; set; } = 120; + public bool bBackground { get; set; } = false; + public int nPriority { get; set; } = 3; + public bool bFourPlayer { get; set; } = true; + public bool bCrcCheck { get; set; } = true; + public bool bDiskThrottle { get; set; } = true; + public bool bLoadFullscreen { get; set; } = false; + public bool bPNGsnapshot { get; set; } = false; + public bool bAutoIPS { get; set; } = false; + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgEmulator.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgEmulator.cs.meta new file mode 100644 index 0000000..1a5035c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgEmulator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aae682cf38878ae40a449ab1a13fc7fc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgExtraSound.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgExtraSound.cs new file mode 100644 index 0000000..9698aee --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgExtraSound.cs @@ -0,0 +1,6 @@ +namespace VirtualNes.Core +{ + public class CfgExtraSound + { + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgExtraSound.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgExtraSound.cs.meta new file mode 100644 index 0000000..3a37df9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgExtraSound.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c707e4c8c38fa2e40a884047d0582b7e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGeneral.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGeneral.cs new file mode 100644 index 0000000..ec6eb1d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGeneral.cs @@ -0,0 +1,7 @@ +namespace VirtualNes.Core +{ + public class CfgGeneral + { + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGeneral.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGeneral.cs.meta new file mode 100644 index 0000000..84efe80 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGeneral.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 797171ffbac5b8748923ba914141781d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGraphics.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGraphics.cs new file mode 100644 index 0000000..d3e1f64 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGraphics.cs @@ -0,0 +1,39 @@ +namespace VirtualNes.Core +{ + public class CfgGraphics + { + public bool bAspect = false; + public bool bAllSprite = true; + public bool bAllLine = false; + public bool bFPSDisp = false; + public bool bTVFrame = false; + public bool bScanline = false; + public int nScanlineColor = 75; + public bool bSyncDraw = false; + public bool bFitZoom = false; + + public bool bLeftClip = true; + + public bool bWindowVSync = false; + + public bool bSyncNoSleep = false; + + public bool bDiskAccessLamp = false; + + public bool bDoubleSize = false; + public bool bSystemMemory = false; + public bool bUseHEL = false; + + public bool bNoSquareList = false; + + public int nGraphicsFilter = 0; + + public uint dwDisplayWidth = 640; + public uint dwDisplayHeight = 480; + public uint dwDisplayDepth = 16; + public uint dwDisplayRate = 0; + + public bool bPaletteFile = false; + public char[] szPaletteFile = new char[260]; + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGraphics.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGraphics.cs.meta new file mode 100644 index 0000000..73cbd53 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgGraphics.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5d72263cee06c74e94d67af00befbdf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLanguage.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLanguage.cs new file mode 100644 index 0000000..9ad0ca3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLanguage.cs @@ -0,0 +1,6 @@ +namespace VirtualNes.Core +{ + public class CfgLanguage + { + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLanguage.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLanguage.cs.meta new file mode 100644 index 0000000..71f37e3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLanguage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c23af0b4dd8a4e04a89d1a380c54688f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLauncher.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLauncher.cs new file mode 100644 index 0000000..cf1e5eb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLauncher.cs @@ -0,0 +1,6 @@ +namespace VirtualNes.Core +{ + public class CfgLauncher + { + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLauncher.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLauncher.cs.meta new file mode 100644 index 0000000..e752de0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgLauncher.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a033c816849b204c8cda167cd1fddb0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgMovie.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgMovie.cs new file mode 100644 index 0000000..0e0dcbf --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgMovie.cs @@ -0,0 +1,14 @@ +using System; + +namespace VirtualNes.Core +{ + public class CfgMovie + { + public byte[] bUsePlayer = new byte[4] { 0xFF, 0x00, 0x00, 0x00 }; + public bool bRerecord = true; + public bool bLoopPlay = false; + public bool bResetRec = false; + public bool bPadDisplay = false; + public bool bTimeDisplay = false; + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgMovie.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgMovie.cs.meta new file mode 100644 index 0000000..cb49734 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgMovie.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fdbdc9850f494ad44a16ec1ec82157cc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgNetPlay.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgNetPlay.cs new file mode 100644 index 0000000..d5efce1 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgNetPlay.cs @@ -0,0 +1,6 @@ +namespace VirtualNes.Core +{ + public class CfgNetPlay + { + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgNetPlay.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgNetPlay.cs.meta new file mode 100644 index 0000000..f781314 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgNetPlay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a81c95a03cbc4f4298e034f2b5cab7c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgPath.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgPath.cs new file mode 100644 index 0000000..6a28259 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgPath.cs @@ -0,0 +1,25 @@ +using System; + +namespace VirtualNes.Core +{ + public class CfgPath + { + public bool bRomPath = true; + public bool bSavePath = true; + public bool bStatePath = true; + public bool bSnapshotPath = true; + public bool bMoviePath = true; + public bool bWavePath = true; + public bool bCheatPath = true; + public bool bIpsPath = true; + + public string szRomPath = "roms"; + public string szSavePath = "save"; + public string szStatePath = "state"; + public string szSnapshotPath = "snapshot"; + public string szMoviePath = "movie"; + public string szWavePath = "wave"; + public string szCheatPath = "cheatcode"; + public string szIpsPath = "ips"; + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgPath.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgPath.cs.meta new file mode 100644 index 0000000..c9bd97a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgPath.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9368c1964e431040a469e2fb7b1c710 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgShortCut.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgShortCut.cs new file mode 100644 index 0000000..ac133b9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgShortCut.cs @@ -0,0 +1,6 @@ +namespace VirtualNes.Core +{ + public class CfgShortCut + { + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgShortCut.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgShortCut.cs.meta new file mode 100644 index 0000000..8af3ee4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgShortCut.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b4bc2f955a549544e9f03a73b98455fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgSound.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgSound.cs new file mode 100644 index 0000000..186b36b --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgSound.cs @@ -0,0 +1,19 @@ +namespace VirtualNes.Core +{ + public class CfgSound + { + public bool bEnable { get; set; } = true; + public int nRate { get; set; } = 48000; + public int nBits { get; set; } = 8; + public int nBufferSize { get; set; } = 4; + public int nFilterType { get; set; } = 0; + public bool bChangeTone { get; set; } = false; + public bool bDisableVolumeEffect { get; set; } = false; + public bool bExtraSoundEnable { get; set; } = true; + public short[] nVolume { get; set; } = new short[16] + { + 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, + }; + + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgSound.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgSound.cs.meta new file mode 100644 index 0000000..1ac8256 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/CfgSound.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f13850718ff124445ad8696ef491313d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/EmulatorConfig.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/EmulatorConfig.cs new file mode 100644 index 0000000..b24afe0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/EmulatorConfig.cs @@ -0,0 +1,51 @@ +namespace VirtualNes.Core +{ + public class EmulatorConfig + { + private bool m_bKeyboardDisable; + + public CfgGeneral general { get; private set; } = new CfgGeneral(); + public CfgPath path { get; private set; } = new CfgPath(); + public CfgEmulator emulator { get; private set; } = new CfgEmulator(); + public CfgGraphics graphics { get; private set; } = new CfgGraphics(); + public CfgSound sound { get; private set; } = new CfgSound(); + public CfgShortCut shortcut { get; private set; } = new CfgShortCut(); + public CfgLanguage language { get; private set; } = new CfgLanguage(); + public CfgController controller { get; private set; } = new CfgController(); + public CfgMovie movie { get; private set; } = new CfgMovie(); + public CfgLauncher launcher { get; private set; } = new CfgLauncher(); + public CfgExtraSound extsound { get; private set; } = new CfgExtraSound(); + public CfgNetPlay netplay { get; private set; } = new CfgNetPlay(); + } + + public static class GameOption + { + // Defaultä¿å­˜ + public static int defRenderMethod; + public static int defIRQtype; + public static bool defFrameIRQ; + public static bool defVideoMode; + + // データ + public static int nRenderMethod; + public static int nIRQtype; + public static bool bFrameIRQ; + public static bool bVideoMode; + + public static void Load(uint crc) + { + nRenderMethod = defRenderMethod; + nIRQtype = defIRQtype; + bFrameIRQ = defFrameIRQ; + bVideoMode = defVideoMode; + } + + public static void Load(uint gid, uint mid) + { + nRenderMethod = defRenderMethod; + nIRQtype = defIRQtype; + bFrameIRQ = defFrameIRQ; + bVideoMode = defVideoMode; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/EmulatorConfig.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/EmulatorConfig.cs.meta new file mode 100644 index 0000000..897ae92 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/EmulatorConfig/EmulatorConfig.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e0eb25b08646f64eaf7930288788c68 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs new file mode 100644 index 0000000..6f6d40e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs @@ -0,0 +1,68 @@ +using System.IO; + +namespace VirtualNes.Core +{ + public static class Supporter + { + private static ISupporterImpl s_support; + public static void Setup(ISupporterImpl supporter) + { + s_support = supporter; + } + + public static Stream OpenRom(string fname) + { + return s_support.OpenRom(fname); + } + + public static void GetFilePathInfo(string fname, out string fullPath, out string directPath) + { + s_support.GetRomPathInfo(fname, out fullPath, out directPath); + } + + public static Stream OpenFile_DISKSYS() + { + return s_support.OpenFile_DISKSYS(); + } + + public static void SaveSRAMToFile(byte[] sramContent, string romName) + { + s_support.SaveSRAMToFile(sramContent, romName); + } + + public static void SaveDISKToFile(byte[] diskFileContent, string romName) + { + s_support.SaveDISKToFile(diskFileContent, romName); + } + + public static void PrepareDirectory(string directPath) + { + s_support.PrepareDirectory(directPath); + } + + public static void SaveFile(byte[] fileData, string directPath, string fileName) + { + s_support.SaveFile(fileData, directPath, fileName); + } + public static Stream OpenFile(string directPath, string fileName) + { + return s_support.OpenFile(directPath, fileName); + } + + public static EmulatorConfig Config => s_support.Config; + } + + public interface ISupporterImpl + { + Stream OpenRom(string fname); + void GetRomPathInfo(string fname, out string fullPath, out string directPath); + Stream OpenFile_DISKSYS(); + void SaveSRAMToFile(byte[] sramContent, string romName); + void SaveDISKToFile(byte[] diskFileContent, string romName); + EmulatorConfig Config { get; } + + void PrepareDirectory(string directPath); + void SaveFile(byte[] fileData, string directPath, string fileName); + Stream OpenFile(string directPath, string fileName); + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs.meta new file mode 100644 index 0000000..7f64c93 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ebaf8e516ae82d647bb19ffff17fd03d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNes.Core.asmdef b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VirtualNes.Core.asmdef similarity index 68% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/MyNes.Core.asmdef rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/VirtualNes.Core.asmdef index 4637f1d..49a4484 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNes.Core.asmdef +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VirtualNes.Core.asmdef @@ -1,9 +1,7 @@ { - "name": "MyNes.Core", - "rootNamespace": "", - "references": [ - "GUID:1c66728ad60364b82bf095d383b87458" - ], + "name": "VirtualNes.Core", + "rootNamespace": "VirtualNes.Core", + "references": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNes.Core.asmdef.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VirtualNes.Core.asmdef.meta similarity index 76% rename from AxibugEmuOnline.Client/Assets/MyNes.Core/MyNes.Core.asmdef.meta rename to AxibugEmuOnline.Client/Assets/VirtualNes.Core/VirtualNes.Core.asmdef.meta index 0ab097f..9892237 100644 --- a/AxibugEmuOnline.Client/Assets/MyNes.Core/MyNes.Core.asmdef.meta +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VirtualNes.Core.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0c194730510bd1b4fad0398ccfe4235b +guid: 390a2c4058e5c304a87e8be70c84d80b AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VsUnisystem.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VsUnisystem.cs new file mode 100644 index 0000000..18f995c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VsUnisystem.cs @@ -0,0 +1,49 @@ +namespace VirtualNes.Core +{ + public class VSDIPSWITCH + { + public string name; + public ushort value; + } + + + public static class VsUnisystem + { + public static VSDIPSWITCH[] vsdip_default = new VSDIPSWITCH[] + { + new VSDIPSWITCH{name="Unknown", value= 0x0100}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x01}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x0200}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x02}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x0400}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x04}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x0800}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x08}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x1000}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x10}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x2000}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x20}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x4000}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x40}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name="Unknown", value= 0x8000}, + new VSDIPSWITCH{name="Off", value= 0x00}, + new VSDIPSWITCH{name="On", value= 0x80}, + new VSDIPSWITCH{name=null, value= 0xFF}, + new VSDIPSWITCH{name=null, value= 0 }, + }; + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VsUnisystem.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VsUnisystem.cs.meta new file mode 100644 index 0000000..3d06276 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/VsUnisystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db82d3b2d60f2c14fa3c5582acc439c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset b/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset index 8638a73..c3d97d1 100644 --- a/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset +++ b/AxibugEmuOnline.Client/ProjectSettings/ProjectSettings.asset @@ -649,7 +649,7 @@ PlayerSettings: managedStrippingLevel: {} incrementalIl2cppBuild: {} suppressCommonWarnings: 1 - allowUnsafeCode: 0 + allowUnsafeCode: 1 useDeterministicCompilation: 1 useReferenceAssemblies: 1 enableRoslynAnalyzers: 1 diff --git a/README.md b/README.md index 616fa9e..df7f3fb 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,30 @@ ~~åšå¸§ç¼“,颜色查找下标缓存,åšåŒæ­¥ï¼ŒåŠ ä¸Šç½‘络库,并实现æœåŠ¡ç«¯ã€‚达到如上效果。~~ -éšåŽï¼Œæˆ‘们选择了更为全é¢çš„MyNes作为Nes模拟器核心,以此åšäºŒæ¬¡å¼€å‘和魔改。并实现自己的æœåŠ¡ç«¯å’Œå®¢æˆ·ç«¯è”机逻辑 +~~----~~ + +~~éšåŽï¼Œæˆ‘们选择了更为全é¢çš„MyNes作为Nes模拟器核心,以此åšäºŒæ¬¡å¼€å‘和魔改。并实现自己的æœåŠ¡ç«¯å’Œå®¢æˆ·ç«¯è”机逻辑~~ + +~~----~~ + +然åŽæˆ‘们åˆå¼€å§‹å°è¯•æŠŠ VirtualNes 的内核翻译为C#,在å°è¯•å†…核的路上越走越远…… + + +### 关于Mapperæ”¯æŒ + +众所周知 NES/FC 在整个生命周期中,有å„ç§åŽ‚商扩展的å„色å¡å¸¦Mapper, + +Mapper支æŒè¶Šå¤šï¼Œé€šä¿—讲就是支æŒæ›´å¤šå¡å¸¦ã€‚ + +由于我们最终使用的是 VirtualNes CPP翻译CSharp, + +那么,ç†è®ºä¸Šå·²ç»ç®—拥有最全的模拟器Mapper支æŒï¼Œå‡ ä¹Žæ²¡æœ‰ä¸èƒ½è¿è¡Œçš„游æˆï¼ˆå®˜æ–¹æ¸¸æˆï¼‰ + +而VirtualNes官方的Mapper的基础上,也有很多民间二次补充,(使得一些特殊的游æˆä¹Ÿå¯ä»¥è¿è¡Œï¼Œæ¯”如 åžé£Ÿå¤©åœ°2孔明传 中文版,ç¦å·žå¤–星科技等等,就得以支æŒï¼‰ + +我们的项目也必须支æŒä¸Š! 咱们也åŒæ­¥è¦è¿›è¡Œä¸€ä¸ªè¡¥å…… + +追加了特殊的失传Mapper 162,163,175,176,178,192,195,199,216 (from https://github.com/yamanyandakure/VirtuaNES097) diff --git a/virtuanessrc097-master/.gitignore b/virtuanessrc097-master/.gitignore new file mode 100644 index 0000000..7d002f6 --- /dev/null +++ b/virtuanessrc097-master/.gitignore @@ -0,0 +1,167 @@ +VirtuaNES.exe +VirtuaNES.ini + +################# +## Eclipse +################# +.vs/ +debug/ +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.vspscc +.builds +*.dotCover + +## TODO: If you have NuGet Package Restore enabled, uncomment this +#packages/ + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp + +# ReSharper is a .NET coding add-in +_ReSharper* + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Others +[Bb]in +[Oo]bj +sql +TestResults +*.Cache +ClientBin +stylecop.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + + + +############ +## Windows +############ + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg + +# Mac crap +.DS_Store diff --git a/virtuanessrc097-master/AboutDlg.cpp b/virtuanessrc097-master/AboutDlg.cpp new file mode 100644 index 0000000..fff98b8 Binary files /dev/null and b/virtuanessrc097-master/AboutDlg.cpp differ diff --git a/virtuanessrc097-master/AboutDlg.h b/virtuanessrc097-master/AboutDlg.h new file mode 100644 index 0000000..7f59354 Binary files /dev/null and b/virtuanessrc097-master/AboutDlg.h differ diff --git a/virtuanessrc097-master/App.cpp b/virtuanessrc097-master/App.cpp new file mode 100644 index 0000000..4db97f8 Binary files /dev/null and b/virtuanessrc097-master/App.cpp differ diff --git a/virtuanessrc097-master/App.h b/virtuanessrc097-master/App.h new file mode 100644 index 0000000..71a71a9 Binary files /dev/null and b/virtuanessrc097-master/App.h differ diff --git a/virtuanessrc097-master/Archive.cpp b/virtuanessrc097-master/Archive.cpp new file mode 100644 index 0000000..1647271 Binary files /dev/null and b/virtuanessrc097-master/Archive.cpp differ diff --git a/virtuanessrc097-master/Archive.h b/virtuanessrc097-master/Archive.h new file mode 100644 index 0000000..c018f85 Binary files /dev/null and b/virtuanessrc097-master/Archive.h differ diff --git a/virtuanessrc097-master/AviConvDlg.cpp b/virtuanessrc097-master/AviConvDlg.cpp new file mode 100644 index 0000000..5dba4e1 Binary files /dev/null and b/virtuanessrc097-master/AviConvDlg.cpp differ diff --git a/virtuanessrc097-master/AviConvDlg.h b/virtuanessrc097-master/AviConvDlg.h new file mode 100644 index 0000000..f1244ea Binary files /dev/null and b/virtuanessrc097-master/AviConvDlg.h differ diff --git a/virtuanessrc097-master/AviWriter.cpp b/virtuanessrc097-master/AviWriter.cpp new file mode 100644 index 0000000..d6e92a3 Binary files /dev/null and b/virtuanessrc097-master/AviWriter.cpp differ diff --git a/virtuanessrc097-master/AviWriter.h b/virtuanessrc097-master/AviWriter.h new file mode 100644 index 0000000..715b1d6 Binary files /dev/null and b/virtuanessrc097-master/AviWriter.h differ diff --git a/virtuanessrc097-master/CHyperLink.h b/virtuanessrc097-master/CHyperLink.h new file mode 100644 index 0000000..5465a70 Binary files /dev/null and b/virtuanessrc097-master/CHyperLink.h differ diff --git a/virtuanessrc097-master/ChatDlg.cpp b/virtuanessrc097-master/ChatDlg.cpp new file mode 100644 index 0000000..2bfe5d3 Binary files /dev/null and b/virtuanessrc097-master/ChatDlg.cpp differ diff --git a/virtuanessrc097-master/ChatDlg.h b/virtuanessrc097-master/ChatDlg.h new file mode 100644 index 0000000..1e97d6a Binary files /dev/null and b/virtuanessrc097-master/ChatDlg.h differ diff --git a/virtuanessrc097-master/CheatDlg.cpp b/virtuanessrc097-master/CheatDlg.cpp new file mode 100644 index 0000000..b159266 Binary files /dev/null and b/virtuanessrc097-master/CheatDlg.cpp differ diff --git a/virtuanessrc097-master/CheatDlg.h b/virtuanessrc097-master/CheatDlg.h new file mode 100644 index 0000000..ff3b7ee Binary files /dev/null and b/virtuanessrc097-master/CheatDlg.h differ diff --git a/virtuanessrc097-master/Com.cpp b/virtuanessrc097-master/Com.cpp new file mode 100644 index 0000000..6756f27 Binary files /dev/null and b/virtuanessrc097-master/Com.cpp differ diff --git a/virtuanessrc097-master/Com.h b/virtuanessrc097-master/Com.h new file mode 100644 index 0000000..a4edd86 Binary files /dev/null and b/virtuanessrc097-master/Com.h differ diff --git a/virtuanessrc097-master/Config.cpp b/virtuanessrc097-master/Config.cpp new file mode 100644 index 0000000..5ce1c58 Binary files /dev/null and b/virtuanessrc097-master/Config.cpp differ diff --git a/virtuanessrc097-master/Config.h b/virtuanessrc097-master/Config.h new file mode 100644 index 0000000..22cbbab Binary files /dev/null and b/virtuanessrc097-master/Config.h differ diff --git a/virtuanessrc097-master/ControllerDlg.cpp b/virtuanessrc097-master/ControllerDlg.cpp new file mode 100644 index 0000000..bb0fd9a Binary files /dev/null and b/virtuanessrc097-master/ControllerDlg.cpp differ diff --git a/virtuanessrc097-master/ControllerDlg.h b/virtuanessrc097-master/ControllerDlg.h new file mode 100644 index 0000000..86bb4da Binary files /dev/null and b/virtuanessrc097-master/ControllerDlg.h differ diff --git a/virtuanessrc097-master/Crclib.cpp b/virtuanessrc097-master/Crclib.cpp new file mode 100644 index 0000000..3587caa Binary files /dev/null and b/virtuanessrc097-master/Crclib.cpp differ diff --git a/virtuanessrc097-master/Crclib.h b/virtuanessrc097-master/Crclib.h new file mode 100644 index 0000000..558aa9f Binary files /dev/null and b/virtuanessrc097-master/Crclib.h differ diff --git a/virtuanessrc097-master/DatachBarcodeDlg.cpp b/virtuanessrc097-master/DatachBarcodeDlg.cpp new file mode 100644 index 0000000..3a1c4b5 Binary files /dev/null and b/virtuanessrc097-master/DatachBarcodeDlg.cpp differ diff --git a/virtuanessrc097-master/DatachBarcodeDlg.h b/virtuanessrc097-master/DatachBarcodeDlg.h new file mode 100644 index 0000000..816ae73 Binary files /dev/null and b/virtuanessrc097-master/DatachBarcodeDlg.h differ diff --git a/virtuanessrc097-master/DebugOut.cpp b/virtuanessrc097-master/DebugOut.cpp new file mode 100644 index 0000000..65fab74 Binary files /dev/null and b/virtuanessrc097-master/DebugOut.cpp differ diff --git a/virtuanessrc097-master/DebugOut.h b/virtuanessrc097-master/DebugOut.h new file mode 100644 index 0000000..9bf1db3 Binary files /dev/null and b/virtuanessrc097-master/DebugOut.h differ diff --git a/virtuanessrc097-master/DipSwitchDlg.cpp b/virtuanessrc097-master/DipSwitchDlg.cpp new file mode 100644 index 0000000..f2eeb2e Binary files /dev/null and b/virtuanessrc097-master/DipSwitchDlg.cpp differ diff --git a/virtuanessrc097-master/DipSwitchDlg.h b/virtuanessrc097-master/DipSwitchDlg.h new file mode 100644 index 0000000..6d23e34 Binary files /dev/null and b/virtuanessrc097-master/DipSwitchDlg.h differ diff --git a/virtuanessrc097-master/DirectDraw.cpp b/virtuanessrc097-master/DirectDraw.cpp new file mode 100644 index 0000000..cfe9093 Binary files /dev/null and b/virtuanessrc097-master/DirectDraw.cpp differ diff --git a/virtuanessrc097-master/DirectDraw.h b/virtuanessrc097-master/DirectDraw.h new file mode 100644 index 0000000..834141a Binary files /dev/null and b/virtuanessrc097-master/DirectDraw.h differ diff --git a/virtuanessrc097-master/DirectInput.cpp b/virtuanessrc097-master/DirectInput.cpp new file mode 100644 index 0000000..870dcdd Binary files /dev/null and b/virtuanessrc097-master/DirectInput.cpp differ diff --git a/virtuanessrc097-master/DirectInput.h b/virtuanessrc097-master/DirectInput.h new file mode 100644 index 0000000..ee4d7ad Binary files /dev/null and b/virtuanessrc097-master/DirectInput.h differ diff --git a/virtuanessrc097-master/DirectSound.cpp b/virtuanessrc097-master/DirectSound.cpp new file mode 100644 index 0000000..cd01df0 Binary files /dev/null and b/virtuanessrc097-master/DirectSound.cpp differ diff --git a/virtuanessrc097-master/DirectSound.h b/virtuanessrc097-master/DirectSound.h new file mode 100644 index 0000000..56324a6 Binary files /dev/null and b/virtuanessrc097-master/DirectSound.h differ diff --git a/virtuanessrc097-master/Doc/Copying.txt b/virtuanessrc097-master/Doc/Copying.txt new file mode 100644 index 0000000..47a5504 Binary files /dev/null and b/virtuanessrc097-master/Doc/Copying.txt differ diff --git a/virtuanessrc097-master/Doc/ReadmeSrc.txt b/virtuanessrc097-master/Doc/ReadmeSrc.txt new file mode 100644 index 0000000..b1c1ad5 Binary files /dev/null and b/virtuanessrc097-master/Doc/ReadmeSrc.txt differ diff --git a/virtuanessrc097-master/EmuThread.cpp b/virtuanessrc097-master/EmuThread.cpp new file mode 100644 index 0000000..50f0bd4 Binary files /dev/null and b/virtuanessrc097-master/EmuThread.cpp differ diff --git a/virtuanessrc097-master/EmuThread.h b/virtuanessrc097-master/EmuThread.h new file mode 100644 index 0000000..ad51812 Binary files /dev/null and b/virtuanessrc097-master/EmuThread.h differ diff --git a/virtuanessrc097-master/EmulatorDlg.cpp b/virtuanessrc097-master/EmulatorDlg.cpp new file mode 100644 index 0000000..f20382d Binary files /dev/null and b/virtuanessrc097-master/EmulatorDlg.cpp differ diff --git a/virtuanessrc097-master/EmulatorDlg.h b/virtuanessrc097-master/EmulatorDlg.h new file mode 100644 index 0000000..5963471 Binary files /dev/null and b/virtuanessrc097-master/EmulatorDlg.h differ diff --git a/virtuanessrc097-master/English.vlp b/virtuanessrc097-master/English.vlp new file mode 100644 index 0000000..868a8af Binary files /dev/null and b/virtuanessrc097-master/English.vlp differ diff --git a/virtuanessrc097-master/ExtSoundFile.h b/virtuanessrc097-master/ExtSoundFile.h new file mode 100644 index 0000000..49847cd Binary files /dev/null and b/virtuanessrc097-master/ExtSoundFile.h differ diff --git a/virtuanessrc097-master/FolderDlg.cpp b/virtuanessrc097-master/FolderDlg.cpp new file mode 100644 index 0000000..f58b913 Binary files /dev/null and b/virtuanessrc097-master/FolderDlg.cpp differ diff --git a/virtuanessrc097-master/FolderDlg.h b/virtuanessrc097-master/FolderDlg.h new file mode 100644 index 0000000..d16e783 Binary files /dev/null and b/virtuanessrc097-master/FolderDlg.h differ diff --git a/virtuanessrc097-master/GameOptionDlg.cpp b/virtuanessrc097-master/GameOptionDlg.cpp new file mode 100644 index 0000000..acc5e40 Binary files /dev/null and b/virtuanessrc097-master/GameOptionDlg.cpp differ diff --git a/virtuanessrc097-master/GameOptionDlg.h b/virtuanessrc097-master/GameOptionDlg.h new file mode 100644 index 0000000..514e620 Binary files /dev/null and b/virtuanessrc097-master/GameOptionDlg.h differ diff --git a/virtuanessrc097-master/GraphicsDlg.cpp b/virtuanessrc097-master/GraphicsDlg.cpp new file mode 100644 index 0000000..08b4f3c Binary files /dev/null and b/virtuanessrc097-master/GraphicsDlg.cpp differ diff --git a/virtuanessrc097-master/GraphicsDlg.h b/virtuanessrc097-master/GraphicsDlg.h new file mode 100644 index 0000000..7c99261 Binary files /dev/null and b/virtuanessrc097-master/GraphicsDlg.h differ diff --git a/virtuanessrc097-master/JoyAxisDlg.cpp b/virtuanessrc097-master/JoyAxisDlg.cpp new file mode 100644 index 0000000..fd41cc3 Binary files /dev/null and b/virtuanessrc097-master/JoyAxisDlg.cpp differ diff --git a/virtuanessrc097-master/JoyAxisDlg.h b/virtuanessrc097-master/JoyAxisDlg.h new file mode 100644 index 0000000..6548adc Binary files /dev/null and b/virtuanessrc097-master/JoyAxisDlg.h differ diff --git a/virtuanessrc097-master/LanguageDlg.cpp b/virtuanessrc097-master/LanguageDlg.cpp new file mode 100644 index 0000000..57e626d Binary files /dev/null and b/virtuanessrc097-master/LanguageDlg.cpp differ diff --git a/virtuanessrc097-master/LanguageDlg.h b/virtuanessrc097-master/LanguageDlg.h new file mode 100644 index 0000000..21805b6 Binary files /dev/null and b/virtuanessrc097-master/LanguageDlg.h differ diff --git a/virtuanessrc097-master/LauncherDlg.cpp b/virtuanessrc097-master/LauncherDlg.cpp new file mode 100644 index 0000000..a8ac3fe Binary files /dev/null and b/virtuanessrc097-master/LauncherDlg.cpp differ diff --git a/virtuanessrc097-master/LauncherDlg.h b/virtuanessrc097-master/LauncherDlg.h new file mode 100644 index 0000000..9643a89 Binary files /dev/null and b/virtuanessrc097-master/LauncherDlg.h differ diff --git a/virtuanessrc097-master/MMTimer.cpp b/virtuanessrc097-master/MMTimer.cpp new file mode 100644 index 0000000..25f2134 Binary files /dev/null and b/virtuanessrc097-master/MMTimer.cpp differ diff --git a/virtuanessrc097-master/MMTimer.h b/virtuanessrc097-master/MMTimer.h new file mode 100644 index 0000000..b6b22a5 Binary files /dev/null and b/virtuanessrc097-master/MMTimer.h differ diff --git a/virtuanessrc097-master/Macro.h b/virtuanessrc097-master/Macro.h new file mode 100644 index 0000000..2145b80 Binary files /dev/null and b/virtuanessrc097-master/Macro.h differ diff --git a/virtuanessrc097-master/MainFrame.cpp b/virtuanessrc097-master/MainFrame.cpp new file mode 100644 index 0000000..1076d0c Binary files /dev/null and b/virtuanessrc097-master/MainFrame.cpp differ diff --git a/virtuanessrc097-master/MainFrame.h b/virtuanessrc097-master/MainFrame.h new file mode 100644 index 0000000..2fb17ae Binary files /dev/null and b/virtuanessrc097-master/MainFrame.h differ diff --git a/virtuanessrc097-master/MemoryView.cpp b/virtuanessrc097-master/MemoryView.cpp new file mode 100644 index 0000000..27a2115 Binary files /dev/null and b/virtuanessrc097-master/MemoryView.cpp differ diff --git a/virtuanessrc097-master/MemoryView.h b/virtuanessrc097-master/MemoryView.h new file mode 100644 index 0000000..9cc093f Binary files /dev/null and b/virtuanessrc097-master/MemoryView.h differ diff --git a/virtuanessrc097-master/MovieDlg.cpp b/virtuanessrc097-master/MovieDlg.cpp new file mode 100644 index 0000000..167bcb4 Binary files /dev/null and b/virtuanessrc097-master/MovieDlg.cpp differ diff --git a/virtuanessrc097-master/MovieDlg.h b/virtuanessrc097-master/MovieDlg.h new file mode 100644 index 0000000..d7aaf7e Binary files /dev/null and b/virtuanessrc097-master/MovieDlg.h differ diff --git a/virtuanessrc097-master/MovieInfoDlg.cpp b/virtuanessrc097-master/MovieInfoDlg.cpp new file mode 100644 index 0000000..4b18542 Binary files /dev/null and b/virtuanessrc097-master/MovieInfoDlg.cpp differ diff --git a/virtuanessrc097-master/MovieInfoDlg.h b/virtuanessrc097-master/MovieInfoDlg.h new file mode 100644 index 0000000..4bdf656 Binary files /dev/null and b/virtuanessrc097-master/MovieInfoDlg.h differ diff --git a/virtuanessrc097-master/NES/APU.cpp b/virtuanessrc097-master/NES/APU.cpp new file mode 100644 index 0000000..4366b22 Binary files /dev/null and b/virtuanessrc097-master/NES/APU.cpp differ diff --git a/virtuanessrc097-master/NES/APU.h b/virtuanessrc097-master/NES/APU.h new file mode 100644 index 0000000..938d8e6 Binary files /dev/null and b/virtuanessrc097-master/NES/APU.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_FDS.cpp b/virtuanessrc097-master/NES/ApuEX/APU_FDS.cpp new file mode 100644 index 0000000..5481c2a Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_FDS.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_FDS.h b/virtuanessrc097-master/NES/ApuEX/APU_FDS.h new file mode 100644 index 0000000..d1d8bec Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_FDS.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_FME7.cpp b/virtuanessrc097-master/NES/ApuEX/APU_FME7.cpp new file mode 100644 index 0000000..85ca987 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_FME7.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_FME7.h b/virtuanessrc097-master/NES/ApuEX/APU_FME7.h new file mode 100644 index 0000000..a49008d Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_FME7.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_INTERFACE.h b/virtuanessrc097-master/NES/ApuEX/APU_INTERFACE.h new file mode 100644 index 0000000..abe78ee Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_INTERFACE.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_INTERNAL.cpp b/virtuanessrc097-master/NES/ApuEX/APU_INTERNAL.cpp new file mode 100644 index 0000000..5f2eb07 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_INTERNAL.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_INTERNAL.h b/virtuanessrc097-master/NES/ApuEX/APU_INTERNAL.h new file mode 100644 index 0000000..a4add6c Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_INTERNAL.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_MMC5.cpp b/virtuanessrc097-master/NES/ApuEX/APU_MMC5.cpp new file mode 100644 index 0000000..2b2e378 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_MMC5.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_MMC5.h b/virtuanessrc097-master/NES/ApuEX/APU_MMC5.h new file mode 100644 index 0000000..c6224bb Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_MMC5.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_N106.cpp b/virtuanessrc097-master/NES/ApuEX/APU_N106.cpp new file mode 100644 index 0000000..a9a2c06 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_N106.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_N106.h b/virtuanessrc097-master/NES/ApuEX/APU_N106.h new file mode 100644 index 0000000..3e98e5b Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_N106.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_VRC6.cpp b/virtuanessrc097-master/NES/ApuEX/APU_VRC6.cpp new file mode 100644 index 0000000..615bf26 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_VRC6.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_VRC6.h b/virtuanessrc097-master/NES/ApuEX/APU_VRC6.h new file mode 100644 index 0000000..995c802 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_VRC6.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_VRC7.cpp b/virtuanessrc097-master/NES/ApuEX/APU_VRC7.cpp new file mode 100644 index 0000000..aa8ec45 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_VRC7.cpp differ diff --git a/virtuanessrc097-master/NES/ApuEX/APU_VRC7.h b/virtuanessrc097-master/NES/ApuEX/APU_VRC7.h new file mode 100644 index 0000000..527485a Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/APU_VRC7.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/emu2413/2413tone.h b/virtuanessrc097-master/NES/ApuEX/emu2413/2413tone.h new file mode 100644 index 0000000..0e6bd91 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/emu2413/2413tone.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.c b/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.c new file mode 100644 index 0000000..b11fecb --- /dev/null +++ b/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.c @@ -0,0 +1,1545 @@ +/*********************************************************************************** + + emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 + + 2001 01-08 : Version 0.10 -- 1st version. + 2001 01-15 : Version 0.20 -- semi-public version. + 2001 01-16 : Version 0.30 -- 1st public version. + 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. + : Version 0.32 -- LPF implemented. + 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. + -- Fixed the LFO bug. + 2001 01-24 : Version 0.35 -- Fixed the drum problem, + support undocumented EG behavior. + 2001 02-02 : Version 0.38 -- Improved the performance. + Fixed the hi-hat and cymbal model. + Fixed the default percussive datas. + Noise reduction. + Fixed the feedback problem. + 2001 03-03 : Version 0.39 -- Fixed some drum bugs. + Improved the performance. + 2001 03-04 : Version 0.40 -- Improved the feedback. + Change the default table size. + Clock and Rate can be changed during play. + 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. + Added VRC7 patch (OPLL_reset_patch is changed). + Fix OPLL_reset() bug. + Added OPLL_setMask, OPLL_getMask and OPLL_toggleMask. + Added OPLL_writeIO. + + References: + fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). + s_opl.c -- 2001 written by mamiya (NEZplug development). + fmgen.cpp -- 1999,2000 written by cisc. + fmpac.ill -- 2000 created by NARUTO. + MSX-Datapack + YMU757 data sheet + YM2143 data sheet + +**************************************************************************************/ +#include +#include +#include +#include +#include "emu2413.h" + +#if defined(_MSC_VER) +#define INLINE __inline +#elif defined(__GNUC__) +#define INLINE __inline__ +#else +#define INLINE +#endif + +#define OPLL_TONE_NUM 2 +static unsigned char default_inst[OPLL_TONE_NUM][(16+3)*16]= +{ + { +#include "2413tone.h" + }, + { +#include "vrc7tone.h" + } +}; + +/* Size of Sintable ( 1 -- 18 can be used, but 7 -- 14 recommended.)*/ +#define PG_BITS 9 +#define PG_WIDTH (1<>(b)) + +/* Leave the lower b bit(s). */ +#define LOWBITS(c,b) ((c)&((1<<(b))-1)) + +/* Expand x which is s bits to d bits. */ +#define EXPAND_BITS(x,s,d) ((x)<<((d)-(s))) + +/* Expand x which is s bits to d bits and fill expanded bits '1' */ +#define EXPAND_BITS_X(x,s,d) (((x)<<((d)-(s)))|((1<<((d)-(s)))-1)) + +/* Adjust envelope speed which depends on sampling rate. */ +#define rate_adjust(x) (uint32)((double)(x)*clk/72/rate + 0.5) /* +0.5 to round */ + +#define MOD(x) ch[x]->mod +#define CAR(x) ch[x]->car + +/* Sampling rate */ +static uint32 rate ; +/* Input clock */ +static uint32 clk ; + +/* WaveTable for each envelope amp */ +static uint32 fullsintable[PG_WIDTH] ; +static uint32 halfsintable[PG_WIDTH] ; +static uint32 snaretable[PG_WIDTH] ; + +static int32 noiseAtable[64] = { + -1,1,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0, + -1,1,0,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0 +} ; + +static int32 noiseBtable[8] = { + -1,1,-1,1,0,0,0,0 +} ; + +static uint32 *waveform[5] = {fullsintable,halfsintable,snaretable} ; + +/* LFO Table */ +static int32 pmtable[PM_PG_WIDTH] ; +static int32 amtable[AM_PG_WIDTH] ; + +/* Noise and LFO */ +static uint32 pm_dphase ; +static uint32 am_dphase ; + +/* dB to Liner table */ +static int32 DB2LIN_TABLE[(DB_MUTE + DB_MUTE)*2] ; + +/* Liner to Log curve conversion table (for Attack rate). */ +static uint32 AR_ADJUST_TABLE[1<=DB_MUTE) DB2LIN_TABLE[i] = 0 ; + DB2LIN_TABLE[i+ DB_MUTE + DB_MUTE] = -DB2LIN_TABLE[i] ; + } +} + +/* Liner(+0.0 - +1.0) to dB((1<0) noiseAtable[i] = DB_POS(0) ; + else if(noiseAtable[i]<0) noiseAtable[i] = DB_NEG(0) ; + else noiseAtable[i] = DB_MUTE - 1 ; + } + + for( i = 0 ; i < 8 ; i++ ) + { + if(noiseBtable[i]>0) noiseBtable[i] = DB_POS(0) ; + else if(noiseBtable[i]<0) noiseBtable[i] = DB_NEG(0) ; + else noiseBtable[i] = DB_MUTE - 1 ; + } + +} + +/* Table for Pitch Modulator */ +static void makePmTable(void) +{ + int i ; + + for(i = 0 ; i < PM_PG_WIDTH ; i++ ) + pmtable[i] = (int32)((double)PM_AMP * pow(2,(double)PM_DEPTH*sin(2.0*PI*i/PM_PG_WIDTH)/1200)) ; +} + +/* Table for Amp Modulator */ +static void makeAmTable(void) +{ + int i ; + + for(i = 0 ; i < AM_PG_WIDTH ; i++ ) + amtable[i] = (int32)((double)AM_DEPTH/2/DB_STEP * (1.0 + sin(2.0*PI*i/PM_PG_WIDTH))) ; +} + +/* Phase increment counter table */ +static void makeDphaseTable(void) +{ + uint32 fnum, block , ML ; + uint32 mltable[16]={ 1,1*2,2*2,3*2,4*2,5*2,6*2,7*2,8*2,9*2,10*2,10*2,12*2,12*2,15*2,15*2 } ; + + for(fnum=0; fnum<512; fnum++) + for(block=0; block<8; block++) + for(ML=0; ML<16; ML++) + dphaseTable[fnum][block][ML] = rate_adjust(((fnum * mltable[ML])<>(20-DP_BITS)) ; +} + +static void makeTllTable(void) +{ +#define dB2(x) (uint32)((x)*2) + + static uint32 kltable[16] = { + dB2( 0.000),dB2( 9.000),dB2(12.000),dB2(13.875),dB2(15.000),dB2(16.125),dB2(16.875),dB2(17.625), + dB2(18.000),dB2(18.750),dB2(19.125),dB2(19.500),dB2(19.875),dB2(20.250),dB2(20.625),dB2(21.000) + } ; + + int32 tmp ; + int fnum, block ,TL , KL ; + + for(fnum=0; fnum<16; fnum++) + for(block=0; block<8; block++) + for(TL=0; TL<64; TL++) + for(KL=0; KL<4; KL++) + { + if(KL==0) + { + tllTable[fnum][block][TL][KL] = TL2EG(TL) ; + } + else + { + tmp = kltable[fnum] - dB2(3.000) * (7 - block) ; + if(tmp <= 0) + tllTable[fnum][block][TL][KL] = TL2EG(TL) ; + else + tllTable[fnum][block][TL][KL] = (uint32)((tmp>>(3-KL))/EG_STEP) + TL2EG(TL) ; + } + } +} + +/* Rate Table for Attack */ +static void makeDphaseARTable(void) +{ + int AR,Rks,RM,RL ; + + for(AR=0; AR<16; AR++) + for(Rks=0; Rks<16; Rks++) + { + RM = AR + (Rks>>2) ; + if(RM>15) RM = 15 ; + RL = Rks&3 ; + switch(AR) + { + case 0: + dphaseARTable[AR][Rks] = 0 ; + break ; + case 15: + dphaseARTable[AR][Rks] = EG_DP_WIDTH ; + break ; + default: + dphaseARTable[AR][Rks] = rate_adjust(( 3 * (RL + 4) << (RM + 1))) ; + break ; + } + } +} + +/* Rate Table for Decay */ +static void makeDphaseDRTable(void) +{ + int DR,Rks,RM,RL ; + + for(DR=0; DR<16; DR++) + for(Rks=0; Rks<16; Rks++) + { + RM = DR + (Rks>>2) ; + RL = Rks&3 ; + if(RM>15) RM = 15 ; + switch(DR) + { + case 0: + dphaseDRTable[DR][Rks] = 0 ; + break ; + default: + dphaseDRTable[DR][Rks] = rate_adjust((RL + 4) << (RM - 1)); + break ; + } + } +} + +static void makeRksTable(void) +{ + + int fnum8, block, KR ; + + for(fnum8 = 0 ; fnum8 < 2 ; fnum8++) + for(block = 0 ; block < 8 ; block++) + for(KR = 0; KR < 2 ; KR++) + { + if(KR!=0) + rksTable[fnum8][block][KR] = ( block << 1 ) + fnum8 ; + else + rksTable[fnum8][block][KR] = block >> 1 ; + } +} + + +void dump2patch(unsigned char *dump, OPLL_PATCH *patch) +{ + patch[0].AM = (dump[0]>>7)&1 ; + patch[1].AM = (dump[1]>>7)&1 ; + patch[0].PM = (dump[0]>>6)&1 ; + patch[1].PM = (dump[1]>>6)&1 ; + patch[0].EG = (dump[0]>>5)&1 ; + patch[1].EG = (dump[1]>>5)&1 ; + patch[0].KR = (dump[0]>>4)&1 ; + patch[1].KR = (dump[1]>>4)&1 ; + patch[0].ML = (dump[0])&15 ; + patch[1].ML = (dump[1])&15 ; + patch[0].KL = (dump[2]>>6)&3 ; + patch[1].KL = (dump[3]>>6)&3 ; + patch[0].TL = (dump[2])&63 ; + patch[0].FB = (dump[3])&7 ; + patch[0].WF = (dump[3]>>3)&1 ; + patch[1].WF = (dump[3]>>4)&1 ; + patch[0].AR = (dump[4]>>4)&15 ; + patch[1].AR = (dump[5]>>4)&15 ; + patch[0].DR = (dump[4])&15 ; + patch[1].DR = (dump[5])&15 ; + patch[0].SL = (dump[6]>>4)&15 ; + patch[1].SL = (dump[7]>>4)&15 ; + patch[0].RR = (dump[6])&15 ; + patch[1].RR = (dump[7])&15 ; +} + +static void makeDefaultPatch() +{ + int i, j ; + + for(i=0;ieg_mode) + { + case ATTACK: + return dphaseARTable[slot->patch->AR][slot->rks] ; + + case DECAY: + return dphaseDRTable[slot->patch->DR][slot->rks] ; + + case SUSHOLD: + return 0 ; + + case SUSTINE: + return dphaseDRTable[slot->patch->RR][slot->rks] ; + + case RELEASE: + if(slot->sustine) + return dphaseDRTable[5][slot->rks] ; + else if(slot->patch->EG) + return dphaseDRTable[slot->patch->RR][slot->rks] ; + else + return dphaseDRTable[7][slot->rks] ; + + case FINISH: + return 0 ; + + default: + return 0 ; + } +} + +/************************************************************* + + OPLL internal interfaces + +*************************************************************/ +#define SLOT_BD1 12 +#define SLOT_BD2 13 +#define SLOT_HH 14 +#define SLOT_SD 15 +#define SLOT_TOM 16 +#define SLOT_CYM 17 + +#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch->ML] +#define UPDATE_TLL(S)\ +(((S)->type==0)?\ +((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->patch->TL][(S)->patch->KL]):\ +((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->volume][(S)->patch->KL])) +#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum)>>8][(S)->block][(S)->patch->KR] +#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch->WF] +#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) +#define UPDATE_ALL(S)\ + UPDATE_PG(S);\ + UPDATE_TLL(S);\ + UPDATE_RKS(S);\ + UPDATE_WF(S); \ + UPDATE_EG(S) /* EG should be last */ + +/* Force Refresh (When external program changes some parameters). */ +void OPLL_forceRefresh(OPLL *opll) +{ + int i ; + + if(opll==NULL) return ; + + for(i=0; i<18 ;i++) + { + UPDATE_PG(opll->slot[i]) ; + UPDATE_RKS(opll->slot[i]) ; + UPDATE_TLL(opll->slot[i]) ; + UPDATE_WF(opll->slot[i]) ; + UPDATE_EG(opll->slot[i]) ; + } +} + +/* Slot key on */ +INLINE static void slotOn(OPLL_SLOT *slot) +{ + slot->eg_mode = ATTACK ; + slot->phase = 0 ; + slot->eg_phase = 0 ; +} + +/* Slot key off */ +INLINE static void slotOff(OPLL_SLOT *slot) +{ + if(slot->eg_mode == ATTACK) + slot->eg_phase = EXPAND_BITS(AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase,EG_DP_BITS-EG_BITS)],EG_BITS,EG_DP_BITS) ; + slot->eg_mode = RELEASE ; +} + +/* Channel key on */ +INLINE static void keyOn(OPLL *opll, int i) +{ + if(!opll->slot_on_flag[i*2]) slotOn(opll->MOD(i)) ; + if(!opll->slot_on_flag[i*2+1]) slotOn(opll->CAR(i)) ; + opll->ch[i]->key_status = 1 ; +} + +/* Channel key off */ +INLINE static void keyOff(OPLL *opll, int i) +{ + if(opll->slot_on_flag[i*2+1]) slotOff(opll->CAR(i)) ; + opll->ch[i]->key_status = 0 ; +} + +INLINE static void keyOn_BD(OPLL *opll){ keyOn(opll,6) ; } +INLINE static void keyOn_SD(OPLL *opll){ if(!opll->slot_on_flag[SLOT_SD]) slotOn(opll->CAR(7)) ; } +INLINE static void keyOn_TOM(OPLL *opll){ if(!opll->slot_on_flag[SLOT_TOM]) slotOn(opll->MOD(8)) ; } +INLINE static void keyOn_HH(OPLL *opll){ if(!opll->slot_on_flag[SLOT_HH]) slotOn(opll->MOD(7)) ; } +INLINE static void keyOn_CYM(OPLL *opll){ if(!opll->slot_on_flag[SLOT_CYM]) slotOn(opll->CAR(8)) ; } + +/* Drum key off */ +INLINE static void keyOff_BD(OPLL *opll){ keyOff(opll,6) ; } +INLINE static void keyOff_SD(OPLL *opll){ if(opll->slot_on_flag[SLOT_SD]) slotOff(opll->CAR(7)) ; } +INLINE static void keyOff_TOM(OPLL *opll){ if(opll->slot_on_flag[SLOT_TOM]) slotOff(opll->MOD(8)) ; } +INLINE static void keyOff_HH(OPLL *opll){ if(opll->slot_on_flag[SLOT_HH]) slotOff(opll->MOD(7)) ; } +INLINE static void keyOff_CYM(OPLL *opll){ if(opll->slot_on_flag[SLOT_CYM]) slotOff(opll->CAR(8)) ; } + +/* Change a voice */ +INLINE static void setPatch(OPLL *opll, int i, int num) +{ + opll->ch[i]->patch_number = num ; + opll->MOD(i)->patch = opll->patch[num*2+0] ; + opll->CAR(i)->patch = opll->patch[num*2+1] ; +} + +/* Change a rythm voice */ +INLINE static void setSlotPatch(OPLL_SLOT *slot, OPLL_PATCH *patch) +{ + slot->patch = patch ; +} + +/* Set sustine parameter */ +INLINE static void setSustine(OPLL *opll, int c, int sustine) +{ + opll->CAR(c)->sustine = sustine ; + if(opll->MOD(c)->type) opll->MOD(c)->sustine = sustine ; +} + +/* Volume : 6bit ( Volume register << 2 ) */ +INLINE static void setVolume(OPLL *opll, int c, int volume) +{ + opll->CAR(c)->volume = volume ; +} + +INLINE static void setSlotVolume(OPLL_SLOT *slot, int volume) +{ + slot->volume = volume ; +} + +/* Set F-Number ( fnum : 9bit ) */ +INLINE static void setFnumber(OPLL *opll, int c, int fnum) +{ + opll->CAR(c)->fnum = fnum ; + opll->MOD(c)->fnum = fnum ; +} + +/* Set Block data (block : 3bit ) */ +INLINE static void setBlock(OPLL *opll, int c, int block) +{ + opll->CAR(c)->block = block ; + opll->MOD(c)->block = block ; +} + +/* Change Rythm Mode */ +INLINE static void setRythmMode(OPLL *opll, int mode) +{ + opll->rythm_mode = mode ; + + if(mode) + { + opll->ch[6]->patch_number = 16 ; + opll->ch[7]->patch_number = 17 ; + opll->ch[8]->patch_number = 18 ; + setSlotPatch(opll->slot[SLOT_BD1], opll->patch[16*2+0]) ; + setSlotPatch(opll->slot[SLOT_BD2], opll->patch[16*2+1]) ; + setSlotPatch(opll->slot[SLOT_HH], opll->patch[17*2+0]) ; + setSlotPatch(opll->slot[SLOT_SD], opll->patch[17*2+1]) ; + opll->slot[SLOT_HH]->type = 1 ; + setSlotPatch(opll->slot[SLOT_TOM], opll->patch[18*2+0]) ; + setSlotPatch(opll->slot[SLOT_CYM], opll->patch[18*2+1]) ; + opll->slot[SLOT_TOM]->type = 1 ; + } + else + { + setPatch(opll, 6, opll->reg[0x36]>>4) ; + setPatch(opll, 7, opll->reg[0x37]>>4) ; + opll->slot[SLOT_HH]->type = 0 ; + setPatch(opll, 8, opll->reg[0x38]>>4) ; + opll->slot[SLOT_TOM]->type = 0 ; + } + + if(!opll->slot_on_flag[SLOT_BD1]) + opll->slot[SLOT_BD1]->eg_mode = FINISH ; + if(!opll->slot_on_flag[SLOT_BD2]) + opll->slot[SLOT_BD2]->eg_mode = FINISH ; + if(!opll->slot_on_flag[SLOT_HH]) + opll->slot[SLOT_HH]->eg_mode = FINISH ; + if(!opll->slot_on_flag[SLOT_SD]) + opll->slot[SLOT_SD]->eg_mode = FINISH ; + if(!opll->slot_on_flag[SLOT_TOM]) + opll->slot[SLOT_TOM]->eg_mode = FINISH ; + if(!opll->slot_on_flag[SLOT_CYM]) + opll->slot[SLOT_CYM]->eg_mode = FINISH ; + +} + +void OPLL_copyPatch(OPLL *opll, int num, OPLL_PATCH *patch) +{ + memcpy(opll->patch[num],patch,sizeof(OPLL_PATCH)) ; +} + +/*********************************************************** + + Initializing + +***********************************************************/ + +static void OPLL_SLOT_reset(OPLL_SLOT *slot) +{ + slot->sintbl = waveform[0] ; + slot->phase = 0 ; + slot->dphase = 0 ; + slot->output[0] = 0 ; + slot->output[1] = 0 ; + slot->feedback = 0 ; + slot->eg_mode = SETTLE ; + slot->eg_phase = EG_DP_WIDTH ; + slot->eg_dphase = 0 ; + slot->rks = 0 ; + slot->tll = 0 ; + slot->sustine = 0 ; + slot->fnum = 0 ; + slot->block = 0 ; + slot->volume = 0 ; + slot->pgout = 0 ; + slot->egout = 0 ; + slot->patch = &null_patch ; +} + +static OPLL_SLOT *OPLL_SLOT_new(void) +{ + OPLL_SLOT *slot ; + + slot = malloc(sizeof(OPLL_SLOT)) ; + if(slot == NULL) return NULL ; + + return slot ; +} + +static void OPLL_SLOT_delete(OPLL_SLOT *slot) +{ + free(slot) ; +} + +static void OPLL_CH_reset(OPLL_CH *ch) +{ + if(ch->mod!=NULL) OPLL_SLOT_reset(ch->mod) ; + if(ch->car!=NULL) OPLL_SLOT_reset(ch->car) ; + ch->key_status = 0 ; +} + +static OPLL_CH *OPLL_CH_new(void) +{ + OPLL_CH *ch ; + OPLL_SLOT *mod, *car ; + + mod = OPLL_SLOT_new() ; + if(mod == NULL) return NULL ; + + car = OPLL_SLOT_new() ; + if(car == NULL) + { + OPLL_SLOT_delete(mod) ; + return NULL ; + } + + ch = malloc(sizeof(OPLL_CH)) ; + if(ch == NULL) + { + OPLL_SLOT_delete(mod) ; + OPLL_SLOT_delete(car) ; + return NULL ; + } + + mod->type = 0 ; + car->type = 1 ; + ch->mod = mod ; + ch->car = car ; + + return ch ; +} + + +static void OPLL_CH_delete(OPLL_CH *ch) +{ + OPLL_SLOT_delete(ch->mod) ; + OPLL_SLOT_delete(ch->car) ; + free(ch) ; +} + +OPLL *OPLL_new(void) +{ + OPLL *opll ; + OPLL_CH *ch[9] ; + OPLL_PATCH *patch[19*2] ; + int i, j ; + + for( i = 0 ; i < 19*2 ; i++ ) + { + patch[i] = calloc(sizeof(OPLL_PATCH),1) ; + if(patch[i] == NULL) + { + for ( j = i ; i > 0 ; i++ ) free(patch[j-1]) ; + return NULL ; + } + } + + for( i = 0 ; i < 9 ; i++ ) + { + ch[i] = OPLL_CH_new() ; + if(ch[i]==NULL) + { + for ( j = i ; i > 0 ; i++ ) OPLL_CH_delete(ch[j-1]) ; + for ( j = 0 ; j < 19*2 ; j++ ) free(patch[j]) ; + return NULL ; + } + } + + opll = malloc(sizeof(OPLL)) ; + if(opll == NULL) return NULL ; + + + for ( i = 0 ; i < 19*2 ; i++ ) + + opll->patch[i] = patch[i] ; + + + for ( i = 0 ; i <9 ; i++) + { + opll->ch[i] = ch[i] ; + opll->slot[i*2+0] = opll->ch[i]->mod ; + opll->slot[i*2+1] = opll->ch[i]->car ; + } + + for ( i = 0 ; i < 18 ; i++) + { + opll->slot[i]->plfo_am = &opll->lfo_am ; + opll->slot[i]->plfo_pm = &opll->lfo_pm ; + } + + opll->mask = 0 ; + + OPLL_reset(opll) ; + OPLL_reset_patch(opll,0) ; + + opll->masterVolume = 32 ; + + return opll ; + +} + +void OPLL_delete(OPLL *opll) +{ + int i ; + + for ( i = 0 ; i < 9 ; i++ ) + OPLL_CH_delete(opll->ch[i]) ; + + for ( i = 0 ; i < 19*2 ; i++ ) + free(opll->patch[i]) ; + + free(opll) ; +} + +/* Reset patch datas by system default. */ +void OPLL_reset_patch(OPLL *opll, int type) +{ + int i ; + + for ( i = 0 ; i < 19*2 ; i++ ) + OPLL_copyPatch(opll, i, &default_patch[type%OPLL_TONE_NUM][i]) ; +} + +/* Reset whole of OPLL except patch datas. */ +void OPLL_reset(OPLL *opll) +{ + int i ; + + if(!opll) return ; + + opll->adr = 0 ; + + opll->output[0] = 0 ; + opll->output[1] = 0 ; + + opll->pm_phase = 0 ; + opll->am_phase = 0 ; + + opll->noise_seed =0xffff ; + opll->noiseA = 0 ; + opll->noiseB = 0 ; + opll->noiseA_phase = 0 ; + opll->noiseB_phase = 0 ; + opll->noiseA_dphase = 0 ; + opll->noiseB_dphase = 0 ; + opll->noiseA_idx = 0 ; + opll->noiseB_idx = 0 ; + + for(i = 0; i < 9 ; i++) + { + OPLL_CH_reset(opll->ch[i]) ; + setPatch(opll,i,0) ; + } + + for ( i = 0 ; i < 0x40 ; i++ ) OPLL_writeReg(opll, i, 0) ; + +} + +void OPLL_setClock(uint32 c, uint32 r) +{ + clk = c ; + rate = r ; + makeDphaseTable() ; + makeDphaseARTable() ; + makeDphaseDRTable() ; + pm_dphase = (uint32)rate_adjust(PM_SPEED * PM_DP_WIDTH / (clk/72) ) ; + am_dphase = (uint32)rate_adjust(AM_SPEED * AM_DP_WIDTH / (clk/72) ) ; +} + +void OPLL_init(uint32 c, uint32 r) +{ + makePmTable() ; + makeAmTable() ; + makeDB2LinTable() ; + makeAdjustTable() ; + makeTllTable() ; + makeRksTable() ; + makeSinTable() ; + makeDefaultPatch() ; + OPLL_setClock(c,r) ; +} + +void OPLL_close(void) +{ +} + +/********************************************************* + + Generate wave data + +*********************************************************/ +/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ +#if ( SLOT_AMP_BITS - PG_BITS ) > 0 +#define wave2_2pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS )) +#else +#define wave2_2pi(e) ( (e) << ( PG_BITS - SLOT_AMP_BITS )) +#endif + +/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ +#if ( SLOT_AMP_BITS - PG_BITS - 1 ) == 0 +#define wave2_4pi(e) (e) +#elif ( SLOT_AMP_BITS - PG_BITS - 1 ) > 0 +#define wave2_4pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 1 )) +#else +#define wave2_4pi(e) ( (e) << ( 1 + PG_BITS - SLOT_AMP_BITS )) +#endif + +/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ +#if ( SLOT_AMP_BITS - PG_BITS - 2 ) == 0 +#define wave2_8pi(e) (e) +#elif ( SLOT_AMP_BITS - PG_BITS - 2 ) > 0 +#define wave2_8pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 2 )) +#else +#define wave2_8pi(e) ( (e) << ( 2 + PG_BITS - SLOT_AMP_BITS )) +#endif + +/* 16bit rand */ +INLINE static uint32 mrand(uint32 seed) +{ + return ((seed>>15)^((seed>>12)&1)) | ((seed<<1)&0xffff) ; +} + +INLINE static uint32 DEC(uint32 db) +{ + if(dbnoise_seed = mrand(opll->noise_seed) ; + opll->whitenoise = opll->noise_seed & 1 ; + + opll->noiseA_phase = (opll->noiseA_phase + opll->noiseA_dphase) ; + opll->noiseB_phase = (opll->noiseB_phase + opll->noiseB_dphase) ; + + if(opll->noiseA_phase<(1<<11)) + { + if(opll->noiseA_phase>16) opll->noiseA = DB_MUTE - 1 ; + } + else + { + opll->noiseA_phase &= (1<<11)-1 ; + opll->noiseA_idx = (opll->noiseA_idx+1)&63 ; + opll->noiseA = noiseAtable[opll->noiseA_idx] ; + } + + if(opll->noiseB_phase<(1<<12)) + { + if(opll->noiseB_phase>16) opll->noiseB = DB_MUTE - 1 ; + } + else + { + opll->noiseB_phase &= (1<<12)-1 ; + opll->noiseB_idx = (opll->noiseB_idx+1)&7 ; + opll->noiseB = noiseBtable[opll->noiseB_idx] ; + } + +} + +/* Update AM, PM unit */ +INLINE static void update_ampm(OPLL *opll) +{ + opll->pm_phase = (opll->pm_phase + pm_dphase)&(PM_DP_WIDTH - 1) ; + opll->am_phase = (opll->am_phase + am_dphase)&(AM_DP_WIDTH - 1) ; + opll->lfo_am = amtable[HIGHBITS(opll->am_phase, AM_DP_BITS - AM_PG_BITS)] ; + opll->lfo_pm = pmtable[HIGHBITS(opll->pm_phase, PM_DP_BITS - PM_PG_BITS)] ; +} + +/* PG */ +INLINE static uint32 calc_phase(OPLL_SLOT *slot) +{ + if(slot->patch->PM) + slot->phase += (slot->dphase * (*(slot->plfo_pm))) >> PM_AMP_BITS ; + else + slot->phase += slot->dphase ; + + slot->phase &= (DP_WIDTH - 1) ; + + return HIGHBITS(slot->phase, DP_BASE_BITS) ; +} + +/* EG */ +INLINE static uint32 calc_envelope(OPLL_SLOT *slot) +{ + #define S2E(x) (SL2EG((int)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) + static uint32 SL[16] = { + S2E( 0), S2E( 3), S2E( 6), S2E( 9), S2E(12), S2E(15), S2E(18), S2E(21), + S2E(24), S2E(27), S2E(30), S2E(33), S2E(36), S2E(39), S2E(42), S2E(48) + } ; + + uint32 egout ; + + switch(slot->eg_mode) + { + + case ATTACK: + slot->eg_phase += slot->eg_dphase ; + if(EG_DP_WIDTH & slot->eg_phase) + { + egout = 0 ; + slot->eg_phase= 0 ; + slot->eg_mode = DECAY ; + UPDATE_EG(slot) ; + } + else + { + egout = AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS)] ; + } + break; + + case DECAY: + slot->eg_phase += slot->eg_dphase ; + egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS) ; + if(slot->eg_phase >= SL[slot->patch->SL]) + { + if(slot->patch->EG) + { + slot->eg_phase = SL[slot->patch->SL] ; + slot->eg_mode = SUSHOLD ; + UPDATE_EG(slot) ; + } + else + { + slot->eg_phase = SL[slot->patch->SL] ; + slot->eg_mode = SUSTINE ; + UPDATE_EG(slot) ; + } + egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS) ; + } + break; + + case SUSHOLD: + egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS) ; + if(slot->patch->EG == 0) + { + slot->eg_mode = SUSTINE ; + UPDATE_EG(slot) ; + } + break; + + case SUSTINE: + case RELEASE: + slot->eg_phase += slot->eg_dphase ; + egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS) ; + if(egout >= (1<eg_mode = FINISH ; + egout = (1<patch->AM) egout = EG2DB(egout+slot->tll) + *(slot->plfo_am) ; + else egout = EG2DB(egout+slot->tll) ; + + if(egout >= DB_MUTE) egout = DB_MUTE-1; + return egout ; + +} + +INLINE static int32 calc_slot_car(OPLL_SLOT *slot, int32 fm) +{ + slot->egout = calc_envelope(slot) ; + slot->pgout = calc_phase(slot) ; + if(slot->egout>=(DB_MUTE-1)) return 0 ; + + return DB2LIN_TABLE[slot->sintbl[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout] ; +} + + +INLINE static int32 calc_slot_mod(OPLL_SLOT *slot) +{ + int32 fm ; + + slot->output[1] = slot->output[0] ; + slot->egout = calc_envelope(slot) ; + slot->pgout = calc_phase(slot) ; + + if(slot->egout>=(DB_MUTE-1)) + { + slot->output[0] = 0 ; + } + else if(slot->patch->FB!=0) + { + fm = wave2_4pi(slot->feedback) >> (7 - slot->patch->FB) ; + slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+fm)&(PG_WIDTH-1)] + slot->egout] ; + } + else + { + slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout] ; + } + + slot->feedback = (slot->output[1] + slot->output[0])>>1 ; + + return slot->feedback ; + +} + +INLINE static int32 calc_slot_tom(OPLL_SLOT *slot) +{ + + slot->egout = calc_envelope(slot) ; + slot->pgout = calc_phase(slot) ; + if(slot->egout>=(DB_MUTE-1)) return 0 ; + + return DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout] ; + +} + +/* calc SNARE slot */ +INLINE static int32 calc_slot_snare(OPLL_SLOT *slot, uint32 whitenoise) +{ + slot->egout = calc_envelope(slot) ; + slot->pgout = calc_phase(slot) ; + if(slot->egout>=(DB_MUTE-1)) return 0 ; + + if(whitenoise) + return DB2LIN_TABLE[snaretable[slot->pgout] + slot->egout] + DB2LIN_TABLE[slot->egout + 6] ; + else + return DB2LIN_TABLE[snaretable[slot->pgout] + slot->egout] ; +} + +INLINE static int32 calc_slot_cym(OPLL_SLOT *slot, int32 a, int32 b, int32 c) +{ + slot->egout = calc_envelope(slot) ; + if(slot->egout>=(DB_MUTE-1)) return 0 ; + + return DB2LIN_TABLE[slot->egout+a] + + (( DB2LIN_TABLE[slot->egout+b] + DB2LIN_TABLE[slot->egout+c] ) >> 2 ); +} + +INLINE static int32 calc_slot_hat(OPLL_SLOT *slot, int32 a, int32 b, int32 c, uint32 whitenoise) +{ + slot->egout = calc_envelope(slot) ; + if(slot->egout>=(DB_MUTE-1)) return 0 ; + + if(whitenoise) + { + return DB2LIN_TABLE[slot->egout+a] + + (( DB2LIN_TABLE[slot->egout+b] + DB2LIN_TABLE[slot->egout+c] ) >> 2 ); + } + else + { + return 0 ; + } +} + +int16 OPLL_calc(OPLL *opll) +{ + int32 inst = 0 , perc = 0 , out = 0 ; + int32 rythmC = 0, rythmH = 0; + int i ; + + update_ampm(opll) ; + update_noise(opll) ; + + for(i = 0 ; i < 6 ; i++) + if(!(opll->mask&OPLL_MASK_CH(i))&&(opll->CAR(i)->eg_mode!=FINISH)) + inst += calc_slot_car(opll->CAR(i),calc_slot_mod(opll->MOD(i))) ; + + if(!opll->rythm_mode) + { + for(i = 6 ; i < 9 ; i++) + if(!(opll->mask&OPLL_MASK_CH(i))&&(opll->CAR(i)->eg_mode!=FINISH)) + inst += calc_slot_car(opll->CAR(i),calc_slot_mod(opll->MOD(i))) ; + } + else + { + opll->MOD(7)->pgout = calc_phase(opll->MOD(7)) ; + opll->CAR(8)->pgout = calc_phase(opll->CAR(8)) ; + if(opll->MOD(7)->phase<256) rythmH = DB_NEG(12.0) ; else rythmH = DB_MUTE - 1 ; + if(opll->CAR(8)->phase<256) rythmC = DB_NEG(12.0) ; else rythmC = DB_MUTE - 1 ; + + if(!(opll->mask&OPLL_MASK_BD)&&(opll->CAR(6)->eg_mode!=FINISH)) + perc += calc_slot_car(opll->CAR(6),calc_slot_mod(opll->MOD(6))) ; + + if(!(opll->mask&OPLL_MASK_HH)&&(opll->MOD(7)->eg_mode!=FINISH)) + perc += calc_slot_hat(opll->MOD(7), opll->noiseA, opll->noiseB, rythmH, opll->whitenoise) ; + + if(!(opll->mask&OPLL_MASK_SD)&&(opll->CAR(7)->eg_mode!=FINISH)) + perc += calc_slot_snare(opll->CAR(7), opll->whitenoise) ; + + if(!(opll->mask&OPLL_MASK_TOM)&&(opll->MOD(8)->eg_mode!=FINISH)) + perc += calc_slot_tom(opll->MOD(8)) ; + + if(!(opll->mask&OPLL_MASK_CYM)&&(opll->CAR(8)->eg_mode!=FINISH)) + perc += calc_slot_cym(opll->CAR(8), opll->noiseA, opll->noiseB, rythmC) ; + } + +#if SLOT_AMP_BITS > 8 + inst = (inst >> (SLOT_AMP_BITS - 8)) ; + perc = (perc >> (SLOT_AMP_BITS - 9)) ; +#else + inst = (inst << (8 - SLOT_AMP_BITS)) ; + perc = (perc << (9 - SLOT_AMP_BITS)) ; +#endif + + out = ((inst + perc) * opll->masterVolume ) >> 2 ; + + if(out>32767) return 32767 ; + if(out<-32768) return -32768 ; + + return (int16)out ; + +} + +uint32 OPLL_setMask(OPLL *opll, uint32 mask) +{ + uint32 ret ; + + if(opll) + { + ret = opll->mask ; + opll->mask = mask ; + return ret ; + } + else return 0 ; +} + +uint32 OPLL_toggleMask(OPLL *opll, uint32 mask) +{ + uint32 ret ; + + if(opll) + { + ret = opll->mask ; + opll->mask ^= mask ; + return ret ; + } + else return 0 ; +} + +/**************************************************** + + Interfaces + +*****************************************************/ + +void OPLL_writeReg(OPLL *opll, uint32 reg, uint32 data){ + + int i,v,ch ; + + data = data&0xff ; + reg = reg&0x3f ; + + switch(reg) + { + case 0x00: + opll->patch[0]->AM = (data>>7)&1 ; + opll->patch[0]->PM = (data>>6)&1 ; + opll->patch[0]->EG = (data>>5)&1 ; + opll->patch[0]->KR = (data>>4)&1 ; + opll->patch[0]->ML = (data)&15 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_PG(opll->MOD(i)) ; + UPDATE_RKS(opll->MOD(i)) ; + UPDATE_EG(opll->MOD(i)) ; + } + } + break ; + + case 0x01: + opll->patch[1]->AM = (data>>7)&1 ; + opll->patch[1]->PM = (data>>6)&1 ; + opll->patch[1]->EG = (data>>5)&1 ; + opll->patch[1]->KR = (data>>4)&1 ; + opll->patch[1]->ML = (data)&15 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_PG(opll->CAR(i)) ; + UPDATE_RKS(opll->CAR(i)) ; + UPDATE_EG(opll->CAR(i)) ; + } + } + break; + + case 0x02: + opll->patch[0]->KL = (data>>6)&3 ; + opll->patch[0]->TL = (data)&63 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_TLL(opll->MOD(i)) ; + } + } + break ; + + case 0x03: + opll->patch[1]->KL = (data>>6)&3 ; + opll->patch[1]->WF = (data>>4)&1 ; + opll->patch[0]->WF = (data>>3)&1 ; + opll->patch[0]->FB = (data)&7 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_WF(opll->MOD(i)) ; + UPDATE_WF(opll->CAR(i)) ; + } + } + break ; + + case 0x04: + opll->patch[0]->AR = (data>>4)&15 ; + opll->patch[0]->DR = (data)&15 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_EG(opll->MOD(i)) ; + } + } + break ; + + case 0x05: + opll->patch[1]->AR = (data>>4)&15 ; + opll->patch[1]->DR = (data)&15 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_EG(opll->CAR(i)) ; + } + } + break ; + + case 0x06: + opll->patch[0]->SL = (data>>4)&15 ; + opll->patch[0]->RR = (data)&15 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_EG(opll->MOD(i)) ; + } + } + break ; + + case 0x07: + opll->patch[1]->SL = (data>>4)&15 ; + opll->patch[1]->RR = (data)&15 ; + for(i=0;i<9;i++) + { + if(opll->ch[i]->patch_number==0) + { + UPDATE_EG(opll->CAR(i)) ; + } + } + break ; + + case 0x0e: + + if(opll->rythm_mode) + { + opll->slot_on_flag[SLOT_BD1] = (opll->reg[0x0e]&0x10) | (opll->reg[0x26]&0x10) ; + opll->slot_on_flag[SLOT_BD2] = (opll->reg[0x0e]&0x10) | (opll->reg[0x26]&0x10) ; + opll->slot_on_flag[SLOT_SD] = (opll->reg[0x0e]&0x08) | (opll->reg[0x27]&0x10) ; + opll->slot_on_flag[SLOT_HH] = (opll->reg[0x0e]&0x01) | (opll->reg[0x27]&0x10) ; + opll->slot_on_flag[SLOT_TOM] = (opll->reg[0x0e]&0x04) | (opll->reg[0x28]&0x10) ; + opll->slot_on_flag[SLOT_CYM] = (opll->reg[0x0e]&0x02) | (opll->reg[0x28]&0x10) ; + } + else + { + opll->slot_on_flag[SLOT_BD1] = (opll->reg[0x26]&0x10) ; + opll->slot_on_flag[SLOT_BD2] = (opll->reg[0x26]&0x10) ; + opll->slot_on_flag[SLOT_SD] = (opll->reg[0x27]&0x10) ; + opll->slot_on_flag[SLOT_HH] = (opll->reg[0x27]&0x10) ; + opll->slot_on_flag[SLOT_TOM] = (opll->reg[0x28]&0x10) ; + opll->slot_on_flag[SLOT_CYM] = (opll->reg[0x28]&0x10) ; + } + + if(((data>>5)&1)^(opll->rythm_mode)) + { + setRythmMode(opll,(data&32)>>5) ; + } + + if(opll->rythm_mode) + { + if(data&0x10) keyOn_BD(opll) ; else keyOff_BD(opll) ; + if(data&0x8) keyOn_SD(opll) ; else keyOff_SD(opll) ; + if(data&0x4) keyOn_TOM(opll) ; else keyOff_TOM(opll) ; + if(data&0x2) keyOn_CYM(opll) ; else keyOff_CYM(opll) ; + if(data&0x1) keyOn_HH(opll) ; else keyOff_HH(opll) ; + } + + UPDATE_ALL(opll->MOD(6)) ; + UPDATE_ALL(opll->CAR(6)) ; + UPDATE_ALL(opll->MOD(7)) ; + UPDATE_ALL(opll->CAR(7)) ; + UPDATE_ALL(opll->MOD(8)) ; + UPDATE_ALL(opll->CAR(8)) ; + break ; + + case 0x0f: + break ; + + case 0x10: case 0x11: case 0x12: case 0x13: + case 0x14: case 0x15: case 0x16: case 0x17: + case 0x18: + ch = reg-0x10 ; + setFnumber(opll, ch, data + ((opll->reg[0x20+ch]&1)<<8)) ; + UPDATE_ALL(opll->MOD(ch)); + UPDATE_ALL(opll->CAR(ch)); + switch(reg) + { + case 0x17: + opll->noiseA_dphase = (data + ((opll->reg[0x27]&1)<<8)) << ((opll->reg[0x27]>>1)&7) ; + break ; + case 0x18: + opll->noiseB_dphase = (data + ((opll->reg[0x28]&1)<<8)) << ((opll->reg[0x28]>>1)&7) ; + break; + default: + break ; + } + break ; + + case 0x20: case 0x21: case 0x22: case 0x23: + case 0x24: case 0x25: case 0x26: case 0x27: + case 0x28: + + ch = reg - 0x20 ; + setFnumber(opll, ch, ((data&1)<<8) + opll->reg[0x10+ch]) ; + setBlock(opll, ch, (data>>1)&7 ) ; + opll->slot_on_flag[ch*2] = opll->slot_on_flag[ch*2+1] = (opll->reg[reg])&0x10 ; + + if(opll->rythm_mode) + { + switch(reg) + { + case 0x26: + opll->slot_on_flag[SLOT_BD1] |= (opll->reg[0x0e])&0x10 ; + opll->slot_on_flag[SLOT_BD2] |= (opll->reg[0x0e])&0x10 ; + break ; + + case 0x27: + opll->noiseA_dphase = (((data&1)<<8) + opll->reg[0x17] ) << ((data>>1)&7) ; + opll->slot_on_flag[SLOT_SD] |= (opll->reg[0x0e])&0x08 ; + opll->slot_on_flag[SLOT_HH] |= (opll->reg[0x0e])&0x01 ; + break; + + case 0x28: + opll->noiseB_dphase = (((data&1)<<8) + opll->reg[0x18] ) << ((data>>1)&7); + opll->slot_on_flag[SLOT_TOM] |= (opll->reg[0x0e])&0x04 ; + opll->slot_on_flag[SLOT_CYM] |= (opll->reg[0x0e])&0x02 ; + break ; + + default: + break ; + } + } + + if((opll->reg[reg]^data)&0x20) setSustine(opll, ch, (data>>5)&1) ; + if(data&0x10) keyOn(opll, ch) ; else keyOff(opll, ch) ; + UPDATE_ALL(opll->MOD(ch)) ; + UPDATE_ALL(opll->CAR(ch)) ; + break ; + + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: + case 0x35: case 0x36: case 0x37: case 0x38: + i = (data>>4)&15 ; + v = data&15 ; + if((opll->rythm_mode)&&(reg>=0x36)) + { + switch(reg) + { + case 0x37 : + setSlotVolume(opll->MOD(7), i<<2) ; + break ; + case 0x38 : + setSlotVolume(opll->MOD(8), i<<2) ; + break ; + } + } + else + { + setPatch(opll, reg-0x30, i) ; + } + + setVolume(opll, reg-0x30, v<<2) ; + UPDATE_ALL(opll->MOD(reg-0x30)) ; + UPDATE_ALL(opll->CAR(reg-0x30)) ; + break ; + + default: + break ; + + } + + opll->reg[reg] = (unsigned char)data ; + +} + +void OPLL_writeIO(OPLL *opll, uint32 adr, uint32 val) +{ + adr &= 0xff ; + if(adr == 0x7C) opll->adr = val ; + else if(adr == 0x7D) OPLL_writeReg(opll, opll->adr, val) ; +} diff --git a/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.h b/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.h new file mode 100644 index 0000000..c10558b Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/emu2413/emu2413.h differ diff --git a/virtuanessrc097-master/NES/ApuEX/emu2413/vrc7tone.h b/virtuanessrc097-master/NES/ApuEX/emu2413/vrc7tone.h new file mode 100644 index 0000000..9060a75 Binary files /dev/null and b/virtuanessrc097-master/NES/ApuEX/emu2413/vrc7tone.h differ diff --git a/virtuanessrc097-master/NES/CPU.h b/virtuanessrc097-master/NES/CPU.h new file mode 100644 index 0000000..52971de Binary files /dev/null and b/virtuanessrc097-master/NES/CPU.h differ diff --git a/virtuanessrc097-master/NES/Cheat.h b/virtuanessrc097-master/NES/Cheat.h new file mode 100644 index 0000000..8d7b6e0 Binary files /dev/null and b/virtuanessrc097-master/NES/Cheat.h differ diff --git a/virtuanessrc097-master/NES/Cpu.cpp b/virtuanessrc097-master/NES/Cpu.cpp new file mode 100644 index 0000000..2c598ef Binary files /dev/null and b/virtuanessrc097-master/NES/Cpu.cpp differ diff --git a/virtuanessrc097-master/NES/IPS.cpp b/virtuanessrc097-master/NES/IPS.cpp new file mode 100644 index 0000000..da24781 Binary files /dev/null and b/virtuanessrc097-master/NES/IPS.cpp differ diff --git a/virtuanessrc097-master/NES/IPS.h b/virtuanessrc097-master/NES/IPS.h new file mode 100644 index 0000000..67ca52d Binary files /dev/null and b/virtuanessrc097-master/NES/IPS.h differ diff --git a/virtuanessrc097-master/NES/MMU.cpp b/virtuanessrc097-master/NES/MMU.cpp new file mode 100644 index 0000000..33d429b Binary files /dev/null and b/virtuanessrc097-master/NES/MMU.cpp differ diff --git a/virtuanessrc097-master/NES/MMU.h b/virtuanessrc097-master/NES/MMU.h new file mode 100644 index 0000000..c9049a4 Binary files /dev/null and b/virtuanessrc097-master/NES/MMU.h differ diff --git a/virtuanessrc097-master/NES/Mapper/EEPROM.h b/virtuanessrc097-master/NES/Mapper/EEPROM.h new file mode 100644 index 0000000..c48c2a5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/EEPROM.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper.cpp b/virtuanessrc097-master/NES/Mapper/Mapper.cpp new file mode 100644 index 0000000..5d1042e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper.h b/virtuanessrc097-master/NES/Mapper/Mapper.h new file mode 100644 index 0000000..5d7ae6b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper000.cpp b/virtuanessrc097-master/NES/Mapper/Mapper000.cpp new file mode 100644 index 0000000..1a06af6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper000.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper000.h b/virtuanessrc097-master/NES/Mapper/Mapper000.h new file mode 100644 index 0000000..c1966ec Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper000.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper001.cpp b/virtuanessrc097-master/NES/Mapper/Mapper001.cpp new file mode 100644 index 0000000..9c182f9 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper001.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper001.h b/virtuanessrc097-master/NES/Mapper/Mapper001.h new file mode 100644 index 0000000..dbca37a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper001.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper002.cpp b/virtuanessrc097-master/NES/Mapper/Mapper002.cpp new file mode 100644 index 0000000..a233018 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper002.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper002.h b/virtuanessrc097-master/NES/Mapper/Mapper002.h new file mode 100644 index 0000000..0f8f402 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper002.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper003.cpp b/virtuanessrc097-master/NES/Mapper/Mapper003.cpp new file mode 100644 index 0000000..0ef3c78 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper003.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper003.h b/virtuanessrc097-master/NES/Mapper/Mapper003.h new file mode 100644 index 0000000..b5072b5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper003.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper004.cpp b/virtuanessrc097-master/NES/Mapper/Mapper004.cpp new file mode 100644 index 0000000..6c09e75 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper004.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper004.h b/virtuanessrc097-master/NES/Mapper/Mapper004.h new file mode 100644 index 0000000..f027346 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper004.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper005.cpp b/virtuanessrc097-master/NES/Mapper/Mapper005.cpp new file mode 100644 index 0000000..190f0b5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper005.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper005.h b/virtuanessrc097-master/NES/Mapper/Mapper005.h new file mode 100644 index 0000000..8f66393 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper005.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper006.cpp b/virtuanessrc097-master/NES/Mapper/Mapper006.cpp new file mode 100644 index 0000000..97f92e4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper006.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper006.h b/virtuanessrc097-master/NES/Mapper/Mapper006.h new file mode 100644 index 0000000..0b500bf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper006.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper007.cpp b/virtuanessrc097-master/NES/Mapper/Mapper007.cpp new file mode 100644 index 0000000..f974e42 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper007.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper007.h b/virtuanessrc097-master/NES/Mapper/Mapper007.h new file mode 100644 index 0000000..21a69fd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper007.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper008.cpp b/virtuanessrc097-master/NES/Mapper/Mapper008.cpp new file mode 100644 index 0000000..dd1f4cc Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper008.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper008.h b/virtuanessrc097-master/NES/Mapper/Mapper008.h new file mode 100644 index 0000000..a87c7ce Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper008.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper009.cpp b/virtuanessrc097-master/NES/Mapper/Mapper009.cpp new file mode 100644 index 0000000..76c18de Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper009.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper009.h b/virtuanessrc097-master/NES/Mapper/Mapper009.h new file mode 100644 index 0000000..faf91f5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper009.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper010.cpp b/virtuanessrc097-master/NES/Mapper/Mapper010.cpp new file mode 100644 index 0000000..7d04716 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper010.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper010.h b/virtuanessrc097-master/NES/Mapper/Mapper010.h new file mode 100644 index 0000000..673b0fb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper010.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper011.cpp b/virtuanessrc097-master/NES/Mapper/Mapper011.cpp new file mode 100644 index 0000000..56ac98f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper011.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper011.h b/virtuanessrc097-master/NES/Mapper/Mapper011.h new file mode 100644 index 0000000..70a7dd1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper011.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper012.cpp b/virtuanessrc097-master/NES/Mapper/Mapper012.cpp new file mode 100644 index 0000000..058cc9a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper012.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper012.h b/virtuanessrc097-master/NES/Mapper/Mapper012.h new file mode 100644 index 0000000..950a407 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper012.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper013.cpp b/virtuanessrc097-master/NES/Mapper/Mapper013.cpp new file mode 100644 index 0000000..4244f2c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper013.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper013.h b/virtuanessrc097-master/NES/Mapper/Mapper013.h new file mode 100644 index 0000000..0ead83a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper013.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper015.cpp b/virtuanessrc097-master/NES/Mapper/Mapper015.cpp new file mode 100644 index 0000000..8c9e32a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper015.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper015.h b/virtuanessrc097-master/NES/Mapper/Mapper015.h new file mode 100644 index 0000000..5a79a8f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper015.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper016.cpp b/virtuanessrc097-master/NES/Mapper/Mapper016.cpp new file mode 100644 index 0000000..71e1d43 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper016.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper016.h b/virtuanessrc097-master/NES/Mapper/Mapper016.h new file mode 100644 index 0000000..b09f70d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper016.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper017.cpp b/virtuanessrc097-master/NES/Mapper/Mapper017.cpp new file mode 100644 index 0000000..a354172 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper017.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper017.h b/virtuanessrc097-master/NES/Mapper/Mapper017.h new file mode 100644 index 0000000..57fd2b1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper017.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper018.cpp b/virtuanessrc097-master/NES/Mapper/Mapper018.cpp new file mode 100644 index 0000000..4451d6d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper018.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper018.h b/virtuanessrc097-master/NES/Mapper/Mapper018.h new file mode 100644 index 0000000..c872a3a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper018.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper019.cpp b/virtuanessrc097-master/NES/Mapper/Mapper019.cpp new file mode 100644 index 0000000..b198437 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper019.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper019.h b/virtuanessrc097-master/NES/Mapper/Mapper019.h new file mode 100644 index 0000000..9f53be2 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper019.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper021.cpp b/virtuanessrc097-master/NES/Mapper/Mapper021.cpp new file mode 100644 index 0000000..70547eb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper021.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper021.h b/virtuanessrc097-master/NES/Mapper/Mapper021.h new file mode 100644 index 0000000..9630c95 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper021.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper022.cpp b/virtuanessrc097-master/NES/Mapper/Mapper022.cpp new file mode 100644 index 0000000..e539aa4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper022.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper022.h b/virtuanessrc097-master/NES/Mapper/Mapper022.h new file mode 100644 index 0000000..455b6ac Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper022.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper023.cpp b/virtuanessrc097-master/NES/Mapper/Mapper023.cpp new file mode 100644 index 0000000..c7ff8ba Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper023.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper023.h b/virtuanessrc097-master/NES/Mapper/Mapper023.h new file mode 100644 index 0000000..d1e84a6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper023.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper024.cpp b/virtuanessrc097-master/NES/Mapper/Mapper024.cpp new file mode 100644 index 0000000..3d2b83d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper024.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper024.h b/virtuanessrc097-master/NES/Mapper/Mapper024.h new file mode 100644 index 0000000..6807a6f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper024.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper025.cpp b/virtuanessrc097-master/NES/Mapper/Mapper025.cpp new file mode 100644 index 0000000..3340ccd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper025.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper025.h b/virtuanessrc097-master/NES/Mapper/Mapper025.h new file mode 100644 index 0000000..6eb1d09 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper025.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper026.cpp b/virtuanessrc097-master/NES/Mapper/Mapper026.cpp new file mode 100644 index 0000000..29d8521 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper026.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper026.h b/virtuanessrc097-master/NES/Mapper/Mapper026.h new file mode 100644 index 0000000..82d6093 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper026.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper027.cpp b/virtuanessrc097-master/NES/Mapper/Mapper027.cpp new file mode 100644 index 0000000..5b44c61 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper027.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper027.h b/virtuanessrc097-master/NES/Mapper/Mapper027.h new file mode 100644 index 0000000..34a5ae7 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper027.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper032.cpp b/virtuanessrc097-master/NES/Mapper/Mapper032.cpp new file mode 100644 index 0000000..ca26dc4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper032.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper032.h b/virtuanessrc097-master/NES/Mapper/Mapper032.h new file mode 100644 index 0000000..8e645d1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper032.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper033.cpp b/virtuanessrc097-master/NES/Mapper/Mapper033.cpp new file mode 100644 index 0000000..b4a6a18 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper033.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper033.h b/virtuanessrc097-master/NES/Mapper/Mapper033.h new file mode 100644 index 0000000..9e8efe2 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper033.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper034.cpp b/virtuanessrc097-master/NES/Mapper/Mapper034.cpp new file mode 100644 index 0000000..7746ff4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper034.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper034.h b/virtuanessrc097-master/NES/Mapper/Mapper034.h new file mode 100644 index 0000000..e985f3e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper034.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper040.cpp b/virtuanessrc097-master/NES/Mapper/Mapper040.cpp new file mode 100644 index 0000000..ed8b98f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper040.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper040.h b/virtuanessrc097-master/NES/Mapper/Mapper040.h new file mode 100644 index 0000000..4043b5f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper040.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper041.cpp b/virtuanessrc097-master/NES/Mapper/Mapper041.cpp new file mode 100644 index 0000000..fb91edb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper041.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper041.h b/virtuanessrc097-master/NES/Mapper/Mapper041.h new file mode 100644 index 0000000..69b0e7f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper041.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper042.cpp b/virtuanessrc097-master/NES/Mapper/Mapper042.cpp new file mode 100644 index 0000000..90ea3f3 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper042.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper042.h b/virtuanessrc097-master/NES/Mapper/Mapper042.h new file mode 100644 index 0000000..2462611 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper042.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper043.cpp b/virtuanessrc097-master/NES/Mapper/Mapper043.cpp new file mode 100644 index 0000000..78e36fa Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper043.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper043.h b/virtuanessrc097-master/NES/Mapper/Mapper043.h new file mode 100644 index 0000000..d0888da Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper043.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper044.cpp b/virtuanessrc097-master/NES/Mapper/Mapper044.cpp new file mode 100644 index 0000000..9bfd6e4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper044.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper044.h b/virtuanessrc097-master/NES/Mapper/Mapper044.h new file mode 100644 index 0000000..d8c5aba Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper044.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper045.cpp b/virtuanessrc097-master/NES/Mapper/Mapper045.cpp new file mode 100644 index 0000000..98e6f06 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper045.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper045.h b/virtuanessrc097-master/NES/Mapper/Mapper045.h new file mode 100644 index 0000000..7069ad7 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper045.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper046.cpp b/virtuanessrc097-master/NES/Mapper/Mapper046.cpp new file mode 100644 index 0000000..3cc543b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper046.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper046.h b/virtuanessrc097-master/NES/Mapper/Mapper046.h new file mode 100644 index 0000000..a1eef06 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper046.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper047.cpp b/virtuanessrc097-master/NES/Mapper/Mapper047.cpp new file mode 100644 index 0000000..fac36ce Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper047.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper047.h b/virtuanessrc097-master/NES/Mapper/Mapper047.h new file mode 100644 index 0000000..4dfad0b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper047.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper048.cpp b/virtuanessrc097-master/NES/Mapper/Mapper048.cpp new file mode 100644 index 0000000..bf8b618 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper048.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper048.h b/virtuanessrc097-master/NES/Mapper/Mapper048.h new file mode 100644 index 0000000..c277e26 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper048.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper050.cpp b/virtuanessrc097-master/NES/Mapper/Mapper050.cpp new file mode 100644 index 0000000..b4af6c6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper050.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper050.h b/virtuanessrc097-master/NES/Mapper/Mapper050.h new file mode 100644 index 0000000..bbf697c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper050.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper051.cpp b/virtuanessrc097-master/NES/Mapper/Mapper051.cpp new file mode 100644 index 0000000..3ae50aa Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper051.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper051.h b/virtuanessrc097-master/NES/Mapper/Mapper051.h new file mode 100644 index 0000000..0e611e6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper051.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper057.cpp b/virtuanessrc097-master/NES/Mapper/Mapper057.cpp new file mode 100644 index 0000000..ccf8482 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper057.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper057.h b/virtuanessrc097-master/NES/Mapper/Mapper057.h new file mode 100644 index 0000000..50fd44a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper057.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper058.cpp b/virtuanessrc097-master/NES/Mapper/Mapper058.cpp new file mode 100644 index 0000000..01c04d4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper058.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper058.h b/virtuanessrc097-master/NES/Mapper/Mapper058.h new file mode 100644 index 0000000..f3a1425 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper058.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper060.cpp b/virtuanessrc097-master/NES/Mapper/Mapper060.cpp new file mode 100644 index 0000000..57710a7 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper060.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper060.h b/virtuanessrc097-master/NES/Mapper/Mapper060.h new file mode 100644 index 0000000..ea7703d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper060.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper061.cpp b/virtuanessrc097-master/NES/Mapper/Mapper061.cpp new file mode 100644 index 0000000..c934f6c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper061.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper061.h b/virtuanessrc097-master/NES/Mapper/Mapper061.h new file mode 100644 index 0000000..04078c0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper061.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper062.cpp b/virtuanessrc097-master/NES/Mapper/Mapper062.cpp new file mode 100644 index 0000000..ba6ffdd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper062.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper062.h b/virtuanessrc097-master/NES/Mapper/Mapper062.h new file mode 100644 index 0000000..e417d0f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper062.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper064.cpp b/virtuanessrc097-master/NES/Mapper/Mapper064.cpp new file mode 100644 index 0000000..bdc3f1b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper064.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper064.h b/virtuanessrc097-master/NES/Mapper/Mapper064.h new file mode 100644 index 0000000..da7831d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper064.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper065.cpp b/virtuanessrc097-master/NES/Mapper/Mapper065.cpp new file mode 100644 index 0000000..9e5e100 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper065.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper065.h b/virtuanessrc097-master/NES/Mapper/Mapper065.h new file mode 100644 index 0000000..f4dc23c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper065.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper066.cpp b/virtuanessrc097-master/NES/Mapper/Mapper066.cpp new file mode 100644 index 0000000..76f5292 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper066.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper066.h b/virtuanessrc097-master/NES/Mapper/Mapper066.h new file mode 100644 index 0000000..4c7c704 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper066.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper067.cpp b/virtuanessrc097-master/NES/Mapper/Mapper067.cpp new file mode 100644 index 0000000..d0e1c25 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper067.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper067.h b/virtuanessrc097-master/NES/Mapper/Mapper067.h new file mode 100644 index 0000000..90ead44 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper067.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper068.cpp b/virtuanessrc097-master/NES/Mapper/Mapper068.cpp new file mode 100644 index 0000000..19aaa92 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper068.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper068.h b/virtuanessrc097-master/NES/Mapper/Mapper068.h new file mode 100644 index 0000000..e65078b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper068.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper069.cpp b/virtuanessrc097-master/NES/Mapper/Mapper069.cpp new file mode 100644 index 0000000..a10df19 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper069.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper069.h b/virtuanessrc097-master/NES/Mapper/Mapper069.h new file mode 100644 index 0000000..9b0b86d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper069.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper070.cpp b/virtuanessrc097-master/NES/Mapper/Mapper070.cpp new file mode 100644 index 0000000..160c78c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper070.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper070.h b/virtuanessrc097-master/NES/Mapper/Mapper070.h new file mode 100644 index 0000000..17d6ef3 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper070.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper071.cpp b/virtuanessrc097-master/NES/Mapper/Mapper071.cpp new file mode 100644 index 0000000..8b5bd8d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper071.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper071.h b/virtuanessrc097-master/NES/Mapper/Mapper071.h new file mode 100644 index 0000000..76e1aeb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper071.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper072.cpp b/virtuanessrc097-master/NES/Mapper/Mapper072.cpp new file mode 100644 index 0000000..7111964 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper072.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper072.h b/virtuanessrc097-master/NES/Mapper/Mapper072.h new file mode 100644 index 0000000..bbebd91 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper072.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper073.cpp b/virtuanessrc097-master/NES/Mapper/Mapper073.cpp new file mode 100644 index 0000000..4c05d7d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper073.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper073.h b/virtuanessrc097-master/NES/Mapper/Mapper073.h new file mode 100644 index 0000000..6b24195 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper073.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper074.cpp b/virtuanessrc097-master/NES/Mapper/Mapper074.cpp new file mode 100644 index 0000000..5776068 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper074.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper074.h b/virtuanessrc097-master/NES/Mapper/Mapper074.h new file mode 100644 index 0000000..821b926 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper074.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper075.cpp b/virtuanessrc097-master/NES/Mapper/Mapper075.cpp new file mode 100644 index 0000000..e327ac4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper075.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper075.h b/virtuanessrc097-master/NES/Mapper/Mapper075.h new file mode 100644 index 0000000..b18a7c5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper075.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper076.cpp b/virtuanessrc097-master/NES/Mapper/Mapper076.cpp new file mode 100644 index 0000000..2458baa Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper076.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper076.h b/virtuanessrc097-master/NES/Mapper/Mapper076.h new file mode 100644 index 0000000..21c29e0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper076.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper077.cpp b/virtuanessrc097-master/NES/Mapper/Mapper077.cpp new file mode 100644 index 0000000..a523ee2 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper077.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper077.h b/virtuanessrc097-master/NES/Mapper/Mapper077.h new file mode 100644 index 0000000..ba97fcd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper077.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper078.cpp b/virtuanessrc097-master/NES/Mapper/Mapper078.cpp new file mode 100644 index 0000000..867ee96 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper078.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper078.h b/virtuanessrc097-master/NES/Mapper/Mapper078.h new file mode 100644 index 0000000..a97c1f1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper078.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper079.cpp b/virtuanessrc097-master/NES/Mapper/Mapper079.cpp new file mode 100644 index 0000000..9edec56 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper079.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper079.h b/virtuanessrc097-master/NES/Mapper/Mapper079.h new file mode 100644 index 0000000..ff74437 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper079.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper080.cpp b/virtuanessrc097-master/NES/Mapper/Mapper080.cpp new file mode 100644 index 0000000..ff746bf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper080.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper080.h b/virtuanessrc097-master/NES/Mapper/Mapper080.h new file mode 100644 index 0000000..d412d7c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper080.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper082.cpp b/virtuanessrc097-master/NES/Mapper/Mapper082.cpp new file mode 100644 index 0000000..b90b0b6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper082.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper082.h b/virtuanessrc097-master/NES/Mapper/Mapper082.h new file mode 100644 index 0000000..e9088ea Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper082.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper083.cpp b/virtuanessrc097-master/NES/Mapper/Mapper083.cpp new file mode 100644 index 0000000..7caa747 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper083.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper083.h b/virtuanessrc097-master/NES/Mapper/Mapper083.h new file mode 100644 index 0000000..d4fe2b4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper083.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper085.cpp b/virtuanessrc097-master/NES/Mapper/Mapper085.cpp new file mode 100644 index 0000000..3253713 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper085.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper085.h b/virtuanessrc097-master/NES/Mapper/Mapper085.h new file mode 100644 index 0000000..59928c4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper085.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper086.cpp b/virtuanessrc097-master/NES/Mapper/Mapper086.cpp new file mode 100644 index 0000000..2ca596e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper086.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper086.h b/virtuanessrc097-master/NES/Mapper/Mapper086.h new file mode 100644 index 0000000..8c837f1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper086.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper087.cpp b/virtuanessrc097-master/NES/Mapper/Mapper087.cpp new file mode 100644 index 0000000..0edcd13 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper087.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper087.h b/virtuanessrc097-master/NES/Mapper/Mapper087.h new file mode 100644 index 0000000..a6e36ed Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper087.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper088.cpp b/virtuanessrc097-master/NES/Mapper/Mapper088.cpp new file mode 100644 index 0000000..251bc5f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper088.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper088.h b/virtuanessrc097-master/NES/Mapper/Mapper088.h new file mode 100644 index 0000000..8a36d98 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper088.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper089.cpp b/virtuanessrc097-master/NES/Mapper/Mapper089.cpp new file mode 100644 index 0000000..36fd604 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper089.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper089.h b/virtuanessrc097-master/NES/Mapper/Mapper089.h new file mode 100644 index 0000000..564bb40 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper089.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper090.cpp b/virtuanessrc097-master/NES/Mapper/Mapper090.cpp new file mode 100644 index 0000000..688389a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper090.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper090.h b/virtuanessrc097-master/NES/Mapper/Mapper090.h new file mode 100644 index 0000000..0e9e883 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper090.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper091.cpp b/virtuanessrc097-master/NES/Mapper/Mapper091.cpp new file mode 100644 index 0000000..2b6e760 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper091.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper091.h b/virtuanessrc097-master/NES/Mapper/Mapper091.h new file mode 100644 index 0000000..7400818 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper091.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper092.cpp b/virtuanessrc097-master/NES/Mapper/Mapper092.cpp new file mode 100644 index 0000000..6e54e36 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper092.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper092.h b/virtuanessrc097-master/NES/Mapper/Mapper092.h new file mode 100644 index 0000000..3ddb21f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper092.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper093.cpp b/virtuanessrc097-master/NES/Mapper/Mapper093.cpp new file mode 100644 index 0000000..2e0c038 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper093.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper093.h b/virtuanessrc097-master/NES/Mapper/Mapper093.h new file mode 100644 index 0000000..4037b3c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper093.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper094.cpp b/virtuanessrc097-master/NES/Mapper/Mapper094.cpp new file mode 100644 index 0000000..277256e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper094.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper094.h b/virtuanessrc097-master/NES/Mapper/Mapper094.h new file mode 100644 index 0000000..0ba086d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper094.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper095.cpp b/virtuanessrc097-master/NES/Mapper/Mapper095.cpp new file mode 100644 index 0000000..2112e5f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper095.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper095.h b/virtuanessrc097-master/NES/Mapper/Mapper095.h new file mode 100644 index 0000000..e93f56e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper095.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper096.cpp b/virtuanessrc097-master/NES/Mapper/Mapper096.cpp new file mode 100644 index 0000000..48c9dbe Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper096.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper096.h b/virtuanessrc097-master/NES/Mapper/Mapper096.h new file mode 100644 index 0000000..fffc0f6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper096.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper097.cpp b/virtuanessrc097-master/NES/Mapper/Mapper097.cpp new file mode 100644 index 0000000..a6131b1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper097.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper097.h b/virtuanessrc097-master/NES/Mapper/Mapper097.h new file mode 100644 index 0000000..1226880 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper097.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper099.cpp b/virtuanessrc097-master/NES/Mapper/Mapper099.cpp new file mode 100644 index 0000000..16b7b43 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper099.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper099.h b/virtuanessrc097-master/NES/Mapper/Mapper099.h new file mode 100644 index 0000000..90667bd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper099.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper100.cpp b/virtuanessrc097-master/NES/Mapper/Mapper100.cpp new file mode 100644 index 0000000..29a6460 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper100.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper100.h b/virtuanessrc097-master/NES/Mapper/Mapper100.h new file mode 100644 index 0000000..03e1704 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper100.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper101.cpp b/virtuanessrc097-master/NES/Mapper/Mapper101.cpp new file mode 100644 index 0000000..0e7d39c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper101.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper101.h b/virtuanessrc097-master/NES/Mapper/Mapper101.h new file mode 100644 index 0000000..668878e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper101.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper105.cpp b/virtuanessrc097-master/NES/Mapper/Mapper105.cpp new file mode 100644 index 0000000..1d0bfd1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper105.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper105.h b/virtuanessrc097-master/NES/Mapper/Mapper105.h new file mode 100644 index 0000000..1a53780 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper105.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper107.cpp b/virtuanessrc097-master/NES/Mapper/Mapper107.cpp new file mode 100644 index 0000000..7a64b8d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper107.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper107.h b/virtuanessrc097-master/NES/Mapper/Mapper107.h new file mode 100644 index 0000000..5313a12 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper107.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper108.cpp b/virtuanessrc097-master/NES/Mapper/Mapper108.cpp new file mode 100644 index 0000000..28f12ac Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper108.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper108.h b/virtuanessrc097-master/NES/Mapper/Mapper108.h new file mode 100644 index 0000000..9d4f0bf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper108.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper109.cpp b/virtuanessrc097-master/NES/Mapper/Mapper109.cpp new file mode 100644 index 0000000..ebf47e0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper109.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper109.h b/virtuanessrc097-master/NES/Mapper/Mapper109.h new file mode 100644 index 0000000..c00da59 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper109.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper110.cpp b/virtuanessrc097-master/NES/Mapper/Mapper110.cpp new file mode 100644 index 0000000..8586a43 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper110.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper110.h b/virtuanessrc097-master/NES/Mapper/Mapper110.h new file mode 100644 index 0000000..2d74588 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper110.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper112.cpp b/virtuanessrc097-master/NES/Mapper/Mapper112.cpp new file mode 100644 index 0000000..d7f0848 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper112.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper112.h b/virtuanessrc097-master/NES/Mapper/Mapper112.h new file mode 100644 index 0000000..0a9d6f2 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper112.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper113.cpp b/virtuanessrc097-master/NES/Mapper/Mapper113.cpp new file mode 100644 index 0000000..f058d1c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper113.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper113.h b/virtuanessrc097-master/NES/Mapper/Mapper113.h new file mode 100644 index 0000000..18d755f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper113.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper114.cpp b/virtuanessrc097-master/NES/Mapper/Mapper114.cpp new file mode 100644 index 0000000..da476c6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper114.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper114.h b/virtuanessrc097-master/NES/Mapper/Mapper114.h new file mode 100644 index 0000000..8b5c8f6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper114.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper115.cpp b/virtuanessrc097-master/NES/Mapper/Mapper115.cpp new file mode 100644 index 0000000..b0f0724 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper115.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper115.h b/virtuanessrc097-master/NES/Mapper/Mapper115.h new file mode 100644 index 0000000..23d6f03 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper115.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper116.cpp b/virtuanessrc097-master/NES/Mapper/Mapper116.cpp new file mode 100644 index 0000000..d1119f6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper116.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper116.h b/virtuanessrc097-master/NES/Mapper/Mapper116.h new file mode 100644 index 0000000..6a3adaf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper116.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper117.cpp b/virtuanessrc097-master/NES/Mapper/Mapper117.cpp new file mode 100644 index 0000000..b1de976 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper117.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper117.h b/virtuanessrc097-master/NES/Mapper/Mapper117.h new file mode 100644 index 0000000..d9cf7f6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper117.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper118.cpp b/virtuanessrc097-master/NES/Mapper/Mapper118.cpp new file mode 100644 index 0000000..b417e77 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper118.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper118.h b/virtuanessrc097-master/NES/Mapper/Mapper118.h new file mode 100644 index 0000000..bd5b7ba Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper118.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper119.cpp b/virtuanessrc097-master/NES/Mapper/Mapper119.cpp new file mode 100644 index 0000000..6600a0e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper119.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper119.h b/virtuanessrc097-master/NES/Mapper/Mapper119.h new file mode 100644 index 0000000..196f6a6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper119.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper122.cpp b/virtuanessrc097-master/NES/Mapper/Mapper122.cpp new file mode 100644 index 0000000..513ec8c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper122.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper122.h b/virtuanessrc097-master/NES/Mapper/Mapper122.h new file mode 100644 index 0000000..af2b121 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper122.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper133.cpp b/virtuanessrc097-master/NES/Mapper/Mapper133.cpp new file mode 100644 index 0000000..84a2054 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper133.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper133.h b/virtuanessrc097-master/NES/Mapper/Mapper133.h new file mode 100644 index 0000000..9ed8828 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper133.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper134.cpp b/virtuanessrc097-master/NES/Mapper/Mapper134.cpp new file mode 100644 index 0000000..8df1c6a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper134.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper134.h b/virtuanessrc097-master/NES/Mapper/Mapper134.h new file mode 100644 index 0000000..aeeb145 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper134.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper135.cpp b/virtuanessrc097-master/NES/Mapper/Mapper135.cpp new file mode 100644 index 0000000..0f22917 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper135.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper135.h b/virtuanessrc097-master/NES/Mapper/Mapper135.h new file mode 100644 index 0000000..efe5f0c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper135.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper140.cpp b/virtuanessrc097-master/NES/Mapper/Mapper140.cpp new file mode 100644 index 0000000..e8bbec9 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper140.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper140.h b/virtuanessrc097-master/NES/Mapper/Mapper140.h new file mode 100644 index 0000000..b15c772 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper140.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper142.cpp b/virtuanessrc097-master/NES/Mapper/Mapper142.cpp new file mode 100644 index 0000000..d348d3b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper142.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper142.h b/virtuanessrc097-master/NES/Mapper/Mapper142.h new file mode 100644 index 0000000..38152d4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper142.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper151.cpp b/virtuanessrc097-master/NES/Mapper/Mapper151.cpp new file mode 100644 index 0000000..8c63e5b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper151.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper151.h b/virtuanessrc097-master/NES/Mapper/Mapper151.h new file mode 100644 index 0000000..0bb6b1c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper151.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper160.cpp b/virtuanessrc097-master/NES/Mapper/Mapper160.cpp new file mode 100644 index 0000000..04459fb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper160.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper160.h b/virtuanessrc097-master/NES/Mapper/Mapper160.h new file mode 100644 index 0000000..2ddc77b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper160.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper164.cpp b/virtuanessrc097-master/NES/Mapper/Mapper164.cpp new file mode 100644 index 0000000..ac77aaf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper164.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper164.h b/virtuanessrc097-master/NES/Mapper/Mapper164.h new file mode 100644 index 0000000..03fb959 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper164.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper165.cpp b/virtuanessrc097-master/NES/Mapper/Mapper165.cpp new file mode 100644 index 0000000..70e7e9b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper165.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper165.h b/virtuanessrc097-master/NES/Mapper/Mapper165.h new file mode 100644 index 0000000..a146d02 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper165.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper167.cpp b/virtuanessrc097-master/NES/Mapper/Mapper167.cpp new file mode 100644 index 0000000..8a91abf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper167.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper167.h b/virtuanessrc097-master/NES/Mapper/Mapper167.h new file mode 100644 index 0000000..1221ca0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper167.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper180.cpp b/virtuanessrc097-master/NES/Mapper/Mapper180.cpp new file mode 100644 index 0000000..1160a3b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper180.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper180.h b/virtuanessrc097-master/NES/Mapper/Mapper180.h new file mode 100644 index 0000000..01b3ac4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper180.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper181.cpp b/virtuanessrc097-master/NES/Mapper/Mapper181.cpp new file mode 100644 index 0000000..d7f21b5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper181.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper181.h b/virtuanessrc097-master/NES/Mapper/Mapper181.h new file mode 100644 index 0000000..4550016 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper181.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper182.cpp b/virtuanessrc097-master/NES/Mapper/Mapper182.cpp new file mode 100644 index 0000000..9abe244 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper182.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper182.h b/virtuanessrc097-master/NES/Mapper/Mapper182.h new file mode 100644 index 0000000..59d2d78 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper182.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper183.cpp b/virtuanessrc097-master/NES/Mapper/Mapper183.cpp new file mode 100644 index 0000000..28e5321 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper183.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper183.h b/virtuanessrc097-master/NES/Mapper/Mapper183.h new file mode 100644 index 0000000..ff19222 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper183.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper185.cpp b/virtuanessrc097-master/NES/Mapper/Mapper185.cpp new file mode 100644 index 0000000..cb39766 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper185.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper185.h b/virtuanessrc097-master/NES/Mapper/Mapper185.h new file mode 100644 index 0000000..0c8fed2 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper185.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper187.cpp b/virtuanessrc097-master/NES/Mapper/Mapper187.cpp new file mode 100644 index 0000000..b0e5aeb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper187.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper187.h b/virtuanessrc097-master/NES/Mapper/Mapper187.h new file mode 100644 index 0000000..65df954 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper187.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper188.cpp b/virtuanessrc097-master/NES/Mapper/Mapper188.cpp new file mode 100644 index 0000000..d082145 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper188.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper188.h b/virtuanessrc097-master/NES/Mapper/Mapper188.h new file mode 100644 index 0000000..1f97b84 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper188.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper189.cpp b/virtuanessrc097-master/NES/Mapper/Mapper189.cpp new file mode 100644 index 0000000..ee8917b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper189.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper189.h b/virtuanessrc097-master/NES/Mapper/Mapper189.h new file mode 100644 index 0000000..a13de7f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper189.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper190.cpp b/virtuanessrc097-master/NES/Mapper/Mapper190.cpp new file mode 100644 index 0000000..3061eb5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper190.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper190.h b/virtuanessrc097-master/NES/Mapper/Mapper190.h new file mode 100644 index 0000000..6e1b733 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper190.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper191.cpp b/virtuanessrc097-master/NES/Mapper/Mapper191.cpp new file mode 100644 index 0000000..166ba3e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper191.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper191.h b/virtuanessrc097-master/NES/Mapper/Mapper191.h new file mode 100644 index 0000000..d62675a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper191.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper193.cpp b/virtuanessrc097-master/NES/Mapper/Mapper193.cpp new file mode 100644 index 0000000..538aaa6 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper193.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper193.h b/virtuanessrc097-master/NES/Mapper/Mapper193.h new file mode 100644 index 0000000..6156b0b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper193.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper194.cpp b/virtuanessrc097-master/NES/Mapper/Mapper194.cpp new file mode 100644 index 0000000..49f9ca1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper194.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper194.h b/virtuanessrc097-master/NES/Mapper/Mapper194.h new file mode 100644 index 0000000..856331c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper194.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper198.cpp b/virtuanessrc097-master/NES/Mapper/Mapper198.cpp new file mode 100644 index 0000000..2c28c06 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper198.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper198.h b/virtuanessrc097-master/NES/Mapper/Mapper198.h new file mode 100644 index 0000000..4ec47a3 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper198.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper200.cpp b/virtuanessrc097-master/NES/Mapper/Mapper200.cpp new file mode 100644 index 0000000..53c187e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper200.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper200.h b/virtuanessrc097-master/NES/Mapper/Mapper200.h new file mode 100644 index 0000000..27ccb11 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper200.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper201.cpp b/virtuanessrc097-master/NES/Mapper/Mapper201.cpp new file mode 100644 index 0000000..a1697a0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper201.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper201.h b/virtuanessrc097-master/NES/Mapper/Mapper201.h new file mode 100644 index 0000000..06f54d1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper201.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper202.cpp b/virtuanessrc097-master/NES/Mapper/Mapper202.cpp new file mode 100644 index 0000000..644ff27 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper202.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper202.h b/virtuanessrc097-master/NES/Mapper/Mapper202.h new file mode 100644 index 0000000..43c8ae0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper202.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper222.cpp b/virtuanessrc097-master/NES/Mapper/Mapper222.cpp new file mode 100644 index 0000000..2f773ef Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper222.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper222.h b/virtuanessrc097-master/NES/Mapper/Mapper222.h new file mode 100644 index 0000000..9c58181 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper222.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper225.cpp b/virtuanessrc097-master/NES/Mapper/Mapper225.cpp new file mode 100644 index 0000000..f1755ee Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper225.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper225.h b/virtuanessrc097-master/NES/Mapper/Mapper225.h new file mode 100644 index 0000000..1bcaff7 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper225.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper226.cpp b/virtuanessrc097-master/NES/Mapper/Mapper226.cpp new file mode 100644 index 0000000..298db31 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper226.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper226.h b/virtuanessrc097-master/NES/Mapper/Mapper226.h new file mode 100644 index 0000000..c17f212 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper226.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper227.cpp b/virtuanessrc097-master/NES/Mapper/Mapper227.cpp new file mode 100644 index 0000000..e748a49 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper227.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper227.h b/virtuanessrc097-master/NES/Mapper/Mapper227.h new file mode 100644 index 0000000..2e59dce Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper227.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper228.cpp b/virtuanessrc097-master/NES/Mapper/Mapper228.cpp new file mode 100644 index 0000000..558224d Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper228.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper228.h b/virtuanessrc097-master/NES/Mapper/Mapper228.h new file mode 100644 index 0000000..0e720f4 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper228.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper229.cpp b/virtuanessrc097-master/NES/Mapper/Mapper229.cpp new file mode 100644 index 0000000..da91ce5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper229.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper229.h b/virtuanessrc097-master/NES/Mapper/Mapper229.h new file mode 100644 index 0000000..d124fbd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper229.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper230.cpp b/virtuanessrc097-master/NES/Mapper/Mapper230.cpp new file mode 100644 index 0000000..93ff703 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper230.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper230.h b/virtuanessrc097-master/NES/Mapper/Mapper230.h new file mode 100644 index 0000000..a79f471 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper230.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper231.cpp b/virtuanessrc097-master/NES/Mapper/Mapper231.cpp new file mode 100644 index 0000000..f409613 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper231.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper231.h b/virtuanessrc097-master/NES/Mapper/Mapper231.h new file mode 100644 index 0000000..95cb976 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper231.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper232.cpp b/virtuanessrc097-master/NES/Mapper/Mapper232.cpp new file mode 100644 index 0000000..5db9674 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper232.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper232.h b/virtuanessrc097-master/NES/Mapper/Mapper232.h new file mode 100644 index 0000000..25bcb50 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper232.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper233.cpp b/virtuanessrc097-master/NES/Mapper/Mapper233.cpp new file mode 100644 index 0000000..6947de0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper233.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper233.h b/virtuanessrc097-master/NES/Mapper/Mapper233.h new file mode 100644 index 0000000..eb0b77c Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper233.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper234.cpp b/virtuanessrc097-master/NES/Mapper/Mapper234.cpp new file mode 100644 index 0000000..73e60d0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper234.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper234.h b/virtuanessrc097-master/NES/Mapper/Mapper234.h new file mode 100644 index 0000000..bdea659 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper234.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper235.cpp b/virtuanessrc097-master/NES/Mapper/Mapper235.cpp new file mode 100644 index 0000000..a6c520e Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper235.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper235.h b/virtuanessrc097-master/NES/Mapper/Mapper235.h new file mode 100644 index 0000000..12ae633 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper235.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper236.cpp b/virtuanessrc097-master/NES/Mapper/Mapper236.cpp new file mode 100644 index 0000000..e773c4f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper236.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper236.h b/virtuanessrc097-master/NES/Mapper/Mapper236.h new file mode 100644 index 0000000..cb644f8 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper236.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper240.cpp b/virtuanessrc097-master/NES/Mapper/Mapper240.cpp new file mode 100644 index 0000000..d191dbb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper240.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper240.h b/virtuanessrc097-master/NES/Mapper/Mapper240.h new file mode 100644 index 0000000..29917e0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper240.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper241.cpp b/virtuanessrc097-master/NES/Mapper/Mapper241.cpp new file mode 100644 index 0000000..12361c3 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper241.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper241.h b/virtuanessrc097-master/NES/Mapper/Mapper241.h new file mode 100644 index 0000000..baa70ea Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper241.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper242.cpp b/virtuanessrc097-master/NES/Mapper/Mapper242.cpp new file mode 100644 index 0000000..1677b05 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper242.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper242.h b/virtuanessrc097-master/NES/Mapper/Mapper242.h new file mode 100644 index 0000000..5ea2601 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper242.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper243.cpp b/virtuanessrc097-master/NES/Mapper/Mapper243.cpp new file mode 100644 index 0000000..131c353 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper243.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper243.h b/virtuanessrc097-master/NES/Mapper/Mapper243.h new file mode 100644 index 0000000..18a0620 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper243.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper244.cpp b/virtuanessrc097-master/NES/Mapper/Mapper244.cpp new file mode 100644 index 0000000..735de6f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper244.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper244.h b/virtuanessrc097-master/NES/Mapper/Mapper244.h new file mode 100644 index 0000000..012f0fd Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper244.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper245.cpp b/virtuanessrc097-master/NES/Mapper/Mapper245.cpp new file mode 100644 index 0000000..7967c98 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper245.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper245.h b/virtuanessrc097-master/NES/Mapper/Mapper245.h new file mode 100644 index 0000000..10e2f32 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper245.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper246.cpp b/virtuanessrc097-master/NES/Mapper/Mapper246.cpp new file mode 100644 index 0000000..f389f3a Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper246.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper246.h b/virtuanessrc097-master/NES/Mapper/Mapper246.h new file mode 100644 index 0000000..0213914 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper246.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper248.cpp b/virtuanessrc097-master/NES/Mapper/Mapper248.cpp new file mode 100644 index 0000000..a7351bf Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper248.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper248.h b/virtuanessrc097-master/NES/Mapper/Mapper248.h new file mode 100644 index 0000000..17807e5 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper248.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper249.cpp b/virtuanessrc097-master/NES/Mapper/Mapper249.cpp new file mode 100644 index 0000000..32fea76 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper249.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper249.h b/virtuanessrc097-master/NES/Mapper/Mapper249.h new file mode 100644 index 0000000..831d0f8 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper249.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper251.cpp b/virtuanessrc097-master/NES/Mapper/Mapper251.cpp new file mode 100644 index 0000000..7586155 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper251.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper251.h b/virtuanessrc097-master/NES/Mapper/Mapper251.h new file mode 100644 index 0000000..919e0aa Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper251.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper252.cpp b/virtuanessrc097-master/NES/Mapper/Mapper252.cpp new file mode 100644 index 0000000..48b3536 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper252.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper252.h b/virtuanessrc097-master/NES/Mapper/Mapper252.h new file mode 100644 index 0000000..1375dc8 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper252.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper254.cpp b/virtuanessrc097-master/NES/Mapper/Mapper254.cpp new file mode 100644 index 0000000..672f9ce Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper254.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper254.h b/virtuanessrc097-master/NES/Mapper/Mapper254.h new file mode 100644 index 0000000..e175c92 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper254.h differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper255.cpp b/virtuanessrc097-master/NES/Mapper/Mapper255.cpp new file mode 100644 index 0000000..7d189bb Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper255.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/Mapper255.h b/virtuanessrc097-master/NES/Mapper/Mapper255.h new file mode 100644 index 0000000..c69315f Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/Mapper255.h differ diff --git a/virtuanessrc097-master/NES/Mapper/MapperFDS.cpp b/virtuanessrc097-master/NES/Mapper/MapperFDS.cpp new file mode 100644 index 0000000..4699312 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/MapperFDS.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/MapperFDS.h b/virtuanessrc097-master/NES/Mapper/MapperFDS.h new file mode 100644 index 0000000..55c2cf0 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/MapperFDS.h differ diff --git a/virtuanessrc097-master/NES/Mapper/MapperFactory.cpp b/virtuanessrc097-master/NES/Mapper/MapperFactory.cpp new file mode 100644 index 0000000..23104b9 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/MapperFactory.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/MapperNSF.cpp b/virtuanessrc097-master/NES/Mapper/MapperNSF.cpp new file mode 100644 index 0000000..c672ea1 Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/MapperNSF.cpp differ diff --git a/virtuanessrc097-master/NES/Mapper/MapperNSF.h b/virtuanessrc097-master/NES/Mapper/MapperNSF.h new file mode 100644 index 0000000..8def35b Binary files /dev/null and b/virtuanessrc097-master/NES/Mapper/MapperNSF.h differ diff --git a/virtuanessrc097-master/NES/Nes.cpp b/virtuanessrc097-master/NES/Nes.cpp new file mode 100644 index 0000000..a3e1ee3 Binary files /dev/null and b/virtuanessrc097-master/NES/Nes.cpp differ diff --git a/virtuanessrc097-master/NES/Nes.h b/virtuanessrc097-master/NES/Nes.h new file mode 100644 index 0000000..90acdbd Binary files /dev/null and b/virtuanessrc097-master/NES/Nes.h differ diff --git a/virtuanessrc097-master/NES/PAD.cpp b/virtuanessrc097-master/NES/PAD.cpp new file mode 100644 index 0000000..4712b1c Binary files /dev/null and b/virtuanessrc097-master/NES/PAD.cpp differ diff --git a/virtuanessrc097-master/NES/PAD.h b/virtuanessrc097-master/NES/PAD.h new file mode 100644 index 0000000..015423b Binary files /dev/null and b/virtuanessrc097-master/NES/PAD.h differ diff --git a/virtuanessrc097-master/NES/PPU.cpp b/virtuanessrc097-master/NES/PPU.cpp new file mode 100644 index 0000000..978540e Binary files /dev/null and b/virtuanessrc097-master/NES/PPU.cpp differ diff --git a/virtuanessrc097-master/NES/PPU.h b/virtuanessrc097-master/NES/PPU.h new file mode 100644 index 0000000..a5f6d3e Binary files /dev/null and b/virtuanessrc097-master/NES/PPU.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD.h b/virtuanessrc097-master/NES/PadEX/EXPAD.h new file mode 100644 index 0000000..0276cd3 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_CrazyClimber.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_CrazyClimber.cpp new file mode 100644 index 0000000..fdc3d20 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_CrazyClimber.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_CrazyClimber.h b/virtuanessrc097-master/NES/PadEX/EXPAD_CrazyClimber.h new file mode 100644 index 0000000..1f2fd80 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_CrazyClimber.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_ExcitingBoxing.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_ExcitingBoxing.cpp new file mode 100644 index 0000000..09dfdcb Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_ExcitingBoxing.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_ExcitingBoxing.h b/virtuanessrc097-master/NES/PadEX/EXPAD_ExcitingBoxing.h new file mode 100644 index 0000000..1dcc010 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_ExcitingBoxing.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_FamlyTrainer.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_FamlyTrainer.cpp new file mode 100644 index 0000000..9ba7825 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_FamlyTrainer.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_FamlyTrainer.h b/virtuanessrc097-master/NES/PadEX/EXPAD_FamlyTrainer.h new file mode 100644 index 0000000..ceb7d32 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_FamlyTrainer.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Gyromite.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Gyromite.cpp new file mode 100644 index 0000000..caac005 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Gyromite.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Gyromite.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Gyromite.h new file mode 100644 index 0000000..2194009 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Gyromite.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_HyperShot.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_HyperShot.cpp new file mode 100644 index 0000000..23d7e69 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_HyperShot.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_HyperShot.h b/virtuanessrc097-master/NES/PadEX/EXPAD_HyperShot.h new file mode 100644 index 0000000..20fff03 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_HyperShot.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Keyboard.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Keyboard.cpp new file mode 100644 index 0000000..f4189ae Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Keyboard.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Keyboard.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Keyboard.h new file mode 100644 index 0000000..5bd3dc8 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Keyboard.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Mahjang.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Mahjang.cpp new file mode 100644 index 0000000..223118c Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Mahjang.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Mahjang.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Mahjang.h new file mode 100644 index 0000000..a4eb056 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Mahjang.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_OekakidsTablet.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_OekakidsTablet.cpp new file mode 100644 index 0000000..1a9d865 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_OekakidsTablet.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_OekakidsTablet.h b/virtuanessrc097-master/NES/PadEX/EXPAD_OekakidsTablet.h new file mode 100644 index 0000000..24a8c05 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_OekakidsTablet.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Paddle.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Paddle.cpp new file mode 100644 index 0000000..5844821 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Paddle.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Paddle.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Paddle.h new file mode 100644 index 0000000..8f7e2f5 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Paddle.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_SpaceShadowGun.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_SpaceShadowGun.cpp new file mode 100644 index 0000000..3c20940 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_SpaceShadowGun.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_SpaceShadowGun.h b/virtuanessrc097-master/NES/PadEX/EXPAD_SpaceShadowGun.h new file mode 100644 index 0000000..0b679c7 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_SpaceShadowGun.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Supor_Keyboard.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Supor_Keyboard.cpp new file mode 100644 index 0000000..2161bd2 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Supor_Keyboard.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Supor_Keyboard.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Supor_Keyboard.h new file mode 100644 index 0000000..cbcb928 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Supor_Keyboard.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Toprider.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Toprider.cpp new file mode 100644 index 0000000..295bea5 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Toprider.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Toprider.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Toprider.h new file mode 100644 index 0000000..aae7862 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Toprider.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_TurboFile.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_TurboFile.cpp new file mode 100644 index 0000000..fbb1146 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_TurboFile.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_TurboFile.h b/virtuanessrc097-master/NES/PadEX/EXPAD_TurboFile.h new file mode 100644 index 0000000..bcc15d4 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_TurboFile.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_VSUnisystem.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_VSUnisystem.cpp new file mode 100644 index 0000000..eec0da8 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_VSUnisystem.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_VSUnisystem.h b/virtuanessrc097-master/NES/PadEX/EXPAD_VSUnisystem.h new file mode 100644 index 0000000..fcd074b Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_VSUnisystem.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_VSZapper.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_VSZapper.cpp new file mode 100644 index 0000000..81c8bb2 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_VSZapper.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_VSZapper.h b/virtuanessrc097-master/NES/PadEX/EXPAD_VSZapper.h new file mode 100644 index 0000000..2952ef8 Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_VSZapper.h differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Zapper.cpp b/virtuanessrc097-master/NES/PadEX/EXPAD_Zapper.cpp new file mode 100644 index 0000000..2c7537d Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Zapper.cpp differ diff --git a/virtuanessrc097-master/NES/PadEX/EXPAD_Zapper.h b/virtuanessrc097-master/NES/PadEX/EXPAD_Zapper.h new file mode 100644 index 0000000..47ece1d Binary files /dev/null and b/virtuanessrc097-master/NES/PadEX/EXPAD_Zapper.h differ diff --git a/virtuanessrc097-master/NES/ROM.cpp b/virtuanessrc097-master/NES/ROM.cpp new file mode 100644 index 0000000..c603afb Binary files /dev/null and b/virtuanessrc097-master/NES/ROM.cpp differ diff --git a/virtuanessrc097-master/NES/ROM.h b/virtuanessrc097-master/NES/ROM.h new file mode 100644 index 0000000..9e9e771 Binary files /dev/null and b/virtuanessrc097-master/NES/ROM.h differ diff --git a/virtuanessrc097-master/NES/ROMDB.cpp b/virtuanessrc097-master/NES/ROMDB.cpp new file mode 100644 index 0000000..2e8e6aa Binary files /dev/null and b/virtuanessrc097-master/NES/ROMDB.cpp differ diff --git a/virtuanessrc097-master/NES/ROMDB.h b/virtuanessrc097-master/NES/ROMDB.h new file mode 100644 index 0000000..e87c1fe Binary files /dev/null and b/virtuanessrc097-master/NES/ROMDB.h differ diff --git a/virtuanessrc097-master/NES/ROM_Patch.cpp b/virtuanessrc097-master/NES/ROM_Patch.cpp new file mode 100644 index 0000000..cee120f Binary files /dev/null and b/virtuanessrc097-master/NES/ROM_Patch.cpp differ diff --git a/virtuanessrc097-master/NES/State.h b/virtuanessrc097-master/NES/State.h new file mode 100644 index 0000000..a806226 Binary files /dev/null and b/virtuanessrc097-master/NES/State.h differ diff --git a/virtuanessrc097-master/NES/VS_Setting.h b/virtuanessrc097-master/NES/VS_Setting.h new file mode 100644 index 0000000..63a9fd3 Binary files /dev/null and b/virtuanessrc097-master/NES/VS_Setting.h differ diff --git a/virtuanessrc097-master/NES/VsUnisystem.cpp b/virtuanessrc097-master/NES/VsUnisystem.cpp new file mode 100644 index 0000000..637a14f Binary files /dev/null and b/virtuanessrc097-master/NES/VsUnisystem.cpp differ diff --git a/virtuanessrc097-master/NES/VsUnisystem.h b/virtuanessrc097-master/NES/VsUnisystem.h new file mode 100644 index 0000000..38d3a2e Binary files /dev/null and b/virtuanessrc097-master/NES/VsUnisystem.h differ diff --git a/virtuanessrc097-master/NameTableView.cpp b/virtuanessrc097-master/NameTableView.cpp new file mode 100644 index 0000000..b8c891a Binary files /dev/null and b/virtuanessrc097-master/NameTableView.cpp differ diff --git a/virtuanessrc097-master/NameTableView.h b/virtuanessrc097-master/NameTableView.h new file mode 100644 index 0000000..eba8640 Binary files /dev/null and b/virtuanessrc097-master/NameTableView.h differ diff --git a/virtuanessrc097-master/NetPlay.cpp b/virtuanessrc097-master/NetPlay.cpp new file mode 100644 index 0000000..7cd03f4 Binary files /dev/null and b/virtuanessrc097-master/NetPlay.cpp differ diff --git a/virtuanessrc097-master/NetPlay.h b/virtuanessrc097-master/NetPlay.h new file mode 100644 index 0000000..aa7a7bc Binary files /dev/null and b/virtuanessrc097-master/NetPlay.h differ diff --git a/virtuanessrc097-master/NetPlayDlg.cpp b/virtuanessrc097-master/NetPlayDlg.cpp new file mode 100644 index 0000000..551bc32 Binary files /dev/null and b/virtuanessrc097-master/NetPlayDlg.cpp differ diff --git a/virtuanessrc097-master/NetPlayDlg.h b/virtuanessrc097-master/NetPlayDlg.h new file mode 100644 index 0000000..f549dba Binary files /dev/null and b/virtuanessrc097-master/NetPlayDlg.h differ diff --git a/virtuanessrc097-master/PaletteEdit.cpp b/virtuanessrc097-master/PaletteEdit.cpp new file mode 100644 index 0000000..bbf6730 Binary files /dev/null and b/virtuanessrc097-master/PaletteEdit.cpp differ diff --git a/virtuanessrc097-master/PaletteEdit.h b/virtuanessrc097-master/PaletteEdit.h new file mode 100644 index 0000000..c07ee13 Binary files /dev/null and b/virtuanessrc097-master/PaletteEdit.h differ diff --git a/virtuanessrc097-master/PaletteView.cpp b/virtuanessrc097-master/PaletteView.cpp new file mode 100644 index 0000000..51c7d79 Binary files /dev/null and b/virtuanessrc097-master/PaletteView.cpp differ diff --git a/virtuanessrc097-master/PaletteView.h b/virtuanessrc097-master/PaletteView.h new file mode 100644 index 0000000..c0c866c Binary files /dev/null and b/virtuanessrc097-master/PaletteView.h differ diff --git a/virtuanessrc097-master/Pathlib.cpp b/virtuanessrc097-master/Pathlib.cpp new file mode 100644 index 0000000..9774ab1 Binary files /dev/null and b/virtuanessrc097-master/Pathlib.cpp differ diff --git a/virtuanessrc097-master/Pathlib.h b/virtuanessrc097-master/Pathlib.h new file mode 100644 index 0000000..86359b3 Binary files /dev/null and b/virtuanessrc097-master/Pathlib.h differ diff --git a/virtuanessrc097-master/PatternView.cpp b/virtuanessrc097-master/PatternView.cpp new file mode 100644 index 0000000..20f076e Binary files /dev/null and b/virtuanessrc097-master/PatternView.cpp differ diff --git a/virtuanessrc097-master/PatternView.h b/virtuanessrc097-master/PatternView.h new file mode 100644 index 0000000..40c233b Binary files /dev/null and b/virtuanessrc097-master/PatternView.h differ diff --git a/virtuanessrc097-master/Plugin.cpp b/virtuanessrc097-master/Plugin.cpp new file mode 100644 index 0000000..1a4670e Binary files /dev/null and b/virtuanessrc097-master/Plugin.cpp differ diff --git a/virtuanessrc097-master/Plugin.h b/virtuanessrc097-master/Plugin.h new file mode 100644 index 0000000..ff1a3e0 Binary files /dev/null and b/virtuanessrc097-master/Plugin.h differ diff --git a/virtuanessrc097-master/Pngwrite.h b/virtuanessrc097-master/Pngwrite.h new file mode 100644 index 0000000..ecd27d2 Binary files /dev/null and b/virtuanessrc097-master/Pngwrite.h differ diff --git a/virtuanessrc097-master/Recent.cpp b/virtuanessrc097-master/Recent.cpp new file mode 100644 index 0000000..220656b Binary files /dev/null and b/virtuanessrc097-master/Recent.cpp differ diff --git a/virtuanessrc097-master/Recent.h b/virtuanessrc097-master/Recent.h new file mode 100644 index 0000000..b043689 Binary files /dev/null and b/virtuanessrc097-master/Recent.h differ diff --git a/virtuanessrc097-master/Registry.cpp b/virtuanessrc097-master/Registry.cpp new file mode 100644 index 0000000..0255c82 Binary files /dev/null and b/virtuanessrc097-master/Registry.cpp differ diff --git a/virtuanessrc097-master/Registry.h b/virtuanessrc097-master/Registry.h new file mode 100644 index 0000000..fc09864 Binary files /dev/null and b/virtuanessrc097-master/Registry.h differ diff --git a/virtuanessrc097-master/Render.h b/virtuanessrc097-master/Render.h new file mode 100644 index 0000000..13c2b82 Binary files /dev/null and b/virtuanessrc097-master/Render.h differ diff --git a/virtuanessrc097-master/Render16bpp.h b/virtuanessrc097-master/Render16bpp.h new file mode 100644 index 0000000..5fdbb00 Binary files /dev/null and b/virtuanessrc097-master/Render16bpp.h differ diff --git a/virtuanessrc097-master/Render24bpp.h b/virtuanessrc097-master/Render24bpp.h new file mode 100644 index 0000000..b9a7863 Binary files /dev/null and b/virtuanessrc097-master/Render24bpp.h differ diff --git a/virtuanessrc097-master/Render32bpp.h b/virtuanessrc097-master/Render32bpp.h new file mode 100644 index 0000000..9ecb5b6 Binary files /dev/null and b/virtuanessrc097-master/Render32bpp.h differ diff --git a/virtuanessrc097-master/Render8bpp.h b/virtuanessrc097-master/Render8bpp.h new file mode 100644 index 0000000..7a859b4 Binary files /dev/null and b/virtuanessrc097-master/Render8bpp.h differ diff --git a/virtuanessrc097-master/RomInfoDlg.cpp b/virtuanessrc097-master/RomInfoDlg.cpp new file mode 100644 index 0000000..5775a46 Binary files /dev/null and b/virtuanessrc097-master/RomInfoDlg.cpp differ diff --git a/virtuanessrc097-master/RomInfoDlg.h b/virtuanessrc097-master/RomInfoDlg.h new file mode 100644 index 0000000..a7bf6db Binary files /dev/null and b/virtuanessrc097-master/RomInfoDlg.h differ diff --git a/virtuanessrc097-master/ShortcutDlg.cpp b/virtuanessrc097-master/ShortcutDlg.cpp new file mode 100644 index 0000000..80cab5d Binary files /dev/null and b/virtuanessrc097-master/ShortcutDlg.cpp differ diff --git a/virtuanessrc097-master/ShortcutDlg.h b/virtuanessrc097-master/ShortcutDlg.h new file mode 100644 index 0000000..9b010fc Binary files /dev/null and b/virtuanessrc097-master/ShortcutDlg.h differ diff --git a/virtuanessrc097-master/SimpleVirusChecker.c b/virtuanessrc097-master/SimpleVirusChecker.c new file mode 100644 index 0000000..e044045 --- /dev/null +++ b/virtuanessrc097-master/SimpleVirusChecker.c @@ -0,0 +1,227 @@ +/* + + SimpleVirusChecker + version 1.13 + programmed by Norix + + Copyright Note + source code: SimpleVirusChecker.c,SimpleVirusChecker.h + + Please use this program freely. + An author isn't concerned on a loss at having used this program at all. + An author prays for virus software disappearing from a PC in the world. + + --Attention-- + Because an author doesn't have a PC infected with a virus program, can't + guarantee it whether you were able to completely check it. + + Histroy: + v1.1 add WORM_FIZZER + add WORM_PALYH + add WORM_LOVGATE + add WORM_OPASERV + v1.11 add WORM_SOBIG.F + v1.12 add WORM_MYDOOM.A + v1.121 fixed WORM_MYDOOM.A checker + v1.13 add WORM_NETSKY.Q +*/ +#include "SimpleVirusChecker.h" +#include + +#define KEYTYPE_1 (1<<0) /* Windows startup registry */ +#define KEYTYPE_2 (1<<1) /* Windows Servece registry(NT only) */ + +typedef struct { + TCHAR* keyname; + int type; /* type */ + int length; /* use strncmp length (0 is use strcmp) */ +} VIRUSKEYTBL; + +static VIRUSKEYTBL viruskeytbl[] = { +/* KEY KEYTYPE LENGTH */ + _T("Wink"), KEYTYPE_1|KEYTYPE_2, 4, /* Klez */ + _T("WindowsMGM"), KEYTYPE_1|KEYTYPE_2, 0, /* Sobig */ + _T("Avril Lavigne - Muse"), KEYTYPE_1, 0, /* Lirva */ + _T("SystemInit"), KEYTYPE_1, 0, /* Fizzer */ + _T("System Tray"), KEYTYPE_1, 0, /* Palyh */ + _T("WinGate initialize"), KEYTYPE_1, 0, /* Lovgate */ + _T("ScrSvr"), KEYTYPE_1, 0, /* Opaserv */ + _T("SSK Service"), KEYTYPE_1, 0, /* Sobig.E */ + _T("TrayX"), KEYTYPE_1, 0, /* Sobig.F */ + _T("SysMonXP"), KEYTYPE_1, 0, /* NetSky.P */ + NULL, 0, 0 /* term */ +}; + +/* WindowsNT? */ +static int IsNT( void ) +{ + OSVERSIONINFO osvi; + osvi.dwOSVersionInfoSize = sizeof(osvi); + if( !GetVersionEx(&osvi) ) + return 0; + + if( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT ) + return 1; + + if( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) + return 0; + + /* unknown */ + return -1; +} + +/* A check of a type to be infected with *.exe activation (representative example:SIRCAM) */ +static int ExeRegistryCheck( void ) +{ + HKEY hKey; + LONG lResult; + DWORD dwCount; + + if( RegOpenKeyEx( HKEY_CLASSES_ROOT, _T("exefile\\shell\\open\\command"), + 0, KEY_READ, &hKey ) != ERROR_SUCCESS ) { + return -1; + } + + lResult = RegQueryValueEx( hKey, _T(""), NULL, NULL, NULL, &dwCount ); + RegCloseKey( hKey ); + if( lResult != ERROR_SUCCESS ) { + return -1; + } + /* + Check it whether a parameter is different from a default parameter. + May think that this is originally infected when it is only '"%1" %*' + and has length more than it. + */ + if( dwCount > 8 ) { + return 1; + } + /* OK */ + return 0; +} + +/* A check of a type to be infected with *.exe activation (representative example:SIRCAM) */ +static int SpecialRegistryCheck( void ) +{ + HKEY hKey; + LONG lResult; + TCHAR szKeyName[1024]; + BYTE KeyValue[1024]; + DWORD dwKeyType, dwKeyBufferSize; + + DWORD dwIndex, dwCount; + + // WORM_MYDOOM.A ? + if( RegOpenKeyEx( HKEY_CLASSES_ROOT, _T("CLSID\\{E6FB5E20-DE35-11CF-9C87-00AA005127ED}\\InProcServer32"), + 0, KEY_READ, &hKey ) != ERROR_SUCCESS ) { + RegCloseKey( hKey ); + return 0; // not found key + } + + dwIndex = 0; + while( 1 ) { + dwCount = sizeof(szKeyName)/sizeof(TCHAR); + dwKeyBufferSize = sizeof(KeyValue); + + lResult = RegEnumValue( hKey, dwIndex, szKeyName, &dwCount, 0, &dwKeyType, KeyValue, &dwKeyBufferSize ); + if( lResult != ERROR_SUCCESS ) { + break; + } + + if( StrStrI( KeyValue, "shimgapi.dll" ) != NULL ) + return 1; // Found!! + + dwIndex++; + } + RegCloseKey( hKey ); + + /* OK */ + return 0; +} + +/* Character string comparison */ +static int KlezTypeCheckSub( const char* name, int mask ) +{ + VIRUSKEYTBL* tbl = viruskeytbl; + + while( tbl->keyname ) { + if( tbl->type & mask ) { + if( !tbl->length ) { + if( StrCmpI( name, tbl->keyname ) == 0 ) + return 1; + } else { + if( StrCmpNI( name, tbl->keyname, tbl->length ) == 0 ) + return 1; + } + } + tbl++; + } + return 0; +} + +/* A check of the registry which a virus uses */ +static int KlezTypeCheck( void ) +{ + HKEY hKey; + LONG lResult; + TCHAR szKeyName[1024]; + DWORD dwIndex, dwCount; + FILETIME ft; + int viruscount = 0; + + /* Search a thing registered with Windows Startup */ + if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), + 0, KEY_READ, &hKey ) != ERROR_SUCCESS ) { + return -1; + } + dwIndex = 0; + while( 1 ) { + dwCount = sizeof(szKeyName)/sizeof(TCHAR); + lResult = RegEnumValue( hKey, dwIndex, szKeyName, &dwCount, 0, NULL, NULL, NULL ); + if( lResult != ERROR_SUCCESS ) { + break; + } + viruscount += KlezTypeCheckSub( szKeyName, KEYTYPE_1 ); + dwIndex++; + } + RegCloseKey( hKey ); + + if( !IsNT() ) { + return viruscount; + } + + /* Search a thing registered with WindowsNT Service */ + if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Services"), + 0, KEY_READ, &hKey ) != ERROR_SUCCESS ) { + return -1; + } + dwIndex = 0; + while( 1 ) { + dwCount = sizeof(szKeyName)/sizeof(TCHAR); + lResult = RegEnumKeyEx( hKey, dwIndex, szKeyName, &dwCount, 0, NULL, NULL, &ft ); + if( lResult != ERROR_SUCCESS ) { + break; + } + viruscount += KlezTypeCheckSub( szKeyName, KEYTYPE_2 ); + dwIndex++; + } + RegCloseKey( hKey ); + + return viruscount; +} + +int SimpleVirusChecker(void) +{ + int viruscount = 0; + + if( IsNT() < 0 ) + return -1; + + if( ExeRegistryCheck() > 0 ) + viruscount++; + + viruscount += SpecialRegistryCheck(); + viruscount += KlezTypeCheck(); + + return viruscount; +} + diff --git a/virtuanessrc097-master/SimpleVirusChecker.h b/virtuanessrc097-master/SimpleVirusChecker.h new file mode 100644 index 0000000..c3fa900 Binary files /dev/null and b/virtuanessrc097-master/SimpleVirusChecker.h differ diff --git a/virtuanessrc097-master/SoundDlg.cpp b/virtuanessrc097-master/SoundDlg.cpp new file mode 100644 index 0000000..9b45e74 Binary files /dev/null and b/virtuanessrc097-master/SoundDlg.cpp differ diff --git a/virtuanessrc097-master/SoundDlg.h b/virtuanessrc097-master/SoundDlg.h new file mode 100644 index 0000000..9670772 Binary files /dev/null and b/virtuanessrc097-master/SoundDlg.h differ diff --git a/virtuanessrc097-master/Typedef.h b/virtuanessrc097-master/Typedef.h new file mode 100644 index 0000000..521fc61 Binary files /dev/null and b/virtuanessrc097-master/Typedef.h differ diff --git a/virtuanessrc097-master/VirtuaNES.dsp b/virtuanessrc097-master/VirtuaNES.dsp new file mode 100644 index 0000000..3701f26 --- /dev/null +++ b/virtuanessrc097-master/VirtuaNES.dsp @@ -0,0 +1,5871 @@ +# Microsoft Developer Studio Project File - Name="VirtuaNES" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** •ÒW‚µ‚È‚¢‚Å‚­‚¾‚³‚¢ ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=VirtuaNES - Win32 Debug +!MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B +!MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚­‚¾‚³‚¢ +!MESSAGE +!MESSAGE NMAKE /f "VirtuaNES.mak". +!MESSAGE +!MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚· +!MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á: +!MESSAGE +!MESSAGE NMAKE /f "VirtuaNES.mak" CFG="VirtuaNES - Win32 Debug" +!MESSAGE +!MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ: +!MESSAGE +!MESSAGE "VirtuaNES - Win32 Release" ("Win32 (x86) Application" —p) +!MESSAGE "VirtuaNES - Win32 Debug" ("Win32 (x86) Application" —p) +!MESSAGE "VirtuaNES - Win32 Profile" ("Win32 (x86) Application" —p) +!MESSAGE "VirtuaNES - Win32 Release_Debugout" ("Win32 (x86) Application" —p) +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "Zlib" /I "." /I "NES" /I "NES\Mapper" /I "NES\ApuEx" /I "NES\ApuEx\emu2413" /I "NES\PadEx" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x411 /d "NDEBUG" +# ADD RSC /l 0x411 /i "res" /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib imm32.lib dinput.lib shlwapi.lib /nologo /subsystem:windows /map /machine:I386 +# SUBTRACT LINK32 /nodefaultlib + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /I "." /I "NES" /I "NES\Mapper" /I "NES\ApuEx" /I "NES\ApuEx\emu2413" /I "NES\PadEx" /I "Zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x411 /d "_DEBUG" +# ADD RSC /l 0x411 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib imm32.lib dinput.lib shlwapi.lib libcmtd.lib /nologo /subsystem:windows /map /debug /machine:I386 /pdbtype:sept +# SUBTRACT LINK32 /nodefaultlib + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "VirtuaNES___Win32_Profile" +# PROP BASE Intermediate_Dir "VirtuaNES___Win32_Profile" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Profile" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "." /I "NES" /I "NES\Mapper" /I "NES\ApuEx" /I "NES\PadEx" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /Z7 /O2 /I "." /I "NES" /I "NES\Mapper" /I "NES\ApuEx" /I "NES\ApuEx\emu2413" /I "NES\PadEx" /I "Zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x411 /d "NDEBUG" +# ADD RSC /l 0x411 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib imm32.lib dinput.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib imm32.lib dinput.lib shlwapi.lib /nologo /subsystem:windows /profile /map:"VirtuaNES.map" /debug /machine:I386 +# SUBTRACT LINK32 /nodefaultlib + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "VirtuaNES___Win32_Release_Debugout" +# PROP BASE Intermediate_Dir "VirtuaNES___Win32_Release_Debugout" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release_Debugout" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "." /I "NES" /I "NES\Mapper" /I "NES\ApuEx" /I "NES\PadEx" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_DEBUGOUT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /Z7 /O2 /I "." /I "NES" /I "NES\Mapper" /I "NES\ApuEx" /I "NES\ApuEx\emu2413" /I "NES\PadEx" /I "Zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_DEBUGOUT" /YX /FD /c +# SUBTRACT CPP /Fr +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x411 /d "NDEBUG" +# ADD RSC /l 0x411 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib imm32.lib dinput.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib imm32.lib dinput.lib shlwapi.lib /nologo /subsystem:windows /map /debug /machine:I386 +# SUBTRACT LINK32 /nodefaultlib + +!ENDIF + +# Begin Target + +# Name "VirtuaNES - Win32 Release" +# Name "VirtuaNES - Win32 Debug" +# Name "VirtuaNES - Win32 Profile" +# Name "VirtuaNES - Win32 Release_Debugout" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\AboutDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\App.cpp +# End Source File +# Begin Source File + +SOURCE=.\Archive.cpp +# End Source File +# Begin Source File + +SOURCE=.\AviConvDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\AviWriter.cpp +# End Source File +# Begin Source File + +SOURCE=.\ChatDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\CheatDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\Com.cpp +# End Source File +# Begin Source File + +SOURCE=.\Config.cpp +# End Source File +# Begin Source File + +SOURCE=.\ControllerDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\Crclib.cpp +# End Source File +# Begin Source File + +SOURCE=.\DatachBarcodeDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\DebugOut.cpp +# End Source File +# Begin Source File + +SOURCE=.\DipSwitchDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\DirectDraw.cpp +# End Source File +# Begin Source File + +SOURCE=.\DirectInput.cpp +# End Source File +# Begin Source File + +SOURCE=.\DirectSound.cpp +# End Source File +# Begin Source File + +SOURCE=.\EmulatorDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\EmuThread.cpp +# End Source File +# Begin Source File + +SOURCE=.\FolderDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\GameOptionDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\GraphicsDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\JoyAxisDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\LanguageDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\LauncherDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\MainFrame.cpp +# End Source File +# Begin Source File + +SOURCE=.\MemoryView.cpp +# End Source File +# Begin Source File + +SOURCE=.\MMTimer.cpp +# End Source File +# Begin Source File + +SOURCE=.\MovieDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\MovieInfoDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\NameTableView.cpp +# End Source File +# Begin Source File + +SOURCE=.\NetPlay.cpp +# End Source File +# Begin Source File + +SOURCE=.\NetPlayDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\PaletteEdit.cpp +# End Source File +# Begin Source File + +SOURCE=.\PaletteView.cpp +# End Source File +# Begin Source File + +SOURCE=.\Pathlib.cpp +# End Source File +# Begin Source File + +SOURCE=.\PatternView.cpp +# End Source File +# Begin Source File + +SOURCE=.\Plugin.cpp +# End Source File +# Begin Source File + +SOURCE=.\Recent.cpp +# End Source File +# Begin Source File + +SOURCE=.\Registry.cpp +# End Source File +# Begin Source File + +SOURCE=.\RomInfoDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\ShortcutDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\SimpleVirusChecker.c +# End Source File +# Begin Source File + +SOURCE=.\SoundDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\VirtuaNES.rc +# End Source File +# Begin Source File + +SOURCE=.\WaveRec.cpp +# End Source File +# Begin Source File + +SOURCE=.\WinMain.cpp +# End Source File +# Begin Source File + +SOURCE=.\Wnd.cpp +# End Source File +# Begin Source File + +SOURCE=.\WndHook.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\AboutDlg.h +# End Source File +# Begin Source File + +SOURCE=.\App.h +# End Source File +# Begin Source File + +SOURCE=.\Archive.h +# End Source File +# Begin Source File + +SOURCE=.\AviConvDlg.h +# End Source File +# Begin Source File + +SOURCE=.\AviWriter.h +# End Source File +# Begin Source File + +SOURCE=.\ChatDlg.h +# End Source File +# Begin Source File + +SOURCE=.\CheatDlg.h +# End Source File +# Begin Source File + +SOURCE=.\CHyperLink.h +# End Source File +# Begin Source File + +SOURCE=.\Com.h +# End Source File +# Begin Source File + +SOURCE=.\Config.h +# End Source File +# Begin Source File + +SOURCE=.\ControllerDlg.h +# End Source File +# Begin Source File + +SOURCE=.\Crclib.h +# End Source File +# Begin Source File + +SOURCE=.\DatachBarcodeDlg.h +# End Source File +# Begin Source File + +SOURCE=.\DebugOut.h +# End Source File +# Begin Source File + +SOURCE=.\DipSwitchDlg.h +# End Source File +# Begin Source File + +SOURCE=.\DirectDraw.h +# End Source File +# Begin Source File + +SOURCE=.\DirectInput.h +# End Source File +# Begin Source File + +SOURCE=.\DirectSound.h +# End Source File +# Begin Source File + +SOURCE=.\EmulatorDlg.h +# End Source File +# Begin Source File + +SOURCE=.\EmuThread.h +# End Source File +# Begin Source File + +SOURCE=.\FolderDlg.h +# End Source File +# Begin Source File + +SOURCE=.\GameOptionDlg.h +# End Source File +# Begin Source File + +SOURCE=.\GraphicsDlg.h +# End Source File +# Begin Source File + +SOURCE=.\hq2x.h +# End Source File +# Begin Source File + +SOURCE=.\interp.h +# End Source File +# Begin Source File + +SOURCE=.\JoyAxisDlg.h +# End Source File +# Begin Source File + +SOURCE=.\LanguageDlg.h +# End Source File +# Begin Source File + +SOURCE=.\LauncherDlg.h +# End Source File +# Begin Source File + +SOURCE=.\lq2x.h +# End Source File +# Begin Source File + +SOURCE=.\lzAscii.h +# End Source File +# Begin Source File + +SOURCE=.\lzSight.h +# End Source File +# Begin Source File + +SOURCE=.\lzTVlayer.h +# End Source File +# Begin Source File + +SOURCE=.\Macro.h +# End Source File +# Begin Source File + +SOURCE=.\MainFrame.h +# End Source File +# Begin Source File + +SOURCE=.\MemoryView.h +# End Source File +# Begin Source File + +SOURCE=.\MMTimer.h +# End Source File +# Begin Source File + +SOURCE=.\MovieDlg.h +# End Source File +# Begin Source File + +SOURCE=.\MovieInfoDlg.h +# End Source File +# Begin Source File + +SOURCE=.\NameTableView.h +# End Source File +# Begin Source File + +SOURCE=.\NetPlay.h +# End Source File +# Begin Source File + +SOURCE=.\NetPlayDlg.h +# End Source File +# Begin Source File + +SOURCE=.\nx_2xSaI.h +# End Source File +# Begin Source File + +SOURCE=.\nx_hq2x.h +# End Source File +# Begin Source File + +SOURCE=.\nx_Scale2x.h +# End Source File +# Begin Source File + +SOURCE=.\nx_Super2xSaI.h +# End Source File +# Begin Source File + +SOURCE=.\nx_Super2xSaI_32bpp_mmx.h +# End Source File +# Begin Source File + +SOURCE=.\nx_SuperEagle.h +# End Source File +# Begin Source File + +SOURCE=.\PaletteEdit.h +# End Source File +# Begin Source File + +SOURCE=.\PaletteView.h +# End Source File +# Begin Source File + +SOURCE=.\Pathlib.h +# End Source File +# Begin Source File + +SOURCE=.\PatternView.h +# End Source File +# Begin Source File + +SOURCE=.\Plugin.h +# End Source File +# Begin Source File + +SOURCE=.\Pngwrite.h +# End Source File +# Begin Source File + +SOURCE=.\Recent.h +# End Source File +# Begin Source File + +SOURCE=.\Registry.h +# End Source File +# Begin Source File + +SOURCE=.\Render.h +# End Source File +# Begin Source File + +SOURCE=.\Render16bpp.h +# End Source File +# Begin Source File + +SOURCE=.\Render24bpp.h +# End Source File +# Begin Source File + +SOURCE=.\Render32bpp.h +# End Source File +# Begin Source File + +SOURCE=.\Render8bpp.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# Begin Source File + +SOURCE=.\RomInfoDlg.h +# End Source File +# Begin Source File + +SOURCE=.\ShortcutDlg.h +# End Source File +# Begin Source File + +SOURCE=.\SimpleVirusChecker.h +# End Source File +# Begin Source File + +SOURCE=.\SoundDlg.h +# End Source File +# Begin Source File + +SOURCE=.\Typedef.h +# End Source File +# Begin Source File + +SOURCE=.\VirtuaNESres.h +# End Source File +# Begin Source File + +SOURCE=.\WaveRec.h +# End Source File +# Begin Source File + +SOURCE=.\Wnd.h +# End Source File +# Begin Source File + +SOURCE=.\WndHook.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\CheatImageList.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\header_down.ico +# End Source File +# Begin Source File + +SOURCE=.\res\header_up.ico +# End Source File +# Begin Source File + +SOURCE=.\LauncherImageList.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\VirtuaNES.exe.manifest +# End Source File +# Begin Source File + +SOURCE=.\res\VirtuaNES.ico +# End Source File +# End Group +# Begin Group "NES" + +# PROP Default_Filter "" +# Begin Group "Mapper" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\NES\Mapper\EEPROM.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper.h +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper000.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper000.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper001.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper001.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper002.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper002.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper003.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper003.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper004.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper004.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper005.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper005.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper006.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper006.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper007.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper007.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper008.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper008.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper009.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper009.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper010.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper010.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper011.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper011.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper012.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper012.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper013.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper013.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper015.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper015.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper016.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper016.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper017.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper017.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper018.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper018.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper019.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper019.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper021.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper021.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper022.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper022.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper023.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper023.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper024.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper024.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper025.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper025.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper026.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper026.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper027.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper027.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper032.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper032.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper033.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper033.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper034.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper034.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper040.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper040.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper041.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper041.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper042.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper042.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper043.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper043.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper044.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper044.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper045.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper045.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper046.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper046.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper047.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper047.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper048.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper048.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper050.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper050.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper051.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper051.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper057.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper057.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper058.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper058.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper060.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper060.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper061.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper061.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper062.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper062.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper064.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper064.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper065.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper065.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper066.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper066.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper067.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper067.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper068.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper068.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper069.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper069.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper070.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper070.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper071.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper071.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper072.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper072.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper073.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper073.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper074.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper074.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper075.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper075.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper076.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper076.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper077.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper077.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper078.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper078.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper079.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper079.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper080.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper080.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper082.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper082.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper083.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper083.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper085.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper085.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper086.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper086.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper087.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper087.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper088.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper088.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper089.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper089.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper090.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper090.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper091.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper091.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper092.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper092.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper093.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper093.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper094.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper094.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper095.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper095.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper096.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper096.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper097.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper097.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper099.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper099.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper100.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper100.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper101.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper101.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper105.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper105.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper107.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper107.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper108.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper108.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper109.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper109.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper110.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper110.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper112.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper112.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper113.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper113.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper114.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper114.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper115.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper115.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper116.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper116.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper117.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper117.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper118.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper118.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper119.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper119.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper122.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper122.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper133.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper133.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper134.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper134.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper135.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper135.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper140.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper140.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper142.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper142.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper151.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper151.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper160.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper160.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper164.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper164.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper165.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper165.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper167.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper167.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper180.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper180.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper181.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper181.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper182.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper182.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper183.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper183.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper185.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper185.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper187.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper187.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper188.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper188.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper189.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper189.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper190.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper190.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper191.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper191.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper193.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper193.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper194.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper194.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper198.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper198.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper200.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper200.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper201.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper201.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper202.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper202.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper222.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper222.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper225.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper225.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper226.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper226.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper227.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper227.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper228.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper228.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper229.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper229.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper230.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper230.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper231.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper231.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper232.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper232.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper233.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper233.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper234.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper234.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper235.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper235.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper236.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper236.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper240.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper240.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper241.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper241.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper242.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper242.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper243.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper243.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper244.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper244.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper245.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper245.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper246.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper246.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper248.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper248.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper249.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper249.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper251.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper251.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper252.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper252.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper254.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper254.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper255.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\Mapper255.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\MapperFactory.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\MapperFDS.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\MapperFDS.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\MapperNSF.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\Mapper\MapperNSF.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# End Group +# Begin Group "ApuEx" + +# PROP Default_Filter "" +# Begin Group "emu2413" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\NES\ApuEX\emu2413\2413tone.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\emu2413\emu2413.c +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\emu2413\emu2413.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\emu2413\vrc7tone.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_FDS.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_FDS.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_FME7.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_FME7.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_INTERFACE.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_INTERNAL.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_INTERNAL.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_MMC5.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_MMC5.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_N106.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_N106.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_VRC6.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_VRC6.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_VRC7.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ApuEX\APU_VRC7.h +# End Source File +# End Group +# Begin Group "PadEx" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_CrazyClimber.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_CrazyClimber.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_ExcitingBoxing.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_ExcitingBoxing.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_FamlyTrainer.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_FamlyTrainer.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Gyromite.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Gyromite.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_HyperShot.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_HyperShot.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Keyboard.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Keyboard.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Mahjang.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Mahjang.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_OekakidsTablet.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_OekakidsTablet.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Paddle.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Paddle.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_SpaceShadowGun.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_SpaceShadowGun.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Supor_Keyboard.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Supor_Keyboard.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Toprider.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Toprider.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_TurboFile.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_TurboFile.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_VSUnisystem.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_VSUnisystem.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_VSZapper.cpp +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_VSZapper.h +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Zapper.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\PadEX\EXPAD_Zapper.h + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# End Group +# Begin Source File + +SOURCE=.\NES\APU.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\APU.h +# End Source File +# Begin Source File + +SOURCE=.\NES\Cheat.h +# End Source File +# Begin Source File + +SOURCE=.\NES\Cpu.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\CPU.h +# End Source File +# Begin Source File + +SOURCE=.\NES\IPS.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\IPS.h +# End Source File +# Begin Source File + +SOURCE=.\NES\MMU.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\MMU.h +# End Source File +# Begin Source File + +SOURCE=.\NES\Nes.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\Nes.h +# End Source File +# Begin Source File + +SOURCE=.\NES\PAD.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\PAD.h +# End Source File +# Begin Source File + +SOURCE=.\NES\PPU.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\PPU.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ROM.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ROM.h +# End Source File +# Begin Source File + +SOURCE=.\NES\ROM_Patch.cpp + +!IF "$(CFG)" == "VirtuaNES - Win32 Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Profile" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "VirtuaNES - Win32 Release_Debugout" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\NES\ROMDB.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\ROMDB.h +# End Source File +# Begin Source File + +SOURCE=.\NES\State.h +# End Source File +# Begin Source File + +SOURCE=.\NES\VS_Setting.h +# End Source File +# Begin Source File + +SOURCE=.\NES\VsUnisystem.cpp +# End Source File +# Begin Source File + +SOURCE=.\NES\VsUnisystem.h +# End Source File +# End Group +# Begin Group "Zlib" + +# PROP Default_Filter "*.c *.cpp *.h" +# Begin Source File + +SOURCE=.\zlib\unzip.c +# End Source File +# Begin Source File + +SOURCE=.\zlib\unzip.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\zconf.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\zlib.h +# End Source File +# Begin Source File + +SOURCE=.\zlib\zlib.lib +# End Source File +# End Group +# End Target +# End Project diff --git a/virtuanessrc097-master/VirtuaNES.dsw b/virtuanessrc097-master/VirtuaNES.dsw new file mode 100644 index 0000000..23a7e33 --- /dev/null +++ b/virtuanessrc097-master/VirtuaNES.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# Œx: ‚±‚ÌÜ°¸½Íß°½ ̧²Ù ‚ð•ÒW‚Ü‚½‚Í휂µ‚È‚¢‚Å‚­‚¾‚³‚¢! + +############################################################################### + +Project: "VirtuaNES"=.\VirtuaNES.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/virtuanessrc097-master/VirtuaNES.opt b/virtuanessrc097-master/VirtuaNES.opt new file mode 100644 index 0000000..0670752 Binary files /dev/null and b/virtuanessrc097-master/VirtuaNES.opt differ diff --git a/virtuanessrc097-master/VirtuaNES.rc b/virtuanessrc097-master/VirtuaNES.rc new file mode 100644 index 0000000..0774a99 --- /dev/null +++ b/virtuanessrc097-master/VirtuaNES.rc @@ -0,0 +1,120 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" +#include "virtuanesres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// “ú–{Œê resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) +#ifdef _WIN32 +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT +#pragma code_page(932) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "#include ""virtuanesres.h""\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST ""res\\\\VirtuaNES.exe.manifest""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON ICON DISCARDABLE "res\VirtuaNES.ico" +IDI_SORT_DOWN ICON DISCARDABLE "res\header_down.ico" +IDI_SORT_UP ICON DISCARDABLE "res\header_up.ico" + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,0,9,5 + PRODUCTVERSION 0,0,9,5 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "041104b0" + BEGIN + VALUE "FileDescription", "VirtuaNES NES emulator for Win32\0" + VALUE "FileVersion", "0.95\0" + VALUE "InternalName", "VirtuaNES\0" + VALUE "LegalCopyright", "Copyright (C) 2001-2007 Norix\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x411, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_CHEATIMAGELIST BITMAP DISCARDABLE "res\CheatImageList.bmp" +IDB_LAUNCHERIMAGELIST BITMAP DISCARDABLE "res\LauncherImageList.bmp" +#endif // “ú–{Œê resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "res\\VirtuaNES.exe.manifest" + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/virtuanessrc097-master/VirtuaNES.sln b/virtuanessrc097-master/VirtuaNES.sln new file mode 100644 index 0000000..3389f87 --- /dev/null +++ b/virtuanessrc097-master/VirtuaNES.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VirtuaNES", "VirtuaNES.vcxproj", "{788F7F02-C4F5-4477-8429-CB02507855EA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Profile|Win32 = Profile|Win32 + Release_Debugout|Win32 = Release_Debugout|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {788F7F02-C4F5-4477-8429-CB02507855EA}.Debug|Win32.ActiveCfg = Debug|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Debug|Win32.Build.0 = Debug|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Profile|Win32.ActiveCfg = Profile|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Profile|Win32.Build.0 = Profile|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Release_Debugout|Win32.ActiveCfg = Release_Debugout|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Release_Debugout|Win32.Build.0 = Release_Debugout|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Release|Win32.ActiveCfg = Release|Win32 + {788F7F02-C4F5-4477-8429-CB02507855EA}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/virtuanessrc097-master/VirtuaNES.vcxproj b/virtuanessrc097-master/VirtuaNES.vcxproj new file mode 100644 index 0000000..1fbde56 --- /dev/null +++ b/virtuanessrc097-master/VirtuaNES.vcxproj @@ -0,0 +1,2426 @@ + + + + + Debug + Win32 + + + Profile + Win32 + + + Release_Debugout + Win32 + + + Release + Win32 + + + + + + {788F7F02-C4F5-4477-8429-CB02507855EA} + 10.0 + + + + Application + v110 + false + MultiByte + + + Application + v110 + false + MultiByte + + + Application + v143 + false + MultiByte + + + Application + v110 + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + .\ + .\Profile\ + false + + + .\ + .\Debug\ + true + + + .\ + .\Release\ + false + + + .\ + .\Release_Debugout\ + false + + + + MultiThreaded + Default + true + true + MaxSpeed + true + Level3 + OldStyle + .;NES;NES\Mapper;NES\ApuEx;NES\ApuEx\emu2413;NES\PadEx;Zlib;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + .\Profile\ + .\Profile\VirtuaNES.pch + .\Profile\ + .\Profile\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\VirtuaNES.tlb + true + Win32 + + + 0x0411 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\VirtuaNES.bsc + + + true + true + Windows + false + .\VirtuaNES.exe + odbc32.lib;odbccp32.lib;winmm.lib;comctl32.lib;imm32.lib;dinput8.lib;shlwapi.lib;%(AdditionalDependencies) + + + + + MultiThreadedDebugDLL + Default + false + Disabled + true + Level3 + true + ProgramDatabase + .;NES;NES\Mapper;NES\ApuEx;NES\ApuEx\emu2413;NES\PadEx;Zlib;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + .\Debug\ + .\Debug\VirtuaNES.pch + .\Debug\ + .\Debug\ + EnableFastChecks + /ZI- %(AdditionalOptions) + + + true + _DEBUG;%(PreprocessorDefinitions) + .\VirtuaNES.tlb + true + Win32 + + + 0x0411 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\VirtuaNES.bsc + + + true + true + Windows + false + .\VirtuaNES.exe + odbc32.lib;odbccp32.lib;winmm.lib;comctl32.lib;imm32.lib;dinput8.lib;shlwapi.lib;%(AdditionalDependencies) + false + + + + + MultiThreaded + Default + true + true + MaxSpeed + true + Level3 + Zlib;.;NES;NES\Mapper;NES\ApuEx;NES\ApuEx\emu2413;NES\PadEx;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + .\Release\ + .\Release\VirtuaNES.pch + .\Release\ + .\Release\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\VirtuaNES.tlb + true + Win32 + + + 0x0411 + res;%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + + + true + .\VirtuaNES.bsc + + + true + Windows + false + .\VirtuaNES.exe + odbc32.lib;odbccp32.lib;winmm.lib;comctl32.lib;imm32.lib;dinput8.lib;shlwapi.lib;%(AdditionalDependencies) + + + + + MultiThreaded + Default + true + true + MaxSpeed + true + Level3 + OldStyle + .;NES;NES\Mapper;NES\ApuEx;NES\ApuEx\emu2413;NES\PadEx;Zlib;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_DEBUGOUT;%(PreprocessorDefinitions) + .\Release_Debugout\ + .\Release_Debugout\VirtuaNES.pch + .\Release_Debugout\ + .\Release_Debugout\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\VirtuaNES.tlb + true + Win32 + + + 0x0411 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\VirtuaNES.bsc + + + true + true + Windows + false + .\VirtuaNES.exe + odbc32.lib;odbccp32.lib;winmm.lib;comctl32.lib;imm32.lib;dinput8.lib;shlwapi.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + + + true + true + true + + + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + + + true + true + true + + + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/virtuanessrc097-master/VirtuaNES.vcxproj.filters b/virtuanessrc097-master/VirtuaNES.vcxproj.filters new file mode 100644 index 0000000..8be6167 --- /dev/null +++ b/virtuanessrc097-master/VirtuaNES.vcxproj.filters @@ -0,0 +1,1565 @@ + + + + + {838e2a92-2af0-4988-bfc6-aeb761e74092} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {fa211b91-695f-494c-a6e4-ab261099e7fb} + h;hpp;hxx;hm;inl + + + {3bc77606-806d-4a5d-8f1b-e9942058e1f7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {8d8c1a1f-0fb2-4a32-a7b1-e8a0c8d8f7b6} + + + {039fef49-90d4-4d8f-8939-7549f680ee2e} + + + {98caa730-39c5-4a07-a91e-634a37b87045} + + + {ac6b7630-911f-4b5b-b42d-dcbbc3f761aa} + + + {1fecdf47-2af5-4bbf-acb6-a4d40709f6dc} + + + {bc932c3f-9d44-4b6d-82ab-cf162aadc0cd} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\ApuEx\emu2413 + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + Zlib + + + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\Mapper + + + NES\ApuEx\emu2413 + + + NES\ApuEx\emu2413 + + + NES\ApuEx\emu2413 + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\ApuEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES\PadEx + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + NES + + + Zlib + + + Zlib + + + Zlib + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + + + + Zlib + + + \ No newline at end of file diff --git a/virtuanessrc097-master/VirtuaNESres.h b/virtuanessrc097-master/VirtuaNESres.h new file mode 100644 index 0000000..f0873f2 Binary files /dev/null and b/virtuanessrc097-master/VirtuaNESres.h differ diff --git a/virtuanessrc097-master/WaveRec.cpp b/virtuanessrc097-master/WaveRec.cpp new file mode 100644 index 0000000..11241a6 Binary files /dev/null and b/virtuanessrc097-master/WaveRec.cpp differ diff --git a/virtuanessrc097-master/WaveRec.h b/virtuanessrc097-master/WaveRec.h new file mode 100644 index 0000000..ed7ff0f Binary files /dev/null and b/virtuanessrc097-master/WaveRec.h differ diff --git a/virtuanessrc097-master/WinMain.cpp b/virtuanessrc097-master/WinMain.cpp new file mode 100644 index 0000000..8c4042b Binary files /dev/null and b/virtuanessrc097-master/WinMain.cpp differ diff --git a/virtuanessrc097-master/Wnd.cpp b/virtuanessrc097-master/Wnd.cpp new file mode 100644 index 0000000..38836a4 Binary files /dev/null and b/virtuanessrc097-master/Wnd.cpp differ diff --git a/virtuanessrc097-master/Wnd.h b/virtuanessrc097-master/Wnd.h new file mode 100644 index 0000000..195b58a Binary files /dev/null and b/virtuanessrc097-master/Wnd.h differ diff --git a/virtuanessrc097-master/WndHook.cpp b/virtuanessrc097-master/WndHook.cpp new file mode 100644 index 0000000..24257b1 Binary files /dev/null and b/virtuanessrc097-master/WndHook.cpp differ diff --git a/virtuanessrc097-master/WndHook.h b/virtuanessrc097-master/WndHook.h new file mode 100644 index 0000000..abeb11a Binary files /dev/null and b/virtuanessrc097-master/WndHook.h differ diff --git a/virtuanessrc097-master/hq2x.h b/virtuanessrc097-master/hq2x.h new file mode 100644 index 0000000..7c628f5 Binary files /dev/null and b/virtuanessrc097-master/hq2x.h differ diff --git a/virtuanessrc097-master/interp.h b/virtuanessrc097-master/interp.h new file mode 100644 index 0000000..7893d7e Binary files /dev/null and b/virtuanessrc097-master/interp.h differ diff --git a/virtuanessrc097-master/lq2x.h b/virtuanessrc097-master/lq2x.h new file mode 100644 index 0000000..bf9a74c Binary files /dev/null and b/virtuanessrc097-master/lq2x.h differ diff --git a/virtuanessrc097-master/lzAscii.h b/virtuanessrc097-master/lzAscii.h new file mode 100644 index 0000000..12ed19d Binary files /dev/null and b/virtuanessrc097-master/lzAscii.h differ diff --git a/virtuanessrc097-master/lzSight.h b/virtuanessrc097-master/lzSight.h new file mode 100644 index 0000000..b5d04eb Binary files /dev/null and b/virtuanessrc097-master/lzSight.h differ diff --git a/virtuanessrc097-master/lzTVlayer.h b/virtuanessrc097-master/lzTVlayer.h new file mode 100644 index 0000000..c540afa Binary files /dev/null and b/virtuanessrc097-master/lzTVlayer.h differ diff --git a/virtuanessrc097-master/nx_2xSaI.h b/virtuanessrc097-master/nx_2xSaI.h new file mode 100644 index 0000000..818ad57 Binary files /dev/null and b/virtuanessrc097-master/nx_2xSaI.h differ diff --git a/virtuanessrc097-master/nx_Scale2x.h b/virtuanessrc097-master/nx_Scale2x.h new file mode 100644 index 0000000..cfbeb85 Binary files /dev/null and b/virtuanessrc097-master/nx_Scale2x.h differ diff --git a/virtuanessrc097-master/nx_Super2xSaI.h b/virtuanessrc097-master/nx_Super2xSaI.h new file mode 100644 index 0000000..cefb715 Binary files /dev/null and b/virtuanessrc097-master/nx_Super2xSaI.h differ diff --git a/virtuanessrc097-master/nx_SuperEagle.h b/virtuanessrc097-master/nx_SuperEagle.h new file mode 100644 index 0000000..17a9b3d Binary files /dev/null and b/virtuanessrc097-master/nx_SuperEagle.h differ diff --git a/virtuanessrc097-master/nx_hq2x.h b/virtuanessrc097-master/nx_hq2x.h new file mode 100644 index 0000000..79154c8 Binary files /dev/null and b/virtuanessrc097-master/nx_hq2x.h differ diff --git a/virtuanessrc097-master/res/CheatImageList.bmp b/virtuanessrc097-master/res/CheatImageList.bmp new file mode 100644 index 0000000..5def99e Binary files /dev/null and b/virtuanessrc097-master/res/CheatImageList.bmp differ diff --git a/virtuanessrc097-master/res/LauncherImageList.bmp b/virtuanessrc097-master/res/LauncherImageList.bmp new file mode 100644 index 0000000..d8102bd Binary files /dev/null and b/virtuanessrc097-master/res/LauncherImageList.bmp differ diff --git a/virtuanessrc097-master/res/VirtuaNES.exe.manifest b/virtuanessrc097-master/res/VirtuaNES.exe.manifest new file mode 100644 index 0000000..0803f35 --- /dev/null +++ b/virtuanessrc097-master/res/VirtuaNES.exe.manifest @@ -0,0 +1,24 @@ + + + + + VirtuaNES Application + + + + + + + diff --git a/virtuanessrc097-master/res/VirtuaNES.ico b/virtuanessrc097-master/res/VirtuaNES.ico new file mode 100644 index 0000000..6d8e88d Binary files /dev/null and b/virtuanessrc097-master/res/VirtuaNES.ico differ diff --git a/virtuanessrc097-master/res/header_down.ico b/virtuanessrc097-master/res/header_down.ico new file mode 100644 index 0000000..31a8c39 Binary files /dev/null and b/virtuanessrc097-master/res/header_down.ico differ diff --git a/virtuanessrc097-master/res/header_up.ico b/virtuanessrc097-master/res/header_up.ico new file mode 100644 index 0000000..ad96699 Binary files /dev/null and b/virtuanessrc097-master/res/header_up.ico differ diff --git a/virtuanessrc097-master/resource.h b/virtuanessrc097-master/resource.h new file mode 100644 index 0000000..e5c5106 Binary files /dev/null and b/virtuanessrc097-master/resource.h differ diff --git a/virtuanessrc097-master/zlib/unzip.c b/virtuanessrc097-master/zlib/unzip.c new file mode 100644 index 0000000..ff71a47 --- /dev/null +++ b/virtuanessrc097-master/zlib/unzip.c @@ -0,0 +1,1294 @@ +/* unzip.c -- IO on .zip files using zlib + Version 0.15 beta, Mar 19th, 1998, + + Read unzip.h for more info +*/ + + +#include +#include +#include +#include "zlib.h" +#include "unzip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + + + +#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ + !defined(CASESENSITIVITYDEFAULT_NO) +#define CASESENSITIVITYDEFAULT_NO +#endif + + +#ifndef UNZ_BUFSIZE +#define UNZ_BUFSIZE (16384) +#endif + +#ifndef UNZ_MAXFILENAMEINZIP +#define UNZ_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) + + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +const char unz_copyright[] = + " unzip 0.15 Copyright 1998 Gilles Vollant "; + +/* unz_file_info_interntal contain internal info about a file in zipfile*/ +typedef struct unz_file_info_internal_s +{ + uLong offset_curfile;/* relative offset of local header 4 bytes */ +} unz_file_info_internal; + + +/* file_in_zip_read_info_s contain internal information about a file in zipfile, + when reading and decompress it */ +typedef struct +{ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + FILE* file; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ +} file_in_zip_read_info_s; + + +/* unz_s contain internal information about the zipfile +*/ +typedef struct +{ + FILE* file; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ + file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + file if we are decompressing it */ +} unz_s; + + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ + + +local int unzlocal_getByte(fin,pi) + FILE *fin; + int *pi; +{ + unsigned char c; + int err = fread(&c, 1, 1, fin); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ferror(fin)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int unzlocal_getShort (fin,pX) + FILE* fin; + uLong *pX; +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int unzlocal_getLong (fin,pX) + FILE* fin; + uLong *pX; +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + + +/* My own strcmpi / strcasecmp */ +local int strcmpcasenosensitive_internal (fileName1,fileName2) + const char* fileName1; + const char* fileName2; +{ + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } +} + + +#ifdef CASESENSITIVITYDEFAULT_NO +#define CASESENSITIVITYDEFAULTVALUE 2 +#else +#define CASESENSITIVITYDEFAULTVALUE 1 +#endif + +#ifndef STRCMPCASENOSENTIVEFUNCTION +#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal +#endif + +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + +*/ +extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) + const char* fileName1; + const char* fileName2; + int iCaseSensitivity; +{ + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); + + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); +} + +#define BUFREADCOMMENT (0x400) + +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local uLong unzlocal_SearchCentralDir(fin) + FILE *fin; +{ + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (fseek(fin,0,SEEK_END) != 0) + return 0; + + + uSizeFile = ftell( fin ); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (fseek(fin,uReadPos,SEEK_SET)!=0) + break; + + if (fread(buf,(uInt)uReadSize,1,fin)!=1) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} + +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer + "zlib/zlib109.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ +extern unzFile ZEXPORT unzOpen (path) + const char *path; +{ + unz_s us; + unz_s *s; + uLong central_pos,uL; + FILE * fin ; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + + int err=UNZ_OK; + + if (unz_copyright[0]!=' ') + return NULL; + + fin=fopen(path,"rb"); + if (fin==NULL) + return NULL; + + central_pos = unzlocal_SearchCentralDir(fin); + if (central_pos==0) + err=UNZ_ERRNO; + + if (fseek(fin,central_pos,SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unzlocal_getLong(fin,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir */ + if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* zipfile comment length */ + if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((central_pospfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + fclose(s->file); + TRYFREE(s); + return UNZ_OK; +} + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ +extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) + unzFile file; + unz_global_info *pglobal_info; +{ + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; +} + + +/* + Translate date/time from Dos format to tm_unz (readable more easilty) +*/ +local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) + uLong ulDosDate; + tm_unz* ptm; +{ + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; +} + +/* + Get Info about the current file in the zipfile, with internal only info +*/ +local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + +local int unzlocal_GetCurrentFileInfoInternal (file, + pfile_info, + pfile_info_internal, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + unz_file_info_internal *pfile_info_internal; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; +{ + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; +} + + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. +*/ +extern int ZEXPORT unzGetCurrentFileInfo (file, + pfile_info, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; +{ + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); +} + +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ +extern int ZEXPORT unzGoToFirstFile (file) + unzFile file; +{ + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ +extern int ZEXPORT unzGoToNextFile (file) + unzFile file; +{ + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzipStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ +extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) + unzFile file; + const char *szFileName; + int iCaseSensitivity; +{ + unz_s* s; + int err; + + + uLong num_fileSaved; + uLong pos_in_central_dirSaved; + + + if (file==NULL) + return UNZ_PARAMERROR; + + if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + return err; +} + + +/* + Read the local header of the current zipfile + Check the coherency of the local header and info in the end of central + directory about this file + store in *piSizeVar the size of extra info in local header + (filename and size of extra field data) +*/ +local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, + poffset_local_extrafield, + psize_local_extrafield) + unz_s* s; + uInt* piSizeVar; + uLong *poffset_local_extrafield; + uInt *psize_local_extrafield; +{ + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (fseek(s->file,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; +/* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; +*/ + if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; +} + +/* + Open for reading data the current file in the zipfile. + If there is no error and the file is opened, the return value is UNZ_OK. +*/ +extern int ZEXPORT unzOpenCurrentFile (file) + unzFile file; +{ + int err=UNZ_OK; + int Store; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if ((s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + Store = s->cur_file_info.compression_method==0; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->file=s->file; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if (!Store) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + + s->pfile_in_zip_read = pfile_in_zip_read_info; + return UNZ_OK; +} + + +/* + Read bytes from the current file. + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ +extern int ZEXPORT unzReadCurrentFile (file, buf, len) + unzFile file; + voidp buf; + unsigned len; +{ + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, + pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if (pfile_in_zip_read_info->compression_method==0) + { + uInt uDoCopy,i ; + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; +} + + +/* + Give the current position in uncompressed data +*/ +extern z_off_t ZEXPORT unztell (file) + unzFile file; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; +} + + +/* + return 1 if the end of file was reached, 0 elsewhere +*/ +extern int ZEXPORT unzeof (file) + unzFile file; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; +} + + + +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field that can be read + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ +extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) + unzFile file; + voidp buf; + unsigned len; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + + return (int)read_now; +} + +/* + Close the file in zip opened with unzipOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ +extern int ZEXPORT unzCloseCurrentFile (file) + unzFile file; +{ + int err=UNZ_OK; + + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); + + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); + + s->pfile_in_zip_read=NULL; + + return err; +} + + +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ +extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) + unzFile file; + char *szComment; + uLong uSizeBuf; +{ + int err=UNZ_OK; + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; + + if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (uReadThis>0) + { + *szComment='\0'; + if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) + return UNZ_ERRNO; + } + + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; +} diff --git a/virtuanessrc097-master/zlib/unzip.h b/virtuanessrc097-master/zlib/unzip.h new file mode 100644 index 0000000..6c947a9 Binary files /dev/null and b/virtuanessrc097-master/zlib/unzip.h differ diff --git a/virtuanessrc097-master/zlib/zconf.h b/virtuanessrc097-master/zlib/zconf.h new file mode 100644 index 0000000..c37cb66 Binary files /dev/null and b/virtuanessrc097-master/zlib/zconf.h differ diff --git a/virtuanessrc097-master/zlib/zlib.h b/virtuanessrc097-master/zlib/zlib.h new file mode 100644 index 0000000..68a250e Binary files /dev/null and b/virtuanessrc097-master/zlib/zlib.h differ