cc65 CONDES

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
dougeff
Posts: 2712
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

cc65 CONDES

Post by dougeff » Wed Jul 25, 2018 6:14 am

After reading though the cc65 source code, I have removed the CONDES features from my cfg files.

This will result in errors, so then

I removed any calls to initlib and donelib, from crt0.s

Errors gone.

I have run multiple tests, and find no ill effects from this.

CONDES (constructor / destructor tables) uses up several (at least 30) bytes of RAM (self modifying code).

The only function that I can see that uses this table is exit() which NES games shouldn't do.

Incidentally, CONDES seems to be the only thing that used the "ONCE" segment. CONDES may be the only thing that was responsible for all those "ONCE" segment missing errors when cc65 files updated.
Last edited by dougeff on Wed Jul 25, 2018 12:20 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES

tepples
Posts: 22019
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: cc65 CONDES

Post by tepples » Wed Jul 25, 2018 8:26 am

The constructor side of CONDES is supposed to be for setting up init code, such that a module's init code gets called if and only if the module is linked into the ROM. On the NES, this might be useful in theory to link in PPU init or audio init or mapper init.

User avatar
rainwarrior
Posts: 7824
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: cc65 CONDES

Post by rainwarrior » Wed Jul 25, 2018 11:45 am

Yeah, I never liked that feature when it was added. A lot of extra hassle to support, and it was not put to enough use in the libraries to make it worthwhile, IMO. (And frankly I'm glad t wasn't, so that it's easier to remove like this.)

The CON point is to add an implied "init" for a module if it gets included, without having to add an extra line of C code or whatever to explicitly initialize it. The DES point is the same for shutdown, but obviously we don't need to care about that for NES.

If you just delete it from your linker configs, you're safe because anything that relies on it will produce an error. I don't think there's currently anything in the required CRT that really needs it, at least last time I looked all the modules that required it were things I'd never need on the NES. If you did need one of those constructors, you could reproduce it in your own CRT init to get support back for it.

User avatar
slembcke
Posts: 171
Joined: Fri Nov 24, 2017 2:40 pm
Location: Minnesota

Re: cc65 CONDES

Post by slembcke » Wed Jul 25, 2018 12:15 pm

Good to know. I've actually been wondering the same thing, and it's been on my TODO list to dig into that for a few months. Thanks!

User avatar
dougeff
Posts: 2712
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: cc65 CONDES

Post by dougeff » Wed Jul 25, 2018 12:59 pm

Just to clarify some of the details.

if you don't include initlib and donelib, then the compiler doesn't include condes.s. Which means that nothing gets copied into the ONCE segment in the RAM.

Thus you can use those (35?) bytes for other things. And you also save a similar amount of ROM space.
nesdoug.com -- blog/tutorial on programming for the NES

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

Re: cc65 CONDES

Post by Banshaku » Wed Jul 25, 2018 4:08 pm

Same thing here, I removed it as soon I understood that it was not necessary for the nes. No ill effect has long you remove what you just mentioned.

calima
Posts: 1160
Joined: Tue Oct 06, 2015 10:16 am

Re: cc65 CONDES

Post by calima » Thu Jul 26, 2018 3:48 am

You can also use some of the regbank ZP area if your C code never uses the register keyword.

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

Re: cc65 CONDES

Post by Banshaku » Thu Jul 26, 2018 6:16 am

By regbank ZP, are you talking about what is defined inside zeropage.inc? I think that is the only part I didn't check much in details yet.

calima
Posts: 1160
Joined: Tue Oct 06, 2015 10:16 am

Re: cc65 CONDES

Post by calima » Fri Jul 27, 2018 3:13 am


na_th_an
Posts: 554
Joined: Mon May 27, 2013 9:40 am

Re: cc65 CONDES

Post by na_th_an » Fri Jul 27, 2018 3:56 am

In 2.13, it shaves 66 bytes of the ROM, too, which is always good.

Post Reply