shonumi / gbe-plus

DMG/GBC/GBA emulator and experimental NDS emulator.
GNU General Public License v2.0
530 stars 80 forks source link

[DMG] HALT should have no effect with disabled interrupts #27

Closed NasenSpray closed 8 years ago

NasenSpray commented 8 years ago
DI
HALT //no effect, continue as normal
shonumi commented 8 years ago

The effect of HALT in this case is actually a bit more complicated than simply continuing as normal (well, on anything that's not a GBC). True, the CPU is not suspended, but the following instruction after HALT is "skipped", or rather its opcode gets executed twice. It's unusual behavior, but only for DMG, MBP, and SGB units. It's not a one-line fix, so I'll get to this later (long work day today...)

Thanks for looking into this edge case though! The DMG core was written quite a while ago and is based on some of my oldest efforts when I got into emulation. So it's not exactly complete in every regard.

NasenSpray commented 8 years ago

yeah, I've read about that. In my fork, I only fixed the not HALTing part:

    //HALT
  case 0x76:
    halt = interrupt;
    cycles += 4;
    break;
shonumi commented 8 years ago

Forgot to close this, but it should be fixed as of 37318afadc95de83d506c9e2f56ca72c698b2c8a