diff --git a/.DS_Store b/.DS_Store index a4647e3..4598c5b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/build/cerezas.asm b/build/cerezas.asm index 33963c0..f7da877 100644 --- a/build/cerezas.asm +++ b/build/cerezas.asm @@ -18,6 +18,7 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 + defb @00000000 defb @00000001 defb @00000010 defb @00000100 @@ -36,7 +37,6 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -51,6 +51,7 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 + defb @00000000 defb @00000101 defb @00000011 defb @00000111 @@ -71,7 +72,6 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -86,6 +86,7 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 + defb @00000000 defb @00001110 defb @00011111 defb @00111110 @@ -106,7 +107,6 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -118,6 +118,7 @@ PUBLIC _cerezas1 defb @00000000 ._cerezas1_f4 + defb @00000000 defb @00000000 defb @00000110 defb @00000010 @@ -141,7 +142,6 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -153,6 +153,7 @@ PUBLIC _cerezas1 defb @00000000 ._cerezas1_f5 + defb @00000000 defb @00000000 defb @00000000 defb @00000001 @@ -176,7 +177,6 @@ PUBLIC _cerezas1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -190,6 +190,7 @@ PUBLIC _cerezas1 PUBLIC _cerezas2 ._cerezas2 + defb @00000000 defb @00000000 defb @00000000 defb @00000110 @@ -213,7 +214,6 @@ PUBLIC _cerezas2 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -228,6 +228,7 @@ PUBLIC _cerezas2 defb @00000000 defb @00000000 defb @00000000 + defb @00000000 defb @01000000 defb @10100000 defb @11000000 @@ -248,7 +249,6 @@ PUBLIC _cerezas2 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -260,6 +260,7 @@ PUBLIC _cerezas2 defb @00000000 ._cerezas2_f3 + defb @00000000 defb @00010000 defb @00100000 defb @01000000 @@ -283,7 +284,6 @@ PUBLIC _cerezas2 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -295,6 +295,7 @@ PUBLIC _cerezas2 defb @00000000 ._cerezas2_f4 + defb @00000000 defb @00000000 defb @01100000 defb @11000000 @@ -318,7 +319,6 @@ PUBLIC _cerezas2 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 @@ -330,6 +330,7 @@ PUBLIC _cerezas2 defb @00000000 ._cerezas2_f5 + defb @00000000 defb @00000000 defb @11000000 defb @00000000 @@ -353,7 +354,6 @@ PUBLIC _cerezas2 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 defb @00000000 defb @00000000 diff --git a/build/cerezas.png b/build/cerezas.png old mode 100755 new mode 100644 index 32a31b4..63cc03c Binary files a/build/cerezas.png and b/build/cerezas.png differ diff --git a/build/cerezas.png.bak.png b/build/cerezas.png.bak.png deleted file mode 100644 index 0ab7cce..0000000 Binary files a/build/cerezas.png.bak.png and /dev/null differ diff --git a/globals.c b/globals.c index 2d0ade4..ea2a1ab 100644 --- a/globals.c +++ b/globals.c @@ -20,7 +20,7 @@ uint8_t map[25][32] = { {E,A,A,A,A,T,I,0,X,A,A,A,T,I,0,E,F,I,0,S,A,A,A,W,I,0,S,A,A,A,A,F}, {0,0,0,0,0,0,I,0,B,0,0,0,0,I,0,0,0,I,0,0,0,0,0,B,I,0,0,0,0,0,0,0}, {0,I,I,I,I,I,I,0,B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,I,I,I,I,I,I,0,0}, -{C,A,A,A,A,T,I,0,B,I,0,C,A,A,A,Y,Y,A,A,A,D,I,0,B,I,0,S,A,A,A,A,D}, +{C,A,A,A,A,T,I,0,B,I,0,C,A,A,T,Y,Y,S,A,A,D,I,0,B,I,0,S,A,A,A,A,D}, {B,0,0,0,0,0,I,0,B,I,0,B,0,0,0,0,0,0,0,0,B,I,0,B,I,0,0,0,0,0,0,B}, {B,I,I,I,I,I,I,0,B,I,0,B,0,0,0,0,0,0,0,0,B,I,0,B,I,I,I,I,I,I,0,B}, {B,I,0,C,A,D,I,0,V,I,0,E,A,A,A,A,A,A,A,A,F,I,0,V,I,0,C,A,D,I,0,B}, @@ -62,6 +62,7 @@ uint8_t remaining_points; uint8_t frame = 0; uint8_t lives = 0; +uint8_t level = 0; uint8_t repaint_lives = 1; uint8_t speed; uint8_t idx; diff --git a/globals.h b/globals.h index e4ed9c8..699e96d 100644 --- a/globals.h +++ b/globals.h @@ -68,6 +68,12 @@ #define X 24 #define Y 25 +#define CHERRY 1 +#define STRAWBERRY 33 +#define COCKTAIL 65 +#define APPLE 97 +#define PEAR 129 + // screen rectangle extern struct sp1_Rect full_screen; @@ -172,6 +178,7 @@ extern uint8_t speed; extern uint8_t frame; extern uint8_t lives; +extern uint8_t level; extern uint8_t repaint_lives; extern uint8_t idx; extern struct sprite * collided_sprite; diff --git a/logic.c b/logic.c index 3847b05..eec5c8b 100644 --- a/logic.c +++ b/logic.c @@ -1,6 +1,7 @@ #include "logic.h" #include "int.h" #include +#include uint8_t get_map_color(uint8_t current) { if(current == I) { @@ -58,6 +59,23 @@ void show_cherry() { cherry.y = 21; cherry.x = 14; cherry.showing = 100; + + if(level == 0) { + cherry.offset = CHERRY; + sp1_IterateSprChar(cherry.sp, initialiseColourGreenRed); + } else if(level == 1) { + cherry.offset = STRAWBERRY; + sp1_IterateSprChar(cherry.sp, initialiseColourGreenRed); + } else if(level == 2) { + cherry.offset = COCKTAIL; + sp1_IterateSprChar(cherry.sp, initialiseColourRedYellowWhiteCyan); + } else if(level == 3) { + cherry.offset = APPLE; + sp1_IterateSprChar(cherry.sp, initialiseColourGhostRed); + } else if (level == 4) { + cherry.offset = PEAR; + sp1_IterateSprChar(cherry.sp, initialiseColourGreen); + } } void hide_cherry() { @@ -345,6 +363,11 @@ void next_level() { if (speed > 1) { --speed; } + + ++level; + if(level == 5) { + level = 0; + } } @@ -375,7 +398,11 @@ void check_fsm() { points += 20; // energizers - are worth 20 points each pill_eaten = 125; for(idx = 0; idx != 4; ++idx) { - if(ghosts[idx]->active == ACTIVE) { + if(ghosts[idx]->active == ACTIVE || ghosts[idx]->active == ELUDE) { + // stop so we could decide to "sacar pies en polvorosa" + ghosts[idx]->dx = 0; + ghosts[idx]->dy = 0; + ghosts[idx]->active = ELUDE; ghosts[idx]->currentoffset = GHOST_FRIGHTENED; sp1_IterateSprChar(ghosts[idx]->sp, initialiseColourBlue); @@ -478,4 +505,18 @@ void check_fsm() { // level finished! next_level(); } + + if(in_key_pressed(IN_KEY_SCANCODE_1)) { + level = 1; + show_cherry(); + } else if(in_key_pressed(IN_KEY_SCANCODE_2)) { + level = 2; + show_cherry(); + }else if(in_key_pressed(IN_KEY_SCANCODE_3)) { + level = 3; + show_cherry(); + }else if(in_key_pressed(IN_KEY_SCANCODE_4)) { + level = 4; + show_cherry(); + } } diff --git a/msnampac.c b/msnampac.c index 75f62a2..a264de7 100644 --- a/msnampac.c +++ b/msnampac.c @@ -20,6 +20,7 @@ void all_lives_lost() { sp1_Invalidate(&full_screen); lives = 5; points = 0; + level = 0; speed = 6; nampac_go_home(); repaint_lives = 1; @@ -130,7 +131,7 @@ int main() sp1_MoveSprAbs(ghosts[idx]->sp, &full_screen, (void*) ghosts[idx]->offset, ghosts[idx]->y, ghosts[idx]->x, 0, 0); } if(cherry.showing != 0) { - sp1_MoveSprAbs(cherry.sp, &full_screen, (void*) 0, cherry.y, cherry.x, 0, 0); + sp1_MoveSprAbs(cherry.sp, &full_screen, (void*) cherry.offset, cherry.y, cherry.x, 0, 0); } if(repaint_lives) { diff --git a/sprites.c b/sprites.c index 9e6dde3..3dee021 100644 --- a/sprites.c +++ b/sprites.c @@ -99,6 +99,28 @@ void initialiseColourGreenRed(unsigned int count, struct sp1_cs *c) } } +void initialiseColourGreen(unsigned int count, struct sp1_cs *c) +{ + (void)count; + c->attr_mask = SP1_AMASK_INK; + c->attr = INK_GREEN; + +} + +void initialiseColourRedYellowWhiteCyan(unsigned int count, struct sp1_cs *c) +{ + c->attr_mask = SP1_AMASK_INK; + if(count == 0) { + c->attr = INK_RED; + } else if (count == 1){ + c->attr = INK_YELLOW; + } else if(count == 3) { + c->attr = INK_WHITE; + } else { + c->attr = INK_CYAN; + } +} + struct sp1_ss * add_cherry_sprite() { struct sp1_ss * sp; sp = sp1_CreateSpr(SP1_DRAW_LOAD1LB, SP1_TYPE_1BYTE, 3, (int)cerezas1, 1); diff --git a/sprites.h b/sprites.h index d54a3a4..41542c3 100644 --- a/sprites.h +++ b/sprites.h @@ -23,5 +23,8 @@ extern void initialiseColourYellow(unsigned int count, struct sp1_cs *c); extern void initialiseColourGhostCyan(unsigned int count, struct sp1_cs *c); extern void initialiseColourGhostMagenta(unsigned int count, struct sp1_cs *c); extern void initialiseColourGhostRed(unsigned int count, struct sp1_cs *c); +extern void initialiseColourGreenRed(unsigned int count, struct sp1_cs *c); +extern void initialiseColourRedYellowWhiteCyan(unsigned int count, struct sp1_cs *c); +extern void initialiseColourGreen(unsigned int count, struct sp1_cs *c); #endif