It is currently Mon Oct 22, 2018 12:20 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: CC65 Won't boot
PostPosted: Fri Oct 12, 2018 3:24 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10906
Location: Rio de Janeiro - Brazil
That happens if ca65 isn't in the same folder where you're typing the command from (Windows doesn't know where ca65 is!). You have to either put everything in the same folder (not recommended) and run the command from that folder, or type the whole path to ca65 and run the command from anywhere (e.g. c:\programming\tools\ca65 game.asm from the folder where game.asm is).


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Fri Oct 12, 2018 3:34 pm 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 167
Another option is adding it to your PATH, the list of folders that Windows looks for programs in. Doing that will let you run ca65 in any folder, but it's a bit more advanced. Take a look at this guide if you're interested.

I also notice that your error message has two sets of quotes in it, which might mean you typed the command with quotes around it by mistake. Make sure to type ca65 filename.txt, not "ca65 filename.txt".


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 1:31 am 
Offline

Joined: Tue Oct 09, 2018 8:31 am
Posts: 8
I'm still having no luck, I've added the PATHs to both the game and ca65, and it still says the mesaage 'Fatal error: Cannot open input file `filename.asm': No such file or directory'. I've tried this for both an asm and a txt file, but it still isn't working. I can send screenshots if you need them. Any ideas?


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 1:39 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10906
Location: Rio de Janeiro - Brazil
It looks like Windows can find ca65 now, but ca65 can't find "filename.asm". You have to run the command from the folder where "filename.asm" is.


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 2:00 am 
Offline

Joined: Tue Oct 09, 2018 8:31 am
Posts: 8
how do I do that?


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 3:03 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10906
Location: Rio de Janeiro - Brazil
Say that the path to the .asm file is c:\Projects\AwesomeGame\game.asm. After you open the command prompt, enter cd\Projects\AwesomeGame ("cd" stands for "change directory", BTW). Then you can enter ca65 game.asm.

To avoid having to type commands all the time, you can create a file named "assemble.bat" in the same folder as the source .asm file, and then write the following in it:

Code:
ca65 game.asm
pause

Then you can just double click that .bat file to assemble the code, no need to type anything. When you double click a .bat file, a command prompt opens up in the folder where the .bat file is and the commands inside the file are executed as if you were typing them. The "pause" at the end is necessary to keep the command prompt open after ca65 is done, otherwise you wouldn't have time to read the messages the assembler outputs.


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 5:57 am 
Offline

Joined: Tue Oct 09, 2018 8:31 am
Posts: 8
Ok I've done that and a .o file has appeared, is there anything else I need to do?


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 7:32 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2308
Location: DIGDUG
Make a linker file. Usually called something like NROM.cfg. Run the linker, something like this.

ld65 -C nrom.cfg -o %name%.nes file1.o file2.o file3.o

replace %name% with the final filename.

Here's a cfg file I use.
https://github.com/nesdoug/01_Hello/blo ... k_vert.cfg

but you will probably want to edit it to your needs.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 7:43 am 
Offline

Joined: Tue Oct 09, 2018 8:31 am
Posts: 8
I'm confused, can you explain that a little slower, and tell me what I should make and where to put it. I'm relatively new to programming and IT, so this is still a bit confusing for me


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 7:53 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2308
Location: DIGDUG
So, the object file has the machine code and a bunch of metadata, but it hasn't arranged all the peices together yet in a way that the NES emulator can read it.

For example, the emulator expects the header to come first, then the code, then the graphics.

Also, you might have multiple source files, which can turn into multiple object files. The linker will peice it all together and resolve any external references, and such.

The cfg file is like a recipe for how to organize the segments into a final file.

The -C directive tells the linker which file is the cfg file.

The -o directive tells the linker what to name the output file.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 9:56 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10906
Location: Rio de Janeiro - Brazil
It's worth noting that ca65 is more complicated to use than other popular assemblers. If you were using NESASM or ASM6, just the one command ("nesasm source.asm" or "asm6 source.asm") would already spit out a working ROM file (provided there were no errors in source.asm, of course) ready to be used in emulators or flash cartridges. Unfortunately, ca65 is more complicated than that.

When you assemble with ca65, it spits out an object (.o) file, which contains assembled code that hasn't yet been assigned an address. To finish the job you need to link one or more object files using ld65 (another tool in the cc65 package) and a configuration file, which specifies the structure of the final ROM file and where all the segments go in that file.

Configuration files for ld65 are way too complex for me to cover in a forum post (if you're really interested you can read the official documentation). Several things have an impact on the structure of a config file, such as the mapper being used, the number of banks you have, how you declare your variables... If you're not already using someone else's configuration file (like from a tutorial or example code), you may be better off starting with a simpler assembler, such as NESASM or ASM6.


Top
 Profile  
 
 Post subject: Re: CC65 Won't boot
PostPosted: Sat Oct 13, 2018 10:26 am 
Offline
Formerly ~J-@D!~
User avatar

Joined: Sun Mar 12, 2006 12:36 am
Posts: 472
Location: Rive nord de Montréal
... you can use cl65 to assemble and link in one step however. That doesn't save you of making a working linker script though.

_________________
((λ (x) (x x)) (λ (x) (x x)))


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: kikutano and 1 guest


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