重写MC68000 指令调度 抛弃Action | 更多的unsafe优化

This commit is contained in:
sin365 2025-01-19 02:37:54 +08:00
parent 0634207bf0
commit 945ff6b319
27 changed files with 919 additions and 427 deletions

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: e61d6d9af3207a64bac790196a97754c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 8f2f5edf7f1ca9846b70758a818564a3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 0cafebfb110d82948babe07af0003aed
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: cd208262dbbc06344b473be3e1337324
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -32,6 +32,7 @@ namespace MAME.Core
public void LoadRom(string Name) => mameMainMotion.LoadRom(Name);
public void GetGameScreenSize(out int _width, out int _height, out IntPtr _framePtr) => mameMainMotion.GetGameScreenSize(out _width, out _height, out _framePtr);
public void StartGame() => mameMainMotion.StartGame();
public void StartGame_WithNewThread() => mameMainMotion.StartGame_WithNewThread();
public void UpdateFrame() => Mame.mame_execute_UpdateMode_NextFrame();
public void UnlockNextFreme(int moreTick = 1) => mameMainMotion.UnlockNextFreme(moreTick);
public void StopGame() => mameMainMotion.StopGame();

View File

@ -15,10 +15,10 @@ namespace MAME.Core
public NeogeoMotion neogeomotion;
public Konami68000Motion konami68000motion;
public string sSelect;
//public static Thread mainThread;
public static Thread mainThread;
//初始化停帧信号量
//public AutoResetEvent emuAutoLoopEvent;
public AutoResetEvent emuAutoLoopEvent;
public static IResources resource;
public bool bRom => Machine.bRom;
@ -203,17 +203,26 @@ namespace MAME.Core
public void StartGame()
{
bIsNewThreadMode = false;
M68000Motion.iStatus = 0;
M68000Motion.iValue = 0;
Mame.exit_pending = false;
Mame.mame_execute_UpdateMode_Start();
}
public void StartGame_WithNewThread()
{
bIsNewThreadMode = true;
M68000Motion.iStatus = 0;
M68000Motion.iValue = 0;
Mame.exit_pending = false;
//初始化停帧信号量
//emuAutoLoopEvent = new AutoResetEvent(false);
emuAutoLoopEvent = new AutoResetEvent(false);
//mainThread = new Thread(Mame.mame_execute);
//mainThread.Start();
Mame.mame_execute_UpdateMode_Start();
mainThread = new Thread(Mame.mame_execute);
mainThread.Start();
}
@ -225,7 +234,10 @@ namespace MAME.Core
/// <param name="moveTick"></param>
public void UnlockNextFreme(int moreTick = 1)
{
//emuAutoLoopEvent.Set();
if (!bIsNewThreadMode)
return;
emuAutoLoopEvent.Set();
//TODO 等待跳帧时测试
if (moreTick > 1)
@ -254,7 +266,14 @@ namespace MAME.Core
}
//等待停帧数
//Machine.mainMotion.emuAutoLoopEvent.WaitOne();
Machine.mainMotion.WaitAutoEvent();
}
private void WaitAutoEvent()
{
if (!bIsNewThreadMode)
return;
emuAutoLoopEvent.WaitOne();
}
public void StopGame()
@ -560,6 +579,8 @@ namespace MAME.Core
int TempWidth = 0;
int TempHeight = 0;
private bool bIsNewThreadMode;
private void ResizeMain()
{
int deltaX, deltaY;

View File

@ -79,114 +79,114 @@ namespace MAME.Core
}
mBList_lsCB.Add(b_cbPC);
}
public void GetData()
{
int i;
string sDisassemble, sDisassemble2 = "";
for (i = 0; i < 8; i++)
{
mTxList_tbDs[i] = MC68000.m1.D[i].u32.ToString("X8");
mTxList_tbAs[i] = MC68000.m1.A[i].u32.ToString("X8");
}
mTx_tbPPC = MC68000.m1.PPC.ToString("X6");
mTx_tbOP = MC68000.m1.op.ToString("X4");
b_cbS = MC68000.m1.S;
b_cbM = MC68000.m1.M;
b_cbX = MC68000.m1.X;
b_cbN = MC68000.m1.N;
b_cbZ = MC68000.m1.Z;
b_cbV = MC68000.m1.V;
b_cbC = MC68000.m1.C;
mTx_tbIML = MC68000.m1.InterruptMaskLevel.ToString();
mTx_tbUSP = MC68000.m1.usp.ToString("X8");
mTx_tbSSP = MC68000.m1.ssp.ToString("X8");
mTx_tbCycles = MC68000.m1.TotalExecutedCycles.ToString("X16");
mTx_tbPC = MC68000.m1.PC.ToString("X6");
sDisassemble = MC68000.m1.Disassemble(MC68000.m1.PPC).ToString();
mTx_tbDisassemble = sDisassemble;
sDisassemble2 = sDisassemble;
foreach (bool cb in mBList_lsCB)
{
if (cb)
{
//sDisassemble2 += " " + cb + cb.TB.Text;
sDisassemble2 += " " + cb + cb;
}
}
if (b_cbTotal)
{
sDisassemble2 = MC68000.m1.TotalExecutedCycles.ToString("X") + " " + sDisassemble2;
}
mTxList_tbResult.Add(sDisassemble2 + "\r\n");
}
public void m68000_start_debug()
{
if (bLogNew && lsPPC.IndexOf(MC68000.m1.PPC) < 0)
{
m68000FState = m68000State;
m68000State = M68000State.M68000_STOP;
lsPPC.Add(MC68000.m1.PPC);
mTxList_tbResult.Add(MC68000.m1.Disassemble(MC68000.m1.PPC).ToString() + "\r\n");
m68000State = m68000FState;
}
PPC = MC68000.m1.PPC;
TotalExecutedCycles = MC68000.m1.TotalExecutedCycles;
if (iStatus == 1)
{
iStatus = 0;
}
if (m68000State == M68000State.M68000_STEP2)
{
if (MC68000.m1.PPC == PPCTill)
{
m68000State = M68000State.M68000_STOP;
}
}
if (m68000State == M68000State.M68000_STEP3)
{
if (MC68000.m1.TotalExecutedCycles >= CyclesTill)
{
m68000State = M68000State.M68000_STOP;
}
}
if (b_cbLog == true && (m68000State == M68000State.M68000_STEP2 || m68000State == M68000State.M68000_STEP3))
{
GetData();
}
if (m68000State == M68000State.M68000_STOP)
{
GetData();
mTx_tsslStatus = "m68000 stop";
}
while (m68000State == M68000State.M68000_STOP)
{
//public void GetData()
//{
// int i;
// string sDisassemble, sDisassemble2 = "";
// for (i = 0; i < 8; i++)
// {
// mTxList_tbDs[i] = MC68000.m1.D[i].u32.ToString("X8");
// mTxList_tbAs[i] = MC68000.m1.A[i].u32.ToString("X8");
// }
// mTx_tbPPC = MC68000.m1.PPC.ToString("X6");
// mTx_tbOP = MC68000.m1.op.ToString("X4");
// b_cbS = MC68000.m1.S;
// b_cbM = MC68000.m1.M;
// b_cbX = MC68000.m1.X;
// b_cbN = MC68000.m1.N;
// b_cbZ = MC68000.m1.Z;
// b_cbV = MC68000.m1.V;
// b_cbC = MC68000.m1.C;
// mTx_tbIML = MC68000.m1.InterruptMaskLevel.ToString();
// mTx_tbUSP = MC68000.m1.usp.ToString("X8");
// mTx_tbSSP = MC68000.m1.ssp.ToString("X8");
// mTx_tbCycles = MC68000.m1.TotalExecutedCycles.ToString("X16");
// mTx_tbPC = MC68000.m1.PC.ToString("X6");
// sDisassemble = MC68000.m1.Disassemble(MC68000.m1.PPC).ToString();
// mTx_tbDisassemble = sDisassemble;
// sDisassemble2 = sDisassemble;
// foreach (bool cb in mBList_lsCB)
// {
// if (cb)
// {
// //sDisassemble2 += " " + cb + cb.TB.Text;
// sDisassemble2 += " " + cb + cb;
// }
// }
// if (b_cbTotal)
// {
// sDisassemble2 = MC68000.m1.TotalExecutedCycles.ToString("X") + " " + sDisassemble2;
// }
// mTxList_tbResult.Add(sDisassemble2 + "\r\n");
//}
//public void m68000_start_debug()
//{
// if (bLogNew && lsPPC.IndexOf(MC68000.m1.PPC) < 0)
// {
// m68000FState = m68000State;
// m68000State = M68000State.M68000_STOP;
// lsPPC.Add(MC68000.m1.PPC);
// mTxList_tbResult.Add(MC68000.m1.Disassemble(MC68000.m1.PPC).ToString() + "\r\n");
// m68000State = m68000FState;
// }
// PPC = MC68000.m1.PPC;
// TotalExecutedCycles = MC68000.m1.TotalExecutedCycles;
// if (iStatus == 1)
// {
// iStatus = 0;
// }
// if (m68000State == M68000State.M68000_STEP2)
// {
// if (MC68000.m1.PPC == PPCTill)
// {
// m68000State = M68000State.M68000_STOP;
// }
// }
// if (m68000State == M68000State.M68000_STEP3)
// {
// if (MC68000.m1.TotalExecutedCycles >= CyclesTill)
// {
// m68000State = M68000State.M68000_STOP;
// }
// }
// if (b_cbLog == true && (m68000State == M68000State.M68000_STEP2 || m68000State == M68000State.M68000_STEP3))
// {
// GetData();
// }
// if (m68000State == M68000State.M68000_STOP)
// {
// GetData();
// mTx_tsslStatus = "m68000 stop";
// }
// while (m68000State == M68000State.M68000_STOP)
// {
}
}
public void m68000_stop_debug()
{
if (iStatus == 1)
{
GetData();
m68000State = M68000State.M68000_STOP;
mTx_tsslStatus = "m68000 stop";
iStatus = 2;
}
if (m68000State == M68000State.M68000_STEP)
{
m68000State = M68000State.M68000_STOP;
mTx_tsslStatus = "m68000 stop";
}
if (iStatus == 0)
{
/*if(Memory.mainram[0xd1b]==0x05)
{
iStatus = 1;
GetData();
m68000State = M68000State.M68000_STOP;
tsslStatus.Text = "m68000 stop";
}*/
}
}
// }
//}
//public void m68000_stop_debug()
//{
// if (iStatus == 1)
// {
// GetData();
// m68000State = M68000State.M68000_STOP;
// mTx_tsslStatus = "m68000 stop";
// iStatus = 2;
// }
// if (m68000State == M68000State.M68000_STEP)
// {
// m68000State = M68000State.M68000_STOP;
// mTx_tsslStatus = "m68000 stop";
// }
// if (iStatus == 0)
// {
// /*if(Memory.mainram[0xd1b]==0x05)
// {
// iStatus = 1;
// GetData();
// m68000State = M68000State.M68000_STOP;
// tsslStatus.Text = "m68000 stop";
// }*/
// }
//}
}
}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using UnityEngine;
namespace MAME.Core
{
@ -229,7 +228,7 @@ namespace MAME.Core
if (count < value)
{
if (Items.Capacity < value)
Items.Capacity = Mathf.NextPowerOfTwo(value);
Items.Capacity = NextPowerOfTwo(value);
do
{
@ -246,6 +245,28 @@ namespace MAME.Core
}
}
// 计算大于或等于给定数的最小的2的幂
public static int NextPowerOfTwo(int value)
{
// 处理value为0的特殊情况
if (value == 0)
return 1;
// value已经是2的幂的情况
if ((value & (value - 1)) == 0)
return value;
// 不断左移直到找到一个大于或等于value的2的幂
int powerOfTwo = 1;
while (powerOfTwo < value)
{
powerOfTwo <<= 1; // 左移一位相当于乘以2
}
return powerOfTwo;
}
/************************************************************************************************************************/
/// <summary>

View File

@ -18,127 +18,127 @@ namespace cpu.m68000
partial class MC68000
{
public DisassemblyInfo Disassemble(int pc)
{
var info = new DisassemblyInfo { Mnemonic = "UNKNOWN", PC = pc, Length = 2 };
op = (ushort)ReadOpWord(pc);
//public DisassemblyInfo Disassemble(int pc)
//{
// var info = new DisassemblyInfo { Mnemonic = "UNKNOWN", PC = pc, Length = 2 };
// op = (ushort)ReadOpWord(pc);
if (Opcodes[op] == MOVE) MOVE_Disasm(info);//
else if (Opcodes[op] == MOVEA) MOVEA_Disasm(info);
else if (Opcodes[op] == MOVEQ) MOVEQ_Disasm(info);
else if (Opcodes[op] == MOVEM0) MOVEM0_Disasm(info);
else if (Opcodes[op] == MOVEM1) MOVEM1_Disasm(info);
else if (Opcodes[op] == LEA) LEA_Disasm(info);//
else if (Opcodes[op] == CLR) CLR_Disasm(info);
else if (Opcodes[op] == EXT) EXT_Disasm(info);
else if (Opcodes[op] == PEA) PEA_Disasm(info);
else if (Opcodes[op] == ANDI) ANDI_Disasm(info);
else if (Opcodes[op] == ANDI_CCR) ANDI_CCR_Disasm(info);
else if (Opcodes[op] == EORI) EORI_Disasm(info);
else if (Opcodes[op] == EORI_CCR) EORI_CCR_Disasm(info);
else if (Opcodes[op] == ORI) ORI_Disasm(info);
else if (Opcodes[op] == ORI_CCR) ORI_CCR_Disasm(info);
else if (Opcodes[op] == ASLd) ASLd_Disasm(info);
else if (Opcodes[op] == ASRd) ASRd_Disasm(info);
else if (Opcodes[op] == LSLd) LSLd_Disasm(info);
else if (Opcodes[op] == LSRd) LSRd_Disasm(info);
else if (Opcodes[op] == ROXLd) ROXLd_Disasm(info);
else if (Opcodes[op] == ROXRd) ROXRd_Disasm(info);
else if (Opcodes[op] == ROLd) ROLd_Disasm(info);
else if (Opcodes[op] == RORd) RORd_Disasm(info);
else if (Opcodes[op] == ASLd0) ASLd0_Disasm(info);
else if (Opcodes[op] == ASRd0) ASRd0_Disasm(info);
else if (Opcodes[op] == LSLd0) LSLd0_Disasm(info);
else if (Opcodes[op] == LSRd0) LSRd0_Disasm(info);
else if (Opcodes[op] == ROXLd0) ROXLd0_Disasm(info);
else if (Opcodes[op] == ROXRd0) ROXRd0_Disasm(info);
else if (Opcodes[op] == ROLd0) ROLd0_Disasm(info);
else if (Opcodes[op] == RORd0) RORd0_Disasm(info);
else if (Opcodes[op] == SWAP) SWAP_Disasm(info);
else if (Opcodes[op] == AND0) AND0_Disasm(info);
else if (Opcodes[op] == AND1) AND1_Disasm(info);
else if (Opcodes[op] == EOR) EOR_Disasm(info);
else if (Opcodes[op] == OR0) OR0_Disasm(info);
else if (Opcodes[op] == OR1) OR1_Disasm(info);
else if (Opcodes[op] == NOT) NOT_Disasm(info);
else if (Opcodes[op] == NEG) NEG_Disasm(info);
else if (Opcodes[op] == JMP) JMP_Disasm(info);
else if (Opcodes[op] == JSR) JSR_Disasm(info);
else if (Opcodes[op] == Bcc) Bcc_Disasm(info);
else if (Opcodes[op] == BRA) BRA_Disasm(info);
else if (Opcodes[op] == BSR) BSR_Disasm(info);
else if (Opcodes[op] == DBcc) DBcc_Disasm(info);
else if (Opcodes[op] == Scc) Scc_Disasm(info);
else if (Opcodes[op] == RTE) RTE_Disasm(info);
else if (Opcodes[op] == RTS) RTS_Disasm(info);
else if (Opcodes[op] == RTR) RTR_Disasm(info);
else if (Opcodes[op] == TST) TST_Disasm(info);
else if (Opcodes[op] == BTSTi) BTSTi_Disasm(info);
else if (Opcodes[op] == BTSTr) BTSTr_Disasm(info);
else if (Opcodes[op] == BCHGi) BCHGi_Disasm(info);
else if (Opcodes[op] == BCHGr) BCHGr_Disasm(info);
else if (Opcodes[op] == BCLRi) BCLRi_Disasm(info);
else if (Opcodes[op] == BCLRr) BCLRr_Disasm(info);
else if (Opcodes[op] == BSETi) BSETi_Disasm(info);
else if (Opcodes[op] == BSETr) BSETr_Disasm(info);
else if (Opcodes[op] == LINK) LINK_Disasm(info);
else if (Opcodes[op] == UNLK) UNLK_Disasm(info);
else if (Opcodes[op] == RESET) RESET_Disasm(info);
else if (Opcodes[op] == NOP) NOP_Disasm(info);
else if (Opcodes[op] == ADD0) ADD_Disasm(info);
else if (Opcodes[op] == ADD1) ADD_Disasm(info);
else if (Opcodes[op] == ADDA) ADDA_Disasm(info);
else if (Opcodes[op] == ADDI) ADDI_Disasm(info);
else if (Opcodes[op] == ADDQ) ADDQ_Disasm(info);
else if (Opcodes[op] == SUB0) SUB_Disasm(info);
else if (Opcodes[op] == SUB1) SUB_Disasm(info);
else if (Opcodes[op] == SUBA) SUBA_Disasm(info);
else if (Opcodes[op] == SUBI) SUBI_Disasm(info);
else if (Opcodes[op] == SUBQ) SUBQ_Disasm(info);
else if (Opcodes[op] == CMP) CMP_Disasm(info);
else if (Opcodes[op] == CMPM) CMPM_Disasm(info);
else if (Opcodes[op] == CMPA) CMPA_Disasm(info);
else if (Opcodes[op] == CMPI) CMPI_Disasm(info);
else if (Opcodes[op] == MULU) MULU_Disasm(info);
else if (Opcodes[op] == MULS) MULS_Disasm(info);
else if (Opcodes[op] == DIVU) DIVU_Disasm(info);
else if (Opcodes[op] == DIVS) DIVS_Disasm(info);
else if (Opcodes[op] == MOVEtSR) MOVEtSR_Disasm(info);//
else if (Opcodes[op] == MOVEfSR) MOVEfSR_Disasm(info);
else if (Opcodes[op] == MOVEUSP) MOVEUSP_Disasm(info);
else if (Opcodes[op] == ANDI_SR) ANDI_SR_Disasm(info);
else if (Opcodes[op] == EORI_SR) EORI_SR_Disasm(info);
else if (Opcodes[op] == ORI_SR) ORI_SR_Disasm(info);
else if (Opcodes[op] == MOVECCR) MOVECCR_Disasm(info);
else if (Opcodes[op] == TRAP) TRAP_Disasm(info);
else if (Opcodes[op] == NBCD) NBCD_Disasm(info);
else if (Opcodes[op] == ILLEGAL) ILLEGAL_Disasm(info);
else if (Opcodes[op] == STOP) STOP_Disasm(info);
else if (Opcodes[op] == TRAPV) TRAPV_Disasm(info);
else if (Opcodes[op] == CHK) CHK_Disasm(info);
else if (Opcodes[op] == NEGX) NEGX_Disasm(info);
else if (Opcodes[op] == SBCD0) SBCD0_Disasm(info);
else if (Opcodes[op] == SBCD1) SBCD1_Disasm(info);
else if (Opcodes[op] == ABCD0) ABCD0_Disasm(info);
else if (Opcodes[op] == ABCD1) ABCD1_Disasm(info);
else if (Opcodes[op] == EXGdd) EXGdd_Disasm(info);
else if (Opcodes[op] == EXGaa) EXGaa_Disasm(info);
else if (Opcodes[op] == EXGda) EXGda_Disasm(info);
else if (Opcodes[op] == TAS) TAS_Disasm(info);
else if (Opcodes[op] == MOVEP) MOVEP_Disasm(info);
else if (Opcodes[op] == ADDX0) ADDX0_Disasm(info);
else if (Opcodes[op] == ADDX1) ADDX1_Disasm(info);
else if (Opcodes[op] == SUBX0) SUBX0_Disasm(info);
else if (Opcodes[op] == SUBX1) SUBX1_Disasm(info);
else if (Opcodes[op] == ILL) ILL_Disasm(info);
// if (Opcodes[op] == MOVE) MOVE_Disasm(info);//
// else if (Opcodes[op] == MOVEA) MOVEA_Disasm(info);
// else if (Opcodes[op] == MOVEQ) MOVEQ_Disasm(info);
// else if (Opcodes[op] == MOVEM0) MOVEM0_Disasm(info);
// else if (Opcodes[op] == MOVEM1) MOVEM1_Disasm(info);
// else if (Opcodes[op] == LEA) LEA_Disasm(info);//
// else if (Opcodes[op] == CLR) CLR_Disasm(info);
// else if (Opcodes[op] == EXT) EXT_Disasm(info);
// else if (Opcodes[op] == PEA) PEA_Disasm(info);
// else if (Opcodes[op] == ANDI) ANDI_Disasm(info);
// else if (Opcodes[op] == ANDI_CCR) ANDI_CCR_Disasm(info);
// else if (Opcodes[op] == EORI) EORI_Disasm(info);
// else if (Opcodes[op] == EORI_CCR) EORI_CCR_Disasm(info);
// else if (Opcodes[op] == ORI) ORI_Disasm(info);
// else if (Opcodes[op] == ORI_CCR) ORI_CCR_Disasm(info);
// else if (Opcodes[op] == ASLd) ASLd_Disasm(info);
// else if (Opcodes[op] == ASRd) ASRd_Disasm(info);
// else if (Opcodes[op] == LSLd) LSLd_Disasm(info);
// else if (Opcodes[op] == LSRd) LSRd_Disasm(info);
// else if (Opcodes[op] == ROXLd) ROXLd_Disasm(info);
// else if (Opcodes[op] == ROXRd) ROXRd_Disasm(info);
// else if (Opcodes[op] == ROLd) ROLd_Disasm(info);
// else if (Opcodes[op] == RORd) RORd_Disasm(info);
// else if (Opcodes[op] == ASLd0) ASLd0_Disasm(info);
// else if (Opcodes[op] == ASRd0) ASRd0_Disasm(info);
// else if (Opcodes[op] == LSLd0) LSLd0_Disasm(info);
// else if (Opcodes[op] == LSRd0) LSRd0_Disasm(info);
// else if (Opcodes[op] == ROXLd0) ROXLd0_Disasm(info);
// else if (Opcodes[op] == ROXRd0) ROXRd0_Disasm(info);
// else if (Opcodes[op] == ROLd0) ROLd0_Disasm(info);
// else if (Opcodes[op] == RORd0) RORd0_Disasm(info);
// else if (Opcodes[op] == SWAP) SWAP_Disasm(info);
// else if (Opcodes[op] == AND0) AND0_Disasm(info);
// else if (Opcodes[op] == AND1) AND1_Disasm(info);
// else if (Opcodes[op] == EOR) EOR_Disasm(info);
// else if (Opcodes[op] == OR0) OR0_Disasm(info);
// else if (Opcodes[op] == OR1) OR1_Disasm(info);
// else if (Opcodes[op] == NOT) NOT_Disasm(info);
// else if (Opcodes[op] == NEG) NEG_Disasm(info);
// else if (Opcodes[op] == JMP) JMP_Disasm(info);
// else if (Opcodes[op] == JSR) JSR_Disasm(info);
// else if (Opcodes[op] == Bcc) Bcc_Disasm(info);
// else if (Opcodes[op] == BRA) BRA_Disasm(info);
// else if (Opcodes[op] == BSR) BSR_Disasm(info);
// else if (Opcodes[op] == DBcc) DBcc_Disasm(info);
// else if (Opcodes[op] == Scc) Scc_Disasm(info);
// else if (Opcodes[op] == RTE) RTE_Disasm(info);
// else if (Opcodes[op] == RTS) RTS_Disasm(info);
// else if (Opcodes[op] == RTR) RTR_Disasm(info);
// else if (Opcodes[op] == TST) TST_Disasm(info);
// else if (Opcodes[op] == BTSTi) BTSTi_Disasm(info);
// else if (Opcodes[op] == BTSTr) BTSTr_Disasm(info);
// else if (Opcodes[op] == BCHGi) BCHGi_Disasm(info);
// else if (Opcodes[op] == BCHGr) BCHGr_Disasm(info);
// else if (Opcodes[op] == BCLRi) BCLRi_Disasm(info);
// else if (Opcodes[op] == BCLRr) BCLRr_Disasm(info);
// else if (Opcodes[op] == BSETi) BSETi_Disasm(info);
// else if (Opcodes[op] == BSETr) BSETr_Disasm(info);
// else if (Opcodes[op] == LINK) LINK_Disasm(info);
// else if (Opcodes[op] == UNLK) UNLK_Disasm(info);
// else if (Opcodes[op] == RESET) RESET_Disasm(info);
// else if (Opcodes[op] == NOP) NOP_Disasm(info);
// else if (Opcodes[op] == ADD0) ADD_Disasm(info);
// else if (Opcodes[op] == ADD1) ADD_Disasm(info);
// else if (Opcodes[op] == ADDA) ADDA_Disasm(info);
// else if (Opcodes[op] == ADDI) ADDI_Disasm(info);
// else if (Opcodes[op] == ADDQ) ADDQ_Disasm(info);
// else if (Opcodes[op] == SUB0) SUB_Disasm(info);
// else if (Opcodes[op] == SUB1) SUB_Disasm(info);
// else if (Opcodes[op] == SUBA) SUBA_Disasm(info);
// else if (Opcodes[op] == SUBI) SUBI_Disasm(info);
// else if (Opcodes[op] == SUBQ) SUBQ_Disasm(info);
// else if (Opcodes[op] == CMP) CMP_Disasm(info);
// else if (Opcodes[op] == CMPM) CMPM_Disasm(info);
// else if (Opcodes[op] == CMPA) CMPA_Disasm(info);
// else if (Opcodes[op] == CMPI) CMPI_Disasm(info);
// else if (Opcodes[op] == MULU) MULU_Disasm(info);
// else if (Opcodes[op] == MULS) MULS_Disasm(info);
// else if (Opcodes[op] == DIVU) DIVU_Disasm(info);
// else if (Opcodes[op] == DIVS) DIVS_Disasm(info);
// else if (Opcodes[op] == MOVEtSR) MOVEtSR_Disasm(info);//
// else if (Opcodes[op] == MOVEfSR) MOVEfSR_Disasm(info);
// else if (Opcodes[op] == MOVEUSP) MOVEUSP_Disasm(info);
// else if (Opcodes[op] == ANDI_SR) ANDI_SR_Disasm(info);
// else if (Opcodes[op] == EORI_SR) EORI_SR_Disasm(info);
// else if (Opcodes[op] == ORI_SR) ORI_SR_Disasm(info);
// else if (Opcodes[op] == MOVECCR) MOVECCR_Disasm(info);
// else if (Opcodes[op] == TRAP) TRAP_Disasm(info);
// else if (Opcodes[op] == NBCD) NBCD_Disasm(info);
// else if (Opcodes[op] == ILLEGAL) ILLEGAL_Disasm(info);
// else if (Opcodes[op] == STOP) STOP_Disasm(info);
// else if (Opcodes[op] == TRAPV) TRAPV_Disasm(info);
// else if (Opcodes[op] == CHK) CHK_Disasm(info);
// else if (Opcodes[op] == NEGX) NEGX_Disasm(info);
// else if (Opcodes[op] == SBCD0) SBCD0_Disasm(info);
// else if (Opcodes[op] == SBCD1) SBCD1_Disasm(info);
// else if (Opcodes[op] == ABCD0) ABCD0_Disasm(info);
// else if (Opcodes[op] == ABCD1) ABCD1_Disasm(info);
// else if (Opcodes[op] == EXGdd) EXGdd_Disasm(info);
// else if (Opcodes[op] == EXGaa) EXGaa_Disasm(info);
// else if (Opcodes[op] == EXGda) EXGda_Disasm(info);
// else if (Opcodes[op] == TAS) TAS_Disasm(info);
// else if (Opcodes[op] == MOVEP) MOVEP_Disasm(info);
// else if (Opcodes[op] == ADDX0) ADDX0_Disasm(info);
// else if (Opcodes[op] == ADDX1) ADDX1_Disasm(info);
// else if (Opcodes[op] == SUBX0) SUBX0_Disasm(info);
// else if (Opcodes[op] == SUBX1) SUBX1_Disasm(info);
// else if (Opcodes[op] == ILL) ILL_Disasm(info);
var sb = new StringBuilder();
for (int p = info.PC; p < info.PC + info.Length; p += 2)
{
sb.AppendFormat("{0:X4} ", ReadOpWord(p));
}
info.RawBytes = sb.ToString();
return info;
}
// var sb = new StringBuilder();
// for (int p = info.PC; p < info.PC + info.Length; p += 2)
// {
// sb.AppendFormat("{0:X4} ", ReadOpWord(p));
// }
// info.RawBytes = sb.ToString();
// return info;
//}
}
}

