RE: [cc65] bank switching/retro replay?

From: Shawn Jefferson <sjefferson1shaw.ca>
Date: 2009-11-08 20:25:56
> Sent: Sunday, November 08, 2009 8:58 AM
> Hi,
> just writing to check if anyone has developed for cartridges (e.g.
> Retro Replay) using cc65 and has wisdom to share?
> If I understand right, there is no in-built support for bank switching
> in cc65, similar to what's available in sdcc?

I've done it for cartridges on the Atari 8-bit.  Basically all there is to
it, is to define your linker config file to contain your different banks
(this is a setup for a 1MB Atari cartridge):

MEMORY {
	<snip built in stuff>

    CART0:    start = $A000, size = $1FFA, type = ro, fill = yes, fillval =
$00, file = %O;
    VECTORS: start = $BFFA, size = 6, type= ro, file = %O;
    CART1:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$11, file = %O;
    CART2:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$22, file = %O;
    CART3:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$33, file = %O;
    CART4:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$44, file = %O;
    CART5:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$55, file = %O;
    CART6:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$66, file = %O;
    CART7:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$77, file = %O;
    CART8:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$88, file = %O;
    CART9:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$99, file = %O;
    CARTA:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$AA, file = %O;
    CARTB:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$BB, file = %O;
    CARTC:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$CC, file = %O;
    CARTD:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$DD, file = %O;
    CARTE:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$EE, file = %O;
    CARTF:    start = $A000, size = $2000, type = ro, fill = yes, fillval =
$FF, file = %O;
}
SEGMENTS {
	<snip builtin stuff>
    BANK0:    load = CART0, run = CART0, type = ro, define = yes;
    BANK1:    load = CART1, run = CART1, type = ro, define = yes;
    BANK2:    load = CART2, run = CART2, type = ro, define = yes;
    BANK3:    load = CART3, run = CART3, type = ro, define = yes;
    BANK4:    load = CART4, run = CART4, type = ro, define = yes;
    BANK5:    load = CART5, run = CART5, type = ro, define = yes;
    BANK6:    load = CART6, run = CART6, type = ro, define = yes;
    BANK7:    load = CART7, run = CART7, type = ro, define = yes;
    BANK8:    load = CART8, run = CART8, type = ro, define = yes;
    BANK9:    load = CART9, run = CART9, type = ro, define = yes;
    BANKA:    load = CARTA, run = CARTA, type = ro, define = yes;
    BANKB:    load = CARTB, run = CARTB, type = ro, define = yes;
    BANKC:    load = CARTC, run = CARTC, type = ro, define = yes;
    BANKD:    load = CARTD, run = CARTD, type = ro, define = yes;
    BANKE:    load = CARTE, run = CARTE, type = ro, define = yes;
    BANKF:    load = CARTF, run = CARTF, type = ro, define = yes;
    VECTORS:  load = VECTORS, type = ro, define = yes;
}

Then a custom crt0.s needs be written, and at least the data segment needs
to be copied to RAM from your cartridge. There is an asm routine in the
library called copydata that can do this for you.

If you are also going to be calling C code from multiple banks then you need
to make sure that your C library code is also not being banked out.  In my
case I moved the CODE, RODATA and DATA into RAM.  All I need to be careful
of is to make sure that my code banks in the right cartridge bank before
attempting to call code there-the code to do this should be in RAM and not
on cartridge.  There are very tricky ways to set this up, this is the basic
way that works for me!

Shawn


----------------------------------------------------------------------
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 Nov 8 20:25:53 2009

This archive was generated by hypermail 2.1.8 : 2009-11-08 20:25:55 CET