MAME:放弃Switch调度NEC的CPU指令,改为委托数组 | 完善MAME的 cpu timer回收

This commit is contained in:
sin365 2025-11-07 17:30:46 +08:00
parent 1aec567eb2
commit b30df60365
11 changed files with 1364 additions and 1225 deletions

View File

@ -130,10 +130,10 @@ namespace cpu.nec
public Action<int, byte> WriteIOByte; public Action<int, byte> WriteIOByte;
public Func<int, ushort> ReadIOWord; public Func<int, ushort> ReadIOWord;
public Action<int, ushort> WriteIOWord; public Action<int, ushort> WriteIOWord;
//public delegate void nec_delegate(); public delegate void nec_delegate();
//public nec_delegate[] nec_instruction; public nec_delegate[] nec_instruction;
//public delegate int getea_delegate(); public delegate int getea_delegate();
//public getea_delegate[] GetEA; public getea_delegate[] GetEA;
public Nec() public Nec()
{ {
nec_init(); nec_init();
@ -483,8 +483,8 @@ namespace cpu.nec
} }
else else
{ {
//EA = GetEA[ModRM](); EA = GetEA[ModRM]();
EA = DoNecGetEAOpCode(ModRM); //EA = DoNecGetEAOpCode(ModRM);
tmp = ReadByte(EA); tmp = ReadByte(EA);
} }
} }
@ -497,8 +497,8 @@ namespace cpu.nec
} }
else else
{ {
//EA = GetEA[ModRM](); EA = GetEA[ModRM]();
EA = DoNecGetEAOpCode(ModRM); //EA = DoNecGetEAOpCode(ModRM);
tmp = ReadWord(EA); tmp = ReadWord(EA);
} }
} }
@ -796,6 +796,7 @@ namespace cpu.nec
di++; di++;
} }
} }
public void nec_init() public void nec_init()
{ {
mod_RM = new Mod_RM(); mod_RM = new Mod_RM();
@ -803,8 +804,6 @@ namespace cpu.nec
mod_RM.regb = new int[256]; mod_RM.regb = new int[256];
mod_RM.RMw = new int[256]; mod_RM.RMw = new int[256];
mod_RM.RMb = new int[256]; mod_RM.RMb = new int[256];
//更换调度方式不再依赖Delegate委托
/*
nec_instruction = new nec_delegate[]{ nec_instruction = new nec_delegate[]{
i_add_br8, i_add_br8,
i_add_wr16, i_add_wr16,
@ -1063,9 +1062,7 @@ namespace cpu.nec
i_fepre, i_fepre,
i_ffpre i_ffpre
}; };
*/
/*
GetEA = new getea_delegate[192]{ GetEA = new getea_delegate[192]{
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
@ -1094,7 +1091,6 @@ namespace cpu.nec
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207, EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207 EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207
}; };
*/
} }
public override void Reset() public override void Reset()
{ {
@ -1196,8 +1192,8 @@ namespace cpu.nec
} }
public void nec_trap() public void nec_trap()
{ {
//nec_instruction[fetchop()](); nec_instruction[fetchop()]();
DoInstructionOpCode(fetchop()); //DoInstructionOpCode(fetchop());
nec_interrupt(1, false); nec_interrupt(1, false);
} }
public void external_int() public void external_int()
@ -1306,8 +1302,8 @@ namespace cpu.nec
I.no_interrupt--; I.no_interrupt--;
} }
iNOP = fetchop(); iNOP = fetchop();
//nec_instruction[iNOP](); nec_instruction[iNOP]();
DoInstructionOpCode(iNOP); //DoInstructionOpCode(iNOP);
int delta = prevCycles - pendingCycles; int delta = prevCycles - pendingCycles;
totalExecutedCycles += (ulong)delta; totalExecutedCycles += (ulong)delta;
} }
@ -1347,8 +1343,8 @@ namespace cpu.nec
I.no_interrupt--; I.no_interrupt--;
} }
iNOP = fetchop(); iNOP = fetchop();
//nec_instruction[iNOP](); nec_instruction[iNOP]();
DoInstructionOpCode(iNOP); //DoInstructionOpCode(iNOP);
int delta = prevCycles - pendingCycles; int delta = prevCycles - pendingCycles;
totalExecutedCycles += (ulong)delta; totalExecutedCycles += (ulong)delta;
} }

View File

@ -372,8 +372,8 @@
seg_prefix = 1; seg_prefix = 1;
prefix_base = I.sregs[0] << 4; prefix_base = I.sregs[0] << 4;
CLK(2); CLK(2);
//nec_instruction[fetchop()](); nec_instruction[fetchop()]();
DoInstructionOpCode(fetchop()); //DoInstructionOpCode(fetchop());
seg_prefix = 0; seg_prefix = 0;
} }
void i_daa() void i_daa()
@ -442,8 +442,8 @@
seg_prefix = 1; seg_prefix = 1;
prefix_base = I.sregs[1] << 4; prefix_base = I.sregs[1] << 4;
CLK(2); CLK(2);
//nec_instruction[fetchop()](); nec_instruction[fetchop()]();
DoInstructionOpCode(fetchop()); //DoInstructionOpCode(fetchop());
seg_prefix = 0; seg_prefix = 0;
} }
void i_das() void i_das()
@ -512,8 +512,8 @@
seg_prefix = 1; seg_prefix = 1;
prefix_base = I.sregs[2] << 4; prefix_base = I.sregs[2] << 4;
CLK(2); CLK(2);
//nec_instruction[fetchop()](); nec_instruction[fetchop()]();
DoInstructionOpCode(fetchop()); //DoInstructionOpCode(fetchop());
seg_prefix = 0; seg_prefix = 0;
} }
void i_aaa() void i_aaa()
@ -572,8 +572,8 @@
seg_prefix = 1; seg_prefix = 1;
prefix_base = I.sregs[3] << 4; prefix_base = I.sregs[3] << 4;
CLK(2); CLK(2);
//nec_instruction[fetchop()](); nec_instruction[fetchop()]();
DoInstructionOpCode(fetchop()); //DoInstructionOpCode(fetchop());
seg_prefix = 0; seg_prefix = 0;
} }
void i_aas() void i_aas()
@ -844,8 +844,8 @@
case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && !CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && !CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && !CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && !CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
default: default:
//nec_instruction[next](); nec_instruction[next]();
DoInstructionOpCode(next); //DoInstructionOpCode(next);
break; break;
} }
seg_prefix = 0; seg_prefix = 0;
@ -878,8 +878,8 @@
case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
default: default:
//nec_instruction[next](); nec_instruction[next]();
DoInstructionOpCode(next); //DoInstructionOpCode(next);
break; break;
} }
seg_prefix = 0; seg_prefix = 0;
@ -1325,8 +1325,8 @@
void i_lea() void i_lea()
{ {
int ModRM = FETCH(); int ModRM = FETCH();
//GetEA[ModRM](); GetEA[ModRM]();
DoNecGetEAOpCode(ModRM); //DoNecGetEAOpCode(ModRM);
//I.regs.w[mod_RM.regw[ModRM]] = EO; //I.regs.w[mod_RM.regw[ModRM]] = EO;
@ -2217,8 +2217,8 @@
case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && ZF() == false); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && ZF() == false); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && ZF() == false); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && ZF() == false); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
default: default:
//nec_instruction[next](); nec_instruction[next]();
DoInstructionOpCode(next); //DoInstructionOpCode(next);
break; break;
} }
seg_prefix = 0; seg_prefix = 0;
@ -2251,8 +2251,8 @@
case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && ZF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && ZF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && ZF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && ZF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break;
default: default:
//nec_instruction[next](); nec_instruction[next]();
DoInstructionOpCode(next); //DoInstructionOpCode(next);
break; break;
} }
seg_prefix = 0; seg_prefix = 0;

View File

@ -14,8 +14,8 @@
{ {
return (ushort)(ModRM >= 0xc0 ? I.regs.b[mod_RM.RMw[ModRM] * 2] + I.regs.b[mod_RM.RMw[ModRM] * 2 + 1] * 0x100 : return (ushort)(ModRM >= 0xc0 ? I.regs.b[mod_RM.RMw[ModRM] * 2] + I.regs.b[mod_RM.RMw[ModRM] * 2 + 1] * 0x100 :
ReadWord( ReadWord(
//GetEA[ModRM]() GetEA[ModRM]()
DoNecGetEAOpCode(ModRM) //DoNecGetEAOpCode(ModRM)
)); ));
} }
void PutbackRMWord(int ModRM, ushort val) void PutbackRMWord(int ModRM, ushort val)
@ -46,8 +46,8 @@
else else
{ {
WriteWord( WriteWord(
//GetEA[ModRM]() GetEA[ModRM]()
DoNecGetEAOpCode(ModRM) //DoNecGetEAOpCode(ModRM)
, val); , val);
} }
} }
@ -63,8 +63,8 @@
} }
else else
{ {
//EA = GetEA[ModRM](); EA = GetEA[ModRM]();
EA = DoNecGetEAOpCode(ModRM); //EA = DoNecGetEAOpCode(ModRM);
val = FETCHWORD(); val = FETCHWORD();
WriteWord(EA, val); WriteWord(EA, val);
} }
@ -72,8 +72,8 @@
byte GetRMByte(int ModRM) byte GetRMByte(int ModRM)
{ {
return ((ModRM) >= 0xc0 ? I.regs.b[mod_RM.RMb[ModRM]] : ReadByte( return ((ModRM) >= 0xc0 ? I.regs.b[mod_RM.RMb[ModRM]] : ReadByte(
//GetEA[ModRM]() GetEA[ModRM]()
DoNecGetEAOpCode(ModRM) //DoNecGetEAOpCode(ModRM)
)); ));
} }
void PutRMByte(int ModRM, byte val) void PutRMByte(int ModRM, byte val)
@ -85,8 +85,8 @@
else else
{ {
WriteByte( WriteByte(
//GetEA[ModRM]() GetEA[ModRM]()
DoNecGetEAOpCode(ModRM) //DoNecGetEAOpCode(ModRM)
, val); , val);
} }
} }
@ -98,8 +98,8 @@
} }
else else
{ {
//EA = GetEA[ModRM](); EA = GetEA[ModRM]();
EA = DoNecGetEAOpCode(ModRM); //EA = DoNecGetEAOpCode(ModRM);
WriteByte(EA, FETCH()); WriteByte(EA, FETCH());
} }
} }

