Site Search
Homepage of Otaku No Zoku
Complete Archives of Otaku No Zoku
About Otaku No Zoku
Subscribe to Otaku No Zoku
Bookmark Otaku No Zoku

Otaku No Gameboy :

This was another attempt to get a programming book published. I originally pitched this idea by cold calling the chief submissions editor at a major publisher directly and had “Yes” in less than 4 minutes and a preliminary contract in my e-mail inbox inside of 20 minutes.After giving the contract due consideration I didn’t feel like the publisher was offering enough money for a project that would completely occupy my time for six months so I turned down the book deal about two months in to writing it. By that time I had about 40% of the book completed.

This page exists as a small note on my second attempt at getting a computer book published. I’ve included here a brief preface and list of chapters with an overview of each one. I tried to include those subjects that I think are relevant to developers working with the Gameboy Colour and those developers who will later move on to the “Gameboy Advance.”


It’s doubtful that you have failed to notice the surge in popularity of handheld electronic games over the past fifteen years. Starting with the simple LED games in the early 80’s and culminating in the release last year of the Gameboy Colour from Nintendo. Today’s handheld games contain some of the most dazzling graphics, endearing characters and engrossing game play that has been seen on the (very) small screen and this book aims to show you how to achieve the same games on the Nintendo Gameboy.

What you need to know

This book is intended as a complete, self-contained text for learning to program the Nintendo Gameboy handheld console in Z80 Assembly and C with the focus on game programming. The reader should already have some programming experience with at least one of these two languages.

This text aims to provide a true level of competence to the person who wishes to program games on the Gameboy. It is based on the author’s direct experience of more than 20 years programming computers, many of them spent programming games for the entertainment industry.

This is not an introductory book, the pace at which concepts and terminology will be introduced is relatively fast. I do not dwell on explaining every piece of information that I introduce so that focus is not lost. There are many books out there that already explain much of the information more adequately than I can. You should be comfortable with the concepts of a computer’s internals, the CPU, memory, video hardware, how a picture is made up on a computer screen, hexadecimal and binary, and the distinction between compilers and assemblers.

In any subject dealing with game programming, and game programming on the Gameboy especially, there will be some assembly language involved, along with a heavy dose of hardware knowledge at a very low level.

In many sections I gloss over a lot of things. I assume you don’t want to know how the ALU connects to the barrel shifter and how it interacts with the internal and external data bus inside the CPU and can happily live without a thoroughly detailed explanation of how RAM really works. If you thirst for this kind of intimate knowledge I can suggest “Master Class Assembly Language” by (insert authors/publisher here) and ” Programming the Z80″ by Rodnay Zaks, (clean up the book references yah dope!) . The latter is now, unfortunately, out of print, but you may be able to pick up a copy either from an on-line out-of-print book search or an on-line auction for around $15.

Even if you already know how to write application software for the Gameboy console I hope that you can still learn something from this book. In addition to learning how to use C and Z80 Assembly more effectively on the Gameboy you’ll also benefit from the detailed explanations and source code solutions to common Gameboy programming problems.

Among the advanced programming concepts covered are those dealing with a re-usable sprite engine, implementing dynamic tile loading and code optimization techniques. There’s even some music and sound effects thrown in for good measure.

So, whether you have yet to be published, are working away on your first title now that someone has given you your “big break”, or are a ten-year veteran I look forward to imparting any knowledge to you that you will find useful.


What’s covered in this book are techniques for developing games on the Gameboy handheld. Its not explicitly designed to be read from cover to cover but more as a reference that you’ll dip in to as the occasion warrants. Some of the chapters logically progress from one to the next, others are isolated and, assuming you understand the material, can be read through without ever referring to a previous section or page.


Chapter A, “Handling Player Input,” introduces you to programming the Gameboy control pad, and how to handle the player’s input once it’s received.

Chapter B, “Chosen Development Environment,” introduces you to the tools that are available, where to obtain them, and how to put them to use.

Chapter C, “Memory,” covers the organization of memory in the Gameboy, it gives an introduction to bank switching, why we need it, and the pitfalls that you will encounter whilst creating your masterpiece game.

In Chapter D, “Gameboy Overview,” you learn the basics of the Gameboy handheld, it’s a brief introduction to Nintendo’s world conquering handheld from the perspective of a programmer.

Chapter E, “Dealing with SRAM,” reveals the workings of battery backed SRAM found on some Gameboy games. You learn how to save and restore a high score table so that it remembers the player’s achievements and also how to save and restore an actual game-state so that the player can return to their position after taking a rest from your latest blockbuster game.

