CC65 Won't boot

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
CC65 Won't boot
by on (#189377)
I try to click on the cc65 icon, and i get a black window for a few seconds, and then it vanishes. I'm using a Windows 10 PC, does anyone know how I could fix this? Thanks!
Re: CC65 Won't boot
by on (#189379)
It's a command line tool?
Re: CC65 Won't boot
by on (#189380)
I don't know, it won't boot so I'm not able to see what the interface looks like.
Re: CC65 Won't boot
by on (#189384)
It doesn't have a GUI. It's a command line tool. Open a console (Windows+R, type cmd, press ENTER) to use it. You can read the documentation on how to setup some required system variables.
Re: CC65 Won't boot
by on (#189387)
Command line tools don't have a graphical interface, you have to call them through the command line, passing the necessary parameters for the program to do what it needs to. What we normally do in these cases is create a batch file (.BAT) in the same folder as the project containing all the commands necessary to run the compiler/assembler, so you can just double click that file every time you have to build.
Re: CC65 Won't boot
by on (#189388)
How many concepts in Before the basics are you familiar with, particularly under the "Command-line interface" heading?
Re: CC65 Won't boot
by on (#189401)
tepples wrote:
How many concepts in Before the basics are you familiar with, particularly under the "Command-line interface" heading?

I understand most of that stuff.
Re: CC65 Won't boot
by on (#189726)
Never mind, I was actually supposed to use CA65, And I think I've just about got it figured out. I'll reply if it doesn't work.
Re: CC65 Won't boot
by on (#189729)
Also command line.

What example files / tutorial are you working from? Tepples perhaps?

Do you know how to set up a .cfg file for NROM size NES ROM, or how to include a header?

EDIT, also, ca65 doesn't (by itself) assemble to an executable. It assembles to an object file. And ld65 links the object file(s) to an executable (using a cfg file as a map). It is not the easiest for a newb, and please ask questions, you will have lots of them.
Re: CC65 Won't boot
by on (#189746)
Okay, I was able to boot up the app, but I wasn't able load the file. I've tried moving the file into the same folder as the exe, I've tried giving it the directory, but I always got the same error, it couldn't open the file. Does it have something to do with the file type? I'm using a .asm file, will that not work? What type of file will work?
Re: CC65 Won't boot
by on (#189749)
What do you mean by "couldn't open the file"? Is there an error message? Do you just get a black window that appears and disappears?
Re: CC65 Won't boot
by on (#189758)
Let's try the lowest level experiment. Make a text file, in the same folder as ca65.exe with these contents...

Code:
.segment "CODE"

   lda #1
   sta $1


from the window explorer, click "File/Open Command Prompt"

type "ca65 filename.txt" (replace filename with actual filename, of course)

it should generate a .o file in the same directory. The file itself will look like gibberish, that's normal, this is just a simple test to confirm to you that it does work. If it generates a .o file, with no errors, this is a successful test.

If you get an error, print the entire error message here, so we know what you are talking about.
Re: CC65 Won't boot
by on (#189761)
Is the .o file a hexdump? What is it for?
Re: CC65 Won't boot
by on (#189763)
Right now, it represents proof that your copy of the assembler is working. Once you get some actual code written, it represents the assembled object code corresponding to one of the source code files in your project, to be combined or "linked" with object code produced by assembling other source code files in order to form a ROM image.
Re: CC65 Won't boot
by on (#227394)
ive been getting the same problem, but when I do the tasks said above, I just get the line
'"ca65 filename.txt"' is not recognized as an internal or external command,
operable program or batch file.
can anyone help??
Re: CC65 Won't boot
by on (#227397)
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).
Re: CC65 Won't boot
by on (#227399)
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".
Re: CC65 Won't boot
by on (#227429)
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?
Re: CC65 Won't boot
by on (#227430)
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.
Re: CC65 Won't boot
by on (#227431)
how do I do that?
Re: CC65 Won't boot
by on (#227432)
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.
Re: CC65 Won't boot
by on (#227437)
Ok I've done that and a .o file has appeared, is there anything else I need to do?
Re: CC65 Won't boot
by on (#227442)
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.
Re: CC65 Won't boot
by on (#227443)
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
Re: CC65 Won't boot
by on (#227444)
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.
Re: CC65 Won't boot
by on (#227452)
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.
Re: CC65 Won't boot
by on (#227453)
... you can use cl65 to assemble and link in one step however. That doesn't save you of making a working linker script though.