Manual
Page 1
THIS DOCUMENT IS PRINTED ON DIN A5 SIZE PAPER (148mm x 210mm)! Game BoyTM CPU Manual Sources by: Pan of Nintendo CO., LTD. © 1989 to ask. Version: 1.01 by Nintendo CO., LTD. Note: Game BoyTM, Game Boy PocketTM, Super Game BoyTM and Game Boy ColorTM are registered trademarks of Anthrox, GABY, Marat Fayzullin, Pascal Felber, Paul Robson, Martin Korth, kOOPa, Bowser Contents: Assembly Language Commands, Timings and Opcodes, and everything you always wanted to know about GB but were afraid to 1999 by DP
THIS DOCUMENT IS PRINTED ON DIN A5 SIZE PAPER (148mm x 210mm)! Game BoyTM CPU Manual Sources by: Pan of Nintendo CO., LTD. © 1989 to ask. Version: 1.01 by Nintendo CO., LTD. Note: Game BoyTM, Game Boy PocketTM, Super Game BoyTM and Game Boy ColorTM are registered trademarks of Anthrox, GABY, Marat Fayzullin, Pascal Felber, Paul Robson, Martin Korth, kOOPa, Bowser Contents: Assembly Language Commands, Timings and Opcodes, and everything you always wanted to know about GB but were afraid to 1999 by DP
Manual
Page 2
... 19 2.7.3. Low-Power Mode 19 2.8. Tiles 22 2.8.2. Sprites 25 2.8.3. Sprite RAM Bug 27 2.9. Interrupts 32 2.12.1. I /O 31 2.12. Foreword 4 2. Forward 5 2.2. Terms 5 2.3. Game Boy Specs 6 2.4. Echo of Contents 1. Power Up Sequence 17 2.7.2. Serial I /O Registers 35 Page 2 V 1.01 Special Registers 35 2.13.1. General memory map 8 2.5.2. Video 22 2.8.1. Sound 28 2.10. Interrupt Descriptions 34 2.13. Foreword...
... 19 2.7.3. Low-Power Mode 19 2.8. Tiles 22 2.8.2. Sprites 25 2.8.3. Sprite RAM Bug 27 2.9. Interrupts 32 2.12.1. I /O 31 2.12. Foreword 4 2. Forward 5 2.2. Terms 5 2.3. Game Boy Specs 6 2.4. Echo of Contents 1. Power Up Sequence 17 2.7.2. Serial I /O Registers 35 Page 2 V 1.01 Special Registers 35 2.13.1. General memory map 8 2.5.2. Video 22 2.8.1. Sound 28 2.10. Interrupt Descriptions 34 2.13. Foreword...
Manual
Page 3
CPU Registers 61 3.2.1. Stack Pointer 63 3.3. Super Game Boy commands 119 4.1. SGB Border 120 4.4. Typical timing diagram 137 by DP Page 3 Flag Register 62 3.2.3. Commands 65 3.3.1. 8-Bit Loads 65... 99 3.3.7. Palettes 119 4.3. Foreword 3. Calls 114 3.3.10. Returns 117 4. Program Counter 63 3.2.4. Jumps 111 3.3.9. Main Action Window 121 4.5. Appendix A 134 5.1. Game BoyTM CPU Manual 1. Generally 61 3.2.2. Emulator Notes 134 5.2. Foreword 119 4.2. Miscellaneous 94 3.3.6. Game Boy command overview 61 3.1. Restarts 116 3.3.11.
CPU Registers 61 3.2.1. Stack Pointer 63 3.3. Super Game Boy commands 119 4.1. SGB Border 120 4.4. Typical timing diagram 137 by DP Page 3 Flag Register 62 3.2.3. Commands 65 3.3.1. 8-Bit Loads 65... 99 3.3.7. Palettes 119 4.3. Foreword 3. Calls 114 3.3.10. Returns 117 4. Program Counter 63 3.2.4. Jumps 111 3.3.9. Main Action Window 121 4.5. Appendix A 134 5.1. Game BoyTM CPU Manual 1. Generally 61 3.2.2. Emulator Notes 134 5.2. Foreword 119 4.2. Miscellaneous 94 3.3.6. Game Boy command overview 61 3.1. Restarts 116 3.3.11.
Manual
Page 4
...Robson, Martin Korth, kOOPa. The third is included. See paragraph 3. Also, a timing diagram of specifications and commands for Nintendo Super Game Boy speciffic programming by GABY (GAmeBoY). DP Page 4 V 1.01 This will need additional documents for the hardware. On the last page a quick reference of three major parts. Foreword This ... CPU Manual 1. The documents consists of ASM commands is a summary of a typical read and write operation on a real Game Boy can be a complete handbook to get your emulator proved programs run on the classic GB bus can be found in paragraph 2....
...Robson, Martin Korth, kOOPa. The third is included. See paragraph 3. Also, a timing diagram of specifications and commands for Nintendo Super Game Boy speciffic programming by GABY (GAmeBoY). DP Page 4 V 1.01 This will need additional documents for the hardware. On the last page a quick reference of three major parts. Foreword This ... CPU Manual 1. The documents consists of ASM commands is a summary of a typical read and write operation on a real Game Boy can be a complete handbook to get your emulator proved programs run on the classic GB bus can be found in paragraph 2....
Manual
Page 5
... Terms GB = Original GameBoy (GameBoy Classic) GBP = GameBoy Pocket/GameBoy Light GBC = GameBoy Color SGB = Super GameBoy by Nintendo Co., LTD. Forward: The following was typed up for educational purposes and higher learning. 2.2. Hardware specifications 2. This info is presented... not presented for monetary gain, but for informational purposes regarding the inner workings on how their Game Boy works and what makes it "tick". Any reference to inform a user on the hand-held game machine known as Game Boy, manufactured and designed by Nintendo Co., LTD. Game BoyTM CPU Manual 2.
... Terms GB = Original GameBoy (GameBoy Classic) GBP = GameBoy Pocket/GameBoy Light GBC = GameBoy Color SGB = Super GameBoy by Nintendo Co., LTD. Forward: The following was typed up for educational purposes and higher learning. 2.2. Hardware specifications 2. This info is presented... not presented for monetary gain, but for informational purposes regarding the inner workings on how their Game Boy works and what makes it "tick". Any reference to inform a user on the hand-held game machine known as Game Boy, manufactured and designed by Nintendo Co., LTD. Game BoyTM CPU Manual 2.
Manual
Page 6
Processor The GameBoy uses a computer chip similar to the Z80, some instructions Page 6 V 1.01 Compared to an Intel 8080. It contains all of the instructions of sprites: 40 • Max # sprites/line: 10 • Max sprite size: ...8226; Sound: 4 channels with stereo sound • Power: DC6V 0.7W (DC3V 0.7W for GB Pocket) Nintendo documents describe the CPU & instructions speed in machine cycles while this document describes them in clock cycles. Game Boy Specs Game BoyTM CPU Manual 2.3. In many ways the processor is the translation: 1 machine cycle = 4 clock cycles Machine...
Processor The GameBoy uses a computer chip similar to the Z80, some instructions Page 6 V 1.01 Compared to an Intel 8080. It contains all of the instructions of sprites: 40 • Max # sprites/line: 10 • Max sprite size: ...8226; Sound: 4 channels with stereo sound • Power: DC6V 0.7W (DC3V 0.7W for GB Pocket) Nintendo documents describe the CPU & instructions speed in machine cycles while this document describes them in clock cycles. Game Boy Specs Game BoyTM CPU Manual 2.3. In many ways the processor is the translation: 1 machine cycle = 4 clock cycles Machine...
Manual
Page 7
... jumps/calls/rets on parity/overflow and sign flag. Processor have been added and some have been taken away. All commands prefixed by DP Page 7 Game BoyTM CPU Manual 2.4.
... jumps/calls/rets on parity/overflow and sign flag. Processor have been added and some have been taken away. All commands prefixed by DP Page 7 Game BoyTM CPU Manual 2.4.
Manual
Page 8
2.5. General memory map Interrupt Enable Register FFFF Internal RAM FF80 Empty but unusable for I/O FF4C I/O ports FF00 Empty but unusable for I/O FEA0 Sprite Attrib Memory (OAM) FE00 Echo of 8kB Internal RAM E000 8kB Internal RAM C000 8kB switchable RAM bank A000 8kB Video RAM 8000 -- 16kB switchable ROM bank | 4000 |= 32kB Cartrigbe 16kB ROM bank #0 | 0000 -- * NOTE: b = bit, B = byte Page 8 V 1.01 Memory Map Game BoyTM CPU Manual 2.5. Memory Map 2.5.1.
2.5. General memory map Interrupt Enable Register FFFF Internal RAM FF80 Empty but unusable for I/O FF4C I/O ports FF00 Empty but unusable for I/O FEA0 Sprite Attrib Memory (OAM) FE00 Echo of 8kB Internal RAM E000 8kB Internal RAM C000 8kB switchable RAM bank A000 8kB Video RAM 8000 -- 16kB switchable ROM bank | 4000 |= 32kB Cartrigbe 16kB ROM bank #0 | 0000 -- * NOTE: b = bit, B = byte Page 8 V 1.01 Memory Map Game BoyTM CPU Manual 2.5. Memory Map 2.5.1.
Manual
Page 9
... in the memory map for whatever purpose you write to address E000 it 's RAM bank is always enabled). Similarly, writing a byte to 6000. by writing 01 to C000 will appear at C000 and E000.) 2.5.3. Game BoyTM CPU Manual 2.5.2.
... in the memory map for whatever purpose you write to address E000 it 's RAM bank is always enabled). Similarly, writing a byte to 6000. by writing 01 to C000 will appear at C000 and E000.) 2.5.3. Game BoyTM CPU Manual 2.5.2.
Manual
Page 10
It contains the following values: 0100-0103 This is the begin code execution point in each cartridge. Page 10 V 1.01 Reserved Memory Locations Game BoyTM CPU Manual 2.5.4. 2.5.4. Reserved Memory Locations 0000 0008 0010 0018 0020 0028 0030 0038 0040 Restart $00 Address (RST $00 calls this address.) Restart $08 ...
It contains the following values: 0100-0103 This is the begin code execution point in each cartridge. Page 10 V 1.01 Reserved Memory Locations Game BoyTM CPU Manual 2.5.4. 2.5.4. Reserved Memory Locations 0000 0008 0010 0018 0020 0028 0030 0038 0040 Restart $00 Address (RST $00 calls this address.) Restart $08 ...
Manual
Page 11
Game BoyTM CPU Manual Locations 2.5.4. If it is less than 16 characters then the remaining bytes are normally $00 if [$014B] $33.) 0146 GB/SGB Indicator ...+MBC5+RUMBLE+SRAM+BATT B-ROM+MMM01 1F-Pocket Camera C-ROM+MMM01+SRAM FD-Bandai TAMA5 D-ROM+MMM01+SRAM+BATT FE - Reserved Memory 0104-0133 Scrolling Nintendo graphic: CE ED 66 66 CC 0D 00 0B 03 73 00 83 00 0C 00 0D 00 08 11 1F 88 89 00 0E... GB, $00 or other = not Color GB 0144 Ascii hex digit, high nibble of licensee code (new). 0145 Ascii hex digit, low nibble of the game in UPPER CASE ASCII. Hudson HuC-3 by DP Page 11
Game BoyTM CPU Manual Locations 2.5.4. If it is less than 16 characters then the remaining bytes are normally $00 if [$014B] $33.) 0146 GB/SGB Indicator ...+MBC5+RUMBLE+SRAM+BATT B-ROM+MMM01 1F-Pocket Camera C-ROM+MMM01+SRAM FD-Bandai TAMA5 D-ROM+MMM01+SRAM+BATT FE - Reserved Memory 0104-0133 Scrolling Nintendo graphic: CE ED 66 66 CC 0D 00 0B 03 73 00 83 00 0C 00 0D 00 08 11 1F 88 89 00 0E... GB, $00 or other = not Color GB 0144 Ascii hex digit, high nibble of licensee code (new). 0145 Ascii hex digit, low nibble of the game in UPPER CASE ASCII. Hudson HuC-3 by DP Page 11
Manual
Page 12
Non-Japanese 014B Licensee code (old): 33 - Konami (Super GameBoy function won't work if $33.) 014C Mask ROM Version number (Usually $00) Page 12 V 1.01 Hudson HuC-1 10-ROM+MBC3+TIMER+RAM+BATT 11-ROM+MBC3 0148 ROM size: 0 - 256Kbit = 32KByte = 2 banks 1 - 512Kbit = 64KByte = 4 banks 2 - 1Mbit = ...2kB = 1 bank 2 - 64kBit = 8kB = 1 bank 3 - 256kBit = 32kB = 4 banks 4 - 1MBit =128kB =16 banks 014A Destination code: 0 - Accolade A4 - Japanese 1 - Reserved Memory Locations Game BoyTM CPU Manual F-ROM+MBC3+TIMER+BATT FF - Check 0144/0145 for Licensee code. 79 - 2.5.4.
Non-Japanese 014B Licensee code (old): 33 - Konami (Super GameBoy function won't work if $33.) 014C Mask ROM Version number (Usually $00) Page 12 V 1.01 Hudson HuC-1 10-ROM+MBC3+TIMER+RAM+BATT 11-ROM+MBC3 0148 ROM size: 0 - 256Kbit = 32KByte = 2 banks 1 - 512Kbit = 64KByte = 4 banks 2 - 1Mbit = ...2kB = 1 bank 2 - 64kBit = 8kB = 1 bank 3 - 256kBit = 32kB = 4 banks 4 - 1MBit =128kB =16 banks 014A Destination code: 0 - Accolade A4 - Japanese 1 - Reserved Memory Locations Game BoyTM CPU Manual F-ROM+MBC3+TIMER+BATT FF - Check 0144/0145 for Licensee code. 79 - 2.5.4.
Manual
Page 13
... (Memory Bank Controller 1) MBC1 has two different maximum memory modes: 16Mbit ROM/8KByte RAM or 4Mbit ROM/32KByte RAM. The MBC1 defaults to ROM bank 1. Game BoyTM CPU Manual Locations 2.5.4.
... (Memory Bank Controller 1) MBC1 has two different maximum memory modes: 16Mbit ROM/8KByte RAM or 4Mbit ROM/32KByte RAM. The MBC1 defaults to ROM bank 1. Game BoyTM CPU Manual Locations 2.5.4.
Manual
Page 14
...is not accessible from 4000-7FFF and can read from false writes during power down of Page 14 V 1.01 Include this operation because it by writing a XXXX1010 into 0000-1FFF area. 2.6. Disabling a RAM bank ...Super Smart Card doesn't require this operation anyway to allow your code to 2Mbit. Cartridge Types Game BoyTM CPU Manual Rom bank 0 is not provided. To disable RAM bank operations write any value...MBC1 which uses external RAM, MBC2 has 512 x 4 bits of the GameBoy. (NOTE: Nintendo suggests values $0A to enable and $00 to disable RAM bank!!) If memory model is set to 16/8...
...is not accessible from 4000-7FFF and can read from false writes during power down of Page 14 V 1.01 Include this operation because it by writing a XXXX1010 into 0000-1FFF area. 2.6. Disabling a RAM bank ...Super Smart Card doesn't require this operation anyway to allow your code to 2Mbit. Cartridge Types Game BoyTM CPU Manual Rom bank 0 is not provided. To disable RAM bank operations write any value...MBC1 which uses external RAM, MBC2 has 512 x 4 bits of the GameBoy. (NOTE: Nintendo suggests values $0A to enable and $00 to disable RAM bank!!) If memory model is set to 16/8...
Manual
Page 15
... is 0000-00FF. Also, this MBC has a built-in battery-backed Real Time Clock (RTC) not found in any writes to the 4000-5FFF area. Game BoyTM CPU Manual 2.6. For example the following addresses can be used to select a ROM bank. The suggested address range to use for MBC2 ram The...
... is 0000-00FF. Also, this MBC has a built-in battery-backed Real Time Clock (RTC) not found in any writes to the 4000-5FFF area. Game BoyTM CPU Manual 2.6. For example the following addresses can be used to select a ROM bank. The suggested address range to use for MBC2 ram The...
Manual
Page 16
... select bits) into 4000-5FFF area will select an appropriate RAM bank at A000-BFFF if the cart contains RAM. Writing a value (XXXXMBBB - Cartridge Types Game BoyTM CPU Manual It is used as the motor on set M = 1, M = 0 turns it off for the rumble cart. Rumble carts can access...= motor, B = bank select bits) into 4000-5FFF area will select an appropriate RAM bank at A000-BFFF if the cart contains RAM. Page 16 V 1.01 To turn the rumble motor on /off . • HuC1 (Memory Bank / Infrared Controller): This controller made by writing $000 to the least significant bit of...
... select bits) into 4000-5FFF area will select an appropriate RAM bank at A000-BFFF if the cart contains RAM. Writing a value (XXXXMBBB - Cartridge Types Game BoyTM CPU Manual It is used as the motor on set M = 1, M = 0 turns it off for the rumble cart. Rumble carts can access...= motor, B = bank select bits) into 4000-5FFF area will select an appropriate RAM bank at A000-BFFF if the cart contains RAM. Page 16 V 1.01 To turn the rumble motor on /off . • HuC1 (Memory Bank / Infrared Controller): This controller made by writing $000 to the least significant bit of...
Manual
Page 17
...Two musical notes are compared with the following register values: AF=$01-GB/SGB, $FF-GBP, $11-GBC F =$B0 by DP Page 17 GB & GB Pocket: Next, the GameBoy starts adding all operations. If the least significant byte of a Nintendo logo on the internal speaker. Power Up Sequence When the GameBoy...: Even though the GB & GBP check the memory locations from $104 to $14d. Again, the cartridge locations $104 to $14d, the SGB doesn't. Game BoyTM CPU Manual 2.7. This image is then scrolled until it is located in the middle of 25 decimal is disabled and cartridge program execution begins...
...Two musical notes are compared with the following register values: AF=$01-GB/SGB, $FF-GBP, $11-GBC F =$B0 by DP Page 17 GB & GB Pocket: Next, the GameBoy starts adding all operations. If the least significant byte of a Nintendo logo on the internal speaker. Power Up Sequence When the GameBoy...: Even though the GB & GBP check the memory locations from $104 to $14d. Again, the cartridge locations $104 to $14d, the SGB doesn't. Game BoyTM CPU Manual 2.7. This image is then scrolled until it is located in the middle of 25 decimal is disabled and cartridge program execution begins...
Manual
Page 18
...FF06] = $00 ; NR32 [$FF1E] = $BF ; NR43 [$FF23] = $BF ; BGP [$FF48] = $FF ; TMA [$FF07] = $00 ; NR30 [$FF1B] = $FF ; NR30 [$FF24] = $77 ; Power Up Sequence Game BoyTM CPU Manual BC=$0013 DE=$00D8 HL=$014D Stack Pointer=$FFFE [$FF05] = $00 ; NR10 [$FF11] = $BF ; NR41 [$FF21] = $00 ; NR52 [$FF40] = $91 ; LYC [$FF47...FF10] = $80 ; NR31 [$FF1C] = $9F ; NR33 [$FF20] = $FF ; NR42 [$FF22] = $00 ; NR50 [$FF25] = $F3 ; WY [$FF4B] = $00 ; SCX [$FF45] = $00 ; IE Page 18 V 1.01 OBP0 [$FF49] = $FF ; NR21 [$FF17] = $00 ; 2.7.1. NR51 [$FF26] = $F1-GB, $F0-SGB ;
...FF06] = $00 ; NR32 [$FF1E] = $BF ; NR43 [$FF23] = $BF ; BGP [$FF48] = $FF ; TMA [$FF07] = $00 ; NR30 [$FF1B] = $FF ; NR30 [$FF24] = $77 ; Power Up Sequence Game BoyTM CPU Manual BC=$0013 DE=$00D8 HL=$014D Stack Pointer=$FFFE [$FF05] = $00 ; NR10 [$FF11] = $BF ; NR41 [$FF21] = $00 ; NR52 [$FF40] = $91 ; LYC [$FF47...FF10] = $80 ; NR31 [$FF1C] = $9F ; NR33 [$FF20] = $FF ; NR42 [$FF22] = $00 ; NR50 [$FF25] = $F3 ; WY [$FF4B] = $00 ; SCX [$FF45] = $00 ; IE Page 18 V 1.01 OBP0 [$FF49] = $FF ; NR21 [$FF17] = $00 ; 2.7.1. NR51 [$FF26] = $F1-GB, $F0-SGB ;
Manual
Page 19
... by DP Page 19 Please note that the HALT instruction be used whenever possible to assume the above . Always set all RAM to some value. 2.7.2. Game BoyTM CPU Manual 2.7.1. This command stops the system clock reducing the power consumption of the GameBoy emulators tend to set these at which point the...
... by DP Page 19 Please note that the HALT instruction be used whenever possible to assume the above . Always set all RAM to some value. 2.7.2. Game BoyTM CPU Manual 2.7.1. This command stops the system clock reducing the power consumption of the GameBoy emulators tend to set these at which point the...
Manual
Page 20
... (EI). This instruction skipping doesn't occur when interrupts are disabled (DI) on the GB,GBP, and SGB as 76 halt Page 20 V 1.01 If interrupts are disabled (DI) then halt doesn't suspend operation but it does cause the program counter to stop counting for all examples) 1) This... code causes the 'a' register to occur on how much CPU time is required by a game, the HALT instruction can extend battery life anywhere from Martin Korth who documented this problem: (assuming interrupts disabled for one instruction on the GB,...
... (EI). This instruction skipping doesn't occur when interrupts are disabled (DI) on the GB,GBP, and SGB as 76 halt Page 20 V 1.01 If interrupts are disabled (DI) then halt doesn't suspend operation but it does cause the program counter to stop counting for all examples) 1) This... code causes the 'a' register to occur on how much CPU time is required by a game, the HALT instruction can extend battery life anywhere from Martin Korth who documented this problem: (assuming interrupts disabled for one instruction on the GB,...