The Technology

The NES has a modified version of the 6502 8-bit CPU inside. This CPU was very prevalent in the era of 8-bit computers and can be found in a large number of the early machines such as the Commodore 64, Commodore PET, Apple II, BBC Micro, and many others. Because of this, the main program was coded using 6502 assembly code.

Assembly code differs from coding languages you might have heard of like Java, Python, Javascript, C, C#, C+, and others. When you code in assembly, you are telling the CPU exactly what it should be doing, step by step. You tell it what numbers to load, where to get them from, where to temporarily load them, what to do with it once it has loaded one, where to store it after it's done, and what aspects of hardware on the NES it needs to manipulate. In contrast, the higher level languages mentioned above like Javascript do most of this work for you in the background.

The code for just the ROM is right at about 2200 lines of code and is responsible for drawing all of the graphics on screen, the GUI logic for song selection or traveling between pages, bankswitching the different blocks of data stored on the cartridge, as well as controller reading for user interaction. It basically ensures that what you see on screen and hear from your speakers corresponds to the right track you wish to select. There are also about 30 files for music, and various others containing things like the graphics tiles and track names for each of the 5 song screens.

The music on this cartridge was all coded using MML or 'Music Macro Language'. This language first appeared in Microsoft BASIC back in the 70's and 80's, and was used to control the Programmable Sound Generator (PSG) in very early computers. With this language, note values, lengths, volumes, vibrato, and other such parameters are written in plain text and later compiled into CPU instructions using a compiler.

In 2001, a compiler for this language called MCK (Music Creation Kit) was made, allowing MML to be used to program the Sound Generator in the NES specifically. It will take the MML code and turn it into an .NSF file (Nintendo Sound Format). This file is very much like a MIDI file, except only for the NES. It contains a set of instructions that the NES can understand to tell the sound chip exactly what to play in order to reproduce a piece of music. These days, people use the modified version of this compiler called ppMCK for it's updated features and functionality. MML in tandem with ppMCK is what I have used to make this project.

The Backstory

The idea for this started back in 2014 when I created two covers from the Zelda series, Midna's Lament and the Song of Storms. At the time I was completely fascinated with the NES, and still am. However, it was more than just the NES itself, but rather albums of music released on NES cartridge, playable on the console.

Some very influential music cartridge releases that I still love to this day are Teletime by Animal Style (nmlstyl), the 2A03 Puritans compilation by Bit Puritans, and Vegavox & Vegavox II by Alex Mauer. The 2A03 Puritans ROM was coded by the very talented Rainwarrior, while Teletime and both Vegavox releases were made possible with the NES coding expertise of No Carrier. Both of these developers have made some very impressive things on the NES. I wanted to follow their example and do the very same, so I set out to try and make one of these type of albums for myself.... Except, while I was familiar with MML and how to make music on the console, I had no knowledge on how to actually code a ROM for the NES.

Among many of the things No Carrier has created, the most notable for me was called VegaPlay (Named after Vegavox). This was a template of NES assembly code he released to allow people to load their NES music into, compile into an NES rom, and play it on actual hardware. This was great news for me, a person that wanted to release a cartridge, but also knew nothing about NES code. However, this was only one step of the puzzle since I had no knowledge on how to modify the graphics, add sprites, add animations, make multiple pages, or modify the any functionality to turn it into an acceptable release. I did not want make or release anything that was not made to it's full potential, and did not want to have to ask another coder to essentially do my project for me and code my GUI. For these reasons, I shelved the idea, and stopped producing my Zelda covers for the NES.

Earlier this year, in 2019, I came across a tutorial series on the Nintendo Age forums called Nerdy Nights. It was a collection of tutorials on how coding for the NES works and was targeted at people that knew nothing about NES assembly code. More importantly, it guides you through the hardware on the console, and explains how to code for it. This sparked my fire again and gave me the motivation and tools needed to make this release happen properly. I decided to study everyday and set out on this project once more.

I took what I learned from analyzing how VegaPlay operated, and my understanding gained from Nerdy Nights, and began coding Moonfall from scratch. Several months, and 2000+ lines of assembly code later, I have completed this project and am ready to share with you all.