PVcollib  1.5.0
A devkit for ColecoVision
Data Structures | Macros | Functions | Variables
sprite.h File Reference

coleco generic sprites support. More...

#include <coleco/coltypes.h>

Go to the source code of this file.

Data Structures

struct  sprite_t
 
sprite entry :
    y,x     : coordinates (y,x) with y 0..191 and x 0..255
    pattern : pattern number of sprite
    colour  : colour between 0..15
More...
 

Macros

#define spr_getx(id)   (sprites[id].x)
 get the x sprite coordinate More...
 
#define spr_gety(id)   (sprites[id].y)
 get the y sprite coordinate More...
 
#define spr_set(id, xp, yp, col, pat)
 sets an sprite entry to the supplied values More...
 
#define spr_setxy(id, xp, yp)
 sets an sprite coordinate to the supplied values More...
 
#define spr_sety(id, yp)   { sprites[id].y=yp; }
 set the y sprite coordinate More...
 

Functions

void spr_clear (void)
 Remove all sprite from screen and init their positions.
 
void spr_clear30r (void)
 Remove all sprite from screen and init their positions in F18a 30 rows mode.
 
u8 spr_getentry (void)
 get a sprite id in sprite list More...
 
u8 spr_getentry30r (void)
 get a sprite id in sprite list More...
 
void spr_mode16x16 (void)
 put sprite in 16x16 pix mode Put all 32 sprites on screen in 16x16 pixels depth.
 
void spr_mode8x8 (void)
 put sprite in 8x8 pix mode Put all 32 sprites on screen in 8x8 pixels depth.
 
void spr_update (void)
 put sprite on screen Put all 32 sprites on screen. Must be call in NMI routine.
 
void spr_updatefast (void)
 put sprite on screen without checking order Put all 32 sprites on screen. Must be call in NMI routine.
 

Variables

volatile u8 spr_enable
 
0 or 1 if sprites can be displayed or not

 
volatile sprite_t sprites [MAXSPRITE]
 
32 sprites entries

 

Detailed Description

coleco generic sprites support.

This unit provides methods to display / remove sprites on screen.

Macro Definition Documentation

◆ spr_getx

spr_getx (   id)    (sprites[id].x)

get the x sprite coordinate

Parameters
idthe sprite number to be get [0 - 31]

◆ spr_gety

spr_gety (   id)    (sprites[id].y)

get the y sprite coordinate

Parameters
idthe sprite number to be get [0 - 31]

◆ spr_set

spr_set (   id,
  xp,
  yp,
  col,
  pat 
)
Value:
{ \
sprites[id].x=xp; \
sprites[id].y=yp; \
sprites[id].colour=col; \
sprites[id].pattern=pat; \
}

sets an sprite entry to the supplied values

Parameters
idthe sprite number to be get [0 - 31]
xpthe x location of the sprite in pixels
ypthe y location of the sprite in pixels
colthe sprite color (0 to 15)
patthe pattern number of sprite (must be a multiple of 4)
Examples:
graphics/sprites/animatedsprite/animatedsprite.c, and graphics/sprites/simplesprite/simplesprite.c.

◆ spr_setxy

spr_setxy (   id,
  xp,
  yp 
)
Value:
{ \
sprites[id].x=xp; \
sprites[id].y=yp; \
}

sets an sprite coordinate to the supplied values

Parameters
idthe sprite number to be get [0 - 31]
xpthe x location of the sprite in pixels
ypthe y location of the sprite in pixels

◆ spr_sety

spr_sety (   id,
  yp 
)    { sprites[id].y=yp; }

set the y sprite coordinate

Parameters
idthe sprite number to be get [0 - 31]
ypthe y location of the sprite in pixels
Examples:
graphics/sprites/animatedsprite/animatedsprite.c, and graphics/sprites/simplesprite/simplesprite.c.

Function Documentation

◆ spr_getentry()

spr_getentry ( void  )

get a sprite id in sprite list

Returns
sprite entry (0..31) Must be used to allocate sprite because we swap sprite each NMI to avoid 4 sprites limit per line.
Warning, it uses 0xcf Y attribute to know if sprite is used or not.
Examples:
graphics/sprites/animatedsprite/animatedsprite.c, and graphics/sprites/simplesprite/simplesprite.c.

◆ spr_getentry30r()

spr_getentry30r ( void  )

get a sprite id in sprite list

Returns
sprite entry (0..31) Must be used to allocate sprite because we swap sprite each NMI to avoid 4 sprites limit per line.
Warning, it uses 0xf0 Y attribute to know if sprite is used or not.