补充Mapper 即时存档代码 | EEROM代码补充实现

This commit is contained in:
sin365 2024-08-28 17:38:01 +08:00
parent 94d03a3b04
commit 6a5393d9bc
33 changed files with 664 additions and 558 deletions

View File

@ -1,4 +1,6 @@
namespace VirtualNes.Core using System;
namespace VirtualNes.Core
{ {
@ -176,28 +178,31 @@
return sda; return sda;
} }
public void Load(byte[] p) public unsafe void Load(byte* p)
{ {
//now_state = *((INT*)&p[0]); //now_state = *((INT*)&p[0]);
now_state = *(int*)p;
//next_state = *((INT*)&p[4]); //next_state = *((INT*)&p[4]);
next_state = *(int*)p[4];
//bitcnt = *((INT*)&p[8]); //bitcnt = *((INT*)&p[8]);
//addr = p[12]; bitcnt = *(int*)p[8];
//data = p[13]; addr = p[12];
//sda = p[14]; data = p[13];
//scl_old = p[15]; sda = p[14];
//sda_old = p[16]; 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[0]) = now_state;
//*((INT*)&p[4]) = next_state; *((int*)&p[4]) = next_state;
//*((INT*)&p[8]) = bitcnt; *((int*)&p[8]) = bitcnt;
//p[12] = addr; p[12] = addr;
//p[13] = data; p[13] = data;
//p[14] = sda; p[14] = sda;
//p[15] = scl_old; p[15] = scl_old;
//p[16] = sda_old; p[16] = sda_old;
} }
} }
@ -424,30 +429,31 @@
return sda; return sda;
} }
public void Load(byte[] p) public unsafe void Load(byte* p)
{ {
//now_state = *((INT*)&p[0]); //now_state = *((INT*)&p[0]);
//next_state = *((INT*)&p[4]); next_state = *((int*)&p[4]);
//bitcnt = *((INT*)&p[8]); //bitcnt = *((INT*)&p[8]);
//addr = p[12]; bitcnt = *((int*)&p[8]);
//data = p[13]; addr = p[12];
//rw = p[14]; data = p[13];
//sda = p[15]; rw = p[14];
//scl_old = p[16]; sda = p[15];
//sda_old = p[17]; 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[0]) = now_state;
//*((INT*)&p[4]) = next_state; *((int*)&p[4]) = next_state;
//*((INT*)&p[8]) = bitcnt; *((int*)&p[8]) = bitcnt;
//p[12] = addr; p[12] = addr;
//p[13] = data; p[13] = data;
//p[14] = rw; p[14] = rw;
//p[15] = sda; p[15] = sda;
//p[16] = scl_old; p[16] = scl_old;
//p[17] = sda_old; p[17] = sda_old;
} }
} }
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper006 FFE F4xxx // // Mapper006 FFE F4xxx //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -92,15 +93,17 @@ namespace VirtualNes.Core
//void Mapper006::SaveState(LPBYTE p) //void Mapper006::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[1] = irq_counter; //*(INT*)&p[1] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 1);
} }
//void Mapper006::LoadState(LPBYTE p) //void Mapper006::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = *(INT*)&p[1]; //irq_counter = *(INT*)&p[1];
irq_counter = BitConverter.ToInt32(p, 1);
} }

View File

@ -1,4 +1,5 @@
using static VirtualNes.Core.CPU; using System;
using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
using INT = System.Int32; using INT = System.Int32;
@ -275,51 +276,55 @@ namespace VirtualNes.Core
//void Mapper012::SaveState(LPBYTE p) //void Mapper012::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[8] = prg0; p[8] = prg0;
//p[9] = prg1; p[9] = prg1;
//p[10] = chr01; p[10] = chr01;
//p[11] = chr23; p[11] = chr23;
//p[12] = chr4; p[12] = chr4;
//p[13] = chr5; p[13] = chr5;
//p[14] = chr6; p[14] = chr6;
//p[15] = chr7; p[15] = chr7;
//p[16] = irq_enable; p[16] = irq_enable;
//p[17] = (BYTE)irq_counter; p[17] = (BYTE)irq_counter;
//p[18] = irq_latch; p[18] = irq_latch;
//p[19] = irq_request; p[19] = irq_request;
//p[20] = irq_preset; p[20] = irq_preset;
//p[21] = irq_preset_vbl; p[21] = irq_preset_vbl;
//*((DWORD*)&p[22]) = vb0; //*((DWORD*)&p[22]) = vb0;
BitConverter.GetBytes(vb0).CopyTo(p,22);
//*((DWORD*)&p[26]) = vb1; //*((DWORD*)&p[26]) = vb1;
BitConverter.GetBytes(vb1).CopyTo(p,26);
} }
//void Mapper012::LoadState(LPBYTE p) //void Mapper012::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//prg0 = p[8]; prg0 = p[8];
//prg1 = p[9]; prg1 = p[9];
//chr01 = p[10]; chr01 = p[10];
//chr23 = p[11]; chr23 = p[11];
//chr4 = p[12]; chr4 = p[12];
//chr5 = p[13]; chr5 = p[13];
//chr6 = p[14]; chr6 = p[14];
//chr7 = p[15]; chr7 = p[15];
//irq_enable = p[16]; irq_enable = p[16];
//irq_counter = (INT)p[17]; irq_counter = (byte)p[17];
//irq_latch = p[18]; irq_latch = p[18];
//irq_request = p[19]; irq_request = p[19];
//irq_preset = p[20]; irq_preset = p[20];
//irq_preset_vbl = p[21]; irq_preset_vbl = p[21];
//vb0 = *((DWORD*)&p[22]); //vb0 = *((DWORD*)&p[22]);
vb0 = BitConverter.ToUInt32(p, 22);
//vb1 = *((DWORD*)&p[26]); //vb1 = *((DWORD*)&p[26]);
vb1 = BitConverter.ToUInt32(p, 26);
} }

