Programming for the Gameboy/Hardware errata and bugs

16-bit Increment/Decrement bug
When the following instructions are used, and the contents of their 16-bit target register is between $FE00 and $FEFF, a flaw in the Gameboy hardware will write trash to OAM RAM, corrupting sprites. Only sprites 1 & 2 ($FE00 & $FE04) are not affected by these instructions. This bug does not affect the Gameboy Color or Advance, only the Gameboy, Gameboy Pocket, and Super Gameboy.

Halt bug
The  has a flaw that occurs whenever it is executed and interrupts are disabled. When this occurs, the instruction counter will "duplicate" the next byte, and read it twice. For example,

To avoid this, always put a  directly after a , to avoid unwanted side-effects.

Odd behavior will occur if two halt instructions are put in a row and interrupts are disabled, which will softlock the Gameboy CPU and require the user to reset it. This bug does not affect the Gameboy Color or Advance, only the Gameboy, Gameboy Pocket, and Super Gameboy.