parent
d24629f3ad
commit
aa6f74108e
Binary file not shown.
|
@ -24,18 +24,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
["F"] = (byte)(data[(int)LibGambatte.RegIndices.F] & 0xff),
|
["F"] = (byte)(data[(int)LibGambatte.RegIndices.F] & 0xff),
|
||||||
["H"] = (byte)(data[(int)LibGambatte.RegIndices.H] & 0xff),
|
["H"] = (byte)(data[(int)LibGambatte.RegIndices.H] & 0xff),
|
||||||
["L"] = (byte)(data[(int)LibGambatte.RegIndices.L] & 0xff),
|
["L"] = (byte)(data[(int)LibGambatte.RegIndices.L] & 0xff),
|
||||||
["ROM Bank"] = LibGambatte.gambatte_getrombank(GambatteState),
|
// banks
|
||||||
["SRAM Bank"] = LibGambatte.gambatte_getsrambank(GambatteState)
|
["ROM0 BANK"] = (ushort)LibGambatte.gambatte_getbank(GambatteState, LibGambatte.BankType.ROM0),
|
||||||
|
["ROMX BANK"] = (ushort)LibGambatte.gambatte_getbank(GambatteState, LibGambatte.BankType.ROMX),
|
||||||
|
["VRAM BANK"] = (byte)LibGambatte.gambatte_getbank(GambatteState, LibGambatte.BankType.VRAM),
|
||||||
|
["SRAM BANK"] = (byte)LibGambatte.gambatte_getbank(GambatteState, LibGambatte.BankType.SRAM),
|
||||||
|
["WRAM BANK"] = (byte)LibGambatte.gambatte_getbank(GambatteState, LibGambatte.BankType.WRAM),
|
||||||
|
// todo: maybe do [bc]/[de]/[hl]?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCpuRegister(string register, int value)
|
public void SetCpuRegister(string register, int value)
|
||||||
{
|
{
|
||||||
int[] data = new int[10];
|
if (register.Length == 9 && register.Substring(4, 5).ToUpperInvariant() == " BANK")
|
||||||
LibGambatte.gambatte_getregs(GambatteState, data);
|
{
|
||||||
LibGambatte.RegIndices index = (LibGambatte.RegIndices)Enum.Parse(typeof(LibGambatte.RegIndices), register);
|
LibGambatte.BankType type = (LibGambatte.BankType)Enum.Parse(typeof(LibGambatte.BankType), register.Substring(0, 4).ToUpperInvariant());
|
||||||
data[(int)index] = value & (index <= LibGambatte.RegIndices.SP ? 0xffff : 0xff);
|
LibGambatte.gambatte_setbank(GambatteState, type, value);
|
||||||
LibGambatte.gambatte_setregs(GambatteState, data);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int[] data = new int[10];
|
||||||
|
LibGambatte.gambatte_getregs(GambatteState, data);
|
||||||
|
LibGambatte.RegIndices index = (LibGambatte.RegIndices)Enum.Parse(typeof(LibGambatte.RegIndices), register.ToUpperInvariant());
|
||||||
|
data[(int)index] = value & (index <= LibGambatte.RegIndices.SP ? 0xffff : 0xff);
|
||||||
|
LibGambatte.gambatte_setregs(GambatteState, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanStep(StepType type) => false;
|
public bool CanStep(StepType type) => false;
|
||||||
|
@ -73,13 +86,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
if (getHasCBOfType())
|
if (getHasCBOfType())
|
||||||
{
|
{
|
||||||
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "System Bus");
|
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "System Bus");
|
||||||
|
var bank = LibGambatte.gambatte_getaddrbank(GambatteState, (ushort)address);
|
||||||
if (address < 0x4000u) // always rom bank 0 for most mbcs (todo: edge mbcs where this doesn't apply)
|
if (address < 0x4000u) // always rom bank 0 for most mbcs (todo: edge mbcs where this doesn't apply)
|
||||||
{
|
{
|
||||||
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
|
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
|
||||||
}
|
}
|
||||||
else if (address < 0x8000u) // rom bank x
|
else if (address < 0x8000u) // rom bank x
|
||||||
{
|
{
|
||||||
var bank = LibGambatte.gambatte_getrombank(GambatteState); // this will return 1 in case there is no mbc (0 is valid for some mbcs too)
|
|
||||||
address += (uint)(bank * 0x4000);
|
address += (uint)(bank * 0x4000);
|
||||||
address -= 0x4000u;
|
address -= 0x4000u;
|
||||||
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
|
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
|
||||||
|
@ -88,7 +101,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
{
|
{
|
||||||
if (IsCGBMode() && !IsCGBDMGMode())
|
if (IsCGBMode() && !IsCGBDMGMode())
|
||||||
{
|
{
|
||||||
var bank = LibGambatte.gambatte_cpuread(GambatteState, 0xFF4F) & 1;
|
|
||||||
address += (uint)(bank * 0x2000);
|
address += (uint)(bank * 0x2000);
|
||||||
}
|
}
|
||||||
address -= 0x8000u;
|
address -= 0x8000u;
|
||||||
|
@ -96,7 +108,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
}
|
}
|
||||||
else if (address < 0xC000u) // sram (may be banked)
|
else if (address < 0xC000u) // sram (may be banked)
|
||||||
{
|
{
|
||||||
var bank = LibGambatte.gambatte_getsrambank(GambatteState); // this will return 0 in case there is only one bank
|
|
||||||
address += (uint)(bank * 0x2000);
|
address += (uint)(bank * 0x2000);
|
||||||
address -= 0xA000u;
|
address -= 0xA000u;
|
||||||
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "SRAM");
|
MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "SRAM");
|
||||||
|
@ -110,7 +121,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
{
|
{
|
||||||
if (IsCGBMode() && !IsCGBDMGMode())
|
if (IsCGBMode() && !IsCGBDMGMode())
|
||||||
{
|
{
|
||||||
var bank = Math.Max(LibGambatte.gambatte_cpuread(GambatteState, 0xFF70) & 7, 1);
|
|
||||||
address += (uint)(bank * 0x1000);
|
address += (uint)(bank * 0x1000);
|
||||||
}
|
}
|
||||||
address -= 0xD000u;
|
address -= 0xD000u;
|
||||||
|
|
|
@ -454,7 +454,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
/// write a single byte to the cpu bus. while there is no cycle cost to these writes, there can be quite a few side effects.
|
/// write a single byte to the cpu bus. while there is no cycle cost to these writes, there can be quite a few side effects.
|
||||||
/// use at your own risk.
|
/// use at your own risk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="core">opaque state pointe</param>
|
/// <param name="core">opaque state pointer</param>
|
||||||
/// <param name="addr">system bus address</param>
|
/// <param name="addr">system bus address</param>
|
||||||
/// <param name="val">byte to write</param>
|
/// <param name="val">byte to write</param>
|
||||||
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
@ -463,24 +463,57 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// link cable stuff; never touch for normal operation
|
/// link cable stuff; never touch for normal operation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="core">opaque state pointe</param>
|
/// <param name="core">opaque state pointer</param>
|
||||||
/// <param name="which">todo</param>
|
/// <param name="which">todo</param>
|
||||||
/// <returns>todo</returns>
|
/// <returns>todo</returns>
|
||||||
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int gambatte_linkstatus(IntPtr core, int which);
|
public static extern int gambatte_linkstatus(IntPtr core, int which);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// get current rom bank
|
/// get current bank for type of memory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="core">opaque state pointe</param>
|
/// <param name="core">opaque state pointer</param>
|
||||||
/// <returns>current rom bank</returns>
|
/// <param name="type">type of memory</param>
|
||||||
|
/// <returns>current bank</returns>
|
||||||
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int gambatte_getrombank(IntPtr core);
|
public static extern int gambatte_getbank(IntPtr core, BankType type);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get current bank for type of memory at address
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="core">opaque state pointer</param>
|
||||||
|
/// <param name="addr">address for memory type</param>
|
||||||
|
/// <returns>current bank, or 0 if not applicable</returns>
|
||||||
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int gambatte_getaddrbank(IntPtr core, ushort addr);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set current bank for type of memory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="core">opaque state pointer</param>
|
||||||
|
/// <param name="type">type of memory</param>
|
||||||
|
/// <param name="bank">bank to set</param>
|
||||||
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void gambatte_setbank(IntPtr core, BankType type, int bank);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set current bank for type of memory at address
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="core">opaque state pointer</param>
|
||||||
|
/// <param name="addr">address for memory type</param>
|
||||||
|
/// <param name="bank">bank to set</param>
|
||||||
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void gambatte_setbank(IntPtr core, ushort addr, int bank);
|
||||||
|
|
||||||
|
public enum BankType : int
|
||||||
|
{
|
||||||
|
ROM0, ROMX, VRAM, SRAM, WRAM
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// get current sram bank
|
/// get current sram bank
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="core">opaque state pointe</param>
|
/// <param name="core">opaque state pointer</param>
|
||||||
/// <returns>current sram bank</returns>
|
/// <returns>current sram bank</returns>
|
||||||
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int gambatte_getsrambank(IntPtr core);
|
public static extern int gambatte_getsrambank(IntPtr core);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dc50297053a3e8fff285629d735a9618b9406245
|
Subproject commit 13c15f2a5ad4e80e3aeeaf973a0bba46e10299af
|
Loading…
Reference in New Issue