mirror of https://github.com/mgba-emu/mgba.git
GB: Actually fix EI this time
This commit is contained in:
parent
3863513b2a
commit
770b80f2b2
21
src/gb/gb.c
21
src/gb/gb.c
|
@ -57,7 +57,7 @@ static void GBInit(struct LR35902Core* cpu, struct LR35902Component* component)
|
||||||
gb->pristineRomSize = 0;
|
gb->pristineRomSize = 0;
|
||||||
gb->yankedRomSize = 0;
|
gb->yankedRomSize = 0;
|
||||||
|
|
||||||
gb->diPending = false;
|
gb->eiPending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GBLoadROM(struct GB* gb, struct VFile* vf) {
|
bool GBLoadROM(struct GB* gb, struct VFile* vf) {
|
||||||
|
@ -210,9 +210,13 @@ void GBProcessEvents(struct LR35902Core* cpu) {
|
||||||
int32_t nextEvent = INT_MAX;
|
int32_t nextEvent = INT_MAX;
|
||||||
int32_t testEvent;
|
int32_t testEvent;
|
||||||
|
|
||||||
if (gb->diPending) {
|
if (gb->eiPending) {
|
||||||
gb->memory.ime = false;
|
gb->eiPending -= cycles;
|
||||||
gb->diPending = false;
|
if (gb->eiPending <= 0) {
|
||||||
|
gb->memory.ime = true;
|
||||||
|
GBUpdateIRQs(gb);
|
||||||
|
gb->eiPending = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testEvent = GBVideoProcessEvents(&gb->video, cycles);
|
testEvent = GBVideoProcessEvents(&gb->video, cycles);
|
||||||
|
@ -246,14 +250,15 @@ void GBProcessEvents(struct LR35902Core* cpu) {
|
||||||
|
|
||||||
void GBSetInterrupts(struct LR35902Core* cpu, bool enable) {
|
void GBSetInterrupts(struct LR35902Core* cpu, bool enable) {
|
||||||
struct GB* gb = (struct GB*) cpu->master;
|
struct GB* gb = (struct GB*) cpu->master;
|
||||||
if (enable) {
|
if (!enable) {
|
||||||
gb->memory.ime = enable;
|
gb->memory.ime = enable;
|
||||||
|
gb->eiPending = 0;
|
||||||
GBUpdateIRQs(gb);
|
GBUpdateIRQs(gb);
|
||||||
} else {
|
} else {
|
||||||
if (cpu->nextEvent > 4) {
|
if (cpu->nextEvent > cpu->cycles + 4) {
|
||||||
cpu->nextEvent = 4;
|
cpu->nextEvent = cpu->cycles + 4;
|
||||||
}
|
}
|
||||||
gb->diPending = true;
|
gb->eiPending = cpu->cycles + 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ struct GB {
|
||||||
struct VFile* romVf;
|
struct VFile* romVf;
|
||||||
struct VFile* sramVf;
|
struct VFile* sramVf;
|
||||||
|
|
||||||
bool diPending;
|
int32_t eiPending;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GBCartridge {
|
struct GBCartridge {
|
||||||
|
|
Loading…
Reference in New Issue