View File

@ -3,42 +3,42 @@
public partial class Nec public partial class Nec
{ {
/// <summary> ///// <summary>
/// 重写的Nec GetEAOpCode指令调度 ///// 重写的Nec GetEAOpCode指令调度
/// </summary> ///// </summary>
/// <param name="op"></param> ///// <param name="op"></param>
public int DoNecGetEAOpCode(int op) //public int DoNecGetEAOpCode(int op)
{ //{
NecGetEAOpCode opType = NecGetEAOpCodeArr[op]; // NecGetEAOpCode opType = NecGetEAOpCodeArr[op];
switch (opType) // switch (opType)
{ // {
case NecGetEAOpCode.EA_000: return EA_000(); // case NecGetEAOpCode.EA_000: return EA_000();
case NecGetEAOpCode.EA_001: return EA_001(); // case NecGetEAOpCode.EA_001: return EA_001();
case NecGetEAOpCode.EA_002: return EA_002(); // case NecGetEAOpCode.EA_002: return EA_002();
case NecGetEAOpCode.EA_003: return EA_003(); // case NecGetEAOpCode.EA_003: return EA_003();
case NecGetEAOpCode.EA_004: return EA_004(); // case NecGetEAOpCode.EA_004: return EA_004();
case NecGetEAOpCode.EA_005: return EA_005(); // case NecGetEAOpCode.EA_005: return EA_005();
case NecGetEAOpCode.EA_006: return EA_006(); // case NecGetEAOpCode.EA_006: return EA_006();
case NecGetEAOpCode.EA_007: return EA_007(); // case NecGetEAOpCode.EA_007: return EA_007();
case NecGetEAOpCode.EA_100: return EA_100(); // case NecGetEAOpCode.EA_100: return EA_100();
case NecGetEAOpCode.EA_101: return EA_101(); // case NecGetEAOpCode.EA_101: return EA_101();
case NecGetEAOpCode.EA_102: return EA_102(); // case NecGetEAOpCode.EA_102: return EA_102();
case NecGetEAOpCode.EA_103: return EA_103(); // case NecGetEAOpCode.EA_103: return EA_103();
case NecGetEAOpCode.EA_104: return EA_104(); // case NecGetEAOpCode.EA_104: return EA_104();
case NecGetEAOpCode.EA_105: return EA_105(); // case NecGetEAOpCode.EA_105: return EA_105();
case NecGetEAOpCode.EA_106: return EA_106(); // case NecGetEAOpCode.EA_106: return EA_106();
case NecGetEAOpCode.EA_107: return EA_107(); // case NecGetEAOpCode.EA_107: return EA_107();
case NecGetEAOpCode.EA_200: return EA_200(); // case NecGetEAOpCode.EA_200: return EA_200();
case NecGetEAOpCode.EA_201: return EA_201(); // case NecGetEAOpCode.EA_201: return EA_201();
case NecGetEAOpCode.EA_202: return EA_202(); // case NecGetEAOpCode.EA_202: return EA_202();
case NecGetEAOpCode.EA_203: return EA_203(); // case NecGetEAOpCode.EA_203: return EA_203();
case NecGetEAOpCode.EA_204: return EA_204(); // case NecGetEAOpCode.EA_204: return EA_204();
case NecGetEAOpCode.EA_205: return EA_205(); // case NecGetEAOpCode.EA_205: return EA_205();
case NecGetEAOpCode.EA_206: return EA_206(); // case NecGetEAOpCode.EA_206: return EA_206();
case NecGetEAOpCode.EA_207: return EA_207(); // case NecGetEAOpCode.EA_207: return EA_207();
default: // default:
throw new System.Exception("NecGetEAOpCode Err"); // throw new System.Exception("NecGetEAOpCode Err");
} // }
} //}
} }
} }

View File

@ -2,232 +2,230 @@
{ {
partial class Nec partial class Nec
{ {
/// <summary> ///// <summary>
/// 自定义Nec GetEA 指令集枚举 ///// 自定义Nec GetEA 指令集枚举
/// </summary> ///// </summary>
public enum NecGetEAOpCode : byte //public enum NecGetEAOpCode : byte
{ //{
EA_000, // EA_000,
EA_001, // EA_001,
EA_002, // EA_002,
EA_003, // EA_003,
EA_004, // EA_004,
EA_005, // EA_005,
EA_006, // EA_006,
EA_007, // EA_007,
EA_100, // EA_100,
EA_101, // EA_101,
EA_102, // EA_102,
EA_103, // EA_103,
EA_104, // EA_104,
EA_105, // EA_105,
EA_106, // EA_106,
EA_107, // EA_107,
EA_200, // EA_200,
EA_201, // EA_201,
EA_202, // EA_202,
EA_203, // EA_203,
EA_204, // EA_204,
EA_205, // EA_205,
EA_206, // EA_206,
EA_207 // EA_207
} //}
//static readonly NecGetEAOpCode[] NecGetEAOpCodeArr = new NecGetEAOpCode[]
// {
static readonly NecGetEAOpCode[] NecGetEAOpCodeArr = new NecGetEAOpCode[] // NecGetEAOpCode.EA_000,
{ // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_000,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_001,
NecGetEAOpCode.EA_000, // NecGetEAOpCode.EA_002,
NecGetEAOpCode.EA_001, // NecGetEAOpCode.EA_003,
NecGetEAOpCode.EA_002, // NecGetEAOpCode.EA_004,
NecGetEAOpCode.EA_003, // NecGetEAOpCode.EA_005,
NecGetEAOpCode.EA_004, // NecGetEAOpCode.EA_006,
NecGetEAOpCode.EA_005, // NecGetEAOpCode.EA_007,
NecGetEAOpCode.EA_006, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_007, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_100,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_101,
NecGetEAOpCode.EA_100, // NecGetEAOpCode.EA_102,
NecGetEAOpCode.EA_101, // NecGetEAOpCode.EA_103,
NecGetEAOpCode.EA_102, // NecGetEAOpCode.EA_104,
NecGetEAOpCode.EA_103, // NecGetEAOpCode.EA_105,
NecGetEAOpCode.EA_104, // NecGetEAOpCode.EA_106,
NecGetEAOpCode.EA_105, // NecGetEAOpCode.EA_107,
NecGetEAOpCode.EA_106, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_107, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207,
NecGetEAOpCode.EA_206, // NecGetEAOpCode.EA_200,
NecGetEAOpCode.EA_207, // NecGetEAOpCode.EA_201,
NecGetEAOpCode.EA_200, // NecGetEAOpCode.EA_202,
NecGetEAOpCode.EA_201, // NecGetEAOpCode.EA_203,
NecGetEAOpCode.EA_202, // NecGetEAOpCode.EA_204,
NecGetEAOpCode.EA_203, // NecGetEAOpCode.EA_205,
NecGetEAOpCode.EA_204, // NecGetEAOpCode.EA_206,
NecGetEAOpCode.EA_205, // NecGetEAOpCode.EA_207
NecGetEAOpCode.EA_206, // };
NecGetEAOpCode.EA_207
};
}; };
} }

View File

