From c64a587af45ee10b90ea3145d86fa1eda9ef6db5 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Mon, 20 Dec 2010 22:51:25 +0000 Subject: [PATCH] PROGMEMed two sprite arrays --- games/space_invaders/invader_init.c | 10 ++++++---- games/space_invaders/invaders2.h | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/games/space_invaders/invader_init.c b/games/space_invaders/invader_init.c index 8fa56d4..15ca77b 100644 --- a/games/space_invaders/invader_init.c +++ b/games/space_invaders/invader_init.c @@ -1,6 +1,8 @@ +#include +#include "../../compat/pgmspace.h" #include "invaders2.h" -unsigned char peter[8][11] = +uint8_t const peter[8][11] PROGMEM = { { 0, 0, P, 0, 0, 0, 0, 0, P, 0, 0 }, { 0, 0, 0, P, 0, 0, 0, P, 0, 0, 0 }, @@ -11,7 +13,7 @@ unsigned char peter[8][11] = { P, 0, P, 0, 0, 0, 0, 0, P, 0, P }, { 0, 0, 0, P, P, 0, P, P, 0, 0, 0 } }; -unsigned char hans[8][11] = +uint8_t const hans[8][11] PROGMEM = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1 }, @@ -114,7 +116,7 @@ void initInvaders(Invaders * iv, unsigned char lv) { for (y = 0; y < 8; ++y) { - if (hans[y][x] != 0) + if (pgm_read_byte(&hans[y][x]) != 0) { iv->map[x][y] = 2; } @@ -134,7 +136,7 @@ void initInvaders(Invaders * iv, unsigned char lv) { for (y = 0; y < 8; ++y) { - if (peter[y][x] != 0) + if (pgm_read_byte(&peter[y][x]) != 0) { iv->map[x][y] = 2; } diff --git a/games/space_invaders/invaders2.h b/games/space_invaders/invaders2.h index 4a4f9e3..d140687 100644 --- a/games/space_invaders/invaders2.h +++ b/games/space_invaders/invaders2.h @@ -11,6 +11,7 @@ #define INVADERS2_H /* TEST PARTS NEW API */ +#include #include "../../config.h" #include "../../pixel.h" @@ -50,8 +51,8 @@ typedef struct /* GLOBALE VAR */ /****************************************************************/ #define P 3 -extern unsigned char peter[8][11]; -extern unsigned char hans[8][11]; +extern uint8_t const peter[8][11]; +extern uint8_t const hans[8][11]; /****************************************************************/ /* DEFINES */