Won't record a movie, but this is my best attempt at a complete walkthrough.
1) Download the latest cc65 suite from here: https://cc65.github.io/cc65/getting-started.html
2) Extract it to c:\cc65
3) In c:\cc65, create a new folder. Name it "_MyFirstProject"
4) Open that folder. And open notepad. Write this:
Code: Select all
ca65 -t nes -l mylist.lst src/mycode.asm -o myobjectfile.o
ld65 -C src/NROM.cfg myobjectfile.o -o mynesrom.nes
And save it as "_makefile.bat" in the project folder you just created. We'll get to what that did in a bit. For now, let's do a couple more things:
5) Within your project folder, create a new one called src. This is where we'll keep sourcecode and assets and configs. Open it.
6) Download dougeff's config zip and place one of the configs in it named something with "nrom" there. It doesn't matter which one at this point, but rename it to NROM.cfg for the sake of this walkthrough.
7) Make a new text file, let's call it mycode.asm.
8) Write some lines of code in it (since we're using dougeffs configs, a tip is following the same tutorials) and save.
9) So, with all that done, let's try it. Double click your batch file to make it run ca65 and ld65.
You should now have a NES binary file called mynesrom.nes. Congratulations!
Allright, let's get back to what the batch file did.
The batch file (.bat) is a way of automating using the command line tool, which you otherwise would use each time you'd assemble source code into a binary file (what one might offhandedly call a ROM, after the .rom file extension), using ca65*. We're not there yet, though, just preparing.
Let me step through what that batch file will do once you run it (you'll eventually do so by double clicking on it)
| this tells windows to run ca65; the assembler. Windows should know where it's at, so we don't need to specify the whole path.
| this is our first "command line option" - optional instructions which tells ca65 what to do. -t sets the target platform to nes. This isn't necessary to specify, but is handy: the right processor is chosen and so we will get notified if we try to use opcodes it can't accept. There's more to it if you'd program for, say, the commodore 64, but let's not get into that.
| this tells ca65 to create a listing of its output. It's not necessary either, but viewing the .lst file in a text or code editor might reveal things when you're analysing your resulting program and its machine language strings can be used for finding stuff in a hex editor. We won't get deeper into that now either.
| this will tell the assembler what file to assemble. The src\ part indicates that we have a folder named src in which the code should be.
| This tells ca65 that the assembled output file (called an object file) will be named myobjectfile.o - if we don't include it, it will default to the filename of your source code file but have the extension .o instead of what your source had.
Allright, so with that line run, the assember has made an object file. It's now the job of the linker to link together object files. Since we only have one for now, the linker will simply take that object file and output it as a nes file. But we need to instruct it to do so, of course. So here's line two:
| This will start the linker. Let's tell it what to do.
| Use the config file named NROM.cfg
| Convert this object file according to specs found in NROM.cfg
| into an output we name mynesrom.nes.
Pause | This is so the command prompt window doesn't close after execution. This way we can review what it had to say - were there any warnings, errors, or did we succeed? The pause is entirely optional, but is handy.
You now know how to make .nes files using batch files and the cc65 suite. If you instead want to use the command line, you simply use the win-r hotkey, write "cmd.exe", hit enter, and then enter the same lines you wrote in the batch files (not "pause". that one is redundant here).
*ca65 and ld65 are two tools in the cc65 toolchain. ca is the assembler, ld is the linker. Both are needed to make a nes rom using assembly language.