Compare commits

..

No commits in common. "c457e27bac253056ff8a314b12531bd5d56febf0" and "c2ceb8de59216645c93141e639ffac0e89b8900b" have entirely different histories.

10 changed files with 41 additions and 100 deletions

View File

@ -632,7 +632,7 @@ namespace cpu.m68000
void STOP() void STOP()
{ {
if (s) if (S)
{ {
short new_sr = ReadOpWord(PC); PC += 2; short new_sr = ReadOpWord(PC); PC += 2;
stopped = true; stopped = true;

View File

@ -169,7 +169,7 @@ namespace cpu.m68000
void RESET() void RESET()
{ {
if (s) if (S)
{ {
pendingCycles -= 132; pendingCycles -= 132;
} }

View File

@ -8,7 +8,7 @@ namespace cpu.m68000
{ {
int mode = (op >> 3) & 7; int mode = (op >> 3) & 7;
int reg = (op >> 0) & 7; int reg = (op >> 0) & 7;
if (s == false) if (S == false)
{ {
//throw new Exception("Write to SR when not in supervisor mode. supposed to trap or something..."); //throw new Exception("Write to SR when not in supervisor mode. supposed to trap or something...");
TrapVector2(8); TrapVector2(8);
@ -54,7 +54,7 @@ namespace cpu.m68000
{ {
int dir = (op >> 3) & 1; int dir = (op >> 3) & 1;
int reg = op & 7; int reg = op & 7;
if (s == false) if (S == false)
{ {
//throw new Exception("MOVE to USP when not supervisor. needs to trap"); //throw new Exception("MOVE to USP when not supervisor. needs to trap");
TrapVector2(8); TrapVector2(8);
@ -76,7 +76,7 @@ namespace cpu.m68000
void ANDI_SR() void ANDI_SR()
{ {
if (s == false) if (S == false)
throw new Exception("trap!"); throw new Exception("trap!");
SR &= ReadOpWord(PC); PC += 2; SR &= ReadOpWord(PC); PC += 2;
pendingCycles -= 20; pendingCycles -= 20;
@ -85,7 +85,7 @@ namespace cpu.m68000
void EORI_SR() void EORI_SR()
{ {
if (s == false) if (S == false)
throw new Exception("trap!"); throw new Exception("trap!");
SR ^= ReadOpWord(PC); PC += 2; SR ^= ReadOpWord(PC); PC += 2;
pendingCycles -= 20; pendingCycles -= 20;
@ -94,7 +94,7 @@ namespace cpu.m68000
void ORI_SR() void ORI_SR()
{ {
if (s == false) if (S == false)
throw new Exception("trap!"); throw new Exception("trap!");
SR |= ReadOpWord(PC); PC += 2; SR |= ReadOpWord(PC); PC += 2;
pendingCycles -= 20; pendingCycles -= 20;

View File

@ -45,7 +45,7 @@ namespace cpu.m68000
public bool stopped; public bool stopped;
/// <summary>Machine/Interrupt mode</summary> /// <summary>Machine/Interrupt mode</summary>
//public bool M { get { return m; } set { m = value; } } // TODO probably have some switch logic maybe public bool M { get { return m; } set { m = value; } } // TODO probably have some switch logic maybe
public void SetS(bool b1) public void SetS(bool b1)
{ {
@ -60,11 +60,10 @@ namespace cpu.m68000
/// <summary>Supervisor/User mode</summary> /// <summary>Supervisor/User mode</summary>
public bool S public bool S
{ {
//减少不必要的访问器堆栈 get
//get {
//{ return s;
// return s; }
//}
set set
{ {
if (value == s) if (value == s)
@ -110,8 +109,8 @@ namespace cpu.m68000
if (Z) value |= 0x0004; if (Z) value |= 0x0004;
if (N) value |= 0x0008; if (N) value |= 0x0008;
if (X) value |= 0x0010; if (X) value |= 0x0010;
if (m) value |= 0x1000; if (M) value |= 0x1000;
if (s) value |= 0x2000; if (S) value |= 0x2000;
value |= (short)((InterruptMaskLevel & 7) << 8); value |= (short)((InterruptMaskLevel & 7) << 8);
return value; return value;
} }
@ -122,7 +121,7 @@ namespace cpu.m68000
Z = (value & 0x0004) != 0; Z = (value & 0x0004) != 0;
N = (value & 0x0008) != 0; N = (value & 0x0008) != 0;
X = (value & 0x0010) != 0; X = (value & 0x0010) != 0;
m = (value & 0x1000) != 0; M = (value & 0x1000) != 0;
S = (value & 0x2000) != 0; S = (value & 0x2000) != 0;
InterruptMaskLevel = (value >> 8) & 7; InterruptMaskLevel = (value >> 8) & 7;
//m68ki_check_interrupts(); //m68ki_check_interrupts();
@ -198,7 +197,7 @@ namespace cpu.m68000
stopped = false; stopped = false;
pendingCycles = 0; pendingCycles = 0;
S = true; S = true;
m = false; M = false;
InterruptMaskLevel = 7; InterruptMaskLevel = 7;
Interrupt = 0; Interrupt = 0;
A[7].s32 = ReadOpLong(0); A[7].s32 = ReadOpLong(0);
@ -288,8 +287,8 @@ namespace cpu.m68000
} }
writer.Write(MC68000.m1.PPC); writer.Write(MC68000.m1.PPC);
writer.Write(MC68000.m1.PC); writer.Write(MC68000.m1.PC);
writer.Write(MC68000.m1.s); writer.Write(MC68000.m1.S);
writer.Write(MC68000.m1.m); writer.Write(MC68000.m1.M);
writer.Write(MC68000.m1.X); writer.Write(MC68000.m1.X);
writer.Write(MC68000.m1.N); writer.Write(MC68000.m1.N);
writer.Write(MC68000.m1.Z); writer.Write(MC68000.m1.Z);
@ -318,7 +317,7 @@ namespace cpu.m68000
MC68000.m1.PPC = reader.ReadInt32(); MC68000.m1.PPC = reader.ReadInt32();
MC68000.m1.PC = reader.ReadInt32(); MC68000.m1.PC = reader.ReadInt32();
MC68000.m1.SetS(reader.ReadBoolean()); MC68000.m1.SetS(reader.ReadBoolean());
MC68000.m1.m = reader.ReadBoolean(); MC68000.m1.M = reader.ReadBoolean();
MC68000.m1.X = reader.ReadBoolean(); MC68000.m1.X = reader.ReadBoolean();
MC68000.m1.N = reader.ReadBoolean(); MC68000.m1.N = reader.ReadBoolean();
MC68000.m1.Z = reader.ReadBoolean(); MC68000.m1.Z = reader.ReadBoolean();

View File

@ -93,7 +93,7 @@
//ushort* curbitmap = curbitmapPtr; //ushort* curbitmap = curbitmapPtr;
ushort* curbitmap = (ushort*)Video.bitmapbase_Ptrs[Video.curbitmap]; ushort* curbitmap = (ushort*)Video.bitmapbase_Ptrs[Video.curbitmap];
//uint* entry_color = entry_colorPtr; //uint* entry_color = entry_colorPtr;
uint* entry_color = (uint*)Palette.entry_color; uint* entry_color = (uint*)Palette.entry_color_Ptr;
//int* bitmapcolorRect = bitmapcolorRectPtr; //int* bitmapcolorRect = bitmapcolorRectPtr;
int* bitmapcolorRect = (int*)Video.bitmapcolorRect_Ptr; int* bitmapcolorRect = (int*)Video.bitmapcolorRect_Ptr;

View File

@ -3,28 +3,13 @@ using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class Palette public class Palette
{ {
//public static uint[] entry_color; public static uint[] entry_color;
/** entry_color的指针管理 **/
#region //指针化 entry_color
static uint[] entry_color_src;
static GCHandle entry_color_handle; static GCHandle entry_color_handle;
public static uint* entry_color; public static IntPtr entry_color_Ptr;
public static int entry_colorLength; /** end **/
public static bool entry_color_IsNull => entry_color == null;
public static uint[] entry_color_set
{
set
{
entry_color_handle.ReleaseGCHandle();
entry_color_src = value;
entry_colorLength = value.Length;
entry_color_src.GetObjectPtr(ref entry_color_handle, ref entry_color);
}
}
#endregion
public static float[] entry_contrast; public static float[] entry_contrast;
private static uint trans_uint; private static uint trans_uint;
@ -189,21 +174,18 @@ namespace MAME.Core
//entry_color = new uint[numcolors]; //entry_color = new uint[numcolors];
entry_color_set = new uint[numcolors];
///** entry_color的指针管理 **/ /** entry_color的指针管理 **/
//// 释放句柄 // 释放句柄
//if (entry_color != null && entry_color_handle.IsAllocated) if (entry_color != null && entry_color_handle.IsAllocated)
// entry_color_handle.Free(); entry_color_handle.Free();
//entry_color = new uint[numcolors];
//// 固定数组,防止垃圾回收器移动它
//entry_color_handle = GCHandle.Alloc(entry_color, GCHandleType.Pinned);
//// 获取数组的指针
//entry_color_Ptr = entry_color_handle.AddrOfPinnedObject();
///** end **/
///
entry_color = new uint[numcolors];
// 固定数组,防止垃圾回收器移动它
entry_color_handle = GCHandle.Alloc(entry_color, GCHandleType.Pinned);
// 获取数组的指针
entry_color_Ptr = entry_color_handle.AddrOfPinnedObject();
/** end **/

View File

@ -45,7 +45,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
} }
public unsafe static void LoadStateBinary_pbaction(System.IO.BinaryReader reader) public static void LoadStateBinary_pbaction(System.IO.BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();

View File

@ -92,9 +92,5 @@
/// 网络即时存档删除 /// 网络即时存档删除
/// </summary> /// </summary>
OnNetGameSavDeleted, OnNetGameSavDeleted,
/// <summary>
/// 核心开始游戏
/// </summary>
OnEmuBeginGame,
} }
} }

View File

@ -77,7 +77,6 @@ namespace AxibugEmuOnline.Client.Manager
break; break;
} }
var result = m_emuCore.StartGame(romFile); var result = m_emuCore.StartGame(romFile);
if (result) if (result)
{ {
@ -99,7 +98,6 @@ namespace AxibugEmuOnline.Client.Manager
StopGame(); StopGame();
OverlayManager.PopTip(result); OverlayManager.PopTip(result);
} }
Eventer.Instance.PostEvent(EEvent.OnEmuBeginGame);
} }
private void OnSlotDataChanged() private void OnSlotDataChanged()

View File

@ -1,7 +1,4 @@
using AxibugEmuOnline.Client.ClientCore; using AxiInputSP.UGUI;
using AxibugEmuOnline.Client.Event;
using AxiInputSP.UGUI;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -29,15 +26,9 @@ namespace AxibugEmuOnline.Client.InputDevices
{ {
AxiScreenGamepad.OnGamepadActive += AxiScreenGamepad_OnGamepadActive; AxiScreenGamepad.OnGamepadActive += AxiScreenGamepad_OnGamepadActive;
AxiScreenGamepad.OnGamepadDisactive += AxiScreenGamepad_OnGamepadDisactive; AxiScreenGamepad.OnGamepadDisactive += AxiScreenGamepad_OnGamepadDisactive;
Eventer.Instance.RegisterEvent(EEvent.OnEmuBeginGame, OnEmuBeginGame);
OnInit(); OnInit();
} }
private void OnEmuBeginGame()
{
ClearLastCheckPerformingValue();
}
private void AxiScreenGamepad_OnGamepadDisactive(AxiScreenGamepad sender) private void AxiScreenGamepad_OnGamepadDisactive(AxiScreenGamepad sender)
{ {
if (m_devices.TryGetValue(sender, out var device)) if (m_devices.TryGetValue(sender, out var device))
@ -104,40 +95,15 @@ namespace AxibugEmuOnline.Client.InputDevices
OnDeviceConnected?.Invoke(connectDevice); OnDeviceConnected?.Invoke(connectDevice);
} }
long last_CheckPerformingFrameIdx = -100;
bool last_CheckPerformingValue = false;
void ClearLastCheckPerformingValue()
{
last_CheckPerformingFrameIdx = -100;
last_CheckPerformingValue = false;
}
public bool CheckPerforming<CONTROLLER>(CONTROLLER control) where CONTROLLER : InputControl_C public bool CheckPerforming<CONTROLLER>(CONTROLLER control) where CONTROLLER : InputControl_C
{ {
//减少遍历开销因为每帧200+次的调用 居然CPU占用了2~3% if (control.Device is ScreenGamepad_D)
if (App.emu?.Core == null || last_CheckPerformingFrameIdx != App.emu.Core.Frame)
{ {
if (control.Device is ScreenGamepad_D) ScreenGamepad_D device = control.Device as ScreenGamepad_D;
{
ScreenGamepad_D device = control.Device as ScreenGamepad_D;
last_CheckPerformingValue = device.CheckPerforming(control); return device.CheckPerforming(control);
}
else last_CheckPerformingValue = OnCheckPerforming(control);
if (App.emu?.Core != null)
last_CheckPerformingFrameIdx = App.emu.Core.Frame;
} }
return last_CheckPerformingValue; else return OnCheckPerforming(control);
//if (control.Device is ScreenGamepad_D)
//{
// ScreenGamepad_D device = control.Device as ScreenGamepad_D;
// return device.CheckPerforming(control);
//}
//else return OnCheckPerforming(control);
} }
protected abstract bool OnCheckPerforming<CONTROLLER>(CONTROLLER control) where CONTROLLER : InputControl_C; protected abstract bool OnCheckPerforming<CONTROLLER>(CONTROLLER control) where CONTROLLER : InputControl_C;