diff --git a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs index f0906c2394..61cbe6ab90 100644 --- a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs +++ b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs @@ -123,6 +123,9 @@ namespace BizHawk.Client.ApiHawk case "O2": return CoreSystem.Odyssey2; + case "MSX": + return CoreSystem.MSX; + case "VB": case "NGP": case "DNGP": diff --git a/BizHawk.Client.Common/Api/CoreSystem.cs b/BizHawk.Client.Common/Api/CoreSystem.cs index 917dc1270c..7d92784ec6 100644 --- a/BizHawk.Client.Common/Api/CoreSystem.cs +++ b/BizHawk.Client.Common/Api/CoreSystem.cs @@ -38,6 +38,7 @@ GB4x, ChannelF, Odyssey2, - MAME + MAME, + MSX } } diff --git a/BizHawk.Client.Common/SystemInfo.cs b/BizHawk.Client.Common/SystemInfo.cs index 49763fe101..391526b437 100644 --- a/BizHawk.Client.Common/SystemInfo.cs +++ b/BizHawk.Client.Common/SystemInfo.cs @@ -232,6 +232,10 @@ namespace BizHawk.Client.Common /// Gets the instance for MAME /// public static SystemInfo Mame { get; } = new SystemInfo("MAME", CoreSystem.MAME, 4); + /// + /// Gets the instance for MSX + /// + public static SystemInfo MSX { get; } = new SystemInfo("MSX", CoreSystem.MSX, 2); #endregion Get SystemInfo diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 87af10fc03..343976f164 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -416,6 +416,13 @@ namespace BizHawk.Client.Common new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + + new PathEntry { System = "MSX", SystemDisplayName = "MSX", Type = "Base", Path = Path.Combine(".", "MSX"), Ordinal = 0 }, + new PathEntry { System = "MSX", SystemDisplayName = "MSX", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "MSX", SystemDisplayName = "MSX", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "MSX", SystemDisplayName = "MSX", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, + new PathEntry { System = "MSX", SystemDisplayName = "MSX", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "MSX", SystemDisplayName = "MSX", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, }; } } diff --git a/BizHawk.Client.DBMan/DATTools/DATParserBase.cs b/BizHawk.Client.DBMan/DATTools/DATParserBase.cs index 92b9656de2..c1fdaeaf1d 100644 --- a/BizHawk.Client.DBMan/DATTools/DATParserBase.cs +++ b/BizHawk.Client.DBMan/DATTools/DATParserBase.cs @@ -219,6 +219,7 @@ namespace BizHawk.Client.DBMan VEC, GB3x, GB4x, - O2 + O2, + MSX } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index e785b48a5f..2d44d0deea 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -396,6 +396,8 @@ this.ZXSpectrumExportSnapshotMenuItemMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.VectrexSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.VectrexsettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.MSXSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.MSXsettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.O2HawkSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.O2HawksettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.HelpSubMenu = new System.Windows.Forms.ToolStripMenuItem(); @@ -530,6 +532,7 @@ this.neoGeoPocketToolStripMenuItem, this.zXSpectrumToolStripMenuItem, this.VectrexSubMenu, + this.MSXSubMenu, this.O2HawkSubMenu, this.amstradCPCToolStripMenuItem, this.arcadeToolStripMenuItem, @@ -3487,6 +3490,21 @@ this.VectrexsettingsToolStripMenuItem.Text = "Settings..."; this.VectrexsettingsToolStripMenuItem.Click += new System.EventHandler(this.VectrexSettingsMenuItem_Click); // + // MSXSubMenu + // + this.MSXSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.MSXsettingsToolStripMenuItem}); + this.MSXSubMenu.Name = "MSXSubMenu"; + this.MSXSubMenu.Size = new System.Drawing.Size(56, 17); + this.MSXSubMenu.Text = "&MSX"; + // + // MSXsettingsToolStripMenuItem + // + this.MSXsettingsToolStripMenuItem.Name = "MSXsettingsToolStripMenuItem"; + this.MSXsettingsToolStripMenuItem.Size = new System.Drawing.Size(125, 22); + this.MSXsettingsToolStripMenuItem.Text = "Settings..."; + this.MSXsettingsToolStripMenuItem.Click += new System.EventHandler(this.MSXSettingsMenuItem_Click); + // // O2HawkSubMenu // this.O2HawkSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -4527,6 +4545,8 @@ private System.Windows.Forms.ToolStripMenuItem GGLsettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem VectrexSubMenu; private System.Windows.Forms.ToolStripMenuItem VectrexsettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem MSXSubMenu; + private System.Windows.Forms.ToolStripMenuItem MSXsettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem O2HawkSubMenu; private System.Windows.Forms.ToolStripMenuItem O2HawksettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem GenesisSubMenu; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 366997f573..0901c2c950 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2462,6 +2462,15 @@ namespace BizHawk.Client.EmuHawk #endregion + #region MSX + + private void MSXSettingsMenuItem_Click(object sender, EventArgs e) + { + GenericCoreConfig.DoDialog(this, "MSX Settings"); + } + + #endregion + #region O2Hawk private void O2HawkSettingsMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 604e585b09..2fabf730c5 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1816,6 +1816,7 @@ namespace BizHawk.Client.EmuHawk zXSpectrumToolStripMenuItem.Visible = false; amstradCPCToolStripMenuItem.Visible = false; VectrexSubMenu.Visible = false; + MSXSubMenu.Visible = false; O2HawkSubMenu.Visible = false; arcadeToolStripMenuItem.Visible = false; @@ -1936,6 +1937,9 @@ namespace BizHawk.Client.EmuHawk case "VEC": VectrexSubMenu.Visible = true; break; + case "MSX": + MSXSubMenu.Visible = true; + break; case "O2": O2HawkSubMenu.Visible = true; break; diff --git a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs index 180e6f04a3..67d2a1f0b8 100644 --- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs +++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs @@ -55,7 +55,8 @@ namespace BizHawk.Client.EmuHawk ["ZXSpectrum"] = "ZX Spectrum", ["AmstradCPC"] = "Amstrad CPC", ["ChannelF"] = "Channel F", - ["Vectrex"] = "Vectrex" + ["Vectrex"] = "Vectrex", + ["MSX"] = "MSX", }; public string TargetSystem { get; set; } diff --git a/BizHawk.Emulation.Common/SystemLookup.cs b/BizHawk.Emulation.Common/SystemLookup.cs index 3c5df40b0c..abdabd4360 100644 --- a/BizHawk.Emulation.Common/SystemLookup.cs +++ b/BizHawk.Emulation.Common/SystemLookup.cs @@ -38,7 +38,8 @@ namespace BizHawk.Emulation.Common new SystemInfo { SystemId = "AmstradCPC", FullName = "Amstrad CPC" }, new SystemInfo { SystemId = "ChannelF", FullName = "Fairchild Channel F"}, new SystemInfo { SystemId = "O2", FullName = "Odyssey2"}, - new SystemInfo { SystemId = "VEC", FullName = "Vectrex"} + new SystemInfo { SystemId = "VEC", FullName = "Vectrex"}, + new SystemInfo { SystemId = "MSX", FullName = "MSX"} }; public SystemInfo this[string systemId] diff --git a/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs b/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs index 9038c32aef..4f1e84f884 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs @@ -10,11 +10,11 @@ namespace BizHawk.Emulation.Cores.Computers.MSX public static class LibMSX { /// opaque state pointer - [DllImport("libMSX.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("MSXHAWK.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MSX_create(); /// opaque state pointer - [DllImport("libMSX.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("MSXHAWK.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_destroy(IntPtr core); } } diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs index 64dd3483c6..d3f85c7dcf 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs @@ -3,7 +3,7 @@ using System; namespace BizHawk.Emulation.Cores.Computers.MSX { - public partial class MSX : IEmulator, ISoundProvider + public partial class MSX : IEmulator, ISoundProvider, IVideoProvider { public IEmulatorServiceProvider ServiceProvider { get; } @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX _controller = controller; _lagged = true; _frame++; - + /* if (Tracer.Enabled) { @@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX { } - + */ if (_lagged) { _lagCount++; @@ -63,6 +63,12 @@ namespace BizHawk.Emulation.Cores.Computers.MSX public void Dispose() { + if (MSX_Pntr != IntPtr.Zero) + { + LibMSX.MSX_destroy(MSX_Pntr); + MSX_Pntr = IntPtr.Zero; + } + if (blip_L != null) { blip_L.Dispose(); @@ -129,5 +135,31 @@ namespace BizHawk.Emulation.Cores.Computers.MSX #endregion + #region Video + public int _frameHz = 60; + + public int[] _vidbuffer; + + public int[] frame_buffer = new int[160 * 144]; + + public int[] GetVideoBuffer() + { + return frame_buffer; + } + + public int VirtualWidth => 160; + public int VirtualHeight => 144; + public int BufferWidth => 160; + public int BufferHeight => 144; + public int BackgroundColor => unchecked((int)0xFF000000); + public int VsyncNumerator => _frameHz; + public int VsyncDenominator => 1; + + public static readonly uint[] color_palette_BW = { 0xFFFFFFFF, 0xFFAAAAAA, 0xFF555555, 0xFF000000 }; + public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 }; + + public uint[] color_palette = new uint[4]; + + #endregion } } diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs index 640d5264c7..11b96c56f8 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs @@ -1,4 +1,10 @@ -using BizHawk.Emulation.Common; +using System; +using System.ComponentModel; + +using Newtonsoft.Json; + +using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Computers.MSX { @@ -34,8 +40,15 @@ namespace BizHawk.Emulation.Cores.Computers.MSX public class MSXSettings { // graphics settings - public bool DispBG = true; - public bool DispOBJ = true; + [DisplayName("Show Background")] + [Description("Display BG Layer")] + [DefaultValue(true)] + public bool DispBG { get; set; } + + [DisplayName("Show Sprites")] + [Description("Display Sprites")] + [DefaultValue(true)] + public bool DispOBJ { get; set; } public MSXSettings Clone() { diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs index 2d507b0431..590902f8b8 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX isPorted: false, isReleased: false)] [ServiceNotApplicable(typeof(IDriveLight))] - public partial class MSX : IEmulator, ISaveRam, IStatable, IInputPollable, IRegionable, ISettable + public partial class MSX : IEmulator, IVideoProvider, ISaveRam, IStatable, IInputPollable, IRegionable, ISettable { [CoreConstructor("MSX")] public MSX(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) @@ -27,6 +27,8 @@ namespace BizHawk.Emulation.Cores.Computers.MSX Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize); } + MSX_Pntr = LibMSX.MSX_create(); + blip_L.SetRates(3579545, 44100); blip_R.SetRates(3579545, 44100); @@ -34,13 +36,10 @@ namespace BizHawk.Emulation.Cores.Computers.MSX SetupMemoryDomains(); - //this manages the linkage between the cpu and mapper callbacks so it needs running before bootup is complete - ((ICodeDataLogger)this).SetCDL(null); - InputCallbacks = new InputCallbackSystem(); - var serviceProvider = ServiceProvider as BasicServiceProvider; - serviceProvider.Register(Tracer); + //var serviceProvider = ServiceProvider as BasicServiceProvider; + //serviceProvider.Register(Tracer); } public void HardReset() @@ -48,6 +47,8 @@ namespace BizHawk.Emulation.Cores.Computers.MSX } + IntPtr MSX_Pntr { get; set; } = IntPtr.Zero; + // Constants private const int BankSize = 16384; diff --git a/libHawk/MSXHawk/MSXHawk/Core.h b/libHawk/MSXHawk/MSXHawk/Core.h index ab07b3db0f..1eb35d874f 100644 --- a/libHawk/MSXHawk/MSXHawk/Core.h +++ b/libHawk/MSXHawk/MSXHawk/Core.h @@ -16,12 +16,32 @@ namespace MSXHawk public: MSXCore() { - + cpu.HW_Write = &HardwareWrite; }; VDP vdp; Z80A cpu; SN76489sms psg; + + unsigned char* rom; + unsigned int rom_size; + unsigned char ram[0x2000]; + + static void HardwareWrite(uint8_t value) + { + + } + + // memory map + unsigned char* Memory_Map[8]; + + void Load_ROM(unsigned char* ext_rom, unsigned int ext_rom_size) + { + rom = ext_rom; + rom_size = ext_rom_size; + + Memory_Map[0] = &rom[0]; + } }; } diff --git a/libHawk/MSXHawk/MSXHawk/MSXHawk.cpp b/libHawk/MSXHawk/MSXHawk/MSXHawk.cpp index b09cbb2b0a..310f10748a 100644 --- a/libHawk/MSXHawk/MSXHawk/MSXHawk.cpp +++ b/libHawk/MSXHawk/MSXHawk/MSXHawk.cpp @@ -6,10 +6,15 @@ using namespace MSXHawk; -// This is an example of an exported variable -MSXHAWK_EXPORT int nMSXHawk=0; - -// This is an example of an exported function. -MSXHAWK_EXPORT MSXCore* MSX_create() { +// Create pointer to a core instance +MSXHAWK_EXPORT MSXCore* MSX_create() +{ return new MSXCore(); -} \ No newline at end of file +} + +// free the memory from the core pointer +MSXHAWK_EXPORT void MSX_destroy(MSXCore* p) +{ + std::free(p); +} + diff --git a/libHawk/MSXHawk/MSXHawk/VDP.h b/libHawk/MSXHawk/MSXHawk/VDP.h index e2c0a31485..c1d3c9ece8 100644 --- a/libHawk/MSXHawk/MSXHawk/VDP.h +++ b/libHawk/MSXHawk/MSXHawk/VDP.h @@ -26,6 +26,11 @@ namespace MSXHawk uint8_t Registers[16] = { 0x06, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF0, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint8_t Statusuint8_t; + static void TO_REGS(uint8_t value) + { + + } + const int Command_VramRead = 0x00; const int Command_VramWrite = 0x40; const int Command_RegisterWrite = 0x80; diff --git a/libHawk/MSXHawk/MSXHawk/Z80A.h b/libHawk/MSXHawk/MSXHawk/Z80A.h index b26cb4ce60..e968aa2a84 100644 --- a/libHawk/MSXHawk/MSXHawk/Z80A.h +++ b/libHawk/MSXHawk/MSXHawk/Z80A.h @@ -20,6 +20,8 @@ namespace MSXHawk uint8_t* HWMemoryMap; uint8_t* HWMemoryMapMask; + void (*HW_Write)(uint8_t); + // when connected devices do not output a value on the BUS, they are responsible for determining open bus behaviour and returning it int ExternalDB;