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

CC65 compiler

CC65 compiler
by on (#202713)
Hello friends I am new here and am wanting to learn to program for Nes, I would like to know how the compiler CC65 installation that will install the rom, because every time I try to start programming for Nes I stop these compilers where I have no idea how to install and get him to do the Assembly of rom, if you can help me I would be grateful ... ....

If it's not too much trouble I'd like a video lesson teaching how to install because it would be much easier to understand, I thank you.
Re: CC65 compiler
by on (#202718)
Are you having trouble "installing" the cc65 suite, or running the .exe files?

If the 2nd, describe the error message you get. Did a black box appear and disappear when you clicked on it?
Re: CC65 compiler
by on (#202721)
To set it up, you simply extract it to c:\cc65 (or wherever you want it).

in that folder, keep your projects in separate folders. My projects always begin with a _ so they will appear first when name-sorted.

In a project folder, you'll need a batch file (out of convenience) and a config file (out of necessity). The batch file can be as simple as it gets.

One of mine looks like this:
Code:
ca65 -t nes -l list.lst -g src/dungeon.asm -o dungeon.o
ld65 -C src/dungeon.cfg dungeon.o -o dungeon.nes
pause


When running the batch file (in my case named _makefile.bat) ca65 -the assembler- will output an object file. ld65 -the linker- will take that object file and link it according to the config file into a playable rom (name its extention .nes for emulator recognition, .bin otherwise)

the config file is needed to tell the linker how to link objects. This differs from platform to platform (like apple II, c64, nes), and for the nes, the config will differ from mapper to mapper. The ld65 reference has useful tips on how to construct one, and dougeff recently made a whole bunch of tutorial templates. Note that they're made with using neslib in mind, so you can cut some parts out at will if you don't use neslib.

the ld65 and ca65 references will allso give you a full list of command line options to put in your batch file.
Re: CC65 compiler
by on (#202730)
dougeff wrote:
Are you having trouble "installing" the cc65 suite, or running the .exe files?

If the 2nd, describe the error message you get. Did a black box appear and disappear when you clicked on it?


I don't know where to start, let me explain ... ....

Where I write the code?

How to turn this code into something executable on the emulator?

I need something very detailed, from how to install cc65 to time to transform the code into a rom do you understand?

I'm a beginner at this and I'm a little lost, I've always wanted to learn more unfortunately never get something very detailed, if they can help me I appreciate it.
Re: CC65 compiler
by on (#202731)
You can write the code in anything that can produce a text format file. Even microsoft notepad. But your code will be more readable in something like notepad++, keep track of line numbers in your code, notify you when there has been changes to opened files, etc etc... lots of useful perks.

Once you have your code (name it code.txt or main.asm or whatever, the extention doesn't matter - it's just for keeping apples from pears for your own convenience), you must use either the command line of your OS* or write a batch file which does the same for you. This is to make the cc65 suite produce a ROM for you.

Have you used the command prompt or made a batch file before?

*On windows 8.1 to 10, you can conveniently open the command prompt three ways
1) win key+r, "cmd.exe", enter key. This works regardless language/localization.
2) win key+x, c key
3) win key+x, a key (same but with administrative privileges)


As a side note, using asm6 is a lot simpler, because you can simply drag and drop your main code file to asm6.ex icon and it will produce a ROM. But you'll eventually need to learn the other stuff anyway.
Re: CC65 compiler
by on (#202733)
FrankenGraphics wrote:
You can write the code in anything that can produce a text format file. Even microsoft notepad. But your code will be more readable in something like notepad++, keep track of line numbers in your code, notify you when there has been changes to opened files, etc etc... lots of useful perks.

Once you have your code (name it code.txt or main.asm or whatever, the extention doesn't matter - it's just for keeping apples from pears for your own convenience), you must use either the command line of your OS* or write a batch file which does the same for you. This is to make the cc65 suite produce a ROM for you.

Have you used the command prompt or made a batch file before?

*On windows 8.1 to 10, you can conveniently open the command prompt three ways
1) win key+r, "cmd.exe", enter key. This works regardless language/localization.
2) win key+x, c key
3) win key+x, a key (same but with administrative privileges)


As a side note, using asm6 is a lot simpler, because you can simply drag and drop your main code file to asm6.ex icon and it will produce a ROM. But you'll eventually need to learn the other stuff anyway.


If it wasn't too much to ask, I'd like you to make a video showing all the steps with the part that you create the rom, as I believe that a lot of people who want to learn this part, keeps "Nes that would not only help me as a lot of people too.
Re: CC65 compiler
by on (#202734)
I haven't seen any video tutorials, but if you can read English, Dougef's blog seems to explain what you need to learn to make your first NES ROM in CC65, and more. And if assembly is fine instead of C, I recommend the Nerdy Nights tutorial. It does teach some bad things, but other than that it is a very good tutorial for beginners of NES and/or 6502. That's where I started.
Re: CC65 compiler
by on (#202735)
Someone once asked me if I could demonstrate programming a NES game, like live in front of an audience. I laughed. Ok, if an audience is willing to watch me sit and type quietly for 12-14 hours, I could bang together a very simple Super Mario Bros style scroller.

The joke being, of course, it takes way too much time to do even a simple game. It would be painfully boring to watch.
Re: CC65 compiler
by on (#202740)
Won't record a movie, but this is my best attempt at a complete walkthrough.

1) Download the latest cc65 suite from here: https://cc65.github.io/cc65/getting-started.html
2) Extract it to c:\cc65
3) In c:\cc65, create a new folder. Name it "_MyFirstProject"
4) Open that folder. And open notepad. Write this:
Code:
ca65 -t nes -l mylist.lst src/mycode.asm -o myobjectfile.o
ld65 -C src/NROM.cfg myobjectfile.o -o mynesrom.nes
Pause

