Ninjabba, on Thu Oct 22, 2009 3:48 PM, said:
making all functions and variables explicit seems to compile the file good
C:\cc65\demo>cc65 -t lynx sprdemo1.c
sprdemo1.c(46): Error: Preprocessor directive expected
sprdemo1.c(47): Warning: Implicit `int' is an obsolete feature
sprdemo1.c(47): Error: `;' expected
now im left with this error, which poinst at directive of the control sprite block
#asm
_SCB1 dc.b $c0,$10,$20
dc.w 0,0
dc.w 0,0,$100,$100
dc.b $01,$23,$45,$67,$89,$Ab,$cd,$ef
#endasm
I tried writing it different
#define SCB1()
asm(
"dc.b $c0,$10,$20"\
"dc.w 0,0"\
"dc.w 0,0,$100,$100"\
"dc.b $01,$23,$45,$67,$89,$Ab,$cd,$ef"
)
but then the compiler gives me the error
"sprdemo1.c(54): Error: ASM code error: dc.b is not a valid mnemonic" on this block
Could you email this sprdemo1.c so I can have a look at it.
lynxlib.h does not exist anymore. Don't include it. Include lynx.h instead.
You could create a new type for sprites like this:
typedef struct {
char a,b,c;
void *next;
char *bitmap;
int x, y;
int sx, sy;
char pal[8];
} sprite_t;
Now you can define your SCB1 like this:
sprite_t SCB = {
0xc0,0x10,0x20,
0,0,
0,0,0x100,0x100,
{0x01,0x23,0x45,0x67,0x89,0xAb,0xcd,0xef}
};
If you want to change something in your code you write
SCB.x = 1234;
SCB.y = 2345;
If you need to pass the structure pointer to your routine
void changePos( sprite_t *spr, int x, int y ) {
spr->x = x;
spr->y = y;
}
You should be able to call this routine from your code like this:
changePos(&SCB, 1234, 2345);
There is not much point in mixing in asm pieces in C-code. Either code in C or in asm.
Oh, and go to the library and borrow a book to learn C-programming. The cc65 is a full C-compiler that knows all the tricks found in the book. I have an old book by Kerningham and Ritchie. It is only around 5mm thick and contains everything I need to know about C.
For info about the special functions available by the cc65 system read this
http://www.cc65.org/doc/funcref.html
There is also a very fundamental change in the interrupt-code. The interrupt handler is set up at start time. The tgi-driver uses interrupts automatically so does the serial driver.
If you want to add an own interrupt handler for some reason in is "easy" to do. (This must be done in assembler.)
.interruptor _gametime
.export _playtime
_playtime:
.byte $00
.byte $00
.byte $00
.proc _gametime: near
.segment "CODE"
inc _playtime
bne @goon
inc _playtime+1
bne @goon
inc _playtime+2
@goon: clc
rts
.endproc
This interruptor will be called during every interrupt. If you only use the tgi-driver then it will be called at every VBL interrupt (75 times per second).
If you have many interrupts active then you need more code to find out who is interrupting.
The interruptor takes care of saving/restoring the registers and returning using rti. If you return with carry set then the interrupt was handled and the interruptor will exit. In this case I return with carry clear as our display handler will also need to take care of the VBL interrupt. The interrupt logic will call all interruptors if nobody sets the carry flag.
--
Karri
Coding in asm is a bit like eating with chopsticks. If you are good at it it works, But for me I just waste time and everything is messy.
Edited by karri, Fri Oct 23, 2009 2:12 AM.