Re: [cc65] Re: Porting to CC65

From: Oliver Schmidt <ol.sc1web.de>
Date: 2010-10-10 10:20:47
Hi doynax,

> I'm looking into transferring a C64 game project from ACME to CA65
> with a view to prototyping tedious game logic in C and to make dealing
> with overlay code easier.

Cool :-)

> Anyway, after spending an afternoon reading
> through the manuals and doing a little testing I've now got a couple
> of questions:

I'm no heavy user of the advanced features of ca65 so I won't comment
on those questions...

Further above you mention "overlay code". I don't know what you are
refering to but want nevertheless make sure you are aware of the
'overlaydemo' program in the 'samples' directory.

> 1. Am I likely to get into trouble compiling the odd C function into
> an existing project? Is there a big fixed space overhead, or are the
> standard library and runtime functions compiled-in as needed? Also,
> what is the convention for preserving the compiler's zeropage
> variables?

Combining a little C with a lot of assembler is in general certainly a
viable option.

Both the standard library and runtime functions (btw: great that you
make that distinction) come in fine granular object files placed
inside libraries allowing the linker to pull in only what is actually
needed.

There are in fact three things to keep in mind:

The zeropage - The tmp? and ptr? locations don't need to be saved
between calls into C code. Additionally they can be used in asm
functions called from C code. I'm not sure about the other loactions.

The C stack - cc65 places parameters and local variables not in page 1
but on a second stack. If using C the you won't get along without. The
zeropage loaction sp is presumed to point to the start of that stack
(which is growning downwards). Between calls to C you can reuse both
the C stack area and the zeropage location sp.

The startup code - If you are not using the standard library then only
two things come into my mind: As already mentioned the C stack needs
to be initialized. The contents of the BSS segment should to be
zero'ed if you want to have global and static C variables be
initialized to zero as the C specs say.

One last note: Make sure you know about the __fastcall__ keyword.
Depending on your scenario it can make interfacing C and asm much
easier.

Regards,
Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Oct 10 10:25:12 2010

This archive was generated by hypermail 2.1.8 : 2010-10-10 10:25:15 CEST