View File

@ -368,55 +368,64 @@ namespace VirtualNes.Core
} }
} }
public override void SaveState(byte[] p) public unsafe override void SaveState(byte[] buffer)
{ {
//p[0] = reg[0]; fixed (byte* p = buffer)
//p[1] = reg[1]; {
//p[2] = reg[2]; p[0] = reg[0];
//p[3] = irq_enable; p[1] = reg[1];
//*(INT*)&p[4] = irq_counter; p[2] = reg[2];
//*(INT*)&p[8] = irq_latch; p[3] = irq_enable;
*(INT*)&p[4] = irq_counter;
*(INT*)&p[8] = irq_latch;
//if (eeprom_type == 0) if (eeprom_type == 0)
//{ {
// x24c01.Save(&p[16]); x24c01.Save(&p[16]);
//} }
//else else
//if (eeprom_type == 1) if (eeprom_type == 1)
//{ {
// x24c02.Save(&p[16]); x24c02.Save(&p[16]);
//} }
//else else
//if (eeprom_type == 2) if (eeprom_type == 2)
//{ {
// x24c02.Save(&p[16]); x24c02.Save(&p[16]);
// x24c01.Save(&p[48]); x24c01.Save(&p[48]);
//} }
}
} }
public override void LoadState(byte[] p) public unsafe override void LoadState(byte[] buffer)
{
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)
{ {
//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]);
//} x24c02.Load(p + 16);
//else }
//if (eeprom_type == 2) else
//{ if (eeprom_type == 2)
{
//x24c02.Load(&p[16]); //x24c02.Load(&p[16]);
//x24c01.Load(&p[48]); //x24c01.Load(&p[48]);
//} x24c02.Load(p+16);
x24c01.Load(p+48);
}
}
} }

View File

@ -1,4 +1,5 @@
using static VirtualNes.Core.CPU; using System;
using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
using INT = System.Int32; using INT = System.Int32;
@ -104,17 +105,21 @@ namespace VirtualNes.Core
//void Mapper017::SaveState(LPBYTE p) //void Mapper017::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[1] = irq_counter; //*(INT*)&p[1] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 1);
//*(INT*)&p[5] = irq_latch; //*(INT*)&p[5] = irq_latch;
BitConverter.GetBytes(irq_latch).CopyTo(p, 5);
} }
//void Mapper017::LoadState(LPBYTE p) //void Mapper017::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = *(INT*)&p[1]; //irq_counter = *(INT*)&p[1];
irq_counter = BitConverter.ToInt32(p, 1);
//irq_latch = *(INT*)&p[5]; //irq_latch = *(INT*)&p[5];
irq_latch = BitConverter.ToInt32(p, 5);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper018 Jaleco SS8806 // // Mapper018 Jaleco SS8806 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -245,27 +246,31 @@ namespace VirtualNes.Core
//void Mapper018::SaveState(LPBYTE p) //void Mapper018::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 11; i++) for (INT i = 0; i < 11; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[11] = irq_enable; p[11] = irq_enable;
//p[12] = irq_mode; p[12] = irq_mode;
//*(INT*)&p[13] = irq_counter; //*(INT*)&p[13] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 13);
//*(INT*)&p[17] = irq_latch; //*(INT*)&p[17] = irq_latch;
BitConverter.GetBytes(irq_latch).CopyTo(p, 17);
} }
//void Mapper018::LoadState(LPBYTE p) //void Mapper018::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 11; i++) for (INT i = 0; i < 11; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//irq_enable = p[11]; irq_enable = p[11];
//irq_mode = p[12]; irq_mode = p[12];
//irq_counter = *(INT*)&p[13]; //irq_counter = *(INT*)&p[13];
irq_counter = BitConverter.ToInt32(p, 13);
//irq_latch = *(INT*)&p[17]; //irq_latch = *(INT*)&p[17];
irq_latch = BitConverter.ToInt32(p, 17);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper019 Namcot 106 // // Mapper019 Namcot 106 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -386,25 +387,29 @@ namespace VirtualNes.Core
//void Mapper019::SaveState(LPBYTE p) //void Mapper019::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
// p[0] = reg[0]; p[0] = reg[0];
// p[1] = reg[1]; p[1] = reg[1];
// p[2] = reg[2]; p[2] = reg[2];
// p[3] = irq_enable; p[3] = irq_enable;
//*(WORD*)&p[4] = irq_counter; //*(WORD*)&p[4] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 4);
//::memcpy(&p[8], exram, sizeof(exram)); //::memcpy(&p[8], exram, sizeof(exram));
Array.Copy(exram, p, exram.Length);
} }
//void Mapper019::LoadState(LPBYTE p) //void Mapper019::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
// reg[0] = p[0]; reg[0] = p[0];
// reg[1] = p[1]; reg[1] = p[1];
// reg[2] = p[2]; reg[2] = p[2];
// irq_enable = p[3]; irq_enable = p[3];
//irq_counter = *(WORD*)&p[4]; //irq_counter = *(WORD*)&p[4];
irq_counter = BitConverter.ToUInt16(p, 4);
//::memcpy(exram, &p[8], sizeof(exram)); //::memcpy(exram, &p[8], sizeof(exram));
Array.Copy(p,exram,exram.Length);
} }

