From c457e27bac253056ff8a314b12531bd5d56febf0 Mon Sep 17 00:00:00 2001
From: sin365 <353374337@qq.com>
Date: Wed, 17 Sep 2025 18:33:21 +0800
Subject: [PATCH] =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=B8=8D=E5=BF=85=E8=A6=81?=
=?UTF-8?q?=E7=9A=84=E8=AE=BF=E9=97=AE=E5=99=A8=E5=A0=86=E6=A0=88=E5=BC=80?=
=?UTF-8?q?=E9=94=80=EF=BC=8C=E5=AE=8C=E5=85=A8=E6=8C=87=E9=92=88=E5=8C=96?=
=?UTF-8?q?entry=5Fcolor=E8=AF=BB=E5=86=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cpu/m68000/Instructions/IntegerMath.cs | 2 +-
.../cpu/m68000/Instructions/ProgramFlow.cs | 2 +-
.../cpu/m68000/Instructions/Supervisor.cs | 10 ++--
.../Plugins/Mame.Core/cpu/m68000/MC68000.cs | 25 +++++-----
.../Assets/Plugins/Mame.Core/emu/Motion.cs | 2 +-
.../Assets/Plugins/Mame.Core/emu/Palette.cs | 48 +++++++++++++------
.../Plugins/Mame.Core/mame/tehkan/State.cs | 2 +-
7 files changed, 55 insertions(+), 36 deletions(-)
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs
index f3b62ef4..df5368ee 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs
@@ -632,7 +632,7 @@ namespace cpu.m68000
void STOP()
{
- if (S)
+ if (s)
{
short new_sr = ReadOpWord(PC); PC += 2;
stopped = true;
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs
index 1fce1578..413fa95f 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs
@@ -169,7 +169,7 @@ namespace cpu.m68000
void RESET()
{
- if (S)
+ if (s)
{
pendingCycles -= 132;
}
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs
index 9c174418..147218e4 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs
@@ -8,7 +8,7 @@ namespace cpu.m68000
{
int mode = (op >> 3) & 7;
int reg = (op >> 0) & 7;
- if (S == false)
+ if (s == false)
{
//throw new Exception("Write to SR when not in supervisor mode. supposed to trap or something...");
TrapVector2(8);
@@ -54,7 +54,7 @@ namespace cpu.m68000
{
int dir = (op >> 3) & 1;
int reg = op & 7;
- if (S == false)
+ if (s == false)
{
//throw new Exception("MOVE to USP when not supervisor. needs to trap");
TrapVector2(8);
@@ -76,7 +76,7 @@ namespace cpu.m68000
void ANDI_SR()
{
- if (S == false)
+ if (s == false)
throw new Exception("trap!");
SR &= ReadOpWord(PC); PC += 2;
pendingCycles -= 20;
@@ -85,7 +85,7 @@ namespace cpu.m68000
void EORI_SR()
{
- if (S == false)
+ if (s == false)
throw new Exception("trap!");
SR ^= ReadOpWord(PC); PC += 2;
pendingCycles -= 20;
@@ -94,7 +94,7 @@ namespace cpu.m68000
void ORI_SR()
{
- if (S == false)
+ if (s == false)
throw new Exception("trap!");
SR |= ReadOpWord(PC); PC += 2;
pendingCycles -= 20;
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs
index 1856266d..f14db677 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs
@@ -45,7 +45,7 @@ namespace cpu.m68000
public bool stopped;
/// Machine/Interrupt mode
- public bool M { get { return m; } set { m = value; } } // TODO probably have some switch logic maybe
+ //public bool M { get { return m; } set { m = value; } } // TODO probably have some switch logic maybe
public void SetS(bool b1)
{
@@ -60,10 +60,11 @@ namespace cpu.m68000
/// Supervisor/User mode
public bool S
{
- get
- {
- return s;
- }
+ //减少不必要的访问器堆栈
+ //get
+ //{
+ // return s;
+ //}
set
{
if (value == s)
@@ -109,8 +110,8 @@ namespace cpu.m68000
if (Z) value |= 0x0004;
if (N) value |= 0x0008;
if (X) value |= 0x0010;
- if (M) value |= 0x1000;
- if (S) value |= 0x2000;
+ if (m) value |= 0x1000;
+ if (s) value |= 0x2000;
value |= (short)((InterruptMaskLevel & 7) << 8);
return value;
}
@@ -121,7 +122,7 @@ namespace cpu.m68000
Z = (value & 0x0004) != 0;
N = (value & 0x0008) != 0;
X = (value & 0x0010) != 0;
- M = (value & 0x1000) != 0;
+ m = (value & 0x1000) != 0;
S = (value & 0x2000) != 0;
InterruptMaskLevel = (value >> 8) & 7;
//m68ki_check_interrupts();
@@ -197,7 +198,7 @@ namespace cpu.m68000
stopped = false;
pendingCycles = 0;
S = true;
- M = false;
+ m = false;
InterruptMaskLevel = 7;
Interrupt = 0;
A[7].s32 = ReadOpLong(0);
@@ -287,8 +288,8 @@ namespace cpu.m68000
}
writer.Write(MC68000.m1.PPC);
writer.Write(MC68000.m1.PC);
- writer.Write(MC68000.m1.S);
- writer.Write(MC68000.m1.M);
+ writer.Write(MC68000.m1.s);
+ writer.Write(MC68000.m1.m);
writer.Write(MC68000.m1.X);
writer.Write(MC68000.m1.N);
writer.Write(MC68000.m1.Z);
@@ -317,7 +318,7 @@ namespace cpu.m68000
MC68000.m1.PPC = reader.ReadInt32();
MC68000.m1.PC = reader.ReadInt32();
MC68000.m1.SetS(reader.ReadBoolean());
- MC68000.m1.M = reader.ReadBoolean();
+ MC68000.m1.m = reader.ReadBoolean();
MC68000.m1.X = reader.ReadBoolean();
MC68000.m1.N = reader.ReadBoolean();
MC68000.m1.Z = reader.ReadBoolean();
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs
index afd81e1f..a363ee62 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs
@@ -93,7 +93,7 @@
//ushort* curbitmap = curbitmapPtr;
ushort* curbitmap = (ushort*)Video.bitmapbase_Ptrs[Video.curbitmap];
//uint* entry_color = entry_colorPtr;
- uint* entry_color = (uint*)Palette.entry_color_Ptr;
+ uint* entry_color = (uint*)Palette.entry_color;
//int* bitmapcolorRect = bitmapcolorRectPtr;
int* bitmapcolorRect = (int*)Video.bitmapcolorRect_Ptr;
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Palette.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Palette.cs
index a89203df..591c4fa9 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Palette.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Palette.cs
@@ -3,13 +3,28 @@ using System.Runtime.InteropServices;
namespace MAME.Core
{
- public class Palette
+ public unsafe class Palette
{
- public static uint[] entry_color;
- /** entry_color的指针管理 **/
+ //public static uint[] entry_color;
+
+ #region //指针化 entry_color
+ static uint[] entry_color_src;
static GCHandle entry_color_handle;
- public static IntPtr entry_color_Ptr;
- /** end **/
+ public static uint* entry_color;
+ public static int entry_colorLength;
+ public static bool entry_color_IsNull => entry_color == null;
+ public static uint[] entry_color_set
+ {
+ set
+ {
+ entry_color_handle.ReleaseGCHandle();
+ entry_color_src = value;
+ entry_colorLength = value.Length;
+ entry_color_src.GetObjectPtr(ref entry_color_handle, ref entry_color);
+ }
+ }
+ #endregion
+
public static float[] entry_contrast;
private static uint trans_uint;
@@ -174,18 +189,21 @@ namespace MAME.Core
//entry_color = new uint[numcolors];
+ entry_color_set = new uint[numcolors];
- /** entry_color的指针管理 **/
- // 释放句柄
- if (entry_color != null && entry_color_handle.IsAllocated)
- entry_color_handle.Free();
+ ///** entry_color的指针管理 **/
+ //// 释放句柄
+ //if (entry_color != null && entry_color_handle.IsAllocated)
+ // entry_color_handle.Free();
+
+ //entry_color = new uint[numcolors];
+ //// 固定数组,防止垃圾回收器移动它
+ //entry_color_handle = GCHandle.Alloc(entry_color, GCHandleType.Pinned);
+ //// 获取数组的指针
+ //entry_color_Ptr = entry_color_handle.AddrOfPinnedObject();
+ ///** end **/
+ ///
- entry_color = new uint[numcolors];
- // 固定数组,防止垃圾回收器移动它
- entry_color_handle = GCHandle.Alloc(entry_color, GCHandleType.Pinned);
- // 获取数组的指针
- entry_color_Ptr = entry_color_handle.AddrOfPinnedObject();
- /** end **/
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/tehkan/State.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/tehkan/State.cs
index 1fd321ca..ae9906ab 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/tehkan/State.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/tehkan/State.cs
@@ -45,7 +45,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
- public static void LoadStateBinary_pbaction(System.IO.BinaryReader reader)
+ public unsafe static void LoadStateBinary_pbaction(System.IO.BinaryReader reader)
{
int i;
dsw1 = reader.ReadByte();