libgambatte/cartridge: allow mapping rom bank0 in more cases/please blargg

blargg seems to be of the opinion that mbc1 allows mapping bank0 via overflow
for carts with few rom banks if his tests are anything to go by. I have no way
of verifying this, but am changing it because it confuses people when his tests
loop forever after succeeding.
This commit is contained in:
sinamas 2013-02-24 10:23:24 +01:00
parent 4bfa055456
commit fec81fa302

View File

@ -88,7 +88,7 @@ class Mbc1 : public DefaultMbc {
rambank & (rambanks(memptrs) - 1)); rambank & (rambanks(memptrs) - 1));
} }
void setRombank() const { memptrs.setRombank(adjustedRombank(rombank & (rombanks(memptrs) - 1))); } void setRombank() const { memptrs.setRombank(adjustedRombank(rombank) & (rombanks(memptrs) - 1)); }
public: public:
explicit Mbc1(MemPtrs &memptrs) explicit Mbc1(MemPtrs &memptrs)
@ -160,7 +160,7 @@ class Mbc1Multi64 : public Mbc {
memptrs.setRombank(adjustedRombank(rb)); memptrs.setRombank(adjustedRombank(rb));
} else { } else {
memptrs.setRombank0(0); memptrs.setRombank0(0);
memptrs.setRombank(adjustedRombank(rombank & (rombanks(memptrs) - 1))); memptrs.setRombank(adjustedRombank(rombank) & (rombanks(memptrs) - 1));
} }
} }
@ -181,10 +181,9 @@ public:
break; break;
case 1: case 1:
rombank = (rombank & 0x60) | (data & 0x1F); rombank = (rombank & 0x60) | (data & 0x1F);
memptrs.setRombank(adjustedRombank( memptrs.setRombank(rombank0Mode
rombank0Mode ? adjustedRombank(toMulti64Rombank(rombank))
? toMulti64Rombank(rombank) : adjustedRombank(rombank) & (rombanks(memptrs) - 1));
: rombank & (rombanks(memptrs) - 1)));
break; break;
case 2: case 2:
rombank = (data << 5 & 0x60) | (rombank & 0x1F); rombank = (data << 5 & 0x60) | (rombank & 0x1F);
@ -395,8 +394,13 @@ class Mbc5 : public DefaultMbc {
bool enableRam; bool enableRam;
static unsigned adjustedRombank(const unsigned bank) { return bank ? bank : 1; } static unsigned adjustedRombank(const unsigned bank) { return bank ? bank : 1; }
void setRambank() const { memptrs.setRambank(enableRam ? MemPtrs::READ_EN | MemPtrs::WRITE_EN : 0, rambank & (rambanks(memptrs) - 1)); }
void setRombank() const { memptrs.setRombank(adjustedRombank(rombank & (rombanks(memptrs) - 1))); } void setRambank() const {
memptrs.setRambank(enableRam ? MemPtrs::READ_EN | MemPtrs::WRITE_EN : 0,
rambank & (rambanks(memptrs) - 1));
}
void setRombank() const { memptrs.setRombank(adjustedRombank(rombank) & (rombanks(memptrs) - 1)); }
public: public:
explicit Mbc5(MemPtrs &memptrs) explicit Mbc5(MemPtrs &memptrs)