1.1 --- a/include/image.h Tue Nov 13 15:17:37 2018 +0100
1.2 +++ b/include/image.h Tue Nov 13 17:54:21 2018 +0100
1.3 @@ -81,6 +81,10 @@
1.4
1.5 position_t *pos;
1.6
1.7 + /* Colour key for transparency. */
1.8 +
1.9 + int key;
1.10 +
1.11 /* The vertical scaling factor translating display rows to image
1.12 coordinates. */
1.13
1.14 @@ -102,9 +106,9 @@
1.15 #define Stored_Regions(NAME, FRAMES, SIZE) \
1.16 uint8_t __##NAME##_image[(FRAMES) * (SIZE)]; \
1.17 stored_regions_t NAME = { \
1.18 - .image=__##NAME##_image, \
1.19 - .size=SIZE, \
1.20 - .stored=0};
1.21 + .image = __##NAME##_image, \
1.22 + .size = SIZE, \
1.23 + .stored = 0};
1.24
1.25 /* Access functions. */
1.26
1.27 @@ -117,44 +121,56 @@
1.28 /* Initialise a sprite object using an existing image without the capability of
1.29 storing regions of the screen.
1.30
1.31 - SpriteOverwriting(<name>, image_t *image, display_config_t *cfg, int frames, int yscale)
1.32 + SpriteOverwriting(<name>, image_t *image, display_config_t *cfg, int frames,
1.33 + int key, int yscale)
1.34 */
1.35
1.36 -#define SpriteOverwriting(NAME, IMAGE, CFG, FRAMES, YSCALE) \
1.37 +#define SpriteOverwriting(NAME, IMAGE, CFG, FRAMES, KEY, YSCALE) \
1.38 position_t __##NAME##_pos[FRAMES]; \
1.39 + \
1.40 sprite_t NAME = { \
1.41 - .image=IMAGE, \
1.42 - .regions=0, \
1.43 - .yscale=YSCALE, \
1.44 - .cfg=CFG, \
1.45 - .pos=__##NAME##_pos};
1.46 + .image = IMAGE, \
1.47 + .regions = 0, \
1.48 + .key = KEY, \
1.49 + .yscale = YSCALE, \
1.50 + .cfg = CFG, \
1.51 + .pos = __##NAME##_pos};
1.52
1.53 /* Initialise a sprite object using an existing image, creating stored regions
1.54 for the animation of the sprite.
1.55
1.56 - Sprite(<name>, image_t *image, display_config_t *cfg, int frames, int yscale)
1.57 + Sprite(<name>, image_t *image, display_config_t *cfg, int frames, int key,
1.58 + int yscale)
1.59 */
1.60
1.61 -#define Sprite(NAME, IMAGE, CFG, FRAMES, YSCALE) \
1.62 +#define Sprite(NAME, IMAGE, CFG, FRAMES, KEY, YSCALE) \
1.63 Stored_Regions(__##NAME##_regions, FRAMES, \
1.64 (IMAGE)->width * (IMAGE)->height * (YSCALE)); \
1.65 position_t __##NAME##_pos[FRAMES]; \
1.66 + \
1.67 sprite_t NAME = { \
1.68 - .image=IMAGE, \
1.69 - .regions=&(__##NAME##_regions), \
1.70 - .yscale=YSCALE, \
1.71 - .cfg=CFG, \
1.72 - .pos=__##NAME##_pos};
1.73 + .image = IMAGE, \
1.74 + .regions = &(__##NAME##_regions), \
1.75 + .key = KEY, \
1.76 + .yscale = YSCALE, \
1.77 + .cfg = CFG, \
1.78 + .pos = __##NAME##_pos};
1.79
1.80 /* Sprite plotting operations. */
1.81
1.82 -void image_plot_sprite(sprite_t *s, int x, int y, int key);
1.83 +void image_plot_sprite(sprite_t *s);
1.84
1.85 void image_unplot_sprite(sprite_t *s);
1.86
1.87 void image_unplot_sprite_from_image(sprite_t *s, sprite_t *bg,
1.88 int xorigin, int yorigin);
1.89
1.90 +/* Update operations. */
1.91 +
1.92 +position_t *image_get_sprite_position(sprite_t *s);
1.93 +
1.94 +void image_set_sprite_position(sprite_t *s, int x, int y);
1.95 +
1.96 /* Convenience operations. */
1.97
1.98 void image_plot_sprite_section(sprite_t *s,