diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs index e81a410..492bdf8 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/EEPROM.cs @@ -1,4 +1,6 @@ -namespace VirtualNes.Core +using System; + +namespace VirtualNes.Core { @@ -176,28 +178,31 @@ return sda; } - public void Load(byte[] p) + public unsafe void Load(byte* p) { //now_state = *((INT*)&p[0]); + now_state = *(int*)p; //next_state = *((INT*)&p[4]); + 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]; + 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) + public unsafe 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; + *((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; } } @@ -424,30 +429,31 @@ return sda; } - public void Load(byte[] p) + public unsafe void Load(byte* p) { //now_state = *((INT*)&p[0]); - //next_state = *((INT*)&p[4]); + 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]; + 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) + public unsafe 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; + *((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/Mapper006.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper006.cs index 8160881..9b37ae1 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper006.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper006.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper006 FFE F4xxx // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -92,15 +93,17 @@ namespace VirtualNes.Core //void Mapper006::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; + p[0] = irq_enable; //*(INT*)&p[1] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 1); } //void Mapper006::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; + irq_enable = p[0]; //irq_counter = *(INT*)&p[1]; + irq_counter = BitConverter.ToInt32(p, 1); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper012.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper012.cs index b6839ee..85cb89e 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper012.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper012.cs @@ -1,4 +1,5 @@ -using static VirtualNes.Core.CPU; +using System; +using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; using INT = System.Int32; @@ -275,51 +276,55 @@ namespace VirtualNes.Core //void Mapper012::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; - //p[20] = irq_preset; - //p[21] = irq_preset_vbl; + 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; + p[20] = irq_preset; + p[21] = irq_preset_vbl; //*((DWORD*)&p[22]) = vb0; + BitConverter.GetBytes(vb0).CopyTo(p,22); //*((DWORD*)&p[26]) = vb1; + BitConverter.GetBytes(vb1).CopyTo(p,26); } //void Mapper012::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]; - //irq_preset = p[20]; - //irq_preset_vbl = p[21]; + 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 = (byte)p[17]; + irq_latch = p[18]; + irq_request = p[19]; + irq_preset = p[20]; + irq_preset_vbl = p[21]; //vb0 = *((DWORD*)&p[22]); + vb0 = BitConverter.ToUInt32(p, 22); //vb1 = *((DWORD*)&p[26]); + vb1 = BitConverter.ToUInt32(p, 26); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs index ecc5fe3..6f05ca4 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper016.cs @@ -368,55 +368,64 @@ namespace VirtualNes.Core } } - public override void SaveState(byte[] p) + public unsafe override void SaveState(byte[] buffer) { - //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; + fixed (byte* p = buffer) + { + 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]); - //} + 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) + public unsafe override void LoadState(byte[] buffer) { - //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]); - //} + fixed (byte* p = buffer) + { + 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]); + x24c02.Load(p + 16); + } + else + if (eeprom_type == 2) + { + //x24c02.Load(&p[16]); + //x24c01.Load(&p[48]); + x24c02.Load(p+16); + x24c01.Load(p+48); + } + } } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs index 2d7c6d6..81fce5e 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper017.cs @@ -1,4 +1,5 @@ -using static VirtualNes.Core.CPU; +using System; +using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; using INT = System.Int32; @@ -104,17 +105,21 @@ namespace VirtualNes.Core //void Mapper017::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; + p[0] = irq_enable; //*(INT*)&p[1] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 1); //*(INT*)&p[5] = irq_latch; + BitConverter.GetBytes(irq_latch).CopyTo(p, 5); } //void Mapper017::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; + irq_enable = p[0]; //irq_counter = *(INT*)&p[1]; + irq_counter = BitConverter.ToInt32(p, 1); //irq_latch = *(INT*)&p[5]; + irq_latch = BitConverter.ToInt32(p, 5); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs index e3da95f..0c43bb6 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper018.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper018 Jaleco SS8806 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -245,27 +246,31 @@ namespace VirtualNes.Core //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; + for (INT i = 0; i < 11; i++) + { + p[i] = reg[i]; + } + p[11] = irq_enable; + p[12] = irq_mode; //*(INT*)&p[13] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 13); //*(INT*)&p[17] = irq_latch; + BitConverter.GetBytes(irq_latch).CopyTo(p, 17); } //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]; + 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_counter = BitConverter.ToInt32(p, 13); //irq_latch = *(INT*)&p[17]; + irq_latch = BitConverter.ToInt32(p, 17); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs index 7aff868..9406ff8 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper019.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper019 Namcot 106 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -386,25 +387,29 @@ namespace VirtualNes.Core //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; + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = reg[2]; + p[3] = irq_enable; + //*(WORD*)&p[4] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 4); //::memcpy(&p[8], exram, sizeof(exram)); + Array.Copy(exram, p, exram.Length); + } //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]; - + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; + irq_enable = p[3]; + //irq_counter = *(WORD*)&p[4]; + irq_counter = BitConverter.ToUInt16(p, 4); //::memcpy(exram, &p[8], sizeof(exram)); + Array.Copy(p,exram,exram.Length); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs index 1920b2d..97a690f 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper021.cs @@ -1,6 +1,7 @@ ////////////////// // Mapper021 Konami VRC4 (Address mask $F006 or $F0C0) // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -223,27 +224,29 @@ namespace VirtualNes.Core //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; + 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; + BitConverter.GetBytes(irq_clock).CopyTo(p, 12); } //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]; + 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/Mapper023.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs index 570835a..26d768b 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper023.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper023 Konami VRC2 type B // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -239,27 +240,29 @@ namespace VirtualNes.Core //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; + 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; + BitConverter.GetBytes(irq_clock).CopyTo(p, 12); } //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]; + 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/Mapper024.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs index f5c0e04..dc78cb4 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper024.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper024 Konami VRC6 (Normal) // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -149,19 +150,21 @@ namespace VirtualNes.Core //void Mapper024::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; - //p[1] = irq_counter; - //p[2] = irq_latch; + p[0] = irq_enable; + p[1] = irq_counter; + p[2] = irq_latch; //*(INT*)&p[3] = irq_clock; + BitConverter.GetBytes(irq_clock).CopyTo(p, 3); } //void Mapper024::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; - //irq_counter = p[1]; - //irq_latch = p[2]; + irq_enable = p[0]; + irq_counter = p[1]; + irq_latch = p[2]; //irq_clock = *(INT*)&p[3]; + irq_clock = BitConverter.ToInt32(p, 3); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs index 24ef68f..65f82b2 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper025.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper025 Konami VRC4 (Normal) // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -248,29 +249,31 @@ namespace VirtualNes.Core //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; + 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; + BitConverter.GetBytes(irq_clock).CopyTo(p, 15); } //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]; + 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]); + irq_clock = BitConverter.ToInt32(p, 15); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs index 08acf5e..6761ed7 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper026.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper026 Konami VRC6 (PA0,PA1 reverse) // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -160,19 +161,21 @@ namespace VirtualNes.Core //void Mapper026::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; - //p[1] = irq_counter; - //p[2] = irq_latch; + p[0] = irq_enable; + p[1] = irq_counter; + p[2] = irq_latch; //*(INT*)&p[3] = irq_clock; + BitConverter.GetBytes(irq_clock).CopyTo(p, 3); } //void Mapper026::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; - //irq_counter = p[1]; - //irq_latch = p[2]; + irq_enable = p[0]; + irq_counter = p[1]; + irq_latch = p[2]; //irq_clock = *(INT*)&p[3]; + irq_clock = BitConverter.ToInt32(p, 3); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs index 2ef048d..a345fae 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper027.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper027 Konami VRC4 (World Hero) // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -200,27 +201,29 @@ namespace VirtualNes.Core //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; + for (INT i = 0; i < 9; i++) + { + p[i] = (byte)reg[i]; + } + p[9] = irq_enable; + p[10] = irq_counter; + p[11] = irq_latch; //*(INT*)&p[12] = irq_clock; + BitConverter.GetBytes(irq_clock).CopyTo(p, 12); } //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]; + 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/Mapper040.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs index ac0823d..01e7b2d 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper040.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper040 SMB2J // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -70,15 +71,17 @@ namespace VirtualNes.Core //void Mapper040::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; + p[0] = irq_enable; //*(INT*)&p[1] = irq_line; + BitConverter.GetBytes(irq_line).CopyTo(p, 1); } //void Mapper040::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; + irq_enable = p[0]; //irq_line = *(INT*)&p[1]; + irq_line = BitConverter.ToInt32(p,1); } public override bool IsStateSave() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs index 6975ce6..ae35ac0 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper043.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper043 SMB2J // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -118,15 +119,17 @@ namespace VirtualNes.Core //void Mapper043::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; + p[0] = irq_enable; //*(INT*)&p[1] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 1); } //void Mapper043::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; + irq_enable = p[0]; //irq_counter = *(INT*)&p[1]; + irq_counter = BitConverter.ToInt32(p, 1); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs index 16ea4d1..c50ab6d 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper045.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper045 1000000-in-1 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -311,69 +312,71 @@ namespace VirtualNes.Core } //void Mapper045::SaveState(LPBYTE ps) - public override void SaveState(byte[] p) + public override void SaveState(byte[] ps) { - //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; + 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]; + BitConverter.GetBytes(c[i]).CopyTo(ps, i * 4 + 64); + } + 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) + public override void LoadState(byte[] ps) { - //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]; + 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]; + c[i] = BitConverter.ToInt32(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]; } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs index c8625b7..c403718 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper064.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper064 Tengen Rambo-1 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -249,29 +250,33 @@ namespace VirtualNes.Core //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; + 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; + BitConverter.GetBytes(irq_counter).CopyTo(p, 8); + //* ((INT*)&p[12]) = irq_counter2; + BitConverter.GetBytes(irq_counter2).CopyTo(p, 12); } //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]; + 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_counter = BitConverter.ToInt32(p, 8); //irq_counter2 = *((INT*)&p[12]); + irq_counter2 = BitConverter.ToInt32(p, 12); } public override bool IsStateSave() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs index dac093e..7c93a04 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper065.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper065 Irem H3001 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -166,17 +167,21 @@ namespace VirtualNes.Core //void Mapper065::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; + p[0] = irq_enable; //*(INT*)&p[1] = irq_counter; - //*(INT*)&p[5] = irq_latch; + BitConverter.GetBytes(irq_counter).CopyTo(p, 1); + //* (INT*)&p[5] = irq_latch; + BitConverter.GetBytes(irq_latch).CopyTo(p, 5); } //void Mapper065::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; + irq_enable = p[0]; //irq_counter = *(INT*)&p[1]; + irq_counter = BitConverter.ToInt32(p, 1); //irq_latch = *(INT*)&p[5]; + irq_latch = BitConverter.ToInt32(p, 5); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs index f43d9c9..137393f 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper067.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper067 SunSoft Mapper 3 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -114,19 +115,21 @@ namespace VirtualNes.Core //void Mapper067::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; - //p[1] = irq_occur; - //p[2] = irq_toggle; + p[0] = irq_enable; + p[1] = irq_occur; + p[2] = irq_toggle; //*((INT*)&p[3]) = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 3); } //void Mapper067::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; - //irq_occur = p[1]; - //irq_toggle = p[2]; + irq_enable = p[0]; + irq_occur = p[1]; + irq_toggle = p[2]; //irq_counter = *((INT*)&p[3]); + irq_counter = BitConverter.ToInt32(p, 3); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs index 6aa3178..5677c35 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper069 SunSoft FME-7 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -156,17 +157,19 @@ namespace VirtualNes.Core //void Mapper069::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = reg; - //p[1] = irq_enable; + p[0] = reg; + p[1] = irq_enable; //*(INT*)&p[2] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 2); } //void Mapper069::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //reg = p[0]; - //irq_enable = p[1]; + reg = p[0]; + irq_enable = p[1]; //irq_counter = *(INT*)&p[2]; + irq_counter = BitConverter.ToInt32(p, 2); } public override bool IsStateSave() { diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs index 7477d5c..e43cb2b 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper073 Konami VRC3 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -73,15 +74,17 @@ namespace VirtualNes.Core //void Mapper073::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; + p[0] = irq_enable; //*(INT*)&p[1] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 1); } //void Mapper073::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; + irq_enable = p[0]; //irq_counter = *(INT*)&p[1]; + irq_counter = BitConverter.ToInt32(p, 1); } public override bool IsStateSave() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs index 63f59e4..2166610 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs @@ -1,6 +1,7 @@ ///////////////////////////// // Mapper083 Cony // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -215,23 +216,27 @@ namespace VirtualNes.Core //void Mapper083::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = reg[0]; - //p[1] = reg[1]; - //p[2] = reg[2]; + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = reg[2]; //*(INT*)&p[3] = chr_bank; - //p[7] = irq_enable; + BitConverter.GetBytes(chr_bank).CopyTo(p,3); + p[7] = irq_enable; //*(INT*)&p[8] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p,8); } //void Mapper083::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //reg[0] = p[0]; - //reg[1] = p[1]; - //reg[2] = p[2]; + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; //chr_bank = *(INT*)&p[3]; - //irq_enable = p[7]; + chr_bank = BitConverter.ToInt32(p, 3); + irq_enable = p[7]; //irq_counter = *(INT*)&p[8]; + irq_counter = BitConverter.ToInt32(p, 8); } public override bool IsStateSave() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs index b3e6c41..9b4838d 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper085 Konami VRC7 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -213,19 +214,21 @@ namespace VirtualNes.Core //void Mapper085::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = irq_enable; - //p[1] = irq_counter; - //p[2] = irq_latch; + p[0] = irq_enable; + p[1] = irq_counter; + p[2] = irq_latch; //*((INT*)&p[4]) = irq_clock; + BitConverter.GetBytes(irq_clock).CopyTo(p, 4); } //void Mapper085::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //irq_enable = p[0]; - //irq_counter = p[1]; - //irq_latch = p[2]; + irq_enable = p[0]; + irq_counter = p[1]; + irq_latch = p[2]; //irq_clock = *((INT*)&p[4]); + irq_clock = BitConverter.ToInt32(p, 4); } public override bool IsStateSave() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs index 57cd384..4522a0c 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper105.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper105 Nintendo World Championship // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -166,29 +167,31 @@ namespace VirtualNes.Core //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; + 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; + BitConverter.GetBytes(irq_counter).CopyTo(p, 12); } //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]; + 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]); + irq_counter = BitConverter.ToInt32(p, 12); } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs index 7b37941..112b82c 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper142.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper142 SMB2J // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -90,17 +91,19 @@ namespace VirtualNes.Core //void Mapper142::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //p[0] = prg_sel; - //p[0] = irq_enable; + p[0] = prg_sel; + p[0] = irq_enable; //*(INT*)&p[2] = irq_counter; + BitConverter.GetBytes(irq_counter).CopyTo(p, 2); } //void Mapper142::LoadState(LPBYTE p) public override void LoadState(byte[] p) { - //prg_sel = p[0]; - //irq_enable = p[1]; + prg_sel = p[0]; + irq_enable = p[1]; //irq_counter = *(INT*)&p[2]; + irq_counter = BitConverter.ToInt32 (p, 2); } public override bool IsStateSave() { diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs index e34b2da..1406401 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper183 Gimmick (Bootleg) // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -168,23 +169,25 @@ namespace VirtualNes.Core //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; + for (INT i = 0; i < 8; i++) + { + p[i] = reg[i]; + } + p[8] = irq_enable; + BitConverter.GetBytes(irq_counter).CopyTo(p, 9); //*((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]); + for (INT i = 0; i < 8; i++) + { + reg[i] = p[i]; + } + irq_enable = p[8]; + irq_counter = BitConverter.ToInt32(p, 9); + //irq_counter = *((INT*)&p[9]); } public override bool IsStateSave() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs index 1135a02..84a9007 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs @@ -1,6 +1,7 @@ ////////////////////////////////////////////////////////////////////////// // Mapper187 Street Fighter Zero 2 97 // ////////////////////////////////////////////////////////////////////////// +using System; using static VirtualNes.Core.CPU; using static VirtualNes.MMU; using BYTE = System.Byte; @@ -310,56 +311,58 @@ namespace VirtualNes.Core //void Mapper187::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //INT i; + 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]; - //} + 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]; + BitConverter.GetBytes(chr[i]).CopyTo(p, 12 + i * sizeof(int)); + } - //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; + 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; + 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]; + 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] = BitConverter.ToInt32(p, 12 + i * sizeof(int)); + //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() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs index 888abc5..8c5acfa 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper199.cs @@ -259,53 +259,55 @@ namespace VirtualNes.Core //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; + int i; + for (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]; + int i; + for (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() diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs index 52fa8e4..a21cf62 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper243.cs @@ -92,19 +92,19 @@ namespace VirtualNes.Core //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]; + 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]; + reg[0] = p[0]; + reg[1] = p[1]; + reg[2] = p[2]; + reg[3] = p[3]; } } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs index 4f5d068..8705ad5 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper245.cs @@ -214,43 +214,43 @@ namespace VirtualNes.Core //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; + 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]; + 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 b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs index 516e69d..41c12fb 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper248.cs @@ -190,43 +190,43 @@ namespace VirtualNes.Core //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; + 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]; + 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 = (BYTE)p[17]; + irq_latch = p[18]; + irq_request = p[19]; } } } diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs index b5594bc..c0e92a4 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper249.cs @@ -338,45 +338,45 @@ namespace VirtualNes.Core //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; + 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]; + 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/Mapper251.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs index c7c689b..2dd93cd 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper251.cs @@ -112,30 +112,30 @@ namespace VirtualNes.Core //void Mapper251::SaveState(LPBYTE p) public override void SaveState(byte[] p) { - //INT i; + INT i; - //for (i = 0; i < 11; i++) - //{ - // p[i] = reg[i]; - //} - //for (i = 0; i < 4; i++) - //{ - // p[i + 11] = breg[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]; - //} + INT i; + for (i = 0; i < 11; i++) + { + reg[i] = p[i]; + } + for (i = 0; i < 4; i++) + { + reg[i] = p[i + 11]; + } } } }