View File

@ -1,6 +1,7 @@
////////////////// //////////////////
// Mapper021 Konami VRC4 (Address mask $F006 or $F0C0) // // Mapper021 Konami VRC4 (Address mask $F006 or $F0C0) //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -223,27 +224,29 @@ namespace VirtualNes.Core
//void Mapper021::SaveState(LPBYTE p) //void Mapper021::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 9; i++) for (INT i = 0; i < 9; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[9] = irq_enable; p[9] = irq_enable;
//p[10] = irq_counter; p[10] = irq_counter;
//p[11] = irq_latch; p[11] = irq_latch;
//*(INT*)&p[12] = irq_clock; //*(INT*)&p[12] = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 12);
} }
//void Mapper021::LoadState(LPBYTE p) //void Mapper021::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 9; i++) for (INT i = 0; i < 9; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//irq_enable = p[9]; irq_enable = p[9];
//irq_counter = p[10]; irq_counter = p[10];
//irq_latch = p[11]; irq_latch = p[11];
//irq_clock = *(INT*)&p[12]; //irq_clock = *(INT*)&p[12];
irq_clock = BitConverter.ToInt32(p, 12);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper023 Konami VRC2 type B // // Mapper023 Konami VRC2 type B //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -239,27 +240,29 @@ namespace VirtualNes.Core
//void Mapper023::SaveState(LPBYTE p) //void Mapper023::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 9; i++) for (INT i = 0; i < 9; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[9] = irq_enable; p[9] = irq_enable;
//p[10] = irq_counter; p[10] = irq_counter;
//p[11] = irq_latch; p[11] = irq_latch;
//*(INT*)&p[12] = irq_clock; //*(INT*)&p[12] = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 12);
} }
//void Mapper023::LoadState(LPBYTE p) //void Mapper023::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 9; i++) for (INT i = 0; i < 9; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//irq_enable = p[9]; irq_enable = p[9];
//irq_counter = p[10]; irq_counter = p[10];
//irq_latch = p[11]; irq_latch = p[11];
//irq_clock = *(INT*)&p[12]; //irq_clock = *(INT*)&p[12];
irq_clock = BitConverter.ToInt32(p, 12);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper024 Konami VRC6 (Normal) // // Mapper024 Konami VRC6 (Normal) //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -149,19 +150,21 @@ namespace VirtualNes.Core
//void Mapper024::SaveState(LPBYTE p) //void Mapper024::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//p[1] = irq_counter; p[1] = irq_counter;
//p[2] = irq_latch; p[2] = irq_latch;
//*(INT*)&p[3] = irq_clock; //*(INT*)&p[3] = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 3);
} }
//void Mapper024::LoadState(LPBYTE p) //void Mapper024::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = p[1]; irq_counter = p[1];
//irq_latch = p[2]; irq_latch = p[2];
//irq_clock = *(INT*)&p[3]; //irq_clock = *(INT*)&p[3];
irq_clock = BitConverter.ToInt32(p, 3);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper025 Konami VRC4 (Normal) // // Mapper025 Konami VRC4 (Normal) //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -248,29 +249,31 @@ namespace VirtualNes.Core
//void Mapper025::SaveState(LPBYTE p) //void Mapper025::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 11; i++) for (INT i = 0; i < 11; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[11] = irq_enable; p[11] = irq_enable;
//p[12] = irq_occur; p[12] = irq_occur;
//p[13] = irq_latch; p[13] = irq_latch;
//p[14] = irq_counter; p[14] = irq_counter;
//*((INT*)&p[15]) = irq_clock; //*((INT*)&p[15]) = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 15);
} }
//void Mapper025::LoadState(LPBYTE p) //void Mapper025::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 11; i++) for (INT i = 0; i < 11; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//irq_enable = p[11]; irq_enable = p[11];
//irq_occur = p[12]; irq_occur = p[12];
//irq_latch = p[13]; irq_latch = p[13];
//irq_counter = p[14]; irq_counter = p[14];
//irq_clock = *((INT*)&p[15]); //irq_clock = *((INT*)&p[15]);
irq_clock = BitConverter.ToInt32(p, 15);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper026 Konami VRC6 (PA0,PA1 reverse) // // Mapper026 Konami VRC6 (PA0,PA1 reverse) //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -160,19 +161,21 @@ namespace VirtualNes.Core
//void Mapper026::SaveState(LPBYTE p) //void Mapper026::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//p[1] = irq_counter; p[1] = irq_counter;
//p[2] = irq_latch; p[2] = irq_latch;
//*(INT*)&p[3] = irq_clock; //*(INT*)&p[3] = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 3);
} }
//void Mapper026::LoadState(LPBYTE p) //void Mapper026::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = p[1]; irq_counter = p[1];
//irq_latch = p[2]; irq_latch = p[2];
//irq_clock = *(INT*)&p[3]; //irq_clock = *(INT*)&p[3];
irq_clock = BitConverter.ToInt32(p, 3);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper027 Konami VRC4 (World Hero) // // Mapper027 Konami VRC4 (World Hero) //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -200,27 +201,29 @@ namespace VirtualNes.Core
//void Mapper027::SaveState(LPBYTE p) //void Mapper027::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 9; i++) for (INT i = 0; i < 9; i++)
//{ {
// p[i] = reg[i]; p[i] = (byte)reg[i];
//} }
//p[9] = irq_enable; p[9] = irq_enable;
//p[10] = irq_counter; p[10] = irq_counter;
//p[11] = irq_latch; p[11] = irq_latch;
//*(INT*)&p[12] = irq_clock; //*(INT*)&p[12] = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 12);
} }
//void Mapper027::LoadState(LPBYTE p) //void Mapper027::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 9; i++) for (INT i = 0; i < 9; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//irq_enable = p[9]; irq_enable = p[9];
//irq_counter = p[10]; irq_counter = p[10];
//irq_latch = p[11]; irq_latch = p[11];
//irq_clock = *(INT*)&p[12]; //irq_clock = *(INT*)&p[12];
irq_clock = BitConverter.ToInt32(p, 12);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper040 SMB2J // // Mapper040 SMB2J //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -70,15 +71,17 @@ namespace VirtualNes.Core
//void Mapper040::SaveState(LPBYTE p) //void Mapper040::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[1] = irq_line; //*(INT*)&p[1] = irq_line;
BitConverter.GetBytes(irq_line).CopyTo(p, 1);
} }
//void Mapper040::LoadState(LPBYTE p) //void Mapper040::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_line = *(INT*)&p[1]; //irq_line = *(INT*)&p[1];
irq_line = BitConverter.ToInt32(p,1);
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper043 SMB2J // // Mapper043 SMB2J //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -118,15 +119,17 @@ namespace VirtualNes.Core
//void Mapper043::SaveState(LPBYTE p) //void Mapper043::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[1] = irq_counter; //*(INT*)&p[1] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 1);
} }
//void Mapper043::LoadState(LPBYTE p) //void Mapper043::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = *(INT*)&p[1]; //irq_counter = *(INT*)&p[1];
irq_counter = BitConverter.ToInt32(p, 1);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper045 1000000-in-1 // // Mapper045 1000000-in-1 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -311,69 +312,71 @@ namespace VirtualNes.Core
} }
//void Mapper045::SaveState(LPBYTE ps) //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 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]; //*(INT*)&ps[i * 4 + 64] = c[i];
//} BitConverter.GetBytes(c[i]).CopyTo(ps, i * 4 + 64);
//ps[20] = prg0; }
//ps[21] = prg1; ps[20] = prg0;
//ps[22] = prg2; ps[21] = prg1;
//ps[23] = prg3; ps[22] = prg2;
//ps[24] = chr0; ps[23] = prg3;
//ps[25] = chr1; ps[24] = chr0;
//ps[26] = chr2; ps[25] = chr1;
//ps[27] = chr3; ps[26] = chr2;
//ps[28] = chr4; ps[27] = chr3;
//ps[29] = chr5; ps[28] = chr4;
//ps[30] = chr6; ps[29] = chr5;
//ps[31] = chr7; ps[30] = chr6;
//ps[32] = irq_enable; ps[31] = chr7;
//ps[33] = irq_counter; ps[32] = irq_enable;
//ps[34] = irq_latch; ps[33] = irq_counter;
ps[34] = irq_latch;
} }
//void Mapper045::LoadState(LPBYTE ps) //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++)
{ {
//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] = *(INT*)&ps[i * 4 + 64];
//} c[i] = BitConverter.ToInt32(ps, i * 4 + 64);
//prg0 = ps[20]; }
//prg1 = ps[21]; prg0 = ps[20];
//prg2 = ps[22]; prg1 = ps[21];
//prg3 = ps[23]; prg2 = ps[22];
//chr0 = ps[24]; prg3 = ps[23];
//chr1 = ps[25]; chr0 = ps[24];
//chr2 = ps[26]; chr1 = ps[25];
//chr3 = ps[27]; chr2 = ps[26];
//chr4 = ps[28]; chr3 = ps[27];
//chr5 = ps[29]; chr4 = ps[28];
//chr6 = ps[30]; chr5 = ps[29];
//chr7 = ps[31]; chr6 = ps[30];
//irq_enable = ps[32]; chr7 = ps[31];
//irq_counter = ps[33]; irq_enable = ps[32];
//irq_latch = ps[34]; irq_counter = ps[33];
irq_latch = ps[34];
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper064 Tengen Rambo-1 // // Mapper064 Tengen Rambo-1 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -249,29 +250,33 @@ namespace VirtualNes.Core
//void Mapper064::SaveState(LPBYTE p) //void Mapper064::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = reg[0]; p[0] = reg[0];
//p[1] = reg[1]; p[1] = reg[1];
//p[2] = reg[2]; p[2] = reg[2];
//p[3] = irq_enable; p[3] = irq_enable;
//p[4] = irq_mode; p[4] = irq_mode;
//p[5] = irq_latch; p[5] = irq_latch;
//p[6] = irq_reset; p[6] = irq_reset;
//*((INT*)&p[8]) = irq_counter; //*((INT*)&p[8]) = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 8);
//* ((INT*)&p[12]) = irq_counter2; //* ((INT*)&p[12]) = irq_counter2;
BitConverter.GetBytes(irq_counter2).CopyTo(p, 12);
} }
//void Mapper064::LoadState(LPBYTE p) //void Mapper064::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//reg[0] = p[0]; reg[0] = p[0];
//reg[1] = p[1]; reg[1] = p[1];
//reg[2] = p[2]; reg[2] = p[2];
//irq_enable = p[3]; irq_enable = p[3];
//irq_mode = p[4]; irq_mode = p[4];
//irq_latch = p[5]; irq_latch = p[5];
//irq_reset = p[6]; irq_reset = p[6];
//irq_counter = *((INT*)&p[8]); //irq_counter = *((INT*)&p[8]);
irq_counter = BitConverter.ToInt32(p, 8);
//irq_counter2 = *((INT*)&p[12]); //irq_counter2 = *((INT*)&p[12]);
irq_counter2 = BitConverter.ToInt32(p, 12);
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper065 Irem H3001 // // Mapper065 Irem H3001 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -166,17 +167,21 @@ namespace VirtualNes.Core
//void Mapper065::SaveState(LPBYTE p) //void Mapper065::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[1] = irq_counter; //*(INT*)&p[1] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 1);
//* (INT*)&p[5] = irq_latch; //* (INT*)&p[5] = irq_latch;
BitConverter.GetBytes(irq_latch).CopyTo(p, 5);
} }
//void Mapper065::LoadState(LPBYTE p) //void Mapper065::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = *(INT*)&p[1]; //irq_counter = *(INT*)&p[1];
irq_counter = BitConverter.ToInt32(p, 1);
//irq_latch = *(INT*)&p[5]; //irq_latch = *(INT*)&p[5];
irq_latch = BitConverter.ToInt32(p, 5);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper067 SunSoft Mapper 3 // // Mapper067 SunSoft Mapper 3 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -114,19 +115,21 @@ namespace VirtualNes.Core
//void Mapper067::SaveState(LPBYTE p) //void Mapper067::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//p[1] = irq_occur; p[1] = irq_occur;
//p[2] = irq_toggle; p[2] = irq_toggle;
//*((INT*)&p[3]) = irq_counter; //*((INT*)&p[3]) = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 3);
} }
//void Mapper067::LoadState(LPBYTE p) //void Mapper067::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_occur = p[1]; irq_occur = p[1];
//irq_toggle = p[2]; irq_toggle = p[2];
//irq_counter = *((INT*)&p[3]); //irq_counter = *((INT*)&p[3]);
irq_counter = BitConverter.ToInt32(p, 3);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper069 SunSoft FME-7 // // Mapper069 SunSoft FME-7 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -156,17 +157,19 @@ namespace VirtualNes.Core
//void Mapper069::SaveState(LPBYTE p) //void Mapper069::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = reg; p[0] = reg;
//p[1] = irq_enable; p[1] = irq_enable;
//*(INT*)&p[2] = irq_counter; //*(INT*)&p[2] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 2);
} }
//void Mapper069::LoadState(LPBYTE p) //void Mapper069::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//reg = p[0]; reg = p[0];
//irq_enable = p[1]; irq_enable = p[1];
//irq_counter = *(INT*)&p[2]; //irq_counter = *(INT*)&p[2];
irq_counter = BitConverter.ToInt32(p, 2);
} }
public override bool IsStateSave() public override bool IsStateSave()
{ {

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper073 Konami VRC3 // // Mapper073 Konami VRC3 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -73,15 +74,17 @@ namespace VirtualNes.Core
//void Mapper073::SaveState(LPBYTE p) //void Mapper073::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[1] = irq_counter; //*(INT*)&p[1] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 1);
} }
//void Mapper073::LoadState(LPBYTE p) //void Mapper073::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = *(INT*)&p[1]; //irq_counter = *(INT*)&p[1];
irq_counter = BitConverter.ToInt32(p, 1);
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -1,6 +1,7 @@
///////////////////////////// /////////////////////////////
// Mapper083 Cony // // Mapper083 Cony //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -215,23 +216,27 @@ namespace VirtualNes.Core
//void Mapper083::SaveState(LPBYTE p) //void Mapper083::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = reg[0]; p[0] = reg[0];
//p[1] = reg[1]; p[1] = reg[1];
//p[2] = reg[2]; p[2] = reg[2];
//*(INT*)&p[3] = chr_bank; //*(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; //*(INT*)&p[8] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p,8);
} }
//void Mapper083::LoadState(LPBYTE p) //void Mapper083::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//reg[0] = p[0]; reg[0] = p[0];
//reg[1] = p[1]; reg[1] = p[1];
//reg[2] = p[2]; reg[2] = p[2];
//chr_bank = *(INT*)&p[3]; //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 = *(INT*)&p[8];
irq_counter = BitConverter.ToInt32(p, 8);
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper085 Konami VRC7 // // Mapper085 Konami VRC7 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -213,19 +214,21 @@ namespace VirtualNes.Core
//void Mapper085::SaveState(LPBYTE p) //void Mapper085::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = irq_enable; p[0] = irq_enable;
//p[1] = irq_counter; p[1] = irq_counter;
//p[2] = irq_latch; p[2] = irq_latch;
//*((INT*)&p[4]) = irq_clock; //*((INT*)&p[4]) = irq_clock;
BitConverter.GetBytes(irq_clock).CopyTo(p, 4);
} }
//void Mapper085::LoadState(LPBYTE p) //void Mapper085::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//irq_enable = p[0]; irq_enable = p[0];
//irq_counter = p[1]; irq_counter = p[1];
//irq_latch = p[2]; irq_latch = p[2];
//irq_clock = *((INT*)&p[4]); //irq_clock = *((INT*)&p[4]);
irq_clock = BitConverter.ToInt32(p, 4);
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper105 Nintendo World Championship // // Mapper105 Nintendo World Championship //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -166,29 +167,31 @@ namespace VirtualNes.Core
//void Mapper105::SaveState(LPBYTE p) //void Mapper105::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 4; i++) for (INT i = 0; i < 4; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[8] = init_state; p[8] = init_state;
//p[9] = write_count; p[9] = write_count;
//p[10] = bits; p[10] = bits;
//p[11] = irq_enable; p[11] = irq_enable;
//*((INT*)&p[12]) = irq_counter; //*((INT*)&p[12]) = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 12);
} }
//void Mapper105::LoadState(LPBYTE p) //void Mapper105::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 4; i++) for (INT i = 0; i < 4; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//init_state = p[8]; init_state = p[8];
//write_count = p[9]; write_count = p[9];
//bits = p[10]; bits = p[10];
//irq_enable = p[11]; irq_enable = p[11];
//irq_counter = *((INT*)&p[12]); //irq_counter = *((INT*)&p[12]);
irq_counter = BitConverter.ToInt32(p, 12);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper142 SMB2J // // Mapper142 SMB2J //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -90,17 +91,19 @@ namespace VirtualNes.Core
//void Mapper142::SaveState(LPBYTE p) //void Mapper142::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = prg_sel; p[0] = prg_sel;
//p[0] = irq_enable; p[0] = irq_enable;
//*(INT*)&p[2] = irq_counter; //*(INT*)&p[2] = irq_counter;
BitConverter.GetBytes(irq_counter).CopyTo(p, 2);
} }
//void Mapper142::LoadState(LPBYTE p) //void Mapper142::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//prg_sel = p[0]; prg_sel = p[0];
//irq_enable = p[1]; irq_enable = p[1];
//irq_counter = *(INT*)&p[2]; //irq_counter = *(INT*)&p[2];
irq_counter = BitConverter.ToInt32 (p, 2);
} }
public override bool IsStateSave() public override bool IsStateSave()
{ {

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper183 Gimmick (Bootleg) // // Mapper183 Gimmick (Bootleg) //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -168,22 +169,24 @@ namespace VirtualNes.Core
//void Mapper183::SaveState(LPBYTE p) //void Mapper183::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[8] = irq_enable; p[8] = irq_enable;
BitConverter.GetBytes(irq_counter).CopyTo(p, 9);
//*((INT*)&p[9]) = irq_counter; //*((INT*)&p[9]) = irq_counter;
} }
//void Mapper183::LoadState(LPBYTE p) //void Mapper183::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
// for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
// { {
// reg[i] = p[i]; reg[i] = p[i];
// } }
// irq_enable = p[8]; irq_enable = p[8];
irq_counter = BitConverter.ToInt32(p, 9);
//irq_counter = *((INT*)&p[9]); //irq_counter = *((INT*)&p[9]);
} }

