1) In your code, add a function sprite_setcolour:
Code: Select all
uchar sprite_attr;
uchar sprite_amask;
void sprite_setcolour(struct sp1_cs *c)
{
c->attr_mask = sprite_amask; // set the sprite character's attribute mask
c->attr = sprite_attr; // set the sprite character's attribute
}
Code: Select all
// Setting colour of the player here
sprite_attr = 7 ; // white ink, black paper (paper colour will be masked by amask)
sprite_amask = 0xF8; // mask will keep everything except INK
sp1_IterateSprChar(sprtbl[0].s, sprite_setcolour); // colour the sprite
This code is inspired by ex4a in github https://github.com/z88dk/z88dk/blob/bd1 ... les/ex4a.c but may be obsolete.
NOTE: I only tested this on old lib in the old lib on sccz80. It will probably work on the sdcc versions or the new lib but I haven't tested that.
B) There is an alternative way to set colours for multiple sprites at once, as mentioned in https://www.z88dk.org/forum/viewtopic.php?f=2&t=3209.
I have not looked into it, most of my games only need about 5 sprites and they don't always need colours.
C) You can also not set colours at all and use the background colour of the tiles instead.
Much easier and saves extra code.