It is currently Sat Mar 23, 2019 9:21 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Mar 13, 2019 4:26 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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?


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:30 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21210
Location: NE Indiana, USA (NTSC)
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?


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:34 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:37 pm 
Online
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2253
Location: Fukuoka, Japan
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 ;)


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:40 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:41 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3661
Location: Indianapolis
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:49 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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?


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 5:55 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21210
Location: NE Indiana, USA (NTSC)
  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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:00 pm 
Online
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2253
Location: Fukuoka, Japan
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:08 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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?


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:10 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:13 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11237
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:20 pm 
Offline
User avatar

Joined: Wed Mar 13, 2019 4:13 pm
Posts: 7
Location: Homer Glen, IL
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?


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:32 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21210
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Wed Mar 13, 2019 6:59 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11237
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group