Merge pull request #2034 from TiKevin83/master

Fix VRAM end of line testROM and a desync in GB Wario Land II
This commit is contained in:
alyosha-tas 2020-05-22 10:50:59 -04:00 committed by GitHub
commit f03fb06370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions

View File

@ -655,6 +655,11 @@ unsigned Memory::nontrivial_read(unsigned const p, unsigned long const cc) {
if (!lcd_.vramReadable(cc))
return 0xFF;
if (lcd_.vramExactlyReadable(cc))
if (p < 0x9000) {
return 0x00;
}
return cart_.vrambankptr()[p];
}

View File

@ -290,6 +290,16 @@ bool LCD::vramReadable(unsigned long const cc) {
|| cc + 2 >= m0TimeOfCurrentLine(cc);
}
bool LCD::vramExactlyReadable(unsigned long const cc) {
if (vramHasBeenExactlyRead) {
return false;
}
if (cc + 2 + isDoubleSpeed() == m0TimeOfCurrentLine(cc)) {
vramHasBeenExactlyRead = true;
}
return cc + 2 + isDoubleSpeed() == m0TimeOfCurrentLine(cc);
}
bool LCD::vramWritable(unsigned long const cc) {
if (cc >= eventTimes_.nextEventTime())
update(cc);
@ -848,4 +858,5 @@ SYNCFUNC(LCD)
SSS(lycIrq_);
SSS(nextM0Time_);
NSS(statReg_);
NSS(vramHasBeenExactlyRead);
}

View File

@ -102,6 +102,7 @@ public:
void resetCc(unsigned long oldCC, unsigned long newCc);
void speedChange(unsigned long cycleCounter);
bool vramReadable(unsigned long cycleCounter);
bool vramExactlyReadable(unsigned long cycleCounter);
bool vramWritable(unsigned long cycleCounter);
bool oamReadable(unsigned long cycleCounter);
bool oamWritable(unsigned long cycleCounter);
@ -228,6 +229,7 @@ public:
LycIrq lycIrq_;
NextM0Time nextM0Time_;
unsigned char statReg_;
bool vramHasBeenExactlyRead = false;
static void setDmgPalette(unsigned long palette[],
unsigned long const dmgColors[],
@ -235,13 +237,13 @@ public:
unsigned long gbcToRgb32(const unsigned bgr15);
void doCgbColorChange(unsigned char *const pdata, unsigned long *const palette, unsigned index, const unsigned data);
void refreshPalettes();
void setDBuffer();
void doMode2IrqEvent();
void event();
unsigned long m0TimeOfCurrentLine(unsigned long cc);
bool cgbpAccessible(unsigned long cycleCounter);
bool lycRegChangeStatTriggerBlockedByM0OrM1Irq(unsigned data, unsigned long cc);
bool lycRegChangeTriggersStatIrq(unsigned old, unsigned data, unsigned long cc);
bool statChangeTriggersM0LycOrM1StatIrqCgb(unsigned old, unsigned data, bool lycperiod, unsigned long cc);

Binary file not shown.