PROGMEMed two sprite arrays

This commit is contained in:
Christian Kroll 2010-12-20 22:51:25 +00:00
parent 847648d5e6
commit c64a587af4
2 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,8 @@
#include <stdint.h>
#include "../../compat/pgmspace.h"
#include "invaders2.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, P, 0, 0, 0, 0, 0, P, 0, 0 },
{ 0, 0, 0, P, 0, 0, 0, P, 0, 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 }, { P, 0, P, 0, 0, 0, 0, 0, P, 0, P },
{ 0, 0, 0, P, P, 0, P, P, 0, 0, 0 } }; { 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 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) for (y = 0; y < 8; ++y)
{ {
if (hans[y][x] != 0) if (pgm_read_byte(&hans[y][x]) != 0)
{ {
iv->map[x][y] = 2; iv->map[x][y] = 2;
} }
@ -134,7 +136,7 @@ void initInvaders(Invaders * iv, unsigned char lv)
{ {
for (y = 0; y < 8; ++y) for (y = 0; y < 8; ++y)
{ {
if (peter[y][x] != 0) if (pgm_read_byte(&peter[y][x]) != 0)
{ {
iv->map[x][y] = 2; iv->map[x][y] = 2;
} }

View File

@ -11,6 +11,7 @@
#define INVADERS2_H #define INVADERS2_H
/* TEST PARTS NEW API */ /* TEST PARTS NEW API */
#include <stdint.h>
#include "../../config.h" #include "../../config.h"
#include "../../pixel.h" #include "../../pixel.h"
@ -50,8 +51,8 @@ typedef struct
/* GLOBALE VAR */ /* GLOBALE VAR */
/****************************************************************/ /****************************************************************/
#define P 3 #define P 3
extern unsigned char peter[8][11]; extern uint8_t const peter[8][11];
extern unsigned char hans[8][11]; extern uint8_t const hans[8][11];
/****************************************************************/ /****************************************************************/
/* DEFINES */ /* DEFINES */