This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

New to NES development and stumped

New to NES development and stumped
by on (#236024)
Hello, I'm new to trying to develop games on the NES. I wanted to create a fully fledged NES game, but I've been searching numerous tutorials for the past few days and finding little results on how. I found a few sources for trying to code NES in python, javascript, etc. that just didn't work, so I've settled with trying to learn 6502 assembly language and using an assembly program.

Where I've gotten stumped now though is I can't figure out how these programs work and no amount of google searching has helped me here. I've tried CA65 and NESASM, and I can't figure out how they're supposed to actually function. From what I've gathered, you need to write code in notepad, and save it as some sort of file that you can then assemble into an .NES file by running the assembler, but I'm still completely unsure how or what needs to be done. Can anyone here who is experienced help me with this?
Re: New to NES development and stumped
by on (#236026)
You ask the same question as in this topic.

Correct me if I'm wrong, but by balance of probabilities, I'll assume you're using Windows, not macOS or GNU/Linux. Do you know how to use the Command Prompt?
Re: New to NES development and stumped
by on (#236029)
tepples wrote:
You ask the same question as in this topic.

Correct me if I'm wrong, but by balance of probabilities, I'll assume you're using Windows, not macOS or GNU/Linux. Do you know how to use the Command Prompt?

I have tried both Windows and Linux, I can use either, I run both at the same time. Also, I have very little knowledge in using CMD, but I can use the Linux terminal.
Re: New to NES development and stumped
by on (#236030)
It seems tepples snipped me already :lol:

Before being able to help you, we will need to know this important thing: what is your current knowledge about programming in general? I don't need to ask about command prompt since tepple asked but you will need to learn more about how to use it.

Those details will already help in what direction to guide you next ;)
Re: New to NES development and stumped
by on (#236031)
Banshaku wrote:
It seems tepples snipped me already :lol:

Before being able to help you, we will need to know this important thing: what is your current knowledge about programming in general? I don't need to ask about command prompt since tepple asked but you will need to learn more about how to use it.

Those details will already help in what direction to guide you next ;)

I know almost nothing about 6502 assembly language, but I understand basic computer science which it revolves around. I also understand GML and some amounts of JS.
Re: New to NES development and stumped
by on (#236032)
Welcome. Have you viewed this thread? It's not totally comprehensive, but might help you get started.
https://forums.nesdev.com/viewtopic.php?f=10&t=3783

ANSI C is fully supported by the cc65 compiler. Other languages seem to be pretty much experimental. Quite a few games were made with the NBASIC compiler as well, but not anything recently AFAIK.

I would recommend trying NESICIDE. It will work for assembly or C. If you can get it to build one of the example projects, you can start from there.
Re: New to NES development and stumped
by on (#236034)
Memblers wrote:
Welcome. Have you viewed this thread? It's not totally comprehensive, but might help you get started.
https://forums.nesdev.com/viewtopic.php?f=10&t=3783

ANSI C is fully supported by the cc65 compiler. Other languages seem to be pretty much experimental. Quite a few games were made with the NBASIC compiler as well, but not anything recently AFAIK.

I would recommend trying NESICIDE. It will work for assembly or C. If you can get it to build one of the example projects, you can start from there.

I may just stick with cc65/ca65. I just want to know how it's supposed to work though? Like how do I get it to compile code I've written? How do I write the code?
Re: New to NES development and stumped
by on (#236035)
  1. You write the code in Notepad++ or any other text editor.
  2. You assemble each source file with ca65 foo.s -o foo.o which produces a relocatable object file. A relocatable object file cannot run on its own; it is combined (or "linked") with other relocatable object files to form an executable.
  3. You link the object files with ld65 -o mygame.nes -C nrom128.cfg foo.o bar.o baz.o

Usually steps 2 and 3 are automated with makefiles. A working example is nrom-template.
Re: New to NES development and stumped
by on (#236037)
With you current background, getting up to par to work with those tools will take a lot of learning. If your goal is to just make a nes game and see if you want to learn more in details later, in that case I would suggest to start with a tool like nes maker to see if you like to make nes games in the first place.

Once you get the hang of it, you can start to learn more advanced stuff.
Re: New to NES development and stumped
by on (#236038)
tepples wrote:
  1. You write the code in Notepad++ or any other text editor.
  2. You assemble each source file with ca65 foo.s -o foo.o which produces a relocatable object file. A relocatable object file cannot run on its own; it is combined (or "linked") with other relocatable object files to form an executable.
  3. You link the object files with ld65 -o mygame.nes -C nrom128.cfg foo.o bar.o baz.o

Usually steps 2 and 3 are automated with makefiles. A working example is nrom-template.

I don't have a makefile with the version of CA65 I downloaded, and CMD says that "ca65" and "ld65" are not recognized commands. Where should I be putting these commands? Also, what format should I save the txt files in so that it can actually assemble them?
Re: New to NES development and stumped
by on (#236039)
Banshaku wrote:
With you current background, getting up to par to work with those tools will take a lot of learning. If your goal is to just make a nes game and see if you want to learn more in details later, in that case I would suggest to start with a tool like nes maker to see if you like to make nes games in the first place.

Once you get the hang of it, you can start to learn more advanced stuff.

I'm not interested in nes maker. I don't know how it actually works, but I just saw "no coding required", so I'm assuming I can't actually do a lot of the things I actually want to do.
Re: New to NES development and stumped
by on (#236040)
You got the basics right. You need to write ASM code in a text editor (Notepad will do, but there are better options) and save it as a text file, usually with the extension .asm. File extensions are just text and don't affect the contents/format of the file at all, they exist only for convenience.

Then you need to run that file through an assembler, which will interpret everything you wrote and hopefully generate a binary file with 6502 instructions and data formatted like an NES ROM. Assemblers don't have a GUI, they're command line applications that take some input, process it and generate some output. You need to call the assembler with a command line, telling it at least which file to assemble, but you can pass other parameters if you wish (e.g. the name of the output file, among other things).

Since you're not an experienced developer, I advise against starting out with ca65, which is the most complex assembler one can use for 6502 development. Most people start with NESASM, which's what the very popular tutorial Nerdy Nights uses.

Anyway, getting the assembler to work is the simple part... put everything in the same folder: nesasm3.exe, game.asm (your ASM code) and build.bat, which is a text file containing the following:

Code:
nesasm3 game.asm
pause

The first line tells NESASM to assemble your file, and the second line (pause) waits for a key press before continuing, so you can see any messages NESASM outputs (success, failure, etc.). Without the pause, the window would close before you had a chance to read anything. Anyway, just double-click this .bat file and those commands will run, assembling your code and generating an .NES file (if no errors occur).

But like I said, calling the assembler is the easy part, the hard part is knowing what to write in the .ASM file, because you need to know the commands that NESASM supports, the 6502 assembly language, and the NES architecture, otherwise you won't be able to write meaningful code. It would probably be a good idea to follow the Nerdy Nights tutorial, to get a hang of how things work. If something isn't clear, you can always come back here and ask.
Re: New to NES development and stumped
by on (#236041)
tokumaru wrote:
You got the basics right. You need to write ASM code in a text editor (Notepad will do, but there are better options) and save it as a text file, usually with the extension .asm. File extensions are just text and don't affect the contents/format of the file at all, they exist only for convenience.

Then you need to run that file through an assembler, which will interpret everything you wrote and hopefully generate a binary file with 6502 instructions and data formatted like an NES ROM. Assemblers don't have a GUI, they're command line applications that take some input, process it and generate some output. You need to call the assembler with a command line, telling it at least which file to assemble, but you can pass other parameters if you wish (e.g. the name of the output file, among other things).

Since you're not an experienced developer, I advise against starting out with ca65, which is the most complex assembler one can use for 6502 development. Most people start with NESASM, which's what the very popular tutorial Nerdy Nights uses.

Anyway, getting the assembler to work is the simple part... put everything in the same folder: nesasm3.exe, game.asm (your ASM code) and build.bat, which is a text file containing the following:

Code:
nesasm3 game.asm
pause

The first line tells NESASM to assemble your file, and the second line (pause) waits for a key press before continuing, so you can see any messages NESASM outputs (success, failure, etc.). Without the pause, the window would close before you had a chance to read anything. Anyway, just double-click this .bat file and those commands will run, assembling your code and generating an .NES file (if no errors occur).

But like I said, calling the assembler is the easy part, the hard part is knowing what to write in the .ASM file, because you need to know the commands that NESASM supports, the 6502 assembly language, and the NES architecture, otherwise you won't be able to write meaningful code. It would probably be a good idea to follow the Nerdy Nights tutorial, to get a hang of how things work. If something isn't clear, you can always come back here and ask.

Thanks, this is the answer I was looking for, it worked! However, I was advised not to use NESASM, as it was an inferior assembler, why is that?
Re: New to NES development and stumped
by on (#236042)
AiNaKa wrote:
I don't have a makefile with the version of CA65 I downloaded

Usually each project that you build will provide its own makefile. If you are trying to make sure that ca65 and ld65 work correctly after you have installed them, I recommend building someone else's simple "hello world"-type project rather than starting from a blank page. The GNU Make program processes makefiles, and it is downloaded separately.

AiNaKa wrote:
and CMD says that "ca65" and "ld65" are not recognized commands. Where should I be putting these commands?

Into Command Prompt after you have added the folder containing the executables ca65.exe and ld65.exe to the Path environment variable.[1]

AiNaKa wrote:
Also, what format should I save the txt files in so that it can actually assemble them?

Any plain text encoding that has ASCII as a subset, such as UTF-8 or Latin-1, will work.

AiNaKa wrote:
I was advised not to use NESASM, as it was an inferior assembler, why is that?

I can think of three reasons people may have advised you not to use NESASM:
  1. Some of the syntax that NESASM requires is nonstandard among 6502 assemblers, such as its use of [address],Y instead of (address),Y for indirect indexed addressing mode.
  2. NESASM has been seen to assemble invalid code to something completely different, second-guessing what you meant instead of raising an error.
  3. The 1-pass model of NESASM and ASM6, where files containing subroutines routinely include other files containing subroutines rather than being assembled separately and linked later, can make larger projects unwieldy.

But even if you learn the basics in NESASM, about 98 percent of your skills should transfer to ASM6, and 90 percent will transfer to ca65.


[1] Whether to add the folder to Path system-wide or to add it in a batch file that extends the Path and then opens cmd is a discussion for elsewhere. I'm interested in having that discussion, just not in this very topic.
Re: New to NES development and stumped
by on (#236045)
AiNaKa wrote:
I was advised not to use NESASM, as it was an inferior assembler, why is that?

I'm not a big fan of NESASM myself, but it is one of the most newbie-friendly assemblers out there. My main gripe with it is that it forces you to divide your ROM into 8KB chunks, something that was carried over from its PC-Engine origins, but doesn't make sense for most NES mappers. That doesn't introduce any actual limitations though, it's just an annoyance.

In fact, you can code any type of game with any assembler, none of them impose any limitations on how far you can go, they just have different philosophies on how things should be structured and how much automation you can do, but for someone who's just starting out, that hardly makes any difference. If at some point you feel that the assembler is holding you back in any way, it will be because you'll have a better understanding of everything, and you'll be able to notice the shortcomings of each tool, so you'll be better equipped to make the decision of whether to switch to other tools.
Re: New to NES development and stumped
by on (#236048)
AiNaKa wrote:
Memblers wrote:
Welcome. Have you viewed this thread? It's not totally comprehensive, but might help you get started.
https://forums.nesdev.com/viewtopic.php?f=10&t=3783

ANSI C is fully supported by the cc65 compiler. Other languages seem to be pretty much experimental. Quite a few games were made with the NBASIC compiler as well, but not anything recently AFAIK.

I would recommend trying NESICIDE. It will work for assembly or C. If you can get it to build one of the example projects, you can start from there.

I may just stick with cc65/ca65. I just want to know how it's supposed to work though? Like how do I get it to compile code I've written? How do I write the code?


NESICIDE is pretty much an IDE for cc65/ca65. But with stuff like NES emulation, being able to step through execution of the source code, stuff like that. In that case, there is a command in the UI to compile it.
Re: New to NES development and stumped
by on (#236067)
I also recommend to follow the Nerdy Nights tutorials so you learn the basics, and don't worry too much about the assembler at this time. Learning some nesasm doesn't hurt at all and the Nerdy Nights examples are available in an asm6 version if you dig around Nesdev forums. That should help you to convert to the much more popular asm6 if you want. I also recommend Tokumaru's asm6 templates in that case. This is the way I learned NES assembly, and I didn't have much programming knowledge either when I started.

As for ca65, it will take some more work as it's a bit less newbie-friendly than nesasm and asm6. But if you are interested once you are more advanced I recommend Rainwarrior's example.
Re: New to NES development and stumped
by on (#236098)
i strongly strongly suggest NESICIDE. you'll still be coding in CA65, but - it has a code editor, a compiler, and an emulator built into one program.

soo, you just write your code, press the compile button, then press another button to load the program into your emulator, and then you can test your code, all in the same program. additionally you can places stops in your code and examine the various register values and so forth at any point in your program.

i was ready to give up trying to program NES games when i found it. and now i'm close to releasing a full-length game.

the one issue i have with it is that the documentation is pretty poor, but you can ask any questions about it here and get help, so not a huge deal. when our game is finished i am thinking about doing a few video tutorials on it.
Re: New to NES development and stumped
by on (#236103)
toggle switch wrote:
the one issue i have with it is that the documentation is pretty poor, but you can ask any questions about it here and get help, so not a huge deal. when our game is finished i am thinking about doing a few video tutorials on it.

My main problem with documentation, and why mine is so poor, is I never feel I'm at a point where stopping to take screenshots of the UI to explain things is going to be representative of the actual state one sees when running the program. I *hate* documentation showing outdated screenshots of a UI that you are forced to assume "Blend the flibulator" checkbox is equivalent to "Mix" option in a "Flibulator" combo box. This has been a gravity well for me for decades, not just with nesicide.

Video tutorials would be awesome...if I had *any* confidence in my own video production or narration skills. I would *love* to do some ElectroBoom-ish nesicide videos...ha.
Re: New to NES development and stumped
by on (#236107)
cpow wrote:
toggle switch wrote:
the one issue i have with it is that the documentation is pretty poor, but you can ask any questions about it here and get help, so not a huge deal. when our game is finished i am thinking about doing a few video tutorials on it.

My main problem with documentation, and why mine is so poor, is I never feel I'm at a point where stopping to take screenshots of the UI to explain things is going to be representative of the actual state one sees when running the program. I *hate* documentation showing outdated screenshots of a UI that you are forced to assume "Blend the flibulator" checkbox is equivalent to "Mix" option in a "Flibulator" combo box. This has been a gravity well for me for decades, not just with nesicide.

Video tutorials would be awesome...if I had *any* confidence in my own video production or narration skills. I would *love* to do some ElectroBoom-ish nesicide videos...ha.


You would have to keep the documentation updated anyway, screenshot/videos or not, right? Also, an outdated picture is better than none, as long as you state what version of the software the documentation is for. :)

Btw, I've never tried NESICIDE but hearing about the ability to set breakpoints in code and not just the compiled result makes me very interested to check it out! :beer:
Re: New to NES development and stumped
by on (#236108)
pwnskar wrote:
You would have to keep the documentation updated anyway, screenshot/videos or not, right? Also, an outdated picture is better than none, as long as you state what version of the software the documentation is for. :)

Right. Like I said, it's a gravity well. I can't even gather energy to get started on it. Updating it is a distant nightmare. I realize this is not user friendly behavior and likely driving people to other tools like NES Maker. I can't compete with their production quality / promotion skillz. But I also don't want to charge $36 a copy either...I have two day jobs already!
pwnskar wrote:
Btw, I've never tried NESICIDE but hearing about the ability to set breakpoints in code and not just the compiled result makes me very interested to check it out! :beer:

I am trying to make it easier to try...by providing builds...but even that has its own 'YMMV' caveat. :beer:
Re: New to NES development and stumped
by on (#236115)
AiNaKa wrote:
Banshaku wrote:
I'm not interested in nes maker. I don't know how it actually works, but I just saw "no coding required", so I'm assuming I can't actually do a lot of the things I actually want to do.


I'd like to point out the thing about nesmaker is that the whole "no coding required" is just a phrase, which, while true, is not really the full story.

NESmaker is basically an UI Tool that manages the game engine below it, which is written in assembly, and while you CAN make a game just by creating graphics and arranging the premade pieces
of assembly provided by the engine, this is something that is entirely optional.

the assemblies of nesmaker's engine are plain .asm files and they are modifyable and compilable just fine without nesmaker itself.
It's a really good tool to act as a stepping stone in learning assembly as you can simply use the engine and then start slowly modifying the scripts it provides to make the engine do things you
wish it to do.

Nesmaker was my first touch to 6502 (started couple months ago) and at this point i have almost completely abandoned the tool in favor of continuing to develop my game, as the limitations of the
tool came hard against me. As such, i set the tool aside and continued to write the code in notepad.

I highly recommend that you take a little deeper look into it before completely disregarding it as an option to get into nes development.
Re: New to NES development and stumped
by on (#236251)
cpow wrote:
I have two day jobs already!
Sorry to hear about it, man! Sounds rough.
I hope my comment didn't come across as arrogant or anything. I'm super grateful for people like you who create and share tools like this and I don't want to give any other impression than that. :)