View File

@ -1,6 +1,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Mapper187 Street Fighter Zero 2 97 // // Mapper187 Street Fighter Zero 2 97 //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
using System;
using static VirtualNes.Core.CPU; using static VirtualNes.Core.CPU;
using static VirtualNes.MMU; using static VirtualNes.MMU;
using BYTE = System.Byte; using BYTE = System.Byte;
@ -310,56 +311,58 @@ namespace VirtualNes.Core
//void Mapper187::SaveState(LPBYTE p) //void Mapper187::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//INT i; int i;
//for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
//{ {
// p[i] = prg[i]; p[i] = prg[i];
//} }
//for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
//{ {
// p[4 + i] = bank[i]; p[4 + i] = bank[i];
//} }
//for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
//{ {
//*((INT*)&p[12 + i * sizeof(INT)]) = chr[i]; //*((INT*)&p[12 + i * sizeof(INT)]) = chr[i];
//} BitConverter.GetBytes(chr[i]).CopyTo(p, 12 + i * sizeof(int));
}
//p[44] = ext_mode; p[44] = ext_mode;
//p[45] = chr_mode; p[45] = chr_mode;
//p[46] = ext_enable; p[46] = ext_enable;
//p[47] = irq_enable; p[47] = irq_enable;
//p[48] = irq_counter; p[48] = irq_counter;
//p[49] = irq_latch; p[49] = irq_latch;
//p[50] = irq_occur; p[50] = irq_occur;
//p[51] = last_write; p[51] = last_write;
} }
//void Mapper187::LoadState(LPBYTE p) //void Mapper187::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//INT i; int i;
//for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
//{ {
// prg[i] = p[i]; prg[i] = p[i];
//} }
//for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
//{ {
// bank[i] = p[4 + i]; bank[i] = p[4 + i];
//} }
//for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
//{ {
chr[i] = BitConverter.ToInt32(p, 12 + i * sizeof(int));
//chr[i] = *((INT*)&p[12 + i * sizeof(INT)]); //chr[i] = *((INT*)&p[12 + i * sizeof(INT)]);
//} }
//ext_mode = p[44]; ext_mode = p[44];
//chr_mode = p[45]; chr_mode = p[45];
//ext_enable = p[46]; ext_enable = p[46];
//irq_enable = p[47]; irq_enable = p[47];
//irq_counter = p[48]; irq_counter = p[48];
//irq_latch = p[49]; irq_latch = p[49];
//irq_occur = p[50]; irq_occur = p[50];
//last_write = p[51]; last_write = p[51];
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -259,53 +259,55 @@ namespace VirtualNes.Core
//void Mapper199::SaveState(LPBYTE p) //void Mapper199::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) int i;
//{ for (i = 0; i < 8; i++)
// p[i] = reg[i]; {
//} p[i] = reg[i];
//for (i = 8; i < 12; i++) }
//{ for (i = 8; i < 12; i++)
// p[i] = prg[i]; {
//} p[i] = prg[i];
//for (i = 8; i < 20; i++) }
//{ for (i = 8; i < 20; i++)
// p[i] = chr[i]; {
//} p[i] = chr[i];
//p[20] = we_sram; }
//p[21] = JMaddr; p[20] = we_sram;
//p[22] = JMaddrDAT[0]; p[21] = JMaddr;
//p[23] = JMaddrDAT[1]; p[22] = JMaddrDAT[0];
//p[24] = JMaddrDAT[2]; p[23] = JMaddrDAT[1];
//p[25] = irq_enable; p[24] = JMaddrDAT[2];
//p[26] = irq_counter; p[25] = irq_enable;
//p[27] = irq_latch; p[26] = irq_counter;
//p[28] = irq_request; p[27] = irq_latch;
p[28] = irq_request;
} }
//void Mapper199::LoadState(LPBYTE p) //void Mapper199::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) int i;
//{ for (i = 0; i < 8; i++)
// reg[i] = p[i]; {
//} reg[i] = p[i];
//for (i = 8; i < 12; i++) }
//{ for (i = 8; i < 12; i++)
// prg[i] = p[i]; {
//} prg[i] = p[i];
//for (i = 8; i < 20; i++) }
//{ for (i = 8; i < 20; i++)
// chr[i] = p[i]; {
//} chr[i] = p[i];
//we_sram = p[20]; }
//JMaddr = p[21]; we_sram = p[20];
//JMaddrDAT[0] = p[22]; JMaddr = p[21];
//JMaddrDAT[1] = p[23]; JMaddrDAT[0] = p[22];
//JMaddrDAT[2] = p[24]; JMaddrDAT[1] = p[23];
//irq_enable = p[25]; JMaddrDAT[2] = p[24];
//irq_counter = p[26]; irq_enable = p[25];
//irq_latch = p[27]; irq_counter = p[26];
//irq_request = p[28]; irq_latch = p[27];
irq_request = p[28];
} }
public override bool IsStateSave() public override bool IsStateSave()

