diff --git a/MAME.Core/Common/mainForm.cs b/MAME.Core/Common/mainForm.cs index 0f7b6eb..7b22a6a 100644 --- a/MAME.Core/Common/mainForm.cs +++ b/MAME.Core/Common/mainForm.cs @@ -1,11 +1,10 @@ using mame; using MAME.Core.run_interface; -using System.IO; -using System.Security.Cryptography; using System; using System.Collections.Generic; +using System.IO; +using System.Linq; using System.Xml.Linq; -using System.Drawing; namespace MAME.Core.Common { @@ -34,10 +33,13 @@ namespace MAME.Core.Common 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); resource = iRes; @@ -45,15 +47,40 @@ namespace MAME.Core.Common sr1.ReadLine(); sSelect = sr1.ReadLine(); sr1.Close(); - - RomInfo.Rom = new RomInfo(); + + RomInfo.Rom = new RomInfo(); + LoadROMXML(); //TODO Wavebuffer //desc1.BufferBytes = 0x9400; - Keyboard.InitializeInput(this); - Mouse.InitialMouse(this); + Keyboard.InitializeInput(this, ikb); + Mouse.InitialMouse(this, imou); } + private void LoadROMXML() + { + XElement xe = XElement.Parse(resource.Get_mame_xml()); + IEnumerable elements = from ele in xe.Elements("game") select ele; + showInfoByElements(elements); + } + + private void showInfoByElements(IEnumerable elements) + { + RomInfo.romList = new List(); + 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) { @@ -190,7 +217,6 @@ namespace MAME.Core.Common } } - private void itemSelect() { switch (Machine.sBoard) diff --git a/MAME.Core/MAME.Core.csproj b/MAME.Core/MAME.Core.csproj index 10b3756..3cff39f 100644 --- a/MAME.Core/MAME.Core.csproj +++ b/MAME.Core/MAME.Core.csproj @@ -7,6 +7,7 @@ + diff --git a/MAME.Core/emu/Inptport.cs b/MAME.Core/emu/Inptport.cs index 32fc527..7f86596 100644 --- a/MAME.Core/emu/Inptport.cs +++ b/MAME.Core/emu/Inptport.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/emu/KeyStruct.cs b/MAME.Core/emu/KeyStruct.cs index b146dfe..11e0190 100644 --- a/MAME.Core/emu/KeyStruct.cs +++ b/MAME.Core/emu/KeyStruct.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; using System.Collections.Generic; namespace mame diff --git a/MAME.Core/emu/Keyboard.cs b/MAME.Core/emu/Keyboard.cs index 11b3b2c..01471f6 100644 --- a/MAME.Core/emu/Keyboard.cs +++ b/MAME.Core/emu/Keyboard.cs @@ -1,34 +1,29 @@ using MAME.Core; using MAME.Core.Common; +using MAME.Core.run_interface; namespace mame { public class Keyboard { 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); - //dIDevice.SetCooperativeLevel(form1, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive); - //dIDevice.Acquire(); + mKeyboard = ikb; } - 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) { - return m_KeyStates[(int)key].IsPressed; + return mKeyboard.IsPressed(key); } public static bool IsTriggered(Key key) { - return m_KeyStates[(int)key].IsTriggered; + return mKeyboard.IsTriggered(key); } + public static void Update() { //TODO diff --git a/MAME.Core/emu/Mame.cs b/MAME.Core/emu/Mame.cs index 61715c3..8b759bf 100644 --- a/MAME.Core/emu/Mame.cs +++ b/MAME.Core/emu/Mame.cs @@ -1,5 +1,4 @@ -using MAME.Core; -using MAME.Core.Common; +using MAME.Core.Common; using MAME.Core.run_interface; using System; using System.IO; diff --git a/MAME.Core/emu/Mouse.cs b/MAME.Core/emu/Mouse.cs index becee28..0fa69ba 100644 --- a/MAME.Core/emu/Mouse.cs +++ b/MAME.Core/emu/Mouse.cs @@ -1,21 +1,25 @@ using MAME.Core.Common; +using MAME.Core.run_interface; namespace mame { public class Mouse { - //public static DIDevice mouseDevice; public static int deltaX, deltaY, oldX, oldY; 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); - //mouseDevice.Properties.AxisModeAbsolute = true; - //mouseDevice.SetCooperativeLevel(form1, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background); - //mouseDevice.Acquire(); + iMouse = im; } + public static void Update() { + iMouse.MouseXY(out int X, out int Y); + deltaX = X - oldX; + deltaY = Y - oldY; + oldX = X; + oldY = Y; //TODO //MouseState mouseState = mouseDevice.CurrentMouseState; //deltaX = mouseState.X - oldX; diff --git a/MAME.Core/emu/RomInfo.cs b/MAME.Core/emu/RomInfo.cs index 53310b0..f1f4419 100644 --- a/MAME.Core/emu/RomInfo.cs +++ b/MAME.Core/emu/RomInfo.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Xml.Linq; namespace mame { @@ -58,5 +59,6 @@ namespace mame } return ls1; } + } } \ No newline at end of file diff --git a/MAME.Core/emu/UI.cs b/MAME.Core/emu/UI.cs index 727de67..4799c08 100644 --- a/MAME.Core/emu/UI.cs +++ b/MAME.Core/emu/UI.cs @@ -1,5 +1,5 @@ -using MAME.Core; -using MAME.Core.Common; +using MAME.Core.Common; +using MAME.Core.run_interface; using System; using System.Runtime.InteropServices; diff --git a/MAME.Core/mame/capcom/Input.cs b/MAME.Core/mame/capcom/Input.cs index b1f76ac..5e3752c 100644 --- a/MAME.Core/mame/capcom/Input.cs +++ b/MAME.Core/mame/capcom/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/cps/Input.cs b/MAME.Core/mame/cps/Input.cs index 5b7d1de..a95590d 100644 --- a/MAME.Core/mame/cps/Input.cs +++ b/MAME.Core/mame/cps/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/dataeast/Input.cs b/MAME.Core/mame/dataeast/Input.cs index b6fd627..d56f62b 100644 --- a/MAME.Core/mame/dataeast/Input.cs +++ b/MAME.Core/mame/dataeast/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; using System.Collections.Generic; namespace mame diff --git a/MAME.Core/mame/igs011/Input.cs b/MAME.Core/mame/igs011/Input.cs index ceecff4..3e325dd 100644 --- a/MAME.Core/mame/igs011/Input.cs +++ b/MAME.Core/mame/igs011/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/konami68000/Input.cs b/MAME.Core/mame/konami68000/Input.cs index 58d8ba2..06e70c9 100644 --- a/MAME.Core/mame/konami68000/Input.cs +++ b/MAME.Core/mame/konami68000/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/m72/Input.cs b/MAME.Core/mame/m72/Input.cs index 610488c..91bd9d3 100644 --- a/MAME.Core/mame/m72/Input.cs +++ b/MAME.Core/mame/m72/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/m92/Input.cs b/MAME.Core/mame/m92/Input.cs index 4766a17..4a19dc1 100644 --- a/MAME.Core/mame/m92/Input.cs +++ b/MAME.Core/mame/m92/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/namcos1/Input.cs b/MAME.Core/mame/namcos1/Input.cs index 70fca7a..c7dbece 100644 --- a/MAME.Core/mame/namcos1/Input.cs +++ b/MAME.Core/mame/namcos1/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/neogeo/Input.cs b/MAME.Core/mame/neogeo/Input.cs index ecffba9..ce6d580 100644 --- a/MAME.Core/mame/neogeo/Input.cs +++ b/MAME.Core/mame/neogeo/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/pgm/Input.cs b/MAME.Core/mame/pgm/Input.cs index af16228..8760ddf 100644 --- a/MAME.Core/mame/pgm/Input.cs +++ b/MAME.Core/mame/pgm/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/suna8/Input.cs b/MAME.Core/mame/suna8/Input.cs index 27876b1..541ff4e 100644 --- a/MAME.Core/mame/suna8/Input.cs +++ b/MAME.Core/mame/suna8/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/taito/Input.cs b/MAME.Core/mame/taito/Input.cs index d8e3f06..9daac50 100644 --- a/MAME.Core/mame/taito/Input.cs +++ b/MAME.Core/mame/taito/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/taitob/Input.cs b/MAME.Core/mame/taitob/Input.cs index 7b0131f..f4750dc 100644 --- a/MAME.Core/mame/taitob/Input.cs +++ b/MAME.Core/mame/taitob/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/mame/tehkan/Input.cs b/MAME.Core/mame/tehkan/Input.cs index b1fdc7e..3c6df13 100644 --- a/MAME.Core/mame/tehkan/Input.cs +++ b/MAME.Core/mame/tehkan/Input.cs @@ -1,4 +1,4 @@ -using MAME.Core; +using MAME.Core.run_interface; namespace mame { diff --git a/MAME.Core/run_interface/IKeyboard.cs b/MAME.Core/run_interface/IKeyboard.cs new file mode 100644 index 0000000..391bc71 --- /dev/null +++ b/MAME.Core/run_interface/IKeyboard.cs @@ -0,0 +1,8 @@ +namespace MAME.Core.run_interface +{ + public interface IKeyboard + { + bool IsPressed(Key key); + bool IsTriggered(Key key); + } +} diff --git a/MAME.Core/run_interface/IMouse.cs b/MAME.Core/run_interface/IMouse.cs new file mode 100644 index 0000000..db4ab6d --- /dev/null +++ b/MAME.Core/run_interface/IMouse.cs @@ -0,0 +1,7 @@ +namespace MAME.Core.run_interface +{ + public interface IMouse + { + void MouseXY(out int X, out int Y); + } +} diff --git a/MAME.Core/run_interface/IResources.cs b/MAME.Core/run_interface/IResources.cs index 4d636aa..de18e3c 100644 --- a/MAME.Core/run_interface/IResources.cs +++ b/MAME.Core/run_interface/IResources.cs @@ -10,5 +10,7 @@ byte[] Get_pgmvideobios(); byte[] Get_pgmaudiobios(); byte[] Get_mcu(); + + string Get_mame_xml(); } } diff --git a/MAME.Core/key.cs b/MAME.Core/run_interface/key.cs similarity index 98% rename from MAME.Core/key.cs rename to MAME.Core/run_interface/key.cs index d5820d6..9b3a3fa 100644 --- a/MAME.Core/key.cs +++ b/MAME.Core/run_interface/key.cs @@ -1,4 +1,4 @@ -namespace MAME.Core +namespace MAME.Core.run_interface { public enum Key