/* data.c --- data managment
 *
 * This file is gift-ware.  This file is given to you freely
 * as a gift.  You may use, modify, redistribute, and generally hack
 * it about in any way you like, and you do not have to give anyone
 * anything in return.
 *
 * I do not accept any responsibility for any effects, adverse or
 * otherwise, that this code may have on just about anything that
 * you can think of.  Use it at your own risk.
 *
 * Copyright (C) 1999  Michael Bukin
 */

#include <stdlib.h>
#include <allegro.h>

#include "data.h"

/* Sprites.  */
BITMAP *eater_left_sprite[EATER_FRAMES] = { 0 };
BITMAP *eater_up_sprite[EATER_FRAMES] = { 0 };
BITMAP *eater_right_sprite[EATER_FRAMES] = { 0 };
BITMAP *eater_down_sprite[EATER_FRAMES] = { 0 };
BITMAP *ghost_left_sprite = 0;
BITMAP *ghost_up_sprite = 0;
BITMAP *ghost_right_sprite = 0;
BITMAP *ghost_down_sprite = 0;
BITMAP *bones_left_sprite = 0;
BITMAP *bones_up_sprite = 0;
BITMAP *bones_right_sprite = 0;
BITMAP *bones_down_sprite = 0;
BITMAP *wall_sprite = 0;
BITMAP *wall_left_sprite = 0;
BITMAP *wall_up_sprite = 0;
BITMAP *wall_right_sprite = 0;
BITMAP *wall_down_sprite = 0;
BITMAP *wall_top_left_sprite = 0;
BITMAP *wall_top_right_sprite = 0;
BITMAP *wall_bottom_left_sprite = 0;
BITMAP *wall_bottom_right_sprite = 0;
BITMAP *bonus_sprite = 0;
BITMAP *coin_sprite = 0;
BITMAP *door_sprite = 0;
BITMAP *prize_sprite[MAX_PRIZE] = { 0 };

struct color_t
{
  int car;
  int cdr;
};

static int
lookup_color_map (int c, struct color_t *cmap)
{
  int i;
  for (i = 0; cmap[i].car != -1; i++)
    if (cmap[i].car == c)
      return cmap[i].cdr;
  return 0;
}

static BITMAP*
make_bitmap_from_text (struct color_t *color_map, char **pixels)
{
  int x, y, w, h;
  BITMAP *bitmap;

  for (w = 0, h = 0; pixels[h] != 0; h++)
    if (strlen (pixels[h]) > w)
      w = strlen (pixels[h]);

  bitmap = create_bitmap (w, h);
  if (bitmap == 0)
    return 0;
  clear (bitmap);

  for (y = 0; y < h; y++)
    {
      char *line = pixels[y];
      for (x = strlen (line) - 1; x >= 0; x--)
	putpixel (bitmap, x, y, lookup_color_map (line[x], color_map));
    }

  return bitmap;
}

/*
 * Draw sprite with different color.
 */
void
draw_colored_sprite (BITMAP *dst, BITMAP *src, int dx, int dy, int color)
{
  int x, y;
  for (y = 0; y < src->h; y++)
    for (x = 0; x < src->w; x++)
      if (getpixel (src, x, y) != 0)
	putpixel (dst, dx + x, dy + y, color);
}

static struct color_t eater_color_map[] =
{
  { ' ', 0 },
  { 'a', 14 },
  { -1, -1 }
};

