cc65 compiling

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: cc65 compiling

Post by Banshaku »

Included, the basic runtime that I'm using with 2.17. The other file (runtime.lst) list which files are included. I think I'm almost using the same thing as Shiru.

Once my makefile is finished, I will release it and you will be able to build the runtime anytime you want. For now I don't like that it uses a copy in a specific folder so I want to retrieve specifics files from the cc65 folder if the version gets updated some day.

That make file will even compile your project once a few specific files are set in the lib folder (neslib/famitone) and in the src folder (your c/s files and crt files). I want to make it so that even if you use a specific neslib/famitone/crt that it still can compile some generic project. It should help for people that want to start C like project (which I'm in the same situation right now).

Will share it soon, once I find it good enough. For now, I will try to help you figure out your current issues until it is available.
Attachments
runtime.lst.zip
(716 Bytes) Downloaded 148 times
runtime.lib.zip
(45.24 KiB) Downloaded 154 times
kennyp1369
Posts: 8
Joined: Fri Jun 08, 2018 6:48 pm

Re: cc65 compiling

Post by kennyp1369 »

Now that I switched to nes.lib, I'm getting a different error:

ld65 -C nes.cfg -o example1.nes crt0.o example1.o nes.lib
ld65: Error: Missing memory area assignment for segment `ONCE'

The only leads I have to follow are to search all the files for ONCE and try to
figure out what's going on with it.

I welcome any suggestions for finding some complete example code to start
working with and modifying
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: cc65 compiling

Post by Banshaku »

Like mentioned before, I’m working on making a sample Makefile that should make it easier to create simple c projects with the latest runtime.

I just finished an example based of Shiru’s example1.c and added some code to test famitone inside it.

It should be usable in it’s current state. Except for example.c and the cfg files, other files were not modified (crt0, neslib, famitone) since it would be a common cause of bugs if some file a refreshed with the current examples.

Librsc folder contains the latest files from cc65 (2.17) so it can be tested right away. You just call make from root folder and everything should be compiled. It is possible to compile/clean the runtime only when required.

The files may be removed at a later stage if there is some issues to include it in a personal project. It is possible to use the currently installed lbsrc on your computer by modifying the Makefile accordingly.

There is not much doc with it for now but I think the Makefile should be quite a time saver. It took me time to make it but I’m more than happy to share it if it can helps people use the latest runtime.

Since I had the same issues to make it work with the latest version, I understand how it feels when nothing compiles with no obvious reason why it failed and you don’t know yet the tool chain.

It’s a work in progress but any comments on possible issues is always appreciated.
Attachments
example.zip
(249.46 KiB) Downloaded 168 times
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: cc65 compiling

Post by dougeff »

Copied from a .cfg file that I use...notice the 'ONCE' segment.


SEGMENTS {
HEADER: load = HEADER, type = ro;
STARTUP: load = PRG, type = ro, define = yes;
LOWCODE: load = PRG, type = ro, optional = yes;
INIT: load = PRG, type = ro, define = yes, optional = yes;
CODE: load = PRG, type = ro, define = yes;
RODATA: load = PRG, type = ro, define = yes;
DATA: load = PRG, run = RAM, type = rw, define = yes;
CHARS: load = CHR, type = rw;
BSS: load = RAM, type = bss, define = yes;
HEAP: load = RAM, type = bss, optional = yes;
ZEROPAGE: load = ZP, type = zp;
ONCE: load = PRG, type = ro, define = yes;

VECTORS: load = PRG, start = $fffa, type = ro;
}



you could also write it as...

ONCE: load = PRG, type = ro, define = yes, optional = yes;
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: cc65 compiling

Post by Banshaku »

The once segment is something they added around 2.14 and is now mandatory if my memory is good. Since Shiru's example where done with 2.11, this segment was not defined in the examples.

edit:

this segment is used for constructors. Since I do not define any, this segment is not in any file and should cause no issue. It just the config file that seems to nags you if you don't define it.

edit2:

@dougeff

Since you did some C tutorials, I would like to know if you think the make file I did is useful for beginners or not. I think it is since you just create you files (.s or .c) in src and it will compile them automatically.
kennyp1369
Posts: 8
Joined: Fri Jun 08, 2018 6:48 pm

Re: cc65 compiling

Post by kennyp1369 »

It compiled. Thanks everyone. I can start figuring out how to make changes now.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: cc65 compiling

Post by dougeff »

Since you did some C tutorials, I would like to know if you think the make file I did is useful for beginners or not. I think it is since you just create you files (.s or .c) in src and it will compile them automatically.
I think it will be useful. Yes. I'm always thinking about changing my tutorial, so it is good for me to see other people write source code.

Maybe one day I should collaborate with you or na_th_an or cppchriscpp to write some better example code.
nesdoug.com -- blog/tutorial on programming for the NES
Post Reply