CDL - add consistency check to GB, fix probably bugs in varying cartram sizes, change GB memdomain from "Cart RAM" to "CartRAM" (hope this doesnt cause a problem)

This commit is contained in:
zeromus 2015-10-26 21:42:48 -05:00
parent 0ff0749191
commit e8d307c33a
7 changed files with 40 additions and 9 deletions

View File

@ -154,6 +154,12 @@ namespace BizHawk.Client.EmuHawk
{
var gambatte = _emu as Gameboy;
var cdl_gb = newCDL as CodeDataLog_GB;
var memd = gambatte.AsMemoryDomains();
if (!cdl_gb.CheckConsistency(memd))
{
MessageBox.Show(this, "CDL file does not match emulator's current memory map!");
return;
}
gambatte.CDL = cdl_gb;
}
}
@ -351,7 +357,10 @@ namespace BizHawk.Client.EmuHawk
pce.Cpu.CDLLoggingActive = LoggingActiveCheckbox.Checked;
}
_cdl.Active = LoggingActiveCheckbox.Checked;
//zeromus doesnt like this kind of logic
if (_cdl != null)
_cdl.Active = LoggingActiveCheckbox.Checked;
}
private void PCECDL_DragEnter(object sender, DragEventArgs e)

View File

@ -10,14 +10,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public static CodeDataLog_GB Create(IMemoryDomains memdomains)
{
var t = new CodeDataLog_GB();
t["ROM"] = new byte[memdomains["ROM"].Size];
//t["HRAM"] = new byte[memdomains["HRAM"].Size]; //this is probably useless, but it's here if someone needs it
t["WRAM"] = new byte[memdomains["WRAM"].Size];
t["CartRAM"] = new byte[memdomains["Cart RAM"].Size];
if(memdomains.Has("CartRAM"))
t["CartRAM"] = new byte[memdomains["WRAM"].Size];
return t;
}
public override string SubType { get { return "GB"; } }
public override int SubVer { get { return 0; } }
//todo - this could be base classed
public bool CheckConsistency(IMemoryDomains memdomains)
{
if (memdomains["ROM"].Size != this["ROM"].Length) return false;
if (memdomains["WRAM"].Size != this["WRAM"].Length) return false;
if(memdomains.Has("CartRAM"))
if (memdomains["CartRAM"].Size != this["CartRAM"].Length)
return false;
return true;
}
}
}

View File

@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
CreateMemoryDomain(LibGambatte.MemoryAreas.wram, "WRAM");
CreateMemoryDomain(LibGambatte.MemoryAreas.rom, "ROM");
CreateMemoryDomain(LibGambatte.MemoryAreas.vram, "VRAM");
CreateMemoryDomain(LibGambatte.MemoryAreas.cartram, "Cart RAM");
CreateMemoryDomain(LibGambatte.MemoryAreas.cartram, "CartRAM");
CreateMemoryDomain(LibGambatte.MemoryAreas.oam, "OAM");
CreateMemoryDomain(LibGambatte.MemoryAreas.hram, "HRAM");

View File

@ -710,7 +710,7 @@ void Cartridge::saveSavedata(char *dest) {
}
}
bool Cartridge::getMemoryArea(int which, unsigned char **data, int *length) {
bool Cartridge::getMemoryArea(int which, unsigned char **data, int *length) const {
if (!data || !length)
return false;

View File

@ -95,7 +95,7 @@ public:
int saveSavedataLength();
void saveSavedata(char *dest);
bool getMemoryArea(int which, unsigned char **data, int *length);
bool getMemoryArea(int which, unsigned char **data, int *length) const;
int loadROM(const char *romfiledata, unsigned romfilelength, bool forceDmg, bool multicartCompat);
const char * romTitle() const { return reinterpret_cast<const char *>(memptrs.romdata() + 0x134); }

View File

@ -144,10 +144,16 @@ public:
{
if(cart.wsrambankptr())
{
//not bankable
unsigned addr = P&0x1FFF;
CDMapResult ret = { eCDLog_AddrType_CartRAM, addr };
return ret;
//not bankable. but. we're not sure how much might be here
unsigned char *data;
int length;
bool has = cart.getMemoryArea(3,&data,&length);
unsigned addr = P&(length-1);
if(has && length!=0)
{
CDMapResult ret = { eCDLog_AddrType_CartRAM, addr };
return ret;
}
}
}
else if(P<0xE000)

Binary file not shown.