static char *eater_right_pixels[EATER_FRAMES][21] =
{
  {
    "       aaaaa        ",
    "    aaaaaaaaaaa     ",
    "   aaaaaaaaaaaaa    ",
    "  aaaaaaaaaaaaaaa   ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    "aaaaaaaaaaaaaaaaaaa ",
    "aaaaaaaaaaaaaaaaaaa ",
    "aaaaaaaaaa          ",
    "aaaaaaaaaaaaaaaaaaa ",
    "aaaaaaaaaaaaaaaaaaa ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    "  aaaaaaaaaaaaaaa   ",
    "   aaaaaaaaaaaaa    ",
    "    aaaaaaaaaaa     ",
    "       aaaaa        ",
    "                    ",
    0
  },
  {
    "       aaaaa        ",
    "    aaaaaaaaaaa     ",
    "   aaaaaaaaaaaaa    ",
    "  aaaaaaaaaaaaaaa   ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaa    ",
    "aaaaaaaaaaaaaa      ",
    "aaaaaaaaaaaa        ",
    "aaaaaaaaaa          ",
    "aaaaaaaaaaaa        ",
    "aaaaaaaaaaaaaa      ",
    " aaaaaaaaaaaaaaa    ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    "  aaaaaaaaaaaaaaa   ",
    "   aaaaaaaaaaaaa    ",
    "    aaaaaaaaaaa     ",
    "       aaaaa        ",
    "                    ",
    0
  },
  {
    "       aaaaa        ",
    "    aaaaaaaaaaa     ",
    "   aaaaaaaaaaaaaa   ",
    "  aaaaaaaaaaaaaa    ",
    " aaaaaaaaaaaaaa     ",
    " aaaaaaaaaaaaa      ",
    " aaaaaaaaaaaa       ",
    "aaaaaaaaaaaa        ",
    "aaaaaaaaaaa         ",
    "aaaaaaaaaa          ",
    "aaaaaaaaaaa         ",
    "aaaaaaaaaaaa        ",
    " aaaaaaaaaaaa       ",
    " aaaaaaaaaaaaa      ",
    " aaaaaaaaaaaaaa     ",
    "  aaaaaaaaaaaaaa    ",
    "   aaaaaaaaaaaaaa   ",
    "    aaaaaaaaaaa     ",
    "       aaaaa        ",
    "                    ",
    0
  },
  {
    "       aaaaa        ",
    "    aaaaaaaaaaa     ",
    "   aaaaaaaaaaaaa    ",
    "  aaaaaaaaaaaaaaa   ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaa    ",
    "aaaaaaaaaaaaaa      ",
    "aaaaaaaaaaaa        ",
    "aaaaaaaaaa          ",
    "aaaaaaaaaaaa        ",
    "aaaaaaaaaaaaaa      ",
    " aaaaaaaaaaaaaaa    ",
    " aaaaaaaaaaaaaaaaa  ",
    " aaaaaaaaaaaaaaaaa  ",
    "  aaaaaaaaaaaaaaa   ",
    "   aaaaaaaaaaaaa    ",
    "    aaaaaaaaaaa     ",
    "       aaaaa        ",
    "                    ",
    0
  },
};

static struct color_t ghost_color_map[] =
{
  { ' ', 0 },
  { 'a', 1 },
  { -1, -1 }
};

static char *ghost_pixels[21] =
{
  "      aaaaaaa       ",
  "     aaaaaaaaa      ",
  "    aaaaaaaaaaa     ",
  "   aaaaaaaaaaaaa    ",
  "  aaaaaaaaaaaaaaa   ",
  " aaaaaaaaaaaaaaaaa  ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaa aaaaa aaaaa aaa ",
  "aa   aaa   aaa   aa ",
  "a     a     a     a ",
  "                    ",
  0
};

static struct color_t bones_color_map[] =
{
  { ' ', 0 },
  { 'a', 1 },
  { -1, -1 }
};

static char *bones_left_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "   aaa   aaa        ",
  "   aaa   aaa        ",
  "   aaa   aaa        ",
  "   aaa   aaa        ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *bones_up_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "     aaa   aaa      ",
  "     aaa   aaa      ",
  "     aaa   aaa      ",
  "     aaa   aaa      ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *bones_right_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "       aaa   aaa    ",
  "       aaa   aaa    ",
  "       aaa   aaa    ",
  "       aaa   aaa    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *bones_down_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "     aaa   aaa      ",
  "     aaa   aaa      ",
  "     aaa   aaa      ",
  "     aaa   aaa      ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static struct color_t wall_color_map[] =
{
  { ' ', 0 },
  { 'a', 7 },
  { 'b', 15 },
  { 'c', 15 },
  { 'd', 8 },
  { 'e', 8 },
  { -1, -1 }
};

static char *wall_pixels[21] =
{
  "                    ",
  "                    ",
  "  accccccccccccca   ",
  "  bacccccccccccad   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  baeeeeeeeeeeead   ",
  "  aeeeeeeeeeeeeea   ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *wall_left_pixels[21] =
{
  "                    ",
  "                    ",
  "ccc                 ",
  "cccc                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "eeee                ",
  "eee                 ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *wall_up_pixels[21] =
{
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "   baaaaaaaaaaad    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *wall_right_pixels[21] =
{
  "                    ",
  "                    ",
  "                cccc",
  "               ccccc",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               eeeee",
  "                eeee",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *wall_down_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "   baaaaaaaaaaad    ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  "  bbaaaaaaaaaaadd   ",
  0
};

static char *wall_top_left_pixels[21] =
{
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *wall_top_right_pixels[21] =
{
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static char *wall_bottom_left_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  "aaaa                ",
  0
};

static char *wall_bottom_right_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  "               aaaaa",
  0
};

static struct color_t bonus_color_map[] =
{
  { ' ', 0 },
  { 'a', 12 },
  { -1, -1 }
};

static char *bonus_pixels[21] =
{
  "                    ",
  "         a          ",
  "        aaa         ",
  "        aaa         ",
  "    aa  aaa  aa     ",
  "    aaa aaa aaa     ",
  "     aaaaaaaaa      ",
  "      aaaaaaa       ",
  "  aaaaaaaaaaaaaaa   ",
  " aaaaaaaaaaaaaaaaa  ",
  "  aaaaaaaaaaaaaaa   ",
  "      aaaaaaa       ",
  "     aaaaaaaaa      ",
  "    aaa aaa aaa     ",
  "    aa  aaa  aa     ",
  "        aaa         ",
  "        aaa         ",
  "         a          ",
  "                    ",
  "                    ",
  0
};

static struct color_t coin_color_map[] =
{
  { ' ', 0 },
  { 'a', 14 },
  { 'b', 4 },
  { -1, -1 }
};

static char *coin_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "        aaa         ",
  "       aaaaa        ",
  "      aaaaaaa       ",
  "      aaaaaaab      ",
  "      aaaaaaab      ",
  "       aaaaabb      ",
  "        aaabb       ",
  "         bbb        ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static struct color_t door_color_map[] =
{
  { ' ', 0 },
  { 'a', 11 },
  { -1, -1 }
};

static char *door_pixels[21] =
{
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "aaaaaaaaaaaaaaaaaaa ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  "                    ",
  0
};

static struct color_t prize_color_map[] =
{
  { ' ', 0 },
  { 'a', 7 },
  { 'b', 15 },
  { 'c', 8 },
  { -1, -1 }
};

static char *prize_pixels[MAX_PRIZE][21] =
{
  {
    "                    ",
    "        b           ",
    "       b            ",
    "      b             ",
    "      b  b          ",
    "      b   b         ",
    "       b  b         ",
    "          b         ",
    "         b          ",
    "                    ",
    "        aaa         ",
    "      acaaaaa       ",
    "    aaaacaaacaa     ",
    "  aacaaaaacaaaaaa   ",
    " aaaacaaacaacaaaaa  ",
    "  aaaaacaaaaaacaa   ",
    "     aaacaaaaa      ",
    "                    ",
    "                    ",
    "                    ",
    0
  }
};

/*
 * Report error when making data.
 */
static void
data_error (char *text)
{
  allegro_exit ();
  allegro_message ("Can not make '%s'!", text);
  exit (EXIT_FAILURE);
}

/*
 * Make all data.
 */
void
game_data_init (char *progname)
{
  int i, x, y;
  BITMAP *ghost;

  /* Create eater sprites.  */
  for (i = 0; i < 4; i++)
    {
      eater_right_sprite[i] = make_bitmap_from_text (eater_color_map, eater_right_pixels[i]);
      if (eater_right_sprite[i] == 0)
	data_error ("eater_right_sprite");

      eater_left_sprite[i] = create_bitmap (eater_right_sprite[i]->w, eater_right_sprite[i]->h);
      if (eater_left_sprite[i] == 0)
	data_error ("eater_left_sprite");
      clear (eater_left_sprite[i]);
      draw_sprite_h_flip (eater_left_sprite[i], eater_right_sprite[i], -1, 0);

      eater_down_sprite[i] = create_bitmap (eater_right_sprite[i]->w, eater_right_sprite[i]->h);
      if (eater_down_sprite[i] == 0)
	data_error ("eater_down_sprite");
      for (y = eater_down_sprite[i]->h - 1; y >= 0; y--)
	for (x = eater_down_sprite[i]->w - 1; x >= 0; x--)
	  putpixel (eater_down_sprite[i], y, x, getpixel (eater_right_sprite[i], x, y));

      eater_up_sprite[i] = create_bitmap (eater_right_sprite[i]->w, eater_right_sprite[i]->h);
      if (eater_up_sprite[i] == 0)
	data_error ("eater_up_sprite");
      clear (eater_up_sprite[i]);
      draw_sprite_v_flip (eater_up_sprite[i], eater_down_sprite[i], 0, -1);
    }

  /* Create bone sprites.  */
  bones_left_sprite = make_bitmap_from_text (bones_color_map, bones_left_pixels);
  bones_up_sprite = make_bitmap_from_text (bones_color_map, bones_up_pixels);
  bones_right_sprite = make_bitmap_from_text (bones_color_map, bones_right_pixels);
  bones_down_sprite = make_bitmap_from_text (bones_color_map, bones_down_pixels);
  if ((bones_left_sprite == 0) || (bones_up_sprite == 0)
      || (bones_right_sprite == 0) || (bones_down_sprite == 0))
    data_error ("bones_sprite");

  /* Create ghost sprites.  */
  ghost = make_bitmap_from_text (ghost_color_map, ghost_pixels);
  if (ghost == 0)
    data_error ("ghost_sprite");

  ghost_left_sprite = create_bitmap (ghost->w, ghost->h);
  if (ghost_left_sprite == 0)
    data_error ("ghost_left_sprite");
  blit (ghost, ghost_left_sprite, 0, 0, 0, 0, ghost->w, ghost->h);
  draw_colored_sprite (ghost_left_sprite, bones_left_sprite, 0, 0, 0);

  ghost_up_sprite = create_bitmap (ghost->w, ghost->h);
  if (ghost_up_sprite == 0)
    data_error ("ghost_up_sprite");
  blit (ghost, ghost_up_sprite, 0, 0, 0, 0, ghost->w, ghost->h);
  draw_colored_sprite (ghost_up_sprite, bones_up_sprite, 0, 0, 0);

  ghost_right_sprite = create_bitmap (ghost->w, ghost->h);
  if (ghost_right_sprite == 0)
    data_error ("ghost_right_sprite");
  blit (ghost, ghost_right_sprite, 0, 0, 0, 0, ghost->w, ghost->h);
  draw_colored_sprite (ghost_right_sprite, bones_right_sprite, 0, 0, 0);

  ghost_down_sprite = create_bitmap (ghost->w, ghost->h);
  if (ghost_down_sprite == 0)
    data_error ("ghost_down_sprite");
  blit (ghost, ghost_down_sprite, 0, 0, 0, 0, ghost->w, ghost->h);
  draw_colored_sprite (ghost_down_sprite, bones_down_sprite, 0, 0, 0);

  destroy_bitmap (ghost);

  /* Create wall sprites.  */
  wall_sprite = make_bitmap_from_text (wall_color_map, wall_pixels);
  wall_left_sprite = make_bitmap_from_text (wall_color_map, wall_left_pixels);
  wall_up_sprite = make_bitmap_from_text (wall_color_map, wall_up_pixels);
  wall_right_sprite = make_bitmap_from_text (wall_color_map, wall_right_pixels);
  wall_down_sprite = make_bitmap_from_text (wall_color_map, wall_down_pixels);
  wall_top_left_sprite = make_bitmap_from_text (wall_color_map, wall_top_left_pixels);
  wall_top_right_sprite = make_bitmap_from_text (wall_color_map, wall_top_right_pixels);
  wall_bottom_left_sprite = make_bitmap_from_text (wall_color_map, wall_bottom_left_pixels);
  wall_bottom_right_sprite = make_bitmap_from_text (wall_color_map, wall_bottom_right_pixels);
  if ((wall_sprite == 0) || (wall_left_sprite == 0) || (wall_up_sprite == 0)
      || (wall_right_sprite == 0) || (wall_down_sprite == 0)
      || (wall_top_left_sprite == 0) || (wall_top_right_sprite == 0)
      || (wall_bottom_left_sprite == 0) || (wall_bottom_right_sprite == 0))
    data_error ("wall_sprite");

  /* Create bonus sprite.  */
  bonus_sprite = make_bitmap_from_text (bonus_color_map, bonus_pixels);
  if (bonus_sprite == 0)
    data_error ("bonus_sprite");

  /* Create coin sprite.  */
  coin_sprite = make_bitmap_from_text (coin_color_map, coin_pixels);
  if (coin_sprite == 0)
    data_error ("coin_sprite");

  /* Create door sprite.  */
  door_sprite = make_bitmap_from_text (door_color_map, door_pixels);
  if (door_sprite == 0)
    data_error ("door_sprite");

  /* Create prize sprites.  */
  for (i = 0; i < MAX_PRIZE; i++)
    {
      prize_sprite[i] = make_bitmap_from_text (prize_color_map, prize_pixels[i]);
      if (prize_sprite[i] == 0)
	data_error ("prize_sprite");
    }
}

/*
 * Free all data.
 */
void
game_data_exit (void)
{
  int i;

  for (i = 0; i < MAX_PRIZE; i++)
    {
      destroy_bitmap (prize_sprite[i]);
      prize_sprite[i] = 0;
    }

  destroy_bitmap (door_sprite);
  door_sprite = 0;

  destroy_bitmap (coin_sprite);
  coin_sprite = 0;

  destroy_bitmap (bonus_sprite);
  bonus_sprite = 0;

  destroy_bitmap (wall_sprite);
  wall_sprite = 0;
  destroy_bitmap (wall_left_sprite);
  wall_left_sprite = 0;
  destroy_bitmap (wall_up_sprite);
  wall_up_sprite = 0;
  destroy_bitmap (wall_right_sprite);
  wall_right_sprite = 0;
  destroy_bitmap (wall_down_sprite);
  wall_down_sprite = 0;
  destroy_bitmap (wall_top_left_sprite);
  wall_top_left_sprite = 0;
  destroy_bitmap (wall_top_right_sprite);
  wall_top_right_sprite = 0;
  destroy_bitmap (wall_bottom_left_sprite);
  wall_bottom_left_sprite = 0;
  destroy_bitmap (wall_bottom_right_sprite);
  wall_bottom_right_sprite = 0;

  destroy_bitmap (ghost_left_sprite);
  ghost_left_sprite = 0;
  destroy_bitmap (ghost_up_sprite);
  ghost_up_sprite = 0;
  destroy_bitmap (ghost_right_sprite);
  ghost_right_sprite = 0;
  destroy_bitmap (ghost_down_sprite);
  ghost_down_sprite = 0;

  destroy_bitmap (bones_left_sprite);
  bones_left_sprite = 0;
  destroy_bitmap (bones_up_sprite);
  bones_up_sprite = 0;
  destroy_bitmap (bones_right_sprite);
  bones_right_sprite = 0;
  destroy_bitmap (bones_down_sprite);
  bones_down_sprite = 0;

  for (i = 0; i < EATER_FRAMES; i++)
    {
      destroy_bitmap (eater_left_sprite[i]);
      eater_left_sprite[i] = 0;
      destroy_bitmap (eater_up_sprite[i]);
      eater_up_sprite[i] = 0;
      destroy_bitmap (eater_right_sprite[i]);
      eater_right_sprite[i] = 0;
      destroy_bitmap (eater_down_sprite[i]);
      eater_down_sprite[i] = 0;
    }
}

/*
 * data.c ends here
 */
