1.1 --- a/include/image.h Sat Nov 10 17:03:17 2018 +0100
1.2 +++ b/include/image.h Sat Nov 10 17:58:49 2018 +0100
1.3 @@ -38,26 +38,52 @@
1.4
1.5 } image_t;
1.6
1.7 +
1.8 +
1.9 /* Stored display regions. */
1.10
1.11 typedef struct
1.12 {
1.13 + /* Position of the stored region on the screen. */
1.14 +
1.15 + int x, y;
1.16 +
1.17 +} position_t;
1.18 +
1.19 +typedef struct
1.20 +{
1.21 /* Stored region overplotted by the sprite. */
1.22
1.23 uint8_t *image;
1.24 + uint32_t size;
1.25 +
1.26 + /* Number of stored frames. */
1.27 +
1.28 int stored;
1.29
1.30 - /* Position of the stored region. */
1.31 + /* Stored region positions. */
1.32
1.33 - int x, y;
1.34 + position_t *pos;
1.35
1.36 -} stored_region_t;
1.37 +} stored_regions_t;
1.38
1.39
1.40
1.41 -/* Initialise the stored regions. */
1.42 +/* Initialise stored regions, allocating memory and a structure to access it. */
1.43
1.44 -void init_stored_regions(stored_region_t *r, int frames,
1.45 - uint8_t *regions, uint32_t region_size);
1.46 +#define Stored_Regions(NAME, FRAMES, SIZE) \
1.47 + uint8_t __##NAME##_image[FRAMES * SIZE]; \
1.48 + position_t __##NAME##_pos[FRAMES]; \
1.49 + stored_regions_t NAME = { \
1.50 + .image=__##NAME##_image, \
1.51 + .size=SIZE, \
1.52 + .stored=0, \
1.53 + .pos=__##NAME##_pos};
1.54 +
1.55 +/* Access functions. */
1.56 +
1.57 +position_t *image_get_stored_position(stored_regions_t *r, int frame);
1.58 +
1.59 +uint8_t *image_get_stored_region(stored_regions_t *r, int frame);
1.60
1.61 #endif /* __IMAGE_H__ */