diff --git a/.DS_Store b/.DS_Store index 4c33a03..db0ed80 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Makefile b/Makefile index 6604afa..008901f 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ compile: png2sp1sprite ./build/prota_sprites.png -b -i sprite_protar -f 16 -s rodata_user > ./build/prota.asm png2sp1sprite ./build/prota_dead.png -b -i sprite_protar_dead -f 16 -s rodata_user > ./build/prota_dead.asm png2sp1sprite ./build/red_ghost.png -b -i red_ghost -f 16 -s rodata_user > ./build/red_ghost.asm + png2sp1sprite ./build/cerezas.png -b -i cerezas -f 16 -s rodata_user > ./build/cerezas.asm ls *.bin zcc +zx -v -startup=31 -DWFRAMES=3 -clib=sdcc_iy -Cz--screen=intro.scr -SO3 --max-allocs-per-node10000 @zproject.lst -pragma-include:zpragma.inc -o msnampac -create-app #zcc +zx -v -m -startup=31 -clib=sdcc_iy -SO3 --max-allocs-per-node10000 @zproject.lst -pragma-include:zpragma.inc -o alley diff --git a/build/binaries.lst b/build/binaries.lst index 861998b..2325fba 100644 --- a/build/binaries.lst +++ b/build/binaries.lst @@ -13,3 +13,4 @@ topvertiright topvertileft ghostpill red_ghost +cerezas diff --git a/build/cerezas.asm b/build/cerezas.asm new file mode 100644 index 0000000..cc9677d --- /dev/null +++ b/build/cerezas.asm @@ -0,0 +1,86 @@ +SECTION rodata_user + +; Original: 16, 24 (=2 x 3 chars) +; Blocks: 2 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +PUBLIC _cerezas1 +._cerezas1 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000001 + defb @00000010 + defb @00000100 + defb @00001000 + defb @00111100 + defb @00111100 + defb @11111111 + defb @11111111 + defb @11111101 + defb @11111101 + defb @00111100 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +PUBLIC _cerezas2 +._cerezas2 + + defb @00000000 + defb @00000000 + defb @00001110 + defb @00111110 + defb @00111110 + defb @11010000 + defb @00010000 + defb @00100000 + defb @00100000 + defb @00100000 + defb @11110000 + defb @11111100 + defb @11111100 + defb @11111100 + defb @11111100 + defb @11110000 + defb @11110000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + diff --git a/build/cerezas.png b/build/cerezas.png new file mode 100644 index 0000000..0ab7cce Binary files /dev/null and b/build/cerezas.png differ diff --git a/build/prota.asm b/build/prota.asm index 036a586..02a5324 100644 --- a/build/prota.asm +++ b/build/prota.asm @@ -1,6 +1,6 @@ SECTION rodata_user -; Original: 128, 24 (=16 x 3 chars) +; Original: 192, 24 (=24 x 3 chars) ; Blocks: 2 defb @00000000 defb @00000000 @@ -16,20 +16,20 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 - defb @00000000 - defb @00001111 + defb @00011100 + defb @00011100 + defb @01110011 + defb @01101111 + defb @00011110 + defb @00011101 defb @00111111 - defb @01111111 - defb @01111111 - defb @11111111 - defb @11111100 - defb @11111100 - defb @11111111 - defb @01111111 - defb @01111111 defb @00111111 + defb @00111111 + defb @00110111 + defb @00011111 + defb @00011111 defb @00001111 + defb @00000011 defb @00000000 defb @00000000 defb @00000000 @@ -51,20 +51,20 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 - defb @00000000 + defb @00001110 + defb @00001110 + defb @00111001 + defb @00110111 + defb @00001110 + defb @00001101 + defb @00011111 + defb @00011111 + defb @00011111 + defb @00011011 defb @00001111 - defb @00111111 - defb @01111111 - defb @01111110 - defb @01111000 - defb @11111000 - defb @11111000 - defb @01111000 - defb @01111110 - defb @01111111 - defb @00111111 defb @00001111 + defb @00000111 + defb @00000001 defb @00000000 defb @00000000 defb @00000000 @@ -86,20 +86,20 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @00000000 - defb @00000000 - defb @11111000 - defb @11111110 - defb @01111111 - defb @00111111 - defb @00001111 + defb @00001100 + defb @00001100 + defb @00111001 + defb @00110111 defb @00001111 + defb @00001110 + defb @00011101 + defb @00011111 + defb @00011111 + defb @00011011 defb @00001111 defb @00001111 - defb @00111111 - defb @01111111 - defb @11111110 - defb @11111000 + defb @00000111 + defb @00000001 defb @00000000 defb @00000000 defb @00000000 @@ -123,18 +123,18 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @00011110 - defb @01111111 - defb @11111111 - defb @11111111 - defb @00011111 - defb @00000111 defb @00000111 defb @00011111 - defb @11111111 - defb @11111111 + defb @00111110 + defb @00111111 defb @01111111 - defb @00011110 + defb @01111111 + defb @01111111 + defb @01111111 + defb @00111111 + defb @00111111 + defb @00011111 + defb @00000111 defb @00000000 defb @00000000 defb @00000000 @@ -158,18 +158,18 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @11000000 - defb @11100000 - defb @11110000 - defb @11110000 - defb @11111111 - defb @01111111 - defb @01111111 - defb @00111111 - defb @00000110 - defb @00000000 + defb @00000111 + defb @00001110 + defb @00000111 + defb @00000011 + defb @00000001 defb @00000000 defb @00000000 + defb @00000001 + defb @00000011 + defb @00000111 + defb @00001111 + defb @00000111 defb @00000000 defb @00000000 defb @00000000 @@ -193,18 +193,18 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @01110000 - defb @01110000 - defb @11111001 - defb @11111001 - defb @11111111 - defb @11111111 - defb @01111111 - defb @01111111 - defb @00111111 - defb @00001111 + defb @00000011 + defb @00001110 + defb @00011111 + defb @00011111 + defb @00000011 defb @00000000 defb @00000000 + defb @00000011 + defb @00011111 + defb @00011111 + defb @00001111 + defb @00000011 defb @00000000 defb @00000000 defb @00000000 @@ -229,18 +229,18 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @00000110 - defb @00111111 - defb @01111111 - defb @01111111 - defb @11111111 - defb @11110000 - defb @11110000 - defb @11100000 - defb @11000000 - defb @00000000 - defb @00000000 - defb @00000000 + defb @00001100 + defb @00011100 + defb @00011100 + defb @00111110 + defb @00101110 + defb @00110111 + defb @00111011 + defb @11011111 + defb @11011111 + defb @11101111 + defb @00110011 + defb @00110000 defb @00000000 defb @00000000 defb @00000000 @@ -263,19 +263,19 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 defb @00000000 - defb @00001111 - defb @00111111 - defb @01111111 - defb @01111111 - defb @11111111 - defb @11111111 - defb @11111001 - defb @11111001 - defb @01110000 - defb @01110000 - defb @00110000 defb @00000000 defb @00000000 + defb @00010000 + defb @00111000 + defb @00111100 + defb @00101110 + defb @00110111 + defb @11011011 + defb @11011111 + defb @11101111 + defb @00110011 + defb @00110000 + defb @00000000 defb @00000000 defb @00000000 defb @00000000 @@ -292,8 +292,31 @@ PUBLIC _sprite_protar1 defb @00000000 defb @00000000 -PUBLIC _sprite_protar2 -._sprite_protar2 +._sprite_protar1_f9 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000011 + defb @00001111 + defb @00011111 + defb @00011111 + defb @00111111 + defb @00111111 + defb @00110111 + defb @00111011 + defb @00011101 + defb @11011111 + defb @11101111 + defb @00110011 + defb @00110000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 @@ -301,16 +324,26 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 defb @00000000 - defb @11000000 - defb @11100000 - defb @11100000 defb @00000000 defb @00000000 + +._sprite_protar1_f10 defb @00000000 defb @00000000 - defb @11100000 - defb @11100000 - defb @11000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000011 + defb @00001111 + defb @00011101 + defb @00011111 + defb @00111111 + defb @00111111 + defb @00111110 + defb @00111110 + defb @00011100 + defb @00011100 + defb @00001100 defb @00000000 defb @00000000 defb @00000000 @@ -329,14 +362,22 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 -._sprite_protar2_f2 +._sprite_protar1_f11 defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 - defb @10000000 - defb @10000000 + defb @00000000 + defb @00000011 + defb @00001111 + defb @00011101 + defb @00011111 + defb @00111111 + defb @00111110 + defb @00111100 + defb @00111000 + defb @00010000 defb @00000000 defb @00000000 defb @00000000 @@ -345,8 +386,9 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 defb @00000000 - defb @10000000 - defb @10000000 + defb @00000000 + + defb @00000000 defb @00000000 defb @00000000 defb @00000000 @@ -355,16 +397,32 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 +._sprite_protar1_f12 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 + defb @00000011 + defb @00001111 + defb @00011101 + defb @00011111 + defb @00111111 + defb @00111111 + defb @00111111 + defb @00111111 + defb @00011111 + defb @00011111 + defb @00001111 + defb @00000011 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 -._sprite_protar2_f3 defb @00000000 defb @00000000 defb @00000000 @@ -373,15 +431,27 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 defb @00000000 + +PUBLIC _sprite_protar2 +._sprite_protar2 + defb @00000000 defb @00000000 - defb @10000000 - defb @10000000 defb @00000000 defb @00000000 defb @00000000 + defb @11000000 + defb @01110000 + defb @11111000 + defb @11111000 + defb @11000000 defb @00000000 defb @00000000 + defb @11000000 + defb @11111000 + defb @11111000 + defb @11110000 + defb @11000000 defb @00000000 defb @00000000 defb @00000000 @@ -399,23 +469,32 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 -._sprite_protar2_f4 +._sprite_protar2_f2 + defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 + defb @11100000 + defb @01110000 + defb @11100000 + defb @11000000 + defb @10000000 defb @00000000 defb @00000000 defb @10000000 defb @11000000 - defb @11000000 - defb @11100000 - defb @11100000 defb @11100000 + defb @11110000 defb @11100000 - defb @11000000 - defb @11000000 - defb @10000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 @@ -425,33 +504,94 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 +._sprite_protar2_f3 defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 + defb @11100000 + defb @11111000 + defb @01111100 + defb @11111100 + defb @11111110 + defb @11111110 + defb @11111110 + defb @11111110 + defb @11111100 + defb @11111100 + defb @11111000 + defb @11100000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 defb @00000000 -._sprite_protar2_f5 defb @00000000 defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar2_f4 defb @00000000 defb @00000000 defb @00000000 defb @00110000 - defb @01110000 + defb @00110000 + defb @10011100 + defb @11101100 defb @11110000 + defb @01110000 + defb @10111000 + defb @11111000 + defb @11111000 + defb @11011000 defb @11110000 defb @11110000 defb @11100000 - defb @11100000 - defb @11000000 + defb @10000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar2_f5 + defb @00000000 defb @00000000 defb @00000000 + defb @01110000 + defb @01110000 + defb @10011100 + defb @11101100 + defb @01110000 + defb @10110000 + defb @11111000 + defb @11111000 + defb @11111000 + defb @11011000 + defb @11110000 + defb @11110000 + defb @11100000 + defb @10000000 defb @00000000 defb @00000000 defb @00000000 @@ -473,19 +613,63 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 defb @00000000 + defb @00111000 + defb @00111000 + defb @11001110 + defb @11110110 + defb @01111000 + defb @10111000 + defb @11111100 + defb @11111100 + defb @11111100 + defb @11101100 + defb @11111000 + defb @11111000 + defb @11110000 + defb @11000000 defb @00000000 defb @00000000 - defb @11100000 - defb @11100000 - defb @11110000 - defb @11110000 - defb @11110000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar2_f7 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00110000 + defb @00111000 + defb @00111000 + defb @01111100 + defb @01111100 + defb @11111100 + defb @11111100 + defb @11111000 + defb @10111000 defb @11110000 - defb @11100000 - defb @11100000 defb @11000000 defb @00000000 defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 @@ -495,6 +679,23 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 +._sprite_protar2_f8 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00001000 + defb @00011100 + defb @00111100 + defb @01111100 + defb @11111100 + defb @11111000 + defb @10111000 + defb @11110000 + defb @11000000 defb @00000000 defb @00000000 defb @00000000 @@ -504,23 +705,76 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 -._sprite_protar2_f7 defb @00000000 defb @00000000 defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar2_f9 defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @11000000 - defb @11100000 - defb @11100000 - defb @11110000 defb @11110000 + defb @11111000 + defb @11111000 + defb @11111100 + defb @11111100 + defb @11111100 + defb @11111100 + defb @11111000 + defb @10111000 defb @11110000 - defb @01110000 + defb @11000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar2_f10 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00001100 + defb @11001100 + defb @11110111 + defb @11111011 + defb @11111011 + defb @11011100 + defb @11101100 + defb @01110100 + defb @01111100 + defb @00111000 + defb @00111000 defb @00110000 defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 defb @00000000 defb @00000000 @@ -530,6 +784,23 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 +._sprite_protar2_f11 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00001100 + defb @11001100 + defb @11110111 + defb @11111011 + defb @11011011 + defb @11101100 + defb @01110100 + defb @00111100 + defb @00011100 + defb @00001000 + defb @00000000 defb @00000000 defb @00000000 defb @00000000 @@ -539,25 +810,34 @@ PUBLIC _sprite_protar2 defb @00000000 defb @00000000 -._sprite_protar2_f8 defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 defb @00000000 - defb @11000000 - defb @11100000 - defb @11100000 - defb @11110000 - defb @11110000 - defb @11110000 - defb @11110000 - defb @11100000 - defb @11100000 - defb @11000000 defb @00000000 defb @00000000 + +._sprite_protar2_f12 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00001100 + defb @11001100 + defb @11110111 + defb @11111011 + defb @10111000 + defb @11011100 + defb @11101100 + defb @11111100 + defb @11111100 + defb @11111000 + defb @11111000 + defb @11110000 + defb @11000000 defb @00000000 defb @00000000 defb @00000000 diff --git a/build/prota_sprites.png b/build/prota_sprites.png index 62e4773..9619cc9 100644 Binary files a/build/prota_sprites.png and b/build/prota_sprites.png differ diff --git a/globals.c b/globals.c index d3023c7..52a318c 100644 --- a/globals.c +++ b/globals.c @@ -41,11 +41,12 @@ uint8_t colors[] = {INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, IN uint8_t pill_eaten = NONE; -struct sprite pacman; +struct spritep pacman; struct sprite ghost_red; struct sprite ghost_cyan; struct sprite ghost_magenta; struct sprite ghost_yellow; +struct bonus cherry; struct sprite * ghosts[4] = {&ghost_red, &ghost_cyan, &ghost_magenta, &ghost_yellow}; @@ -58,10 +59,12 @@ uint8_t row; uint8_t col; uint8_t current; uint16_t points = 0; +uint8_t remaining_points; uint8_t frame = 0; uint8_t lives = 0; uint8_t repaint_lives = 1; +uint8_t speed = 5; uint8_t idx; struct sprite * collided_sprite; diff --git a/globals.h b/globals.h index 2f5f41b..6eccc27 100644 --- a/globals.h +++ b/globals.h @@ -10,12 +10,17 @@ #define RIGHTC1 1 #define RIGHTC2 33 -#define LEFTC1 65 -#define LEFTC2 97 -#define UP1 129 -#define UP2 161 -#define DOWN1 193 -#define DOWN2 225 +#define RIGHTC3 65 +#define LEFTC1 97 +#define LEFTC2 129 +#define LEFTC3 161 +#define UP1 193 +#define UP2 225 +#define UP3 257 +#define DOWN1 289 +#define DOWN2 321 +#define DOWN3 353 + #define DECIDED_DIRECTION 1 #define UNDECIDED 0 @@ -60,6 +65,30 @@ struct sprite { void *default_color; }; +struct spritep { + struct sp1_ss* sp; + struct sp1_ss* alt; + uint8_t x; + uint8_t y; + uint16_t offset; + uint16_t currentoffset; + uint8_t active; + int8_t dx; + int8_t dy; + uint8_t direction; + uint8_t default_x; + uint8_t default_y; + void *default_color; +}; + +struct bonus { + struct sp1_ss* sp; + uint8_t x; + uint8_t y; + uint8_t offset; + uint8_t showing; +}; + // it comes from built binaries: extern uint8_t sprite_protar1[]; extern uint8_t sprite_protar2[]; @@ -67,6 +96,10 @@ extern uint8_t sprite_protar2[]; extern uint8_t sprite_protar_dead1[]; extern uint8_t sprite_protar_dead2[]; +// extra +extern uint8_t cerezas1[]; +extern uint8_t cerezas2[]; + // red ghost extern uint8_t red_ghost1[]; extern uint8_t red_ghost2[]; @@ -91,12 +124,13 @@ extern uint8_t correspondence[]; extern uint8_t colors[]; extern uint8_t pill_eaten; -extern struct sprite pacman; +extern struct spritep pacman; extern struct sprite ghost_red; extern struct sprite ghost_cyan; extern struct sprite ghost_magenta; extern struct sprite ghost_yellow; extern struct sprite * ghosts[4]; +extern struct bonus cherry; extern JOYFUNC joy; extern udk_t joy_keys; @@ -106,7 +140,8 @@ extern uint8_t row; extern uint8_t col; extern uint8_t current; extern uint16_t points; - +extern uint8_t remaining_points; +extern uint8_t speed; extern uint8_t frame; extern uint8_t lives; diff --git a/int.c b/int.c index 177cff7..ef12ee2 100644 --- a/int.c +++ b/int.c @@ -1,5 +1,6 @@ #include #include "int.h" +#include "globals.h" #include #include @@ -12,8 +13,10 @@ unsigned char pick; void wait(void) { - while (abs(tick - timer) < WFRAMES) + while (abs(tick - timer) < speed) { intrinsic_halt(); + in = (joy)(&joy_keys); + } timer = tick; } diff --git a/int.h b/int.h index f518460..2ea1f41 100644 --- a/int.h +++ b/int.h @@ -14,7 +14,7 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL #ifndef WFRAMES // WFRAMES 3, are 50/3 -> 25 FPS. -#define WFRAMES 3 +#define WFRAMES 2 #endif #define clock(x) (tick) diff --git a/logic.c b/logic.c index 81ce399..40ffda3 100644 --- a/logic.c +++ b/logic.c @@ -1,5 +1,20 @@ #include "logic.h" #include "int.h" +#include + + +void show_cherry() { + cherry.y = 21; + cherry.x = 14; + cherry.showing = 100; +} + +void hide_cherry() { + cherry.y = 21; + cherry.x = 32; + cherry.showing = 0; + sp1_MoveSprAbs(cherry.sp, &full_screen, (void*) 0, cherry.y, cherry.x, 0, 0); +} void check_keys() @@ -9,34 +24,48 @@ void check_keys() if ((in & IN_STICK_UP) && allow_next(map[row - 1][col])) { pacman.dy = -1; pacman.currentoffset = UP1; + pacman.direction = DIR_UP; } else if((in & IN_STICK_DOWN) && allow_next(map[row + 1][col])) { pacman.dy = 1; pacman.currentoffset = DOWN1; + pacman.direction = DIR_DOWN; } if((in & IN_STICK_LEFT) && allow_next(map[row][col - 1])) { pacman.dx = -1; pacman.currentoffset = LEFTC1; + pacman.direction = DIR_LEFT; } else if((in & IN_STICK_RIGHT) && allow_next(map[row][col + 1])) { pacman.dx = 1; pacman.currentoffset = RIGHTC1; + pacman.direction = DIR_RIGHT; } } +void all_ghosts_go_home() { + uint8_t i; + for(i = 0; i != 4; ++i) { + set_eaten(ghosts[i]); + sp1_MoveSprAbs(ghosts[i]->sp, &full_screen, (void*) ghosts[i]->offset, ghosts[i]->default_y, ghosts[i]->default_x, 0, 0); + } +} + +void nampac_go_home() { + pacman.y = 21; + pacman.x = 14; + pacman.dx = 0; + pacman.dy = 0; + pacman.offset = RIGHTC1; +} + void loose_a_live() { uint8_t i, j; + hide_cherry(); repaint_lives = 1; --lives; - set_eaten(&ghost_magenta); - set_eaten(&ghost_red); - set_eaten(&ghost_cyan); - set_eaten(&ghost_yellow); - - for(i = 0; i != 4; ++i) { - sp1_MoveSprAbs(ghosts[i]->sp, &full_screen, (void*) ghosts[i]->offset, ghosts[i]->default_y, ghosts[i]->default_x, 0, 0); - } + all_ghosts_go_home(); // prota dead animation, first hide the sprite from the screen sp1_MoveSprAbs(pacman.sp, &full_screen, (void*) pacman.offset, pacman.y, 32, 0, 0); @@ -52,10 +81,7 @@ void loose_a_live() { sp1_MoveSprAbs(pacman.alt, &full_screen, (void*) col, pacman.y, 32, 0, 0); sp1_UpdateNow(); - pacman.y = 21; - pacman.x = 14; - pacman.dx = 0; - pacman.dy = 0; + nampac_go_home(); } uint8_t allow_next(uint8_t next) { @@ -222,7 +248,7 @@ void move_ghosts() { row = ghosts[idx]->y + 1; switch(idx) { - case 0: // Rojo: Intenta estár detrás de Pac-Man en modo "Acoso" + case 0: // Rojo: Intenta estár detras de Pac-Man en modo "Acoso" move_one_ghost(40, 80, 40, 100); break; case 1: @@ -237,10 +263,19 @@ void move_ghosts() { // "a su bola" move_one_ghost(125, 255, 125, 255); } +} +void next_level() { + zx_border(INK_BLUE); + bit_beepfx_di_fastcall(BEEPFX_SCORE); + zx_border(INK_BLACK); + remaining_points = 238; + nampac_go_home(); + all_ghosts_go_home(); } + void check_fsm() { random_value = rand(); row = pacman.y + 1; @@ -262,9 +297,10 @@ void check_fsm() { if(current == 9) { pick += 1; - points += 10; // ten points each + points += 5; // 5 points each dot + --remaining_points; } else if(current == 11) { - points += 50; // energizers - are worth 50 points each + points += 20; // energizers - are worth 20 points each pill_eaten = 125; for(idx = 0; idx != 4; ++idx) { if(ghosts[idx]->active == ACTIVE) { @@ -284,29 +320,30 @@ void check_fsm() { } } - if(ghosts[frame]->y == 12) { - if(ghosts[frame]->x < 2 && ghosts[frame]->dx == -1) { - ghosts[frame]->x = 29; - } else if(ghosts[frame]->x > 28 && ghosts[frame]->dx == 1) { - ghosts[frame]->x = 1; - } + if(pacman.direction == DIR_UP && allow_next(map[row - 1][col])) { + --pacman.y; + } else if(pacman.direction == DIR_DOWN && allow_next(map[row + 1][col])) { + ++pacman.y; + } else if(pacman.direction == DIR_LEFT && allow_next(map[row][col - 1])) { + --pacman.x; + } else if(pacman.direction == DIR_RIGHT && allow_next(map[row][col + 1])) { + ++pacman.x; } - - if(allow_next(map[row + pacman.dy][col + pacman.dx])) { + /*if(allow_next(map[row + pacman.dy][col + pacman.dx])) { pacman.y += pacman.dy; pacman.x += pacman.dx; } else if (pacman.dy != 0) { pacman.dy = 0; pacman.dx = 0; - } + }*/ - if((tick & 1) == 0) { - pacman.offset = pacman.currentoffset + 32; - ghosts[frame]->offset = ghosts[frame]->currentoffset + 32; - } else { + if(frame == 0) { pacman.offset = pacman.currentoffset; - ghosts[frame]->offset = ghosts[frame]->currentoffset; + } else if(frame == 1) { + pacman.offset = pacman.currentoffset + 32; + } else if(frame == 2) { + pacman.offset = pacman.currentoffset + 64; } // IA FOR GHOSTS @@ -320,6 +357,22 @@ void check_fsm() { } else if(ghosts[idx]->active <= JAILED) { --ghosts[idx]->active; } + // side change + if(ghosts[idx]->y == 12) { + if(ghosts[idx]->x < 2 && ghosts[idx]->dx == -1) { + ghosts[idx]->x = 29; + } else if(ghosts[idx]->x > 28 && ghosts[idx]->dx == 1) { + ghosts[idx]->x = 1; + } + } + + if(frame == 0) { + ghosts[idx]->offset = ghosts[idx]->currentoffset; + } else if(frame == 1) { + ghosts[idx]->offset = ghosts[idx]->currentoffset + 32; + } else if(frame == 2) { + ghosts[idx]->offset = ghosts[idx]->currentoffset; + } } // while has eaten pill if(pill_eaten != NONE) { @@ -339,4 +392,25 @@ void check_fsm() { sp1_IterateSprChar(ghost_magenta.sp, initialiseColourGhostMagenta); sp1_IterateSprChar(ghost_yellow.sp, initialiseColourYellow); } + + if(cherry.showing > 0) { + if(pacman.x == cherry.x && pacman.y == cherry.y) { + hide_cherry(); + points += 10; + } + --cherry.showing; + if(cherry.showing == 0) { + hide_cherry(); + } + } else if(random_value == 200) { + show_cherry(); + zx_border(INK_RED); + zx_border(INK_BLACK); + } + + if(remaining_points == 0) { + // level finished! + next_level(); + } } + diff --git a/logic.h b/logic.h index 35fb87d..bd409d5 100644 --- a/logic.h +++ b/logic.h @@ -14,5 +14,8 @@ extern void check_fsm(); extern uint8_t allow_next(uint8_t next); extern void set_eaten(struct sprite * for_who); - +extern void hide_cherry(); +extern void show_cherry(); +extern void nampac_go_home(); +extern void all_ghosts_go_home(); #endif diff --git a/msnampac.c b/msnampac.c index e4f4774..3e2eedf 100644 --- a/msnampac.c +++ b/msnampac.c @@ -20,38 +20,33 @@ void all_lives_lost() { sp1_Invalidate(&full_screen); lives = 5; points = 0; - pacman.y = 21; - pacman.x = 14; + nampac_go_home(); repaint_lives = 1; + remaining_points = 238; ghost_red.offset = GHOST_RED; ghost_red.currentoffset = GHOST_RED; ghost_red.default_color = initialiseColourGhostRed; ghost_red.default_y = 15; ghost_red.default_x = 14; - set_eaten(&ghost_red); ghost_cyan.offset = GHOST_CYAN; ghost_cyan.currentoffset = GHOST_CYAN; ghost_cyan.default_color = initialiseColourGhostCyan; ghost_cyan.default_y = 15; ghost_cyan.default_x = 12; - set_eaten(&ghost_cyan); ghost_magenta.offset = GHOST_MAGENTA; ghost_magenta.currentoffset = GHOST_CYAN; ghost_magenta.default_color = initialiseColourGhostMagenta; ghost_magenta.default_y = 15; ghost_magenta.default_x = 16; - set_eaten(&ghost_magenta); ghost_yellow.offset = GHOST_YELLOW; ghost_yellow.currentoffset = GHOST_YELLOW; ghost_yellow.default_color = initialiseColourYellow; ghost_yellow.default_y = 15; ghost_yellow.default_x = 18; - set_eaten(&ghost_yellow); - for(row = 0; row != 24; ++row) { for(col = 0; col != 32; ++col) { @@ -79,9 +74,8 @@ void all_lives_lost() { sp1_PrintAt(0, 5, INK_RED | PAPER_BLACK, 'E'); sp1_PrintAt(0, 6, INK_RED | PAPER_BLACK, 'S'); - for(idx = 0; idx != 4; ++idx) { - sp1_MoveSprAbs(ghosts[idx]->sp, &full_screen, (void*) ghosts[idx]->offset, ghosts[idx]->y, ghosts[idx]->x, 0, 0); - } + all_ghosts_go_home(); + sp1_UpdateNow(); @@ -129,10 +123,12 @@ int main() pacman.offset = 1; pacman.currentoffset = 1; - ghost_red.sp = add_ghost_red_sprite(); - ghost_cyan.sp = add_ghost_cyan_sprite(); - ghost_magenta.sp = add_ghost_magenta_sprite(); - ghost_yellow.sp = add_ghost_yellow_sprite(); + ghost_red.sp = add_ghost_sprite(); + ghost_cyan.sp = add_ghost_sprite(); + ghost_magenta.sp = add_ghost_sprite(); + ghost_yellow.sp = add_ghost_sprite(); + cherry.sp = add_cherry_sprite(); + hide_cherry(); // painting an UDG is just assigning it to any char // row, col, char @@ -152,7 +148,9 @@ int main() for(idx = 0; idx != 4; ++idx) { 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); + } if(repaint_lives) { sp1_PrintAtInv(0, 8, INK_CYAN | PAPER_BLACK, 48 + lives); @@ -163,7 +161,7 @@ int main() frame += 1; - if(frame == 5) { + if(frame == 3) { // frame will go 0, 1, 2 frame = 0; print_points(); } diff --git a/sprites.c b/sprites.c index 07dcb9d..1c5868b 100644 --- a/sprites.c +++ b/sprites.c @@ -89,29 +89,24 @@ struct sp1_ss * add_ghost_sprite() { return sp; } -struct sp1_ss * add_ghost_red_sprite() { - struct sp1_ss * sp = add_ghost_sprite(); - - - return sp; -} - -struct sp1_ss * add_ghost_cyan_sprite() { - struct sp1_ss * sp = add_ghost_sprite(); - - - return sp; +void initialiseColourGreenRed(unsigned int count, struct sp1_cs *c) +{ + c->attr_mask = SP1_AMASK_INK; + if(count < 2) { + c->attr = INK_GREEN; + } else { + c->attr = INK_RED; + } } -struct sp1_ss * add_ghost_magenta_sprite() { - struct sp1_ss * sp = add_ghost_sprite(); - +struct sp1_ss * add_cherry_sprite() { + struct sp1_ss * sp; + sp = sp1_CreateSpr(SP1_DRAW_LOAD1LB, SP1_TYPE_1BYTE, 3, (int)cerezas1, 1); + sp1_AddColSpr(sp, SP1_DRAW_LOAD1, SP1_TYPE_1BYTE, (int)cerezas2, 1); - return sp; -} + sp1_AddColSpr(sp, SP1_DRAW_LOAD1RB, SP1_TYPE_1BYTE, 0, 0); -struct sp1_ss * add_ghost_yellow_sprite() { - struct sp1_ss * sp = add_ghost_sprite(); + sp1_IterateSprChar(sp, initialiseColourGreenRed); return sp; diff --git a/sprites.h b/sprites.h index a136c87..d54a3a4 100644 --- a/sprites.h +++ b/sprites.h @@ -15,6 +15,7 @@ extern struct sp1_ss * add_ghost_red_sprite(); extern struct sp1_ss * add_ghost_cyan_sprite(); extern struct sp1_ss * add_ghost_magenta_sprite(); extern struct sp1_ss * add_ghost_yellow_sprite(); +extern struct sp1_ss * add_cherry_sprite(); extern void initialiseColourBlue(unsigned int count, struct sp1_cs *c); extern void initialiseColourWhite(unsigned int count, struct sp1_cs *c);