Re: [cc65] bank switching/retro replay?

From: Groepaz <groepaz1gmx.net>
Date: 2009-11-10 14:22:51
On Dienstag 10 November 2009, Ullrich von Bassewitz wrote:

> No, there is not. And, while I see that having an interface for bank
> switching routines would be useful, I cannot currently see how it could be
> implemented without too much overhead. What would be possible is some
> additional function attribute like
>
>         __attribute__ ((banked, 0x01))
>
> where 0x01 is the bank number or some other information related to the
> target bank. It would then be the problem of the bank switching code to
> make proper use of the information. But writing such code that covers all
> cases is rather difficult. Especially if the caller needs to get banked
> out, before the callee is invoked.

my proposal would be to add an additional (and optional) property to the 
memory segments in the linker config... something like this:

MEMORY {
    ZP:    start = $0002, size = $001A, type = rw, define = yes;
    RAM:   start = $07FF, size = $C801, file = %O, define = yes;
    RAMB1: start = $d000, size = $0fff, banked= $11, file = %O, define = yes;
    RAMB2: start = $d000, size = $0fff, banked= $12, file = %O, define = yes;
    RAMB3: start = $d000, size = $0fff, banked= $13, file = %O, define = yes;
}

SEGMENTS {
    STARTUP:  load = RAM, type = ro;
    LOWCODE:  load = RAM, type = ro,               optional = yes;
    INIT:     load = RAM, type = ro, define = yes, optional = yes;
    CODE:     load = RAM, type = ro;

    CODEB1:   load = RAMB1, type = ro;
    CODEB2:   load = RAMB2, type = ro;
    CODEB3:   load = RAMB3, type = ro;
}

the linker could then define some symbol for the value(s) given to the 
respective "banked" property, which can then be used in tables used by the 
custom banking logic. this would also need some kind of pseudoop that 
evaluates the "banked" value from a given function/symbol, so tables can be 
build like this:


	.segment "CODEB1"
f1:
	..
	.segment "CODEB2"
f2:
	..

	.segment "CODE"

	.word f1,.banked(f1) ; evaluates to $11
	.word f2,.banked(f2) ; evaluates to $12

this approach seems simpler and cleaner to me, and it should cover most 
practical uses... the function attribute really doesnt make a lot of sense 
unless the compiler/assembler/linker are able to _automatically_ place 
functions in different banks, imho. when having to manually manage it, then 
simply using specific segments for specific banks is a lot more 
straightforward :)

(OT: this one missing feature is pretty much what keeps me porting the 
retroreplay source to ca65 =P)

-- 

http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

if brute force doesn't work, you're not applying it hard enough.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 10 14:22:28 2009

This archive was generated by hypermail 2.1.8 : 2009-11-10 14:22:31 CET