gba: add system bus memory domain

This commit is contained in:
goyuken 2012-11-25 19:03:13 +00:00
parent 890b7c354e
commit d77efde5fc
6 changed files with 54 additions and 1 deletions

View File

@ -210,6 +210,20 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
[DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool libmeteor_loadstate(byte[] data, uint size);
/// <summary>
/// read a byte off the system bus. guaranteed to have no side effects
/// </summary>
/// <param name="addr"></param>
/// <returns></returns>
[DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte libmeteor_peekbus(uint addr);
/// <summary>
/// write a byte to the system bus.
/// </summary>
/// <param name="addr"></param>
/// <param name="val"></param>
[DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void libmeteor_writebus(uint addr, byte val);
}
}

View File

@ -230,6 +230,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
AddMemoryDomain(LibMeteor.MemoryArea.oam, 1024, "OAM");
// even if the rom is less than 32MB, the whole is still valid in meteor
AddMemoryDomain(LibMeteor.MemoryArea.rom, 32 * 1024 * 1024, "ROM");
// special domain for system bus
MemoryDomain sb = new MemoryDomain("BUS", 1 << 28, Endian.Little,
delegate(int addr)
{
return LibMeteor.libmeteor_peekbus((uint)addr);
},
delegate(int addr, byte val)
{
LibMeteor.libmeteor_writebus((uint)addr, val);
});
_MemoryDomains.Add(sb);
}
#endregion

View File

@ -202,5 +202,13 @@ EXPORT int libmeteor_loadstate(const void *data, unsigned size)
return AMeteor::LoadState(ss);
}
// TODO: cartram and system bus memory domains
// TODO: cartram memory domain, cartram in system bus memory domain
EXPORT uint8_t libmeteor_peekbus(uint32_t addr)
{
return AMeteor::_memory.Peek8(addr);
}
EXPORT void libmeteor_writebus(uint32_t addr, uint8_t val)
{
AMeteor::_memory.Write8(addr, val);
}

View File

@ -115,6 +115,8 @@ namespace AMeteor
bool SaveState (std::ostream& stream);
bool LoadState (std::istream& stream);
uint8_t Peek8 (uint32_t add);
// TODO make const members
uint8_t Read8 (uint32_t add);
uint16_t Read16 (uint32_t add);

View File

@ -583,6 +583,24 @@ namespace AMeteor
// Read
////////////////////////////////////////////////////////////////////////////////
uint8_t Memory::Peek8 (uint32_t add)
{
switch (add >> 24)
{
case 0x04:
if (add < 0x04001000)
return IO.DRead8(add & 0xfff);
else
return 0;
case 0x0e:
// todo: cart reading
return 0xff;
default:
uint8_t *r = (uint8_t*)GetRealAddress(add, 1);
return r ? *r : 0;
}
}
uint8_t Memory::Read8 (uint32_t add)
{
switch (add >> 24)