View File

@ -92,19 +92,19 @@ namespace VirtualNes.Core
//void Mapper243::SaveState(LPBYTE p) //void Mapper243::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//p[0] = reg[0]; p[0] = reg[0];
//p[1] = reg[1]; p[1] = reg[1];
//p[2] = reg[2]; p[2] = reg[2];
//p[3] = reg[3]; p[3] = reg[3];
} }
//void Mapper243::LoadState(LPBYTE p) //void Mapper243::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//reg[0] = p[0]; reg[0] = p[0];
//reg[1] = p[1]; reg[1] = p[1];
//reg[2] = p[2]; reg[2] = p[2];
//reg[3] = p[3]; reg[3] = p[3];
} }
} }

View File

@ -214,43 +214,43 @@ namespace VirtualNes.Core
//void Mapper245::SaveState(LPBYTE p) //void Mapper245::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[8] = prg0; p[8] = prg0;
//p[9] = prg1; p[9] = prg1;
//p[10] = chr01; p[10] = chr01;
//p[11] = chr23; p[11] = chr23;
//p[12] = chr4; p[12] = chr4;
//p[13] = chr5; p[13] = chr5;
//p[14] = chr6; p[14] = chr6;
//p[15] = chr7; p[15] = chr7;
//p[16] = irq_enable; p[16] = irq_enable;
//p[17] = (BYTE)irq_counter; p[17] = (BYTE)irq_counter;
//p[18] = irq_latch; p[18] = irq_latch;
//p[19] = irq_request; p[19] = irq_request;
} }
//void Mapper245::LoadState(LPBYTE p) //void Mapper245::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//prg0 = p[8]; prg0 = p[8];
//prg1 = p[9]; prg1 = p[9];
//chr01 = p[10]; chr01 = p[10];
//chr23 = p[11]; chr23 = p[11];
//chr4 = p[12]; chr4 = p[12];
//chr5 = p[13]; chr5 = p[13];
//chr6 = p[14]; chr6 = p[14];
//chr7 = p[15]; chr7 = p[15];
//irq_enable = p[16]; irq_enable = p[16];
//irq_counter = (INT)p[17]; irq_counter = (INT)p[17];
//irq_latch = p[18]; irq_latch = p[18];
//irq_request = p[19]; irq_request = p[19];
} }
} }
} }