And save it as "_makefile.bat" in the project folder you just created. We'll get to what that did in a bit. For now, let's do a couple more things:
5) Within your project folder, create a new one called src. This is where we'll keep sourcecode and assets and configs. Open it.
6) Download dougeff's config zip and place one of the configs in it named something with "nrom" there. It doesn't matter which one at this point, but rename it to NROM.cfg for the sake of this walkthrough.
7) Make a new text file, let's call it mycode.asm.
8) Write some lines of code in it (since we're using dougeffs configs, a tip is following the same tutorials) and save.
9) So, with all that done, let's try it. Double click your batch file to make it run ca65 and ld65.
You should now have a NES binary file called mynesrom.nes. Congratulations!

Allright, let's get back to what the batch file did.

The batch file (.bat) is a way of automating using the command line tool, which you otherwise would use each time you'd assemble source code into a binary file (what one might offhandedly call a ROM, after the .rom file extension), using ca65*. We're not there yet, though, just preparing.

Let me step through what that batch file will do once you run it (you'll eventually do so by double clicking on it)
First line:
ca65 | this tells windows to run ca65; the assembler. Windows should know where it's at, so we don't need to specify the whole path.
-t nes | this is our first "command line option" - optional instructions which tells ca65 what to do. -t sets the target platform to nes. This isn't necessary to specify, but is handy: the right processor is chosen and so we will get notified if we try to use opcodes it can't accept. There's more to it if you'd program for, say, the commodore 64, but let's not get into that.
-l mylist.lst | this tells ca65 to create a listing of its output. It's not necessary either, but viewing the .lst file in a text or code editor might reveal things when you're analysing your resulting program and its machine language strings can be used for finding stuff in a hex editor. We won't get deeper into that now either.
src/mycode.asm | this will tell the assembler what file to assemble. The src\ part indicates that we have a folder named src in which the code should be.
-o myobjectfile.o | This tells ca65 that the assembled output file (called an object file) will be named myobjectfile.o - if we don't include it, it will default to the filename of your source code file but have the extension .o instead of what your source had.

Allright, so with that line run, the assember has made an object file. It's now the job of the linker to link together object files. Since we only have one for now, the linker will simply take that object file and output it as a nes file. But we need to instruct it to do so, of course. So here's line two:

ld65 | This will start the linker. Let's tell it what to do.
-C src/NROM.cfg | Use the config file named NROM.cfg
myobjectfile.o | Convert this object file according to specs found in NROM.cfg
-o mynesrom.nes | into an output we name mynesrom.nes.

Line three:
Pause | This is so the command prompt window doesn't close after execution. This way we can review what it had to say - were there any warnings, errors, or did we succeed? The pause is entirely optional, but is handy.

DONE!
You now know how to make .nes files using batch files and the cc65 suite. If you instead want to use the command line, you simply use the win-r hotkey, write "cmd.exe", hit enter, and then enter the same lines you wrote in the batch files (not "pause". that one is redundant here).

*ca65 and ld65 are two tools in the cc65 toolchain. ca is the assembler, ld is the linker. Both are needed to make a nes rom using assembly language.
Re: CC65 compiler
by on (#202741)
dougeff wrote:
Someone once asked me if I could demonstrate programming a NES game, like live in front of an audience. I laughed. Ok, if an audience is willing to watch me sit and type quietly for 12-14 hours, I could bang together a very simple Super Mario Bros style scroller.

The joke being, of course, it takes way too much time to do even a simple game. It would be painfully boring to watch.

Yeah some things are best explained by showing, and programming isn't one of them. Video tutorials are slow, if you loose concentration for an instance or try to fast-forward a little, you easily miss what the teacher is doing and won't be able to follow anymore, you are forced to rewind and watch the part again. Another bad thing is if you quit in the middle of the video it's a pain to find where you where last time, or if you need to review an old part of the tutorial you have to search in the video search-bar, it's almost impossible to get to a point where the context makes sense without watching it all over again. Also you can't glean through the video like with text when searching it.
Everything takes like ten times the time than learning from text and pictures that you can study in your own pace. Certain parts of a tutorial might be better shown in short video clips, but definitely not punching code.
Re: CC65 compiler
by on (#202743)
Before you try to program for the NES, you should learn about basic computer-related things, like the command line prompt because it looks like you don't know about it yet.

Also, you should research what a compiler is and what it does.

And I don't understand why you insist on getting a video tutorial. If you want to become a programmer, you should be able to gather information in text form. Not everything will be presented to you in the form of a video.

But in the moment, this point is moot anyway. You won't get very far with NES programming if you seriously have to ask for a video tutorial on setting up a simple compiler from a zip file. That's like trying to write a novel without even being able to read.
Even if you follow the instructions that the other users listed for you, you will most likely be stuck by the next step. And the next step afterwards. And so on.

Before bothering with NES programming at all, it's mandatory that you have basic computer knowledge. For a start, research what the windows command line prompt is and what a compiler is used for.

Also, for starting programming, you should use something different than the NES. The NES is very specific.
Since you don't even seem to know how to program at all (otherwise you wouldn't ask where to enter the source code), I'd suggest to start with a C, C++ or C# tutorial for Windows (at least the first few chapters) where you write simple text-based applications, so that you first learn about the concept of programming before you get to the highly hardware-specific NES.

Please don't let this discourage you. But I think if somebody wants to start with something, he should start at the beginning. Programming the NES is advanced stuff. Don't do this unless you know what a Win32 console application is and you can create one yourself from a source code file.
Re: CC65 compiler
by on (#202744)
This list of articles should help bring you up to speed on basic computer science concepts.

@DRW
Should someone really have to download and install multiple gigabytes of Visual Studio just to prove he can create a Windows console app? I can see how it'd be helpful if someone wants to program the NES in C, not so much assembly language, as all my asset conversion tools are in Python. I know MinGW (GCC for Windows) exists, but not being a regular user of MinGW, I can't walk you through installing it.
Re: CC65 compiler
by on (#202746)
tepples wrote:
Should someone really have to download and install multiple gigabytes of Visual Studio just to prove he can create a Windows console app?

It's not about "proving" anything, it's a help for him. If he prefers to start with a highly specific console like the NES, despite not even knowing what the Windows console is, it's his decision, but I doubt that he'll get very far.

And you don't need to install a whole Visual Studio. There is Code::Blocks. Or he can use Turbo C++ 1.01 which was released as freeware by Borland.

tepples wrote:
I can see how it'd be helpful if someone wants to program the NES in C, not so much assembly language

The programming language is secondary in this case (unless he actually plans to use the C compiler of cc65). It's about getting a grip of how programming works in general since he asked stuff like "Where do I enter the code?" I could also have said that he should get QBasic for a start, but I hate the BASIC programming language, that's why I suggested C-like languages.
Re: CC65 compiler
by on (#202760)
DRW wrote:
I could also have said that he should get QBasic for a start, but I hate the BASIC programming language, that's why I suggested C-like languages.

I would allow for the different way different brains think. I've used several different versions of BASIC, from toy (Timex Sinclair ZX-81, IIRC) to professional instrumentation BASICs (from Hewlett-Packard); and although I'm not crazy about BASIC, it was much easier for me than C. I cannot get my brain around C. To me, it's an absolute disaster of a language that never should have hit the streets. I do great at Forth and RPN though, and at assembly (particularly if I can use macros to raise the level of the language a lot). A friend said, "You have an RPN brain."
Re: CC65 compiler
by on (#202762)
There really isn't one "beginning" when it comes to programming. I've seen people start with something like assembly and work their way up, start with something very abstract like Haskell and work their way down... There's many ways to do it.

In general, I don't think saying "instead of doing this thing you're interested in, you have to do all this other stuff you're not interested in first" tends to work very well. All they really need to know here is how to get started; I imagine they don't because tutorials tend to assume some level of familiarity with the command line already and thus don't cover the subject, but it's honestly pretty orthogonal to the subject of NES programming itself. They might have an easier time once they're actually dealing with things documented by the wiki, so I don't think it's worthwhile to assume they'll be stuck by everything.

(It's also worth noting that not being familiar with the command line does not immediately imply never having programmed before. A number of languages have IDEs or built-in editors; Python is one notable example.)
Re: CC65 compiler
by on (#202764)
This. You could begin with BASIC, C#, python, 6502 assembly language, z80 assembly, NES specific 6502 assembly... either way, you'll learn something.

Something as literal as assembly language might actually be easier to understand than a very high level language. There's little or no hiding what the code actually does.

Learning how to use the command line is super useful and most likely necessary at some point, but you *can* assemble a nes program without it, for example using asm6.exe's drag and drop feature.
Re: CC65 compiler
by on (#202770)
DRW wrote:
Before you try to program for the NES, you should learn about basic computer-related things, like the command line prompt because it looks like you don't know about it yet.

Also, you should research what a compiler is and what it does.

And I don't understand why you insist on getting a video tutorial. If you want to become a programmer, you should be able to gather information in text form. Not everything will be presented to you in the form of a video.

But in the moment, this point is moot anyway. You won't get very far with NES programming if you seriously have to ask for a video tutorial on setting up a simple compiler from a zip file. That's like trying to write a novel without even being able to read.
Even if you follow the instructions that the other users listed for you, you will most likely be stuck by the next step. And the next step afterwards. And so on.

Before bothering with NES programming at all, it's mandatory that you have basic computer knowledge. For a start, research what the windows command line prompt is and what a compiler is used for.

Also, for starting programming, you should use something different than the NES. The NES is very specific.
Since you don't even seem to know how to program at all (otherwise you wouldn't ask where to enter the source code), I'd suggest to start with a C, C++ or C# tutorial for Windows (at least the first few chapters) where you write simple text-based applications, so that you first learn about the concept of programming before you get to the highly hardware-specific NES.

Please don't let this discourage you. But I think if somebody wants to start with something, he should start at the beginning. Programming the NES is advanced stuff. Don't do this unless you know what a Win32 console application is and you can create one yourself from a source code file.


Friend, you kind of jumped to conclusions about me, I know what is the command prompt as well as have notions of informatica and also already programmed some things just never programmed anything for old consoles and I would just like to know how to make a rom, a video class would be enough for the rest I am able to learn from research ...
Re: CC65 compiler
by on (#202771)
And just to be perfectly clear, noone needs to learn how to write a win32 program prior to writing a nes or c64 program, even if prior experience will be useful.

Deterring someone by presenting requirements has a tendency to function as gatekeeping, even if the intention is to be helpful.
Re: CC65 compiler
by on (#202772)
Vedita, are you brazilian by any chance? Judging by your username and the way you write, it looks to me like you speak portuguese.
Re: CC65 compiler
by on (#202796)
It sounds like you are more than capable of following the instructions of the linked tutorials or FrankenGraphic's post.
I doubt that anyone here is going to bother recording a video tutorial about typing text in a text editor and running it through a compiler or assembler.
If you are using windows I'd recommend Notepad++ as your text editor, that's what I've been using anyway.

If there's something in particular you don't understand you can post and ask about it on this forum.
Re: CC65 compiler
by on (#202829)
Garth wrote:
and although I'm not crazy about BASIC, it was much easier for me than C. I cannot get my brain around C. To me, it's an absolute disaster of a language that never should have hit the streets.

Just out of curiosity: What do you dislike so much about C?

Nicole wrote:
In general, I don't think saying "instead of doing this thing you're interested in, you have to do all this other stuff you're not interested in first" tends to work very well.
FrankenGraphics wrote:
And just to be perfectly clear, noone needs to learn how to write a win32 program prior to writing a nes or c64 program, even if prior experience will be useful.

I suggested this because on the NES, it takes longer until you actually see anything useful on the screen. If he already has programming experience, that's fine. If he doesn't, I think this:
Code:
for (int i = 1; i <= 10; ++i)
    cout << i * 9 << "\n";

is a better start for getting some quick first results than this:
Code:
   SEI
   CLD
   LDX #$40
   STX ApuFrameCounter
   LDX #$FF
   TXS
   INX
   STX PpuCtrl
   STX PpuMask
   STX DmcFreq


Remember? Wax on, wax off.

vedita wrote:
I know what is the command prompt as well as have notions of informatica and also already programmed some things

If you know the command prompt, then that's even better. I assumed you didn't because you had problems running the cc65 compiler. Which is literally just a zip file that contains a bunch of command line tools like "cc65.exe" or "cl65.exe". If you know about the command line, starting these programs should be pretty simple. cc65 even has a step by step documentation included.

vedita wrote:
just never programmed anything for old consoles and I would just like to know how to make a rom, a video class would be enough for the rest I am able to learn from research ...

I still don't understand why you insist on a video.

If you already know how to program, read this:
http://cc65.github.io/doc/intro.html#ss1.1

Then read one of the NES-specific tutorials. If you need a video to understand it and cannot learn from text, you won't understand the rest either.
Re: CC65 compiler
by on (#202895)
DRW wrote:
Before you try to program for the NES, you should learn about basic computer-related things, like the command line prompt because it looks like you don't know about it yet.

Also, you should research what a compiler is and what it does.

And I don't understand why you insist on getting a video tutorial. If you want to become a programmer, you should be able to gather information in text form. Not everything will be presented to you in the form of a video.

But in the moment, this point is moot anyway. You won't get very far with NES programming if you seriously have to ask for a video tutorial on setting up a simple compiler from a zip file. That's like trying to write a novel without even being able to read.
Even if you follow the instructions that the other users listed for you, you will most likely be stuck by the next step. And the next step afterwards. And so on.

Before bothering with NES programming at all, it's mandatory that you have basic computer knowledge. For a start, research what the windows command line prompt is and what a compiler is used for.

Also, for starting programming, you should use something different than the NES. The NES is very specific.
Since you don't even seem to know how to program at all (otherwise you wouldn't ask where to enter the source code), I'd suggest to start with a C, C++ or C# tutorial for Windows (at least the first few chapters) where you write simple text-based applications, so that you first learn about the concept of programming before you get to the highly hardware-specific NES.

Please don't let this discourage you. But I think if somebody wants to start with something, he should start at the beginning. Programming the NES is advanced stuff. Don't do this unless you know what a Win32 console application is and you can create one yourself from a source code file.

+1
If you can't even learn on your own without a video, you can forget about NES programming immediately. However doing a Win32 application is not a necessary step for coding on the NES, but it'll help in developing your own tools when a specific tool is lacking in what already exist. For example I had to use my own tool to compress my levels in my game.

Quote:
Just out of curiosity: What do you dislike so much about C?

Can't speak for him, but there's plenty of things I dislike about C. Making an explicit list wouldn't be terribly useful, as you can probably get a lot of C langauge critisism by searching the internet. However my major gripes are :
  • The necessary of ; to terminate statements
  • The abundance of symbols like { } [ ] which are easy to reach on an american keyboard but hard and annoying to reach on a german-style keyboard like we have here
  • The necessity to either declare function in headers before you use them or have them in a specific, un-intuitive "declare-before-use" order
  • Case sensitive labels/variables
  • The type system is retarded, the size of an int is unknown cannonically so you have to use weird crap using SIZEOF. Yes in "modern" C we can use types like uint16_t and know their size but they don't come naturally.
  • The way pointers/arrays are declared and used is FUCKING RETARDED
  • C-strings impose a format of zero-terminated strings when you would want to use otherwise (for example, $ff terminated or having the length as a header)
  • Inability to call arguments by value (bad)
  • The confusion between = and == symbols is constantly annoying
  • Memory management is a headache
  • The "*" symbol can mean 3 different thing, the "const" keyword is annoying and the "static" keyword can have 3 completely different meanings, all of them very poorly described by the word "static".

None of this prevents me to use C and write C programs, but that doesn't change I do not like the language very much.
Actually while writing a program in both assembly or C is not particularly hard per se, I find understanding C code I wrote 5 years ago again typically much harder than assembly code I wrote 5 years ago, ironically. But this depends on a case-per-case basis.
Re: CC65 compiler
by on (#202918)
Bregalad wrote:
  • The abundance of symbols like { } [ ] which are easy to reach on an american keyboard but hard and annoying to reach on a german-style keyboard like we have here

I couldn't agree more. Since these are symbols that are normally never used in Swedish writings, they are placed so they require the AltGr key to be held instead of shift. But in programming they are used all the time, which gets really tiresome. Same goes for other symbols that requires AltGr including @, $, £, \, ~ and |, but they are not used as often as {[]} so they are usually fine. The exception is $ which is used all the time in 6502 assembly as hexadecimal notation. I'm just glad that semicolon (also never used in Swedish writings) is easy to type, it only requires holding shift. But GNU ARM assembler apparently uses @ for comments, what a nightmare!!
Re: CC65 compiler
by on (#202919)
Pokun wrote:
I couldn't agree more. Since these are symbols that are normally never used in Swedish writings, they are placed so they require the AltGr key to be held instead of shift. But in programming they are used all the time, which gets really tiresome. Same goes for other symbols that requires AltGr including @, $, £, \, ~ and |, but they are not used as often as {[]} so they are usually fine. The exception is $ which is used all the time in 6502 assembly as hexadecimal notation. I'm just glad that semicolon (also never used in Swedish writings) is easy to type, it only requires holding shift. But GNU ARM assembler apparently uses @ for comments, what a nightmare!!

Well here the '$' is accessible directly without needing neither shift nor AltGr keys. I guess we're lucky. '@' is relatively easy to access because we can use AltGr with our right hand wile typing '2' with our left hand. However the []{} needs to type both AltGr and the corresponding key with the right hand, which is very tiresome.

Actually I'm seriously considering switching to Pascal or Python language as a "default" programming language JUST to get rids of the brackets.
Re: CC65 compiler
by on (#202920)
I've found the "rites of passage" attitude pretty unhelpful in other forums. Development should be as easy a possible for beginners. let them tackle assembly and archaic command line fiddling later.

I'd suggest checking out NESICIDE which is a pre-configured C IDE for NES development.
https://sites.google.com/site/nesicideproject/

I'd compile some of the examples on the NESICIDE web page to get the hang of things.
Re: CC65 compiler
by on (#202948)
Bregalad wrote:
Actually I'm seriously considering switching to Pascal or Python language as a "default" programming language JUST to get rids of the brackets.

C does have two alternatives built in. The first is trigraph and digraph alternatives to those as part of the language standard, e.g. ??< (trigraph) and <% (digraph) both have the same meaning as {, but also #define would let you pick a symbol of your choice to replace it. Most compilers these days (including CC65) seem very tolerant of unicode as well.

e.g.
Code:
#define « {
#define » }

void test()
«
   for (int x=0; x<25; ++x)
   «
      x = x;
   »
   return;
»
Re: CC65 compiler
by on (#202963)
DRW wrote:
I still don't understand why you insist on a video.

I think I figured it out when I read this:
In this post, NovaSquirrel wrote:
TeMaToS wrote:
Oh, grate. But how to compile this game? Can you tell me that please?

With ca65 and ld65 on the path, run mk.bat

It caused me to remember my experience collaborating with teammates on The Curse of Possum Hollow. The most confusing thing about setting up any toolchain on Windows is PATH configuration, as the steps seem to change with every Windows version. It needed Skype screen sharing when I walked people through it the last couple times. So setting up PATH might be the one step that needs a video.
Re: CC65 compiler
by on (#202965)
tepples wrote:
So setting up PATH might be the one step that needs a video.

I can make it short:

Put your compiler commands into a .bat file and add the following to the file:
path=%path%;C:\cc65\bin
(or whatever other path you want to put your compiler).

No need to fiddle with the Windows path options somewhere in the system configuration.
Re: CC65 compiler
by on (#202968)
Yeah that one is indeed confusing and Microsoft loves changing these things.

Personally I often just throw the assembler and linker (or other command-line program) in the same directory as the bat file so I don't have to setup PATH on every single computer with every single command-line program I happen to be using at the moment. They are often so small that it doesn't make much of a difference.
Re: CC65 compiler
by on (#202969)
I just put a copy of cc65 in a cc65 folder at the same level as each project, and then my command lines are just relative like cc65/bin/cc65 etc.

There are only a few cases where I'm happy at all with using a global PATH. Especially not with programming, where projects can have varying age, dependent on different versions of tools and libraries, etc. I want that all relative whenever it's practical to do so.

cc65 is small, there's no harm in having multiple copies around.

Edit: Sorry for redundancy, was typing at the same time as Pokun.
Re: CC65 compiler
by on (#202979)
rainwarrior wrote:
I just put a copy of cc65 in a cc65 folder at the same level as each project, and then my command lines are just relative like cc65/bin/cc65 etc.
[...]
cc65 is small, there's no harm in having multiple copies around.

Can't you do it linux-style and use shortuts instead ? The equivalent of PATH is to have a shortcut in /usr/bin pointing to the actual program - sometimes to another shortcut and so on.
Re: CC65 compiler
by on (#202980)
That's not really functionally different than a global PATH though. My objection is to the globalness of it. If I have an old project, I want to keep using the version of CC65 it started with, I don't want a new global version potentially breaking old code.
Re: CC65 compiler
by on (#203004)
How to add something to the PATH on every version of Windows and DOS since 3.0

SET PATH=%PATH%;<new thing here>

Or if you want to do it via a gui since Win95

System >> Advanced System Settings >> click on Environment Variables button on the first pane. This is the same dialog in Windows 10 as in XP ;) if you are on 98/95 you might need to hunt for it...

Personally I just added one folder PathStuff to it and I just put what I want on the path into it, saves the hassle each time.

If you want to program get a US keyboard. If you want to do 6502 get a UK keyboard ;) Or just switch the keyboard layouts in windows (LAlt+shift by default but you can change it ) and learn the US or UK layout for your keyboard. :D
Also in English we never use {} [] or # @ < > either, nor ~ or really care about ' vs ` and ^ is something you do with a pen and not something you ever type because when you need to make a correction you just delete and type it again ;) and I'm not even sure what one uses | for in a normal context.
Re: CC65 compiler
by on (#203013)
I guess those characters aren't used more than in Swedish after all (except £, $ and semicolon of course). I guess when Swedish layout was standardized they just felt that those symbols are less important and because they needed room for the three additional letters ÅÄÖ they moved {[]} to the AltGr row of the number keys (but they also moved around a bunch of other keys for some reason).
American keyboards doesn't seem to use AltGr at all, it's just a secondary Alt key. UK keyboards looks like they have the same key layout as Swedish keyboards. Just the labels on the keys are different.

I'm already using Japanese keyboard layout in Windows a lot (since it's the most practical way to type Japanese) and in alphanumeric input mode, Japanese keyboard layout is pretty much the same as the English ones and I pretty much memorized the keys for that. So why don't I just use that? Because switching keyboard layout back and forth isn't really less troublesome than using AltGr.
Also getting a foreign keyboard would just introduce more problems than it would solve.
Re: CC65 compiler
by on (#203014)
[] are used in quoting to insert editorial notes. It is especially used by journalists, in academia, and by private sector researchers.

-To clarify something which got lost out of context:
"Due to extensive cat cuddling, it [the construction of a warehouse] will be delayed", says a representative of the company.

-To cut out clauses
"[...] it will be delayed", says a representative

This is especially versatile when you want to declare that the whole sentence hasn't been reproduced. In papers, you'd use this a lot when quoting others' research.

-To assure the reader that a spelling or expression or choice of words is reproduced as is, and not a mistake:
"Due to extensive bat [sic] cuddling, it will be delayed".

In dictionaries, they're used for declaring the start and end of phonetic script, but i now see that oxfords' online dictionary is using / / instead.

| is a separator. You can for example use it in a document header/footnote like so:
name | phone | p.o. box

In dictionaries, it is used to separe base word from endings.
which/how in russian (latin transcript): kak|óy, -aya, -óye, -ye.


----
The worst decision they made on swedish keyboard layouts is that they mapped ¤ to shift+4 where $ should be. This might very well be the first time i've used ¤ for something.
Re: CC65 compiler
by on (#203015)
Those are all what I'd call technical usage, rather than "normal" text though.
In phonology // and [] are both used for pronunciation, but I'm not really sure what's different between their usage.

Quote:
The worst decision they made on swedish keyboard layouts is that they mapped ¤ to shift+4 where $ should be. This might very well be the first time i've used ¤ for something.

Haha agreed! I always thought it was so useless so I googled it. Apparently it's used in economy as a currency sign as a replacement when a certain currency sign isn't available. I don't think I've ever seen it being used though. I kind of wished it was possible to make a dollar sign appear instead of it when programming.
According to Swedish Wikipedia it seems it was used instead of the dollar sign in BASIC of the Swedish computer ABC 80.
Re: CC65 compiler
by on (#203018)
Hm, maybe ¤ was used a bit more in business or stock trading programs when there was both a 256 character limit and limited screen space.

I remember abc 80 / 800, primarily because those was the first programming manuals i ever read (ABC BASIC). I didn't have access to one such computer, though. Did you know Ericsson made computers and even laptops? They had stylish but presumably(?) eye troubling monochrome screens in red phosphor.

As for a somewhat more casual example of using |, i used it quite a lot on the previous page in this very thread. :lol:
Re: CC65 compiler
by on (#203025)
Oziphantom wrote:
System >> Advanced System Settings >> click on Environment Variables button on the first pane. This is the same dialog in Windows 10 as in XP ;) if you are on 98/95 you might need to hunt for it...


Except Windows 10 changed it: it's no longer semicolon separated but instead allows choosing individual folders.

Quote:
Personally I just added one folder PathStuff to it and I just put what I want on the path into it, saves the hassle each time.

Analogous to what I do on Linux in ~/.local/bin.

Quote:
Also in English we never use {} [] or # @ < > either

Until you're writing a blog, forum, or wiki contribution. HTML, BBCode, MediaWiki, and Markdown use those characters precisely because English itself does not, except for square brackets to indicate that a quotation has been altered.

The difference between /x/ and [x] in phonology is that /x/ represents a phonemic transcription and [x] a phonetic one. A phoneme is a set of sounds considered equivalent in speech. A phonemic transcription uses one symbol for each phoneme; a phonetic transcription specifies which particular sound is used in each case.
Re: CC65 compiler
by on (#206547)
slobu wrote:
I'd suggest checking out NESICIDE which is a pre-configured C IDE for NES development.
https://sites.google.com/site/nesicideproject/

I'd compile some of the examples on the NESICIDE web page to get the hang of things.

I'm not maintaining [and should remove, I suppose] the NESICIDE distributions at this site.
I'm ultimately going to host them on my own server:
https://knob.phreneticappsllc.com/nesicide/
Re: CC65 compiler
by on (#206556)
If you're maintaining the issues on GitHub, could you maintain the releases on GitHub as well?
Re: CC65 compiler
by on (#206712)
tepples wrote:
If you're maintaining the issues on GitHub, could you maintain the releases on GitHub as well?

I could do it manually, I guess. But I'd prefer to have it be automated and in order to do that I need some way to log in to github without having to commit my login credentials. :roll: At least, that is my understanding of reading through their REST API.
Re: CC65 compiler
by on (#206731)
I think the idea is that you'd key in your login credentials the same way you key them in when you git push. Or you'd store them in an environment variable.
Re: CC65 compiler
by on (#206734)
tepples wrote:
I think the idea is that you'd key in your login credentials the same way you key them in when you git push. Or you'd store them in an environment variable.

Agreed. But that means I can't really have Travis do it for me.
Re: CC65 compiler
by on (#206738)
Google travis ci make release brought me "GitHub Releases Uploading".

Oh, now I see the problem: It'd end up adding the OAuth key to .travis.yml, and even though it "creates and encrypts a GitHub oauth token" (my emphasis), the page isn't quite clear as to who holds the decryption key for this encrypted token.
Re: CC65 compiler
by on (#220019)
Little outdated topic sorry but following nesdoug's tutorial and I cant it to compile correctly. Getting this error. I left the .asm file blank as I dont know what code to test because Im still learning. Tried a few examples at his site but get errors with the .asm also. Not sure why Im having such a issue compiling. Any help would be great. Thanks :)

Code:
ld65: Warning: NROM.cfg(76): Segment `HEADER' does not exist
ld65: Warning: nrom.cfg(76): Segment `STARTUP' does not exist
ld65: Warning: nrom.cfg(76): Segment `VECTORS' does not exist
ld65: Warning: nrom.cfg(76): Segment `CHARS' does not exist
ld65: Warning: nrom.cfg(76): Segment `ONCE' does not exist
Re: CC65 compiler
by on (#220021)
Quote:
Little outdated topic sorry but following nesdoug's tutorial and I cant it to compile correctly. Getting this error. I left the .asm file blank as I dont know what code to test because Im still learning. Tried a few examples at his site but get errors with the .asm also. Not sure why Im having such a issue compiling. Any help would be great. Thanks :)

Code:
ld65: Warning: NROM.cfg(76): Segment `HEADER' does not exist
ld65: Warning: nrom.cfg(76): Segment `STARTUP' does not exist
ld65: Warning: nrom.cfg(76): Segment `VECTORS' does not exist
ld65: Warning: nrom.cfg(76): Segment `CHARS' does not exist
ld65: Warning: nrom.cfg(76): Segment `ONCE' does not exist


Need more info. Windows or Linux?

Using a .bat file, make file, or manually typing commands into the terminal?

Which example code are you trying to compile?

None of my .cfg files are named NROM.cfg ... nor nrom.cfg. Where did you get that from?

Most of those segments are located in 'reset.s' which is almost the same as 'crt0.s' found in other people's source code. Are you sure that file is in the same folder?
Re: CC65 compiler
by on (#220022)
dude3585 wrote:
Little outdated topic sorry but following nesdoug's tutorial and I cant it to compile correctly. Getting this error. I left the .asm file blank as I dont know what code to test because Im still learning. Tried a few examples at his site but get errors with the .asm also. Not sure why Im having such a issue compiling. Any help would be great. Thanks :)

Code:
ld65: Warning: NROM.cfg(76): Segment `HEADER' does not exist
ld65: Warning: nrom.cfg(76): Segment `STARTUP' does not exist
ld65: Warning: nrom.cfg(76): Segment `VECTORS' does not exist
ld65: Warning: nrom.cfg(76): Segment `CHARS' does not exist
ld65: Warning: nrom.cfg(76): Segment `ONCE' does not exist

Well, obviously, you don't have any of these segments in your Assembly file, even though they're declared in your CFG file.
Which is no wonder if you are using a blank Assembly file.

This way the compiler thinks you have forgotten these segments and warns you about it.

Your code file needs stuff like:
Code:
.segment "STARTUP"
    ; Startup code goes here.

.segment "VECTORS"
    .addr Nmi
    .addr Reset
    .addr 0

etc.


P.S.: It's just a warning, not an error. After compiling, you should still get an NES file with all zeroes out of it, don't you?
Re: CC65 compiler
by on (#220023)
The fix isn't to add those segments to your assembly file, though. That's just treating the symptoms rather than the problem. It might compile but the ROM is not going to run unless you fill those segments up with what they require.

The fix is to find and include the content that you're missing from whatever example you're working from that is supposed to fill in those segments for you already.
Re: CC65 compiler
by on (#220024)
Well, it looks like he's trying to compile a blank file, so I assume the actual code comes afterwards anyway and he's just trying to set up the system to get zero errors.
Re: CC65 compiler
by on (#220030)
Sorry, yes you gave good information, I was merely clarifying that only doing that won't solve the problem, only hiding it.
Re: CC65 compiler
by on (#220036)
Thanks for quick reply! I followed this.On Win10 64bit. Notepad ++.
Followed this pretty much exactly but was confused by a few things. For the .cfg file Ive tried a few differnt nrom files that were at your site. In the CFG.zip. For the .asm I tried copy and pasting all the code here https://nesdoug.com/2015/11/17/3-our-first-program/.
I also made exceptions for PATH environment variables.


Update: I havnt made path exceptions in Windows for ld65. If that is needed?
Also that is correct I did try blank .asm and also code from Doug''s first program page. Basically tried blanka dn not blank to just get a .nes file compiled even if it wont run. Ill take a look at the reset.s file. That could be the missing code I need to take a look at.

FrankenGraphics wrote:
Won't record a movie, but this is my best attempt at a complete walkthrough.

1) Download the latest cc65 suite from here: https://cc65.github.io/cc65/getting-started.html
2) Extract it to c:\cc65
3) In c:\cc65, create a new folder. Name it "_MyFirstProject"
4) Open that folder. And open notepad. Write this:
Code:
ca65 -t nes -l mylist.lst src/mycode.asm -o myobjectfile.o
ld65 -C src/NROM.cfg myobjectfile.o -o mynesrom.nes
Pause

And save it as "_makefile.bat" in the project folder you just created. We'll get to what that did in a bit. For now, let's do a couple more things:
5) Within your project folder, create a new one called src. This is where we'll keep sourcecode and assets and configs. Open it.
6) Download dougeff's config zip and place one of the configs in it named something with "nrom" there. It doesn't matter which one at this point, but rename it to NROM.cfg for the sake of this walkthrough.
7) Make a new text file, let's call it mycode.asm.
8) Write some lines of code in it (since we're using dougeffs configs, a tip is following the same tutorials) and save.
9) So, with all that done, let's try it. Double click your batch file to make it run ca65 and ld65.
You should now have a NES binary file called mynesrom.nes. Congratulations!

Allright, let's get back to what the batch file did.

The batch file (.bat) is a way of automating using the command line tool, which you otherwise would use each time you'd assemble source code into a binary file (what one might offhandedly call a ROM, after the .rom file extension), using ca65*. We're not there yet, though, just preparing.

Let me step through what that batch file will do once you run it (you'll eventually do so by double clicking on it)
First line:
ca65 | this tells windows to run ca65; the assembler. Windows should know where it's at, so we don't need to specify the whole path.
-t nes | this is our first "command line option" - optional instructions which tells ca65 what to do. -t sets the target platform to nes. This isn't necessary to specify, but is handy: the right processor is chosen and so we will get notified if we try to use opcodes it can't accept. There's more to it if you'd program for, say, the commodore 64, but let's not get into that.
-l mylist.lst | this tells ca65 to create a listing of its output. It's not necessary either, but viewing the .lst file in a text or code editor might reveal things when you're analysing your resulting program and its machine language strings can be used for finding stuff in a hex editor. We won't get deeper into that now either.
src/mycode.asm | this will tell the assembler what file to assemble. The src\ part indicates that we have a folder named src in which the code should be.
-o myobjectfile.o | This tells ca65 that the assembled output file (called an object file) will be named myobjectfile.o - if we don't include it, it will default to the filename of your source code file but have the extension .o instead of what your source had.

Allright, so with that line run, the assember has made an object file. It's now the job of the linker to link together object files. Since we only have one for now, the linker will simply take that object file and output it as a nes file. But we need to instruct it to do so, of course. So here's line two:

ld65 | This will start the linker. Let's tell it what to do.
-C src/NROM.cfg | Use the config file named NROM.cfg
myobjectfile.o | Convert this object file according to specs found in NROM.cfg
-o mynesrom.nes | into an output we name mynesrom.nes.

Line three:
Pause | This is so the command prompt window doesn't close after execution. This way we can review what it had to say - were there any warnings, errors, or did we succeed? The pause is entirely optional, but is handy.

DONE!
You now know how to make .nes files using batch files and the cc65 suite. If you instead want to use the command line, you simply use the win-r hotkey, write "cmd.exe", hit enter, and then enter the same lines you wrote in the batch files (not "pause". that one is redundant here).

*ca65 and ld65 are two tools in the cc65 toolchain. ca is the assembler, ld is the linker. Both are needed to make a nes rom using assembly language.