GameBoy
Hardware and
Programming

What makes the gameboy attractive to the hobby designer (besides its slick look and low cost) is the great wealth of  publicly available hardware and software support.  Most games machines are black boxes containing custom made hardware with little if any information on their inner workings.  But a few dedicated individuals have literally taken the gameboy apart and documented what they have found.

My interest concentrate on hardware interface via the plug in ROM cartridge and software development using 'C'.  So I have collected all the documents and links that relate to these topics plus a few other useful bits.
 

Latest updates 
 
20/3/2000

MBC5
Pin-Out
11/1999

GBGPI
General Purpose Interface
9/1999

GBDSO
Digital Sampling 
Oscilloscope
4/1999
The last unknown pin
(pin 2) on the Gamepack edge connector defined.

 

 

3/1999
Simple hardware IO address decoder using a single 74HC138 chip.

Hardware highlights

CPU: 8-bit Z80 like processor
Main ROM: up to 2M byte on plugin cartridge
Main RAM: 8K Byte internal, 128K Byte on plugin cartridge
Video RAM: 8K Byte
LCD: 160x144 (20x18 tiles)
Sound: 4 channels with stereo sound via headphones
Power: GBclassic 4*AA cells 60mA, GBpocket 2*AAA cells 100mA
 

Introduction

The Gameboy is controlled by an 8bit micro-processor which similar to the Zilog Z80.  It contains six general purpose 8bit registers which can be paired to form three 16 registers 'BC DE HL'. There is also an 8bit accumulator 'A' for arithmetic calculations and data movement. The I/O ports and commands have been replaced with LCD, sound, joypad and serial gamelink interfaces. Dedicated memory locations (0xFF00 to 0xFF4B) enable control of these I/O interfaces through software see GBspec.txt.

Internally the gameboy contains several RAM blocks :-

8Kb of video RAM:        0x8000  - 0x9FFF
8Kb of user RAM:          0xC000 - 0xDFFF
160bytes OAM (sprites): 0xFE00 - 0xFE9F
127bytes of HIRAM:      0xFF80 - 0xFFFE

But all programs are loaded from an external ROM cartridge.
 

The ROM cartridge interface

To make the gameboy do anything useful you will have to attach a ROM cartridge containing your program.  It is not possible to remotely boot the gameboy (eg: via the Gamelink) without a ROM cartridge to initiate communications.

Connections of a 32Kb EPROM (27C256) is relatively simple as it can be directly connected to the cartridge socket without additional logic 27C256.gif

If you need a ROM larger than 32Kb things get a little bit more complicated as the additional memory has to be paged into memory in blocks of 16Kb at address 0x4000 to 0x7FFF.  The bottom 16Kb of the ROM (0x0000 to 0x3FFF) is fixed and cannot be paged as this is where code execution starts at switch on.
The paging is done by a custom chip known as the MBC1 (MBC2 and MBC3 are available but less common) which sits alongside the the ROM in the games cartridge interface.  Selection of the current page is done in software by writing a page number to memory at address 0x2000 see Mbc1.gif.  It is possible to reproduce the hardware of the MBC1 using standard logic Mbc1ro.gif, but by far the easiest solution is to get one out of an old games cartridge.

The first thing you will need to develop your own Gameboy hardware is a programmable ROM cartridge.  If you love DIY and really want to develop your own hardware then have a look at Reiner Ziegler's cart reader/writer.

If you are uneasy about making a PCB and soldering small components you could pick up a second hand commercial programmer if your lucky. Or check out one of the many high quality products available from liksang.com. Please to not ask me about the different products which are available. 
 

Documentation

Bellow is a selection of documents that I have found essential, in particularly the latest document by Dr Pan which covers all the software controlled IO registers.

The definitive reference by Dr. Pan: GBspec.txt (58K)
Gameboy assembler Opcodes:  Opcodes.htm (3K)
Schematic overview of internals:  Gbguts.gif (5K)
Main circuit diagram with 32K ROM:  Gbmain.gif (30K)
LCD circuit diagram:  Gblcd.gif (10K)
Jeff Frohwein's Gameboy Tech Page lots of technical info.
Gameboy Development News.
 


 

Development Software

Lots of great software is available including assemblers, high level language compilers, development environments and simulators. The software listed below is a selection of what I have found most useful and should work together reliably. Hopefully these are the latest versions but you should check the home pages for any updates.
 

Pascal Faviours/Michael Hope's C compiler GBDK: GBDK Ver 2.1.0 (922K)
Ian James Gameboy integrated development studio: GBDS Ver 0.63 (609K)
Paul Robson's GB97 gameboy simulator for the PC: GB97 Ver 2937 (69K)
 

If you install the software to their default locations in C:\ then the GBDS settings should look something like this.

The GBDK lib files must be compiled before you can build any programs. To do this go to the lib directory (eg: C:\SDK\gbz80-gb\2-1-0\lib) and run the MAKE.BAT file which will compile the lib files.  You should also run the \examples\make.bat file to compile the examples.
 
 


Back to Main Page
Counter