Chapter F, “Programming the Gameboy,” takes you through the steps required to get your code up and running. It introduces the tools used for compiling, how to set them up, specific techniques you can utilize when programming an 8-bit CPU and how to interface your C code with Assembly Language for maximum performance.

Chapter G, “Handheld Video Game Primer,” introduces you to how video games are made, the design process a video game will go through at each stage of development and the final pass through of play balancing to make sure it has all the qualities it needs to succeed. The chapter covers peculiarities of developing for the Gameboy handheld and design decisions to watch out for that go against what is known to work and not work on the Gameboy.

In Chapter H, “Interrupts,” you learn how interrupts work and what they are used for. How they apply specifically to a Gameboy game and examples of when to use them is also covered in depth.

Chapter I, “Sound and Music,” you learn how to implement computer game music and those all-important sound effects that make up the hidden 30% fun factor in any successful game.

Chapter J, “Assembly Language,” introduces you to assembly language and how to integrate it with C to produce the fastest and slickest games around.

Chapter K, “Crib Sheet,” the colourful, ever-popular, world famous, can’t live without it, Gameboy Crib Sheet is introduced. It’s the one information resource, if you do any kind of work with the Gameboy, that you will refer to time and again, no matter how many titles you’ve shipped.

Chapter L, “Sprites,” shows you the workings of hardware and software sprites and how to use them in games to represent the player, enemy, missiles and explosions.

Chapter M, “Video Display,” reveals the workings of the Gameboy video hardware, how colours are displayed on screen, how to interact with the colour palettes and tricks you can use to display more than the normal number of colours per screen.

In Chapter N, “APA Mode,” you learn how to address the video display as a regular bitmap device and draw lines, circles and dynamic special effects that can’t be achieved any other way.

Chapter O, “Collision Detection,” introduces you to detecting collisions between game objects and what to do when it happens with collision resolution. Optimisation of collision detection routines is also covered to keep your game’s frame rate as high as possible.

Chapter P, “Hardware Registers,” reveals the inner workings of the Gameboy hardware. You learn about each hardware register that the Gameboy has to control the video display, sound, joypad, interrupts, serial link, DMA and so on.

In Chapter Q, “Scoring Points,” you learn how to award points for actions the player performs, when they blow up enemies or reach a particular area of the map, and the rewards received for earning a particular score.

Chapter R, “Lives and Death,” explains how to add the element of risk into a game to make it more exciting for the player and how to track, and display, the player’s lives and what happens when they reach zero.

Chapter S, “Dynamic Tiles,” explains how to add dynamic tiles to your game engine to handle hundreds of differing sprites throughout a game and large, varied maps far bigger than could ordinarily be stored in the Gameboy video memory.

Chapter T, “Optimization Techniques,” gives you tricks and techniques to optimize your game for maximum performance, how to track down elusive bottlenecks in your code and showing where to concentrate your optimization efforts.

Chapter U, “Scrolling A Map Around,” explains how to let the player scroll around a map larger than the screen. It introduces meta-tiles and special properties you can give to parts of the background that let the player and computer controlled game objects interact with it.

Chapter V, “The Window,” shows how to display a window overlaid on the screen to use as a status bar for your game. It explains how to display multiple windows and how to achieve parallax-scrolling effects.

In Chapter W, “Rumble Pack,” you learn about putting rumble effects in your game to immerse the player deeper in to the game world and provide tactile feedback for their actions.

Chapter X, “Other Gameboy Hardware,” (probably want to break this out in to 2 or 3 separate chapters, one for each piece of hardware) shows you how to control the infra-red port to send messages between two Gameboy handheld units, and how to control your home VCR. The serial link is explained and you are given examples on how to communicate with another Gameboy in your game.

Chapter Y, “Power Consumption,” explains the power consumed by various components of the Gameboy when used in your game and how you can maximize battery life for your players.

In Chapter Z, “Random Numbers,” you learn how to introduce randomness in to your game and how to generate random numbers as efficiently as possible.

Chapter A1, “Writing a Game,” explains the general game loop and how to best approach each feature requirement from a programmer’s perspective.

Chapter B1, “Special FX,” introduces you to creating lighting effects, real-time palette changes, big explosions and on screen trickery.

— Justin Lloyd

Liked This Post?

Subscribe to the RSS feed or follow me on Twitter to stay up to date!