View File

@ -4,7 +4,7 @@ namespace cpu.m68000
{
partial class MC68000
{
void MOVEtSR()
unsafe void MOVEtSR()
{
int mode = (op >> 3) & 7;
int reg = (op >> 0) & 7;
@ -17,9 +17,29 @@ namespace cpu.m68000
{
SR = ReadValueW(mode, reg);
}
pendingCycles -= 12 + EACyclesBW[mode, reg];
//pendingCycles -= 12 + EACyclesBW[mode, reg];
fixed (int* EACyclesBW_mode = &EACyclesBW[mode,0])
{
pendingCycles -= 12 + EACyclesBW_mode[reg];
}
}
//void MOVEtSR()
//{
// int mode = (op >> 3) & 7;
// int reg = (op >> 0) & 7;
// if (S == false)
// {
// //throw new Exception("Write to SR when not in supervisor mode. supposed to trap or something...");
// TrapVector2(8);
// }
// else
// {
// SR = ReadValueW(mode, reg);
// }
// pendingCycles -= 12 + EACyclesBW[mode, reg];
//}
void MOVEtSR_Disasm(DisassemblyInfo info)
{
int pc = info.PC + 2;

View File

@ -206,7 +206,7 @@ namespace cpu.m68000
PC = ReadOpLong(4);
}
public Action[] Opcodes = new Action[0x10000];
//public Action[] Opcodes = new Action[0x10000];
public ushort op;
public void Step()
@ -214,7 +214,8 @@ namespace cpu.m68000
//EmuLogger.Log(Disassemble(PC));
op = (ushort)ReadOpWord(PC); PC += 2;
Opcodes[op]();
//Opcodes[op]();
DoOpCode(op);
}
public override int ExecuteCycles(int cycles)
@ -231,7 +232,8 @@ namespace cpu.m68000
PPC = PC;
//debugger_start_cpu_hook_callback();
op = (ushort)ReadOpWord(PC); PC += 2;
Opcodes[op]();
//Opcodes[op]();
DoOpCode(op);
m68ki_check_interrupts();
//debugger_stop_cpu_hook_callback();
int delta = prevCycles - pendingCycles;
@ -267,15 +269,15 @@ namespace cpu.m68000
}
}
public string State()
{
string a = Disassemble(PC).ToString().PadRight(64);
//string a = string.Format("{0:X6}: {1:X4}", PC, ReadWord(PC)).PadRight(64);
string b = string.Format("D0:{0:X8} D1:{1:X8} D2:{2:X8} D3:{3:X8} D4:{4:X8} D5:{5:X8} D6:{6:X8} D7:{7:X8} ", D[0].u32, D[1].u32, D[2].u32, D[3].u32, D[4].u32, D[5].u32, D[6].u32, D[7].u32);
string c = string.Format("A0:{0:X8} A1:{1:X8} A2:{2:X8} A3:{3:X8} A4:{4:X8} A5:{5:X8} A6:{6:X8} A7:{7:X8} ", A[0].u32, A[1].u32, A[2].u32, A[3].u32, A[4].u32, A[5].u32, A[6].u32, A[7].u32);
string d = string.Format("SR:{0:X4} Pending {1}", SR, pendingCycles);
return a + b + c + d;
}
//public string State()
//{
// string a = Disassemble(PC).ToString().PadRight(64);
// //string a = string.Format("{0:X6}: {1:X4}", PC, ReadWord(PC)).PadRight(64);
// string b = string.Format("D0:{0:X8} D1:{1:X8} D2:{2:X8} D3:{3:X8} D4:{4:X8} D5:{5:X8} D6:{6:X8} D7:{7:X8} ", D[0].u32, D[1].u32, D[2].u32, D[3].u32, D[4].u32, D[5].u32, D[6].u32, D[7].u32);
// string c = string.Format("A0:{0:X8} A1:{1:X8} A2:{2:X8} A3:{3:X8} A4:{4:X8} A5:{5:X8} A6:{6:X8} A7:{7:X8} ", A[0].u32, A[1].u32, A[2].u32, A[3].u32, A[4].u32, A[5].u32, A[6].u32, A[7].u32);
// string d = string.Format("SR:{0:X4} Pending {1}", SR, pendingCycles);
// return a + b + c + d;
//}
public void SaveStateBinary(BinaryWriter writer)
{

View File

@ -0,0 +1,126 @@
namespace cpu.m68000
{
partial class MC68000
{
/// <summary>
/// 重写的68000指令调度
/// </summary>
/// <param name="op"></param>
void DoOpCode(ushort op)
{
MC68000Code opType = MC68000CodeArr[op];
switch (opType)
{
case MC68000Code.ORI: ORI(); break;
case MC68000Code.ILL: ILL(); break;
case MC68000Code.ORI_CCR: ORI_CCR(); break;
case MC68000Code.ORI_SR: ORI_SR(); break;
case MC68000Code.BTSTr: BTSTr(); break;
case MC68000Code.MOVEP: MOVEP(); break;
case MC68000Code.BCHGr: BCHGr(); break;
case MC68000Code.BCLRr: BCLRr(); break;
case MC68000Code.BSETr: BSETr(); break;
case MC68000Code.ANDI: ANDI(); break;
case MC68000Code.ANDI_CCR: ANDI_CCR(); break;
case MC68000Code.ANDI_SR: ANDI_SR(); break;
case MC68000Code.SUBI: SUBI(); break;
case MC68000Code.ADDI: ADDI(); break;
case MC68000Code.BTSTi: BTSTi(); break;
case MC68000Code.BCHGi: BCHGi(); break;
case MC68000Code.BCLRi: BCLRi(); break;
case MC68000Code.BSETi: BSETi(); break;
case MC68000Code.EORI: EORI(); break;
case MC68000Code.EORI_CCR: EORI_CCR(); break;
case MC68000Code.EORI_SR: EORI_SR(); break;
case MC68000Code.CMPI: CMPI(); break;
case MC68000Code.MOVE: MOVE(); break;
case MC68000Code.MOVEA: MOVEA(); break;
case MC68000Code.NEGX: NEGX(); break;
case MC68000Code.MOVEfSR: MOVEfSR(); break;
case MC68000Code.CHK: CHK(); break;
case MC68000Code.LEA: LEA(); break;
case MC68000Code.CLR: CLR(); break;
case MC68000Code.NEG: NEG(); break;
case MC68000Code.MOVECCR: MOVECCR(); break;
case MC68000Code.NOT: NOT(); break;
case MC68000Code.MOVEtSR: MOVEtSR(); break;
case MC68000Code.NBCD: NBCD(); break;
case MC68000Code.SWAP: SWAP(); break;
case MC68000Code.PEA: PEA(); break;
case MC68000Code.EXT: EXT(); break;
case MC68000Code.MOVEM0: MOVEM0(); break;
case MC68000Code.TST: TST(); break;
case MC68000Code.TAS: TAS(); break;
case MC68000Code.ILLEGAL: ILLEGAL(); break;
case MC68000Code.MOVEM1: MOVEM1(); break;
case MC68000Code.TRAP: TRAP(); break;
case MC68000Code.LINK: LINK(); break;
case MC68000Code.UNLK: UNLK(); break;
case MC68000Code.MOVEUSP: MOVEUSP(); break;
case MC68000Code.RESET: RESET(); break;
case MC68000Code.NOP: NOP(); break;
case MC68000Code.STOP: STOP(); break;
case MC68000Code.RTE: RTE(); break;
case MC68000Code.RTS: RTS(); break;
case MC68000Code.TRAPV: TRAPV(); break;
case MC68000Code.RTR: RTR(); break;
case MC68000Code.JSR: JSR(); break;
case MC68000Code.JMP: JMP(); break;
case MC68000Code.ADDQ: ADDQ(); break;
case MC68000Code.Scc: Scc(); break;
case MC68000Code.DBcc: DBcc(); break;
case MC68000Code.SUBQ: SUBQ(); break;
case MC68000Code.BRA: BRA(); break;
case MC68000Code.BSR: BSR(); break;
case MC68000Code.Bcc: Bcc(); break;
case MC68000Code.MOVEQ: MOVEQ(); break;
case MC68000Code.OR0: OR0(); break;
case MC68000Code.DIVU: DIVU(); break;
case MC68000Code.SBCD0: SBCD0(); break;
case MC68000Code.SBCD1: SBCD1(); break;
case MC68000Code.OR1: OR1(); break;
case MC68000Code.DIVS: DIVS(); break;
case MC68000Code.SUB0: SUB0(); break;
case MC68000Code.SUBA: SUBA(); break;
case MC68000Code.SUBX0: SUBX0(); break;
case MC68000Code.SUBX1: SUBX1(); break;
case MC68000Code.SUB1: SUB1(); break;
case MC68000Code.CMP: CMP(); break;
case MC68000Code.CMPA: CMPA(); break;
case MC68000Code.EOR: EOR(); break;
case MC68000Code.CMPM: CMPM(); break;
case MC68000Code.AND0: AND0(); break;
case MC68000Code.MULU: MULU(); break;
case MC68000Code.ABCD0: ABCD0(); break;
case MC68000Code.ABCD1: ABCD1(); break;
case MC68000Code.AND1: AND1(); break;
case MC68000Code.EXGdd: EXGdd(); break;
case MC68000Code.EXGaa: EXGaa(); break;
case MC68000Code.EXGda: EXGda(); break;
case MC68000Code.MULS: MULS(); break;
case MC68000Code.ADD0: ADD0(); break;
case MC68000Code.ADDA: ADDA(); break;
case MC68000Code.ADDX0: ADDX0(); break;
case MC68000Code.ADDX1: ADDX1(); break;
case MC68000Code.ADD1: ADD1(); break;
case MC68000Code.ASRd: ASRd(); break;
case MC68000Code.LSRd: LSRd(); break;
case MC68000Code.ROXRd: ROXRd(); break;
case MC68000Code.RORd: RORd(); break;
case MC68000Code.ASRd0: ASRd0(); break;
case MC68000Code.ASLd: ASLd(); break;
case MC68000Code.LSLd: LSLd(); break;
case MC68000Code.ROXLd: ROXLd(); break;
case MC68000Code.ROLd: ROLd(); break;
case MC68000Code.ASLd0: ASLd0(); break;
case MC68000Code.LSRd0: LSRd0(); break;
case MC68000Code.LSLd0: LSLd0(); break;
case MC68000Code.ROXRd0: ROXRd0(); break;
case MC68000Code.ROXLd0: ROXLd0(); break;
case MC68000Code.RORd0: RORd0(); break;
case MC68000Code.ROLd0: ROLd0(); break;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6be477f2e8966cf4c8eb308e23568bbf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb52db132edb72746a600471b199d49b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,5 @@
using System;
using MAME.Core;
using System;
using System.Collections.Generic;
namespace cpu.m68000
@ -7,187 +8,286 @@ namespace cpu.m68000
{
void BuildOpcodeTable()
{
Assign("ill", ILL, "", "Data8", "Data8");//
Assign("ori2ccr", ORI_CCR, "0000000000111100");//
Assign("ori2sr", ORI_SR, "0000000001111100");
Assign("ori", ORI, "00000000", "Size2_1", "OAmXn");
Assign("andi2ccr", ANDI_CCR, "0000001000111100");//
Assign("andi2sr", ANDI_SR, "0000001001111100");
Assign("andi", ANDI, "00000010", "Size2_1", "OAmXn");
Assign("subi", SUBI, "00000100", "Size2_1", "OAmXn");
Assign("addi", ADDI, "00000110", "Size2_1", "OAmXn");
Assign("eori2ccr", EORI_CCR, "0000101000111100");//
Assign("eori2sr", EORI_SR, "0000101001111100");
Assign("eori", EORI, "00001010", "Size2_1", "OAmXn");
Assign("cmpi", CMPI, "00001100", "Size2_1", "OAmXn");
Assign("btst", BTSTi, "0000100000", "BAmXn");
Assign("bchg", BCHGi, "0000100001", "OAmXn");
Assign("bclr", BCLRi, "0000100010", "OAmXn");
Assign("bset", BSETi, "0000100011", "OAmXn");
Assign("btst", BTSTr, "0000", "Xn", "100", "AmXn");
Assign("bchg", BCHGr, "0000", "Xn", "101", "OAmXn");
Assign("bclr", BCLRr, "0000", "Xn", "110", "OAmXn");
Assign("bset", BSETr, "0000", "Xn", "111", "OAmXn");
Assign("movep", MOVEP, "0000", "Xn", "1", "Data1", "Size1", "001", "Xn");//
Assign("movea", MOVEA, "00", "Size2_2", "Xn", "001", "AmXn");
Assign("move", MOVE, "00", "01", "OXnAm", "MAmXn");
Assign("move", MOVE, "00", "Size2_2", "OXnAm", "AmXn");
Assign("movefsr", MOVEfSR, "0100000011", "OAmXn");
Assign("moveccr", MOVECCR, "0100010011", "MAmXn");
Assign("move2sr", MOVEtSR, "0100011011", "MAmXn");
Assign("negx", NEGX, "01000000", "Size2_1", "OAmXn");//
Assign("clr", CLR, "01000010", "Size2_1", "OAmXn");
Assign("neg", NEG, "01000100", "Size2_1", "OAmXn");
Assign("not", NOT, "01000110", "Size2_1", "OAmXn");
Assign("ext", EXT, "010010001", "Size1", "000", "Xn");
Assign("nbcd", NBCD, "0100100000", "OAmXn");//
Assign("swap", SWAP, "0100100001000", "Xn");
Assign("pea", PEA, "0100100001", "LAmXn");
Assign("illegal", ILLEGAL, "0100101011111100");//
Assign("tas", TAS, "0100101011", "OAmXn");//
Assign("tst", TST, "01001010", "Size2_1", "OAmXn");
Assign("trap", TRAP, "010011100100", "Data4");
Assign("link", LINK, "0100111001010", "Xn");
Assign("unlk", UNLK, "0100111001011", "Xn");
Assign("moveusp", MOVEUSP, "010011100110", "Data1", "Xn");
Assign("reset", RESET, "0100111001110000");//
Assign("nop", NOP, "0100111001110001");
Assign("stop", STOP, "0100111001110010");//
Assign("rte", RTE, "0100111001110011");
Assign("rts", RTS, "0100111001110101");
Assign("trapv", TRAPV, "0100111001110110");//
Assign("rtr", RTR, "0100111001110111");
Assign("jsr", JSR, "0100111010", "LAmXn");
Assign("jmp", JMP, "0100111011", "LAmXn");
Assign("movem", MOVEM0, "010010001", "Size1", "M2AmXn");
Assign("movem", MOVEM1, "010011001", "Size1", "M3AmXn");
Assign("lea", LEA, "0100", "Xn", "111", "LAmXn");
Assign("chk", CHK, "0100", "Xn", "110", "MAmXn");//
Assign("addq", ADDQ, "0101", "Data3", "0", "00", "OAmXn");
Assign("addq", ADDQ, "0101", "Data3", "0", "Size2_3", "A2AmXn");
Assign("subq", SUBQ, "0101", "Data3", "1", "00", "OAmXn");
Assign("subq", SUBQ, "0101", "Data3", "1", "Size2_3", "A2AmXn");
Assign("scc", Scc, "0101", "CondAll", "11", "OAmXn");
Assign("dbcc", DBcc, "0101", "CondAll", "11001", "Xn");
Assign("bra", BRA, "01100000", "Data8");
Assign("bsr", BSR, "01100001", "Data8");
Assign("bcc", Bcc, "0110", "CondMain", "Data8");
Assign("moveq", MOVEQ, "0111", "Xn", "0", "Data8");
Assign("divu", DIVU, "1000", "Xn", "011", "MAmXn");
Assign("divs", DIVS, "1000", "Xn", "111", "MAmXn");
Assign("sbcd", SBCD0, "1000", "Xn", "100000", "Xn");//
Assign("sbcd", SBCD1, "1000", "Xn", "100001", "Xn");//
Assign("or", OR0, "1000", "Xn", "0", "Size2_1", "MAmXn");
Assign("or", OR1, "1000", "Xn", "1", "Size2_1", "O2AmXn");
Assign("sub", SUB0, "1001", "Xn", "0", "00", "MAmXn");
Assign("sub", SUB0, "1001", "Xn", "0", "Size2_3", "AmXn");
Assign("sub", SUB1, "1001", "Xn", "1", "00", "O2AmXn");
Assign("sub", SUB1, "1001", "Xn", "1", "Size2_3", "A2AmXn");
Assign("subx", SUBX0, "1001", "Xn", "1", "Size2_1", "000", "Xn");//
Assign("subx", SUBX1, "1001", "Xn", "1", "Size2_1", "001", "Xn");//
Assign("suba", SUBA, "1001", "Xn", "Size1", "11", "AmXn");
Assign("eor", EOR, "1011", "Xn", "1", "Size2_1", "OAmXn");
Assign("cmpm", CMPM, "1011", "Xn", "1", "Size2_1", "001", "Xn");
Assign("cmp", CMP, "1011", "Xn", "0", "00", "MAmXn");
Assign("cmp", CMP, "1011", "Xn", "0", "Size2_3", "AmXn");
Assign("cmpa", CMPA, "1011", "Xn", "Size1", "11", "AmXn");
Assign("mulu", MULU, "1100", "Xn", "011", "MAmXn");
Assign("muls", MULS, "1100", "Xn", "111", "MAmXn");
Assign("abcd", ABCD0, "1100", "Xn", "100000", "Xn");//
Assign("abcd", ABCD1, "1100", "Xn", "100001", "Xn");//
Assign("exg", EXGdd, "1100", "Xn", "101000", "Xn");//
Assign("exg", EXGaa, "1100", "Xn", "101001", "Xn");//
Assign("exg", EXGda, "1100", "Xn", "110001", "Xn");//
Assign("and", AND0, "1100", "Xn", "0", "Size2_1", "MAmXn");
Assign("and", AND1, "1100", "Xn", "1", "Size2_1", "O2AmXn");
Assign("add", ADD0, "1101", "Xn", "0", "00", "MAmXn");
Assign("add", ADD0, "1101", "Xn", "0", "Size2_3", "AmXn");
Assign("add", ADD1, "1101", "Xn", "1", "Size2_1", "O2AmXn");
Assign("addx", ADDX0, "1101", "Xn", "1", "Size2_1", "000", "Xn");//
Assign("addx", ADDX1, "1101", "Xn", "1", "Size2_1", "001", "Xn");//
Assign("adda", ADDA, "1101", "Xn", "Size1", "11", "AmXn");
Assign("asl", ASLd0, "1110000111", "O2AmXn");//
Assign("asr", ASRd0, "1110000011", "O2AmXn");//
Assign("lsl", LSLd0, "1110001111", "O2AmXn");//
Assign("lsr", LSRd0, "1110001011", "O2AmXn");//
Assign("roxl", ROXLd0, "1110010111", "O2AmXn");//
Assign("roxr", ROXRd0, "1110010011", "O2AmXn");//
Assign("rol", ROLd0, "1110011111", "O2AmXn");//
Assign("ror", RORd0, "1110011011", "O2AmXn");//
Assign("asl", ASLd, "1110", "Data3", "1", "Size2_1", "Data1", "00", "Xn");
Assign("asr", ASRd, "1110", "Data3", "0", "Size2_1", "Data1", "00", "Xn");
Assign("lsl", LSLd, "1110", "Data3", "1", "Size2_1", "Data1", "01", "Xn");
Assign("lsr", LSRd, "1110", "Data3", "0", "Size2_1", "Data1", "01", "Xn");
Assign("roxl", ROXLd, "1110", "Data3", "1", "Size2_1", "Data1", "10", "Xn");
Assign("roxr", ROXRd, "1110", "Data3", "0", "Size2_1", "Data1", "10", "Xn");
Assign("rol", ROLd, "1110", "Data3", "1", "Size2_1", "Data1", "11", "Xn");
Assign("ror", RORd, "1110", "Data3", "0", "Size2_1", "Data1", "11", "Xn");
//Assign("ill", ILL, "", "Data8", "Data8");//
//Assign("ori2ccr", ORI_CCR, "0000000000111100");//
//Assign("ori2sr", ORI_SR, "0000000001111100");
//Assign("ori", ORI, "00000000", "Size2_1", "OAmXn");
//Assign("andi2ccr", ANDI_CCR, "0000001000111100");//
//Assign("andi2sr", ANDI_SR, "0000001001111100");
//Assign("andi", ANDI, "00000010", "Size2_1", "OAmXn");
//Assign("subi", SUBI, "00000100", "Size2_1", "OAmXn");
//Assign("addi", ADDI, "00000110", "Size2_1", "OAmXn");
//Assign("eori2ccr", EORI_CCR, "0000101000111100");//
//Assign("eori2sr", EORI_SR, "0000101001111100");
//Assign("eori", EORI, "00001010", "Size2_1", "OAmXn");
//Assign("cmpi", CMPI, "00001100", "Size2_1", "OAmXn");
//Assign("btst", BTSTi, "0000100000", "BAmXn");
//Assign("bchg", BCHGi, "0000100001", "OAmXn");
//Assign("bclr", BCLRi, "0000100010", "OAmXn");
//Assign("bset", BSETi, "0000100011", "OAmXn");
//Assign("btst", BTSTr, "0000", "Xn", "100", "AmXn");
//Assign("bchg", BCHGr, "0000", "Xn", "101", "OAmXn");
//Assign("bclr", BCLRr, "0000", "Xn", "110", "OAmXn");
//Assign("bset", BSETr, "0000", "Xn", "111", "OAmXn");
//Assign("movep", MOVEP, "0000", "Xn", "1", "Data1", "Size1", "001", "Xn");//
//Assign("movea", MOVEA, "00", "Size2_2", "Xn", "001", "AmXn");
//Assign("move", MOVE, "00", "01", "OXnAm", "MAmXn");
//Assign("move", MOVE, "00", "Size2_2", "OXnAm", "AmXn");
//Assign("movefsr", MOVEfSR, "0100000011", "OAmXn");
//Assign("moveccr", MOVECCR, "0100010011", "MAmXn");
//Assign("move2sr", MOVEtSR, "0100011011", "MAmXn");
//Assign("negx", NEGX, "01000000", "Size2_1", "OAmXn");//
//Assign("clr", CLR, "01000010", "Size2_1", "OAmXn");
//Assign("neg", NEG, "01000100", "Size2_1", "OAmXn");
//Assign("not", NOT, "01000110", "Size2_1", "OAmXn");
//Assign("ext", EXT, "010010001", "Size1", "000", "Xn");
//Assign("nbcd", NBCD, "0100100000", "OAmXn");//
//Assign("swap", SWAP, "0100100001000", "Xn");
//Assign("pea", PEA, "0100100001", "LAmXn");
//Assign("illegal", ILLEGAL, "0100101011111100");//
//Assign("tas", TAS, "0100101011", "OAmXn");//
//Assign("tst", TST, "01001010", "Size2_1", "OAmXn");
//Assign("trap", TRAP, "010011100100", "Data4");
//Assign("link", LINK, "0100111001010", "Xn");
//Assign("unlk", UNLK, "0100111001011", "Xn");
//Assign("moveusp", MOVEUSP, "010011100110", "Data1", "Xn");
//Assign("reset", RESET, "0100111001110000");//
//Assign("nop", NOP, "0100111001110001");
//Assign("stop", STOP, "0100111001110010");//
//Assign("rte", RTE, "0100111001110011");
//Assign("rts", RTS, "0100111001110101");
//Assign("trapv", TRAPV, "0100111001110110");//
//Assign("rtr", RTR, "0100111001110111");
//Assign("jsr", JSR, "0100111010", "LAmXn");
//Assign("jmp", JMP, "0100111011", "LAmXn");
//Assign("movem", MOVEM0, "010010001", "Size1", "M2AmXn");
//Assign("movem", MOVEM1, "010011001", "Size1", "M3AmXn");
//Assign("lea", LEA, "0100", "Xn", "111", "LAmXn");
//Assign("chk", CHK, "0100", "Xn", "110", "MAmXn");//
//Assign("addq", ADDQ, "0101", "Data3", "0", "00", "OAmXn");
//Assign("addq", ADDQ, "0101", "Data3", "0", "Size2_3", "A2AmXn");
//Assign("subq", SUBQ, "0101", "Data3", "1", "00", "OAmXn");
//Assign("subq", SUBQ, "0101", "Data3", "1", "Size2_3", "A2AmXn");
//Assign("scc", Scc, "0101", "CondAll", "11", "OAmXn");
//Assign("dbcc", DBcc, "0101", "CondAll", "11001", "Xn");
//Assign("bra", BRA, "01100000", "Data8");
//Assign("bsr", BSR, "01100001", "Data8");
//Assign("bcc", Bcc, "0110", "CondMain", "Data8");
//Assign("moveq", MOVEQ, "0111", "Xn", "0", "Data8");
//Assign("divu", DIVU, "1000", "Xn", "011", "MAmXn");
//Assign("divs", DIVS, "1000", "Xn", "111", "MAmXn");
//Assign("sbcd", SBCD0, "1000", "Xn", "100000", "Xn");//
//Assign("sbcd", SBCD1, "1000", "Xn", "100001", "Xn");//
//Assign("or", OR0, "1000", "Xn", "0", "Size2_1", "MAmXn");
//Assign("or", OR1, "1000", "Xn", "1", "Size2_1", "O2AmXn");
//Assign("sub", SUB0, "1001", "Xn", "0", "00", "MAmXn");
//Assign("sub", SUB0, "1001", "Xn", "0", "Size2_3", "AmXn");
//Assign("sub", SUB1, "1001", "Xn", "1", "00", "O2AmXn");
//Assign("sub", SUB1, "1001", "Xn", "1", "Size2_3", "A2AmXn");
//Assign("subx", SUBX0, "1001", "Xn", "1", "Size2_1", "000", "Xn");//
//Assign("subx", SUBX1, "1001", "Xn", "1", "Size2_1", "001", "Xn");//
//Assign("suba", SUBA, "1001", "Xn", "Size1", "11", "AmXn");
//Assign("eor", EOR, "1011", "Xn", "1", "Size2_1", "OAmXn");
//Assign("cmpm", CMPM, "1011", "Xn", "1", "Size2_1", "001", "Xn");
//Assign("cmp", CMP, "1011", "Xn", "0", "00", "MAmXn");
//Assign("cmp", CMP, "1011", "Xn", "0", "Size2_3", "AmXn");
//Assign("cmpa", CMPA, "1011", "Xn", "Size1", "11", "AmXn");
//Assign("mulu", MULU, "1100", "Xn", "011", "MAmXn");
//Assign("muls", MULS, "1100", "Xn", "111", "MAmXn");
//Assign("abcd", ABCD0, "1100", "Xn", "100000", "Xn");//
//Assign("abcd", ABCD1, "1100", "Xn", "100001", "Xn");//
//Assign("exg", EXGdd, "1100", "Xn", "101000", "Xn");//
//Assign("exg", EXGaa, "1100", "Xn", "101001", "Xn");//
//Assign("exg", EXGda, "1100", "Xn", "110001", "Xn");//
//Assign("and", AND0, "1100", "Xn", "0", "Size2_1", "MAmXn");
//Assign("and", AND1, "1100", "Xn", "1", "Size2_1", "O2AmXn");
//Assign("add", ADD0, "1101", "Xn", "0", "00", "MAmXn");
//Assign("add", ADD0, "1101", "Xn", "0", "Size2_3", "AmXn");
//Assign("add", ADD1, "1101", "Xn", "1", "Size2_1", "O2AmXn");
//Assign("addx", ADDX0, "1101", "Xn", "1", "Size2_1", "000", "Xn");//
//Assign("addx", ADDX1, "1101", "Xn", "1", "Size2_1", "001", "Xn");//
//Assign("adda", ADDA, "1101", "Xn", "Size1", "11", "AmXn");
//Assign("asl", ASLd0, "1110000111", "O2AmXn");//
//Assign("asr", ASRd0, "1110000011", "O2AmXn");//
//Assign("lsl", LSLd0, "1110001111", "O2AmXn");//
//Assign("lsr", LSRd0, "1110001011", "O2AmXn");//
//Assign("roxl", ROXLd0, "1110010111", "O2AmXn");//
//Assign("roxr", ROXRd0, "1110010011", "O2AmXn");//
//Assign("rol", ROLd0, "1110011111", "O2AmXn");//
//Assign("ror", RORd0, "1110011011", "O2AmXn");//
//Assign("asl", ASLd, "1110", "Data3", "1", "Size2_1", "Data1", "00", "Xn");
//Assign("asr", ASRd, "1110", "Data3", "0", "Size2_1", "Data1", "00", "Xn");
//Assign("lsl", LSLd, "1110", "Data3", "1", "Size2_1", "Data1", "01", "Xn");
//Assign("lsr", LSRd, "1110", "Data3", "0", "Size2_1", "Data1", "01", "Xn");
//Assign("roxl", ROXLd, "1110", "Data3", "1", "Size2_1", "Data1", "10", "Xn");
//Assign("roxr", ROXRd, "1110", "Data3", "0", "Size2_1", "Data1", "10", "Xn");
//Assign("rol", ROLd, "1110", "Data3", "1", "Size2_1", "Data1", "11", "Xn");
//Assign("ror", RORd, "1110", "Data3", "0", "Size2_1", "Data1", "11", "Xn");
//string[] temp = new string[Opcodes.Length];
//HashSet<string> seen = new HashSet<string>();
//var sb = ObjectPoolAuto.AcquireStringBuilder();
//var sb2 = ObjectPoolAuto.AcquireStringBuilder();
//sb.Append("[");
//for (int i = 0; i < Opcodes.Length; i++)
//{
// temp[i] = Opcodes[i].Method.Name;
// sb.Append("MC68000Code.");
// sb.Append(temp[i]);
// sb.Append(",");
// if (!seen.Contains(temp[i]))
// {
// seen.Add(temp[i]);
// }
//}
//sb.Append("]");
//sb2.Append("[");
//foreach (var s in seen)
//{
// sb2.Append(s);
// sb2.Append(",");
//}
//sb2.Append("]");
//var all = sb.ToString();
//var all2 = sb2.ToString();
//ObjectPoolAuto.Release(sb);
}
//void Assign(string instr, Action exec, string root, params string[] bitfield)
//{
// List<string> opList = new List<string>();
// opList.Add(root);
// foreach (var component in bitfield)
// {
// if (IsBinary(component)) AppendConstant(opList, component);
// else if (component == "Size1") opList = AppendPermutations(opList, Size1);
// else if (component == "Size2_0") opList = AppendPermutations(opList, Size2_0);
// else if (component == "Size2_1") opList = AppendPermutations(opList, Size2_1);
// else if (component == "Size2_2") opList = AppendPermutations(opList, Size2_2);
// else if (component == "Size2_3") opList = AppendPermutations(opList, Size2_3);
// else if (component == "OXnAm") opList = AppendPermutations(opList, OXn3Am3);//0,2-6,7_0-7_1
// else if (component == "AmXn") opList = AppendPermutations(opList, Am3Xn3);//0-6,7_0-7_4
// else if (component == "OAmXn") opList = AppendPermutations(opList, OAm3Xn3);//0,2-6,7_0-7_1
// else if (component == "BAmXn") opList = AppendPermutations(opList, BAm3Xn3);//0,2-6,7_0-7_3
// else if (component == "MAmXn") opList = AppendPermutations(opList, MAm3Xn3);//0,2-6,7_0-7_4
// else if (component == "AAmXn") opList = AppendPermutations(opList, AAm3Xn3);//1-6,7_0-7_4
// else if (component == "LAmXn") opList = AppendPermutations(opList, LAm3Xn3);//2,5-6,7_0-7_3
// else if (component == "M2AmXn") opList = AppendPermutations(opList, M2Am3Xn3);//2,4-6,7_0-7_1
// else if (component == "M3AmXn") opList = AppendPermutations(opList, M3Am3Xn3);//2-3,5-6,7_0-7_3
// else if (component == "A2AmXn") opList = AppendPermutations(opList, A2Am3Xn3);//0-6,7_0-7_1
// else if (component == "O2AmXn") opList = AppendPermutations(opList, O2Am3Xn3);//2-6,7_0-7_1
// else if (component == "Xn") opList = AppendPermutations(opList, Xn3);
// else if (component == "CondMain") opList = AppendPermutations(opList, ConditionMain);
// else if (component == "CondAll") opList = AppendPermutations(opList, ConditionAll);
// else if (component == "Data1") opList = AppendData(opList, 1);
// else if (component == "Data3") opList = AppendData(opList, 3);
// else if (component == "Data4") opList = AppendData(opList, 4);
// else if (component == "Data8") opList = AppendData(opList, 8);
// }
// foreach (var opcode in opList)
// {
// int opc = Convert.ToInt32(opcode, 2);
// Opcodes[opc] = exec;
// }
//}
void Assign(string instr, Action exec, string root, params string[] bitfield)
{
List<string> opList = new List<string>();
opList.Add(root);
foreach (var component in bitfield)
{
if (IsBinary(component)) AppendConstant(opList, component);
else if (component == "Size1") opList = AppendPermutations(opList, Size1);
else if (component == "Size2_0") opList = AppendPermutations(opList, Size2_0);
else if (component == "Size2_1") opList = AppendPermutations(opList, Size2_1);
else if (component == "Size2_2") opList = AppendPermutations(opList, Size2_2);
else if (component == "Size2_3") opList = AppendPermutations(opList, Size2_3);
else if (component == "OXnAm") opList = AppendPermutations(opList, OXn3Am3);//0,2-6,7_0-7_1
else if (component == "AmXn") opList = AppendPermutations(opList, Am3Xn3);//0-6,7_0-7_4
else if (component == "OAmXn") opList = AppendPermutations(opList, OAm3Xn3);//0,2-6,7_0-7_1
else if (component == "BAmXn") opList = AppendPermutations(opList, BAm3Xn3);//0,2-6,7_0-7_3
else if (component == "MAmXn") opList = AppendPermutations(opList, MAm3Xn3);//0,2-6,7_0-7_4
else if (component == "AAmXn") opList = AppendPermutations(opList, AAm3Xn3);//1-6,7_0-7_4
else if (component == "LAmXn") opList = AppendPermutations(opList, LAm3Xn3);//2,5-6,7_0-7_3
else if (component == "M2AmXn") opList = AppendPermutations(opList, M2Am3Xn3);//2,4-6,7_0-7_1
else if (component == "M3AmXn") opList = AppendPermutations(opList, M3Am3Xn3);//2-3,5-6,7_0-7_3
else if (component == "A2AmXn") opList = AppendPermutations(opList, A2Am3Xn3);//0-6,7_0-7_1
else if (component == "O2AmXn") opList = AppendPermutations(opList, O2Am3Xn3);//2-6,7_0-7_1
else if (component == "Xn") opList = AppendPermutations(opList, Xn3);
else if (component == "CondMain") opList = AppendPermutations(opList, ConditionMain);
else if (component == "CondAll") opList = AppendPermutations(opList, ConditionAll);
else if (component == "Data1") opList = AppendData(opList, 1);
else if (component == "Data3") opList = AppendData(opList, 3);
else if (component == "Data4") opList = AppendData(opList, 4);
else if (component == "Data8") opList = AppendData(opList, 8);
}
foreach (var opcode in opList)
{
int opc = Convert.ToInt32(opcode, 2);
Opcodes[opc] = exec;
}
//List<string> opList = ObjectPoolAuto.AcquireList<string>();
//opList.Add(root);
//foreach (var component in bitfield)
//{
// if (IsBinary(component)) AppendConstant(ref opList, component);
// else if (component == "Size1") AppendPermutations(ref opList, Size1);
// else if (component == "Size2_0") AppendPermutations(ref opList, Size2_0);
// else if (component == "Size2_1") AppendPermutations(ref opList, Size2_1);
// else if (component == "Size2_2") AppendPermutations(ref opList, Size2_2);
// else if (component == "Size2_3") AppendPermutations(ref opList, Size2_3);
// else if (component == "OXnAm") AppendPermutations(ref opList, OXn3Am3);//0,2-6,7_0-7_1
// else if (component == "AmXn") AppendPermutations(ref opList, Am3Xn3);//0-6,7_0-7_4
// else if (component == "OAmXn") AppendPermutations(ref opList, OAm3Xn3);//0,2-6,7_0-7_1
// else if (component == "BAmXn") AppendPermutations(ref opList, BAm3Xn3);//0,2-6,7_0-7_3
// else if (component == "MAmXn") AppendPermutations(ref opList, MAm3Xn3);//0,2-6,7_0-7_4
// else if (component == "AAmXn") AppendPermutations(ref opList, AAm3Xn3);//1-6,7_0-7_4
// else if (component == "LAmXn") AppendPermutations(ref opList, LAm3Xn3);//2,5-6,7_0-7_3
// else if (component == "M2AmXn") AppendPermutations(ref opList, M2Am3Xn3);//2,4-6,7_0-7_1
// else if (component == "M3AmXn") AppendPermutations(ref opList, M3Am3Xn3);//2-3,5-6,7_0-7_3
// else if (component == "A2AmXn") AppendPermutations(ref opList, A2Am3Xn3);//0-6,7_0-7_1
// else if (component == "O2AmXn") AppendPermutations(ref opList, O2Am3Xn3);//2-6,7_0-7_1
// else if (component == "Xn") AppendPermutations(ref opList, Xn3);
// else if (component == "CondMain") AppendPermutations(ref opList, ConditionMain);
// else if (component == "CondAll") AppendPermutations(ref opList, ConditionAll);
// else if (component == "Data1") AppendData(ref opList, 1);
// else if (component == "Data3") AppendData(ref opList, 3);
// else if (component == "Data4") AppendData(ref opList, 4);
// else if (component == "Data8") AppendData(ref opList, 8);
//}
//foreach (var opcode in opList)
//{
// int opc = Convert.ToInt32(opcode, 2);
// Opcodes[opc] = exec;
//}
//ObjectPoolAuto.Release(opList);
}
void AppendConstant(List<string> ops, string constant)
void AppendConstant(ref List<string> ops, string constant)
{
for (int i = 0; i < ops.Count; i++)
ops[i] = ops[i] + constant;
}
List<string> AppendPermutations(List<string> ops, string[] permutations)
{
List<string> output = new List<string>();
//List<string> AppendPermutations(List<string> ops, string[] permutations)
//{
// List<string> output = new List<string>();
// foreach (var input in ops)
// foreach (var perm in permutations)
// output.Add(input + perm);
// return output;
//}
void AppendPermutations(ref List<string> ops, string[] permutations)
{
List<string> output = ObjectPoolAuto.AcquireList<string>();
foreach (var input in ops)
foreach (var perm in permutations)
output.Add(input + perm);
return output;
ops.Clear();
ops.AddRange(output);
ObjectPoolAuto.Release(output);
}
List<string> AppendData(List<string> ops, int bits)
{
List<string> output = new List<string>();
//List<string> AppendData(List<string> ops, int bits)
//{
// List<string> output = new List<string>();
// foreach (var input in ops)
// for (int i = 0; i < BinaryExp(bits); i++)
// output.Add(input + Convert.ToString(i, 2).PadLeft(bits, '0'));
// return output;
//}
void AppendData(ref List<string> ops, int bits)
{
List<string> output = ObjectPoolAuto.AcquireList<string>();
foreach (var input in ops)
for (int i = 0; i < BinaryExp(bits); i++)
output.Add(input + Convert.ToString(i, 2).PadLeft(bits, '0'));
return output;
{
//output.Add(input + Convert.ToString(i, 2).PadLeft(bits, '0'));
var sb = ObjectPoolAuto.AcquireStringBuilder();
sb.Append(input);
sb.Append(Convert.ToString(i, 2).PadLeft(bits, '0'));
output.Add(sb.ToString());
ObjectPoolAuto.Release(sb);
}
ops.Clear();
ops.AddRange(output);
ObjectPoolAuto.Release(output);
}
int BinaryExp(int bits)

View File

@ -342,19 +342,24 @@ namespace MAME.Core
{
paletteram16[offset] = data;
ushort data1 = paletteram16[offset];
//TODO 通道修改BGRA->RGBA
Palette.palette_set_callback(offset, (uint)((Palette.pal5bit((byte)(((data1 >> 11) & 0x1e) | ((data1 >> 3) & 0x01))) << 16) | (Palette.pal5bit((byte)(((data >> 7) & 0x1e) | ((data >> 2) & 0x01))) << 8) | Palette.pal5bit((byte)(((data >> 3) & 0x1e) | ((data >> 1) & 0x01)))));
}
public static void paletteram16_RRRRGGGGBBBBRGBx_word_w1(int offset, byte data)
{
paletteram16[offset] = (ushort)((data << 8) | (paletteram16[offset] & 0xff));
ushort data1 = paletteram16[offset];
//TODO 通道修改BGRA->RGBA
Palette.palette_set_callback(offset, (uint)((Palette.pal5bit((byte)(((data1 >> 11) & 0x1e) | ((data1 >> 3) & 0x01))) << 16) | (Palette.pal5bit((byte)(((data >> 7) & 0x1e) | ((data >> 2) & 0x01))) << 8) | Palette.pal5bit((byte)(((data >> 3) & 0x1e) | ((data >> 1) & 0x01)))));
}
public static void paletteram16_RRRRGGGGBBBBRGBx_word_w2(int offset, byte data)
{
paletteram16[offset] = (ushort)((paletteram16[offset] & 0xff00) | data);
ushort data1 = paletteram16[offset];
//TODO 通道修改BGRA->RGBA
Palette.palette_set_callback(offset, (uint)((Palette.pal5bit((byte)(((data1 >> 11) & 0x1e) | ((data1 >> 3) & 0x01))) << 16) | (Palette.pal5bit((byte)(((data >> 7) & 0x1e) | ((data >> 2) & 0x01))) << 8) | Palette.pal5bit((byte)(((data >> 3) & 0x1e) | ((data >> 1) & 0x01)))));
}
}
}

View File

@ -87,7 +87,7 @@ namespace MAME.Core
}
}
#region
#region Update
public static void mame_execute_UpdateMode_Start()
{

View File

@ -304,11 +304,15 @@ namespace MAME.Core
}
public static uint make_rgb(int r, int g, int b)
{
return ((((uint)(r) & 0xff) << 16) | (((uint)(g) & 0xff) << 8) | ((uint)(b) & 0xff));
//return ((((uint)(r) & 0xff) << 16) | (((uint)(g) & 0xff) << 8) | ((uint)(b) & 0xff));
//通道修改BGRA->RGBA
return ((((uint)(b) & 0xff) << 16) | (((uint)(g) & 0xff) << 8) | ((uint)(r) & 0xff));
}
public static uint make_argb(int a, int r, int g, int b)
{
return ((((uint)(a) & 0xff) << 24) | (((uint)(r) & 0xff) << 16) | (((uint)(g) & 0xff) << 8) | ((uint)(b) & 0xff));
//return ((((uint)(a) & 0xff) << 24) | (((uint)(r) & 0xff) << 16) | (((uint)(g) & 0xff) << 8) | ((uint)(b) & 0xff));
//通道修改BGRA->RGBA
return ((((uint)(a) & 0xff) << 24) | (((uint)(b) & 0xff) << 16) | (((uint)(g) & 0xff) << 8) | ((uint)(r) & 0xff));
}
public static byte pal1bit(byte bits)
{

View File

@ -116,14 +116,30 @@
paletteram16[offset / 2] = (ushort)((paletteram16[offset / 2] & 0xff00) | data);
}
rgb = (paletteram16[(offset / 2) & 0x7ff] & 0xff) | ((paletteram16[(offset / 2) | 0x800] & 0xff) << 8);
Palette.palette_entry_set_color1((offset / 2) & 0x7ff, (uint)((Palette.pal5bit((byte)(rgb >> 0)) << 16) | (Palette.pal5bit((byte)(rgb >> 5)) << 8) | Palette.pal5bit((byte)(rgb >> 10))));
//Palette.palette_entry_set_color1((offset / 2) & 0x7ff, (uint)((Palette.pal5bit((byte)(rgb >> 0)) << 16) | (Palette.pal5bit((byte)(rgb >> 5)) << 8) | Palette.pal5bit((byte)(rgb >> 10))));
//通道修改BGRA->RGBA
Palette.palette_entry_set_color1((offset / 2) & 0x7ff,
(uint)(
(Palette.pal5bit((byte)(rgb >> 10)) << 16) |
(Palette.pal5bit((byte)(rgb >> 5)) << 8) |
Palette.pal5bit((byte)(rgb >> 0))
)
);
}
private static void igs011_palette(int offset, ushort data)
{
int rgb;
paletteram16[offset] = data;
rgb = (paletteram16[offset & 0x7ff] & 0xff) | ((paletteram16[offset | 0x800] & 0xff) << 8);
Palette.palette_entry_set_color1(offset & 0x7ff, (uint)((Palette.pal5bit((byte)(rgb >> 0)) << 16) | (Palette.pal5bit((byte)(rgb >> 5)) << 8) | Palette.pal5bit((byte)(rgb >> 10))));
//Palette.palette_entry_set_color1(offset & 0x7ff, (uint)((Palette.pal5bit((byte)(rgb >> 0)) << 16) | (Palette.pal5bit((byte)(rgb >> 5)) << 8) | Palette.pal5bit((byte)(rgb >> 10))));
//通道修改BGRA->RGBA
Palette.palette_entry_set_color1(offset & 0x7ff,
(uint)(
(Palette.pal5bit((byte)(rgb >> 10)) << 16) |
(Palette.pal5bit((byte)(rgb >> 5)) << 8) |
Palette.pal5bit((byte)(rgb >> 0)))
);
}
private static void igs011_blit_x_w(int offset, byte data)
{

View File

@ -69,7 +69,10 @@ namespace MAME.Core
(data >> 1) & 0x01,
(data >> 0) & 0x01,
(data >> 12) & 0x01);
return (r << 16) | (g << 8) | b;
//return (r << 16) | (g << 8) | b;
//通道修改BGRA->RGBA
return (b << 16) | (g << 8) | r;
}
public static void regenerate_pens()
{

View File

@ -110,7 +110,7 @@ public class UMAME : MonoBehaviour
void LoadGame(bool bReplay = false)
{
Application.targetFrameRate = 60;
//Application.targetFrameRate = 60;
mReplayWriter = new ReplayWriter(mChangeRomName, "fuck", ReplayData.ReplayFormat.FM32IP64, Encoding.UTF8);
mChangeRomName = HadGameList[optionDropdown.value].Name;

View File

@ -17,7 +17,7 @@ public class UniVideoPlayer : MonoBehaviour, IVideoPlayer
private RawImage m_drawCanvas;
[SerializeField]
private RectTransform m_drawCanvasrect;
int[] mFrameData;
//int[] mFrameData;
IntPtr mFrameDataPtr;
private TimeSpan lastElapsed;
@ -41,9 +41,9 @@ public class UniVideoPlayer : MonoBehaviour, IVideoPlayer
mWidth = width;
mHeight = height;
mDataLenght = width * height * 4;
mFrameData = new int[mWidth * mHeight];
//MAME来的是BGRA32好好好
m_rawBufferWarper = new Texture2D(mWidth, mHeight, TextureFormat.BGRA32, false);
//mFrameData = new int[mWidth * mHeight];
//MAME来的是BGRA32好好好 BGRA->RGBA
m_rawBufferWarper = new Texture2D(mWidth, mHeight, TextureFormat.RGBA32, false);
m_rawBufferWarper.filterMode = FilterMode.Point;
}
@ -76,7 +76,7 @@ public class UniVideoPlayer : MonoBehaviour, IVideoPlayer
var delta = current - lastElapsed;
lastElapsed = current;
videoFPS = 1d / delta.TotalSeconds;
mFrameData = data;
//mFrameData = data;
//Debug.Log($"frame_number -> {frame_number}");
}