View File

@ -190,43 +190,43 @@ namespace VirtualNes.Core
//void Mapper248::SaveState(LPBYTE p) //void Mapper248::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[8] = prg0; p[8] = prg0;
//p[9] = prg1; p[9] = prg1;
//p[10] = chr01; p[10] = chr01;
//p[11] = chr23; p[11] = chr23;
//p[12] = chr4; p[12] = chr4;
//p[13] = chr5; p[13] = chr5;
//p[14] = chr6; p[14] = chr6;
//p[15] = chr7; p[15] = chr7;
//p[16] = irq_enable; p[16] = irq_enable;
//p[17] = (BYTE)irq_counter; p[17] = (BYTE)irq_counter;
//p[18] = irq_latch; p[18] = irq_latch;
//p[19] = irq_request; p[19] = irq_request;
} }
//void Mapper248::LoadState(LPBYTE p) //void Mapper248::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//prg0 = p[8]; prg0 = p[8];
//prg1 = p[9]; prg1 = p[9];
//chr01 = p[10]; chr01 = p[10];
//chr23 = p[11]; chr23 = p[11];
//chr4 = p[12]; chr4 = p[12];
//chr5 = p[13]; chr5 = p[13];
//chr6 = p[14]; chr6 = p[14];
//chr7 = p[15]; chr7 = p[15];
//irq_enable = p[16]; irq_enable = p[16];
//irq_counter = (INT)p[17]; irq_counter = (BYTE)p[17];
//irq_latch = p[18]; irq_latch = p[18];
//irq_request = p[19]; irq_request = p[19];
} }
} }
} }

