Compare commits

...

2 Commits

10 changed files with 100 additions and 41 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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