The World of NES Homebrew Development
I’ve been itching to explain just how an NES game is made and the process involved, but I just haven’t had any idea on how to go about it. Then after a little tinkering with a homebrew game called ‘Hiatus Ward,’ it became all too clear: The best way to explain how to make a game is to dissect one. Now, I’m not gonna explain how to program a game for the NES, or explain how the NES hardware works – maybe I will eventually in a future article, once I’ve mastered how to make an NES game of my own. What I will explain is what the NES can do and where to look if one is to pursue NES development.
The first thing you’ll need to know, in order to develop a game on the NES, is 6502 assembly language. Assembly language is the lowest level form of programming and often considered the hardest. To be honest with you, it isn’t that hard, I managed to learn it in about 2 weeks after reading a few chapters from “Using 6502 Assembly Language,” an out of print book that can be downloaded from various sources for free. The book teaches how to program in 6502 assembly on an Apple II, and how to get around some of the limitations it has – such as its lack of being able to multiply and divide numbers other than two, or being able to perform simple arithmetic on numbers greater than 256 (8-bit data). Although the book’s focus is solely on the Apple II, almost everything that can be learned from it can be applied to other devices that use the 6502 processor (or it’s variants).
When I was finally able to grasp how to program the 6502 processor, I was surprised by how many devices actually used it. Not only did I learn how to read source code for an NES game, but I could also read source code for an Atari 2600, the TurboGrafx 16, the Commodore 64, and the Apple II series – all of which use the 6502 processor. The 6502 is an 8-bit processor, meaning it can fit 8 bits of data into its many registers. Each register in the 6502 performs a specific task. One of the registers, called the accumulator, is the one programmers use the most, and where a majority of arithmetic operations are performed. The other two notable registers are the X and Y Index registers which are used for counting and comparisons, such as if A is greater than B, etc. A very important register is the status register, which contains a bunch of bits, eight in all, that give information about the last operation performed, like, if a number overflowed (if a number was greater than 256, which is the maximum an 8-bit piece of data can hold before wrapping around back to zero).
Once a person is able to grasp how to program the 6502 processor, the next step is to learn how to program the NES. Programming the NES is pretty simple, the hard part is trying to get around its limitations once the foundations of a game are made. The limitation that bothers me the most is the lack of memory, roughly 64 kilobytes in all, and 2 kilobytes of memory, or RAM (Random Access Memory) are used by the programmer for data that’s always changing, such as a characters position throughout a level.
A bulk of the NES’s memory is found on the cartridge, on the ROM (Read Only Memory) chips. The ROM chips on a cartridge come in two flavors, a PRG chip that holds the actual data for the game, and a CHR chip that’s used to hold the tiles (graphics) used for sprites and the level. A PRG chip usually comes in two flavors, a 16-kilobyte chip or a 32-kilobyte chip, while the CHR chip is usually 8 kilobytes. Because the PRG and CHR data are restricted to such a small size, special memory management controllers were created.
MMCs (memory management controllers), also called mappers, were created to sorta trick the NES into accessing more memory. Without MMCs, games such as the original Super Mario Brothers would not be possible. An MMC allowed the NES to flip through “pages” of PRG or CHR data, which allowed for more graphics and program data. Think of the NES as a person who is restricted to reading books with only two pages, and the only way this person could read beyond two pages is to fool him into thinking he is reading two new pages of an entirely different book. An MMC comes in handy for large games, and can even add special abilities to the NES.
To understand how to hack or debug an NES game requires understanding of how memory is mapped on the NES. Each memory location or chunk of memory locations has a special purpose, some of which are designated solely for program and graphics data (the PRG and CHR respectively). There are memory locations that are used to communicate with the PPU (Picture Processing Unit) which handles all of the graphics rendering. If you need to make the screen scroll, you simply send a few instructions to the PPU, which in turn moves the screen over (well, something like that). Strange to say, programming the NES has been a lot easier for me than using a library on a PC, such as Direct X.
The NES Homebrew Community
One of the best and oldest sources for NES development has been nesdev.parodius.com, which is an accumulation of knowledge from many people who wanted to better understand the NES’s hardware. The website contains tutorials, sample programs and technical articles all on different parts of the NES hardware. What I like about the website is being able to download all of its content into a single compressed file.
Another great source for NES development is NintendoAge.com, a website with a large community of collectors, homebrewers and much more. Some of the rarest games belong to collectors who are also members of the NintendoAge.com forums. There have been many times when collectors will sell off their rarest titles through the websites forum. Some notable collectors and hackers known to lurk the forums are the likes of PatTheNESPunk, Sivak (the creator of Battle Kid), and Julius Riecke (creator of the Super Bat Puncher Demo).
The NintendoAge forums are especially known for the Nerdy Nights series, which is how many homebrewers got their start. The Nerdy Nights series is a collection of forum posts all of which try to teach game development on the NES. Some of the posts contain a zip file with a program demonstrating the things learned in a particular lesson.
NES Homebrew Corner: Hiatus Ward
Through the NintendoAge forums I have found many NES homebrew games that have caught my eye, and one in particular is Hiatus Ward. Although roughly 50% complete, the game demonstrates the first I’ve ever seen of a homebrewed NES game that features a parallax background. Parallax backgrounds are generally found in 16-bit and above games – such as Sonic the Hedgehog. What makes a parallax background so special is it scrolls at a different speed than the foreground – creating the illusion of depth, or of a distant far away background. The NES was never designed to handle a second background layer, and for a homebrewer to accomplish such a feat would be pretty amazing. The first thing I wanted to do when I saw Hiatus Ward’s use of a parallax background was to ask the developer how he accomplished it. But, through the knowledge I accumulated about memory management controllers used in many NES games, I figured out my own answer.
Certain memory management controllers have the ability to sorta enhance the NES’s PPU (Picture Processing Unit) by adding the ability to create a separate scrollable section of the screen. This separate scrollable section can be scrolled at a different speed than the regular background. One benefit of a separate scrollable section is in games that utilize split screens used for two players. If the separate scrollable layer were to be used for a parallax background, the downside would be it would have to cover an entire region of a “room”. The method Hiatus Ward uses for a parallax background is not the same as what you would find in other games that utilize the parallax effect. For example, you can’t mix background A with background B; instead, there is one large strip of screen with only the second background on it. In order for the developer to create the illusion of two mixed backgrounds, he had to use some of the sprites (typically used for characters and enemies) to create platforms.
The problem with using sprites for platforms (or background objects) is if more than 8 sprites are on a horizontal region of the screen at the same time, the sprites will flicker. Sometimes the flickering can be tolerable, but in the case of Hiatus Ward it can get a little annoying. There are some rooms that do not use sprites, with tiles that create a perfect illusion of a stationary object. For example in the room of the first boss, there is a large green beam that covers the parallax portion of the screen. Upon inspection, my guess was it’s probably moving since the parallax background only moves vertically. The use of patterned tiles to create the illusion of a stationary object is Hiatus Ward’s strongest feat. Hopefully Hiatus Ward’s developer will find other ways to put illusionary objects on a parallax background. If he accomplished that, it would be something homebrew developers would try to mimic for years to come.
A parallax background is not the only unique feature found in Hiatus Ward. Upon first inspection, the player will notice that there aren’t a lot of flat platforms. Most of the platforms are slanted, with background tiles that are triangular in shape. It’s not very trivial on how to implement the slanted platforms, since for the most part they are likely to be algebraic in nature. If someone were to want to mimic how the platforms were created in Hiatus Ward, they would have already learned how in a high school algebra class – this is where math comes in handy kids!
The main character of Hiatus Ward is Sefi, a female heroine whose weapon can attack enemies from many different angles. With all the ninjas jumping around, one thing I can appreciate about this game is how Sefi doesn’t recoil after being attacked. If the designer dared to incorporate a recoil, the game play would look something like the original Ninja Turtles for NES. Imagine trying to control a character who was about to make a vital jump to the next platform, only to have one of many enemies’ attack causing your character to recoil into a ditch. Now imagine that a dozen more times and you’ll get the general idea of what introducing a recoil to this game will cause. For an NES game, the character and enemy sprites are huge, about the average size of a character sprite found in many 16-bit games. What I don’t like about both the main characters and enemies is how stiff they look when running and jumping – I understand it takes a lot of sprites to make up all these things, and that the designer was trying to save resources, but do they have to look so stiff?
Hiatus Ward doesn’t look like much when watching it through a video, or by glimpsing the screen shots. The game is very buggy, but keep in mind it is incomplete… however, there are many bosses one could fight and it is very playable (and addicting). I loaded Hiatus Ward on the PowerPak and played it on an actual NES, and the results were much more impressive than had I played it through an emulator. On the NES, Hiatus Ward did not have as many graphical glitches as on an emulator. The only problem with Hiatus Ward was with the top portion of the screen – it is hard to see and you’ll need that portion of the screen to view a boss’s life bar.
A feature I hope eventually gets added is to be able to skip dialog. It’s rough trying to play the game only to have accidentally talked to a character who won’t shut up! All in all, Hiatus Ward is a very promising game that I’d love to see get released in cartridge form. If it makes it that far, I would be more than happy to purchase a copy.
That’s it for a glimpse into the world of NES Homebrew development. I hope I made it clear how knowledge of NES development can help one understand games better. Much of the NES’s limitations can be used as an advantage as a game player, and help one appreciate the simpler games in life (like Cheetahmen 2). What I have provided is merely a taste of the NES homebrew world. Beyond what I have talked about there is actually a whole world that is as limited as your imagination. You like playing video games, right? So what’s stopping you from making your own? It’s not as hard as you think.