View File

@ -338,45 +338,45 @@ namespace VirtualNes.Core
//void Mapper249::SaveState(LPBYTE p) //void Mapper249::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//p[8] = prg0; p[8] = prg0;
//p[9] = prg1; p[9] = prg1;
//p[10] = chr01; p[10] = chr01;
//p[11] = chr23; p[11] = chr23;
//p[12] = chr4; p[12] = chr4;
//p[13] = chr5; p[13] = chr5;
//p[14] = chr6; p[14] = chr6;
//p[15] = chr7; p[15] = chr7;
//p[16] = irq_enable; p[16] = irq_enable;
//p[17] = irq_counter; p[17] = irq_counter;
//p[18] = irq_latch; p[18] = irq_latch;
//p[19] = irq_request; p[19] = irq_request;
//p[20] = spdata; p[20] = spdata;
} }
//void Mapper249::LoadState(LPBYTE p) //void Mapper249::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//for (INT i = 0; i < 8; i++) for (INT i = 0; i < 8; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//prg0 = p[8]; prg0 = p[8];
//prg1 = p[9]; prg1 = p[9];
//chr01 = p[10]; chr01 = p[10];
//chr23 = p[11]; chr23 = p[11];
//chr4 = p[12]; chr4 = p[12];
//chr5 = p[13]; chr5 = p[13];
//chr6 = p[14]; chr6 = p[14];
//chr7 = p[15]; chr7 = p[15];
//irq_enable = p[16]; irq_enable = p[16];
//irq_counter = p[17]; irq_counter = p[17];
//irq_latch = p[18]; irq_latch = p[18];
//irq_request = p[19]; irq_request = p[19];
//spdata = p[20]; spdata = p[20];
} }
} }
} }

View File

@ -112,30 +112,30 @@ namespace VirtualNes.Core
//void Mapper251::SaveState(LPBYTE p) //void Mapper251::SaveState(LPBYTE p)
public override void SaveState(byte[] p) public override void SaveState(byte[] p)
{ {
//INT i; INT i;
//for (i = 0; i < 11; i++) for (i = 0; i < 11; i++)
//{ {
// p[i] = reg[i]; p[i] = reg[i];
//} }
//for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
//{ {
// p[i + 11] = breg[i]; p[i + 11] = breg[i];
//} }
} }
//void Mapper251::LoadState(LPBYTE p) //void Mapper251::LoadState(LPBYTE p)
public override void LoadState(byte[] p) public override void LoadState(byte[] p)
{ {
//INT i; INT i;
//for (i = 0; i < 11; i++) for (i = 0; i < 11; i++)
//{ {
// reg[i] = p[i]; reg[i] = p[i];
//} }
//for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
//{ {
// reg[i] = p[i + 11]; reg[i] = p[i + 11];
//} }
} }
} }
} }