PVcollib  1.5.0
A devkit for ColecoVision
sprite.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------------
2 
3  Generic sprites functions.
4 
5  Copyright (C) 2018-2019
6  Alekmaul
7 
8  This software is provided 'as-is', without any express or implied
9  warranty. In no event will the authors be held liable for any
10  damages arising from the use of this software.
11 
12  Permission is granted to anyone to use this software for any
13  purpose, including commercial applications, and to alter it and
14  redistribute it freely, subject to the following restrictions:
15 
16  1. The origin of this software must not be misrepresented; you
17  must not claim that you wrote the original software. If you use
18  this software in a product, an acknowledgment in the product
19  documentation would be appreciated but is not required.
20  2. Altered source versions must be plainly marked as such, and
21  must not be misrepresented as being the original software.
22  3. This notice may not be removed or altered from any source
23  distribution.
24 
25 
26 ---------------------------------------------------------------------------------*/
34 #ifndef COL_SPRITE_H
35 #define COL_SPRITE_H
36 
37 #include <coleco/coltypes.h>
38 
39 #define SPHIDE 0xCF
40 #define SPHIDE1 0xCE
41 
42 #define MAXSPRITE 32
43 #define MAXSPRITE4 (MAXSPRITE*4)
44 #define MAXSPRITE2 (MAXSPRITE*2)
45 
53 typedef struct
54 {
55  u8 y;
56  u8 x;
57  u8 pattern;
58  u8 colour;
59 } sprite_t;
60 
65 extern volatile sprite_t sprites[MAXSPRITE]; // sprites entries
66 
71 extern volatile u8 spr_enable;
72 
77 void spr_clear(void);
78 
83 void spr_clear30r(void);
84 
90 void spr_update(void);
91 
97 void spr_updatefast(void);
98 
105 u8 spr_getentry(void);
106 
113 u8 spr_getentry30r(void);
114 
115 
120 void spr_mode8x8(void);
121 
126 void spr_mode16x16(void);
127 
136 #define spr_set(id, xp, yp, col, pat) \
137  { \
138  sprites[id].x=xp; \
139  sprites[id].y=yp; \
140  sprites[id].colour=col; \
141  sprites[id].pattern=pat; \
142  }
143 
150 #define spr_setxy(id, xp, yp) \
151  { \
152  sprites[id].x=xp; \
153  sprites[id].y=yp; \
154  }
155 
161 #define spr_setx(id,xp) { sprites[id].x=xp; }
162 
168 #define spr_sety(id,yp) { sprites[id].y=yp; }
169 
175 #define spr_setpat(id,pat) { sprites[id].pattern=pat; }
176 
182 #define spr_setcol(id,col) { sprites[id].colour=col; }
183 
188 #define spr_getx(id) (sprites[id].x)
189 
194 #define spr_gety(id) (sprites[id].y)
195 
196 #endif
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
volatile sprite_t sprites[MAXSPRITE]
32 sprites entries
sprite entry : y,x : coordinates (y,x) with y 0..191 and x 0..255 pattern : pattern numbe...
Definition: sprite.h:53
void spr_mode8x8(void)
put sprite in 8x8 pix mode Put all 32 sprites on screen in 8x8 pixels depth.
Custom types used by pvcollib.
u8 spr_getentry30r(void)
get a sprite id in sprite list
volatile u8 spr_enable
0 or 1 if sprites can be displayed or not
void spr_clear(void)
Remove all sprite from screen and init their positions.
void spr_updatefast(void)
put sprite on screen without checking order Put all 32 sprites on screen. Must be call in NMI routine...
void spr_mode16x16(void)
put sprite in 16x16 pix mode Put all 32 sprites on screen in 16x16 pixels depth.
void spr_update(void)
put sprite on screen Put all 32 sprites on screen. Must be call in NMI routine.