support register reading on GB core. untested as i can't compile at the moment. flags are exported as part of register "F", as is usual for z80.
This commit is contained in:
parent
50527c006e
commit
e5c569f818
|
@ -126,7 +126,20 @@ namespace BizHawk.Emulation.Consoles.GB
|
|||
|
||||
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
List<KeyValuePair<string, int>> ret = new List<KeyValuePair<string, int>>();
|
||||
int[] data = new int[10];
|
||||
LibGambatte.gambatte_getregs(GambatteState, data);
|
||||
ret.Add(new KeyValuePair<string, int>("PC", data[(int)LibGambatte.RegIndicies.PC] & 0xffff));
|
||||
ret.Add(new KeyValuePair<string, int>("SP", data[(int)LibGambatte.RegIndicies.SP] & 0xffff));
|
||||
ret.Add(new KeyValuePair<string, int>("A", data[(int)LibGambatte.RegIndicies.A] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("B", data[(int)LibGambatte.RegIndicies.B] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("C", data[(int)LibGambatte.RegIndicies.C] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("D", data[(int)LibGambatte.RegIndicies.D] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("E", data[(int)LibGambatte.RegIndicies.E] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("F", data[(int)LibGambatte.RegIndicies.F] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("H", data[(int)LibGambatte.RegIndicies.H] & 0xff));
|
||||
ret.Add(new KeyValuePair<string, int>("L", data[(int)LibGambatte.RegIndicies.L] & 0xff));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -402,5 +402,18 @@ namespace BizHawk.Emulation.Consoles.GB
|
|||
/// <returns>todo</returns>
|
||||
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int gambatte_linkstatus(IntPtr core, int which);
|
||||
|
||||
/// <summary>
|
||||
/// get reg and flag values
|
||||
/// </summary>
|
||||
/// <param name="core">opaque state pointer</param>
|
||||
/// <param name="dest">length of at least 10, please</param>
|
||||
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void gambatte_getregs(IntPtr core, int[] dest);
|
||||
|
||||
public enum RegIndicies : int
|
||||
{
|
||||
PC, SP, A, B, C, D, E, F, H, L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,6 +162,8 @@ public:
|
|||
|
||||
int LinkStatus(int which);
|
||||
|
||||
void GetRegs(int *dest);
|
||||
|
||||
private:
|
||||
struct Priv;
|
||||
Priv *const p_;
|
||||
|
|
|
@ -246,3 +246,9 @@ __declspec(dllexport) int gambatte_linkstatus(void *core, int which)
|
|||
GB *g = (GB *) core;
|
||||
return g->LinkStatus(which);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void gambatte_getregs(void *core, int *dest)
|
||||
{
|
||||
GB *g = (GB *) core;
|
||||
g->GetRegs(dest);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ extern "C"
|
|||
|
||||
__declspec(dllexport) int gambatte_linkstatus(void *core, int which);
|
||||
|
||||
__declspec(dllexport) void gambatte_getregs(void *core, int *dest);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2833,4 +2833,18 @@ void CPU::process(const unsigned long cycles) {
|
|||
cycleCounter_ = cycleCounter;
|
||||
}
|
||||
|
||||
void CPU::GetRegs(int *dest)
|
||||
{
|
||||
dest[0] = PC_;
|
||||
dest[1] = SP;
|
||||
dest[2] = A_;
|
||||
dest[3] = B;
|
||||
dest[4] = C;
|
||||
dest[5] = D;
|
||||
dest[6] = E;
|
||||
dest[7] = F();
|
||||
dest[8] = H;
|
||||
dest[9] = L;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -127,6 +127,8 @@ public:
|
|||
void ExternalWrite(unsigned short addr, unsigned char val) { memory.write(addr, val, cycleCounter_); }
|
||||
|
||||
int LinkStatus(int which) { return memory.LinkStatus(which); }
|
||||
|
||||
void GetRegs(int *dest);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -268,4 +268,8 @@ int GB::LinkStatus(int which) {
|
|||
return p_->cpu.LinkStatus(which);
|
||||
}
|
||||
|
||||
void GB::GetRegs(int *dest) {
|
||||
p_->cpu.GetRegs(dest);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue