D-pad

In one sentence

The cross on the left of a Game Boy is four switches, not a joystick. Pressing it closes one or two of those switches. The game reads them as up, down, left, and right.

The detail

Buttons share one register, and the hardware only reports half of them at a time. A game reads directions, then reads A, B, Select, and Start. The bits are active low: a pressed direction is a 0, not a 1. Code that treats 1 as pressed walks the character the wrong way.

On retroable.dev the browser player maps WASD and the arrow keys to those four switches. Space is A. Ctrl is B. C is Select. V and Enter are Start. That mapping is the keyboard in front of the same four switches, not a different control scheme inside the ROM.

Diagonals are two switches at once. A game that only checks for a single direction will ignore a diagonal even though both bits are closed.

Worth keeping

  • The pad is four switches, and diagonals are two of them together
  • Direction bits are active low in the joypad register
  • WASD, arrows, Space, Ctrl, C, and V are the browser's names for those switches

Questions

Does the ROM know I used the W key?

No. It sees the up switch. The browser translated the key.

Why would a character move when I have not pressed anything?

The read is inverted. Unpressed bits are 1, and pressed bits are 0.

Are Select and Start on the pad?

No. They are the two small buttons, read in the other half of the joypad register.

Related

Game Boy is a trademark of Nintendo. Retroable is independent and is not affiliated with Nintendo.