Backport ' allocate vram on heap to reduce field offset sizes for easier access …

…on ARM'
This commit is contained in:
twinaphex 2015-02-18 07:29:17 +01:00
parent 72860ebcc4
commit b2c370ae2a
3 changed files with 11 additions and 19 deletions

View File

@ -398,6 +398,7 @@ namespace gambatte
void Cartridge::setStatePtrs(SaveState &state)
{
state.mem.vram.set(memptrs_.vramdata(), memptrs_.vramdataend() - memptrs_.vramdata());
state.mem.sram.set(memptrs_.rambankdata(), memptrs_.rambankdataend() - memptrs_.rambankdata());
state.mem.wram.set(memptrs_.wramdata(0), memptrs_.wramdataend() - memptrs_.wramdata(0));
}

View File

@ -33,8 +33,6 @@ namespace gambatte
, wsrambankptr_(0)
,memchunk_(0)
, rambankdata_(0)
, rdisabledRam_(0)
, wdisabledRam_(0)
, wramdataend_(0)
, oamDmaSrc_(oam_dma_src_off)
{
@ -50,21 +48,16 @@ namespace gambatte
delete []memchunk_;
memchunk_ = new unsigned char[
0x4000
+ rombanks * 0x4000ul
+ rombanks * 0x4000ul + 0x4000
+ rambanks * 0x2000ul
+ wrambanks * 0x1000ul
+ 0x4000];
romdata_[0] = romdata();
rambankdata_ = romdata_[0] + rombanks * 0x4000ul;
rambankdata_ = romdata_[0] + rombanks * 0x4000ul + 0x4000;
wramdata_[0] = rambankdata_ + rambanks * 0x2000ul;
wramdataend_ = wramdata_[0] + wrambanks * 0x1000ul;
rdisabledRam_ = wramdata_[0] + wrambanks * 0x1000ul;
wdisabledRam_ = rdisabledRam_ + 0x2000;
/* TODO - get rid of rdisabledRam_ */
std::memset(rdisabledRam_, 0xFF, 0x2000);
std::memset(rdisabledRamw(), 0xFF, 0x2000);
oamDmaSrc_ = oam_dma_src_off;
@ -97,10 +90,10 @@ namespace gambatte
unsigned char *const srambankptr = flags & RTC_EN
? 0
: (rambankdata() != rambankdataend()
? rambankdata_ + rambank * 0x2000ul - 0xA000 : wdisabledRam_ - 0xA000);
? rambankdata_ + rambank * 0x2000ul - 0xA000 : wdisabledRam() - 0xA000);
rsrambankptr_ = (flags & READ_EN) && srambankptr != wdisabledRam_ - 0xA000 ? srambankptr : rdisabledRam_ - 0xA000;
wsrambankptr_ = flags & WRITE_EN ? srambankptr : wdisabledRam_ - 0xA000;
rsrambankptr_ = (flags & READ_EN) && srambankptr != wdisabledRam() - 0xA000 ? srambankptr : rdisabledRamw() - 0xA000;
wsrambankptr_ = flags & WRITE_EN ? srambankptr : wdisabledRam() - 0xA000;
rmem_[0xB] = rmem_[0xA] = rsrambankptr_;
wmem_[0xB] = wmem_[0xA] = wsrambankptr_;
disconnectOamDmaAreas();

View File

@ -75,7 +75,7 @@ namespace gambatte
unsigned char * romdataend() const
{
return rambankdata_;
return rambankdata_ - 0x4000;
}
unsigned char * wramdata(unsigned area) const
@ -85,7 +85,7 @@ namespace gambatte
unsigned char * wramdataend() const
{
return rdisabledRam_;
return wramdataend_;
}
unsigned char * rambankdata() const
@ -100,7 +100,7 @@ namespace gambatte
const unsigned char * rdisabledRam() const
{
return rdisabledRam_;
return rdisabledRamw();
}
const unsigned char * rsrambankptr() const
@ -131,17 +131,15 @@ namespace gambatte
void setOamDmaSrc(OamDmaSrc oamDmaSrc);
private:
const unsigned char *rmem_[0x10];
unsigned char *wmem_[0x10];
unsigned char *romdata_[2];
unsigned char *wramdata_[2];
const unsigned char *rmem_[0x10];
unsigned char *wmem_[0x10];
unsigned char *vrambankptr_;
unsigned char *rsrambankptr_;
unsigned char *wsrambankptr_;
unsigned char *memchunk_;
unsigned char *rambankdata_;
unsigned char *rdisabledRam_;
unsigned char *wdisabledRam_;
unsigned char *wramdataend_;
OamDmaSrc oamDmaSrc_;
MemPtrs(const MemPtrs &);