Skip to content
Shane DeSeranno edited this page Nov 4, 2015 · 12 revisions

Go Home

Part 12 - GPU

This is a huge can of worms. But at the end of the day, the entire purpose of this device is to arrange bytes into a picture. We are only implementing the classic Gameboy (no color). This makes our job a bit easier.

The Control Register (0xFF40)

This register is used to control the LCD screen.

Bit 7: LCD Display Enable             (0=Off, 1=On)
Bit 6: Window Tile Map Display Select (0=0x9800-0x9BFF, 1=0x9C00-0x9FFF)
Bit 5: Window Display Enable          (0=Off, 1=On)
Bit 4: BG & Window Tile Data Select   (0=0x8800-0x97FF, 1=0x8000-0x8FFF)
Bit 3: BG Tile Map Display Select     (0=0x9800-0x9BFF, 1=0x9C00-0x9FFF)
Bit 2: OBJ (Sprite) Size              (0=8x8, 1=8x16)
Bit 1: OBJ (Sprite) Display Enable    (0=Off, 1=On)
Bit 0: BG Display                     (0=Off, 1=On)

For example, during the boot sequence:

LD A, $91           ; $005b
LD ($FF00+$40), A   ; $005d  Turn on LCD, showing Background

This loads 0x91 into the 0xFF40 control register. This is 1001 0001 in binary. So bit 7, 4, and 0 are set to 1. Everything else is 0. This performs all of these actions:

  • Turns on the LCD display
  • Selects 0x9800-0x9BFF as the tile map
  • Disables window display
  • Selects 0x8000-0x8FFF for the BG & Window tile data
  • Selects 0x9800-0x9BFF for the BG tile map data
  • Sets OBJ size to 8x8
  • Disables OBJ display
  • Enables BG display

Clone this wiki locally