Generic指针化,以及指针化代码片段编写

This commit is contained in:
sin365 2025-01-22 11:15:22 +08:00
parent e7262578a3
commit 69a6a816bc
30 changed files with 540 additions and 97 deletions

View File

@ -45,6 +45,7 @@ namespace MAME.Core
ITimeSpan itime ITimeSpan itime
) )
{ {
AxiMemoryEx.Init();
Mame.RomRoot = RomDir; Mame.RomRoot = RomDir;
EmuLogger.BindFunc(ilog); EmuLogger.BindFunc(ilog);
Video.BindFunc(ivp); Video.BindFunc(ivp);

View File

@ -1,30 +1,290 @@
using cpu.m68000; using cpu.m68000;
using System; using System;
using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
{ {
public class Generic public unsafe class Generic
{ {
private static uint[] coin_count; //private static uint[] coin_count;
private static uint[] coinlockedout; //private static uint[] coinlockedout;
private static uint[] lastcoin; //private static uint[] lastcoin;
public static byte[] videoram, colorram; //public static byte[] videoram, colorram;
public static byte[] generic_nvram; //public static byte[] generic_nvram;
public static byte[] buffered_spriteram; //public static byte[] buffered_spriteram;
public static ushort[] buffered_spriteram16; //public static ushort[] buffered_spriteram16;
public static byte[] spriteram; //public static byte[] spriteram;
public static ushort[] spriteram16, spriteram16_2; //public static ushort[] spriteram16, spriteram16_2;
public static byte[] paletteram, paletteram_2; //public static byte[] paletteram, paletteram_2;
public static ushort[] paletteram16, paletteram16_2; //public static ushort[] paletteram16, paletteram16_2;
#region //指针化coin_count
static uint[] coin_count_src;
static GCHandle coin_count_handle;
public static uint* coin_count;
public static int coin_countLength;
public static uint[] coin_count_set
{
set
{
coin_count_handle.ReleaseGCHandle();
coin_count_src = value;
coin_countLength = value.Length;
coin_count_src.GetObjectPtr(ref coin_count_handle, ref coin_count);
}
}
#endregion
#region //指针化coinlockedout
static uint[] coinlockedout_src;
static GCHandle coinlockedout_handle;
public static uint* coinlockedout;
public static int coinlockedoutLength;
public static uint[] coinlockedout_set
{
set
{
coinlockedout_handle.ReleaseGCHandle();
coinlockedout_src = value;
coinlockedoutLength = value.Length;
coinlockedout_src.GetObjectPtr(ref coinlockedout_handle, ref coinlockedout);
}
}
#endregion
#region //指针化lastcoin
static uint[] lastcoin_src;
static GCHandle lastcoin_handle;
public static uint* lastcoin;
public static int lastcoinLength;
public static uint[] lastcoin_set
{
set
{
lastcoin_handle.ReleaseGCHandle();
lastcoin_src = value;
lastcoinLength = value.Length;
lastcoin_src.GetObjectPtr(ref lastcoin_handle, ref lastcoin);
}
}
#endregion
#region //指针化colorram
static byte[] colorram_src;
static GCHandle colorram_handle;
public static byte* colorram;
public static int colorramLength;
public static byte[] colorram_set
{
set
{
colorram_handle.ReleaseGCHandle();
colorram_src = value;
colorramLength = value.Length;
colorram_src.GetObjectPtr(ref colorram_handle, ref colorram);
}
}
#endregion
#region //指针化videoram
static byte[] videoram_src;
static GCHandle videoram_handle;
public static byte* videoram;
public static int videoramLength;
public static byte[] videoram_set
{
set
{
videoram_handle.ReleaseGCHandle();
videoram_src = value;
videoramLength = value.Length;
videoram_src.GetObjectPtr(ref videoram_handle, ref videoram);
}
}
#endregion
#region //指针化generic_nvram
static byte[] generic_nvram_src;
static GCHandle generic_nvram_handle;
public static byte* generic_nvram;
public static int generic_nvramLength;
public static byte[] generic_nvram_set
{
set
{
generic_nvram_handle.ReleaseGCHandle();
generic_nvram_src = value;
generic_nvramLength = value.Length;
generic_nvram_src.GetObjectPtr(ref generic_nvram_handle, ref generic_nvram);
}
}
#endregion
#region //指针化buffered_spriteram
static byte[] buffered_spriteram_src;
static GCHandle buffered_spriteram_handle;
public static byte* buffered_spriteram;
public static int buffered_spriteramLength;
public static byte[] buffered_spriteram_set
{
set
{
buffered_spriteram_handle.ReleaseGCHandle();
buffered_spriteram_src = value;
buffered_spriteramLength = value.Length;
buffered_spriteram_src.GetObjectPtr(ref buffered_spriteram_handle, ref buffered_spriteram);
}
}
#endregion
#region //指针化buffered_spriteram16
static ushort[] buffered_spriteram16_src;
static GCHandle buffered_spriteram16_handle;
public static ushort* buffered_spriteram16;
public static int buffered_spriteram16Length;
public static ushort[] buffered_spriteram16_set
{
set
{
buffered_spriteram16_handle.ReleaseGCHandle();
buffered_spriteram16_src = value;
buffered_spriteram16Length = value.Length;
buffered_spriteram16_src.GetObjectPtr(ref buffered_spriteram16_handle, ref buffered_spriteram16);
}
}
#endregion
#region //指针化spriteram
static byte[] spriteram_src;
static GCHandle spriteram_handle;
public static byte* spriteram;
public static int spriteramLength;
public static byte[] spriteram_set
{
set
{
spriteram_handle.ReleaseGCHandle();
spriteram_src = value;
spriteramLength = value.Length;
spriteram_src.GetObjectPtr(ref spriteram_handle, ref spriteram);
}
}
#endregion
#region //指针化spriteram16
static ushort[] spriteram16_src;
static GCHandle spriteram16_handle;
public static ushort* spriteram16;
public static int spriteram16Length;
public static ushort[] spriteram16_set
{
set
{
spriteram16_handle.ReleaseGCHandle();
spriteram16_src = value;
spriteram16Length = value.Length;
spriteram16_src.GetObjectPtr(ref spriteram16_handle, ref spriteram16);
}
}
#endregion
#region //指针化spriteram16_2
static ushort[] spriteram16_2_src;
static GCHandle spriteram16_2_handle;
public static ushort* spriteram16_2;
public static int spriteram16_2Length;
public static ushort[] spriteram16_2_set
{
set
{
spriteram16_2_handle.ReleaseGCHandle();
spriteram16_2_src = value;
spriteram16_2Length = value.Length;
spriteram16_2_src.GetObjectPtr(ref spriteram16_2_handle, ref spriteram16_2);
}
}
#endregion
#region //指针化paletteram
static byte[] paletteram_src;
static GCHandle paletteram_handle;
public static byte* paletteram;
public static int paletteramLength;
public static byte[] paletteram_set
{
set
{
paletteram_handle.ReleaseGCHandle();
paletteram_src = value;
paletteramLength = value.Length;
paletteram_src.GetObjectPtr(ref paletteram_handle, ref paletteram);
}
}
#endregion
#region //指针化paletteram_2
static byte[] paletteram_2_src;
static GCHandle paletteram_2_handle;
public static byte* paletteram_2;
public static int paletteram_2Length;
public static byte[] paletteram_2_set
{
set
{
paletteram_2_handle.ReleaseGCHandle();
paletteram_2_src = value;
paletteram_2Length = value.Length;
paletteram_2_src.GetObjectPtr(ref paletteram_2_handle, ref paletteram_2);
}
}
#endregion
#region //指针化paletteram16
static ushort[] paletteram16_src;
static GCHandle paletteram16_handle;
public static ushort* paletteram16;
public static int paletteram16Length;
public static ushort[] paletteram16_set
{
set
{
paletteram16_handle.ReleaseGCHandle();
paletteram16_src = value;
paletteram16Length = value.Length;
paletteram16_src.GetObjectPtr(ref paletteram16_handle, ref paletteram16);
}
}
#endregion
#region //指针化paletteram16_2
static ushort[] paletteram16_2_src;
static GCHandle paletteram16_2_handle;
public static ushort* paletteram16_2;
public static int paletteram16_2Length;
public static ushort[] paletteram16_2_set
{
set
{
paletteram16_2_handle.ReleaseGCHandle();
paletteram16_2_src = value;
paletteram16_2Length = value.Length;
paletteram16_2_src.GetObjectPtr(ref paletteram16_2_handle, ref paletteram16_2);
}
}
#endregion
public static int[] interrupt_enable; public static int[] interrupt_enable;
public static int objcpunum; public static int objcpunum;
public static int flip_screen_x, flip_screen_y; public static int flip_screen_x, flip_screen_y;
public static void generic_machine_init() public static void generic_machine_init()
{ {
int counternum; int counternum;
coin_count = new uint[8]; coin_count_set = new uint[8];
coinlockedout = new uint[8]; coinlockedout_set = new uint[8];
lastcoin = new uint[8]; lastcoin_set = new uint[8];
for (counternum = 0; counternum < 8; counternum++) for (counternum = 0; counternum < 8; counternum++)
{ {
lastcoin[counternum] = 0; lastcoin[counternum] = 0;
@ -205,11 +465,11 @@ namespace MAME.Core
} }
public static void buffer_spriteram_w() public static void buffer_spriteram_w()
{ {
Array.Copy(spriteram, buffered_spriteram, spriteram.Length); AxiArray.Copy(spriteram, buffered_spriteram, spriteramLength);
} }
public static void buffer_spriteram16_w() public static void buffer_spriteram16_w()
{ {
Array.Copy(spriteram16, buffered_spriteram16, spriteram16.Length); AxiArray.Copy(spriteram16, buffered_spriteram16, spriteram16Length);
} }
public static ushort paletteram16_le(int offset) public static ushort paletteram16_le(int offset)
{ {

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -437,20 +438,129 @@ namespace MAME.Core
} }
public unsafe static class MemoryEx public unsafe static class AxiMemoryEx
{ {
// 创建一个临时数组来存储从指针指向的数据中复制的内容 static HashSet<GCHandle> GCHandles = new HashSet<GCHandle>();
static byte[] tempBuffer = new byte[0x20000];
public static void Init()
{
FreeAllGCHandle();
set_TempBuffer = new byte[0x20000];
}
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr)
{
GetObjectPtr(srcObj, ref handle, out IntPtr intptr);
ptr = (uint*)intptr;
}
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr)
{
GetObjectPtr(srcObj, ref handle, out IntPtr intptr);
ptr = (ushort*)intptr;
}
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr)
{
GetObjectPtr(srcObj, ref handle, out IntPtr intptr);
ptr = (int*)intptr;
}
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr)
{
GetObjectPtr(srcObj, ref handle, out IntPtr intptr);
ptr = (byte*)intptr;
}
static void GetObjectPtr(this object srcObj, ref GCHandle handle, out IntPtr intptr)
{
ReleaseGCHandle(ref handle);
handle = GCHandle.Alloc(srcObj, GCHandleType.Pinned);
GCHandles.Add(handle);
intptr = handle.AddrOfPinnedObject();
}
public static void ReleaseGCHandle(this ref GCHandle handle)
{
if (handle.IsAllocated)
handle.Free();
GCHandles.Remove(handle);
}
public static void FreeAllGCHandle()
{
foreach (var handle in GCHandles)
{
if (handle.IsAllocated)
handle.Free();
}
GCHandles.Clear();
}
#region TempBuffer
static byte[] TempBuffer_src;
static GCHandle TempBuffer_handle;
public static byte* TempBuffer;
public static byte[] set_TempBuffer
{
set
{
TempBuffer_handle.ReleaseGCHandle();
TempBuffer_src = value;
TempBuffer_src.GetObjectPtr(ref TempBuffer_handle, ref TempBuffer);
}
}
#endregion
public static void Write(this BinaryWriter bw, byte* buffer, int index, int count) public static void Write(this BinaryWriter bw, byte* buffer, int index, int count)
{ {
fixed (byte* pTempBuffer = tempBuffer) // 使用指针复制数据到临时数组
{ Buffer.MemoryCopy(buffer + index, TempBuffer, count, count);
// 使用指针复制数据到临时数组
Buffer.MemoryCopy(buffer + index, pTempBuffer, count, count);
}
// 使用BinaryWriter写入临时数组 // 使用BinaryWriter写入临时数组
bw.Write(tempBuffer, 0, count); bw.Write(TempBuffer, 0, count);
}
}
public unsafe static class AxiArray
{
public static void Copy(byte* src, int srcindex, byte* target, int targetindex, int count)
{
Buffer.MemoryCopy(&src[srcindex], target, targetindex, count);
}
public static void Copy(byte* src, byte* target, int index, int count)
{
Buffer.MemoryCopy(src, target, index, count);
}
public static void Copy(ushort* src, ushort* target, int index, int count)
{
long destinationStartIndexInBytes = index * sizeof(ushort);
long totalBytesToCopy = count * sizeof(ushort);
Buffer.MemoryCopy(src, target, destinationStartIndexInBytes, totalBytesToCopy);
}
public static void Copy(ushort* src, ushort* target, int count)
{
long totalBytesToCopy = count * sizeof(ushort);
Buffer.MemoryCopy(src, target, 0, totalBytesToCopy);
}
public static void Copy(byte* src, byte* target, int count)
{
Buffer.MemoryCopy(src, target, 0, count);
}
public static void Clear(byte* data, int index, int lenght)
{
for (int i = index; i < lenght; i++, index++)
{
data[index] = 0;
}
}
public static void Clear(ushort* data, int index, int lenght)
{
for (int i = index; i < lenght; i++, index++)
{
data[index] = 0;
}
} }
} }
} }

View File

@ -28,8 +28,8 @@ namespace MAME.Core
case "makaimurc": case "makaimurc":
case "makaimurg": case "makaimurg":
case "diamond": case "diamond":
Generic.spriteram = new byte[0x200]; Generic.spriteram_set = new byte[0x200];
Generic.buffered_spriteram = new byte[0x200]; Generic.buffered_spriteram_set = new byte[0x200];
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
//Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); //Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));
Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));
@ -59,8 +59,8 @@ namespace MAME.Core
} }
Memory.Set_mainram(new byte[0x1e00]); Memory.Set_mainram(new byte[0x1e00]);
Memory.Set_audioram(new byte[0x800]); Memory.Set_audioram(new byte[0x800]);
Generic.paletteram = new byte[0x100]; Generic.paletteram_set = new byte[0x100];
Generic.paletteram_2 = new byte[0x100]; Generic.paletteram_2_set = new byte[0x100];
if (Memory.mainrom_IsNull|| Memory.audiorom_IsNull || gfx12rom == null || gfx22rom == null || gfx32rom == null) if (Memory.mainrom_IsNull|| Memory.audiorom_IsNull || gfx12rom == null || gfx22rom == null || gfx32rom == null)
{ {
Machine.bRom = false; Machine.bRom = false;
@ -74,7 +74,7 @@ namespace MAME.Core
case "sfp": case "sfp":
sf_objectram = new ushort[0x1000]; sf_objectram = new ushort[0x1000];
sf_videoram = new ushort[0x800]; sf_videoram = new ushort[0x800];
Generic.paletteram16 = new ushort[0x400]; Generic.paletteram16_set = new ushort[0x400];
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
//Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); //Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));
Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));

