Skip to content

Instantly share code, notes, and snippets.

@zorchenhimer
Last active July 10, 2023 18:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zorchenhimer/b5e1f30feb082f5a920c6b7e7a072b13 to your computer and use it in GitHub Desktop.
Save zorchenhimer/b5e1f30feb082f5a920c6b7e7a072b13 to your computer and use it in GitHub Desktop.
Setting up a build environment for the NES with cc65

Setting up a NES Build environment

This setup will allow you to assemble the NES projects I've got up on GitHub.

Requirements

Setting up dependencies

Make a folder somewhere for all this stuff to go. Something like C:\nes (or ~/nes if on Linux). All of the following commands should be run from the command line in the folder you create.

All dependencies will be put into a subfolder:

$ mkdir tools

cc65

If you're on Windows you can grab the release snapshot from their SourceForge instead of compiling from source: cc65-snapshot-win32.zip

For linux, or if you want to compile from source on Windows:

$ cd tools && git clone https://github.com/cc65/cc65.git
$ cd cc65 && make && cd ..

Compiling cc65 may take a little while.

Go

A few utilities are written in Go and are incorperated into the build process. These utilities are usually built when needed and include things like bmp2chr and generate-credits.

Download and install Go from here: https://golang.org/dl/

If you run linux, your distribution may have Go in it's package repository. The most recent version of Go is usually required (v1.12 as of this writing).

Ready to build

At this point you should be able to assemble my various NES projects by typing make in the correct source directory.

For instance, to assemble nes-pong run these commands, starting in the top-level nes folder:

$ git clone https://github.com/zorchenhimer/nes-pong.git
$ cd nes-pong
$ make

After make finishes you should have a bin/ folder inside the nes-pong folder which will contain the rom file pong.nes. The directory structure should look like this:

nes
├── pong
│   ├── bin
│   │   ├── pong.labels
│   │   ├── pong.lst
│   │   ├── pong.mlb
│   │   ├── pong.nes
│   │   ├── pong.nes.0.nl
│   │   ├── pong.nes.db
│   │   ├── pong.nes.map
│   │   ├── pong.nes.ram.nl
│   │   └── pong.o
│   ├── LICENSE.txt
│   ├── Makefile
│   ├── pong.asm
│   ├── pong.chr
│   ├── README.md
│   └── [...]
└── tools
    └── cc65
        ├── bin
        │   ├── ca65
        │   ├── ld65
        │   └── [...]
        └── [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment