libgambatte: Non-atomic interrupt handling
This commit is contained in:
parent
9d266ce281
commit
ca31e9ad72
|
@ -1107,9 +1107,9 @@ static void setInitialDmgIoamhram(unsigned char ioamhram[]) {
|
|||
static unsigned char const ffxxDump[0x100] = {
|
||||
0xCF, 0x00, 0x7E, 0xFF, 0xD3, 0x00, 0x00, 0xF8,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1,
|
||||
0x80, 0xBF, 0xF3, 0xFF, 0xBF, 0xFF, 0x3F, 0x00,
|
||||
0x80, 0x3F, 0x00, 0xFF, 0xBF, 0xFF, 0x3F, 0x00,
|
||||
0xFF, 0xBF, 0x7F, 0xFF, 0x9F, 0xFF, 0xBF, 0xFF,
|
||||
0xFF, 0x00, 0x00, 0xBF, 0x77, 0xF3, 0xF1, 0xFF,
|
||||
0xFF, 0x00, 0x00, 0xBF, 0x00, 0x00, 0x70, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x71, 0x72, 0xD5, 0x91, 0x58, 0xBB, 0x2A, 0xFA,
|
||||
0xCF, 0x3C, 0x54, 0x75, 0x48, 0xCF, 0x8F, 0xD9,
|
||||
|
|
|
@ -295,33 +295,35 @@ unsigned long Memory::event(unsigned long cc) {
|
|||
}
|
||||
|
||||
if (ime()) {
|
||||
unsigned address;
|
||||
|
||||
cc += 12;
|
||||
lcd_.update(cc);
|
||||
sp_ = (sp_ - 2) & 0xFFFF;
|
||||
write(sp_ + 1, pc_ >> 8, cc);
|
||||
unsigned ie = intreq_.iereg();
|
||||
|
||||
sp_ = (sp_ - 1) & 0xFFFF;
|
||||
write(sp_, pc_ >> 8, cc);
|
||||
|
||||
cc += 4;
|
||||
lcd_.update(cc);
|
||||
|
||||
updateIrqs(cc);
|
||||
unsigned const pendingIrqs = intreq_.pendingIrqs();
|
||||
|
||||
sp_ = (sp_ - 1) & 0xFFFF;
|
||||
write(sp_, pc_ & 0xFF, cc);
|
||||
const unsigned pendingIrqs = ie & intreq_.ifreg();
|
||||
|
||||
cc += 4;
|
||||
lcd_.update(cc);
|
||||
const unsigned n = pendingIrqs & -pendingIrqs;
|
||||
cc += 2;
|
||||
|
||||
unsigned const n = pendingIrqs & -pendingIrqs;
|
||||
unsigned address;
|
||||
if (n == 0) {
|
||||
address = 0;
|
||||
}
|
||||
else if (n < 8) {
|
||||
static const unsigned char lut[] = { 0x40, 0x48, 0x48, 0x50 };
|
||||
} else if (n <= 4) {
|
||||
static unsigned char const lut[] = { 0x40, 0x48, 0x48, 0x50 };
|
||||
address = lut[n-1];
|
||||
} else
|
||||
address = 0x50 + n;
|
||||
|
||||
intreq_.ackIrq(n);
|
||||
|
||||
cc += 2;
|
||||
|
||||
pc_ = address;
|
||||
}
|
||||
|
||||
|
|
|
@ -268,10 +268,6 @@ public:
|
|||
|
||||
void setCgbPalette(unsigned *lut);
|
||||
|
||||
void blackScreen() {
|
||||
lcd_.blackScreen();
|
||||
}
|
||||
|
||||
int linkStatus(int which);
|
||||
|
||||
private:
|
||||
|
|
|
@ -177,23 +177,6 @@ void LCD::copyCgbPalettesToDmg() {
|
|||
}
|
||||
}
|
||||
|
||||
void LCD::blackScreen() {
|
||||
if (ppu_.cgb()) {
|
||||
for (unsigned i = 0; i < 8 * 8; i += 2) {
|
||||
ppu_.bgPalette()[i >> 1] = 0;
|
||||
ppu_.spPalette()[i >> 1] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
dmgColorsRgb32_[i] = 0;
|
||||
}
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
dmgColorsRgb32_[i + 4] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -57,7 +57,6 @@ public:
|
|||
void setLayers(unsigned mask) { ppu_.setLayers(mask); }
|
||||
void setCgb(bool cgb);
|
||||
void copyCgbPalettesToDmg();
|
||||
void blackScreen();
|
||||
|
||||
int debugGetLY() const { return ppu_.lyCounter().ly(); }
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue