’Cause all games were better on the GBC

You are not logged in.

#1 2015-02-18 18:42:56

From: Spain
Registered: 2012-09-16
Post 245/450

Stop / Halt instructions clarification

So this was brought up in a video where we were discussing different results in the bgb and vba emulators when stumbling upon a stop instruction. BGB halted the game forever while vba seemed to ignore the instruction altogether. Vba has most gameboy registers at 00 in the memory viewer, so I will just focus on BGB.

I will start with how I *think* these two instructions work from what I've read in gameboy cpu manuals. The thing is if I'm right in everything I'm going to say, then BGB is doing some things wrong, but I've always have BGB as a very accurate emulator.


- If interrupts are enabled (through ime), the gameboy remains suspended until any interrupt occurs
- If interrupts are disabled (through ime), the gameboy isn't suspended and the pc skips the next instruction (that's why you put a nop)

I think that's how it works. However with the stop instruction there are some things I'm not sure about. Again, I'll say here what I believe:

- Stop also halts the gameboy until any interrupt occurs (e.g. vblank), but you are supposed to disable interrupts prior to executing a stop instruction so that only a button press will wake the gameboy up. Or would Stop ignore all interrupts but the joypad interrupt? (or just a key press, since most games have the joypad interrupt disabled). Either way, BGB clears the interrupt enable register (FFFF) automatically after executing a Stop instruction, and the only way I could continue playing was by enabling the interrupts again in the interrupt enable register AND also removing the stop instruction from memory. It wouldn't respond to any button press until I did that. This obviously doesn't make any sense to me since it would mean that there would be no way to get back from a Stop in a real gameboy.
- Also should Stop be necessarily followed by a 00 byte, or is just something similar to the way halt is followed by a nop? BGB actually has stop as a two byte instruction (10 00) and calls any other 10 XX as a "corrupted stop".

Last edited by Crystal_ (2015-02-18 18:46:24)


Board footer

Powered by FluxBB