@ -3,263 +3,263 @@
public partial class Nec public partial class Nec
{ {
/// <summary> ///// <summary>
/// 重写的Nec Instruction指令调度 ///// 重写的Nec Instruction指令调度
/// </summary> ///// </summary>
/// <param name="op"></param> ///// <param name="op"></param>
public void DoInstructionOpCode(int op) //public void DoInstructionOpCode(int op)
{ //{
NecInstructionOpCode opType = NecInstructionOpCodeArr[op]; // NecInstructionOpCode opType = NecInstructionOpCodeArr[op];
switch (opType) // switch (opType)
{ // {
case NecInstructionOpCode.i_add_br8: i_add_br8(); return; // case NecInstructionOpCode.i_add_br8: i_add_br8(); return;
case NecInstructionOpCode.i_add_wr16: i_add_wr16(); return; // case NecInstructionOpCode.i_add_wr16: i_add_wr16(); return;
case NecInstructionOpCode.i_add_r8b: i_add_r8b(); return; // case NecInstructionOpCode.i_add_r8b: i_add_r8b(); return;
case NecInstructionOpCode.i_add_r16w: i_add_r16w(); return; // case NecInstructionOpCode.i_add_r16w: i_add_r16w(); return;
case NecInstructionOpCode.i_add_ald8: i_add_ald8(); return; // case NecInstructionOpCode.i_add_ald8: i_add_ald8(); return;
case NecInstructionOpCode.i_add_axd16: i_add_axd16(); return; // case NecInstructionOpCode.i_add_axd16: i_add_axd16(); return;
case NecInstructionOpCode.i_push_es: i_push_es(); return; // case NecInstructionOpCode.i_push_es: i_push_es(); return;
case NecInstructionOpCode.i_pop_es: i_pop_es(); return; // case NecInstructionOpCode.i_pop_es: i_pop_es(); return;
case NecInstructionOpCode.i_or_br8: i_or_br8(); return; // case NecInstructionOpCode.i_or_br8: i_or_br8(); return;
case NecInstructionOpCode.i_or_wr16: i_or_wr16(); return; // case NecInstructionOpCode.i_or_wr16: i_or_wr16(); return;
case NecInstructionOpCode.i_or_r8b: i_or_r8b(); return; // case NecInstructionOpCode.i_or_r8b: i_or_r8b(); return;
case NecInstructionOpCode.i_or_r16w: i_or_r16w(); return; // case NecInstructionOpCode.i_or_r16w: i_or_r16w(); return;
case NecInstructionOpCode.i_or_ald8: i_or_ald8(); return; // case NecInstructionOpCode.i_or_ald8: i_or_ald8(); return;
case NecInstructionOpCode.i_or_axd16: i_or_axd16(); return; // case NecInstructionOpCode.i_or_axd16: i_or_axd16(); return;
case NecInstructionOpCode.i_push_cs: i_push_cs(); return; // case NecInstructionOpCode.i_push_cs: i_push_cs(); return;
case NecInstructionOpCode.i_pre_nec: i_pre_nec(); return; // case NecInstructionOpCode.i_pre_nec: i_pre_nec(); return;
case NecInstructionOpCode.i_adc_br8: i_adc_br8(); return; // case NecInstructionOpCode.i_adc_br8: i_adc_br8(); return;
case NecInstructionOpCode.i_adc_wr16: i_adc_wr16(); return; // case NecInstructionOpCode.i_adc_wr16: i_adc_wr16(); return;
case NecInstructionOpCode.i_adc_r8b: i_adc_r8b(); return; // case NecInstructionOpCode.i_adc_r8b: i_adc_r8b(); return;
case NecInstructionOpCode.i_adc_r16w: i_adc_r16w(); return; // case NecInstructionOpCode.i_adc_r16w: i_adc_r16w(); return;
case NecInstructionOpCode.i_adc_ald8: i_adc_ald8(); return; // case NecInstructionOpCode.i_adc_ald8: i_adc_ald8(); return;
case NecInstructionOpCode.i_adc_axd16: i_adc_axd16(); return; // case NecInstructionOpCode.i_adc_axd16: i_adc_axd16(); return;
case NecInstructionOpCode.i_push_ss: i_push_ss(); return; // case NecInstructionOpCode.i_push_ss: i_push_ss(); return;
case NecInstructionOpCode.i_pop_ss: i_pop_ss(); return; // case NecInstructionOpCode.i_pop_ss: i_pop_ss(); return;
case NecInstructionOpCode.i_sbb_br8: i_sbb_br8(); return; // case NecInstructionOpCode.i_sbb_br8: i_sbb_br8(); return;
case NecInstructionOpCode.i_sbb_wr16: i_sbb_wr16(); return; // case NecInstructionOpCode.i_sbb_wr16: i_sbb_wr16(); return;
case NecInstructionOpCode.i_sbb_r8b: i_sbb_r8b(); return; // case NecInstructionOpCode.i_sbb_r8b: i_sbb_r8b(); return;
case NecInstructionOpCode.i_sbb_r16w: i_sbb_r16w(); return; // case NecInstructionOpCode.i_sbb_r16w: i_sbb_r16w(); return;
case NecInstructionOpCode.i_sbb_ald8: i_sbb_ald8(); return; // case NecInstructionOpCode.i_sbb_ald8: i_sbb_ald8(); return;
case NecInstructionOpCode.i_sbb_axd16: i_sbb_axd16(); return; // case NecInstructionOpCode.i_sbb_axd16: i_sbb_axd16(); return;
case NecInstructionOpCode.i_push_ds: i_push_ds(); return; // case NecInstructionOpCode.i_push_ds: i_push_ds(); return;
case NecInstructionOpCode.i_pop_ds: i_pop_ds(); return; // case NecInstructionOpCode.i_pop_ds: i_pop_ds(); return;
case NecInstructionOpCode.i_and_br8: i_and_br8(); return; // case NecInstructionOpCode.i_and_br8: i_and_br8(); return;
case NecInstructionOpCode.i_and_wr16: i_and_wr16(); return; // case NecInstructionOpCode.i_and_wr16: i_and_wr16(); return;
case NecInstructionOpCode.i_and_r8b: i_and_r8b(); return; // case NecInstructionOpCode.i_and_r8b: i_and_r8b(); return;
case NecInstructionOpCode.i_and_r16w: i_and_r16w(); return; // case NecInstructionOpCode.i_and_r16w: i_and_r16w(); return;
case NecInstructionOpCode.i_and_ald8: i_and_ald8(); return; // case NecInstructionOpCode.i_and_ald8: i_and_ald8(); return;
case NecInstructionOpCode.i_and_axd16: i_and_axd16(); return; // case NecInstructionOpCode.i_and_axd16: i_and_axd16(); return;
case NecInstructionOpCode.i_es: i_es(); return; // case NecInstructionOpCode.i_es: i_es(); return;
case NecInstructionOpCode.i_daa: i_daa(); return; // case NecInstructionOpCode.i_daa: i_daa(); return;
case NecInstructionOpCode.i_sub_br8: i_sub_br8(); return; // case NecInstructionOpCode.i_sub_br8: i_sub_br8(); return;
case NecInstructionOpCode.i_sub_wr16: i_sub_wr16(); return; // case NecInstructionOpCode.i_sub_wr16: i_sub_wr16(); return;
case NecInstructionOpCode.i_sub_r8b: i_sub_r8b(); return; // case NecInstructionOpCode.i_sub_r8b: i_sub_r8b(); return;
case NecInstructionOpCode.i_sub_r16w: i_sub_r16w(); return; // case NecInstructionOpCode.i_sub_r16w: i_sub_r16w(); return;
case NecInstructionOpCode.i_sub_ald8: i_sub_ald8(); return; // case NecInstructionOpCode.i_sub_ald8: i_sub_ald8(); return;
case NecInstructionOpCode.i_sub_axd16: i_sub_axd16(); return; // case NecInstructionOpCode.i_sub_axd16: i_sub_axd16(); return;
case NecInstructionOpCode.i_cs: i_cs(); return; // case NecInstructionOpCode.i_cs: i_cs(); return;
case NecInstructionOpCode.i_das: i_das(); return; // case NecInstructionOpCode.i_das: i_das(); return;
case NecInstructionOpCode.i_xor_br8: i_xor_br8(); return; // case NecInstructionOpCode.i_xor_br8: i_xor_br8(); return;
case NecInstructionOpCode.i_xor_wr16: i_xor_wr16(); return; // case NecInstructionOpCode.i_xor_wr16: i_xor_wr16(); return;
case NecInstructionOpCode.i_xor_r8b: i_xor_r8b(); return; // case NecInstructionOpCode.i_xor_r8b: i_xor_r8b(); return;
case NecInstructionOpCode.i_xor_r16w: i_xor_r16w(); return; // case NecInstructionOpCode.i_xor_r16w: i_xor_r16w(); return;
case NecInstructionOpCode.i_xor_ald8: i_xor_ald8(); return; // case NecInstructionOpCode.i_xor_ald8: i_xor_ald8(); return;
case NecInstructionOpCode.i_xor_axd16: i_xor_axd16(); return; // case NecInstructionOpCode.i_xor_axd16: i_xor_axd16(); return;
case NecInstructionOpCode.i_ss: i_ss(); return; // case NecInstructionOpCode.i_ss: i_ss(); return;
case NecInstructionOpCode.i_aaa: i_aaa(); return; // case NecInstructionOpCode.i_aaa: i_aaa(); return;
case NecInstructionOpCode.i_cmp_br8: i_cmp_br8(); return; // case NecInstructionOpCode.i_cmp_br8: i_cmp_br8(); return;
case NecInstructionOpCode.i_cmp_wr16: i_cmp_wr16(); return; // case NecInstructionOpCode.i_cmp_wr16: i_cmp_wr16(); return;
case NecInstructionOpCode.i_cmp_r8b: i_cmp_r8b(); return; // case NecInstructionOpCode.i_cmp_r8b: i_cmp_r8b(); return;
case NecInstructionOpCode.i_cmp_r16w: i_cmp_r16w(); return; // case NecInstructionOpCode.i_cmp_r16w: i_cmp_r16w(); return;
case NecInstructionOpCode.i_cmp_ald8: i_cmp_ald8(); return; // case NecInstructionOpCode.i_cmp_ald8: i_cmp_ald8(); return;
case NecInstructionOpCode.i_cmp_axd16: i_cmp_axd16(); return; // case NecInstructionOpCode.i_cmp_axd16: i_cmp_axd16(); return;
case NecInstructionOpCode.i_ds: i_ds(); return; // case NecInstructionOpCode.i_ds: i_ds(); return;
case NecInstructionOpCode.i_aas: i_aas(); return; // case NecInstructionOpCode.i_aas: i_aas(); return;
case NecInstructionOpCode.i_inc_ax: i_inc_ax(); return; // case NecInstructionOpCode.i_inc_ax: i_inc_ax(); return;
case NecInstructionOpCode.i_inc_cx: i_inc_cx(); return; // case NecInstructionOpCode.i_inc_cx: i_inc_cx(); return;
case NecInstructionOpCode.i_inc_dx: i_inc_dx(); return; // case NecInstructionOpCode.i_inc_dx: i_inc_dx(); return;
case NecInstructionOpCode.i_inc_bx: i_inc_bx(); return; // case NecInstructionOpCode.i_inc_bx: i_inc_bx(); return;
case NecInstructionOpCode.i_inc_sp: i_inc_sp(); return; // case NecInstructionOpCode.i_inc_sp: i_inc_sp(); return;
case NecInstructionOpCode.i_inc_bp: i_inc_bp(); return; // case NecInstructionOpCode.i_inc_bp: i_inc_bp(); return;
case NecInstructionOpCode.i_inc_si: i_inc_si(); return; // case NecInstructionOpCode.i_inc_si: i_inc_si(); return;
case NecInstructionOpCode.i_inc_di: i_inc_di(); return; // case NecInstructionOpCode.i_inc_di: i_inc_di(); return;
case NecInstructionOpCode.i_dec_ax: i_dec_ax(); return; // case NecInstructionOpCode.i_dec_ax: i_dec_ax(); return;
case NecInstructionOpCode.i_dec_cx: i_dec_cx(); return; // case NecInstructionOpCode.i_dec_cx: i_dec_cx(); return;
case NecInstructionOpCode.i_dec_dx: i_dec_dx(); return; // case NecInstructionOpCode.i_dec_dx: i_dec_dx(); return;
case NecInstructionOpCode.i_dec_bx: i_dec_bx(); return; // case NecInstructionOpCode.i_dec_bx: i_dec_bx(); return;
case NecInstructionOpCode.i_dec_sp: i_dec_sp(); return; // case NecInstructionOpCode.i_dec_sp: i_dec_sp(); return;
case NecInstructionOpCode.i_dec_bp: i_dec_bp(); return; // case NecInstructionOpCode.i_dec_bp: i_dec_bp(); return;
case NecInstructionOpCode.i_dec_si: i_dec_si(); return; // case NecInstructionOpCode.i_dec_si: i_dec_si(); return;
case NecInstructionOpCode.i_dec_di: i_dec_di(); return; // case NecInstructionOpCode.i_dec_di: i_dec_di(); return;
case NecInstructionOpCode.i_push_ax: i_push_ax(); return; // case NecInstructionOpCode.i_push_ax: i_push_ax(); return;
case NecInstructionOpCode.i_push_cx: i_push_cx(); return; // case NecInstructionOpCode.i_push_cx: i_push_cx(); return;
case NecInstructionOpCode.i_push_dx: i_push_dx(); return; // case NecInstructionOpCode.i_push_dx: i_push_dx(); return;
case NecInstructionOpCode.i_push_bx: i_push_bx(); return; // case NecInstructionOpCode.i_push_bx: i_push_bx(); return;
case NecInstructionOpCode.i_push_sp: i_push_sp(); return; // case NecInstructionOpCode.i_push_sp: i_push_sp(); return;
case NecInstructionOpCode.i_push_bp: i_push_bp(); return; // case NecInstructionOpCode.i_push_bp: i_push_bp(); return;
case NecInstructionOpCode.i_push_si: i_push_si(); return; // case NecInstructionOpCode.i_push_si: i_push_si(); return;
case NecInstructionOpCode.i_push_di: i_push_di(); return; // case NecInstructionOpCode.i_push_di: i_push_di(); return;
case NecInstructionOpCode.i_pop_ax: i_pop_ax(); return; // case NecInstructionOpCode.i_pop_ax: i_pop_ax(); return;
case NecInstructionOpCode.i_pop_cx: i_pop_cx(); return; // case NecInstructionOpCode.i_pop_cx: i_pop_cx(); return;
case NecInstructionOpCode.i_pop_dx: i_pop_dx(); return; // case NecInstructionOpCode.i_pop_dx: i_pop_dx(); return;
case NecInstructionOpCode.i_pop_bx: i_pop_bx(); return; // case NecInstructionOpCode.i_pop_bx: i_pop_bx(); return;
case NecInstructionOpCode.i_pop_sp: i_pop_sp(); return; // case NecInstructionOpCode.i_pop_sp: i_pop_sp(); return;
case NecInstructionOpCode.i_pop_bp: i_pop_bp(); return; // case NecInstructionOpCode.i_pop_bp: i_pop_bp(); return;
case NecInstructionOpCode.i_pop_si: i_pop_si(); return; // case NecInstructionOpCode.i_pop_si: i_pop_si(); return;
case NecInstructionOpCode.i_pop_di: i_pop_di(); return; // case NecInstructionOpCode.i_pop_di: i_pop_di(); return;
case NecInstructionOpCode.i_pusha: i_pusha(); return; // case NecInstructionOpCode.i_pusha: i_pusha(); return;
case NecInstructionOpCode.i_popa: i_popa(); return; // case NecInstructionOpCode.i_popa: i_popa(); return;
case NecInstructionOpCode.i_chkind: i_chkind(); return; // case NecInstructionOpCode.i_chkind: i_chkind(); return;
case NecInstructionOpCode.i_brkn: i_brkn(); return; // case NecInstructionOpCode.i_brkn: i_brkn(); return;
case NecInstructionOpCode.i_repnc: i_repnc(); return; // case NecInstructionOpCode.i_repnc: i_repnc(); return;
case NecInstructionOpCode.i_repc: i_repc(); return; // case NecInstructionOpCode.i_repc: i_repc(); return;
case NecInstructionOpCode.i_invalid: i_invalid(); return; // case NecInstructionOpCode.i_invalid: i_invalid(); return;
case NecInstructionOpCode.i_push_d16: i_push_d16(); return; // case NecInstructionOpCode.i_push_d16: i_push_d16(); return;
case NecInstructionOpCode.i_imul_d16: i_imul_d16(); return; // case NecInstructionOpCode.i_imul_d16: i_imul_d16(); return;
case NecInstructionOpCode.i_push_d8: i_push_d8(); return; // case NecInstructionOpCode.i_push_d8: i_push_d8(); return;
case NecInstructionOpCode.i_imul_d8: i_imul_d8(); return; // case NecInstructionOpCode.i_imul_d8: i_imul_d8(); return;
case NecInstructionOpCode.i_insb: i_insb(); return; // case NecInstructionOpCode.i_insb: i_insb(); return;
case NecInstructionOpCode.i_insw: i_insw(); return; // case NecInstructionOpCode.i_insw: i_insw(); return;
case NecInstructionOpCode.i_outsb: i_outsb(); return; // case NecInstructionOpCode.i_outsb: i_outsb(); return;
case NecInstructionOpCode.i_outsw: i_outsw(); return; // case NecInstructionOpCode.i_outsw: i_outsw(); return;
case NecInstructionOpCode.i_jo: i_jo(); return; // case NecInstructionOpCode.i_jo: i_jo(); return;
case NecInstructionOpCode.i_jno: i_jno(); return; // case NecInstructionOpCode.i_jno: i_jno(); return;
case NecInstructionOpCode.i_jc: i_jc(); return; // case NecInstructionOpCode.i_jc: i_jc(); return;
case NecInstructionOpCode.i_jnc: i_jnc(); return; // case NecInstructionOpCode.i_jnc: i_jnc(); return;
case NecInstructionOpCode.i_jz: i_jz(); return; // case NecInstructionOpCode.i_jz: i_jz(); return;
case NecInstructionOpCode.i_jnz: i_jnz(); return; // case NecInstructionOpCode.i_jnz: i_jnz(); return;
case NecInstructionOpCode.i_jce: i_jce(); return; // case NecInstructionOpCode.i_jce: i_jce(); return;
case NecInstructionOpCode.i_jnce: i_jnce(); return; // case NecInstructionOpCode.i_jnce: i_jnce(); return;
case NecInstructionOpCode.i_js: i_js(); return; // case NecInstructionOpCode.i_js: i_js(); return;
case NecInstructionOpCode.i_jns: i_jns(); return; // case NecInstructionOpCode.i_jns: i_jns(); return;
case NecInstructionOpCode.i_jp: i_jp(); return; // case NecInstructionOpCode.i_jp: i_jp(); return;
case NecInstructionOpCode.i_jnp: i_jnp(); return; // case NecInstructionOpCode.i_jnp: i_jnp(); return;
case NecInstructionOpCode.i_jl: i_jl(); return; // case NecInstructionOpCode.i_jl: i_jl(); return;
case NecInstructionOpCode.i_jnl: i_jnl(); return; // case NecInstructionOpCode.i_jnl: i_jnl(); return;
case NecInstructionOpCode.i_jle: i_jle(); return; // case NecInstructionOpCode.i_jle: i_jle(); return;
case NecInstructionOpCode.i_jnle: i_jnle(); return; // case NecInstructionOpCode.i_jnle: i_jnle(); return;
case NecInstructionOpCode.i_80pre: i_80pre(); return; // case NecInstructionOpCode.i_80pre: i_80pre(); return;
case NecInstructionOpCode.i_81pre: i_81pre(); return; // case NecInstructionOpCode.i_81pre: i_81pre(); return;
case NecInstructionOpCode.i_82pre: i_82pre(); return; // case NecInstructionOpCode.i_82pre: i_82pre(); return;
case NecInstructionOpCode.i_83pre: i_83pre(); return; // case NecInstructionOpCode.i_83pre: i_83pre(); return;
case NecInstructionOpCode.i_test_br8: i_test_br8(); return; // case NecInstructionOpCode.i_test_br8: i_test_br8(); return;
case NecInstructionOpCode.i_test_wr16: i_test_wr16(); return; // case NecInstructionOpCode.i_test_wr16: i_test_wr16(); return;
case NecInstructionOpCode.i_xchg_br8: i_xchg_br8(); return; // case NecInstructionOpCode.i_xchg_br8: i_xchg_br8(); return;
case NecInstructionOpCode.i_xchg_wr16: i_xchg_wr16(); return; // case NecInstructionOpCode.i_xchg_wr16: i_xchg_wr16(); return;
case NecInstructionOpCode.i_mov_br8: i_mov_br8(); return; // case NecInstructionOpCode.i_mov_br8: i_mov_br8(); return;
case NecInstructionOpCode.i_mov_wr16: i_mov_wr16(); return; // case NecInstructionOpCode.i_mov_wr16: i_mov_wr16(); return;
case NecInstructionOpCode.i_mov_r8b: i_mov_r8b(); return; // case NecInstructionOpCode.i_mov_r8b: i_mov_r8b(); return;
case NecInstructionOpCode.i_mov_r16w: i_mov_r16w(); return; // case NecInstructionOpCode.i_mov_r16w: i_mov_r16w(); return;
case NecInstructionOpCode.i_mov_wsreg: i_mov_wsreg(); return; // case NecInstructionOpCode.i_mov_wsreg: i_mov_wsreg(); return;
case NecInstructionOpCode.i_lea: i_lea(); return; // case NecInstructionOpCode.i_lea: i_lea(); return;
case NecInstructionOpCode.i_mov_sregw: i_mov_sregw(); return; // case NecInstructionOpCode.i_mov_sregw: i_mov_sregw(); return;
case NecInstructionOpCode.i_popw: i_popw(); return; // case NecInstructionOpCode.i_popw: i_popw(); return;
case NecInstructionOpCode.i_nop: i_nop(); return; // case NecInstructionOpCode.i_nop: i_nop(); return;
case NecInstructionOpCode.i_xchg_axcx: i_xchg_axcx(); return; // case NecInstructionOpCode.i_xchg_axcx: i_xchg_axcx(); return;
case NecInstructionOpCode.i_xchg_axdx: i_xchg_axdx(); return; // case NecInstructionOpCode.i_xchg_axdx: i_xchg_axdx(); return;
case NecInstructionOpCode.i_xchg_axbx: i_xchg_axbx(); return; // case NecInstructionOpCode.i_xchg_axbx: i_xchg_axbx(); return;
case NecInstructionOpCode.i_xchg_axsp: i_xchg_axsp(); return; // case NecInstructionOpCode.i_xchg_axsp: i_xchg_axsp(); return;
case NecInstructionOpCode.i_xchg_axbp: i_xchg_axbp(); return; // case NecInstructionOpCode.i_xchg_axbp: i_xchg_axbp(); return;
case NecInstructionOpCode.i_xchg_axsi: i_xchg_axsi(); return; // case NecInstructionOpCode.i_xchg_axsi: i_xchg_axsi(); return;
case NecInstructionOpCode.i_xchg_axdi: i_xchg_axdi(); return; // case NecInstructionOpCode.i_xchg_axdi: i_xchg_axdi(); return;
case NecInstructionOpCode.i_cbw: i_cbw(); return; // case NecInstructionOpCode.i_cbw: i_cbw(); return;
case NecInstructionOpCode.i_cwd: i_cwd(); return; // case NecInstructionOpCode.i_cwd: i_cwd(); return;
case NecInstructionOpCode.i_call_far: i_call_far(); return; // case NecInstructionOpCode.i_call_far: i_call_far(); return;
case NecInstructionOpCode.i_wait: i_wait(); return; // case NecInstructionOpCode.i_wait: i_wait(); return;
case NecInstructionOpCode.i_pushf: i_pushf(); return; // case NecInstructionOpCode.i_pushf: i_pushf(); return;
case NecInstructionOpCode.i_popf: i_popf(); return; // case NecInstructionOpCode.i_popf: i_popf(); return;
case NecInstructionOpCode.i_sahf: i_sahf(); return; // case NecInstructionOpCode.i_sahf: i_sahf(); return;
case NecInstructionOpCode.i_lahf: i_lahf(); return; // case NecInstructionOpCode.i_lahf: i_lahf(); return;
case NecInstructionOpCode.i_mov_aldisp: i_mov_aldisp(); return; // case NecInstructionOpCode.i_mov_aldisp: i_mov_aldisp(); return;
case NecInstructionOpCode.i_mov_axdisp: i_mov_axdisp(); return; // case NecInstructionOpCode.i_mov_axdisp: i_mov_axdisp(); return;
case NecInstructionOpCode.i_mov_dispal: i_mov_dispal(); return; // case NecInstructionOpCode.i_mov_dispal: i_mov_dispal(); return;
case NecInstructionOpCode.i_mov_dispax: i_mov_dispax(); return; // case NecInstructionOpCode.i_mov_dispax: i_mov_dispax(); return;
case NecInstructionOpCode.i_movsb: i_movsb(); return; // case NecInstructionOpCode.i_movsb: i_movsb(); return;
case NecInstructionOpCode.i_movsw: i_movsw(); return; // case NecInstructionOpCode.i_movsw: i_movsw(); return;
case NecInstructionOpCode.i_cmpsb: i_cmpsb(); return; // case NecInstructionOpCode.i_cmpsb: i_cmpsb(); return;
case NecInstructionOpCode.i_cmpsw: i_cmpsw(); return; // case NecInstructionOpCode.i_cmpsw: i_cmpsw(); return;
case NecInstructionOpCode.i_test_ald8: i_test_ald8(); return; // case NecInstructionOpCode.i_test_ald8: i_test_ald8(); return;
case NecInstructionOpCode.i_test_axd16: i_test_axd16(); return; // case NecInstructionOpCode.i_test_axd16: i_test_axd16(); return;
case NecInstructionOpCode.i_stosb: i_stosb(); return; // case NecInstructionOpCode.i_stosb: i_stosb(); return;
case NecInstructionOpCode.i_stosw: i_stosw(); return; // case NecInstructionOpCode.i_stosw: i_stosw(); return;
case NecInstructionOpCode.i_lodsb: i_lodsb(); return; // case NecInstructionOpCode.i_lodsb: i_lodsb(); return;
case NecInstructionOpCode.i_lodsw: i_lodsw(); return; // case NecInstructionOpCode.i_lodsw: i_lodsw(); return;
case NecInstructionOpCode.i_scasb: i_scasb(); return; // case NecInstructionOpCode.i_scasb: i_scasb(); return;
case NecInstructionOpCode.i_scasw: i_scasw(); return; // case NecInstructionOpCode.i_scasw: i_scasw(); return;
case NecInstructionOpCode.i_mov_ald8: i_mov_ald8(); return; // case NecInstructionOpCode.i_mov_ald8: i_mov_ald8(); return;
case NecInstructionOpCode.i_mov_cld8: i_mov_cld8(); return; // case NecInstructionOpCode.i_mov_cld8: i_mov_cld8(); return;
case NecInstructionOpCode.i_mov_dld8: i_mov_dld8(); return; // case NecInstructionOpCode.i_mov_dld8: i_mov_dld8(); return;
case NecInstructionOpCode.i_mov_bld8: i_mov_bld8(); return; // case NecInstructionOpCode.i_mov_bld8: i_mov_bld8(); return;
case NecInstructionOpCode.i_mov_ahd8: i_mov_ahd8(); return; // case NecInstructionOpCode.i_mov_ahd8: i_mov_ahd8(); return;
case NecInstructionOpCode.i_mov_chd8: i_mov_chd8(); return; // case NecInstructionOpCode.i_mov_chd8: i_mov_chd8(); return;
case NecInstructionOpCode.i_mov_dhd8: i_mov_dhd8(); return; // case NecInstructionOpCode.i_mov_dhd8: i_mov_dhd8(); return;
case NecInstructionOpCode.i_mov_bhd8: i_mov_bhd8(); return; // case NecInstructionOpCode.i_mov_bhd8: i_mov_bhd8(); return;
case NecInstructionOpCode.i_mov_axd16: i_mov_axd16(); return; // case NecInstructionOpCode.i_mov_axd16: i_mov_axd16(); return;
case NecInstructionOpCode.i_mov_cxd16: i_mov_cxd16(); return; // case NecInstructionOpCode.i_mov_cxd16: i_mov_cxd16(); return;
case NecInstructionOpCode.i_mov_dxd16: i_mov_dxd16(); return; // case NecInstructionOpCode.i_mov_dxd16: i_mov_dxd16(); return;
case NecInstructionOpCode.i_mov_bxd16: i_mov_bxd16(); return; // case NecInstructionOpCode.i_mov_bxd16: i_mov_bxd16(); return;
case NecInstructionOpCode.i_mov_spd16: i_mov_spd16(); return; // case NecInstructionOpCode.i_mov_spd16: i_mov_spd16(); return;
case NecInstructionOpCode.i_mov_bpd16: i_mov_bpd16(); return; // case NecInstructionOpCode.i_mov_bpd16: i_mov_bpd16(); return;
case NecInstructionOpCode.i_mov_sid16: i_mov_sid16(); return; // case NecInstructionOpCode.i_mov_sid16: i_mov_sid16(); return;
case NecInstructionOpCode.i_mov_did16: i_mov_did16(); return; // case NecInstructionOpCode.i_mov_did16: i_mov_did16(); return;
case NecInstructionOpCode.i_rotshft_bd8: i_rotshft_bd8(); return; // case NecInstructionOpCode.i_rotshft_bd8: i_rotshft_bd8(); return;
case NecInstructionOpCode.i_rotshft_wd8: i_rotshft_wd8(); return; // case NecInstructionOpCode.i_rotshft_wd8: i_rotshft_wd8(); return;
case NecInstructionOpCode.i_ret_d16: i_ret_d16(); return; // case NecInstructionOpCode.i_ret_d16: i_ret_d16(); return;
case NecInstructionOpCode.i_ret: i_ret(); return; // case NecInstructionOpCode.i_ret: i_ret(); return;
case NecInstructionOpCode.i_les_dw: i_les_dw(); return; // case NecInstructionOpCode.i_les_dw: i_les_dw(); return;
case NecInstructionOpCode.i_lds_dw: i_lds_dw(); return; // case NecInstructionOpCode.i_lds_dw: i_lds_dw(); return;
case NecInstructionOpCode.i_mov_bd8: i_mov_bd8(); return; // case NecInstructionOpCode.i_mov_bd8: i_mov_bd8(); return;
case NecInstructionOpCode.i_mov_wd16: i_mov_wd16(); return; // case NecInstructionOpCode.i_mov_wd16: i_mov_wd16(); return;
case NecInstructionOpCode.i_enter: i_enter(); return; // case NecInstructionOpCode.i_enter: i_enter(); return;
case NecInstructionOpCode.i_leave: i_leave(); return; // case NecInstructionOpCode.i_leave: i_leave(); return;
case NecInstructionOpCode.i_retf_d16: i_retf_d16(); return; // case NecInstructionOpCode.i_retf_d16: i_retf_d16(); return;
case NecInstructionOpCode.i_retf: i_retf(); return; // case NecInstructionOpCode.i_retf: i_retf(); return;
case NecInstructionOpCode.i_int3: i_int3(); return; // case NecInstructionOpCode.i_int3: i_int3(); return;
case NecInstructionOpCode.i_int: i_int(); return; // case NecInstructionOpCode.i_int: i_int(); return;
case NecInstructionOpCode.i_into: i_into(); return; // case NecInstructionOpCode.i_into: i_into(); return;
case NecInstructionOpCode.i_iret: i_iret(); return; // case NecInstructionOpCode.i_iret: i_iret(); return;
case NecInstructionOpCode.i_rotshft_b: i_rotshft_b(); return; // case NecInstructionOpCode.i_rotshft_b: i_rotshft_b(); return;
case NecInstructionOpCode.i_rotshft_w: i_rotshft_w(); return; // case NecInstructionOpCode.i_rotshft_w: i_rotshft_w(); return;
case NecInstructionOpCode.i_rotshft_bcl: i_rotshft_bcl(); return; // case NecInstructionOpCode.i_rotshft_bcl: i_rotshft_bcl(); return;
case NecInstructionOpCode.i_rotshft_wcl: i_rotshft_wcl(); return; // case NecInstructionOpCode.i_rotshft_wcl: i_rotshft_wcl(); return;
case NecInstructionOpCode.i_aam: i_aam(); return; // case NecInstructionOpCode.i_aam: i_aam(); return;
case NecInstructionOpCode.i_aad: i_aad(); return; // case NecInstructionOpCode.i_aad: i_aad(); return;
case NecInstructionOpCode.i_setalc: i_setalc(); return; // case NecInstructionOpCode.i_setalc: i_setalc(); return;
case NecInstructionOpCode.i_trans: i_trans(); return; // case NecInstructionOpCode.i_trans: i_trans(); return;
case NecInstructionOpCode.i_fpo: i_fpo(); return; // case NecInstructionOpCode.i_fpo: i_fpo(); return;
case NecInstructionOpCode.i_loopne: i_loopne(); return; // case NecInstructionOpCode.i_loopne: i_loopne(); return;
case NecInstructionOpCode.i_loope: i_loope(); return; // case NecInstructionOpCode.i_loope: i_loope(); return;
case NecInstructionOpCode.i_loop: i_loop(); return; // case NecInstructionOpCode.i_loop: i_loop(); return;
case NecInstructionOpCode.i_jcxz: i_jcxz(); return; // case NecInstructionOpCode.i_jcxz: i_jcxz(); return;
case NecInstructionOpCode.i_inal: i_inal(); return; // case NecInstructionOpCode.i_inal: i_inal(); return;
case NecInstructionOpCode.i_inax: i_inax(); return; // case NecInstructionOpCode.i_inax: i_inax(); return;
case NecInstructionOpCode.i_outal: i_outal(); return; // case NecInstructionOpCode.i_outal: i_outal(); return;
case NecInstructionOpCode.i_outax: i_outax(); return; // case NecInstructionOpCode.i_outax: i_outax(); return;
case NecInstructionOpCode.i_call_d16: i_call_d16(); return; // case NecInstructionOpCode.i_call_d16: i_call_d16(); return;
case NecInstructionOpCode.i_jmp_d16: i_jmp_d16(); return; // case NecInstructionOpCode.i_jmp_d16: i_jmp_d16(); return;
case NecInstructionOpCode.i_jmp_far: i_jmp_far(); return; // case NecInstructionOpCode.i_jmp_far: i_jmp_far(); return;
case NecInstructionOpCode.i_jmp_d8: i_jmp_d8(); return; // case NecInstructionOpCode.i_jmp_d8: i_jmp_d8(); return;
case NecInstructionOpCode.i_inaldx: i_inaldx(); return; // case NecInstructionOpCode.i_inaldx: i_inaldx(); return;
case NecInstructionOpCode.i_inaxdx: i_inaxdx(); return; // case NecInstructionOpCode.i_inaxdx: i_inaxdx(); return;
case NecInstructionOpCode.i_outdxal: i_outdxal(); return; // case NecInstructionOpCode.i_outdxal: i_outdxal(); return;
case NecInstructionOpCode.i_outdxax: i_outdxax(); return; // case NecInstructionOpCode.i_outdxax: i_outdxax(); return;
case NecInstructionOpCode.i_lock: i_lock(); return; // case NecInstructionOpCode.i_lock: i_lock(); return;
case NecInstructionOpCode.i_repne: i_repne(); return; // case NecInstructionOpCode.i_repne: i_repne(); return;
case NecInstructionOpCode.i_repe: i_repe(); return; // case NecInstructionOpCode.i_repe: i_repe(); return;
case NecInstructionOpCode.i_hlt: i_hlt(); return; // case NecInstructionOpCode.i_hlt: i_hlt(); return;
case NecInstructionOpCode.i_cmc: i_cmc(); return; // case NecInstructionOpCode.i_cmc: i_cmc(); return;
case NecInstructionOpCode.i_f6pre: i_f6pre(); return; // case NecInstructionOpCode.i_f6pre: i_f6pre(); return;
case NecInstructionOpCode.i_f7pre: i_f7pre(); return; // case NecInstructionOpCode.i_f7pre: i_f7pre(); return;
case NecInstructionOpCode.i_clc: i_clc(); return; // case NecInstructionOpCode.i_clc: i_clc(); return;
case NecInstructionOpCode.i_stc: i_stc(); return; // case NecInstructionOpCode.i_stc: i_stc(); return;
case NecInstructionOpCode.i_di: i_di(); return; // case NecInstructionOpCode.i_di: i_di(); return;
case NecInstructionOpCode.i_ei: i_ei(); return; // case NecInstructionOpCode.i_ei: i_ei(); return;
case NecInstructionOpCode.i_cld: i_cld(); return; // case NecInstructionOpCode.i_cld: i_cld(); return;
case NecInstructionOpCode.i_std: i_std(); return; // case NecInstructionOpCode.i_std: i_std(); return;
case NecInstructionOpCode.i_fepre: i_fepre(); return; // case NecInstructionOpCode.i_fepre: i_fepre(); return;
case NecInstructionOpCode.i_ffpre: i_ffpre(); return; // case NecInstructionOpCode.i_ffpre: i_ffpre(); return;
} // }
} //}
} }
} }

