It is currently Tue Dec 18, 2018 5:56 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Sun Oct 15, 2006 6:00 am 
Offline

Joined: Sat Oct 14, 2006 4:10 am
Posts: 15
So I downloaded CA65, read through the documentation to get an idea of how it's used, and it sounds great. Then I went to the NES101 document and immediatley came across a whole bunch of commands that don't exist in CA65. :x Should I just forget the tutorial and try to write a simple program on my own? Because I'm definitely planning on sticking with CA65 and it seems like following a tutorial written specifically for a different assembler ("P65" in this case) is kind of pointless. (It would be better if the tutorial explained what the commands did so you could find the corresponding command in whatever assembler you were using without having to look at the documentation and "translate" everything. Yes, I'm lazy. Plus it's not condusive to actual understanding.)

Is NES101 the only reliable tutorial out there?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 10:32 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1441
Significant changes would need to be made to NES 101 to get it to assemble with anything other than P65 - no two assemblers use the exact same syntax for "special" things like inserting data (".db", "dc.b", ".byte"), defining constants ("label: .equ value", "label = value", ".alias label value"), reserving space for variables ("label: .block size", "label: .res size", ".space label size"), and anonymous branch labels ("- DEX || BNE -", "* DEX || BNE -", ": DEX || BNE :-"). I'd say, for your purposes, just use P65 for the NES 101 tutorial so you can get a good feel for how the NES works, then choose whatever assembler you want to use for your own projects.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 11:05 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20898
Location: NE Indiana, USA (NTSC)
One problem with P65 Ophis is that a lot of people who run Microsoft Windows do not have Python installed, and Python is 10 MB.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 11:15 am 
Offline
User avatar

Joined: Wed Aug 03, 2005 3:15 pm
Posts: 394
What I did was installed Perl, and used the older version of P65 (for Perl obviously). I did alot with that, but the main thing I didn't like was my sprite tiles were being eaten into by the assembler. But I did get a feel for how to do some things for the NES. I had a fellow Nes Devver help me setup CA65 for NES development (which I think was kind of a pain), and have been going from there.

My point is pretty much what Quietust said. Use P65 to go with the NES101 tut, then if you want to change assemblers after getting an understanding of what is going on, do so.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 1:55 am 
Offline

Joined: Sat Oct 14, 2006 4:10 am
Posts: 15
The process for setting up CA65 to do NES development is complicated? Are there any instructions for doing this anywhere?

Are there any tutorials available other than NES101?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 3:35 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3602
Location: Indianapolis
oxymoron wrote:
The process for setting up CA65 to do NES development is complicated? Are there any instructions for doing this anywhere?


It's not super hard, just different from usual assemblers since there is a linking stage after assembly (using LD65).

In the assembly source, instead of using .ORG you use things like .segment "CODE", .segment "DATA", .segment "VECTORS", and whatever other segments you create and name. The size and location of those are defined by your linker config.

I've got an example linker config you can use here to start with (nes.cfg):
http://www.parodius.com/~memblers/nes/
And n.bat there shows the commands used to assemble it. But in that example I link several different objects (.o files) together.

See the docs for CA65 and LD65 for further info:
http://www.cc65.org/doc/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 6:07 am 
Offline

Joined: Sat Oct 14, 2006 4:10 am
Posts: 15
Thanks memblers! :D I decided to just go ahead and do the tutorial with p65 and now I'm realizing that switching it to ca65 wouldn't be that difficult and I was worrying for nothing. :roll:

Is that all there is to using LD65? It seems pretty simple. After running it you would end up with a valid .nes file?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 6:39 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3602
Location: Indianapolis
oxymoron wrote:
Is that all there is to using LD65? It seems pretty simple. After running it you would end up with a valid .nes file?


The way my linker setup works, you'll end up with just a PRG ROM, no header or CHR-ROM. Which is appropriate for running on an NES (and I prefer to use CHR-RAM).

For emulator use, I have a seperate header file that I just copy onto the ROM after assembly (it's the HEADER file (which seems to not be in that folder online there), and you see it being copied on in n.bat). You could add an iNES header segment to the linker config though.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 12:46 am 
Offline

Joined: Sat Oct 14, 2006 4:10 am
Posts: 15
Thanks again memblers. I just want to make sure I understand what the batch file does:

Run CA65 on the components
Run LD65 on all the CA65 output files to output the file "lib", which would be playabe on the NES (along with a map file rom.map)
Combine header and lib into the file "lib.nes" which is playable in an emulator

Is that right? Is "header" just the iNes header after being run through ca65 by itself? Could you make a rom in a format other than iNes just by changing to a different header file?

Why are the components of the program separate object files? Is that to make it quicker to use the same ones in different programs, or to make it easier to see where the mistakes are if there are any? Would using .include when you run ca65 in the first place sort of do the same thing?

Also I'm not that familiar with batch files - is the line \nes\fce\fceu lib.nes a continuation of the "COPY" command line before it and mean copy the file as lib.nes to the folder nes\fce\fceu? And the REM lines would copy to other folders if you removed the REMs?

(Sorry, I just want to make sure I fully understand everything as I go along so I don't get confused later. :oops:)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 3:53 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3602
Location: Indianapolis
I made the header by editing it in an emulator (Nintendulator and NESticle both come to mind as emus with header editors) and cutting it off in a hex editor. You could add any kind of header or other data (like CHR-ROM or other pre-assembled PRG banks) the same way.

I'm not sure why I did it as seperate object files there, normally I just .include a source file in the main one. Not sure if I had any advantage by doing it that way.

The \nes\fce\fceu lib.nes line is a seperate command, it runs the emulator and loads the ROM from the current directory. And yeah, the REM lines are just lines that are commented out.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 6:21 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1441
I generally have my assembler output a plain PRG binary and then use a separate program I wrote (called MakeINES, with counterpart MakeUNIF) which takes a plain text 'makefile' to combine the PRG and CHR and generate a header (or, for UNIF, the internal structures) to produce a valid ROM image.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Last edited by Quietust on Fri May 15, 2009 10:22 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 10:31 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20898
Location: NE Indiana, USA (NTSC)
oxymoron wrote:
Could you make a rom in a format other than iNes just by changing to a different header file?

Yes, provided that one of the fields of the header isn't a CRC or some other digest of the contents of the ROM. For such formats, you'll want to assemble separate PRG and CHR files and then run them through the format's builder.

Quote:
Why are the components of the program separate object files? Is that to make it quicker to use the same ones in different programs, or to make it easier to see where the mistakes are if there are any?

That, plus you only need to recompile one component if you have changed it. The GNU tool called Make automates this, and there are a whole bunch of frontends for making "makefiles", or scripts for Make.

Quote:
Would using .include when you run ca65 in the first place sort of do the same thing?

Using .include to bring in code or data tables makes compilation take longer and runs the risk of bringing in a piece of code twice.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 5:14 pm 
Offline

Joined: Sat Oct 14, 2006 4:10 am
Posts: 15
Is there anything wrong with just writing the iNes header into the original assembly program? Is there a benefit to adding it afterward? (I mean if you're just going to run the program on an emulator.)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 5:22 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20898
Location: NE Indiana, USA (NTSC)
oxymoron wrote:
Is there anything wrong with just writing the iNes header into the original assembly program? Is there a benefit to adding it afterward?

With iNES format or NES 2.0 format, you can write the header into a segment of the assembly language program. But with other formats, you won't be as lucky.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 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