规范接口

This commit is contained in:
sin365 2024-07-25 13:21:16 +08:00
parent 5ac30ca622
commit 8c5b80098b
27 changed files with 96 additions and 52 deletions

View File

@ -1,11 +1,10 @@
using mame; using mame;
using MAME.Core.run_interface; using MAME.Core.run_interface;
using System.IO;
using System.Security.Cryptography;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using System.Drawing;
namespace MAME.Core.Common namespace MAME.Core.Common
{ {
@ -34,10 +33,13 @@ namespace MAME.Core.Common
konami68000form = new konami68000Form(this); konami68000form = new konami68000Form(this);
} }
public void Init(IVideoPlayer Ivp,ISoundPlayer isp,IResources iRes) public void Init(IResources iRes,
IVideoPlayer ivp,
ISoundPlayer isp,
IKeyboard ikb,
IMouse imou)
{ {
Video.BindFunc(ivp);
Video.BindFunc(Ivp);
Sound.BindFunc(isp); Sound.BindFunc(isp);
resource = iRes; resource = iRes;
@ -45,15 +47,40 @@ namespace MAME.Core.Common
sr1.ReadLine(); sr1.ReadLine();
sSelect = sr1.ReadLine(); sSelect = sr1.ReadLine();
sr1.Close(); sr1.Close();
RomInfo.Rom = new RomInfo();
RomInfo.Rom = new RomInfo();
LoadROMXML();
//TODO Wavebuffer //TODO Wavebuffer
//desc1.BufferBytes = 0x9400; //desc1.BufferBytes = 0x9400;
Keyboard.InitializeInput(this); Keyboard.InitializeInput(this, ikb);
Mouse.InitialMouse(this); Mouse.InitialMouse(this, imou);
} }
private void LoadROMXML()
{
XElement xe = XElement.Parse(resource.Get_mame_xml());
IEnumerable<XElement> elements = from ele in xe.Elements("game") select ele;
showInfoByElements(elements);
}
private void showInfoByElements(IEnumerable<XElement> elements)
{
RomInfo.romList = new List<RomInfo>();
foreach (var ele in elements)
{
RomInfo rom = new RomInfo();
rom.Name = ele.Attribute("name").Value;
rom.Board = ele.Attribute("board").Value;
rom.Parent = ele.Element("parent").Value;
rom.Direction = ele.Element("direction").Value;
rom.Description = ele.Element("description").Value;
rom.Year = ele.Element("year").Value;
rom.Manufacturer = ele.Element("manufacturer").Value;
RomInfo.romList.Add(rom);
//loadform.listView1.Items.Add(new ListViewItem(new string[] { rom.Description, rom.Year, rom.Name, rom.Parent, rom.Direction, rom.Manufacturer, rom.Board }));
}
}
public void LoadRom(string Name) public void LoadRom(string Name)
{ {
@ -190,7 +217,6 @@ namespace MAME.Core.Common
} }
} }
private void itemSelect() private void itemSelect()
{ {
switch (Machine.sBoard) switch (Machine.sBoard)

View File

@ -7,6 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="ImageProcessor.Core" Version="1.1.0" /> <PackageReference Include="ImageProcessor.Core" Version="1.1.0" />
<PackageReference Include="LamarCodeGeneration" Version="6.3.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
using System.Collections.Generic; using System.Collections.Generic;
namespace mame namespace mame

View File

@ -1,34 +1,29 @@
using MAME.Core; using MAME.Core;
using MAME.Core.Common; using MAME.Core.Common;
using MAME.Core.run_interface;
namespace mame namespace mame
{ {
public class Keyboard public class Keyboard
{ {
public static bool bF10; public static bool bF10;
//public static DIDevice dIDevice;
public static void InitializeInput(mainForm form1) static IKeyboard mKeyboard;
public static void InitializeInput(mainForm form1,IKeyboard ikb)
{ {
//dIDevice = new DIDevice(SystemGuid.Keyboard); mKeyboard = ikb;
//dIDevice.SetCooperativeLevel(form1, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
//dIDevice.Acquire();
} }
struct KeyState
{
public bool IsPressed;
public bool IsTriggered;
public bool WasPressed;
};
private static KeyState[] m_KeyStates = new KeyState[256];
public static bool IsPressed(Key key) public static bool IsPressed(Key key)
{ {
return m_KeyStates[(int)key].IsPressed; return mKeyboard.IsPressed(key);
} }
public static bool IsTriggered(Key key) public static bool IsTriggered(Key key)
{ {
return m_KeyStates[(int)key].IsTriggered; return mKeyboard.IsTriggered(key);
} }
public static void Update() public static void Update()
{ {
//TODO //TODO

View File

@ -1,5 +1,4 @@
using MAME.Core; using MAME.Core.Common;
using MAME.Core.Common;
using MAME.Core.run_interface; using MAME.Core.run_interface;
using System; using System;
using System.IO; using System.IO;

View File

@ -1,21 +1,25 @@
using MAME.Core.Common; using MAME.Core.Common;
using MAME.Core.run_interface;
namespace mame namespace mame
{ {
public class Mouse public class Mouse
{ {
//public static DIDevice mouseDevice;
public static int deltaX, deltaY, oldX, oldY; public static int deltaX, deltaY, oldX, oldY;
public static byte[] buttons; public static byte[] buttons;
public static void InitialMouse(mainForm form1) static IMouse iMouse;
public static void InitialMouse(mainForm form1,IMouse im)
{ {
//mouseDevice = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse); iMouse = im;
//mouseDevice.Properties.AxisModeAbsolute = true;
//mouseDevice.SetCooperativeLevel(form1, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
//mouseDevice.Acquire();
} }
public static void Update() public static void Update()
{ {
iMouse.MouseXY(out int X, out int Y);
deltaX = X - oldX;
deltaY = Y - oldY;
oldX = X;
oldY = Y;
//TODO //TODO
//MouseState mouseState = mouseDevice.CurrentMouseState; //MouseState mouseState = mouseDevice.CurrentMouseState;
//deltaX = mouseState.X - oldX; //deltaX = mouseState.X - oldX;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq;
namespace mame namespace mame
{ {
@ -58,5 +59,6 @@ namespace mame
} }
return ls1; return ls1;
} }
} }
} }

View File

@ -1,5 +1,5 @@
using MAME.Core; using MAME.Core.Common;
using MAME.Core.Common; using MAME.Core.run_interface;
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
using System.Collections.Generic; using System.Collections.Generic;
namespace mame namespace mame

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -1,4 +1,4 @@
using MAME.Core; using MAME.Core.run_interface;
namespace mame namespace mame
{ {

View File

@ -0,0 +1,8 @@
namespace MAME.Core.run_interface
{
public interface IKeyboard
{
bool IsPressed(Key key);
bool IsTriggered(Key key);
}
}

View File

@ -0,0 +1,7 @@
namespace MAME.Core.run_interface
{
public interface IMouse
{
void MouseXY(out int X, out int Y);
}
}

View File

@ -10,5 +10,7 @@
byte[] Get_pgmvideobios(); byte[] Get_pgmvideobios();
byte[] Get_pgmaudiobios(); byte[] Get_pgmaudiobios();
byte[] Get_mcu(); byte[] Get_mcu();
string Get_mame_xml();
} }
} }

View File

@ -1,4 +1,4 @@
namespace MAME.Core namespace MAME.Core.run_interface
{ {
public enum Key public enum Key