Hallo!
Bin C-technisch ein wenig eingerostet, und versuche gerade eine kleine Sprite-Lade-Routine mit dem cc65 zu schreiben und er bringt mich gerade etwas zur Verzweiflung. Es geht um folgende, kleine, Funktion:
/**
* Load sprite data from a file into a given memory address and set the VIC data accordingly.
*
* @param filename Name of the file holding the sprite data.
* @param address The memory address of the loaded sprite
* (address is not(!) checked, if it's in the correct bank!).
* @param isMultiColor Flag to indicate, if the sprite is multicolor.
* @param spriteNumber The number of the sprite in the VIC.
*
* @return true if the sprite was successfully loaded, false otherwise.
*/
int spriteLoad( char *filename,
unsigned char *address,
int isMultiColor,
unsigned char spriteNumber) {
FILE *fhandle; /* Handle for the file holding the sprite data. */
fhandle = fopen( filename, "r"); /* Open the file for reading. */
if( ! fhandle) { return false; } /* Could not open the file. */
if( 63 != fread( address, sizeof( unsigned char), 63, fhandle)) { return false; }
fclose( fhandle);
VIC.spr_mcolor &= (unsigned char)(0xfe << spriteNumber);
if( isMultiColor) {
VIC.spr_mcolor |= (unsigned char)(1 << spriteNumber);
}
/* Set the address of the sprite in the VIC's sprite pointer. */
/* Bank is selected in bit 0 and 1 of the cia2. */
unsigned char *bankStart = ((unsigned char *)CIA2.pra & 3) << 14;
/* Compute the sprite pointer by getting the screen ram address. */
unsigned char *screenOffset = ((unsigned char *)(VIC.addr >> 4)) << 10;
/* Pointers are in the last 8 Byte of the screen ram block. */
unsigned char *spritePointer = bankStart + screenOffset + 1016 + spriteNumber;
#ifdef DEBUG
printf("Spritepointer for sprite %d is %d\n", spriteNumber, spritePointer);
#endif
/* Sprite index is (address - bankstart) / 64 */
*spritePointer = (unsigned char)((address - bankstart) >> 6)
return true;
}
Alles anzeigen
, und nun scheitert es schon in der Zeile:
unsigned char *bankStart = ((unsigned char *)CIA2.pra & 3) << 14;
, wobei der Compiler meint:
====
localhost shooter # make
cl65 -t c64 shooter.c sprite.c -o shooter
sprite.c(67): Error: Expression expected
sprite.c(67): Warning: Statement has no effect
sprite.c(67): Error: `;' expected
sprite.c(67): Error: Expression expected
sprite.c(67): Error: Undefined symbol: `bankStart'
sprite.c(67): Error: Invalid lvalue in assignment
sprite.c(67): Error: Integer expression expected
sprite.c(70): Error: Expression expected
sprite.c(70): Warning: Statement has no effect
sprite.c(70): Error: `;' expected
sprite.c(70): Error: Expression expected
sprite.c(70): Error: Undefined symbol: `screenOffset'
sprite.c(70): Error: Invalid lvalue in assignment
sprite.c(70): Fatal: Too many errors
make: *** [all] Fehler 1
====
Sieht jemand auf die Schnelle, warum das kein Ausdruck sein soll? Irgendwie bin ich wohl gerade etwas blind...
Vielen Dank im Voraus,
Andreas