1.1 --- a/lib/image.c Sat Nov 10 22:11:32 2018 +0100
1.2 +++ b/lib/image.c Sat Nov 10 22:40:06 2018 +0100
1.3 @@ -42,14 +42,20 @@
1.4
1.5 void image_plot_sprite(sprite_t *s, int x, int y, int key)
1.6 {
1.7 - int frame = s->cfg->frame;
1.8 - position_t *p = image_get_stored_position(s->regions, frame);
1.9 + int frame = 0;
1.10 + position_t *p = 0;
1.11
1.12 - /* Copy to the stored region. */
1.13 + if (s->regions)
1.14 + {
1.15 + frame = s->cfg->frame;
1.16 + p = image_get_stored_position(s->regions, frame);
1.17
1.18 - display_copy(s->cfg, image_get_stored_region(s->regions, frame),
1.19 - s->image->width, s->image->height / s->yscale, 1,
1.20 - x, y, -1, 0);
1.21 + /* Copy to the stored region. */
1.22 +
1.23 + display_copy(s->cfg, image_get_stored_region(s->regions, frame),
1.24 + s->image->width, s->image->height / s->yscale, 1,
1.25 + x, y, -1, 0);
1.26 + }
1.27
1.28 /* Plot to the screen. */
1.29
1.30 @@ -57,13 +63,16 @@
1.31 s->image->width, s->image->height, s->yscale,
1.32 x, y, key, 1);
1.33
1.34 - /* Record the stored background details. */
1.35 + if (s->regions)
1.36 + {
1.37 + /* Record the stored background details. */
1.38
1.39 - p->x = x;
1.40 - p->y = y;
1.41 + p->x = x;
1.42 + p->y = y;
1.43
1.44 - if (frame >= s->regions->stored)
1.45 - s->regions->stored = frame + 1;
1.46 + if (frame >= s->regions->stored)
1.47 + s->regions->stored = frame + 1;
1.48 + }
1.49 }
1.50
1.51 /* Copy a region from the store to the screen, restoring the original
1.52 @@ -71,8 +80,14 @@
1.53
1.54 void image_unplot_sprite(sprite_t *s)
1.55 {
1.56 - int frame = s->cfg->frame;
1.57 - position_t *p = image_get_stored_position(s->regions, frame);
1.58 + int frame;
1.59 + position_t *p;
1.60 +
1.61 + if (!s->regions)
1.62 + return;
1.63 +
1.64 + frame = s->cfg->frame;
1.65 + p = image_get_stored_position(s->regions, frame);
1.66
1.67 /* Only unplot the sprite if a region was stored for the frame. */
1.68