View File

@ -125,18 +125,19 @@ namespace MAME.Core
period = default; period = default;
start = default; start = default;
expire = default; expire = default;
_refCount = 1; _refCount = 0;
} }
static HashSet<emu_timer> _readyToRelease = new HashSet<emu_timer>(); static Queue<emu_timer> _readyToRelease = new Queue<emu_timer>();
/// <summary> /// <summary>
/// 线程安全队列(因为析构函数是额外线程来的) /// 线程安全队列(因为析构函数是额外线程来的)
/// </summary> /// </summary>
static ConcurrentQueue<emu_timer> _failedDeletions = new ConcurrentQueue<emu_timer>(); static Queue<emu_timer> _failedDeletions = new Queue<emu_timer>();
static HashSet<emu_timer> _tempCheck = new HashSet<emu_timer>();
static int outTimerAllCount = 0; static int outTimerAllCount = 0;
static int newTimerCount = 0; static int newTimerCount = 0;
public static emu_timer GetEmu_timer() public static emu_timer GetEmu_timerNoRef()
{ {
emu_timer obj; emu_timer obj;
if (!_failedDeletions.TryDequeue(out obj)) if (!_failedDeletions.TryDequeue(out obj))
@ -144,38 +145,36 @@ namespace MAME.Core
obj = new emu_timer(); obj = new emu_timer();
newTimerCount++; newTimerCount++;
} }
//这里引用计数为0直接放入带Ready里等待下一帧检测
obj.reset(); obj.reset();
_readyToRelease.Enqueue(obj);
outTimerAllCount++; outTimerAllCount++;
return obj; return obj;
} }
/// <summary>
/// 释放创建的引用这个要和GetEmu_timer成对
/// </summary>
/// <returns></returns>
public static void ReleaseCreateRef(emu_timer obj)
{
obj.ReleaseRef();
}
public static void CheckReadyRelaseAfterRun() public static void CheckReadyRelaseBeforeFrameRun()
{ {
if (_readyToRelease.Count < 1) if (_readyToRelease.Count < 1)
return; return;
int checkcount = _readyToRelease.Count;
int beforpoolcount = _failedDeletions.Count; int beforpoolcount = _failedDeletions.Count;
int releaseCount = 0; int releaseCount = 0;
foreach (var ready in _readyToRelease) while(_readyToRelease.TryDequeue(out emu_timer ready))
{ {
if (_tempCheck.Contains(ready))
continue;
_tempCheck.Add(ready);
if (ready._refCount <= 0) if (ready._refCount <= 0)
{ {
ready.ReturnToPool(); ready.ReturnToPool();
releaseCount++; releaseCount++;
} }
} }
//UnityEngine.Debug.Log($"CheckReadyRelaseAfterRun 出池数量{outTimerAllCount}其中new创建的数量{newTimerCount} 回收数量{releaseCount} ,处理前池数量{beforpoolcount},处理后池数量{_failedDeletions.Count}"); //UnityEngine.Debug.Log($"CheckReadyRelaseAfterRun 检查数量{checkcount}| 出池数量{outTimerAllCount}其中new创建的数量{newTimerCount} 回收数量{releaseCount} ,处理前池数量{beforpoolcount},处理后池数量{_failedDeletions.Count}");
outTimerAllCount = 0; outTimerAllCount = 0;
newTimerCount = 0; newTimerCount = 0;
_readyToRelease.Clear(); _readyToRelease.Clear();
_tempCheck.Clear();
} }
// 引用计数字段(线程安全) // 引用计数字段(线程安全)
@ -188,15 +187,16 @@ namespace MAME.Core
{ {
int newCount = Interlocked.Increment(ref _refCount); int newCount = Interlocked.Increment(ref _refCount);
//引用计数重新回到1时移除。 ////引用计数重新回到1时移除。
//但是还是不在这里做把注释了,在每一帧开始之前统一检测 ////但是还是不在这里做把注释了,在每一帧开始之前统一检测
//if (newCount == 1) //if (newCount == 1)
//{ //{
// if (_readyToRelease.Contains(this)) // UnityEngine.Debug.Log("CheckReadyRelaseAfterRun AddRef 复活");
// { // //if (_readyToRelease.Contains(this))
// //UnityEngine.Debug.Log("移除ReadyToRelease"); // //{
// _readyToRelease.Remove(this); // // //UnityEngine.Debug.Log("移除ReadyToRelease");
// } // // _readyToRelease.Remove(this);
// //}
//} //}
} }
@ -208,6 +208,7 @@ namespace MAME.Core
int newCount = Interlocked.Decrement(ref _refCount); int newCount = Interlocked.Decrement(ref _refCount);
if (newCount == 0) if (newCount == 0)
{ {
//UnityEngine.Debug.Log("CheckReadyRelaseAfterRun ReleaseRef 预回收");
// 引用计数为0释放资源并回池 // 引用计数为0释放资源并回池
ReadyToRelease(); ReadyToRelease();
} }
@ -221,8 +222,7 @@ namespace MAME.Core
void ReadyToRelease() void ReadyToRelease()
{ {
//UnityEngine.Debug.Log("ReadyToRelease"); //UnityEngine.Debug.Log("ReadyToRelease");
if(!_readyToRelease.Contains(this)) _readyToRelease.Enqueue(this);
_readyToRelease.Add(this);
} }
/// <summary> /// <summary>
@ -230,7 +230,6 @@ namespace MAME.Core
/// </summary> /// </summary>
void ReturnToPool() void ReturnToPool()
{ {
reset();
_failedDeletions.Enqueue(this); _failedDeletions.Enqueue(this);
} }
@ -699,14 +698,14 @@ namespace MAME.Core
} }
return global_basetime; return global_basetime;
} }
public static void timer_remove(emu_timer timer1) /*public static void timer_remove(emu_timer timer1)
{ {
if (timer1 == callback_timer) if (timer1 == callback_timer)
{ {
callback_timer_modified = true; callback_timer_modified = true;
} }
timer_list_remove(timer1); timer_list_remove(timer1);
} }*/
public static void timer_adjust_periodic(emu_timer which, Atime start_delay, Atime period) public static void timer_adjust_periodic(emu_timer which, Atime start_delay, Atime period)
{ {
Atime time = get_current_time(); Atime time = get_current_time();
@ -722,8 +721,11 @@ namespace MAME.Core
which.start = time; which.start = time;
which.expire = Attotime.attotime_add(time, start_delay); which.expire = Attotime.attotime_add(time, start_delay);
which.period = period; which.period = period;
timer_list_remove(which);
timer_list_insert(which); timer_list_remove_and_insert(which);
//timer_list_remove(which);
//timer_list_insert(which);
//if (lt.IndexOf(which) == 0) //if (lt.IndexOf(which) == 0)
if (lt[0] == which) if (lt[0] == which)
{ {
@ -745,7 +747,20 @@ namespace MAME.Core
emu_timer timer = timer_alloc_common_NoRef(action, true); emu_timer timer = timer_alloc_common_NoRef(action, true);
timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
} }
public static void timer_list_insert(emu_timer timer1)
static void timer_list_remove_and_insert(emu_timer timer)
{
//包一层引用避免引用计数中间丢失,进等待检测队列(减少这样的情况)
{
emu_timer tempref = null;
emu_timer.SetRefUsed(ref tempref, ref timer);
timer_list_remove(timer);
timer_list_insert(timer);
emu_timer.SetNull(ref tempref);
}
}
static void timer_list_insert(emu_timer timer1)
{ {
int i; int i;
int i1 = -1; int i1 = -1;
@ -885,8 +900,10 @@ namespace MAME.Core
{ {
timer.start = timer.expire; timer.start = timer.expire;
timer.expire = Attotime.attotime_add(timer.expire, timer.period); timer.expire = Attotime.attotime_add(timer.expire, timer.period);
timer_list_remove(timer);
timer_list_insert(timer); timer_list_remove_and_insert(timer);
//timer_list_remove(timer);
//timer_list_insert(timer);
} }
} }
} }
@ -939,7 +956,7 @@ namespace MAME.Core
{ {
Atime time = get_current_time(); Atime time = get_current_time();
//创建一个timer //创建一个timer
emu_timer timer = emu_timer.GetEmu_timer(); emu_timer timer = emu_timer.GetEmu_timerNoRef();
timer.action = action; timer.action = action;
timer.enabled = false; timer.enabled = false;
timer.temporary = temp; timer.temporary = temp;
@ -948,8 +965,6 @@ namespace MAME.Core
timer.start = time; timer.start = time;
timer.expire = Attotime.ATTOTIME_NEVER; timer.expire = Attotime.ATTOTIME_NEVER;
timer_list_insert(timer); timer_list_insert(timer);
//断开创建的引用计数
emu_timer.ReleaseCreateRef(timer);
return timer; return timer;
} }
@ -958,8 +973,11 @@ namespace MAME.Core
bool old; bool old;
old = which.enabled; old = which.enabled;
which.enabled = enable; which.enabled = enable;
timer_list_remove(which);
timer_list_insert(which); timer_list_remove_and_insert(which);
//timer_list_remove(which);
//timer_list_insert(which);
return old; return old;
} }
public static bool timer_enabled(emu_timer which) public static bool timer_enabled(emu_timer which)
@ -1009,7 +1027,7 @@ namespace MAME.Core
EmuTimerLister.GetNewTimerLister(ref lt); EmuTimerLister.GetNewTimerLister(ref lt);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
emu_timer etimer = emu_timer.GetEmu_timer(); emu_timer etimer = emu_timer.GetEmu_timerNoRef();
#region #region
lt.Add(etimer); lt.Add(etimer);
i1 = reader.ReadInt32(); i1 = reader.ReadInt32();
@ -1317,8 +1335,6 @@ namespace MAME.Core
lt.Add(YM3812.timer[1]); lt.Add(YM3812.timer[1]);
} }
#endregion #endregion
//断开创建的引用计数
emu_timer.ReleaseCreateRef(etimer);
} }
for (i = n; i < 32; i++) for (i = n; i < 32; i++)
{ {

View File

@ -99,7 +99,7 @@ namespace MAME.Core
if (exit_pending) if (exit_pending)
return; return;
EmuTimer.emu_timer.CheckReadyRelaseAfterRun(); EmuTimer.emu_timer.CheckReadyRelaseBeforeFrameRun();
long lastframe = Video.screenstate.frame_number; long lastframe = Video.screenstate.frame_number;
//执行CPU命令直到一次画面更新 //执行CPU命令直到一次画面更新
while (lastframe == Video.screenstate.frame_number) while (lastframe == Video.screenstate.frame_number)

View File

@ -9,14 +9,44 @@ namespace MAME.Core
{ {
public int fr; public int fr;
public byte by; public byte by;
public fr1(int i1, byte b1) //public fr1(int i1, byte b1)
//{
// fr = i1;
// by = b1;
//}
public void reset()
{ {
fr = i1; fr = default;
by = b1; by = default;
}
public static fr1 getnew(int i1, byte b1)
{
fr1 obj = ObjectPoolAuto.Acquire<fr1>();
obj.fr = i1;
obj.by = b1;
return obj;
} }
} }
public static int i3 = 70; public static int i3 = 70;
public static List<fr1> lfr = new List<fr1>(); static List<fr1> lfr = resetlfr_list();//= new List<fr1>();
static List<fr1> resetlfr_list()
{
if (lfr == null)
{
lfr = ObjectPoolAuto.AcquireList<fr1>();
}
else
{
for (int i = 0; i < lfr.Count; i++)
{
lfr[i].reset();
ObjectPoolAuto.Release(lfr[i]);
}
lfr.Clear();
}
return lfr;
}
public static void loop_inputports_dataeast_pcktgal() public static void loop_inputports_dataeast_pcktgal()
{ {
if (Keyboard.IsPressed(MotionKey.P1_INSERT_COIN))//if (Keyboard.IsPressed(Corekey.D5)) if (Keyboard.IsPressed(MotionKey.P1_INSERT_COIN))//if (Keyboard.IsPressed(Corekey.D5))
@ -149,36 +179,41 @@ namespace MAME.Core
} }
if (Keyboard.IsPressed(MotionKey.UNKNOW_N))//if (Keyboard.IsPressed(Corekey.N)) if (Keyboard.IsPressed(MotionKey.UNKNOW_N))//if (Keyboard.IsPressed(Corekey.N))
{ {
lfr = new List<fr1>(); //lfr = new List<fr1>();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0x7f)); resetlfr_list();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0x7f));
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2 + i3), 0x7f)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff));
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2 + i3 + 1), 0xff)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2 + i3), 0x7f));
lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2 + i3 + 1), 0xff));
} }
if (Keyboard.IsPressed(MotionKey.P1_BTN_3))//if (Keyboard.IsPressed(Corekey.U)) if (Keyboard.IsPressed(MotionKey.P1_BTN_3))//if (Keyboard.IsPressed(Corekey.U))
{ {
lfr = new List<fr1>(); //lfr = new List<fr1>();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xf7)); resetlfr_list();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xf7));
lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff));
} }
if (Keyboard.IsPressed(MotionKey.P1_BTN_4))//if (Keyboard.IsPressed(Corekey.I)) if (Keyboard.IsPressed(MotionKey.P1_BTN_4))//if (Keyboard.IsPressed(Corekey.I))
{ {
lfr = new List<fr1>(); //lfr = new List<fr1>();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xfb)); resetlfr_list();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xfb));
lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff));
} }
if (Keyboard.IsPressed(MotionKey.UNKNOW_V))//if (Keyboard.IsPressed(Corekey.V)) if (Keyboard.IsPressed(MotionKey.UNKNOW_V))//if (Keyboard.IsPressed(Corekey.V))
{ {
lfr = new List<fr1>(); //lfr = new List<fr1>();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xfd)); resetlfr_list();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xfd));
lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff));
} }
if (Keyboard.IsPressed(MotionKey.UNKNOW_B))//if (Keyboard.IsPressed(Corekey.B)) if (Keyboard.IsPressed(MotionKey.UNKNOW_B))//if (Keyboard.IsPressed(Corekey.B))
{ {
lfr = new List<fr1>(); //lfr = new List<fr1>();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xfe)); resetlfr_list();
lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xfe));
lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff));
} }
foreach (fr1 f in lfr) foreach (fr1 f in lfr)
{ {

View File

@ -274,109 +274,205 @@ namespace MAME.Core
} }
public static void draw_sprites(RECT cliprect) public static void draw_sprites(RECT cliprect)
{ {
int offs, k; // 预计算不变的值
for (k = 0; k < 8; k++) bool flip_screen = Generic.flip_screen_get() != 0;
int sprite_count = m92_sprite_list;
// 预先计算常用值避免重复计算
const int SCREEN_WIDTH = 512;
const int SCREEN_HEIGHT = 384;
const int X_OFFSET = 16;
const int Y_BASE = SCREEN_HEIGHT - X_OFFSET;
for (int k = 0; k < 8; k++)
{ {
for (offs = 0; offs < m92_sprite_list;) int offs = 0;
// 使用while循环避免for循环的额外开销
while (offs < sprite_count)
{ {
int x, y, sprite, colour, fx, fy, x_multi, y_multi, i, j, s_ptr, pri_back, pri_sprite; // 一次性读取所有需要的数据到局部变量[7](@ref)
y = Generic.buffered_spriteram16[offs + 0] & 0x1ff; ushort data0 = Generic.buffered_spriteram16[offs];
x = Generic.buffered_spriteram16[offs + 3] & 0x1ff; ushort data1 = Generic.buffered_spriteram16[offs + 1];
if ((Generic.buffered_spriteram16[offs + 2] & 0x0080) != 0) ushort data2 = Generic.buffered_spriteram16[offs + 2];
{ ushort data3 = Generic.buffered_spriteram16[offs + 3];
pri_back = 0;
} // 提前进行优先级检查,避免不必要的计算[8](@ref)
else int pri_sprite = (data0 & 0xe000) >> 13;
{
pri_back = 2;
}
sprite = Generic.buffered_spriteram16[offs + 1];
colour = Generic.buffered_spriteram16[offs + 2] & 0x007f;
pri_sprite = (Generic.buffered_spriteram16[offs + 0] & 0xe000) >> 13;
fx = (Generic.buffered_spriteram16[offs + 2] >> 8) & 1;
fy = (Generic.buffered_spriteram16[offs + 2] >> 9) & 1;
y_multi = (Generic.buffered_spriteram16[offs + 0] >> 9) & 3;
x_multi = (Generic.buffered_spriteram16[offs + 0] >> 11) & 3;
y_multi = 1 << y_multi;
x_multi = 1 << x_multi;
offs += 4 * x_multi;
if (pri_sprite != k) if (pri_sprite != k)
{ {
offs += 4;
continue; continue;
} }
x = x - 16;
y = 384 - 16 - y; // 提取精灵属性(使用局部变量避免重复内存访问)
int y = data0 & 0x1ff;
int x = data3 & 0x1ff;
int sprite = data1;
int colour = data2 & 0x007f;
int fx = (data2 >> 8) & 1;
int fy = (data2 >> 9) & 1;
int y_multi = 1 << ((data0 >> 9) & 3);
int x_multi = 1 << ((data0 >> 11) & 3);
bool high_priority = (data2 & 0x0080) != 0;
int pri_back = high_priority ? 0 : 2;
// 计算基础坐标变换
x = x - X_OFFSET;
y = Y_BASE - y;
// 处理水平翻转的偏移
if (fx != 0) if (fx != 0)
{ {
x += 16 * (x_multi - 1); x += 16 * (x_multi - 1);
} }
for (j = 0; j < x_multi; j++)
// 预先计算绘制参数
uint draw_flags = (uint)(pri_back | (1 << 31));
int x_step = fx != 0 ? -16 : 16;
// 内层循环优化:减少重复计算
for (int j = 0; j < x_multi; j++)
{ {
s_ptr = 8 * j; int s_ptr = 8 * j;
if (fy == 0) if (fy == 0)
{ {
s_ptr += y_multi - 1; s_ptr += y_multi - 1;
} }
x &= 0x1ff;
for (i = 0; i < y_multi; i++) int current_x = x & 0x1ff;
for (int i = 0; i < y_multi; i++)
{ {
if (Generic.flip_screen_get() != 0) if (flip_screen)
{ {
int i1 = 1; // 翻转屏幕的绘制逻辑(已注释,保持原样)
/*pdrawgfx(bitmap,machine->gfx[1],
sprite + s_ptr,
colour,
!fx,!fy,
464-x,240-(y-i*16),
cliprect,TRANSPARENCY_PEN,0,pri_back);
pdrawgfx(bitmap,machine->gfx[1],
sprite + s_ptr,
colour,
!fx,!fy,
464-x+512,240-(y-i*16),
cliprect,TRANSPARENCY_PEN,0,pri_back);*/
} }
else else
{ {
/*pdrawgfx(bitmap,machine->gfx[1], // 直接调用绘制函数,避免中间计算[3](@ref)
sprite + s_ptr, Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy,
colour, current_x, y - i * 16, cliprect, draw_flags);
fx,fy, Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy,
x,y-i*16, current_x - SCREEN_WIDTH, y - i * 16, cliprect, draw_flags);
cliprect,TRANSPARENCY_PEN,0,pri_back); }
pdrawgfx(bitmap,machine->gfx[1], // 优化指针更新
sprite + s_ptr, s_ptr += fy != 0 ? 1 : -1;
colour,
fx,fy,
x-512,y-i*16,
cliprect,TRANSPARENCY_PEN,0,pri_back);*/
Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x, y - i * 16, cliprect, (uint)(pri_back | (1 << 31)));
Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x - 512, y - i * 16, cliprect, (uint)(pri_back | (1 << 31)));
}
if (fy != 0)
{
s_ptr++;
}
else
{
s_ptr--;
}
}
if (fx != 0)
{
x -= 16;
}
else
{
x += 16;
} }
current_x += x_step;
} }
offs += 4 * x_multi;
} }
} }
} }
//public static void draw_sprites(RECT cliprect)
//{
// int offs, k;
// for (k = 0; k < 8; k++)
// {
// for (offs = 0; offs < m92_sprite_list;)
// {
// int x, y, sprite, colour, fx, fy, x_multi, y_multi, i, j, s_ptr, pri_back, pri_sprite;
// y = Generic.buffered_spriteram16[offs + 0] & 0x1ff;
// x = Generic.buffered_spriteram16[offs + 3] & 0x1ff;
// if ((Generic.buffered_spriteram16[offs + 2] & 0x0080) != 0)
// {
// pri_back = 0;
// }
// else
// {
// pri_back = 2;
// }
// sprite = Generic.buffered_spriteram16[offs + 1];
// colour = Generic.buffered_spriteram16[offs + 2] & 0x007f;
// pri_sprite = (Generic.buffered_spriteram16[offs + 0] & 0xe000) >> 13;
// fx = (Generic.buffered_spriteram16[offs + 2] >> 8) & 1;
// fy = (Generic.buffered_spriteram16[offs + 2] >> 9) & 1;
// y_multi = (Generic.buffered_spriteram16[offs + 0] >> 9) & 3;
// x_multi = (Generic.buffered_spriteram16[offs + 0] >> 11) & 3;
// y_multi = 1 << y_multi;
// x_multi = 1 << x_multi;
// offs += 4 * x_multi;
// if (pri_sprite != k)
// {
// continue;
// }
// x = x - 16;
// y = 384 - 16 - y;
// if (fx != 0)
// {
// x += 16 * (x_multi - 1);
// }
// for (j = 0; j < x_multi; j++)
// {
// s_ptr = 8 * j;
// if (fy == 0)
// {
// s_ptr += y_multi - 1;
// }
// x &= 0x1ff;
// for (i = 0; i < y_multi; i++)
// {
// if (Generic.flip_screen_get() != 0)
// {
// int i1 = 1;
// /*pdrawgfx(bitmap,machine->gfx[1],
// sprite + s_ptr,
// colour,
// !fx,!fy,
// 464-x,240-(y-i*16),
// cliprect,TRANSPARENCY_PEN,0,pri_back);
//
// pdrawgfx(bitmap,machine->gfx[1],
// sprite + s_ptr,
// colour,
// !fx,!fy,
// 464-x+512,240-(y-i*16),
// cliprect,TRANSPARENCY_PEN,0,pri_back);*/
//
// }
// else
// {
// /*pdrawgfx(bitmap,machine->gfx[1],
// sprite + s_ptr,
// colour,
// fx,fy,
// x,y-i*16,
// cliprect,TRANSPARENCY_PEN,0,pri_back);
//
// pdrawgfx(bitmap,machine->gfx[1],
// sprite + s_ptr,
// colour,
// fx,fy,
// x-512,y-i*16,
// cliprect,TRANSPARENCY_PEN,0,pri_back);*/
// Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x, y - i * 16, cliprect, (uint)(pri_back | (1 << 31)));
// Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x - 512, y - i * 16, cliprect, (uint)(pri_back | (1 << 31)));
// }
// if (fy != 0)
// {
// s_ptr++;
// }
// else
// {
// s_ptr--;
// }
// }
// if (fx != 0)
// {
// x -= 16;
// }
// else
// {
// x += 16;
// }
// }
// }
// }
//}
public static void m92_update_scroll_positions() public static void m92_update_scroll_positions()
{ {
int laynum; int laynum;