7 static sprite *spr[MAX_SPRITES];
8 static sprite *hwspr[4]; /* 4 channels because we support only attached sprites */
10 void begin_sprites(void)
13 memset(hwspr_used, 0, sizeof hwspr_used);
16 void end_sprites(void)
20 /* sort sprites by increasing start position */
21 for(i=0; i<scount; i++) {
22 for(j=i+1; j<scount; j++) {
23 if(spr[j]->y < spr[i]->y) {
24 struct sprite *tmp = spr[i];
31 /* set sprite positions and populate copperlist to draw
34 for(i=0; i<scount; i++) {
35 struct sprite *s = spr[i];
36 uint16_t sx = 0x80 + s->x;
37 uint16_t sy = 0x2c + s->y;
38 uint16_t vstop = sy + s->height;
42 if(!hwspr[j] || hwspr[j]->y + hwspr[j]->height < s->y) {
47 if(chan == -1) continue;
49 for(j=0; j<s->hwslices; j++) {
50 s->hwspr[idx][0] = s->hwspr[idx + 1][0] = (sx >> 1) | (sy << 8);
51 s->hwspr[idx][1] = s->hwspr[idx + 1][1] = (vstop << 8) |
52 ((vstop >> 7) & 2) | (sx & 1) | 0x80;
57 void draw_sprite(struct sprite *s, int x, int y)