In pursuit of trying something new, I decided to have a stab at some assembly language. 6502 Assembly is the language used by the MOS 6502 processor, which is found in systems such as the NES, Apple II and Commodore 64. When I grew up I had my parents’ old NES and SNES games consoles to use, so I figured it’d be exciting to try to program something for the NES console.
Before I can jump into games development with the language, I need to learn it first. I found a useful source which walked me through the basics, and explained different functions and the registers. I came across a very useful wiki page which explains important architecture of the Nintendo Entertainment System, such as registers, the PPU, Pattern Tables, Palettes and more. For someone used to C# and other object-oriented languages, it’s very different to be programming and regularly using hexadecimal numbers, and to be maintaining my own memory usage. One thing I find particularly clever is how efficient they are. One example is they can keep 8 individual settings in a single byte, simply by converting it to a binary number and reading off the corresponding 0 or 1.
To create a program, I need a palette set to use. A palette set consists of 8 palettes which each have 3 colours plus a background colour. I couldn’t find any software that worked to make my own palettes, so decided to make my own program. When looking at a sample palette set, I noticed it was 32 random characters. It clicked that these were actually 32 bytes which represent numbers, so I did a few tests and confirmed it. I wrote my own quick program to generate NES Palettes. The values in each box are hexadecimal and correspond to the colour palette of the NES.
Using this I can now generate and edit my own palettes. Because of the way the NES colours works (they aren’t RGB values, rather tv signals to be converted to colour).
I found a compiler called NESASM3, and a tile editor called TLP, and managed to make my own sprites, and assign them a palette. I managed to get together a start of a game. Basically there’s a paddle on the screen which can move left and right, and is kept on the screen by bounds. There is a ball, however it doesn’t do anything yet. I’m thinking of either making a pong game, or maybe a breakout game. Here is the code I’m working with.
It should go without saying it isn’t much yet, but as far as learning a 30+ year old language goes, I feel I’ve made good progress. I found it hard finding good resources to use to learn 6502, and could only find few. I hope to be able to write an extensive tutorial on programming and on the basic architecture of the NES to help anyone else who is looking to learn 6502 assembly.
I’m a software developer and recent graduate from the University of Hull. I’m fascinated by machine learning, artificial intelligence & procedural generation, and love sinking into exciting projects such as games, simulations & websites!