View File

@ -1,6 +1,6 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class Capcom public unsafe partial class Capcom
{ {
public static byte[] gng_fgvideoram, gng_bgvideoram; public static byte[] gng_fgvideoram, gng_bgvideoram;
public static byte[] scrollx, scrolly; public static byte[] scrollx, scrolly;

View File

@ -63,10 +63,10 @@ namespace MAME.Core
gng_bgvideoram = reader.ReadBytes(0x800); gng_bgvideoram = reader.ReadBytes(0x800);
scrollx = reader.ReadBytes(2); scrollx = reader.ReadBytes(2);
scrolly = reader.ReadBytes(2); scrolly = reader.ReadBytes(2);
Generic.paletteram = reader.ReadBytes(0x100); Generic.paletteram_set = reader.ReadBytes(0x100);
Generic.paletteram_2 = reader.ReadBytes(0x100); Generic.paletteram_2_set = reader.ReadBytes(0x100);
Generic.spriteram = reader.ReadBytes(0x200); Generic.spriteram_set = reader.ReadBytes(0x200);
Generic.buffered_spriteram = reader.ReadBytes(0x200); Generic.buffered_spriteram_set = reader.ReadBytes(0x200);
for (i = 0; i < 0x100; i++) for (i = 0; i < 0x100; i++)
{ {
Palette.entry_color[i] = reader.ReadUInt32(); Palette.entry_color[i] = reader.ReadUInt32();

View File

@ -11,8 +11,8 @@
Machine.bRom = true; Machine.bRom = true;
Memory.Set_mainram(new byte[0x800]); Memory.Set_mainram(new byte[0x800]);
Memory.Set_audioram(new byte[0x800]); Memory.Set_audioram(new byte[0x800]);
Generic.spriteram = new byte[0x200]; Generic.spriteram_set = new byte[0x200];
Generic.videoram = new byte[0x800]; Generic.videoram_set = new byte[0x800];
switch (Machine.sName) switch (Machine.sName)
{ {
case "pcktgal": case "pcktgal":

View File

@ -62,8 +62,8 @@ namespace MAME.Core
Palette.entry_color[i] = reader.ReadUInt32(); Palette.entry_color[i] = reader.ReadUInt32();
} }
Memory.Set_mainram(reader.ReadBytes(0x800)); Memory.Set_mainram(reader.ReadBytes(0x800));
Generic.videoram = reader.ReadBytes(0x800); Generic.videoram_set = reader.ReadBytes(0x800);
Generic.spriteram = reader.ReadBytes(0x200); Generic.spriteram_set = reader.ReadBytes(0x200);
Memory.Set_audioram(reader.ReadBytes(0x800)); Memory.Set_audioram(reader.ReadBytes(0x800));
M6502.mm1[0].LoadStateBinary(reader); M6502.mm1[0].LoadStateBinary(reader);
M6502.mm1[1].LoadStateBinary(reader); M6502.mm1[1].LoadStateBinary(reader);

View File

@ -1,6 +1,6 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class Dataeast public unsafe partial class Dataeast
{ {
public static void palette_init_pcktgal(byte[] color_prom) public static void palette_init_pcktgal(byte[] color_prom)
{ {

View File

@ -1,6 +1,6 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class IGS011 public unsafe partial class IGS011
{ {
public static ushort[] priority_ram, paletteram16; public static ushort[] priority_ram, paletteram16;
public static byte prot1, prot2, prot1_swap; public static byte prot1, prot2, prot1_swap;
@ -14,7 +14,7 @@
public static void IGS011Init() public static void IGS011Init()
{ {
Machine.bRom = true; Machine.bRom = true;
Generic.generic_nvram = new byte[0x4000]; Generic.generic_nvram_set = new byte[0x4000];
priority_ram = new ushort[0x800]; priority_ram = new ushort[0x800];
paletteram16 = new ushort[0x1000]; paletteram16 = new ushort[0x1000];
igs003_reg = new ushort[2]; igs003_reg = new ushort[2];

View File

@ -3,7 +3,7 @@ using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public partial class IGS011 public unsafe partial class IGS011
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
@ -81,7 +81,7 @@ namespace MAME.Core
{ {
Palette.entry_color[i] = reader.ReadUInt32(); Palette.entry_color[i] = reader.ReadUInt32();
} }
Generic.generic_nvram = reader.ReadBytes(0x4000); Generic.generic_nvram_set = reader.ReadBytes(0x4000);
for (i = 0; i < 0x800; i++) for (i = 0; i < 0x800; i++)
{ {
priority_ram[i] = reader.ReadUInt16(); priority_ram[i] = reader.ReadUInt16();

View File

@ -3,7 +3,7 @@ using System;
namespace MAME.Core namespace MAME.Core
{ {
public partial class Konami68000 public unsafe partial class Konami68000
{ {
public static byte[] gfx1rom, gfx2rom, gfx12rom, gfx22rom, titlerom, user1rom, zoomrom; public static byte[] gfx1rom, gfx2rom, gfx12rom, gfx22rom, titlerom, user1rom, zoomrom;
public static byte dsw1, dsw2, dsw3, bytee; public static byte dsw1, dsw2, dsw3, bytee;
@ -17,8 +17,8 @@ namespace MAME.Core
public static void Konami68000Init() public static void Konami68000Init()
{ {
int i, n1, n2; int i, n1, n2;
Generic.paletteram16 = new ushort[0x800]; Generic.paletteram16_set = new ushort[0x800];
Generic.spriteram16 = new ushort[0x2000]; Generic.spriteram16_set = new ushort[0x2000];
init_eeprom_count = 10; init_eeprom_count = 10;
toggle = 0; toggle = 0;
Memory.Set_mainram(new byte[0x4000]); Memory.Set_mainram(new byte[0x4000]);

View File

@ -40,9 +40,9 @@ namespace MAME.Core
public static void M72Init() public static void M72Init()
{ {
int i1, i2, i3, n1, n2, n3; int i1, i2, i3, n1, n2, n3;
Generic.paletteram16 = new ushort[0x600]; Generic.paletteram16_set = new ushort[0x600];
Generic.paletteram16_2 = new ushort[0x600]; Generic.paletteram16_2_set = new ushort[0x600];
Generic.spriteram16 = new ushort[0x200]; Generic.spriteram16_set = new ushort[0x200];
Machine.bRom = true; Machine.bRom = true;
EmuTimer.setvector = setvector_callback; EmuTimer.setvector = setvector_callback;
protection_ram = new byte[0x1000]; protection_ram = new byte[0x1000];

View File

@ -1,13 +1,32 @@
using System; using System;
using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
{ {
public partial class M72 public unsafe partial class M72
{ {
public static byte[] m72_videoram1, m72_videoram2; public static byte[] m72_videoram1, m72_videoram2;
public static ushort[] majtitle_rowscrollram; public static ushort[] majtitle_rowscrollram;
public static int m72_raster_irq_position; public static int m72_raster_irq_position;
public static ushort[] m72_spriteram; //public static ushort[] m72_spriteram;
#region //指针化m72_spriteram
static ushort[] m72_spriteram_src;
static GCHandle m72_spriteram_handle;
public static ushort* m72_spriteram;
public static int m72_spriteramLength;
public static ushort[] m72_spriteram_set
{
set
{
m72_spriteram_handle.ReleaseGCHandle();
m72_spriteram_src = value;
m72_spriteramLength = value.Length;
m72_spriteram_src.GetObjectPtr(ref m72_spriteram_handle, ref m72_spriteram);
}
}
#endregion
private static ushort[] uuB200; private static ushort[] uuB200;
public static int scrollx1, scrolly1, scrollx2, scrolly2; public static int scrollx1, scrolly1, scrollx2, scrolly2;
public static int video_off, spriteram_size, majtitle_rowscroll; public static int video_off, spriteram_size, majtitle_rowscroll;
@ -96,7 +115,7 @@ namespace MAME.Core
public static void m72_dmaon_w(ushort data) public static void m72_dmaon_w(ushort data)
{ {
//if (ACCESSING_BITS_0_7) //if (ACCESSING_BITS_0_7)
Array.Copy(Generic.spriteram16, m72_spriteram, spriteram_size / 2); AxiArray.Copy(Generic.spriteram16, m72_spriteram, spriteram_size / 2);
} }
public static void m72_port02_w(ushort data) public static void m72_port02_w(ushort data)
{ {
@ -200,7 +219,7 @@ namespace MAME.Core
{ {
uuB200[i] = 0x200; uuB200[i] = 0x200;
} }
m72_spriteram = new ushort[0x200]; m72_spriteram_set = new ushort[0x200];
m72_videoram1 = new byte[0x4000]; m72_videoram1 = new byte[0x4000];
m72_videoram2 = new byte[0x4000]; m72_videoram2 = new byte[0x4000];
fg_tilemap.tilemap_set_scrolldx(0, 0); fg_tilemap.tilemap_set_scrolldx(0, 0);

View File

@ -225,9 +225,9 @@ namespace MAME.Core
{ {
pf_layer[i1].control = new ushort[4]; pf_layer[i1].control = new ushort[4];
} }
Generic.paletteram16 = new ushort[0x800]; Generic.paletteram16_set = new ushort[0x800];
Generic.spriteram16 = new ushort[0x400]; Generic.spriteram16_set = new ushort[0x400];
Generic.buffered_spriteram16 = new ushort[0x400]; Generic.buffered_spriteram16_set = new ushort[0x400];
m92_vram_data = new ushort[0x8000]; m92_vram_data = new ushort[0x8000];
m92_spritecontrol = new ushort[8]; m92_spritecontrol = new ushort[8];
bb1 = Machine.GetRom("maincpu.rom"); bb1 = Machine.GetRom("maincpu.rom");

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class M92 public unsafe partial class M92
{ {
public static ushort[] pf_master_control; public static ushort[] pf_master_control;
public static int m92_sprite_list; public static int m92_sprite_list;

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class Namcos1 public unsafe partial class Namcos1
{ {
public static byte byte0, byte1, byte2, byte00, byte01, byte02, byte03; public static byte byte0, byte1, byte2, byte00, byte01, byte02, byte03;
public static byte byte0_old, byte1_old, byte2_old; public static byte byte0_old, byte1_old, byte2_old;

View File

@ -41,7 +41,7 @@ namespace MAME.Core
bank_ram20 = new byte[0x2000]; bank_ram20 = new byte[0x2000];
bank_ram30 = new byte[0x80]; bank_ram30 = new byte[0x80];
Namco.namco_wavedata = new byte[0x400]; Namco.namco_wavedata = new byte[0x400];
Generic.generic_nvram = new byte[0x800]; Generic.generic_nvram_set = new byte[0x800];
cus117_offset = new int[2, 8]; cus117_offset = new int[2, 8];
key = new byte[8]; key = new byte[8];
if (audiorom == null || gfx1rom == null || gfx2rom == null || gfx3rom == null || user1rom == null || voicerom == null) if (audiorom == null || gfx1rom == null || gfx2rom == null || gfx3rom == null || user1rom == null || voicerom == null)

View File

@ -4,7 +4,7 @@ using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public partial class Namcos1 public unsafe partial class Namcos1
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
@ -101,7 +101,7 @@ namespace MAME.Core
dac1_value = reader.ReadInt32(); dac1_value = reader.ReadInt32();
dac0_gain = reader.ReadInt32(); dac0_gain = reader.ReadInt32();
dac1_gain = reader.ReadInt32(); dac1_gain = reader.ReadInt32();
Generic.generic_nvram = reader.ReadBytes(0x800); Generic.generic_nvram_set = reader.ReadBytes(0x800);
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)

View File

@ -50,7 +50,7 @@ namespace MAME.Core
pgm_bg_videoram = new byte[0x4000]; pgm_bg_videoram = new byte[0x4000];
pgm_tx_videoram = new byte[0x2000]; pgm_tx_videoram = new byte[0x2000];
pgm_rowscrollram = new byte[0x800]; pgm_rowscrollram = new byte[0x800];
Generic.paletteram16 = new ushort[0x900]; Generic.paletteram16_set = new ushort[0x900];
pgm_videoregs = new byte[0x10000]; pgm_videoregs = new byte[0x10000];
Memory.Set_audioram(new byte[0x10000]); Memory.Set_audioram(new byte[0x10000]);
if (Memory.mainrom_IsNull || sprmaskrom == null || pgm_sprite_a_region == null) if (Memory.mainrom_IsNull || sprmaskrom == null || pgm_sprite_a_region == null)

View File

@ -4,7 +4,7 @@ using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public partial class PGM public unsafe partial class PGM
{ {
public unsafe static void SaveStateBinary(BinaryWriter writer) public unsafe static void SaveStateBinary(BinaryWriter writer)
{ {

View File

@ -23,7 +23,7 @@ namespace MAME.Core
switch (Machine.sName) switch (Machine.sName)
{ {
case "starfigh": case "starfigh":
Generic.spriteram = new byte[0x4000]; Generic.spriteram_set = new byte[0x4000];
mainromop = Machine.GetRom("maincpuop.rom"); mainromop = Machine.GetRom("maincpuop.rom");
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));
@ -38,7 +38,7 @@ namespace MAME.Core
} }
Memory.Set_mainram(new byte[0x1800]); Memory.Set_mainram(new byte[0x1800]);
Memory.Set_audioram(new byte[0x800]); Memory.Set_audioram(new byte[0x800]);
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
if (mainromop == null || Memory.mainrom_IsNull || Memory.audiorom_IsNull || samplesrom == null || gfx12rom == null) if (mainromop == null || Memory.mainrom_IsNull || Memory.audiorom_IsNull || samplesrom == null || gfx12rom == null)
{ {
Machine.bRom = false; Machine.bRom = false;

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class SunA8 public unsafe partial class SunA8
{ {
public static RECT cliprect; public static RECT cliprect;
public static ushort[] uuFF; public static ushort[] uuFF;
@ -61,9 +61,9 @@ namespace MAME.Core
m_palettebank = 0; m_palettebank = 0;
if (m_has_text == 0) if (m_has_text == 0)
{ {
Generic.paletteram = new byte[0x200 * 2]; Generic.paletteram_set = new byte[0x200 * 2];
Generic.spriteram = new byte[0x2000 * 2 * 2]; Generic.spriteram_set = new byte[0x2000 * 2 * 2];
Array.Clear(Generic.spriteram, 0, 0x2000 * 2 * 2); AxiArray.Clear(Generic.spriteram, 0, 0x2000 * 2 * 2);
} }
} }
public static void video_start_suna8_text() public static void video_start_suna8_text()

View File

@ -65,7 +65,7 @@ namespace MAME.Core
basebankmain = reader.ReadInt32(); basebankmain = reader.ReadInt32();
videoram = reader.ReadBytes(0x1d00); videoram = reader.ReadBytes(0x1d00);
bublbobl_objectram = reader.ReadBytes(0x300); bublbobl_objectram = reader.ReadBytes(0x300);
Generic.paletteram = reader.ReadBytes(0x200); Generic.paletteram_set = reader.ReadBytes(0x200);
bublbobl_video_enable = reader.ReadInt32(); bublbobl_video_enable = reader.ReadInt32();
tokio_prot_count = reader.ReadInt32(); tokio_prot_count = reader.ReadInt32();
sound_nmi_enable = reader.ReadInt32(); sound_nmi_enable = reader.ReadInt32();
@ -178,7 +178,7 @@ namespace MAME.Core
basebankmain = reader.ReadInt32(); basebankmain = reader.ReadInt32();
videoram = reader.ReadBytes(0x1d00); videoram = reader.ReadBytes(0x1d00);
bublbobl_objectram = reader.ReadBytes(0x300); bublbobl_objectram = reader.ReadBytes(0x300);
Generic.paletteram = reader.ReadBytes(0x200); Generic.paletteram_set = reader.ReadBytes(0x200);
bublbobl_mcu_sharedram = reader.ReadBytes(0x400); bublbobl_mcu_sharedram = reader.ReadBytes(0x400);
bublbobl_video_enable = reader.ReadInt32(); bublbobl_video_enable = reader.ReadInt32();
ddr1 = reader.ReadByte(); ddr1 = reader.ReadByte();
@ -296,7 +296,7 @@ namespace MAME.Core
basebankmain = reader.ReadInt32(); basebankmain = reader.ReadInt32();
videoram = reader.ReadBytes(0x1d00); videoram = reader.ReadBytes(0x1d00);
bublbobl_objectram = reader.ReadBytes(0x300); bublbobl_objectram = reader.ReadBytes(0x300);
Generic.paletteram = reader.ReadBytes(0x200); Generic.paletteram_set = reader.ReadBytes(0x200);
bublbobl_video_enable = reader.ReadInt32(); bublbobl_video_enable = reader.ReadInt32();
ic43_a = reader.ReadInt32(); ic43_a = reader.ReadInt32();
ic43_b = reader.ReadInt32(); ic43_b = reader.ReadInt32();
@ -407,7 +407,7 @@ namespace MAME.Core
basebankmain = reader.ReadInt32(); basebankmain = reader.ReadInt32();
videoram = reader.ReadBytes(0x1d00); videoram = reader.ReadBytes(0x1d00);
bublbobl_objectram = reader.ReadBytes(0x300); bublbobl_objectram = reader.ReadBytes(0x300);
Generic.paletteram = reader.ReadBytes(0x200); Generic.paletteram_set = reader.ReadBytes(0x200);
bublbobl_mcu_sharedram = reader.ReadBytes(0x400); bublbobl_mcu_sharedram = reader.ReadBytes(0x400);
bublbobl_video_enable = reader.ReadInt32(); bublbobl_video_enable = reader.ReadInt32();
portA_in = reader.ReadByte(); portA_in = reader.ReadByte();

View File

@ -20,7 +20,7 @@ namespace MAME.Core
bublbobl_objectram = new byte[0x300]; bublbobl_objectram = new byte[0x300];
Memory.Set_mainram(new byte[0x1800]); Memory.Set_mainram(new byte[0x1800]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
//bublbobl_mcu_sharedram = new byte[0x400]; //bublbobl_mcu_sharedram = new byte[0x400];
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
slaverom = Machine.GetRom("slave.rom"); slaverom = Machine.GetRom("slave.rom");
@ -59,7 +59,7 @@ namespace MAME.Core
Memory.Set_mainram(new byte[0x1800]); Memory.Set_mainram(new byte[0x1800]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
mcuram = new byte[0xc0]; mcuram = new byte[0xc0];
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
bublbobl_mcu_sharedram = new byte[0x400]; bublbobl_mcu_sharedram = new byte[0x400];
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
slaverom = Machine.GetRom("slave.rom"); slaverom = Machine.GetRom("slave.rom");
@ -100,7 +100,7 @@ namespace MAME.Core
bublbobl_objectram = new byte[0x300]; bublbobl_objectram = new byte[0x300];
Memory.Set_mainram(new byte[0x1800]); Memory.Set_mainram(new byte[0x1800]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
slaverom = Machine.GetRom("slave.rom"); slaverom = Machine.GetRom("slave.rom");
//Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); //Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));
@ -133,7 +133,7 @@ namespace MAME.Core
bublbobl_objectram = new byte[0x300]; bublbobl_objectram = new byte[0x300];
Memory.Set_mainram(new byte[0x1800]); Memory.Set_mainram(new byte[0x1800]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
slaverom = Machine.GetRom("slave.rom"); slaverom = Machine.GetRom("slave.rom");
//Memory.Set_audiorom(Machine.GetRom("audiocpu.rom")); //Memory.Set_audiorom(Machine.GetRom("audiocpu.rom"));
@ -165,7 +165,7 @@ namespace MAME.Core
{ {
mainram2 = new byte[0x10000]; mainram2 = new byte[0x10000];
cchip_ram = new byte[0x2000]; cchip_ram = new byte[0x2000];
Generic.paletteram16 = new ushort[0x800]; Generic.paletteram16_set = new ushort[0x800];
Memory.Set_mainram(new byte[0x8000]); Memory.Set_mainram(new byte[0x8000]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
@ -209,7 +209,7 @@ namespace MAME.Core
{ {
mainram2 = new byte[0x10000]; mainram2 = new byte[0x10000];
cchip_ram = new byte[0x2000]; cchip_ram = new byte[0x2000];
Generic.paletteram16 = new ushort[0x800]; Generic.paletteram16_set = new ushort[0x800];
Memory.Set_mainram(new byte[0x8000]); Memory.Set_mainram(new byte[0x8000]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));
@ -254,7 +254,7 @@ namespace MAME.Core
{ {
mainram2 = new byte[0x10000]; mainram2 = new byte[0x10000];
cchip_ram = new byte[0x2000]; cchip_ram = new byte[0x2000];
Generic.paletteram16 = new ushort[0x800]; Generic.paletteram16_set = new ushort[0x800];
Memory.Set_mainram(new byte[0x8000]); Memory.Set_mainram(new byte[0x8000]);
Memory.Set_audioram(new byte[0x1000]); Memory.Set_audioram(new byte[0x1000]);
Memory.Set_mainrom(Machine.GetRom("maincpu.rom")); Memory.Set_mainrom(Machine.GetRom("maincpu.rom"));

View File

@ -12,7 +12,7 @@ namespace MAME.Core
public static void TaitobInit() public static void TaitobInit()
{ {
int i, n; int i, n;
Generic.paletteram16 = new ushort[0x1000]; Generic.paletteram16_set = new ushort[0x1000];
TC0180VCU_ram = new ushort[0x8000]; TC0180VCU_ram = new ushort[0x8000];
TC0180VCU_ctrl = new ushort[0x10]; TC0180VCU_ctrl = new ushort[0x10];
TC0220IOC_regs = new byte[8]; TC0220IOC_regs = new byte[8];

View File

@ -23,12 +23,12 @@ namespace MAME.Core
gfx32rom = Machine.GetRom("gfx32.rom"); gfx32rom = Machine.GetRom("gfx32.rom");
Memory.Set_mainram(new byte[0x1000]); Memory.Set_mainram(new byte[0x1000]);
Memory.Set_audioram(new byte[0x800]); Memory.Set_audioram(new byte[0x800]);
Generic.videoram = new byte[0x400]; Generic.videoram_set = new byte[0x400];
pbaction_videoram2 = new byte[0x400]; pbaction_videoram2 = new byte[0x400];
Generic.colorram = new byte[0x400]; Generic.colorram_set = new byte[0x400];
pbaction_colorram2 = new byte[0x400]; pbaction_colorram2 = new byte[0x400];
Generic.spriteram = new byte[0x80]; Generic.spriteram_set = new byte[0x80];
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
if (Memory.mainrom_IsNull || Memory.audiorom_IsNull || gfx1rom == null || gfx2rom == null || gfx3rom == null || gfx32rom == null) if (Memory.mainrom_IsNull || Memory.audiorom_IsNull || gfx1rom == null || gfx2rom == null || gfx3rom == null || gfx32rom == null)
{ {
Machine.bRom = false; Machine.bRom = false;
@ -47,12 +47,12 @@ namespace MAME.Core
gfx32rom = Machine.GetRom("gfx32.rom"); gfx32rom = Machine.GetRom("gfx32.rom");
Memory.Set_mainram(new byte[0x1000]); Memory.Set_mainram(new byte[0x1000]);
Memory.Set_audioram(new byte[0x800]); Memory.Set_audioram(new byte[0x800]);
Generic.videoram = new byte[0x400]; Generic.videoram_set = new byte[0x400];
pbaction_videoram2 = new byte[0x400]; pbaction_videoram2 = new byte[0x400];
Generic.colorram = new byte[0x400]; Generic.colorram_set = new byte[0x400];
pbaction_colorram2 = new byte[0x400]; pbaction_colorram2 = new byte[0x400];
Generic.spriteram = new byte[0x80]; Generic.spriteram_set = new byte[0x80];
Generic.paletteram = new byte[0x200]; Generic.paletteram_set = new byte[0x200];
if (Memory.mainrom_IsNull || mainromop == null || Memory.audiorom_IsNull || gfx1rom == null || gfx2rom == null || gfx3rom == null || gfx32rom == null) if (Memory.mainrom_IsNull || mainromop == null || Memory.audiorom_IsNull || gfx1rom == null || gfx2rom == null || gfx3rom == null || gfx32rom == null)
{ {
Machine.bRom = false; Machine.bRom = false;

View File

@ -57,12 +57,12 @@ namespace MAME.Core
Palette.entry_color[i] = reader.ReadUInt32(); Palette.entry_color[i] = reader.ReadUInt32();
} }
Memory.Set_mainram(reader.ReadBytes(0x1000)); Memory.Set_mainram(reader.ReadBytes(0x1000));
Generic.videoram = reader.ReadBytes(0x400); Generic.videoram_set = reader.ReadBytes(0x400);
pbaction_videoram2 = reader.ReadBytes(0x400); pbaction_videoram2 = reader.ReadBytes(0x400);
Generic.colorram = reader.ReadBytes(0x400); Generic.colorram_set = reader.ReadBytes(0x400);
pbaction_colorram2 = reader.ReadBytes(0x400); pbaction_colorram2 = reader.ReadBytes(0x400);
Generic.spriteram = reader.ReadBytes(0x80); Generic.spriteram_set = reader.ReadBytes(0x80);
Generic.paletteram = reader.ReadBytes(0x200); Generic.paletteram_set = reader.ReadBytes(0x200);
Memory.Set_audioram(reader.ReadBytes(0x800)); Memory.Set_audioram(reader.ReadBytes(0x800));
Z80A.zz1[0].LoadStateBinary(reader); Z80A.zz1[0].LoadStateBinary(reader);
Z80A.zz1[1].LoadStateBinary(reader); Z80A.zz1[1].LoadStateBinary(reader);

View File

@ -1,6 +1,6 @@
namespace MAME.Core namespace MAME.Core
{ {
public partial class Tehkan public unsafe partial class Tehkan
{ {
public static byte[] pbaction_videoram2, pbaction_colorram2; public static byte[] pbaction_videoram2, pbaction_colorram2;
public static int scroll; public static int scroll;

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>SafeCust</Title>
<Shortcut>safecust</Shortcut>
<Description>SafeCust for C#Array.</Description>
<Author>YourName</Author>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>PtrDataname</ID>
<ToolTip>Name of the delegate</ToolTip>
<Default>PtrDataname</Default>
</Literal>
<Literal>
<ID>PtrDataType</ID>
<ToolTip>Type</ToolTip>
<Default>byte</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
#region //指针化$PtrDataname$
static $PtrDataType$[] $PtrDataname$_src;
static GCHandle $PtrDataname$_handle;
public static $PtrDataType$* $PtrDataname$;
public static int $PtrDataname$Length;
public static $PtrDataType$[] $PtrDataname$_set
{
set
{
$PtrDataname$_handle.ReleaseGCHandle();
$PtrDataname$_src = value;
$PtrDataname$Length = value.Length;
$PtrDataname$_src.GetObjectPtr(ref $PtrDataname$_handle, ref $PtrDataname$);
}
}
#endregion
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Runtime.InteropServices</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>