MSXHawk: Core interface stuff

This commit is contained in:
alyosha-tas 2020-01-10 15:51:56 -05:00
parent 2fa22c2505
commit 46d0818f09
18 changed files with 154 additions and 25 deletions

View File

@ -123,6 +123,9 @@ namespace BizHawk.Client.ApiHawk
case "O2":
return CoreSystem.Odyssey2;
case "MSX":
return CoreSystem.MSX;
case "VB":
case "NGP":
case "DNGP":

View File

@ -38,6 +38,7 @@
GB4x,
ChannelF,
Odyssey2,
MAME
MAME,
MSX
}
}

View File

@ -232,6 +232,10 @@ namespace BizHawk.Client.Common
/// Gets the <see cref="SystemInfo"/> instance for MAME
/// </summary>
public static SystemInfo Mame { get; } = new SystemInfo("MAME", CoreSystem.MAME, 4);
/// <summary>
/// Gets the <see cref="SystemInfo"/> instance for MSX
/// </summary>
public static SystemInfo MSX { get; } = new SystemInfo("MSX", CoreSystem.MSX, 2);
#endregion Get SystemInfo

View File

@ -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 },
};
}
}

View File

@ -219,6 +219,7 @@ namespace BizHawk.Client.DBMan
VEC,
GB3x,
GB4x,
O2
O2,
MSX
}
}

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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; }

View File

@ -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]

View File

@ -10,11 +10,11 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
public static class LibMSX
{
/// <returns>opaque state pointer</returns>
[DllImport("libMSX.dll", CallingConvention = CallingConvention.Cdecl)]
[DllImport("MSXHAWK.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr MSX_create();
/// <param name="core">opaque state pointer</param>
[DllImport("libMSX.dll", CallingConvention = CallingConvention.Cdecl)]
[DllImport("MSXHAWK.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void MSX_destroy(IntPtr core);
}
}

View File

@ -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
}
}

View File

@ -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()
{

View File

@ -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<MSX.MSXSettings, MSX.MSXSyncSettings>
public partial class MSX : IEmulator, IVideoProvider, ISaveRam, IStatable, IInputPollable, IRegionable, ISettable<MSX.MSXSettings, MSX.MSXSyncSettings>
{
[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<ITraceable>(Tracer);
//var serviceProvider = ServiceProvider as BasicServiceProvider;
//serviceProvider.Register<ITraceable>(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;

View File

@ -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];
}
};
}

View File

@ -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();
}
}
// free the memory from the core pointer
MSXHAWK_EXPORT void MSX_destroy(MSXCore* p)
{
std::free(p);
}

View File

@ -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;

View File

@ -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;