[cc65] Running C program in a cart

From: Payton Byrd <plbyrd1gmail.com>
Date: 2012-05-25 22:28:38
Hello,

I've got the following code that I'm trying to compile to an
8k cartridridge and run.

#include <peekpoke.h>


void main(void)
{
	POKE(53280, 2);
	POKE(53281, 2);

	while(1);
}

The configuration file is as such:


SYMBOLS {
    __STACKSIZE__:   type = weak,   value = $0800; # 2k stack
    __OVERLAYSIZE__: type = weak,   value = $0000;
	__ROMLOADADDRESS__: type = import;
}
MEMORY {
    ZP:       file = "", define = yes, start = $0002, size = $001A;
    RAM:      file = "", define = yes, start = $080D, size = $8000 -
$080D, fill = no;
    ROM1LA:		file = "easycli.bin", start = $8000, size = $0011;
	ROM1:		file = "easycli.bin", define = yes, start = $8011, size =
$1FEF, fill = yes;
	RAM2:		file = "", define = yes, start = $C000, size = $1000, fill = yes;
}
SEGMENTS {
	ROMLA:	  load = ROM1LA,	type = ro, define = yes, optional = no;
    STARTUP:  load = ROM1,      type = ro;
    LOWCODE:  load = ROM1,      type = ro,                optional = yes;
    INIT:     load = ROM1,      type = ro,  define = yes, optional = yes;
    CODE:     load = ROM1,      type = ro, define = yes;
    RODATA:   load = ROM1,      type = ro;
    DATA:     load = RAM,		type = rw, define = yes;
    ZPSAVE:   load = RAM,		type = bss;
    BSS:      load = RAM,		type = bss, define = yes;
    ZEROPAGE: load = ZP,		type = zp;
}
FEATURES {
    CONDES: segment = INIT,
	    type    = constructor,
	    label   = __CONSTRUCTOR_TABLE__,
	    count   = __CONSTRUCTOR_COUNT__;
    CONDES: segment = RODATA,
	    type    = destructor,
	    label   = __DESTRUCTOR_TABLE__,
	    count   = __DESTRUCTOR_COUNT__;
    CONDES: segment = RODATA,
	    type    = interruptor,
	    label   = __INTERRUPTOR_TABLE__,
	    count   = __INTERRUPTOR_COUNT__;
}


Finally, my cart header looks like this:


;
; Ullrich von Bassewitz, 2010-11-13
;
; This module supplies the load address that is expected by Commodore
; machines in the first two bytes of an excutable disk file.
;


        ; The following symbol is used by linker config to force the module
        ; to get included into the output file
        .export         __ROMLOADADDRESS__: absolute = 1

.segment        "ROMLA"

		.word	$8009
		.word	$febc
		.byte   'c' + $80
		.byte   'b' + $80
		.byte   'm' + $80
		.byte   $38, $30

		lda #$01
		sta $d020
		sta $d021


Now, the cart compiles and loads into VICE, and when it's loaded as a Cart
the screen and border turn white which is as expected based on the code in
the header.  The compiled binary then drops straight into the CC65
initialization code that is normally at 2061 as you would expect.  The
problem is that somewhere during initialization the system goes into an
infinite loop of displaying garbage on the screen.

Is there something special I need to do to make this work?
-- 
Payton Byrd
<http://www.paytonbyrd.com>
<http://it.toolbox.com/blogs/paytonbyrd>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri May 25 22:30:12 2012

This archive was generated by hypermail 2.1.8 : 2012-05-25 22:30:15 CEST