From 110f83b420279b28a9fe40ecf73bd6a7881f4c1f Mon Sep 17 00:00:00 2001 From: derek mcquay Date: Sun, 10 Apr 2016 09:23:30 -0700 Subject: [PATCH] adding in ecen427 space invaders final lab --- ecen427/alien.c | 337 +++++++++++++ ecen427/alien.h | 158 ++++++ ecen427/alienDeathSound.c | 18 + ecen427/bullet.c | 226 +++++++++ ecen427/bullet.h | 109 +++++ ecen427/bunker.c | 638 +++++++++++++++++++++++++ ecen427/bunker.h | 440 +++++++++++++++++ ecen427/global.c | 284 +++++++++++ ecen427/global.h | 16 + ecen427/lscript.ld | 213 +++++++++ ecen427/nes.c | 14 + ecen427/nes.h | 123 +++++ ecen427/pit.c | 14 + ecen427/pit.h | 129 +++++ ecen427/platform.c | 81 ++++ ecen427/platform.h | 27 ++ ecen427/platform_config.h | 8 + ecen427/score.c | 618 ++++++++++++++++++++++++ ecen427/score.h | 402 ++++++++++++++++ ecen427/shoot.c | 3 + ecen427/sounds.c | 215 +++++++++ ecen427/sounds.h | 47 ++ ecen427/spaceShipDeathSound.c | 3 + ecen427/spaceShipSound.c | 3 + ecen427/tank.c | 111 +++++ ecen427/tank.h | 77 +++ ecen427/tankDeath.c | 383 +++++++++++++++ ecen427/ufo.c | 255 ++++++++++ ecen427/ufo.h | 134 ++++++ ecen427/vdma.c | 872 ++++++++++++++++++++++++++++++++++ ecen427/xac97_l.c | 180 +++++++ ecen427/xac97_l.h | 291 ++++++++++++ 32 files changed, 6429 insertions(+) create mode 100644 ecen427/alien.c create mode 100644 ecen427/alien.h create mode 100644 ecen427/alienDeathSound.c create mode 100644 ecen427/bullet.c create mode 100644 ecen427/bullet.h create mode 100644 ecen427/bunker.c create mode 100644 ecen427/bunker.h create mode 100644 ecen427/global.c create mode 100644 ecen427/global.h create mode 100644 ecen427/lscript.ld create mode 100644 ecen427/nes.c create mode 100644 ecen427/nes.h create mode 100644 ecen427/pit.c create mode 100644 ecen427/pit.h create mode 100644 ecen427/platform.c create mode 100644 ecen427/platform.h create mode 100644 ecen427/platform_config.h create mode 100644 ecen427/score.c create mode 100644 ecen427/score.h create mode 100644 ecen427/shoot.c create mode 100644 ecen427/sounds.c create mode 100644 ecen427/sounds.h create mode 100644 ecen427/spaceShipDeathSound.c create mode 100644 ecen427/spaceShipSound.c create mode 100644 ecen427/tank.c create mode 100644 ecen427/tank.h create mode 100644 ecen427/tankDeath.c create mode 100644 ecen427/ufo.c create mode 100644 ecen427/ufo.h create mode 100644 ecen427/vdma.c create mode 100644 ecen427/xac97_l.c create mode 100644 ecen427/xac97_l.h diff --git a/ecen427/alien.c b/ecen427/alien.c new file mode 100644 index 0000000..5a7d80c --- /dev/null +++ b/ecen427/alien.c @@ -0,0 +1,337 @@ +#include "alien.h" + +int leftLim; +int rightLim; + +void renderAlien(unsigned int* framePointer) { + if(getGuise() == 0) { + setGuise(1); + renderAlien1(framePointer); + }else { + setGuise(0); + renderAlien2(framePointer); + } +} + +void renderAlien1(unsigned int* framePointer) { + short alienx, alieny; + alienx = getAlienBlockPositionX(); + alieny = getAlienBlockPositionY(); + short row=0, col=0; + short line = 0; + short position = 0; + short* aliens = getAliens(); + for(line = 0; line < 10; line++) { + if(line % 2 == 1) { + alieny += 10; + } + else { + if(line == 0) { + for(row=0; row<16; row++) { + short position_helper = -1; + for(col=0; col<352; col++) { + if (((topAlien1[row%16] & (1<<(32-1-col)))) && aliens[position+position_helper] == 1) { + framePointer[alieny*640 + alienx] = 0x00FFFFFF; + } +// else if(aliens[position+position_helper] == 0) { +// +// } + else { + framePointer[alieny*640 + alienx] = 0x00000000; + } + if(col % 32 == 0) { + position_helper++; + } + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } + } + if(line == 2 || line == 4) { + position += 11; + for(row=0; row<16; row++) { + short position_helper = -1; + for(col=0; col<352; col++) { + if (((middleAlien1[row%16] & (1<<(32-1-col)))) && aliens[position+position_helper] == 1) { + framePointer[alieny*640 + alienx] = 0x00FFFFFF; + } +// else if(aliens[position+position_helper] == 0) { +// +// } + else { + framePointer[alieny*640 + alienx] = 0x00000000; + } + if(col % 32 == 0) { + position_helper++; + } + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } + } + if(line == 6 || line == 8) { + position += 11; + for(row=0; row<16; row++) { + short position_helper = -1; + for(col=0; col<352; col++) { + if (((bottomAlien1[row%16] & (1<<(32-1-col))))&& aliens[position+position_helper] == 1) { + framePointer[alieny*640 + alienx] = 0x00FFFFFF; + } +// else if( aliens[position+position_helper] == 0) { +// +// } + else { + framePointer[alieny*640 + alienx] = 0x00000000; + } + if(col % 32 == 0) { + position_helper++; + } + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } + } + } + } +} + +void renderAlien2(unsigned int* framePointer) { + short alienx, alieny; + alienx = getAlienBlockPositionX(); + alieny = getAlienBlockPositionY(); + short row=0, col=0; + short line = 0; + short position = 0; + short* aliens = getAliens(); + for(line = 0; line < 10; line++) { + if(line % 2 == 1) { + alieny += 10; + } + else { + if(line == 0) { + for(row=0; row<16; row++) { + short position_helper = -1; + for(col=0; col<352; col++) { + if (((topAlien2[row%16] & (1<<(32-1-col)))) && aliens[position+position_helper] == 1) { + framePointer[alieny*640 + alienx] = 0x00FFFFFF; + } +// else if(aliens[position+position_helper] == 0) { +// +// } + else { + framePointer[alieny*640 + alienx] = 0x00000000; + } + if(col % 32 == 0) { + position_helper++; + } + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } + } + if(line == 2 || line == 4) { + position += 11; + for(row=0; row<16; row++) { + short position_helper = -1; + for(col=0; col<352; col++) { + if (((middleAlien2[row%16] & (1<<(32-1-col))))&& aliens[position+position_helper] == 1) { + framePointer[alieny*640 + alienx] = 0x00FFFFFF; + } +// else if(aliens[position+position_helper] == 0) { +// +// } + else { + framePointer[alieny*640 + alienx] = 0x00000000; + } + if(col % 32 == 0) { + position_helper++; + } + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } + } + if(line == 6 || line == 8) { + position += 11; + for(row=0; row<16; row++) { + short position_helper = -1; + for(col=0; col<352; col++) { + if (((bottomAlien2[row%16] & (1<<(32-1-col))))&& aliens[position+position_helper] == 1) { + framePointer[alieny*640 + alienx] = 0x00FFFFFF; + } +// else if(aliens[position+position_helper] == 0) { +// +// } + else { + framePointer[alieny*640 + alienx] = 0x00000000; + } + if(col % 32 == 0) { + position_helper++; + } + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } + } + } + } +} + +void blankAlien(unsigned int* framePointer){ + short alienx, alieny; + alienx = getAlienBlockPositionX(); + alieny = getAlienBlockPositionY(); + short row=0, col=0; + for(row = 0; row < 130; row++){ + for(col = 0; col < 352; col++){ + framePointer[alieny*640 + alienx] = 0x00000000; + alienx++; + } + alienx=getAlienBlockPositionX(); + alieny++; + } +} + +void dyingAlien(unsigned int* framePointer, short alienx, short alieny) { + short row=0, col=0; + for(row = 0; row < 16; row++){ + for(col = 0; col < 32; col++){ + if ((dying_alien[row%16] & (1<<(32-1-col)))) { + framePointer[(alieny+row)*640 + alienx+col] = 0x00FFFFFE; + } else { + framePointer[(alieny+row)*640 + alienx+col] = 0x00000000; + } + } + } +} + +void dyingAlienHelper(unsigned int* framePointer, short alienx, short alieny) { + short row=0, col=0; + for(row = 0; row < 16; row++){ + for(col = 0; col < 32; col++){ + framePointer[(alieny+row)*640 + alienx+col] = 0x00000000; + } + } +} + +int columnCheck(int value) { + short* aliens = getAliens(); + if(aliens[value] == 0 && aliens[value+11] == 0 && aliens[value+22] == 0 && aliens[value+33] == 0 && aliens[value+44] == 0) { + return 0; + } + return 1; +} + +int setRightMax() { + int max = 352; + if(!columnCheck(10)) { + max = 320; + if(!columnCheck(9)) { + max = 288; + if(!columnCheck(8)) { + max = 256; + if(!columnCheck(7)) { + max = 224; + if(!columnCheck(6)) { + max = 192; + if(!columnCheck(5)) { + max = 160; + if(!columnCheck(4)) { + max = 128; + if(!columnCheck(3)) { + max = 96; + if(!columnCheck(2)) { + max = 64; + if(!columnCheck(1)) { + max = 32; + if(!columnCheck(0)) { + max = 0; + } + } + } + } + } + } + } + } + } + } + } + return max; +} + +int setLeftMin() { + int min = 0; + if(!columnCheck(0)) { + min = 32; + if(!columnCheck(1)) { + min = 64; + if(!columnCheck(2)) { + min = 96; + if(!columnCheck(3)) { + min = 128; + if(!columnCheck(4)) { + min = 160; + if(!columnCheck(5)) { + min = 192; + if(!columnCheck(6)) { + min = 224; + if(!columnCheck(7)) { + min = 256; + if(!columnCheck(8)) { + min = 288; + if(!columnCheck(9)) { + min = 320; + if(!columnCheck(10)) { + min = 352; + } + } + } + } + } + } + } + } + } + } + } + return min; +} + +void moveAlien(unsigned int* framePointer) { + short dir = getDirection(); + short alienx, alieny; + alienx = getAlienBlockPositionX(); + alieny = getAlienBlockPositionY(); + int right = setRightMax(); + if((alienx+right) == 640 && dir == 0) { + setDirection(1); + blankAlien(framePointer); + alieny += 8; + setAlienBlockPosition(alienx, alieny); + + } + int left = 0 - setLeftMin(); + if(alienx == left && dir == 1) { + setDirection(0); + blankAlien(framePointer); + alieny += 8; + setAlienBlockPosition(alienx, alieny); + + } + if(dir == 0) { + alienx += 4; + setAlienBlockPosition(alienx, alieny); + } + else { + alienx -= 4; + setAlienBlockPosition(alienx, alieny); + } +} + diff --git a/ecen427/alien.h b/ecen427/alien.h new file mode 100644 index 0000000..1d32795 --- /dev/null +++ b/ecen427/alien.h @@ -0,0 +1,158 @@ +#ifndef ALIEN_H_ +#define ALIEN_H_ +#define ALIEN_HEIGHT 16 + +// Packs each horizontal line of the figures into a single 32 bit word. +#define packWord32(b31,b30,b29,b28,b27,b26,b25,b24,b23,b22,b21,b20,b19,b18,b17,b16,b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0) \ +((b31 << 31) | (b30 << 30) | (b29 << 29) | (b28 << 28) | (b27 << 27) | (b26 << 26) | (b25 << 25) | (b24 << 24) | \ + (b23 << 23) | (b22 << 22) | (b21 << 21) | (b20 << 20) | (b19 << 19) | (b18 << 18) | (b17 << 17) | (b16 << 16) | \ + (b15 << 15) | (b14 << 14) | (b13 << 13) | (b12 << 12) | (b11 << 11) | (b10 << 10) | (b9 << 9 ) | (b8 << 8 ) | \ + (b7 << 7 ) | (b6 << 6 ) | (b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 ) ) + +int topAlien1[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0), +}; + +int topAlien2[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0), +}; + +int middleAlien1[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0), +}; + +int middleAlien2[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0), +}; + +int bottomAlien1[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0), +}; + +int bottomAlien2[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0), +}; + +int dying_alien[ALIEN_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; + +void renderAlien(unsigned int*); +void renderAlien1(unsigned int*); +void renderAlien2(unsigned int*); +void blankAlien(unsigned int*); +void moveAlien(unsigned int*); + +#endif /* ALIEN_H_ */ diff --git a/ecen427/alienDeathSound.c b/ecen427/alienDeathSound.c new file mode 100644 index 0000000..189e045 --- /dev/null +++ b/ecen427/alienDeathSound.c @@ -0,0 +1,18 @@ +int alienDeathSound_soundData[] = {128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,144,164,145,111,95,91,100,106,126,134,108,109,123,160,158,118,101,144,189,110,79,154,202,117,16,96,208,187,65,100,192,175,93,0,106,253,137,17,140,242,103,1,134,255,134,4,110,230,118,1,149,255,89,6,160,255,110,0,60,177,255,81,27,207,170,43,61,200,179,23,104,245,112,11,102,210,217,39,73,237,114,29,57,173,255,91,0,145,255,138,10,62,171,252,84,0,172,244,46,47,207,190,74,0,141,255,147,16,65,191,215,30,84,224,163,78,0,128,255,124,0,149,255,102,0,138,249,169,63,0,166,255,62,24,195,229,33,78,224,163,70,0,145,255,100,0,161,255,92,0,163,255,95,0,134,246,191,77,0,125,255,130,0,88,198,226,95,0,122,255,158,43,53,213,178,21,99,214,200,49,39,198,214,75,0,131,255,134,6,104,219,179,18,105,251,104,4,106,228,204,45,51,185,247,76,0,178,244,39,52,199,220,85,0,105,255,182,35,99,254,96,0,118,207,243,84,0,137,255,124,0,140,253,121,43,19,162,255,147,15,60,180,255,62,26,196,222,91,0,135,255,96,0,178,255,76,6,179,255,80,0,166,255,108,0,110,255,92,0,122,228,215,57,24,181,252,75,0,118,255,134,1,133,214,188,65,0,163,255,95,0,143,255,126,34,48,193,255,65,22,208,201,50,31,209,199,42,70,190,251,57,11,190,221,87,0,140,255,129,27,88,209,202,54,28,186,251,94,0,144,255,82,4,190,255,60,19,202,220,42,55,212,186,35,78,221,169,27,95,213,189,75,0,146,255,113,0,169,255,83,0,118,241,164,25,107,202,212,79,0,133,255,153,42,62,216,164,7,148,229,154,54,0,185,255,65,9,197,232,54,34,189,244,80,0,113,238,210,40,90,214,159,51,2,197,218,59,31,192,255,70,8,168,255,122,0,117,235,92,7,130,234,188,16,124,229,121,46,15,178,255,104,0,142,255,87,0,156,254,131,25,100,212,183,64,6,164,255,107,8,97,179,255,99,0,121,229,155,44,87,214,181,60,35,175,255,119,15,50,167,255,98,0,171,241,113,14,97,238,127,19,159,252,91,0,162,251,126,21,102,212,172,62,15,174,255,90,0,163,229,169,49,14,189,231,78,0,147,255,127,31,120,221,148,36,86,227,127,20,131,215,195,38,70,205,178,66,0,167,255,103,5,139,215,175,73,0,176,255,122,15,104,213,164,68,0,179,255,73,22,197,245,65,0,175,255,88,0,167,242,116,39,41,198,242,67,12,171,255,105,0,149,224,142,29,88,195,198,63,0,192,241,66,10,180,255,90,0,177,250,63,24,191,236,85,0,135,247,98,29,134,222,197,50,52,200,209,58,19,196,230,59,20,175,255,103,0,158,239,80,0,148,209,206,71,0,192,234,56,28,189,255,85,0,149,237,135,51,38,174,255,92,0,145,211,150,63,7,189,255,61,17,184,255,119,21,52,182,240,63,0,190,245,86,4,126,229,169,62,55,195,246,55,13,192,243,65,0,181,251,118,42,38,187,255,68,0,186,255,131,45,29,182,255,83,0,148,211,187,81,0,181,255,84,9,158,240,91,11,181,249,99,19,117,229,107,33,121,215,206,38,87,213,153,47,47,211,177,32,119,225,128,24,145,236,91,31,121,208,215,61,0,181,255,85,2,165,228,99,28,92,213,194,39,108,211,164,66,0,189,255,109,42,53,202,227,62,20,179,255,99,20,97,192,219,59,1,190,255,84,23,83,186,255,62,0,191,236,66,0,193,242,59,28,208,212,56,30,181,255,65,8,198,221,46,31,204,203,42,63,213,176,53,49,194,251,60,6,167,246,92,19,133,199,211,60,0,170,252,126,32,104,209,149,41,81,204,192,42,74,218,159,49,73,193,250,78,0,170,235,67,15,177,252,87,31,126,195,243,68,0,180,230,64,8,158,242,130,40,109,191,223,64,0,170,228,151,47,38,200,213,63,0,152,243,167,39,124,222,105,54,43,190,255,57,14,175,235,142,28,91,194,171,46,23,201,240,69,7,143,239,145,34,157,238,79,41,86,190,255,59,0,191,234,112,40,43,197,248,57,3,194,255,70,17,191,232,83,13,107,209,190,54,41,209,217,52,25,205,239,54,20,192,251,113,29,43,190,253,52,0,145,235,165,34,133,224,116,33,94,212,165,33,99,230,109,23,182,233,110,32,106,218,148,30,128,232,86,15,191,240,96,42,73,201,252,45,6,208,238,53,0,157,247,130,41,104,190,243,42,0,176,222,140,44,6,201,255,57,0,169,216,175,49,16,217,203,32,72,213,185,45,51,226,176,36,89,201,250,69,0,177,227,53,21,152,245,149,39,94,200,250,59,0,134,216,146,27,144,224,121,45,46,214,240,31,64,225,157,40,91,205,206,43,16,212,254,75,0,160,236,78,37,118,215,215,35,68,209,196,46,2,209,241,60,1,174,249,80,38,139,213,221,43,0,182,242,134,20,100,205,161,49,5,209,255,44,34,223,219,44,21,187,255,64,25,136,225,168,15,134,204,139,34,36,210,219,50,6,216,237,34,58,209,222,53,0,188,230,140,36,65,227,142,41,86,218,211,29,82,218,165,37,51,206,239,34,3,220,214,41,33,203,255,54,4,172,232,98,25,145,212,137,28,93,209,173,42,23,224,207,27,94,219,179,50,6,198,255,97,26,149,222,92,34,103,212,212,39,27,211,252,69,0,160,225,89,30,132,219,163,37,75,218,195,39,36,228,196,32,84,226,152,25,130,209,151,39,48,228,167,40,69,209,251,38,22,214,224,35,2,170,241,104,26,161,204,178,41,0,207,250,90,23,118,224,112,33,144,222,137,51,53,206,254,55,4,183,214,132,46,5,213,255,42,30,172,231,167,32,45,213,202,17,86,227,113,49,85,213,252,29,32,229,189,40,32,191,254,83,13,165,220,73,35,108,222,208,34,63,219,213,35,14,195,235,137,43,0,201,255,45,34,159,229,161,30,83,220,162,41,54,205,248,38,19,177,224,170,31,25,226,198,31,71,215,236,38,0,206,237,52,31,216,217,34,22,218,249,74,16,156,222,62,28,216,241,68,17,142,220,89,19,191,227,81,42,84,207,255,35,0,180,207,157,33,51,223,180,38,42,226,230,23,63,222,188,40,9,205,255,66,45,107,209,252,26,0,213,227,84,18,140,213,132,51,24,208,255,65,39,213,222,40,26,115,215,242,27,21,224,225,48,11,155,229,123,47,119,220,168,23,121,212,129,46,25,204,255,77,29,170,206,124,46,24,202,255,63,37,208,219,46,17,166,223,91,35,179,228,70,41,135,215,214,22,20,230,192,28,83,214,191,30,32,227,207,30,71,229,169,40,61,199,248,70,19,153,205,123,42,78,221,193,22,104,209,169,42,6,215,246,58,41,203,218,46,17,192,221,73,41,135,227,154,45,75,202,242,59,12,173,201,45,44,149,232,171,40,72,208,230,27,10,215,203,38,45,217,226,30,31,217,210,36,26,202,223,134,45,34,227,213,32,65,221,194,36,47,198,231,115,24,93,197,170,32,54,228,179,44,56,198,238,128,44,39,213,227,23,44,218,212,46,20,163,220,104,61,101,212,245,43,26,106,201,236,30,15,213,218,55,46,122,214,203,24,73,215,163,37,66,224,174,42,69,198,235,92,42,84,200,226,27,23,212,209,65,38,151,217,98,45,188,210,94,61,70,210,242,65,47,73,203,247,27,38,145,206,219,30,16,155,224,152,44,116,203,177,37,28,198,227,82,47,153,199,123,44,103,219,130,42,169,197,120,52,41,188,239,80,49,181,206,68,45,163,196,166,35,37,227,180,41,92,221,170,41,101,211,172,46,40,199,223,53,60,138,218,182,27,106,201,130,49,49,188,234,115,46,137,203,88,49,174,196,119,53,65,210,210,31,32,194,214,72,51,198,199,50,43,167,208,79,50,188,205,85,49,136,193,160,43,33,217,220,79,55,103,206,199,36,49,219,189,41,76,213,198,36,38,183,216,99,62,89,202,234,47,40,167,198,94,45,182,194,90,60,69,214,218,44,77,210,188,33,45,139,213,205,36,50,217,191,42,43,185,215,90,69,100,204,220,34,61,208,186,41,37,168,206,128,57,113,205,172,41,68,220,163,50,83,206,215,48,41,162,194,124,62,70,190,224,65,59,205,184,41,52,208,199,61,49,145,202,112,61,147,202,142,47,105,204,147,45,100,207,156,47,89,206,176,33,106,205,116,64,85,197,218,62,59,124,200,179,33,92,207,137,49,110,194,170,40,59,219,168,47,93,206,186,39,52,149,213,184,37,66,209,191,45,42,202,184,50,73,133,224,186,35,112,191,150,45,42,201,206,70,62,160,194,118,60,105,207,172,46,67,205,195,44,72,206,181,44,49,181,200,107,66,116,198,174,43,51,164,216,121,51,175,179,89,61,95,210,158,53,100,205,186,39,51,169,206,119,65,88,183,211,59,60,200,176,59,61,116,203,190,41,75,212,177,46,59,197,196,65,68,164,195,105,57,168,181,87,66,109,201,191,40,51,192,194,120,64,80,205,203,50,54,195,182,79,73,99,210,190,50,83,203,192,45,56,174,188,86,65,196,176,46,79,208,169,49,68,193,198,100,70,84,202,199,44,65,125,207,181,51,81,200,190,47,60,172,184,84,67,188,185,84,65,144,195,107,73,111,194,206,60,61,149,184,111,60,167,177,104,69,80,206,192,58,79,199,173,55,83,140,205,175,29,47,181,184,78,83,102,195,204,54,73,107,198,187,47,78,144,205,130,60,94,189,193,66,65,114,196,152,52,135,182,137,58,68,207,196,78,69,154,182,93,73,157,187,104,77,103,182,207,69,72,192,170,64,63,166,177,90,85,105,188,204,67,75,198,171,64,76,104,198,203,65,73,121,190,177,43,72,157,197,167,50,65,202,164,66,88,145,210,138,63,95,184,190,74,68,111,191,184,42,71,201,172,57,82,149,198,174,47,64,187,180,71,87,193,159,56,82,195,173,62,82,184,179,75,75,156,184,104,69,148,181,105,74,116,192,178,50,72,168,183,97,76,139,178,150,51,92,196,153,55,80,195,183,65,87,195,147,66,89,167,191,104,76,108,191,162,53,82,189,178,67,79,117,194,189,48,70,150,185,116,69,161,166,107,78,89,196,185,57,86,192,164,62,82,169,182,96,76,157,170,121,65,114,189,117,78,108,171,197,116,60,115,180,125,71,97,189,181,60,89,195,162,63,76,149,184,120,70,162,168,80,84,155,184,105,80,110,175,184,68,83,150,177,152,49,71,187,175,96,79,97,184,181,71,84,170,171,86,84,131,192,167,52,77,167,178,111,75,91,179,185,87,81,141,179,114,83,109,173,188,85,82,112,186,170,55,91,192,163,60,78,157,181,109,84,138,185,149,61,83,171,182,117,74,88,193,174,67,86,120,191,180,52,85,168,174,90,82,180,156,85,85,111,193,164,65,99,173,176,107,71,96,187,162,65,98,184,163,72,90,185,165,72,83,156,175,123,73,116,189,133,80,115,188,159,59,86,133,197,157,63,109,182,157,58,82,157,178,121,75,92,149,194,131,68,87,159,182,106,77,121,179,135,74,107,180,160,65,91,169,169,104,78,99,179,173,73,95,185,160,74,89,128,182,163,57,93,190,159,70,86,175,159,82,98,146,186,153,63,83,180,166,86,88,144,171,121,82,106,184,164,74,93,157,171,104,84,129,181,148,64,92,138,192,166,55,87,184,152,70,93,159,176,105,88,155,160,114,80,124,181,122,82,127,179,150,66,88,173,171,87,94,151,171,133,69,106,185,131,77,103,141,197,137,73,127,167,132,70,86,163,177,105,89,134,171,133,74,106,186,143,77,105,172,166,79,88,142,170,122,80,105,146,190,135,71,95,174,156,73,98,126,186,159,65,90,141,178,139,75,101,173,156,74,98,156,168,123,75,115,176,143,69,101,185,145,75,106,183,149,75,97,160,164,96,96,167,154,101,82,140,166,100,100,119,159,179,92,94,130,176,155,63,86,157,164,104,92,133,175,143,72,102,170,150,85,99,163,165,100,91,112,149,185,117,80,129,162,111,87,140,164,111,92,142,163,128,78,113,176,141,76,98,173,162,106,91,114,179,148,74,105,163,163,100,89,145,153,99,100,136,177,127,86,114,138,184,137,69,94,163,160,93,99,122,177,156,72,94,150,164,109,96,136,171,131,82,105,147,175,105,91,151,150,104,96,107,146,184,118,88,144,152,108,95,119,177,149,72,102,124,176,165,84,96,136,165,130,80,108,171,151,82,104,141,170,133,83,103,150,172,130,81,100,169,157,98,99,113,169,159,85,107,150,162,120,87,112,171,151,77,103,169,144,93,102,139,178,124,94,115,133,181,134,77,102,162,153,93,95,114,166,150,80,105,145,163,114,90,146,147,100,101,131,171,138,79,107,128,178,152,78,95,135,163,130,86,115,167,143,88,108,154,158,117,89,108,170,153,89,102,152,148,112,99,113,173,146,90,109,143,170,121,89,108,143,171,130,82,108,170,139,80,107,130,173,158,85,106,127,169,153,80,101,148,154,109,100,136,160,121,94,117,163,147,93,105,145,160,110,100,119,160,157,96,103,117,168,147,81,105,139,165,136,86,103,158,154,101,105,147,156,115,98,116,156,153,91,107,161,145,93,109,116,147,174,106,106,118,138,168,107,95,137,149,116,96,114,163,148,93,107,133,163,139,83,105,160,147,96,110,153,146,105,105,117,141,173,133,84,113,163,132,86,109,126,165,149,97,108,127,166,146,81,108,146,138,103,107,153,144,104,109,132,164,130,97,116,152,149,102,106,129,164,137,83,105,141,160,125,96,110,140,167,121,101,116,155,145,94,108,135,159,132,88,108,138,165,130,94,118,160,137,91,108,138,156,130,97,114,160,143,91,112,150,141,102,109,150,145,104,108,150,142,109,108,127,163,136,91,110,134,161,132,96,112,148,149,111,101,130,153,125,99,113,137,168,136,90,108,143,152,115,106,125,153,138,93,122,154,127,99,125,158,119,103,116,138,167,122,97,115,149,145,105,108,136,146,113,109,118,133,172,133,93,109,139,150,113,108,134,147,128,97,112,151,147,105,115,126,142,153,107,107,122,148,147,101,108,130,153,127,101,120,148,139,106,113,127,160,139,97,109,136,152,123,105,126,154,138,94,111,139,149,123,105,119,152,143,106,110,135,146,122,105,118,153,143,108,113,116,145,145,105,111,124,153,135,93,114,150,134,102,117,124,148,150,109,112,123,151,138,96,112,124,152,142,105,112,125,154,133,102,116,126,154,145,108,111,115,141,150,110,116,122,133,158,115,111}; // Sound data +int alienDeathSound_numberOfSamples = 3077; + +int alienMovement1Sound_soundData[]={122,110,99,88,76,71,65,68,74,82,91,105,110,125,130,141,153,161,170,175,181,184,188,188,188,188,188,188,188,188,187,187,181,178,173,170,164,161,156,153,144,139,136,127,125,122,119,113,110,102,102,96,96,91,91,91,96,102,108,105,108,110,105,102,93,88,82,76,68,62,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,68,74,79,88,91,99,102,110,116,122,125,130,136,144,147,156,161,167,170,175,178,184,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,184,178,175,173,173,167,161,158,153,141,127,116,102,91,82,79,76,79,82,88,93,102,108,113,119,122,127,130,133,136,141,141,141,144,141,139,136,136,133,130,125,125,122,119,113,110,102,99,93,88,82,79,74,68,62,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,68,74,82,91,99,108,116,125,130,139,147,150,158,167,173,181,187,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,187,178,164,150,136,125,116,110,110,113,116,122,125,130,136,144,150,156,161,161,167,170,173,173,175,173,173,173,167,167,164,161,156,153,147,141,136,130,125,122,113,108,105,99,93,88,82,74,74,68,61,61,61,61,61,61,61,61,62,65,65,62,62,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,68,74,82,91,96,102,110,119,125,130,136,141,150,156,161,167,170,175,184,187,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,187,184,181,178,173,170,167,158,147,130,122,110,99,96,93,93,96,102,108,113,119,125,130,136,141,147,153,156,158,158,161,158,161,158,158,156,150,147,144,141,136,130,125,125,119,113,110,102,96,91,85,79,74,71,65,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,68,76,82,91,96,108,110,119,125,130,139,147,153,158,164,173,178,184,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,187,187,181,173,164,147,133,125,113,105,102,105,102,108,116,122,125,133,139,147,150,156,164,164,167,170,170,173,173,167,164,161,156,153,150,144,139,136,130,125,125,116,110,105,99,96,88,82,79,74,69,63,61,61,61,62,62,62,62,62,62,63,66,66,69,66,63,62,62,62,62,62,63,63,63,63,63,63,64,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,66,66,67,74,80,88,97,102,111,116,125,131,136,145,150,155,161,170,175,181,186,192,193,193,193,193,193,193,192,192,192,192,192,192,191,191,191,191,191,190,190,190,190,190,189,189,189,189,189,189,188,188,188,188,188,187,187,187,187,187,187,187,187,185,182,179,173,171,168,165,162,156,154,151,148,145,143,137,134,131,129}; +int alienMovement1Sound_numberOfSamples =809; +int alienMovement1Sound_sampleRate=8; + +int alienMovement2Sound_soundData[]={127,119,110,96,88,76,74,71,76,82,90,99,113,119,130,138,150,158,164,175,178,184,186,189,192,194,192,192,192,189,189,186,184,178,175,170,167,164,158,155,150,147,138,136,133,127,124,119,116,110,107,102,99,93,96,99,99,105,107,113,113,110,113,107,102,96,90,85,79,68,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,68,74,79,82,90,96,102,105,113,122,127,130,136,141,150,155,161,167,170,175,178,184,186,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,189,184,184,181,178,172,172,167,164,164,158,155,150,147,144,141,141,136,133,130,127,124,122,119,116,113,113,107,107,105,105,99,99,96,88,76,66,66,66,66,66,66,66,66,66,66,66,66,74,79,88,96,105,107,116,119,124,124,130,130,130,130,130,130,127,124,122,119,116,119,113,110,107,105,99,96,90,88,85,82,79,76,74,71,68,68,66,66,66,68,71,79,85,90,90,90,90,88,85,79,74,71,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,68,74,79,85,90,96,102,110,119,124,130,136,141,150,155,164,170,175,184,189,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,192,186,186,184,178,172,170,164,164,158,153,150,147,144,141,136,133,133,130,130,124,122,119,119,113,110,102,88,74,66,66,66,66,66,66,66,66,66,66,71,79,85,93,102,107,113,119,122,124,124,127,127,127,130,127,127,124,124,122,122,116,110,107,105,102,99,93,88,88,82,76,74,68,66,66,66,66,66,66,66,66,66,66,68,71,74,76,74,76,71,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,68,74,79,88,93,102,110,116,122,127,133,141,147,153,161,167,172,178,184,189,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,189,186,184,178,175,172,170,167,161,158,155,153,150,144,144,141,136,130,130,130,127,124,122,119,116,113,113,110,99,88,74,66,66,66,66,66,66,66,66,68,74,82,90,99,107,113,119,124,130,133,136,138,141,141,138,141,138,136,136,133,130,124,122,116,113,107,107,105,96,93,90,88,85,79,74,74,71,68,66,66,66,66,66,68,74,79,82,88,88,85,85,82,76,74,68,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,68,74,82,88,90,99,105,113,119,127,130,138,144,150,158,164,170,175,181,186,192,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,193,193,193,193,193,193,192,192,192,192,192,192,192,190,187,182,179,176,173,170,168,165,162,156,153,153,151,142,140,140,134,129,129}; +int alienMovement2Sound_numberOfSamples=725; + +int alienMovement3Sound_soundData[] ={134,134,128,117,105,97,85,80,74,80,85,94,102,114,122,134,139,150,159,165,173,179,184,190,196,196,196,197,197,196,196,196,190,190,184,182,176,173,170,162,162,156,150,145,142,134,134,131,125,119,117,111,108,102,100,97,97,105,105,111,114,117,117,117,111,108,102,100,88,85,77,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,71,74,80,83,91,97,102,105,114,119,128,131,136,142,148,153,159,162,167,173,179,184,187,193,196,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,196,193,190,187,182,179,179,173,170,167,165,162,159,156,153,150,148,142,139,142,136,134,134,131,128,128,122,122,117,117,114,111,108,108,102,102,100,100,97,97,94,91,91,88,88,85,85,83,83,77,71,70,70,70,70,70,70,70,70,70,70,70,70,70,80,88,97,105,111,117,122,125,131,134,136,136,139,136,139,139,139,136,139,134,134,134,128,128,125,125,119,114,117,111,108,105,102,100,100,94,91,88,85,88,91,97,105,108,114,117,117,114,114,108,105,100,97,91,85,80,77,71,70,70,70,70,70,70,70,70,70,70,71,71,77,80,85,91,94,100,105,111,119,125,131,134,139,145,153,159,165,170,176,182,187,193,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,196,190,187,182,179,179,173,170,167,165,159,159,153,148,145,142,139,136,134,131,128,128,122,119,117,117,111,105,108,105,100,97,97,94,91,88,85,83,83,83,80,77,71,70,70,70,70,70,70,70,70,70,70,70,70,70,70,77,85,94,100,108,114,117,119,122,128,128,131,131,134,131,131,128,128,125,122,119,117,114,111,108,102,100,97,94,94,88,85,83,80,77,74,71,70,71,70,74,83,85,91,94,97,94,94,91,85,83,77,71,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,77,80,85,91,97,102,111,117,122,131,134,142,148,153,162,165,173,179,184,190,196,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,196,190,187,184,182,179,173,170,167,165,162,159,159,153,150,148,142,139,136,134,136,134,128,125,125,122,117,114,108,105,102,100,100,97,97,94,94,91,91,88,85,83,80,71,70,70,70,70,70,70,70,70,70,70,70,70,77,83,94,102,111,117,125,131,134,134,136,136,139,139,142,139,142,139,139,136,134,134,128,128,125,119,117,114,111,111,105,100,97,94,91,88,85,83,80,83,80,83,91,94,100,102,102,102,105,102,97,94,91,85,80,74,71,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,74,80,83,91,94,100,108,114,122,128,134,136,142,150,156,164,170,175,178,183,189,195,196,196,196,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,195,194,194,194,194,194,194,194,194,194,193,192,189,186,183,177,174,171,166,162,157,157,154,148,145,143,139,136,134,128,128}; +int alienMovement3Sound_numberOfSamples=763; + +int alienMovement4Sound_soundData[] ={133,133,135,135,133,135,133,127,116,104,96,84,79,76,79,84,96,104,113,124,133,144,149,161,169,178,181,189,189,195,196,196,196,196,196,196,195,192,192,186,183,178,175,169,166,161,155,149,147,141,138,133,130,124,121,116,110,107,104,101,96,99,101,107,110,116,116,116,113,113,104,99,93,87,79,73,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,70,79,84,90,96,99,107,116,121,127,130,135,141,147,149,158,164,166,175,178,183,189,192,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,192,189,186,186,181,175,172,169,166,161,161,155,155,149,147,144,141,135,133,133,130,130,127,121,121,118,116,113,113,107,107,101,101,99,99,93,90,84,84,82,82,79,82,79,76,79,76,76,76,73,73,76,73,73,73,73,70,70,73,73,73,70,69,69,69,69,69,69,69,69,69,69,69,69,69,76,87,96,107,116,124,133,135,141,147,149,155,155,161,164,164,161,164,161,161,161,155,155,152,152,147,147,141,135,133,133,130,130,124,121,116,116,113,107,104,104,107,113,118,124,130,130,133,130,127,124,121,116,110,104,99,93,87,84,84,79,76,73,73,70,70,70,73,70,76,79,79,84,87,90,96,101,107,113,118,124,130,133,141,147,149,158,164,166,175,181,183,189,195,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,195,192,186,183,178,175,172,169,164,164,158,152,149,147,141,138,133,133,130,127,124,118,116,113,110,107,104,101,99,99,96,93,90,90,84,84,82,82,79,76,73,73,70,69,70,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,79,87,99,107,116,121,127,133,133,135,138,141,144,144,147,144,144,141,141,138,135,133,133,130,127,124,121,118,116,113,110,107,104,101,99,93,93,90,90,90,96,101,107,116,116,118,118,116,113,107,101,96,90,84,82,76,70,69,69,69,69,69,69,69,69,69,69,69,69,70,73,79,82,87,93,99,107,110,116,124,130,133,138,144,152,158,164,169,178,183,189,192,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,195,192,189,186,183,178,175,172,169,166,161,158,155,149,147,144,141,141,135,133,133,127,124,118,116,113,110,107,104,101,99,99,96,93,90,90,84,84,82,82,79,76,73,73,70,69,70,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,79,87,99,107,116,121,127,133,133,135,138,141,144,144,147,144,144,141,141,138,135,133,133,130,127,124,121,118,116,113,110,107,104,101,99,93,93,90,90,90,96,101,107,116,116,118,118,116,113,107,101,96,90,84,82,76,70,69,69,69,69,69,69,69,69,69,69,69,69,70,73,79,82,87,93,99,107,110,116,124,130,133,138,144,152,158,164,169,178,183,189,192,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,195,192,189,186,183,178,175,172,169,166,161,158,155,149,147,144,141,141,135,133,133,127}; +int alienMovement4Sound_numberOfSamples=818; + +int alienSilenceSound_soundData[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +int alienSilenceSound_numberOfSamples=40; diff --git a/ecen427/bullet.c b/ecen427/bullet.c new file mode 100644 index 0000000..1f892cb --- /dev/null +++ b/ecen427/bullet.c @@ -0,0 +1,226 @@ +#include "bullet.h" + +void renderBullet(unsigned int* framePointer) { + if(getGuiseBullet() == 0) { + setGuiseBullet(1); + renderBullet1(framePointer); + }else { + setGuiseBullet(0); + renderBullet2(framePointer); + } +} + +void renderBullet1(unsigned int* framePointer) { + if(getTankBulletState() == 1) { + short initial_x = getTankBulletPositionX(); + short initial_y = getTankBulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((tankBullet[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien1BulletState() == 1) { + short initial_x = getAlien1BulletPositionX(); + short initial_y = getAlien1BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet1_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien2BulletState() == 1) { + short initial_x = getAlien2BulletPositionX(); + short initial_y = getAlien2BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet2_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien3BulletState() == 1) { + short initial_x = getAlien3BulletPositionX(); + short initial_y = getAlien3BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet3_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien4BulletState() == 1) { + short initial_x = getAlien4BulletPositionX(); + short initial_y = getAlien4BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet1_1[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } +} + +void renderBullet2(unsigned int* framePointer) { + if(getTankBulletState() == 1) { + short initial_x = getTankBulletPositionX(); + short initial_y = getTankBulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((tankBullet[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien1BulletState() == 1) { + short initial_x = getAlien1BulletPositionX(); + short initial_y = getAlien1BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet1_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien2BulletState() == 1) { + short initial_x = getAlien2BulletPositionX(); + short initial_y = getAlien2BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet2_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien3BulletState() == 1) { + short initial_x = getAlien3BulletPositionX(); + short initial_y = getAlien3BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet3_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } + if(getAlien4BulletState() == 1) { + short initial_x = getAlien4BulletPositionX(); + short initial_y = getAlien4BulletPositionY(); + int x, y; + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((alienBullet1_2[x%10] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00FFFFFE; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + } +} + +void blankTankBullet(unsigned int* framePointer){ + short tankx, tanky; + tankx = getTankBulletPositionX(); + tanky = getTankBulletPositionY(); + short row=0, col=0; + for(row = 0; row < BLOCK_HEIGHT; row++){ + for(col = 0; col < BLOCK_WIDTH; col++){ + framePointer[(tanky+row)*640 + tankx+col] = 0x00000000; + } + } +} + +void blankAlienBullet(unsigned int* framePointer, short alienx, short alieny) { + short row=0, col=0; + for(row = 0; row < BLOCK_HEIGHT; row++){ + for(col = 0; col < BLOCK_WIDTH; col++){ + framePointer[(alieny+row)*640 + alienx+col] = 0x00000000; + } + } +} + +void moveBullets(unsigned int* framePointer) { + if(getTankBulletState() == 1) { + if(getTankBulletPositionY() == 30) { + blankTankBullet(framePointer); + setTankBulletState(0); + } + else { + setTankBulletPositionY(getTankBulletPositionY()-1); + } + } + if(getAlien1BulletState() == 1) { + if(getAlien1BulletPositionY() == 450) { + blankAlienBullet(framePointer, getAlien1BulletPositionX(), getAlien1BulletPositionY()); + setAlien1BulletState(0); + } + else { + setAlien1BulletPositionY(getAlien1BulletPositionY()+1); + } + } + if(getAlien2BulletState() == 1) { + if(getAlien2BulletPositionY() == 450) { + blankAlienBullet(framePointer, getAlien2BulletPositionX(), getAlien2BulletPositionY()); + setAlien2BulletState(0); + } + else { + setAlien2BulletPositionY(getAlien2BulletPositionY()+1); + } + } + if(getAlien3BulletState() == 1) { + if(getAlien3BulletPositionY() == 450) { + blankAlienBullet(framePointer, getAlien3BulletPositionX(), getAlien3BulletPositionY()); + setAlien3BulletState(0); + } + else { + setAlien3BulletPositionY(getAlien3BulletPositionY()+1); + } + } + if(getAlien4BulletState() == 1) { + if(getAlien4BulletPositionY() == 450) { + blankAlienBullet(framePointer, getAlien4BulletPositionX(), getAlien4BulletPositionY()); + setAlien4BulletState(0); + } + else { + setAlien4BulletPositionY(getAlien4BulletPositionY()+1); + } + } +} diff --git a/ecen427/bullet.h b/ecen427/bullet.h new file mode 100644 index 0000000..732ab52 --- /dev/null +++ b/ecen427/bullet.h @@ -0,0 +1,109 @@ +#ifndef BULLET_H_ +#define BULLET_H_ + +#define BLOCK_HEIGHT 10 +#define BLOCK_WIDTH 6 +#define packWord24(b5,b4,b3,b2,b1,b0) \ +((b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 )) + +int alienBullet1_1[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(1,1,1,1,1,1), + packWord24(1,1,1,1,1,1), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,0,0,0), +}; + +int alienBullet1_2[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(1,1,1,1,1,1), + packWord24(1,1,1,1,1,1), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,0,0,0), +}; + +int alienBullet2_1[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(0,0,0,0,1,1), + packWord24(0,0,0,1,1,0), + packWord24(0,0,1,1,0,0), + packWord24(0,1,1,0,0,0), + packWord24(0,1,1,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,1,1,0), + packWord24(0,0,0,0,1,1), + packWord24(0,0,0,0,0,0), +}; + +int alienBullet2_2[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,1,1,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,1,1,0), + packWord24(0,0,0,0,1,1), + packWord24(0,0,0,1,1,0), + packWord24(0,0,1,1,0,0), + packWord24(0,1,1,0,0,0), + packWord24(0,0,0,0,0,0), +}; + +int alienBullet3_1[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(1,1,0,0,0,0), + packWord24(0,1,1,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,1,1,0), + packWord24(0,0,0,1,1,0), + packWord24(0,0,1,1,0,0), + packWord24(0,1,1,0,0,0), + packWord24(1,1,0,0,0,0), + packWord24(0,0,0,0,0,0), +}; + +int alienBullet3_2[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(1,1,0,0,0,0), + packWord24(0,1,1,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,1,1,0,0,0), + packWord24(1,1,0,0,0,0), + packWord24(0,1,1,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,1,1,0), + packWord24(0,0,0,0,0,0), +}; + +int tankBullet[BLOCK_HEIGHT] = +{ + packWord24(0,0,0,0,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,1,1,0,0), + packWord24(0,0,0,0,0,0), +}; + +void renderBullet(unsigned int*); +void moveBullets(unsigned int*); +#endif /* BULLET_H_ */ diff --git a/ecen427/bunker.c b/ecen427/bunker.c new file mode 100644 index 0000000..16695e7 --- /dev/null +++ b/ecen427/bunker.c @@ -0,0 +1,638 @@ +#include "bunker.h" +#include "stdlib.h" +#include "xintc_l.h" // Provides handy macros for the interrupt controller. + +int x_y[4] = {BUNKER1_X, BUNKER2_X, BUNKER3_X, BUNKER4_X}; +int initial_x = 70; +int initial_y = 300; +int tank_y_position = 420; + +void renderBunker(unsigned int* framePointer) { // draw for the first time + short x=0, y=0; + + int i,j; + for(j = 0; j < 4; j++) { + initial_x = x_y[j]; + for(i=0; i<10; i++){ + switch(i){ + case 0: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_left0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x0000FF00; + } else { + framePointer[(initial_y+x)*640 + initial_x+y] = 0x00000000; + } + } + } + break; + case 1: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_normal0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y+BLOCK_WIDTH] = 0x0000FF00; + } else { + framePointer[(initial_y+x)*640 + initial_x+y+BLOCK_WIDTH] = 0x00000000; + } + } + } + break; + case 2: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_normal0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y+BLOCK_WIDTH*2] = 0x0000FF00; + } else { + framePointer[(initial_y+x)*640 + initial_x+y+BLOCK_WIDTH*2] = 0x00000000; + } + } + } + break; + + case 3: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_right0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x)*640 + initial_x+y+BLOCK_WIDTH*3] = 0x0000FF00; + } else { + framePointer[(initial_y+x)*640 + initial_x+y+BLOCK_WIDTH*3] = 0x00000000; + } + } + } + + break; + case 4: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_normal0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y] = 0x0000FF00; + } else { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y] = 0x00000000; + } + } + } + break; + case 5: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_center_left0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y+BLOCK_WIDTH] = 0x0000FF00; + } else { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y+BLOCK_WIDTH] = 0x00000000; + } + } + } + break; + case 6: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_center_right0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y+BLOCK_WIDTH*2] = 0x0000FF00; + } else { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y+BLOCK_WIDTH*2] = 0x00000000; + } + } + } + break; + case 7: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_normal0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y+BLOCK_WIDTH*3] = 0x0000FF00; + } else { + framePointer[(initial_y+x+BLOCK_HEIGHT)*640 + initial_x+y+BLOCK_WIDTH*3] = 0x00000000; + } + } + } + break; + + case 8: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_normal0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x+BLOCK_HEIGHT*2)*640 + initial_x+y] = 0x0000FF00; + } else { + framePointer[(initial_y+x+BLOCK_HEIGHT*2)*640 + initial_x+y] = 0x00000000; + } + } + } + break; + case 9: + for(x = 0; x < BLOCK_HEIGHT; x++) { + for(y = 0; y < BLOCK_WIDTH; y++){ + if ((block_normal0[x%16] & (1<<(BLOCK_WIDTH-1-y)))) { + framePointer[(initial_y+x+BLOCK_HEIGHT*2)*640 + initial_x+y+BLOCK_WIDTH*3] = 0x0000FF00; + } else { + framePointer[(initial_y+x+BLOCK_HEIGHT*2)*640 + initial_x+y+BLOCK_WIDTH*3] = 0x00000000; + } + } + } + break; + default : + + break; + } + } + } +} + +void erodeBunker(unsigned int* framePointer, int which_bunker, int which_block){ + // int which_block = rand()%10; + short* bunker; + int i, j; + int block_row, block_col; + switch(which_bunker){ // select a bunker that I want to erode + case 0: + bunker = getBunker1(); + break; + case 1: + bunker = getBunker2(); + break; + case 2: + bunker = getBunker3(); + break; + case 3: + bunker = getBunker4(); + break; + default : + break; + } + + switch(which_block){ // 'block_row, block_col' are used to calculate to find out the position of framePointer + case 0: + block_row = 0; + block_col = 0; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + break; + case 1: + block_row = 0; + block_col = 1; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 2: + block_row = 0; + block_col = 2; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 3: + block_row = 0; + block_col = 3; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 4: + block_row = 1; + block_col = 0; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 5: + block_row = 1; + block_col = 1; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 6: + block_row = 1; + block_col = 2; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 7: + block_row = 1; + block_col = 3; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 8: + block_row = 2; + block_col = 0; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + case 9: + block_row = 2; + block_col = 3; + blankBlock(framePointer, which_bunker, which_block, block_row, block_col); + updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); + + break; + + default : + + break; + } + +} +// This function runs first to make a block empty, and then draw an eroded block by 'updateBlock()' function +void blankBlock(unsigned int* framePointer, int which_bunker, int which_block, int block_row, int block_col){ + int i, j; + initial_x = x_y[which_bunker]; + for(i = 0; i < BLOCK_HEIGHT; i++){ + for(j = 0; j < BLOCK_WIDTH; j++){ + framePointer[(initial_y+i+BLOCK_HEIGHT*block_row)*640 + initial_x+j+BLOCK_WIDTH*block_col] = 0x00000000; + } + } +} + +void updateBlock(unsigned int* framePointer, int which_bunker, int which_block, int block_row, int block_col, short* bunker){ + int i, j; + initial_x = x_y[which_bunker]; + + int* which_state; + + if(bunker[which_block]==0){ // depending on the block selected and bunker status, 'which_state' points to a pre-defined eroded block + bunker[which_block] = 1; + if(which_block == 0){ + which_state = block_left1; + } + else if(which_block == 1 || which_block == 2 || which_block == 4 || which_block == 7 || which_block == 8 || which_block == 9){ + which_state = block_normal1; + } + else if(which_block == 3){ + which_state = block_right1; + } + else if(which_block == 5){ + which_state = block_center_left1; + } + else if(which_block == 6){ + which_state = block_center_right1; + } + } + else if(bunker[which_block]==1){ + bunker[which_block] = 2; + if(which_block == 0){ + which_state = block_left2; + } + else if(which_block == 1 || which_block == 2 || which_block == 4 || which_block == 7 || which_block == 8 || which_block == 9){ + which_state = block_normal2; + } + else if(which_block == 3){ + which_state = block_right2; + } + else if(which_block == 5){ + which_state = block_center_left2; + } + else if(which_block == 6){ + which_state = block_center_right2; + } + } + else if(bunker[which_block]==2){ + bunker[which_block] = 3; + if(which_block == 0){ + which_state = block_left3; + } + else if(which_block == 1 || which_block == 2 || which_block == 4 || which_block == 7 || which_block == 8 || which_block == 9){ + which_state = block_normal3; + } + else if(which_block == 3){ + which_state = block_right3; + } + else if(which_block == 5){ + which_state = block_center_left3; + } + else if(which_block == 6){ + which_state = block_center_right3; + } + } + else{ + bunker[which_block] = 4; + which_state = empty; + } + + for(i = 0; i < BLOCK_HEIGHT; i++){ + for(j = 0; j < BLOCK_WIDTH; j++){ + if ((which_state[i%16] & (1<<(BLOCK_WIDTH-1-j)))) { + framePointer[(initial_y+i+BLOCK_HEIGHT*block_row)*640 + initial_x+j+BLOCK_WIDTH*block_col] = 0x0000FF00; + } else { + framePointer[(initial_y+i+BLOCK_HEIGHT*block_row)*640 + initial_x+j+BLOCK_WIDTH*block_col] = 0x00000000; + } + } + } +} +void selectBlock(unsigned int* framePointer, int bullet){ + int bullet_x; + int bullet_y; + short hit = 0; + short* bunker; + int counter=0; + short dying = 0; + int gameover = 0; + + switch(bullet){ + case 1: + bullet_x = getAlien1BulletPositionX()+3; + bullet_y = getAlien1BulletPositionY()+10; + break; + case 2: + bullet_x = getAlien2BulletPositionX()+3; + bullet_y = getAlien2BulletPositionY()+10; + break; + case 3: + bullet_x = getAlien3BulletPositionX()+3; + bullet_y = getAlien3BulletPositionY()+10; + break; + case 4: + bullet_x = getAlien4BulletPositionX()+3; + bullet_y = getAlien4BulletPositionY()+10; + break; + case 5: + bullet_x = getTankBulletPositionX()+3; + bullet_y = getTankBulletPositionY(); + default: + break; + } + + if(bullet_x >= BUNKER1_X-3 && bullet_x < BUNKER1_X+64+3){ + bunker = getBunker1(); + if(bullet_y > initial_y && bullet_y < initial_y+16){ + if(bullet_x >= BUNKER1_X-3 && bullet_x < BUNKER1_X+16 && bunker[0] != 4){ + erodeBunker(framePointer, 0, 0); + hit = 1; + } + if(bullet_x >= BUNKER1_X+16 && bullet_x < BUNKER1_X+32 && bunker[1] != 4){ + erodeBunker(framePointer, 0, 1); + hit = 1; + } + if(bullet_x >= BUNKER1_X+32 && bullet_x < BUNKER1_X+48 && bunker[2] != 4){ + erodeBunker(framePointer, 0, 2); + hit = 1; + } + if(bullet_x >= BUNKER1_X+48 && bullet_x < BUNKER1_X+64+3 && bunker[3] != 4){ + erodeBunker(framePointer, 0, 3); + hit = 1; + } + } + if(bullet_y>initial_y+16 && bullet_y= BUNKER1_X-3 && bullet_x < BUNKER1_X+16 && bunker[4] != 4){ + erodeBunker(framePointer, 0, 4); + hit = 1; + } + if(bullet_x >= BUNKER1_X+16 && bullet_x < BUNKER1_X+32 && bunker[5] != 4){ + erodeBunker(framePointer, 0, 5); + hit = 1; + } + if(bullet_x >= BUNKER1_X+32 && bullet_x < BUNKER1_X+48 && bunker[6] != 4){ + erodeBunker(framePointer, 0, 6); + hit = 1; + } + if(bullet_x >= BUNKER1_X+48 && bullet_x < BUNKER1_X+64+3 && bunker[7] != 4){ + erodeBunker(framePointer, 0, 7); + hit = 1; + } + } + if(bullet_y>initial_y+32 && bullet_y= BUNKER1_X-3 && bullet_x= BUNKER1_X+48 && bullet_x BUNKER2_X-3 && bullet_x < BUNKER2_X+64+3){ + bunker = getBunker2(); + if(bullet_y>initial_y && bullet_y= BUNKER2_X-3 && bullet_x= BUNKER2_X+16 && bullet_x= BUNKER2_X+32 && bullet_x= BUNKER2_X+48 && bullet_xinitial_y+16 && bullet_y= BUNKER2_X-3 && bullet_x= BUNKER2_X+16 && bullet_x= BUNKER2_X+32 && bullet_x= BUNKER2_X+48 && bullet_xinitial_y+32 && bullet_y= BUNKER2_X-3 && bullet_x= BUNKER2_X+48 && bullet_x BUNKER3_X-3 && bullet_x < BUNKER3_X+64+3){ + bunker = getBunker3(); + if(bullet_y>initial_y && bullet_y= BUNKER3_X-3 && bullet_x= BUNKER3_X+16 && bullet_x= BUNKER3_X+32 && bullet_x= BUNKER3_X+48 && bullet_xinitial_y+16 && bullet_y= BUNKER3_X-3 && bullet_x= BUNKER3_X+16 && bullet_x= BUNKER3_X+32 && bullet_x= BUNKER3_X+48 && bullet_xinitial_y+32 && bullet_y= BUNKER3_X-3 && bullet_x= BUNKER3_X+48 && bullet_x BUNKER4_X-3 && bullet_x < BUNKER4_X+64+3){ + bunker = getBunker4(); + if(bullet_y>initial_y && bullet_y= BUNKER4_X-3 && bullet_x= BUNKER4_X+16 && bullet_x= BUNKER4_X+32 && bullet_x= BUNKER4_X+48 && bullet_xinitial_y+16 && bullet_y= BUNKER4_X-3 && bullet_x= BUNKER4_X+16 && bullet_x= BUNKER4_X+32 && bullet_x= BUNKER4_X+48 && bullet_xinitial_y+32 && bullet_y= BUNKER4_X-3 && bullet_x= BUNKER4_X+48 && bullet_x tank_y_position && bullet_y < tank_y_position+16){ + if(bullet_x >= getTankPositionX()-3 && bullet_x < getTankPositionX()+32+3){ + setHaveTankDeathSound(1); + + counter = 0; + // xil_printf("tank dies\r\n"); + + // disable interrupt to stop the whole game for little bit +// XIntc_MasterDisable(XPAR_INTC_0_BASEADDR); + + setAlien1BulletState(0); + blankAlienBullet(framePointer, getAlien1BulletPositionX(), getAlien1BulletPositionY()); + setAlien2BulletState(0); + blankAlienBullet(framePointer, getAlien2BulletPositionX(), getAlien2BulletPositionY()); + setAlien3BulletState(0); + blankAlienBullet(framePointer, getAlien3BulletPositionX(), getAlien3BulletPositionY()); + setAlien4BulletState(0); + blankAlienBullet(framePointer, getAlien4BulletPositionX(), getAlien4BulletPositionY()); + setTankBulletState(0); + blankTankBullet(framePointer, getTankBulletPositionX(), getTankBulletPositionY()); + + gameover = tankDied(framePointer); + + if(!gameover){ + + // for tank dying animation + while(counter < 1000){ + // if(counter%250){ + + if(dying == 0){ + dying = 1; + blankTank(framePointer); + renderDying1(framePointer); + } + else{ + dying = 0; + blankTank(framePointer); + renderDying2(framePointer); + } + // } + counter++; + } + + // reenable interrupt +// XIntc_MasterEnable(XPAR_INTC_0_BASEADDR); + renderTank(framePointer); + } + } + } + + if(hit){ + + switch(bullet){ + case 1: + setAlien1BulletState(0); + blankAlienBullet(framePointer, bullet_x-3, bullet_y-10); + break; + case 2: + setAlien2BulletState(0); + blankAlienBullet(framePointer, bullet_x-3, bullet_y-10); + break; + case 3: + setAlien3BulletState(0); + blankAlienBullet(framePointer, bullet_x-3, bullet_y-10); + break; + case 4: + setAlien4BulletState(0); + blankAlienBullet(framePointer, bullet_x-3, bullet_y-10); + break; + case 5: + setTankBulletState(0); + blankTankBullet(framePointer, bullet_x, bullet_y); + break; + + default: + break; + } + } + +} diff --git a/ecen427/bunker.h b/ecen427/bunker.h new file mode 100644 index 0000000..acfdd6d --- /dev/null +++ b/ecen427/bunker.h @@ -0,0 +1,440 @@ +#ifndef BUNKER_H_ +#define BUNKER_H_ + + +#define BUNKER1_X 70 +#define BUNKER2_X 210 +#define BUNKER3_X 350 +#define BUNKER4_X 490 + +#define BLOCK_HEIGHT 16 +#define BLOCK_WIDTH 16 +#define packWord16(b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0) \ + ((b15 << 15) | (b14 << 14) | (b13 << 13) | (b12 << 12) | (b11 << 11) | (b10 << 10) | (b9 << 9 ) | (b8 << 8 ) | \ + (b7 << 7 ) | (b6 << 6 ) | (b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 )) + + + +int block_left0[BLOCK_HEIGHT] = // whole block +{ + packWord16(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), +}; +int block_left1[BLOCK_HEIGHT] = // 1-hit +{ + packWord16(0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,0), + packWord16(0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,0), + packWord16(0,0,0,0,1,1,0,0,1,1,1,0,0,1,1,1), + packWord16(0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,0,0,1,1,1,1,1,0,0,1,1,1), + packWord16(0,1,1,1,0,0,1,1,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,1,1,0,0,1,1,0,0,1,1,0,0), + packWord16(0,0,1,1,1,1,0,0,1,1,0,0,1,1,0,0), + packWord16(1,1,0,0,1,1,1,1,1,0,0,1,1,1,0,0), + packWord16(1,1,0,0,1,1,1,1,1,0,0,1,1,1,0,0), + packWord16(0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1), + packWord16(0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1), + packWord16(1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1), + packWord16(1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1), + packWord16(1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1), + packWord16(1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1), +}; +int block_left2[BLOCK_HEIGHT] = // 2-hit +{ + packWord16(0,0,0,0,0,0,1,0,0,1,1,0,0,1,1,0), + packWord16(0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0), + packWord16(0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0), + packWord16(0,0,0,1,1,1,0,0,0,0,1,0,0,1,1,0), + packWord16(0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0), + packWord16(0,0,1,0,0,1,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,1,0,0,1,0,0,0,0,0,0,1,1,0,0), + packWord16(1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,1,1,0,0,0,0,0,0,1,1,0,0,1,0), + packWord16(0,0,1,1,0,0,0,0,0,0,1,1,0,0,1,0), + packWord16(0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0), + packWord16(0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,1), + packWord16(0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,1), +}; + +int block_left3[BLOCK_HEIGHT] = // 3-hit +{ + packWord16(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0), + packWord16(0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0), + packWord16(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0), + packWord16(0,0,1,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,1,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; +int empty[BLOCK_HEIGHT] = // no block +{ + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; + +int block_right0[BLOCK_HEIGHT] = // whole block +{ + packWord16(1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + +}; + +int block_right1[BLOCK_HEIGHT] = // 1-hit +{ + packWord16(1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord16(1,1,0,0,1,1,0,0,1,1,1,0,0,0,0,0), + packWord16(1,1,0,0,1,1,0,0,1,1,1,0,0,0,0,0), + packWord16(1,1,1,1,1,0,0,1,1,1,1,0,0,1,0,0), + packWord16(1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,0), + packWord16(0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0), + packWord16(0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0), + packWord16(0,0,1,1,1,0,0,1,1,1,1,0,0,0,0,1), + packWord16(0,0,1,1,1,0,0,1,1,1,1,0,0,0,0,1), + packWord16(1,1,1,0,0,1,1,1,1,0,0,1,1,1,0,0), + packWord16(1,1,1,0,0,1,1,1,1,0,0,1,1,1,0,0), + packWord16(0,0,1,1,1,0,0,1,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,1,0,0,1,1,1,1,0,0,1,1,1), + packWord16(1,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0), + packWord16(1,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0), + +}; + +int block_right2[BLOCK_HEIGHT] = // 2-hit +{ + packWord16(1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0), + packWord16(0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,1,1,0,0,0,0,1,0,0), + packWord16(1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0), + packWord16(0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1), + packWord16(0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1), + packWord16(1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1), + packWord16(0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0), + +}; + +int block_right3[BLOCK_HEIGHT] = // 3-hit +{ + packWord16(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + +}; + +int block_center_left0[BLOCK_HEIGHT] = // whole block +{ + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0), + packWord16(1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0), + packWord16(1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; + +int block_center_left1[BLOCK_HEIGHT] = // 1-hit +{ + packWord16(1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,1), + packWord16(1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,0), + packWord16(1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0), + packWord16(1,1,1,1,1,1,0,0,1,1,1,1,1,0,0,0), + packWord16(1,1,1,0,0,1,1,1,1,1,1,1,0,0,0,0), + packWord16(1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0), + packWord16(0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0), + packWord16(0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; +int block_center_left2[BLOCK_HEIGHT] = // 2-hit +{ + packWord16(1,1,0,0,1,1,1,0,0,1,1,0,0,1,1,1), + packWord16(1,1,0,0,1,1,1,0,0,1,1,0,0,1,1,0), + packWord16(0,0,1,1,1,1,0,0,1,1,0,0,1,1,0,0), + packWord16(0,0,1,1,1,1,0,0,1,1,0,0,1,0,0,0), + packWord16(1,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0), + packWord16(1,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0), + packWord16(0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0), + packWord16(0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; +int block_center_left3[BLOCK_HEIGHT] = // 3-hit +{ + packWord16(0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0), + packWord16(0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0), + packWord16(0,0,1,0,0,1,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0), + packWord16(1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0), + packWord16(1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), +}; + +int block_center_right0[BLOCK_HEIGHT] = // whole block +{ + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1), +}; +int block_center_right1[BLOCK_HEIGHT] = // 1-hit +{ + packWord16(0,0,1,1,0,0,1,1,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,0,0,1,1,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1), + packWord16(0,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1), + packWord16(0,0,0,0,1,0,0,1,1,1,1,0,0,1,0,0), + packWord16(0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0), + packWord16(0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1), +}; + +int block_center_right2[BLOCK_HEIGHT] = // 2-hit +{ + packWord16(0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,1), + packWord16(0,0,1,1,1,1,1,0,0,1,0,0,1,1,0,0), + packWord16(0,0,0,1,1,1,1,0,0,1,0,0,1,1,0,0), + packWord16(0,0,0,0,1,0,0,1,1,1,1,0,0,1,0,0), + packWord16(0,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0), + packWord16(0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,1), + packWord16(0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,1), + packWord16(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1), +}; +int block_center_right3[BLOCK_HEIGHT] = // 3-hit +{ + packWord16(0,0,1,1,0,0,0,0,1,1,1,0,0,0,0,0), + packWord16(0,0,1,1,0,0,0,0,1,1,1,0,0,0,0,0), + packWord16(0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0), + packWord16(0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0), + packWord16(0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1), + packWord16(0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1), + packWord16(0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1), +}; + +int block_normal0[BLOCK_HEIGHT] = // whole block +{ + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), + packWord16(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), +}; +int block_normal1[BLOCK_HEIGHT] = // 1-hit +{ + packWord16(1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1), + packWord16(1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1), + packWord16(1,1,1,1,0,0,1,1,0,0,1,0,0,1,1,1), + packWord16(1,1,1,1,0,0,1,1,0,0,1,0,0,1,1,1), + packWord16(1,1,0,0,1,1,0,0,1,1,1,1,1,1,0,0), + packWord16(1,1,0,0,1,1,0,0,1,1,1,1,1,1,0,0), + packWord16(0,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1), + packWord16(0,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1), + packWord16(1,1,1,0,0,1,1,0,0,1,1,1,1,1,0,0), + packWord16(1,1,1,0,0,1,1,0,0,1,1,1,1,1,0,0), + packWord16(0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1), + packWord16(0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,1), + packWord16(1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1), + packWord16(1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1), + packWord16(1,1,1,0,0,1,1,1,0,0,1,1,1,1,0,0), + packWord16(1,1,1,0,0,1,1,1,0,0,1,1,1,1,0,0), +}; + +int block_normal2[BLOCK_HEIGHT] = // 2-hit +{ + packWord16(1,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1), + packWord16(1,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1), + packWord16(0,0,1,1,0,0,1,1,0,0,1,0,0,1,0,0), + packWord16(0,0,1,1,0,0,1,1,0,0,1,0,0,1,0,0), + packWord16(0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0), + packWord16(0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0), + packWord16(0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,1), + packWord16(0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,1), + packWord16(0,0,1,0,0,1,1,0,0,0,0,1,1,1,0,0), + packWord16(0,0,1,0,0,1,1,0,0,0,0,1,1,1,0,0), + packWord16(0,1,1,1,1,0,0,1,1,0,0,0,0,0,1,1), + packWord16(0,1,1,1,1,0,0,1,1,0,0,0,0,0,1,1), + packWord16(1,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0), + packWord16(1,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0), + packWord16(0,1,1,0,0,0,0,1,0,0,0,0,1,1,0,0), + packWord16(0,1,1,0,0,0,0,1,0,0,0,0,1,1,0,0), +}; + +int block_normal3[BLOCK_HEIGHT] = // 3-hit +{ + packWord16(1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1), + packWord16(1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1), + packWord16(0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0), + packWord16(0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0), + packWord16(0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0), + packWord16(0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1), + packWord16(0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0), + packWord16(0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0), +}; + +void renderBunker(unsigned int*); +void erodeBunker(unsigned int*, int which_bunker, int which_block); +void blankBlock(unsigned int*, int which_bunker, int which_block, int block_row, int block_col); +void updateBlock(unsigned int*, int which_bunker, int which_block, int block_row, int block_col, short* bunker); +void selectBlock(unsigned int*, int bullet); + +#endif /* BUNKER_H_ */ diff --git a/ecen427/global.c b/ecen427/global.c new file mode 100644 index 0000000..5d183d1 --- /dev/null +++ b/ecen427/global.c @@ -0,0 +1,284 @@ +#include "global.h" + + +static point_t alienBlockPosition; +static point_t tankPosition; + + + +static short alienDirection; +static short guise = 0; +static short guiseBullet = 0; +static short aliens[55] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + +static short bunker1[10] = {0,0,0,0,0,0,0,0,0,0}; +static short bunker2[10] = {0,0,0,0,0,0,0,0,0,0}; +static short bunker3[10] = {0,0,0,0,0,0,0,0,0,0}; +static short bunker4[10] = {0,0,0,0,0,0,0,0,0,0}; + + + +static point_t tankBulletPosition; +static point_t alienBulletPosition1; +static point_t alienBulletPosition2; +static point_t alienBulletPosition3; +static point_t alienBulletPosition4; + +static short tankBullet = 0; +static short alienBullet1 = 0; +static short alienBullet2 = 0; +static short alienBullet3 = 0; +static short alienBullet4 = 0; + +static point_t ufoPosition; +static short ufo_state = 0; +static short ufo_left; + + +short getUfoDirection(){ + return ufo_left; +} +short setUfoDirection(){ + ufo_left = rand()%2; +} + +short getUfoPositionY() { + return ufoPosition.y; +} +void setUfoPositionY(short update) { + ufoPosition.y = update; +} +short getUfoPositionX() { + return ufoPosition.x; +} +void setUfoPositionX(short update) { + ufoPosition.x = update; +} +short getUfoState(){ + return ufo_state; +} +void setUfoState(short state){ + ufo_state = state; +} + +unsigned short getGuiseBullet() { + return guiseBullet; +} + +void setGuiseBullet(unsigned short frame) { + guiseBullet = frame; +} + +// for tank bullet +void setTankBulletState(short state) { + tankBullet = state; +} + +short getTankBulletState() { + return tankBullet; +} + +void initialTankBulletPosition() { + tankBulletPosition.x = getTankPositionX()+11; + tankBulletPosition.y = 410; +} + +short getTankBulletPositionX() { + return tankBulletPosition.x; +} + +short getTankBulletPositionY() { + return tankBulletPosition.y; +} + +void setTankBulletPositionY(short update) { + tankBulletPosition.y = update; +} + +//for alien bullet1 +void setAlien1BulletState(short state) { + alienBullet1 = state; +} + +short getAlien1BulletState() { + return alienBullet1; +} + +short getAlien1BulletPositionX() { + return alienBulletPosition1.x; +} + +short getAlien1BulletPositionY() { + return alienBulletPosition1.y; +} + +void setAlien1BulletPositionY(short update) { + alienBulletPosition1.y = update; +} + +void setAlien1BulletPosition(short x, short y) { + alienBulletPosition1.x = x; + alienBulletPosition1.y = y; +} +//for alien bullet2 +void setAlien2BulletState(short state) { + alienBullet2 = state; +} + +short getAlien2BulletState() { + return alienBullet2; +} + +short getAlien2BulletPositionX() { + return alienBulletPosition2.x; +} + +short getAlien2BulletPositionY() { + return alienBulletPosition2.y; +} + +void setAlien2BulletPositionY(short update) { + alienBulletPosition2.y = update; +} + +void setAlien2BulletPosition(short x, short y) { + alienBulletPosition2.x = x; + alienBulletPosition2.y = y; +} + +//for alien bullet3 +void setAlien3BulletState(short state) { + alienBullet3 = state; +} + +short getAlien3BulletState() { + return alienBullet3; +} + +short getAlien3BulletPositionX() { + return alienBulletPosition3.x; +} + +short getAlien3BulletPositionY() { + return alienBulletPosition3.y; +} + +void setAlien3BulletPositionY(short update) { + alienBulletPosition3.y = update; +} + +void setAlien3BulletPosition(short x, short y) { + alienBulletPosition3.x = x; + alienBulletPosition3.y = y; +} + +//for alien bullet4 +void setAlien4BulletState(short state) { + alienBullet4 = state; +} + +short getAlien4BulletState() { + return alienBullet4; +} + +short getAlien4BulletPositionX() { + return alienBulletPosition4.x; +} + +short getAlien4BulletPositionY() { + return alienBulletPosition4.y; +} + +void setAlien4BulletPositionY(short update) { + alienBulletPosition4.y = update; +} + +void setAlien4BulletPosition(short x, short y) { + alienBulletPosition4.x = x; + alienBulletPosition4.y = y; +} +//for bunker +short* getBunker1() { + return bunker1; +} + +void setBunker1(unsigned short state, unsigned short block) { + bunker1[block] = state; +} +short* getBunker2() { + return bunker2; +} + +void setBunker2(unsigned short state, unsigned short block) { + bunker2[block] = state; +} +short* getBunker3() { + return bunker3; +} + +void setBunker3(unsigned short state, unsigned short block) { + bunker3[block] = state; +} +short* getBunker4() { + return bunker4; +} + +void setBunker4(unsigned short state, unsigned short block) { + bunker1[block] = state; +} + +// Here are the accessors. +short* getAliens() { + return aliens; +} + +void setAliens(unsigned short alien, unsigned short position) { + xil_printf("setting alien\r\n"); + aliens[position] = alien; +} + +unsigned short getGuise() { + return guise; +} + +void setGuise(unsigned short frame) { + guise = frame; +} + +unsigned short getDirection() { + return alienDirection; +} + +void setDirection(unsigned short direction) { + alienDirection = direction; +} + +void setAlienBlockPosition(unsigned short x, unsigned short y) { + alienBlockPosition.x = x; + alienBlockPosition.y = y; +} + +unsigned short getAlienBlockPositionX() { + return alienBlockPosition.x; +} + +unsigned short getAlienBlockPositionY() { + return alienBlockPosition.y; +} +void setTankPosition(unsigned short x, unsigned short y) { + tankPosition.x = x; + tankPosition.y = y; +} + +unsigned short getTankPositionX() { + return tankPosition.x; +} + +unsigned short getTankPositionY() { + return tankPosition.y; +} + diff --git a/ecen427/global.h b/ecen427/global.h new file mode 100644 index 0000000..5945c59 --- /dev/null +++ b/ecen427/global.h @@ -0,0 +1,16 @@ +#ifndef GLOBAL_H_ +#define GLOBAL_H_ +#define WORD_WIDTH 32; + +typedef struct {unsigned short x; unsigned short y;} point_t; + +void setAlienBlockPosition(unsigned short x, unsigned short y); +unsigned short getAlienBlockPositionX(); +unsigned short getAlienBlockPositionY(); + +void setTankPosition(unsigned short x, unsigned short y); +unsigned short getTankPositionX(); +unsigned short getTankPositionY(); + + +#endif /* GLOBAL_H_ */ diff --git a/ecen427/lscript.ld b/ecen427/lscript.ld new file mode 100644 index 0000000..027d19f --- /dev/null +++ b/ecen427/lscript.ld @@ -0,0 +1,213 @@ +/*******************************************************************/ +/* */ +/* This file is automatically generated by linker script generator.*/ +/* */ +/* Version: Xilinx EDK 13.4 EDK_O.87xd */ +/* */ +/* Copyright (c) 2010 Xilinx, Inc. All rights reserved. */ +/* */ +/* Description : MicroBlaze Linker Script */ +/* */ +/*******************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x1000; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x400; + +/* Define Memories in the system */ + +MEMORY +{ + microblaze_0_i_bram_ctrl_microblaze_0_d_bram_ctrl : ORIGIN = 0x00000050, LENGTH = 0x00007FB0 + MCB_DDR2_S0_AXI_BASEADDR : ORIGIN = 0xC0000000, LENGTH = 0x08000000 +} + +/* Specify the default entry point to the program */ + +ENTRY(_start) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors.reset 0x00000000 : { + *(.vectors.reset) +} + +.vectors.sw_exception 0x00000008 : { + *(.vectors.sw_exception) +} + +.vectors.interrupt 0x00000010 : { + *(.vectors.interrupt) +} + +.vectors.hw_exception 0x00000020 : { + *(.vectors.hw_exception) +} + +.text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) +} > MCB_DDR2_S0_AXI_BASEADDR + +.init : { + KEEP (*(.init)) +} > MCB_DDR2_S0_AXI_BASEADDR + +.fini : { + KEEP (*(.fini)) +} > MCB_DDR2_S0_AXI_BASEADDR + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.sdata2 : { + . = ALIGN(8); + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + . = ALIGN(8); + __sdata2_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.data : { + . = ALIGN(4); + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + __data_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.got : { + *(.got) +} > MCB_DDR2_S0_AXI_BASEADDR + +.got1 : { + *(.got1) +} > MCB_DDR2_S0_AXI_BASEADDR + +.got2 : { + *(.got2) +} > MCB_DDR2_S0_AXI_BASEADDR + +.eh_frame : { + *(.eh_frame) +} > MCB_DDR2_S0_AXI_BASEADDR + +.jcr : { + *(.jcr) +} > MCB_DDR2_S0_AXI_BASEADDR + +.gcc_except_table : { + *(.gcc_except_table) +} > MCB_DDR2_S0_AXI_BASEADDR + +.sdata : { + . = ALIGN(8); + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.sbss : { + . = ALIGN(4); + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + . = ALIGN(8); + __sbss_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +.bss : { + . = ALIGN(4); + __bss_start = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end = .; +} > MCB_DDR2_S0_AXI_BASEADDR + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + +.heap : { + . = ALIGN(8); + _heap = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; +} > microblaze_0_i_bram_ctrl_microblaze_0_d_bram_ctrl + +.stack : { + _stack_end = .; + . += _STACK_SIZE; + . = ALIGN(8); + _stack = .; + __stack = _stack; +} > microblaze_0_i_bram_ctrl_microblaze_0_d_bram_ctrl + +_end = .; +} + diff --git a/ecen427/nes.c b/ecen427/nes.c new file mode 100644 index 0000000..a6bfc68 --- /dev/null +++ b/ecen427/nes.c @@ -0,0 +1,14 @@ +/***************************************************************************** +* Filename: C:\Users\superman\Desktop\korea\SpaceInvaderTestHW2/drivers/nes_v1_00_a/src/nes.c +* Version: 1.00.a +* Description: nes Driver Source File +* Date: Tue Nov 18 16:03:58 2014 (by Create and Import Peripheral Wizard) +*****************************************************************************/ + + +/***************************** Include Files *******************************/ + +#include "nes.h" + +/************************** Function Definitions ***************************/ + diff --git a/ecen427/nes.h b/ecen427/nes.h new file mode 100644 index 0000000..7b01caa --- /dev/null +++ b/ecen427/nes.h @@ -0,0 +1,123 @@ +/***************************************************************************** +* Filename: C:\Users\superman\Desktop\korea\SpaceInvaderTestHW2/drivers/nes_v1_00_a/src/nes.h +* Version: 1.00.a +* Description: nes Driver Header File +* Date: Tue Nov 18 16:03:58 2014 (by Create and Import Peripheral Wizard) +*****************************************************************************/ + +#ifndef NES_H +#define NES_H + +/***************************** Include Files *******************************/ + +#include "xbasic_types.h" +#include "xstatus.h" +#include "xil_io.h" + +/************************** Constant Definitions ***************************/ + + +/** + * User Logic Slave Space Offsets + * -- SLV_REG0 : user logic slave module register 0 + */ +#define NES_USER_SLV_SPACE_OFFSET (0x00000000) +#define NES_SLV_REG0_OFFSET (NES_USER_SLV_SPACE_OFFSET + 0x00000000) + +/**************************** Type Definitions *****************************/ + + +/***************** Macros (Inline Functions) Definitions *******************/ + +/** + * + * Write a value to a NES register. A 32 bit write is performed. + * If the component is implemented in a smaller width, only the least + * significant data is written. + * + * @param BaseAddress is the base address of the NES device. + * @param RegOffset is the register offset from the base to write to. + * @param Data is the data written to the register. + * + * @return None. + * + * @note + * C-style signature: + * void NES_mWriteReg(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Data) + * + */ +#define NES_mWriteReg(BaseAddress, RegOffset, Data) \ + Xil_Out32((BaseAddress) + (RegOffset), (Xuint32)(Data)) + +/** + * + * Read a value from a NES register. A 32 bit read is performed. + * If the component is implemented in a smaller width, only the least + * significant data is read from the register. The most significant data + * will be read as 0. + * + * @param BaseAddress is the base address of the NES device. + * @param RegOffset is the register offset from the base to write to. + * + * @return Data is the data from the register. + * + * @note + * C-style signature: + * Xuint32 NES_mReadReg(Xuint32 BaseAddress, unsigned RegOffset) + * + */ +#define NES_mReadReg(BaseAddress, RegOffset) \ + Xil_In32((BaseAddress) + (RegOffset)) + + +/** + * + * Write/Read 32 bit value to/from NES user logic slave registers. + * + * @param BaseAddress is the base address of the NES device. + * @param RegOffset is the offset from the slave register to write to or read from. + * @param Value is the data written to the register. + * + * @return Data is the data from the user logic slave register. + * + * @note + * C-style signature: + * void NES_mWriteSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Value) + * Xuint32 NES_mReadSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset) + * + */ +#define NES_mWriteSlaveReg0(BaseAddress, RegOffset, Value) \ + Xil_Out32((BaseAddress) + (NES_SLV_REG0_OFFSET) + (RegOffset), (Xuint32)(Value)) + +#define NES_mReadSlaveReg0(BaseAddress, RegOffset) \ + Xil_In32((BaseAddress) + (NES_SLV_REG0_OFFSET) + (RegOffset)) + +/************************** Function Prototypes ****************************/ + + +/** + * + * Run a self-test on the driver/device. Note this may be a destructive test if + * resets of the device are performed. + * + * If the hardware system is not built correctly, this function may never + * return to the caller. + * + * @param baseaddr_p is the base address of the NES instance to be worked on. + * + * @return + * + * - XST_SUCCESS if all self-test code passed + * - XST_FAILURE if any self-test code failed + * + * @note Caching must be turned off for this function to work. + * @note Self test may fail if data memory and device are not on the same bus. + * + */ +XStatus NES_SelfTest(void * baseaddr_p); +/** +* Defines the number of registers available for read and write*/ +#define TEST_AXI_LITE_USER_NUM_REG 1 + + +#endif /** NES_H */ diff --git a/ecen427/pit.c b/ecen427/pit.c new file mode 100644 index 0000000..7e8e477 --- /dev/null +++ b/ecen427/pit.c @@ -0,0 +1,14 @@ +/***************************************************************************** +* Filename: C:\Users\superman\Desktop\korea\SpaceInvaderTestHW2/drivers/pit_v1_00_a/src/pit.c +* Version: 1.00.a +* Description: pit Driver Source File +* Date: Thu Nov 06 14:24:21 2014 (by Create and Import Peripheral Wizard) +*****************************************************************************/ + + +/***************************** Include Files *******************************/ + +#include "pit.h" + +/************************** Function Definitions ***************************/ + diff --git a/ecen427/pit.h b/ecen427/pit.h new file mode 100644 index 0000000..2ee3500 --- /dev/null +++ b/ecen427/pit.h @@ -0,0 +1,129 @@ +/***************************************************************************** +* Filename: C:\Users\superman\Desktop\korea\SpaceInvaderTestHW2/drivers/pit_v1_00_a/src/pit.h +* Version: 1.00.a +* Description: pit Driver Header File +* Date: Thu Nov 06 14:24:21 2014 (by Create and Import Peripheral Wizard) +*****************************************************************************/ + +#ifndef PIT_H +#define PIT_H + +/***************************** Include Files *******************************/ + +#include "xbasic_types.h" +#include "xstatus.h" +#include "xil_io.h" + +/************************** Constant Definitions ***************************/ + + +/** + * User Logic Slave Space Offsets + * -- SLV_REG0 : user logic slave module register 0 + * -- SLV_REG1 : user logic slave module register 1 + */ +#define PIT_USER_SLV_SPACE_OFFSET (0x00000000) +#define PIT_SLV_REG0_OFFSET (PIT_USER_SLV_SPACE_OFFSET + 0x00000000) +#define PIT_SLV_REG1_OFFSET (PIT_USER_SLV_SPACE_OFFSET + 0x00000004) + +/**************************** Type Definitions *****************************/ + + +/***************** Macros (Inline Functions) Definitions *******************/ + +/** + * + * Write a value to a PIT register. A 32 bit write is performed. + * If the component is implemented in a smaller width, only the least + * significant data is written. + * + * @param BaseAddress is the base address of the PIT device. + * @param RegOffset is the register offset from the base to write to. + * @param Data is the data written to the register. + * + * @return None. + * + * @note + * C-style signature: + * void PIT_mWriteReg(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Data) + * + */ +#define PIT_mWriteReg(BaseAddress, RegOffset, Data) \ + Xil_Out32((BaseAddress) + (RegOffset), (Xuint32)(Data)) + +/** + * + * Read a value from a PIT register. A 32 bit read is performed. + * If the component is implemented in a smaller width, only the least + * significant data is read from the register. The most significant data + * will be read as 0. + * + * @param BaseAddress is the base address of the PIT device. + * @param RegOffset is the register offset from the base to write to. + * + * @return Data is the data from the register. + * + * @note + * C-style signature: + * Xuint32 PIT_mReadReg(Xuint32 BaseAddress, unsigned RegOffset) + * + */ +#define PIT_mReadReg(BaseAddress, RegOffset) \ + Xil_In32((BaseAddress) + (RegOffset)) + + +/** + * + * Write/Read 32 bit value to/from PIT user logic slave registers. + * + * @param BaseAddress is the base address of the PIT device. + * @param RegOffset is the offset from the slave register to write to or read from. + * @param Value is the data written to the register. + * + * @return Data is the data from the user logic slave register. + * + * @note + * C-style signature: + * void PIT_mWriteSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Value) + * Xuint32 PIT_mReadSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset) + * + */ +#define PIT_mWriteSlaveReg0(BaseAddress, RegOffset, Value) \ + Xil_Out32((BaseAddress) + (PIT_SLV_REG0_OFFSET) + (RegOffset), (Xuint32)(Value)) +#define PIT_mWriteSlaveReg1(BaseAddress, RegOffset, Value) \ + Xil_Out32((BaseAddress) + (PIT_SLV_REG1_OFFSET) + (RegOffset), (Xuint32)(Value)) + +#define PIT_mReadSlaveReg0(BaseAddress, RegOffset) \ + Xil_In32((BaseAddress) + (PIT_SLV_REG0_OFFSET) + (RegOffset)) +#define PIT_mReadSlaveReg1(BaseAddress, RegOffset) \ + Xil_In32((BaseAddress) + (PIT_SLV_REG1_OFFSET) + (RegOffset)) + +/************************** Function Prototypes ****************************/ + + +/** + * + * Run a self-test on the driver/device. Note this may be a destructive test if + * resets of the device are performed. + * + * If the hardware system is not built correctly, this function may never + * return to the caller. + * + * @param baseaddr_p is the base address of the PIT instance to be worked on. + * + * @return + * + * - XST_SUCCESS if all self-test code passed + * - XST_FAILURE if any self-test code failed + * + * @note Caching must be turned off for this function to work. + * @note Self test may fail if data memory and device are not on the same bus. + * + */ +XStatus PIT_SelfTest(void * baseaddr_p); +/** +* Defines the number of registers available for read and write*/ +#define TEST_AXI_LITE_USER_NUM_REG 2 + + +#endif /** PIT_H */ diff --git a/ecen427/platform.c b/ecen427/platform.c new file mode 100644 index 0000000..3eaf385 --- /dev/null +++ b/ecen427/platform.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2010-2011 Xilinx, Inc. All rights reserved. + * + * Xilinx, Inc. + * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A + * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS + * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR + * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION + * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE + * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. + * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO + * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO + * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE + * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include "xparameters.h" +#include "xil_cache.h" + +#include "platform_config.h" + +#ifdef STDOUT_IS_PS7_UART +#include "xuartps.h" +#elif defined(STDOUT_IS_16550) +#include "xuartns550_l.h" +#endif + +#define UART_BAUD 9600 + +void +enable_caches() +{ +#ifdef __PPC__ + Xil_ICacheEnableRegion(CACHEABLE_REGION_MASK); + Xil_DCacheEnableRegion(CACHEABLE_REGION_MASK); +#elif __MICROBLAZE__ +#ifdef XPAR_MICROBLAZE_USE_ICACHE + Xil_ICacheEnable(); +#endif +#ifdef XPAR_MICROBLAZE_USE_DCACHE + Xil_DCacheEnable(); +#endif +#endif +} + +void +disable_caches() +{ + Xil_DCacheDisable(); + Xil_ICacheDisable(); +} + +void +init_uart() +{ +#ifdef STDOUT_IS_PS7_UART + /* Use the PS UART for Zynq devices */ + XUartPs Uart_Ps_0; + XUartPs_Config *Config_0 = XUartPs_LookupConfig(UART_DEVICE_ID); + XUartPs_CfgInitialize(&Uart_Ps_0, Config_0, Config_0->BaseAddress); + XUartPs_SetBaudRate(&Uart_Ps_0, UART_BAUD); +#elif defined(STDOUT_IS_16550) + XUartNs550_SetBaud(STDOUT_BASEADDR, XPAR_XUARTNS550_CLOCK_HZ, UART_BAUD); + XUartNs550_SetLineControlReg(STDOUT_BASEADDR, XUN_LCR_8_DATA_BITS); +#endif +} + +void +init_platform() +{ + enable_caches(); + init_uart(); +} + +void +cleanup_platform() +{ + disable_caches(); +} diff --git a/ecen427/platform.h b/ecen427/platform.h new file mode 100644 index 0000000..efc9088 --- /dev/null +++ b/ecen427/platform.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2008 Xilinx, Inc. All rights reserved. + * + * Xilinx, Inc. + * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A + * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS + * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR + * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION + * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE + * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. + * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO + * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO + * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE + * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef __PLATFORM_H_ +#define __PLATFORM_H_ + +#include "platform_config.h" + +void init_platform(); +void cleanup_platform(); + +#endif diff --git a/ecen427/platform_config.h b/ecen427/platform_config.h new file mode 100644 index 0000000..df292fe --- /dev/null +++ b/ecen427/platform_config.h @@ -0,0 +1,8 @@ +#ifndef __PLATFORM_CONFIG_H_ +#define __PLATFORM_CONFIG_H_ + +#ifdef __PPC__ +#define CACHEABLE_REGION_MASK 0x80000080 +#endif + +#endif diff --git a/ecen427/score.c b/ecen427/score.c new file mode 100644 index 0000000..190bee4 --- /dev/null +++ b/ecen427/score.c @@ -0,0 +1,618 @@ +#include "score.h" +#include "xintc_l.h" // Provides handy macros for the interrupt controller. + +#define SCORE_START1 20 +#define SCORE_START2 360 +int score_position[10] = {SCORE_START1, SCORE_START1+12, SCORE_START1+24, SCORE_START1+36, SCORE_START1+48, \ + SCORE_START2, SCORE_START2+12, SCORE_START2+24, SCORE_START2+36, SCORE_START2+48}; + +int score_x = 20; +int score_y = 10; + + +int number_position[4] = {100, 116, 132, 148}; +int number_x = 100; +int number_y = 10; + +int tank_position[3] = {440, 480, 520}; +int tank_x = 440; +int tank_y = 10; + +int lives = 3; + + +#define GAMEOVER_X 250 + +int gameover_position[8] = {GAMEOVER_X, GAMEOVER_X+12, GAMEOVER_X+24, GAMEOVER_X+36, GAMEOVER_X+64, GAMEOVER_X+76, GAMEOVER_X+88, GAMEOVER_X+100}; +int game_x = 250; +int game_y = 200; + + +int total_score = 0; + + +#define TANK_HEIGHT 16 +#define TANK_WIDTH 32 +extern int tank[TANK_HEIGHT]; + +void renderScore(unsigned int* framePointer) { // draw for the first time + short x=0, y=0; + int i; + + for(i=0; i<10; i++){ + score_x = score_position[i]; + switch(i){ + case 0: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((s_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 1: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((c_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 2: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((o_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + + case 3: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((r_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + + break; + case 4: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((e_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 5: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((l_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 6: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((i_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 7: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((v_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 8: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((e_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + case 9: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((s_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(score_y+x)*640 + score_x+y] = 0x00FFFFFF; + } else { + framePointer[(score_y+x)*640 + score_x+y] = 0x00000000; + } + } + } + break; + + default : + + break; + } + } + +} + + +void updateMyscore(int adding_score){ + total_score += adding_score; +} + +void drawNumber(unsigned int* framePointer, int digit, int number){ + short x=0, y=0; + + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + + switch(number){ + case 0: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((o_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 1: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((one_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 2: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((two_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 3: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((three_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 4: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((four_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 5: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((five_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 6: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((six_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 7: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((seven_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 8: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((eight_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + case 9: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((nine_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[digit]+y] = 0x00000000; + } + } + } + break; + default: + break; + } + +} + +void updateNumber(unsigned int* framePointer){ + int i; + int first; + int second; + int third; + int fourth; + + int temp_score = total_score; + + if(temp_score >= 1000){ // 4-digit scores + for(i = 0; i < 4; i++){ + switch(i){ + case 0: + fourth = 0; + drawNumber(framePointer, 3, fourth); + break; + case 1: + third = temp_score % 10; + temp_score -= third; + drawNumber(framePointer, 2, third); + break; + case 2: + second = temp_score % 10; + temp_score -= second; + drawNumber(framePointer, 1, second); + break; + case 3: + first = temp_score; + drawNumber(framePointer, 0, first); + break; + + default: + break; + } + temp_score = temp_score / 10; + } + + + } + else if(temp_score >= 100 && temp_score < 1000){ // 3-digit scores + for(i = 0; i < 3; i++){ + switch(i){ + case 0: + third = temp_score % 10; + temp_score -= third; + drawNumber(framePointer, 2, third); + break; + case 1: + second = temp_score % 10; + temp_score -= second; + drawNumber(framePointer, 1, second); + break; + case 2: + first = temp_score; + drawNumber(framePointer, 0, first); + break; + default: + break; + } + temp_score = temp_score / 10; + } + + } + else if(temp_score >= 10 && temp_score < 100){ // 2-digit scores + for(i = 0; i < 2; i++){ + switch(i){ + case 0: + second = temp_score % 10; + temp_score -= second; + drawNumber(framePointer, 1, second); + break; + case 1: + first = temp_score; + drawNumber(framePointer, 0, first); + break; + default: + break; + } + temp_score = temp_score / 10; + } + + } +} + + + +void renderNumber(unsigned int* framePointer) { // draw for the first time + short x=0, y=0; + + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((o_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(number_y+x)*640 + number_position[0]+y] = 0x0000FF00; + } else { + framePointer[(number_y+x)*640 + number_position[0]+y] = 0x00000000; + } + } + } + +} + +void renderTanks(unsigned int* framePointer) { // draw for the first time + short x=0, y=0; + int i; + + for(i=0; i<3; i++){ + tank_x = tank_position[i]; + switch(i){ + case 0: + for(x = 0; x < TANK_HEIGHT; x++) { + for(y = 0; y < TANK_WIDTH; y++){ + if ((tank[x%TANK_HEIGHT] & (1<<(TANK_WIDTH-1-y)))) { + framePointer[(tank_y+x)*640 + tank_x+y] = 0x0000FF00; + } else { + framePointer[(tank_y+x)*640 + tank_x+y] = 0x00000000; + } + } + } + break; + case 1: + for(x = 0; x < TANK_HEIGHT; x++) { + for(y = 0; y < TANK_WIDTH; y++){ + if ((tank[x%TANK_HEIGHT] & (1<<(TANK_WIDTH-1-y)))) { + framePointer[(tank_y+x)*640 + tank_x+y] = 0x0000FF00; + } else { + framePointer[(tank_y+x)*640 + tank_x+y] = 0x00000000; + } + } + } + break; + case 2: + for(x = 0; x < TANK_HEIGHT; x++) { + for(y = 0; y < TANK_WIDTH; y++){ + if ((tank[x%TANK_HEIGHT] & (1<<(TANK_WIDTH-1-y)))) { + framePointer[(tank_y+x)*640 + tank_x+y] = 0x0000FF00; + } else { + framePointer[(tank_y+x)*640 + tank_x+y] = 0x00000000; + } + } + } + break; + + default : + + break; + } + } + +} + +void blankTanks(unsigned int* framePointer, int which_tank){ + short x=0, y=0; + + tank_x = tank_position[which_tank]; + + for(x = 0; x < TANK_HEIGHT; x++) { + for(y = 0; y < TANK_WIDTH; y++){ + framePointer[(tank_y+x)*640 + tank_x+y] = 0x00000000; + + } + } + +} + +void gameOver(unsigned int* framePointer){ + short x=0, y=0; + int i; + int counter; + + XIntc_MasterDisable(XPAR_INTC_0_BASEADDR); + setGameState(0); + + int row = 0; + int col = 0; + for(row=0; row<480; row++) { + for(col=0; col<640; col++) { + framePointer[row*640 + col] = 0x00000000; + + } + } + + + for(i=0; i<8; i++){ + counter = 0; + game_x = gameover_position[i]; + switch(i){ + case 0: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((g_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x00FF0000; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + case 1: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((a_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x0000FF00; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + case 2: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((m_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x000000FF; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + + case 3: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((e_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x00FFFF00; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + case 4: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((o_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x0000FFFF; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + case 5: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((v_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x00FF00FF; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + case 6: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((e_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x008888FF; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + + case 7: + for(x = 0; x < SCORE_HEIGHT; x++) { + for(y = 0; y < SCORE_WIDTH; y++){ + if ((r_block[x%SCORE_HEIGHT] & (1<<(SCORE_WIDTH-1-y)))) { + framePointer[(game_y+x)*640 + game_x+y] = 0x00448844; + } else { + framePointer[(game_y+x)*640 + game_x+y] = 0x00000000; + } + } + } + break; + + default : + + break; + } + + while(counter < 3000000){ + counter++; + } + + } + exit(0); + +} + +int tankDied(unsigned int* framePointer){ + + switch(lives){ + + case 3: + blankTanks(framePointer, 2); + + break; + + case 2: + blankTanks(framePointer, 1); + break; + + case 1: + blankTanks(framePointer, 0); + + break; + + case 0: + gameOver(framePointer); + return 1; + break; + + default: + + break; + } + lives--; + + return 0; +} diff --git a/ecen427/score.h b/ecen427/score.h new file mode 100644 index 0000000..65ab1e4 --- /dev/null +++ b/ecen427/score.h @@ -0,0 +1,402 @@ +#ifndef SCORE_H_ +#define SCORE_H_ + +#define SCORE_HEIGHT 16 +#define SCORE_WIDTH 10 +#define packWord10(b9,b8,b7,b6,b5,b4,b3,b2,b1,b0) \ + ((b9 << 9 ) | (b8 << 8 ) | \ + (b7 << 7 ) | (b6 << 6 ) | (b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 )) + +int s_block[SCORE_HEIGHT] = // S block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), +}; + +int c_block[SCORE_HEIGHT] = // C block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), +}; +int o_block[SCORE_HEIGHT] = // O block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), +}; + +int r_block[SCORE_HEIGHT] = // R block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), +}; +int e_block[SCORE_HEIGHT] = // E block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), +}; + +int l_block[SCORE_HEIGHT] = // L block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), +}; + +int i_block[SCORE_HEIGHT] = // I block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), +}; + +int v_block[SCORE_HEIGHT] = // V block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,0,0,1,1,0,0), + packWord10(0,0,1,1,0,0,1,1,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), +}; + +int g_block[SCORE_HEIGHT] = // G block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,1,1,1,1,1,1), + packWord10(1,1,0,0,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), +}; + +int a_block[SCORE_HEIGHT] = // A block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,1,1,0,0,1,1,0,0), + packWord10(0,0,1,1,0,0,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), +}; +int m_block[SCORE_HEIGHT] = // M block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,1,0,0,0,0,1,1,1), + packWord10(1,1,1,1,0,0,1,1,1,1), + packWord10(1,1,0,1,1,1,1,0,1,1), + packWord10(1,1,0,0,1,1,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), +}; + +int one_block[SCORE_HEIGHT] = // 1 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,0,0,0,0), + packWord10(0,0,1,1,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), + packWord10(0,0,0,0,1,1,0,0,0,0), +}; + +int two_block[SCORE_HEIGHT] = // 2 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), +}; + +int three_block[SCORE_HEIGHT] = // 3 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), +}; + +int four_block[SCORE_HEIGHT] = // 4 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), +}; +int five_block[SCORE_HEIGHT] = // 5 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), +}; +int six_block[SCORE_HEIGHT] = // 6 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), +}; +int seven_block[SCORE_HEIGHT] = // 7 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(1,1,1,1,1,1,1,1,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,1,1,0), + packWord10(0,0,0,0,0,0,0,1,1,0), + packWord10(0,0,0,0,0,0,1,1,0,0), + packWord10(0,0,0,0,0,0,1,1,0,0), + packWord10(0,0,0,0,0,1,1,0,0,0), + packWord10(0,0,0,0,0,1,1,0,0,0), +}; +int eight_block[SCORE_HEIGHT] = // 8 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), +}; +int nine_block[SCORE_HEIGHT] = // 9 block +{ + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,0,0,0,0,0,0,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(1,1,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,1,1,1,1,1,1,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,0,0,0,0,0,0,1,1), + packWord10(0,0,1,1,1,1,1,1,0,0), + packWord10(0,0,1,1,1,1,1,1,0,0), +}; + +#endif /* SCORE_H_ */ diff --git a/ecen427/shoot.c b/ecen427/shoot.c new file mode 100644 index 0000000..de4d79e --- /dev/null +++ b/ecen427/shoot.c @@ -0,0 +1,3 @@ +int shoot_soundData[] = {127,99,103,92,42,127,31,105,52,118,55,92,116,31,104,61,84,102,72,101,75,127,47,121,47,94,125,49,90,72,79,121,61,118,68,122,51,120,64,106,113,83,105,54,122,56,123,74,106,41,20,91,43,84,93,115,34,81,106,47,72,58,65,113,95,12,0,79,89,111,120,18,1,1,118,0,0,0,0,0,89,20,1,1,1,1,66,0,0,0,20,86,95,119,1,1,1,75,37,0,0,15,0,60,89,1,1,1,1,1,60,0,0,41,60,44,128,45,1,1,1,106,51,12,0,0,10,120,55,48,20,1,1,47,0,0,0,15,16,31,128,1,1,1,1,4,112,0,0,0,77,68,75,85,1,1,1,23,117,53,0,0,9,106,77,123,47,1,1,1,110,68,7,0,0,0,120,90,97,37,1,1,1,82,0,0,0,0,0,81,42,31,27,1,1,1,115,0,0,0,75,63,47,126,47,1,1,1,34,119,54,0,0,0,112,123,103,71,1,1,1,34,120,74,0,0,0,102,96,98,79,1,1,1,1,65,119,0,0,0,44,125,116,122,34,1,1,1,20,98,50,0,0,0,17,127,48,92,62,1,1,1,58,19,0,0,0,0,40,102,51,65,47,1,1,1,109,74,20,0,0,0,112,116,119,76,1,1,1,20,45,122,0,0,0,33,85,81,123,49,1,1,1,1,1,124,0,0,0,29,31,33,115,72,1,1,8,1,1,30,33,0,0,0,55,44,58,128,41,1,13,1,1,1,30,36,0,0,0,12,31,98,86,24,31,28,1,1,1,116,39,0,0,0,0,13,96,64,64,82,14,1,1,1,49,50,0,0,0,0,0,70,107,24,64,65,8,1,1,20,116,40,0,0,0,0,24,118,48,89,93,32,1,1,1,47,119,63,10,0,0,0,88,120,115,103,75,3,1,1,28,17,37,87,0,0,0,0,22,54,126,52,56,79,18,1,1,25,48,119,75,0,0,0,0,94,105,112,78,31,52,41,1,1,1,55,112,44,10,0,0,0,91,101,115,89,42,11,24,40,1,1,31,106,63,23,0,0,0,40,101,113,116,58,40,58,37,1,1,23,76,119,81,17,0,0,0,64,78,108,102,59,16,44,49,23,1,1,47,112,71,36,0,0,0,22,103,106,120,86,56,8,35,44,23,1,1,61,112,37,6,0,0,0,27,126,128,117,83,66,32,13,35,42,23,1,35,112,54,2,0,0,0,0,67,102,79,95,83,85,42,6,35,45,31,13,52,122,48,9,3,0,0,2,75,102,89,96,79,54,38,61,61,35,7,21,68,113,105,53,0,0,0,15,63,79,123,90,54,41,82,96,65,16,27,51,56,49,52,109,20,0,0,0,0,19,89,92,82,93,88,69,40,73,85,54,45,16,44,85,102,113,68,0,0,0,0,16,54,115,104,56,42,78,99,80,55,64,79,61,38,48,88,120,87,55,2,0,0,0,55,77,108,104,76,45,58,90,86,69,61,75,71,51,38,82,107,124,91,60,0,0,0,3,64,88,108,97,58,59,75,89,79,62,83,97,72,66,42,54,96,103,116,103,34,0,0,3,6,19,71,115,90,52,72,86,73,59,90,112,104,76,52,62,82,76,71,99,124,96,60,36,0,0,0,24,78,105,125,100,71,54,79,88,88,75,86,114,102,76,55,75,89,88,85,86,128,85,44,30,16,0,3,22,58,120,119,107,83,80,62,71,92,100,100,86,110,120,95,71,65,85,100,93,88,114,108,84,60,17,0,7,29,48,55,85,128,85,73,85,78,69,78,96,109,104,96,110,123,107,88,68,86,102,97,97,100,126,109,96,68,23,5,13,23,50,71,81,106,110,88,68,65,83,85,88,82,95,117,117,109,112,124,114,97,80,82,96,103,106,109,106,128,109,91,53,44,34,15,24,40,70,82,96,126,107,76,72,78,83,82,79,90,112,112,107,106,119,126,127,113,107,103,100,93,88,107,117,120,121,120,118,106,92,74,46,26,31,44,55,60,75,91,119,110,100,90,83,73,73,88,95,97,97,100,114,117,113,113,124,128,126,117,112,119,113,104,93,96,109,116,123,120,127,116,112,118,112,89,68,50,46,53,53,58,67,84,105,105,113,120,100,86,85,83,80,79,89,96,103,103,104,116,117,114,116,116,126,124,127,119,123,128,128,121,116,114,113,109,106,110,120,126,127,126,128,116,111,113,120,119,87,46,13,0,6,53,96,117,95,56,1,1,82,82,58,55,105,37,48,82,71,70,112,21,52,79,70,71,120,17,49,79,68,67,118,14,52,78,65,65,112,14,49,78,64,60,109,13,45,77,58,57,103,11,40,81,60,58,99,24,31,82,53,58,88,35,20,98,53,58,81,51,6,118,51,55,72,73,1,117,51,57,63,89,1,92,55,54,57,113,1,65,58,53,55,115,1,42,75,51,55,96,24,13,96,44,54,78,56,1,123,47,57,63,93,1,79,53,55,55,122,1,41,64,47,51,98,18,11,98,46,60,75,65,1,106,46,53,55,114,1,55,58,48,50,101,13,13,91,44,51,70,66,1,104,46,54,58,127,1,44,68,43,50,92,34,1,116,43,54,61,92,1,69,51,46,53,102,8,10,94,41,54,65,80,1,82,48,46,54,113,1,20,81,40,54,72,79,1,88,47,48,58,111,4,11,89,46,51,71,80,1,76,50,46,54,101,21,1,106,41,54,64,104,1,49,63,39,51,88,54,1,116,40,48,55,120,1,16,82,40,53,68,93,1,65,51,46,50,94,42,1,120,40,53,57,120,1,14,88,41,54,70,100,1,49,60,43,53,85,66,1,90,46,47,60,101,34,1,125,41,48,61,122,1,13,95,37,51,70,112,1,35,67,41,54,75,92,1,56,55,43,53,84,72,1,79,50,46,57,95,55,1,100,47,47,60,101,40,1,117,44,50,61,112,32,1,126,44,51,65,113,27,1,122,39,48,63,115,20,1,120,47,48,64,119,25,1,118,43,50,68,116,27,1,128,46,47,67,112,37,1,121,47,53,63,108,51,1,102,50,48,61,98,64,1,86,50,50,58,92,83,1,61,57,39,46,77,107,1,48,65,34,51,78,119,1,23,79,41,50,72,120,24,1,112,43,47,67,106,55,1,96,47,47,60,92,86,1,56,63,46,55,82,114,1,14,91,48,50,75,118,44,1,110,48,47,63,101,89,1,55,64,47,57,84,120,13,3,106,44,55,71,111,68,1,79,55,47,55,91,110,4,13,92,47,54,77,113,65,1,88,54,48,63,92,112,6,13,96,51,50,74,106,72,1,71,57,48,54,87,123,23,1,116,50,51,65,105,92,1,42,67,48,53,84,118,56,1,96,55,51,58,95,116,14,4,108,48,51,67,101,97,1,40,71,50,50,81,113,76,1,69,57,47,53,88,122,51,1,103,50,48,61,96,121,30,1,123,51,53,65,98,112,14,16,102,48,48,72,103,110,1,24,84,50,53,74,103,100,1,34,84,51,54,79,106,97,1,32,78,53,54,75,106,102,1,30,85,51,54,75,105,104,1,28,89,51,54,74,106,109,11,18,106,50,50,74,103,117,25,6,126,53,53,65,101,127,48,1,109,54,53,61,91,120,65,1,79,61,47,57,87,115,92,1,45,71,54,53,78,109,110,13,16,108,55,55,65,105,128,54,1,100,58,51,58,98,115,85,1,48,74,51,53,79,112,113,28,3,128,55,51,64,102,122,75,1,61,67,48,57,89,111,113,23,7,123,58,55,68,102,119,80,1,61,72,51,58,84,112,120,40,1,106,55,51,60,92,115,97,3,27,99,54,58,72,103,123,78,1,61,68,53,60,81,113,120,49,1,92,61,51,58,89,119,112,31,1,119,58,54,64,94,119,102,17,16,112,54,58,68,103,119,100,10,32,96,46,48,65,101,118,97,10,32,94,50,55,65,106,122,97,8,35,99,51,55,68,105,126,100,13,28,108,55,51,70,101,122,102,25,14,128,55,55,65,98,119,112,41,1,104,60,54,63,91,119,120,62,1,75,64,51,63,85,109,126,85,1,38,94,57,58,71,108,122,103,31,11,116,57,51,67,94,118,120,69,1,64,74,53,58,82,109,126,102,27,10,126,57,57,67,95,118,124,73,1,59,77,54,60,78,106,125,106,42,1,103,61,54,63,88,116,126,90,14,30,112,58,50,67,96,120,120,76,1,54,79,54,55,71,102,122,114,61,1,75,68,53,60,79,108,125,112,58,1,85,67,50,57,85,108,126,112,54,1,88,65,50,58,85,112,128,110,59,3,83,67,50,57,82,105,123,117,66,3,71,72,50,58,79,108,126,119,79,7,49,92,58,60,72,99,119,123,95,27,20,126,58,51,67,94,113,126,109,58,4,82,67,50,61,84,105,128,120,92,13,37,103,58,53,67,96,116,126,110,58,7,86,68,50,61,79,111,126,123,93,25,27,125,58,50,64,95,112,127,116,79,8,54,92,58,54,72,99,118,124,109,66,7,69,75,53,57,81,106,118,123,112,56,1,80,67,54,60,81,109,123,119,113,59,4,83,71,53,60,81,106,118,119,113,66,6,69,77,54,63,77,102,119,123,112,79,16,54,99,54,54,74,98,118,124,119,92,32,24,124,60,48,63,94,115,126,116,104,61,7,78,72,55,55,78,109,119,121,112,88,31,28,127,63,50,63,91,112,127,117,112,68,17,56,92,60,57,71,101,119,123,113,107,59,7,76,72,53,57,70,101,113,127,120,112,59,18,89,68,50,55,77,102,118,123,116,106,59,16,86,70,57,60,81,102,116,124,114,113,66,16,69,87,53,57,72,99,118,124,113,113,83,27,44,120,60,50,68,91,115,126,120,116,100,58,17,88,72,55,58,79,106,120,123,117,113,88,32,38,124,60,48,67,91,112,125,123,113,110,80,24,52,108,55,51,71,94,113,126,117,112,112,75,24,61,103,57,53,71,95,112,127,116,116,113,82,30,52,115,57,51,71,94,112,125,121,113,113,92,47,32,110,64,51,60,79,108,123,123,116,116,106,72,27,69,89,54,54,72,96,116,127,117,119,114,96,59,27,100,68,51,55,78,106,118,126,120,116,110,95,52,35,107,64,51,63,79,105,120,127,116,114,117,96,54,35,100,64,53,60,75,102,120,126,116,112,112,102,68,32,78,89,55,54,70,95,116,125,119,113,114,114,92,52,40,112,63,51,63,84,102,118,126,120,116,113,109,85,42,58,122,60,48,65,88,112,118,124,117,117,117,113,88,47,54,128,60,50,65,87,105,120,124,117,117,113,113,96,58,44,104,70,54,60,79,101,118,126,119,119,119,114,110,82,48,62,116,57,51,71,89,111,123,128,119,116,113,109,110,79,45,72,109,57,51,70,92,111,123,120,119,119,113,113,109,85,54,58,128,61,50,63,85,108,120,124,117,116,113,113,116,104,72,48,93,89,54,54,74,96,112,128,124,116,117,113,114,116,99,72,51,97,84,58,53,72,98,116,127,117,113,114,110,116,119,109,80,55,76,111,57,51,70,92,111,125,124,116,114,112,114,116,117,102,73,51,99,84,54,51,70,92,106,125,123,120,114,116,119,120,121,112,76,56,93,98,55,50,75,89,112,125,123,117,116,113,116,117,119,121,99,68,61,112,75,55,55,81,99,115,124,119,113,114,114,117,116,120,120,103,72,59,103,84,57,55,77,98,115,128,119,114,116,112,117,120,119,117,114,95,71,71,117,74,54,64,79,102,116,127,117,117,116,112,117,116,120,121,120,106,80,64,95,96,58,53,77,96,115,123,124,114,117,117,114,114,121,119,121,126,106,79,68,96,101,58,54,72,91,111,122,121,119,113,114,114,117,120,119,121,126,123,103,80,71,107,87,61,55,77,94,112,127,121,117,117,114,116,117,120,119,121,124,128,119,95,78,73,124,75,53,60,81,101,118,126,120,116,117,113,116,121,120,119,126,127,124,128,116,89,75,89,115,70,54,67,85,108,119,120,120,114,114,117,114,116,124,121,124,126,126,126,128,109,88,73,100,106,68,57,65,92,106,123,124,120,114,116,116,119,117,123,127,123,126,125,126,126,126,110,89,80,96,113,71,55,65,87,105,119,123,117,116,116,119,116,117,126,123,126,127,124,124,128,126,126,117,102,89,82,114,95,67,57,72,95,111,126,124,116,114,116,116,117,120,119,126,121,124,128,128,128,126,126,126,124,106,93,83,95,118,79,60,67,84,102,120,127,121,116,116,114,114,116,124,121,126,126,123,127,128,126,126,126,126,125,126,119,100,93,86,110,102,74,58,72,88,109,122,126,117,116,116,117,119,120,119,126,121,124,128,127,128,124,128,126,128,125,126,126,128,121,106,97,93,93,125,91,65,63,75,95,115,123,124,116,114,113,116,117,126,124,127,128,128,123,127,127,125,123,126,126,126,125,127,125,125,125,126,121,113,102,97,99,121,102,78,61,71,89,106,120,127,119,117,113,114,114,117,117,120,124,128,123,128,128,124,128,126,124,126,126,126,128,126,126,126,128,128,128,125,127,126,117,104,104,100,106,126,99,82,65,70,89,106,120,123,117,116,113,116,117,119,117,124,120,123,127,128,123,127,128,124,128,126,125,126,128,124,128,126,126,126,126,126,125,125,125,126,128,128,128,128,128,127,114,112,106,109,112,123,108,91,79,70,77,96,106,123,123,117,112,116,116,117,119,117,124,103,80,119,102,113,113,116,126,90,122,99,126,113,124,90,118,103,126,111,120,90,115,105,127,111,124,96,120,102,128,115,126,96,120,101,127,109,126,93,119,105,128,109,126,92,116,101,127,111,126,92,116,108,127,111,128,97,119,112,127,111,125,99,120,116,128,106,126,106,126,123,120,111,120,117,110,126,113,116,119,123,103,126,106,120,113,124,96,122,102,128,109,126,93,115,111,127,109,126,102,125,119,123,111,120,117,110,126,109,120,116,123,92,118,102,128,109,126,93,119,108,127,111,125,107,126,123,118,115,122,124,97,128,108,125,111,124,92,118,109,127,111,125,106,124,128,119,112,119,124,97,123,106,128,111,128,97,120,118,125,112,122,117,106,126,111,125,115,127,92,116,112,128,111,125,112,114,128,113,118,116,126,92,120,106,126,115,126,110,117,123,113,122,116,126,90,118,106,127,112,125,112,113,127,116,119,118,126,96,116,116,125,116,126,123,102,128,109,126,116,128,103,126,120,120,118,120,124,90,122,109,126,112,120,120,117,125,109,115,118,123,102,122,116,120,112,122,127,93,119,108,123,113,125,120,104,126,112,122,118,122,106,124,125,119,116,116,126,99,119,118,123,118,122,124,97,120,109,125,115,125,119,100,123,111,123,118,126,117,114,128,116,119,118,128,109,124,122,115,118,123,128,104,128,120,125,116,116,124,103,120,120,123,118,122,128,99,122,119,125,119,123,127,97,116,116,126,119,123,127,97,116,116,126,119,120,124,97,116,118,125,119,120,124,102,118,118,123,122,123,127,103,120,120,123,118,122,128,104,120,125,125,116,123,126,112,126,120,120,113,122,126,112,119,122,118,118,123,120,121,109,125,119,119,122,120,124,102,122,115,123,118,119,124,102,119,113,123,115,126,124,110,122,125,122,115,122,125,119,113,126,119,119,125,120,124,102,122,115,126,123,122,127,103,122,119,125,119,123,126,117,114,123,119,119,125,118,124,102,118,118,125,116,126,126,116,124,125,123,116,123,120,124,102,122,113,122,118,122,128,110,126,123,122,115,126,120,124,103,116,116,123,118,122,128,114,127,123,125,116,123,120,124,103,116,116,128,116,126,126,117,119,122,120,119,122,120,124,107,120,125,125,116,127,122,127,103,122,119,125,119,128,123,120,112,128,120,118,123,123,127,114,126,122,125,119,127,118,124,107,119,123,125,119,127,122,127,103,120,120,125,119,127,128,127,106,122,122,125,120,127,125,124,117,122,120,119,125,125,127,116,119,128,120,120,126,126,126,119,119,123,122,125,125,126,127,121,119,128,120,120,123,128,128,120,119,126,120,125,125,125,125,120,116,128,120,125,125,125,125,124,112,128,115,119,116,122,123,127,112,118,115,125,118,126,120,126,112,118,122,128,116,128,122,127,116,120,125,125,119,128,123,127,120,124,125,125,122,123,128,128,127,113,123,122,125,123,128,125,125,114,120,125,125,123,128,128,128,124,120,126,122,125,123,128,125,127,113,118,125,125,123,128,128,128,124,120,126,122,125,123,128,128,127,114,119,125,125,123,128,128,128,127,119,126,122,125,125,125,126,127,114,122,126,125,123,128,125,128,127,114,119,123,125,123,123,128,128,127,119,125,125,125,123,128,128,128,124,126,123,125,125,125,126,126,126,120,126,125,125,123,123,128,128,128,119,120,123,123,123,125,127,128,128,119,120,125,125,125,123,128,128,128,120,123,123,128,119,126,128,128,128,120,123,123,128,123,123,123,123,127,120,123,125,125,119,128,128,123,126,121,127,126,120,125,125,125,125,125,127,121,125,125,125,125,123,128,128,128,119,120,123,128,125,128,128,125,125,124,125,125,125,125,126,126,126,126,126,120,126,120,126,125,123,128,128,128,120,123,125,125,123,128,123,128,128,128,123,126,125,125,125,123,128,123,128,123,123,125,125,123,128,128,128,128,128,121,123,125,125,125,125,126,126,126,126,121,125,125,125,125,125,126,126,126,126,126,125,125,125,125,126,126,126,126,126,127,125,125,125,125,126,126,126,126,124,125,125,125,125,126,126,126,126,126,126,123,127,125,125,127,125,125,125,125,127,127,125,125,125,125,126,126,126,126,127,126,126,125,125,125,125,126,127,125,127,121,125,125,127,125,125,125,127,125,127,126,123,125,127,125,127,125,125,125,127,127,126,123,125,125,125,126,126,126,122,127,128,123,123,123,122,126,122,126,128,123,128,128,128,123,128,123,128,128,128,128,128,127,127,125,127,125,125,125,125,126,126,126,126,125,125,125,126,126,126,126,128,128,128,127,125,125,125,125,126,126,126,126,126,126,127,125,125,125,125,126,125,125,127,125,127,127,125,125,125,125,126,126,126,126,125,125,127,125,125,125,125,126,125,125,125,125,126,125,127,125,127,127,125,125,127,125,127,125,127,127,125,125,125,125,127,125,125,125,126,128,128,127,125,127,125,125,0}; +int shoot_numberOfSamples = 4080; //removed all negatives from [] +int shoot_sampleRate = 8; diff --git a/ecen427/sounds.c b/ecen427/sounds.c new file mode 100644 index 0000000..2d252aa --- /dev/null +++ b/ecen427/sounds.c @@ -0,0 +1,215 @@ +/* + * sounds.c + * + * Created on: Oct 26, 2013 + * Author: superman + */ + +#include "sounds.h" + +extern int shoot_numberOfSamples; +extern int tankDeath_numberOfSamples; +extern int spaceShipSound_numberOfSamples; +extern int spaceShipDeathSound_numberOfSamples; +extern int alienDeathSound_numberOfSamples; +extern int alienMovement1Sound_numberOfSamples; +extern int alienMovement2Sound_numberOfSamples; +extern int alienMovement3Sound_numberOfSamples; +extern int alienMovement4Sound_numberOfSamples; + + +extern int shoot_soundData[]; +extern int tankDeath_soundData[]; +extern int spaceShipSound_soundData[]; +extern int spaceShipDeathSound_soundData[]; +extern int alienDeathSound_soundData[]; +extern int alienMovement1Sound_soundData[]; +extern int alienMovement2Sound_soundData[]; +extern int alienMovement3Sound_soundData[]; +extern int alienMovement4Sound_soundData[]; +extern int alienSilenceSound_soundData[]; +int haveTankBulletSound = 0; +int haveTankDeathSound = 0; +int haveSpaceShipSound = 0; +int haveSpaceShipDeathSound = 0; +int haveAlienDeathSound = 0; +int haveAlienMoveSound =1; + +int bulletSoundIndex = 0; +int tankDeathIndex = 0; +int spaceShipIndex = 0; +int spaceShipDeathIndex = 0; +int alienDeathIndex = 0; +int alienCadenceIndex = 1; +int alien1Index=0; +int alien2Index=0; +int alien3Index=0; +int alien4Index=0; +int isHaveTankBulletSound() { + return haveTankBulletSound; +} +void setHaveTankBulletSound(int x) { + haveTankBulletSound = x; +} + +int isHaveTankDeathSound() { + return haveTankDeathSound; +} +void setHaveTankDeathSound(int x) { + haveTankDeathSound = x; +} + +int isHaveSpaceShipSound() { + return haveSpaceShipSound; +} +void setHaveSpaceShipSound(int x) { + haveSpaceShipSound = x; +} + +int isHaveSpaceShipDeathSound() { + return haveSpaceShipDeathSound; +} +void setHaveSpaceShipDeathSound(int x) { + haveSpaceShipDeathSound = x; +} + +int isHaveAlienDeathSound() { + return haveAlienDeathSound; +} +void setHaveAlienDeathSound(int x) { + haveAlienDeathSound = x; +} +int isAlienSoundCadence(){ + return alienCadenceIndex; +} +void setAlienSoundCadence(int x){ + alienCadenceIndex = x; +} +//Responsible for rotating the different alien sounds called in the timer +void incrementAlienSoundCadence(){ + if(isAlienSoundCadence() == 8) + setAlienSoundCadence(1); + else + setAlienSoundCadence(isAlienSoundCadence() + 1); +} + +void fillSound(){ + int i; + for(i=0;i<256;i++){ + Xuint32 sample = getNextSample(); + XAC97_mSetInFifoData(XPAR_AXI_AC97_0_BASEADDR,sample); + } +} + + +Xuint32 getNextSample(){ + + Xuint32 sample = 0x00000000; //Play no sound + + if (haveTankBulletSound != 0) { + sample = (shoot_soundData[bulletSoundIndex] | (shoot_soundData[bulletSoundIndex])<<16); + if(bulletSoundIndex < (shoot_numberOfSamples - 1)){ + bulletSoundIndex++; + } else { + bulletSoundIndex = 0; + haveTankBulletSound = 0; + } + } else if (haveTankDeathSound != 0) { + sample = (tankDeath_soundData[tankDeathIndex] | (tankDeath_soundData[tankDeathIndex])<<16); + if (tankDeathIndex < (tankDeath_numberOfSamples - 1)) { + tankDeathIndex++; + } else { + tankDeathIndex = 0; + haveTankDeathSound = 0; + } + } else if (haveSpaceShipSound != 0 ) { //set in setHaveSpaceShip global + sample = (spaceShipSound_soundData[spaceShipIndex] | (spaceShipSound_soundData[spaceShipIndex])<<16); + if (spaceShipIndex < (spaceShipSound_numberOfSamples -1)) { + spaceShipIndex++; + } else { + spaceShipIndex = 0; + //Set no sound when it goes off the page - Done by setHaveSpaceShip global + + } + } else if (haveSpaceShipDeathSound != 0) { + sample = (spaceShipDeathSound_soundData[spaceShipDeathIndex] | (spaceShipDeathSound_soundData[spaceShipDeathIndex])<<16); + if (spaceShipDeathIndex < (spaceShipDeathSound_numberOfSamples - 1)) { + spaceShipDeathIndex++; + } else { + spaceShipDeathIndex = 0; + haveSpaceShipDeathSound = 0; + } + + } + else if (haveAlienDeathSound != 0) { + sample = (alienDeathSound_soundData[alienDeathIndex] | (alienDeathSound_soundData[alienDeathIndex])<<16); + if (alienDeathIndex < (alienDeathSound_numberOfSamples - 1)) { + alienDeathIndex++; + } else { + alienDeathIndex = 0; + haveAlienDeathSound = 0; + } + } +//Set to always on since aliens are always in the game + else if (haveAlienMoveSound != 0){ + //Performs the change in the four different sounds which are incremented by the alienCounter which is in timer_interrupt_handler() + switch (isAlienSoundCadence()){ + case 1: + sample = (alienMovement1Sound_soundData[alien1Index] | (alienMovement1Sound_soundData[alien1Index]) <<16); + + if(alien1Index < (alienMovement1Sound_numberOfSamples -1)){ + alien1Index++; + } + else{ + alien1Index = 0; + } + + + break; + case 3: + sample = (alienMovement2Sound_soundData[alien2Index] | (alienMovement2Sound_soundData[alienCadenceIndex]) <<16); + + if(alien2Index < (alienMovement2Sound_numberOfSamples -1)){ + alien2Index++; + } + else{ + alien2Index = 0; + } + break; + case 5: + sample = (alienMovement3Sound_soundData[alien3Index] | (alienMovement3Sound_soundData[alienCadenceIndex]) <<16); + + if(alien3Index < (alienMovement3Sound_numberOfSamples -1)){ + alien3Index++; + } + else{ + alien3Index = 0; + } + break; + case 7: + + + sample = (alienMovement4Sound_soundData[alien4Index] | (alienMovement4Sound_soundData[alienCadenceIndex]) <<16); + + if(alien4Index < (alienMovement4Sound_numberOfSamples -1)){ + alien4Index++; + } + else{ + alien4Index = 0; + } + break; + default: + sample = 0x00000080; + + break; + + } + + + + } + + return sample; +} + + diff --git a/ecen427/sounds.h b/ecen427/sounds.h new file mode 100644 index 0000000..bf277a8 --- /dev/null +++ b/ecen427/sounds.h @@ -0,0 +1,47 @@ +/* + * sounds.h + * + * Created on: Oct 29, 2013 + * Author: superman + */ + +#ifndef SOUNDS_H_ +#define SOUNDS_H_ + +#include +#include "xparameters.h" +#include "xac97_l.h" + + + +/** + * These are the Getters and setters to control global sounds + * Set the value to (1) in order to allow sound generation + * Set the value to (0) in order to halt the sound + */ +int isHaveTankBulletSound(); +void setHaveTankBulletSound(int x); + +int isHaveTankDeathSound(); +void setHaveTankDeathSound(int x); + +int isHaveSpaceShipSound(); +void setHaveSpaceShipSound(int x); + +int isHaveSpaceShipDeathSound(); +void setHaveSpaceShipDeathSound(int x); + +int isHaveAlienDeathSound(); +void setHaveAlienDeathSound(int x); + +int isAlienSoundCadence(); +void setAlienSoundCadence(); +void incrementAlienSoundCadence(); +//This loops through 128 values to control the fifo input of ac97 +void fillSound(); + + +Xuint32 getNextSample(); + +#endif /* SOUNDS_H_ */ + diff --git a/ecen427/spaceShipDeathSound.c b/ecen427/spaceShipDeathSound.c new file mode 100644 index 0000000..a4604b0 --- /dev/null +++ b/ecen427/spaceShipDeathSound.c @@ -0,0 +1,3 @@ +int spaceShipDeathSound_soundData[] = {1,94,102,101,46,7,47,59,111,106,96,80,93,30,36,57,99,120,74,95,31,13,47,64,116,101,94,85,75,10,49,62,114,102,84,70,8,31,53,92,118,100,82,94,33,30,55,89,124,79,95,18,18,47,71,119,102,86,97,50,17,53,73,120,85,101,25,9,43,62,114,101,90,92,50,17,52,73,120,87,97,24,10,44,71,114,103,90,93,34,23,53,84,125,89,78,9,23,48,91,124,93,92,73,7,44,58,109,93,96,36,6,42,64,110,104,90,88,29,28,53,95,113,97,58,0,37,52,104,115,89,94,35,20,52,85,116,99,57,0,35,53,104,117,89,94,35,20,52,85,113,101,54,0,37,54,106,107,99,80,18,31,54,101,106,98,22,8,42,76,117,96,104,47,8,47,71,127,107,59,0,31,51,104,114,100,76,12,34,55,104,109,86,10,13,45,92,123,96,97,22,23,52,94,119,92,19,8,43,81,125,94,101,24,20,50,90,115,92,19,8,43,88,127,100,86,14,29,52,107,118,71,2,19,47,102,113,108,55,4,43,61,-128,116,38,0,36,60,107,108,107,24,11,47,103,122,66,4,22,47,93,117,111,40,6,44,81,123,92,16,8,43,90,125,113,53,3,41,68,126,102,21,5,40,86,127,112,50,3,41,73,121,85,19,7,42,97,117,111,37,8,46,93,113,60,2,19,54,106,116,88,13,23,50,112,126,32,0,39,77,126,115,46,4,43,82,113,59,2,19,59,109,122,73,6,29,60,113,99,16,6,44,99,121,93,20,18,53,106,116,19,3,40,91,127,95,22,15,54,103,110,21,3,40,96,122,84,19,18,62,106,92,9,8,50,104,126,63,1,34,81,102,53,0,31,64,116,116,40,4,50,92,124,24,1,47,92,112,72,4,26,74,105,48,0,40,64,116,101,28,9,64,93,89,9,13,52,109,124,41,3,54,88,107,16,5,50,105,-128,45,2,57,85,113,17,4,54,108,125,40,3,59,85,94,13,18,55,109,114,29,7,72,87,62,0,47,70,107,74,9,32,71,119,28,0,49,100,125,36,4,66,84,72,0,46,68,104,67,4,43,74,117,21,6,64,99,99,19,17,68,116,36,0,57,98,126,23,8,71,95,38,0,56,90,126,27,7,67,102,33,0,60,93,117,25,10,75,108,35,0,67,90,97,16,33,61,114,24,11,71,97,64,1,61,66,68,0,57,72,126,35,4,67,118,42,0,73,87,68,1,61,65,60,0,69,69,113,21,30,57,107,21,30,66,112,41,1,69,121,32,1,75,99,51,1,72,97,39,0,74,89,52,1,67,96,38,0,83,93,50,1,68,110,36,9,72,102,39,1,61,113,18,39,66,122,25,29,55,66,0,72,69,75,1,62,84,44,0,61,103,44,16,63,87,7,58,60,80,9,63,94,31,13,69,127,32,29,68,55,0,72,95,47,9,59,78,4,65,71,54,3,58,99,12,61,65,63,7,57,105,19,60,67,61,9,56,97,14,64,77,54,4,69,80,7,63,108,50,4,80,60,3,68,112,37,23,113,43,30,66,69,12,61,87,10,65,109,49,10,104,58,16,68,76,13,57,84,12,65,122,42,16,126,43,44,76,61,10,89,63,13,66,78,13,67,76,12,64,92,26,47,82,18,64,109,32,39,88,17,65,113,34,45,86,23,64,105,25,52,79,21,68,87,20,79,69,24,74,64,10,110,55,37,93,50,25,103,33,59,112,28,65,74,25,83,72,5,116,38,61,123,35,71,79,26,93,63,18,101,33,70,101,12,122,60,45,125,34,78,84,23,105,64,31,93,23,96,82,7,94,28,92,92,7,95,38,81,101,6,103,40,88,99,12,95,35,95,94,13,89,25,114,80,37,86,19,121,49,94,87,38,108,20,107,59,86,96,23,87,22,120,55,99,86,50,97,23,91,30,127,58,97,81,55,91,26,86,23,111,50,127,63,101,80,73,80,51,87,36,81,31,98,40,100,38,113,57,120,54,123,59,118,61,112,71,109,64,102,66,109,68,106,76,111,65,113,62,126,54,124,56,105,47,98,55,91,44,75,59,75,66,67,91,58,121,65,103,50,85,58,75,68,62,104,53,105,68,85,53,64,93,52,106,73,85,59,55,115,46,80,82,68,102,58,98,50,51,110,45,68,94,59,115,75,79,90,57,98,59,43,116,51,46,126,46,50,118,46,69,96,56,106,78,78,91,58,105,50,57,116,46,103,78,68,77,58,123,37,72,80,62,93,66,119,46,81,67,66,75,62,109,53,121,63,98,46,85,56,76,51,72,67,70,79,70,91,61,102,63,114,65,115,66,116,60,109,69,107,67,99,67,93,72,77,75,65,78,44,79,35,78,31,99,40,106,53,124,70,89,79,52,83,29,73,30,106,47,121,72,71,86,25,73,29,118,56,85,77,43,95,23,102,63,82,93,10,75,32,116,78,33,72,21,125,59,59,82,18,117,50,72,78,23,122,48,68,80,21,127,55,53,77,21,109,62,20,77,31,91,79,3,98,46,60,106,16,109,66,37,112,44,39,80,25,78,75,12,118,51,42,113,47,33,82,27,70,87,9,90,56,23,83,47,10,125,46,46,102,43,23,93,33,66,123,36,41,81,26,70,116,31,46,81,23,70,118,30,36,89,32,65,119,37,24,104,38,44,98,40,8,122,50,25,77,56,10,81,56,8,73,95,30,40,97,31,59,88,41,12,97,53,6,74,87,27,42,109,33,45,80,48,8,77,60,12,72,110,30,16,96,42,7,75,113,31,27,105,33,17,68,96,24,37,110,32,19,75,103,22,39,97,28,10,76,115,27,29,85,43,3,78,104,26,11,73,68,9,67,74,51,14,62,118,19,27,71,114,21,28,74,46,7,76,77,40,9,67,108,21,12,79,120,23,9,70,80,15,52,69,95,22,34,68,46,12,73,69,76,12,55,72,38,0,78,72,64,13,50,68,40,5,72,73,85,20,33,71,59,9,59,76,109,15,17,77,101,18,22,79,109,25,4,77,92,15,0,85,86,67,14,47,73,76,8,45,80,118,21,7,82,103,14,2,67,83,100,16,21,83,121,14,5,77,100,70,15,41,80,93,9,18,74,112,61,10,48,77,83,11,24,72,112,56,10,44,82,89,12,12,75,115,75,12,28,83,122,9,5,69,107,108,6,18,80,100,24,0,71,80,-128,37,5,56,82,87,3,15,73,117,98,6,23,81,103,28,0,63,79,-128,57,6,41,80,127,11,4,65,95,-128,33,5,59,87,110,6,7,70,103,123,27,7,63,89,107,4,8,67,102,125,34,5,53,86,117,3,6,68,94,126,58,7,35,88,118,19,1,55,75,123,100,7,23,78,104,81,0,18,69,112,119,42,4,51,87,121,14,2,46,79,127,107,7,17,72,98,104,0,10,59,97,118,82,3,29,77,110,89,0,15,64,105,123,73,6,29,78,116,86,0,18,64,102,118,78,4,29,73,110,100,0,13,60,98,118,101,6,23,69,99,116,11,5,51,73,121,116,44,5,43,82,125,70,0,23,62,111,115,91,3,28,67,106,114,15,5,43,76,124,109,63,1,37,74,126,105,0,13,52,90,116,111,44,6,45,79,123,100,0,19,53,92,115,105,41,7,46,79,120,103,0,14,56,84,116,106,68,1,41,74,117,108,10,6,43,71,120,105,94,1,35,61,102,111,67,0,28,62,110,114,102,43,8,46,83,-128,104,11,8,42,70,122,96,104,3,29,52,92,107,99,0,17,51,82,115,98,92,1,37,60,106,107,90,0,24,59,89,117,97,92,1,37,54,107,111,91,0,22,51,83,113,96,99,12,28,52,87,112,101,23,6,40,67,127,102,94,61,6,46,67,124,99,77,0,30,60,96,108,95,92,15,31,57,97,108,88,33,6,43,60,114,106,94,87,1,41,63,107,106,90,11,13,45,68,125,104,90,82,2,44,65,109,103,91,10,13,45,68,127,98,93,82,2,44,56,102,101,90,42,5,42,67,119,108,90,92,18,33,54,82,112,96,78,0,34,54,99,113,96,90,73,6,49,0}; +int spaceShipDeathSound_numberOfSamples = 1802; +int spaceShipDeathSound_sampleRate = 8; diff --git a/ecen427/spaceShipSound.c b/ecen427/spaceShipSound.c new file mode 100644 index 0000000..c0573f7 --- /dev/null +++ b/ecen427/spaceShipSound.c @@ -0,0 +1,3 @@ +int spaceShipSound_soundData[] = {120,123,123,127,126,127,123,126,127,123,126,126,127,123,128,123,128,127,127,127,128,128,128,128,128,126,125,125,125,126,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,127,126,126,126,126,127,127,127,127,127,127,126,125,125,125,126,127,127,127,127,127,128,128,128,128,127,124,125,125,125,127,127,127,127,127,128,127,124,126,124,126,124,126,124,125,125,125,126,127,127,124,127,124,126,124,125,126,125,125,126,125,126,124,126,127,126,126,125,126,125,126,125,125,126,126,126,127,127,127,127,125,125,126,127,127,126,126,126,126,127,125,126,125,125,125,126,125,123,125,126,125,126,125,126,124,125,126,125,126,124,125,125,126,127,127,128,128,128,128,128,128,128,127,127,126,126,126,126,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,123,123,122,127,122,128,126,126,127,123,126,121,127,126,127,123,128,128,128,123,127,120,123,128,123,128,123,125,128,128,128,128,120,128,127,128,123,127,128,128,128,128,123,124,124,125,125,123,127,127,125,124,127,124,124,123,125,128,128,122,122,124,128,120,128,122,125,123,127,119,122,124,128,120,128,122,125,128,127,121,121,125,125,119,128,123,128,127,123,119,118,124,125,120,126,127,122,125,122,122,123,120,120,128,123,125,123,124,118,118,126,125,120,125,122,126,126,121,116,118,120,124,118,124,126,121,120,110,115,125,125,116,126,123,122,122,114,125,118,121,118,123,124,124,123,115,116,115,121,120,122,123,124,125,109,115,116,119,120,119,125,124,128,111,110,115,121,117,118,125,124,126,109,108,112,119,119,113,125,128,128,103,111,110,119,118,118,125,124,122,106,114,112,114,119,117,124,120,110,99,123,115,113,114,123,122,128,104,98,109,120,112,113,128,120,116,96,120,106,115,112,120,128,120,101,95,115,115,113,111,124,119,115,89,120,107,110,114,120,123,127,90,104,106,111,108,112,127,123,101,90,121,109,110,106,118,122,120,81,106,104,107,103,112,126,125,98,85,117,109,104,101,120,124,119,78,98,101,109,104,107,124,120,104,71,117,101,103,98,113,122,125,87,74,117,103,98,99,116,119,120,72,85,113,96,96,102,118,122,116,65,85,106,95,94,98,118,124,113,67,81,99,95,91,100,116,128,112,66,74,105,88,88,98,113,119,116,65,67,118,91,86,91,112,119,121,74,57,116,87,82,87,101,118,124,94,50,80,96,78,83,91,114,126,107,58,54,119,78,78,76,99,115,122,84,46,80,93,67,75,89,107,124,111,55,46,117,75,65,72,94,114,123,92,44,55,117,71,65,73,100,115,116,79,36,59,104,62,64,71,104,121,116,72,30,59,100,59,57,71,104,117,112,72,34,48,110,57,53,67,98,114,118,76,32,41,122,62,42,62,85,110,118,89,43,26,81,80,37,48,69,102,123,102,57,24,43,121,48,33,55,87,113,120,81,43,16,68,83,34,33,61,98,116,108,66,28,23,92,66,26,35,68,100,124,100,49,18,28,108,62,18,33,62,98,124,95,52,17,19,98,65,17,23,57,95,121,98,58,21,12,74,79,18,12,43,88,117,110,65,29,6,47,110,39,2,26,66,103,122,89,42,15,11,77,81,17,1,34,77,113,111,69,35,8,19,104,65,4,0,41,80,121,107,61,25,9,18,97,66,2,0,36,75,115,107,60,24,10,14,81,75,17,0,13,67,104,115,78,36,13,4,48,113,44,0,0,43,85,124,98,47,19,14,14,78,76,26,0,0,57,98,123,79,39,13,13,19,92,67,12,0,0,57,96,118,78,36,14,12,19,84,82,24,0,0,36,86,126,83,46,19,9,14,53,125,42,0,0,1,62,107,111,65,27,11,10,20,75,95,31,0,0,11,64,111,103,55,26,8,15,24,67,98,31,0,0,1,55,105,109,64,25,13,13,23,48,117,57,9,0,0,26,82,119,88,43,17,7,20,36,65,118,46,2,0,0,24,86,123,89,40,18,8,20,37,60,123,56,14,0,0,16,61,110,99,53,28,10,17,33,50,85,107,42,2,0,0,20,68,120,95,47,23,11,18,38,52,85,116,46,8,0,0,12,49,102,113,61,29,12,14,33,49,73,99,89,29,4,0,12,13,59,105,107,55,26,13,16,33,53,69,96,111,46,17,0,2,18,40,81,126,84,40,21,11,26,40,62,82,104,109,48,19,4,6,20,42,71,115,94,52,28,11,24,36,58,80,93,118,96,44,19,8,13,32,50,74,107,98,56,32,18,25,41,56,78,96,108,123,79,37,20,15,23,39,63,85,104,102,58,37,23,28,44,56,79,92,113,121,108,61,38,22,21,36,52,69,88,109,111,69,42,28,35,41,61,75,95,105,123,126,104,59,39,28,29,44,58,74,94,108,126,88,57,35,36,41,57,71,89,103,115,125,126,109,80,57,37,38,40,53,70,89,100,116,126,93,62,45,42,47,61,71,90,101,116,126,126,119,117,90,65,48,40,48,62,74,88,99,111,120,121,98,72,58,50,53,66,75,92,100,115,120,125,121,119,114,113,85,67,55,54,60,70,84,93,105,113,122,127,113,99,75,62,60,64,73,85,95,103,115,122,125,125,122,122,116,114,105,82,69,63,62,71,81,93,98,111,119,125,128,122,116,107,87,74,65,68,77,81,95,108,110,120,125,127,123,120,120,118,120,115,119,108,92,76,72,66,79,84,92,98,108,119,125,127,122,119,123,116,114,103,90,79,74,78,86,88,99,105,112,116,124,126,128,123,120,123,120,119,119,119,118,119,113,115,105,94,83,81,75,88,94,99,108,109,121,123,127,126,126,121,122,118,120,124,118,118,111,103,92,90,84,89,95,101,103,109,114,121,122,123,126,123,126,123,123,121,119,119,122,117,120,117,119,115,114,113,117,115,114,112,107,116,110,111,107,100,98,91,98,101,108,111,115,119,123,126,127,126,122,122,122,123,121,118,123,118,117,114,117,116,117,111,116,115,114,113,108,98,93,90,94,96,105,105,115,117,121,125,128,126,122,124,121,118,123,114,118,115,114,115,112,114,113,113,107,113,110,109,112,94,86,80,84,80,92,96,99,114,110,122,125,128,122,128,120,119,125,118,114,113,101,88,80,80,85,85,92,98,107,110,117,118,126,127,126,127,126,121,125,118,122,119,120,109,94,84,74,78,79,85,94,102,107,115,123,121,127,128,121,116,107,98,82,75,72,78,89,96,99,108,115,122,123,128,126,124,121,120,119,112,102,76,72,67,71,74,89,96,104,110,120,124,128,120,111,83,74,69,67,75,83,95,102,110,117,121,126,125,121,117,119,103,76,65,62,66,71,80,88,103,106,118,124,123,100,82,63,62,62,69,82,92,103,111,117,127,124,119,121,100,79,62,50,53,63,75,86,97,107,115,123,101,73,58,55,56,66,79,87,104,113,120,127,124,113,88,67,49,48,55,61,77,89,102,108,125,93,65,53,50,55,65,78,91,102,114,124,125,109,75,57,42,40,50,62,78,90,101,127,94,61,46,42,48,56,76,93,99,117,123,117,78,54,36,34,44,55,66,89,104,117,79,49,38,38,47,63,77,91,109,120,115,80,45,30,30,36,52,73,83,114,95,58,40,32,36,50,72,84,99,111,111,71,45,22,30,33,49,71,86,118,76,48,29,32,43,52,76,89,107,115,68,39,23,23,30,50,68,95,106,59,37,27,31,45,61,82,94,128,82,39,23,17,27,42,60,96,97,56,37,29,34,49,66,84,104,106,55,24,15,15,32,50,83,117,63,39,22,26,41,58,82,103,99,51,23,10,15,31,56,102,96,49,25,24,25,47,64,85,121,59,27,6,15,28,44,94,99,50,24,19,27,46,64,86,110,52,23,4,10,28,57,121,77,36,23,17,30,50,69,124,65,31,8,6,18,46,109,82,43,22,16,29,47,69,127,65,28,5,3,22,56,126,73,38,17,17,35,50,91,95,41,11,4,13,33,97,89,45,22,16,30,44,82,110,49,12,1,7,34,96,88,49,24,19,28,44,90,96,42,9,3,10,45,118,75,39,17,20,34,56,122,63,25,1,5,20,90,95,47,22,14,31,43,101,73,33,2,0,18,78,100,51,24,13,28,43,108,73,28,1,0,22,92,91,42,22,16,28,53,125,55,18,0,0,43,127,67,36,11,22,31,86,87,36,2,0,20,94,90,45,16,17,25,73,108,45,10,0,9,79,100,48,18,15,23,70,108,42,9,0,13,83,95,40,19,17,25,81,90,35,0,0,31,107,79,35,15,18,39,108,63,24,0,1,64,109,56,20,15,22,77,99,38,3,0,36,116,70,32,15,14,54,120,49,11,0,25,100,85,37,12,10,48,128,53,17,0,18,100,85,38,11,11,49,123,47,10,0,32,110,73,32,14,13,64,103,41,0,0,50,125,61,21,11,21,95,73,29,0,9,80,92,42,9,9,53,116,46,3,0,49,123,59,19,9,25,107,67,21,0,19,104,75,32,8,15,88,82,29,0,14,91,84,34,12,13,77,92,33,0,10,88,91,41,13,7,74,87,33,0,9,90,81,36,6,17,87,75,26,0,15,103,75,31,8,27,109,58,14,0,38,122,57,23,3,52,116,41,0,0,79,94,40,11,11,89,73,22,0,31,125,63,21,6,48,115,41,0,5,85,86,38,9,17,108,62,11,0,58,108,44,13,8,88,78,27,0,37,122,60,18,2,68,93,34,0,23,119,64,22,1,60,101,35,0,24,119,68,25,2,60,104,35,0,26,117,65,23,1,65,92,28,0,40,126,55,13,8,87,76,19,0,56,102,52,8,17,109,54,6,0,86,83,36,1,45,112,36,0,28,121,61,21,2,86,73,17,0,69,95,41,1,40,123,40,0,25,118,61,17,8,91,68,11,0,78,82,40,1,54,101,35,0,42,115,52,9,18,114,48,0,8,103,68,25,1,75,83,23,0,58,99,49,3,29,124,47,0,10,102,68,28,1,71,92,30,0,48,114,53,9,8,101,61,9,0,75,90,39,1,32,126,44,0,6,98,73,29,3,49,108,39,0,18,117,66,22,2,65,98,28,0,31,127,66,17,4,66,91,27,0,34,123,61,20,4,73,93,31,0,31,122,62,19,4,61,104,35,0,21,107,71,26,6,43,123,44,0,3,85,86,38,9,20,107,62,11,0,52,109,52,15,8,70,91,35,0,16,105,73,32,8,25,116,53,10,0,56,109,50,19,8,62,102,36,0,10,88,83,39,10,16,90,76,24,0,26,111,68,29,8,26,109,60,18,0,37,126,65,27,8,30,117,55,20,0,43,128,64,27,9,30,109,60,18,0,37,118,69,28,8,20,99,72,27,0,21,98,80,37,18,15,74,100,40,0,0,70,107,48,21,10,40,123,56,17,0,30,113,75,37,18,24,80,94,39,1,0,58,117,54,23,18,27,105,66,32,0,13,82,96,47,20,19,38,118,58,23,0,18,90,91,45,21,17,43,115,63,24,0,15,88,96,43,24,19,33,109,73,30,0,9,68,110,56,25,16,29,77,97,39,10,2,37,119,76,39,15,23,47,120,61,26,4,9,73,108,55,29,17,27,65,111,47,19,0,19,92,96,49,25,22,31,75,107,41,18,2,23,90,92,49,26,22,36,73,114,51,19,4,16,76,107,56,30,21,30,55,123,62,29,6,12,50,121,75,44,20,31,40,83,104,46,14,8,19,73,116,58,34,24,34,46,99,87,41,12,7,27,76,106,59,28,26,33,52,93,89,43,18,9,22,65,119,66,35,25,35,49,75,111,56,27,11,18,41,106,89,48,33,26,41,59,102,91,46,23,14,28,54,120,78,48,25,33,45,58,104,88,47,23,19,26,50,113,85,50,32,33,42,60,84,110,54,32,16,21,42,81,107,65,43,29,39,51,71,105,89,48,26,18,28,51,94,102,61,37,34,43,56,72,103,95,49,31,19,30,47,80,116,67,47,33,37,51,66,88,119,70,43,26,26,39,58,100,101,62,40,36,42,58,77,88,122,70,43,24,29,39,58,91,112,63,49,32,43,54,71,88,111,90,53,36,29,33,50,69,109,98,58,42,38,42,60,74,91,111,96,54,38,31,34,52,69,94,116,67,51,36,42,56,69,89,102,128,86,54,40,32,41,56,72,98,119,73,55,43,43,53,67,82,103,115,107,70,47,37,38,53,66,81,106,108,74,54,43,47,58,76,89,104,112,119,84,60,40,45,47,61,79,91,115,101,73,60,50,55,67,81,96,106,116,125,95,65,51,45,50,63,72,88,104,128,92,64,52,52,60,74,86,97,111,116,128,109,83,58,52,51,59,72,86,99,113,128,87,70,56,54,63,72,85,96,110,120,127,124,105,75,60,55,58,65,78,92,103,113,125,107,83,66,60,63,69,79,93,106,115,121,127,121,113,93,79,63,60,66,74,83,100,104,116,125,115,92,78,66,65,70,83,91,104,111,120,125,126,119,119,110,90,75,69,65,73,85,92,101,114,118,124,124,108,91,81,72,74,81,85,100,105,115,122,121,122,126,123,117,119,100,85,80,75,74,84,90,104,109,112,123,127,126,123,109,95,81,76,80,84,89,100,110,119,121,126,126,120,122,117,123,118,117,111,96,83,78,81,85,92,98,104,117,117,122,126,125,122,121,114,107,93,84,85,85,89,98,107,112,118,122,127,128,123,126,123,121,119,117,124,113,119,120,104,94,87,84,86,94,99,104,110,115,120,124,128,123,126,122,120,120,123,120,115,102,97,90,92,96,101,108,106,116,115,127,125,125,127,127,122,123,124,119,123,122,120,117,120,120,114,112,118,119,117,116,101,100,94,91,99,102,111,115,114,121,123,127,127,127,121,122,122,126,120,117,123,121,119,120,118,117,116,120,118,112,110,108,106,97,103,112,109,117,119,121,124,127,127,125,124,124,126,124,122,123,120,122,118,119,119,118,117,114,115,119,114,118,114,116,116,116,116,116,116,113,103,102,92,95,101,101,112,112,119,125,126,128,124,122,122,122,119,119,120,117,114,115,113,106,98,89,88,88,91,98,106,110,111,120,118,126,126,127,124,119,122,118,122,122,117,123,119,117,115,104,92,87,83,89,89,96,99,107,114,120,122,127,128,127,123,126,121,109,92,86,82,91,95,96,102,110,116,121,121,125,124,125,122,126,122,115,122,118,96,85,82,78,82,86,91,103,111,114,121,122,127,126,116,107,86,82,81,80,86,96,103,110,117,119,126,128,126,121,121,122,109,94,78,75,71,82,83,91,102,108,119,123,125,120,100,82,77,71,73,83,88,100,110,116,123,124,122,123,119,112,93,72,70,63,69,78,89,102,107,115,126,117,98,80,65,65,68,74,90,99,109,114,124,127,124,117,95,79,62,55,64,69,80,92,104,112,126,106,82,66,61,64,65,78,92,104,113,119,127,123,106,75,61,51,55,64,71,87,98,114,126,94,70,54,53,62,68,82,96,102,113,126,121,91,67,52,48,48,61,75,89,100,119,98,70,51,46,54,62,79,87,105,117,124,104,77,49,43,39,51,63,77,94,119,92,66,47,41,49,61,73,92,108,117,121,78,53,38,35,42,54,70,91,123,89,59,40,38,46,63,76,90,107,122,86,56,36,30,36,46,63,84,125,88,51,44,35,45,57,75,91,109,113,67,40,29,30,36,52,78,110,94,60,36,33,41,51,76,89,108,104,57,35,19,25,42,55,87,116,66,45,29,35,47,63,78,102,104,58,33,20,21,38,55,93,106,63,37,27,36,45,66,84,116,77,39,24,16,22,45,78,120,67,41,28,31,42,61,80,122,78,39,14,12,27,47,91,108,54,37,22,31,44,67,93,100,53,27,8,19,32,68,123,70,38,25,28,40,57,85,109,53,26,9,16,32,74,115,67,41,29,31,45,59,101,86,40,16,6,19,42,103,85,50,26,22,40,47,81,103,52,20,9,10,34,97,99,47,27,20,34,50,82,102,47,22,4,16,41,109,83,43,19,25,38,55,106,81,34,11,7,22,75,111,60,30,20,30,40,80,100,41,17,6,13,61,124,67,34,20,25,38,80,106,44,16,1,13,61,119,65,35,19,24,37,88,93,36,7,0,19,83,96,52,24,19,31,51,126,66,24,1,6,49,124,68,34,18,24,41,96,80,31,4,1,35,109,78,41,20,20,34,95,89,34,6,0,36,113,80,40,19,19,38,103,77,28,2,2,46,127,68,32,18,20,47,124,55,19,0,14,80,104,49,23,18,29,88,91,36,2,0,45,125,68,34,21,20,56,114,46,14,0,26,104,84,40,19,17,46,126,53,18,0,23,97,90,39,20,13,46,127,56,21,0,17,102,83,39,15,17,54,117,46,13,0,34,122,69,32,15,23,76,95,33,3,0,66,109,50,26,9,40,119,62,17,0,28,105,76,32,14,19,82,89,32,0,8,82,97,46,16,15,56,108,42,7,0,65,113,53,17,14,45,119,51,7,0,55,116,57,23,10,45,124,52,6,0,58,115,52,21,11,47,113,46,4,0,71,106,45,20,12,62,97,37,0,4,94,82,39,9,24,96,76,19,0,36,125,63,26,6,42,116,46,4,1,79,94,45,9,18,94,78,21,0,37,125,61,23,9,52,106,39,0,11,100,75,36,5,33,125,55,7,0,73,97,42,8,18,105,66,14,0,59,106,48,16,14,94,77,19,0,53,113,48,15,18,87,77,16,0,60,112,47,14,17,103,70,11,0,64,104,45,12,22,119,60,4,0,85,88,38,4,37,116,45,0,15,114,71,30,5,68,96,25,0,43,113,52,9,18,111,66,4,0,90,84,30,5,50,105,31,0,34,118,56,14,12,107,63,4,4,95,83,33,2,61,96,25,0,49,103,50,7,24,121,46,0,17,123,66,19,7,91,80,12,0,77,95,41,4,31,116,38,0,17,122,63,21,7,82,80,14,0,65,100,48,7,23,128,55,5,4,98,75,28,5,51,103,31,0,27,126,66,21,7,76,86,21,0,47,115,52,13,14,97,76,17,0,63,105,52,9,19,103,70,11,0,66,102,48,10,17,103,66,10,0,59,108,44,13,18,87,75,19,0,47,117,56,20,9,76,89,27,0,30,127,66,25,5,53,100,40,0,8,100,84,34,8,30,116,64,9,0,58,113,50,19,10,63,101,31,0,14,102,83,37,7,25,111,66,16,0,46,127,62,26,6,45,116,46,8,0,71,106,46,21,15,61,98,37,0,4,84,96,41,15,21,67,89,35,0,9,87,96,40,14,20,66,90,37,1,3,82,96,45,20,14,60,103,43,5,1,64,108,49,24,11,46,123,56,14,0,44,127,70,29,15,29,96,77,28,0,15,91,93,43,19,15,50,111,52,12,0,43,121,67,31,16,22,79,88,34,3,4,68,113,54,28,18,29,102,76,31,2,11,76,99,51,29,12,39,103,74,30,1,12,73,104,50,25,18,32,93,81,36,6,7,59,119,61,31,23,25,71,103,44,15,3,37,107,80,34,22,21,47,112,71,25,6,12,67,116,63,28,23,25,66,115,51,16,8,22,86,97,49,25,22,36,81,95,43,12,0,27,93,95,48,25,24,34,78,103,44,17,6,25,82,101,57,25,29,33,62,120,58,24,11,15,61,120,67,37,23,35,45,94,87,41,17,6,31,90,93,52,32,24,37,58,119,71,34,14,13,40,103,86,52,29,29,37,63,118,68,34,13,17,38,98,95,52,32,26,41,54,106,83,44,16,14,33,69,118,64,40,24,37,48,77,120,65,30,14,18,43,95,99,55,38,26,38,52,85,108,57,26,17,23,42,99,100,56,37,26,41,57,80,121,63,32,18,23,36,78,116,69,44,29,38,52,68,104,89,48,26,17,27,51,97,98,61,39,32,37,57,76,112,88,47,24,19,36,51,92,105,62,43,36,40,60,71,101,114,61,38,24,26,42,66,120,84,54,42,38,46,61,82,104,97,55,34,27,34,44,69,120,92,53,39,38,47,62,76,98,117,65,45,28,29,47,59,92,120,75,49,36,42,54,69,85,102,110,66,43,30,33,46,63,84,126,79,52,43,43,54,67,85,97,121,86,54,41,29,40,56,70,97,118,73,53,41,45,52,72,92,99,121,100,62,42,38,37,53,71,87,112,95,63,50,45,54,63,78,95,108,122,106,68,51,39,44,56,69,85,108,118,80,57,45,50,61,74,87,104,115,126,103,69,55,44,48,61,70,90,102,128,95,68,51,52,59,69,84,96,110,120,127,105,72,59,46,55,61,75,91,102,119,114,83,62,53,56,65,78,89,106,114,125,127,116,86,64,54,52,61,72,87,98,110,122,111,81,66,55,61,70,80,94,103,114,125,126,125,110,91,69,60,56,66,80,86,103,108,115,124,99,77,67,62,71,77,92,103,107,118,120,127,116,118,113,89,76,62,68,69,80,91,100,112,120,121,125,103,83,73,68,75,79,94,99,108,119,121,128,123,121,118,120,99,89,74,72,77,82,90,100,108,116,123,123,124,116,103,82,77,76,81,87,94,102,111,117,127,124,122,125,121,122,121,115,109,87,80,81,80,89,91,103,108,117,122,128,126,124,120,115,105,90,80,86,81,91,98,108,108,122,122,126,128,123,123,121,120,119,119,120,119,112,95,88,83,85,89,91,102,106,116,120,126,126,124,124,119,124,119,123,111,102,91,90,90,97,97,103,111,121,118,125,128,126,127,122,125,123,118,122,122,121,119,116,117,118,116,115,108,97,93,91,92,101,103,107,112,117,118,125,128,126,124,122,122,124,125,121,123,119,122,117,120,117,110,105,99,96,101,103,108,111,115,121,122,124,127,127,124,124,121,123,123,125,118,120,117,120,118,120,117,116,115,118,118,118,118,118,118,118,118,119,116,118,118,119,119,107,105,100,103,101,111,114,114,119,123,126,127,125,124,125,121,119,120,121,118,115,118,119,115,119,112,111,101,92,91,96,95,102,106,111,116,120,124,127,128,124,123,123,119,122,124,119,120,116,114,117,114,116,115,111,100,92,85,86,88,89,100,104,109,116,120,124,125,126,126,121,123,120,121,107,99,91,88,90,90,99,107,110,113,118,123,125,127,123,126,123,124,120,124,123,113,101,90,84,79,85,89,94,101,110,113,119,121,127,125,125,118,103,89,82,82,82,85,100,102,111,116,121,122,127,123,122,123,123,122,104,88,78,75,81,82,86,97,105,110,121,126,128,118,103,89,78,73,78,86,91,102,110,112,121,126,125,120,121,121,103,82,72,67,72,75,87,91,102,112,120,126,115,96,80,68,70,72,81,89,99,109,119,123,128,124,117,105,84,70,62,59,72,83,90,97,111,119,124,94,78,61,60,67,79,88,95,105,117,125,126,120,99,75,62,57,58,65,75,92,102,108,128,98,74,61,53,59,69,82,93,107,117,124,127,108,72,59,49,48,59,71,85,93,113,116,84,59,51,55,58,69,87,99,110,121,127,98,65,48,44,45,54,70,85,97,127,87,65,46,44,53,63,81,90,109,115,114,78,52,42,35,47,56,71,92,122,95,59,45,38,47,59,77,91,108,117,99,60,44,31,33,46,62,79,109,99,64,47,36,43,55,70,87,99,124,87,49,35,27,35,47,63,91,124,77,45,34,39,49,61,81,96,117,88,50,32,25,32,45,67,97,104,64,43,32,38,50,69,87,104,103,57,35,22,27,37,55,93,106,62,41,30,37,47,65,81,116,84,45,25,17,29,42,71,125,84,42,31,28,42,60,73,107,94,47,25,12,21,42,67,124,76,39,28,31,40,58,76,125,72,36,15,12,29,45,104,93,51,31,24,37,50,70,116,75,39,14,12,25,48,104,90,45,33,22,35,53,73,128,67,30,12,14,24,62,125,71,34,27,31,39,59,104,88,42,18,8,19,48,114,79,44,28,24,36,52,98,88,42,18,7,19,53,120,75,40,25,24,40,57,110,69,35,14,7,25,74,111,57,30,20,30,47,82,101,47,16,9,13,56,127,66,36,22,26,39,76,113,52,18,5,8,53,127,67,38,17,27,37,78,100,44,11,4,17,68,110,65,34,25,30,46,108,71,27,9,0,37,105,81,38,24,24,31,83,99,44,11,0,20,88,98,48,24,24,26,69,111,51,15,1,16,79,98,52,24,23,26,68,106,46,13,0,23,91,92,44,20,20,34,86,84,39,5,2,41,117,74,37,16,23,51,121,62,17,0,12,83,102,47,22,21,30,92,82,33,3,2,57,120,64,31,17,21,74,98,42,7,0,44,127,69,32,14,22,70,100,41,9,0,48,127,65,27,18,21,80,85,41,4,0,63,115,56,24,15,34,100,68,27,0,15,91,92,40,16,16,56,115,50,7,0,45,123,67,29,11,32,96,71,22,0,18,97,85,32,20,14,71,92,38,0,4,76,102,46,20,12,59,112,46,3,0,64,107,52,21,10,54,117,46,5,0,59,111,52,22,11,52,112,48,2,0,61,104,47,20,10,59,101,42,1,5,85,92,44,17,12,87,79,28,0,23,114,73,28,12,37,121,59,9,0,61,108,49,21,10,74,88,36,0,20,110,77,30,9,39,126,49,7,0,78,94,47,13,18,95,66,17,0,52,113,55,23,6,75,83,34,0,32,127,64,24,5,65,95,34,0,29,118,68,28,3,61,99,39,0,29,118,68,24,7,61,96,28,0,13,104,81,42,16,82,76,27,0,52,108,45,6,1,78,78,31,14,81,85,32,1,18,110,64,12,24,110,73,24,2,52,101,35,0,45,120,59,13,20,103,59,6,3,78,90,45,8,63,94,27,0,34,120,53,12,23,105,57,1,10,94,85,41,21,93,67,5,0,43,116,57,25,59,102,31,0,16,108,75,33,22,101,63,3,0,66,96,41,10,44,111,37,0,19,113,65,18,1,74,85,32,0,64,97,37,1,13,98,73,18,20,96,68,24,1,27,119,63,14,32,122,60,8,1,40,121,55,9,43,127,55,12,1,53,105,47,4,44,121,53,12,1,62,100,40,5,37,127,58,22,4,58,102,42,0,27,113,72,32,7,51,117,46,0,5,90,86,41,12,39,123,55,6,0,61,112,55,28,23,90,78,23,0,24,109,74,38,21,55,114,45,0,0,66,107,55,28,23,91,73,26,0,18,100,83,43,19,43,126,46,0,0,23,111,82,41,29,57,113,52,11,4,71,100,47,13,11,55,119,51,10,14,76,93,45,15,7,60,109,49,10,6,73,107,49,23,14,56,118,46,9,0,55,126,67,31,18,43,124,51,12,0,32,119,69,32,10,21,85,80,32,0,1,72,107,56,38,28,65,112,46,3,0,27,109,85,40,31,36,87,86,34,3,0,59,119,59,29,19,29,95,79,42,2,17,82,95,44,14,11,22,93,86,44,17,29,88,88,33,7,2,16,80,92,52,30,24,80,95,43,9,1,16,61,117,62,35,21,58,122,61,21,3,12,39,107,76,34,18,32,86,88,48,16,15,27,74,107,54,24,13,39,108,82,48,22,27,37,96,89,39,12,10,36,109,83,49,26,32,47,106,81,35,9,5,32,101,97,52,37,38,44,93,92,44,9,3,13,76,113,66,44,40,45,70,124,56,23,3,2,40,109,91,51,43,42,54,89,97,42,8,0,0,40,108,96,61,50,48,53,92,99,54,23,17,34,68,123,73,40,24,31,37,73,122,56,33,22,26,51,112,84,52,34,35,45,58,114,81,38,14,10,22,66,128,76,49,43,44,57,79,121,61,28,13,19,33,79,108,60,46,35,42,62,77,124,64,33,7,5,20,50,115,90,58,45,49,61,76,103,96,50,22,15,22,42,82,111,64,38,33,40,54,69,104,99,59,38,29,40,59,100,93,52,28,23,27,46,56,80,124,79,52,45,48,62,84,118,66,33,17,17,31,49,65,90,116,72,47,48,51,68,88,120,66,38,25,25,36,52,67,91,118,76,53,37,47,57,74,104,96,63,36,30,41,56,71,87,106,98,61,41,31,39,50,69,101,109,68,50,42,51,59,76,99,110,107,66,39,28,31,44,56,75,112,99,67,56,49,61,73,90,105,117,107,67,45,29,28,35,54,73,93,122,83,58,56,61,69,82,98,114,124,101,64,45,31,35,43,58,74,91,124,91,65,61,57,65,76,93,108,117,127,96,66,50,40,44,53,67,83,94,124,100,70,59,53,67,70,89,99,108,125,125,97,70,55,45,51,61,76,89,104,115,106,79,62,51,59,67,81,93,103,114,125,125,103,82,62,56,58,67,77,92,105,118,121,95,67,58,52,64,74,82,95,106,111,125,124,123,96,75,65,62,68,74,89,101,112,123,125,105,75,67,57,62,69,84,93,102,111,118,126,125,123,112,92,75,68,70,73,84,99,107,114,126,125,113,95,76,69,63,73,80,92,98,113,114,122,127,127,122,120,108,94,78,76,74,80,88,100,104,117,120,127,122,115,97,86,77,72,81,84,93,106,111,119,122,127,128,123,121,120,120,113,96,87,77,77,82,87,96,107,113,123,123,127,126,123,116,104,89,84,80,86,91,99,104,116,119,123,128,119,120,120,115,121,115,120,116,109,98,84,80,79,84,95,98,102,112,115,120,127,126,124,126,122,121,118,108,94,89,91,94,98,103,110,118,117,127,128,124,122,125,125,117,121,121,119,119,116,114,117,114,116,101,93,92,88,91,99,100,103,112,118,119,123,126,126,127,124,125,121,126,122,123,120,120,113,109,103,100,96,103,104,108,116,115,120,123,125,123,128,123,123,125,121,122,124,121,116,121,119,115,121,116,115,118,114,118,121,115,114,117,117,117,121,114,118,110,104,105,103,106,109,113,114,115,123,126,128,125,125,125,121,123,121,122,124,119,117,118,114,120,118,115,117,117,111,109,104,93,96,101,102,107,110,115,119,122,125,127,124,123,123,120,120,124,118,120,117,120,117,115,115,114,113,117,110,113,100,91,90,86,89,97,102,107,113,119,121,125,128,126,125,121,122,122,118,118,106,96,88,88,91,95,95,105,110,116,118,123,123,127,126,124,128,121,123,121,123,120,117,105,90,86,81,87,94,95,103,111,115,121,122,126,128,126,121,107,97,87,78,84,85,94,103,107,111,121,120,125,126,125,124,123,125,117,112,93,79,77,77,85,90,97,105,116,119,121,126,124,112,95,83,75,77,80,91,98,106,108,120,126,124,124,125,121,115,99,87,75,70,72,79,87,94,106,115,118,128,119,97,83,71,67,74,83,89,101,110,116,125,127,123,121,112,90,74,67,61,69,75,85,100,104,116,126,111,81,78,61,65,70,84,93,105,114,121,125,122,120,94,73,62,56,62,66,81,92,104,109,125,98,68,60,59,67,73,81,98,108,114,126,122,109,78,58,52,49,61,74,80,93,104,128,88,67,56,56,58,70,84,98,109,122,127,107,73,57,40,42,54,65,81,97,112,105,69,54,42,53,59,77,90,102,115,125,94,67,47,35,42,54,66,80,102,118,77,54,45,44,50,68,83,98,112,127,88,53,41,32,39,50,73,83,119,88,58,44,38,47,62,75,90,107,127,82,49,34,27,39,53,66,94,116,73,46,38,36,50,65,84,95,121,90,46,35,25,35,46,63,97,109,63,45,32,36,54,67,87,99,108,63,37,23,27,35,56,89,119,69,43,28,39,48,64,83,105,101,49,32,19,25,40,59,106,94,49,38,27,41,53,68,95,112,62,33,16,20,31,55,107,92,52,31,27,38,51,71,103,100,47,26,14,23,36,69,122,69,40,25,30,43,60,85,112,62,29,8,19,30,63,127,74,43,26,30,42,57,81,108,56,28,8,21,37,78,113,59,38,22,31,46,65,114,77,37,13,10,23,58,123,74,42,26,25,38,59,105,87,40,12,10,22,59,124,72,43,24,26,43,59,123,73,33,8,12,24,80,107,56,33,26,28,42,84,101,44,17,6,14,56,126,73,38,19,28,38,72,111,55,24,1,11,51,120,70,41,22,26,38,73,108,48,21,0,14,63,122,65,35,19,28,41,100,87,36,6,9,25,99,90,47,23,23,32,67,114,49,22,0,14,70,109,61,25,21,27,54,127,62,22,2,10,60,115,61,30,19,28,54,128,58,20,0,9,72,108,56,29,15,29,66,114,48,18,0,18,91,92,44,20,19,33,97,84,37,1,1,53,127,65,33,19,23,58,114,49,15,0,22,105,87,40,19,19,44,123,58,23,0,19,86,97,47,26,25,40,118,67,25,0,14,85,93,43,22,19,42,125,55,22,0,21,103,85,39,15,21,56,110,45,13,0,44,125,63,32,16,24,91,83,34,0,9,82,97,46,14,21,50,119,48,12,0,50,127,58,25,11,30,108,67,24,0,24,107,78,35,12,18,87,84,33,0,11,95,86,41,12,18,82,93,32,0,11,92,86,44,13,15,80,92,31,0,14,96,82,38,9,23,99,81,30,0,27,112,71,29,12,29,117,62,12,0,58,121,53,18,15,57,106,42,1,9,87,88,40,11,22,104,72,22,0,43,120,61,25,11,64,107,38,0,14,99,76,35,13,31,126,55,9,0,73,95,49,9,19,103,66,21,0,55,111,53,17,12,88,81,24,0,48,123,58,19,13,81,87,24,0,42,123,59,18,14,82,82,26,0,48,118,59,16,13,89,81,18,0,58,111,51,15,18,106,63,12,1,80,95,42,12,33,123,48,5,14,109,76,31,4,68,96,25,0,49,116,52,15,17,113,62,11,3,92,85,35,5,54,101,28,0,42,116,54,12,24,117,59,8,9,104,77,27,9,79,88,22,0,67,97,46,5,42,116,39,0,32,124,63,16,13,98,73,11,0,82,89,40,6,40,111,36,0,32,124,63,20,9,91,79,18,0,66,100,47,7,27,124,52,7,9,97,75,36,7,50,110,39,0,21,119,68,22,9,70,99,27,0,38,125,58,20,13,81,87,26,0,51,121,53,18,12,82,82,26,0,43,122,58,16,12,76,90,29,0,37,126,63,25,8,65,105,35,0,22,109,70,31,5,42,118,48,4,7,85,87,42,8,27,105,70,17,0,46,124,58,25,14,62,98,37,0,12,96,79,42,11,24,115,67,18,0,49,123,57,23,13,52,112,45,7,3,78,100,47,14,20,72,92,35,0,13,94,84,42,10,19,90,81,29,0,19,105,77,38,13,20,94,78,31,0,20,100,82,39,14,22,87,89,34,0,16,88,87,45,12,20,67,103,39,6,5,73,109,52,23,18,39,125,58,15,0,40,117,70,35,14,27,86,90,32,5,5,77,103,51,23,18,43,120,61,26,0,28,102,83,38,21,20,59,115,44,14,1,43,121,72,37,19,23,69,102,42,13,1,44,124,74,33,24,28,63,109,46,15,0,37,115,79,39,23,21,53,122,60,21,1,22,92,97,48,24,27,35,98,87,31,7,8,50,127,65,36,26,30,57,124,60,23,4,18,82,103,56,28,29,33,70,109,50,22,5,24,91,98,49,27,26,36,74,102,47,25,8,24,85,102,54,29,26,35,66,115,61,23,10,18,65,115,68,35,24,31,53,111,80,35,16,13,35,110,90,48,28,34,38,69,114,60,32,7,21,53,124,74,46,20,33,46,78,108,54,28,12,21,57,128,76,46,24,33,46,72,120,59,29,15,17,47,108,87,49,31,32,46,58,109,83,43,19,14,33,69,118,67,43,28,34,50,70,127,67,33,17,23,34,84,110,62,37,33,36,54,74,127,70,39,19,24,36,72,120,70,42,35,35,47,68,104,89,47,29,18,31,51,104,97,57,36,35,42,60,75,117,82,47,20,24,34,55,109,91,58,35,35,46,61,75,109,89,51,30,22,39,46,87,113,69,45,36,40,54,70,89,125,74,43,30,28,41,60,95,105,66,50,42,48,61,73,90,127,78,47,27,29,41,52,84,126,82,49,39,38,52,72,84,104,112,66,43,30,33,46,63,87,118,77,50,37,44,55,70,84,104,125,74,48,39,35,44,63,72,115,96,61,48,36,49,62,80,92,106,121,79,48,39,34,52,63,79,103,109,68,54,42,51,59,74,91,102,118,107,71,50,37,45,53,72,85,104,111,76,54,50,53,58,73,86,103,114,124,90,62,48,44,50,64,76,89,112,113,77,59,51,52,66,78,87,106,115,125,116,77,64,48,49,61,69,83,99,110,116,83,63,53,55,66,79,88,101,116,122,126,107,79,60,55,53,62,76,85,103,108,126,99,69,59,58,65,72,87,98,111,116,126,124,111,89,68,60,54,65,73,89,94,110,120,121,102,77,67,65,63,80,86,99,111,121,121,123,125,114,97,76,70,61,70,76,88,99,109,115,124,126,96,79,72,68,71,80,95,102,105,121,122,123,122,120,117,108,87,78,68,68,79,87,96,106,116,119,128,128,110,94,85,77,72,81,88,94,110,112,121,124,126,125,120,119,117,114,105,83,80,76,80,84,97,99,114,115,123,128,126,120,113,104,85,83,79,85,90,98,108,116,116,127,127,125,124,119,120,119,118,122,115,98,88,83,80,85,93,98,106,113,119,122,126,127,122,121,122,116,110,95,91,86,86,93,96,107,110,119,123,123,127,123,127,122,125,118,121,122,122,117,118,116,117,107,94,91,91,93,94,101,109,114,118,121,123,124,128,123,118,125,122,119,119,122,117,111,103,97,92,98,99,105,107,113,115,118,125,127,125,128,124,125,121,121,122,124,122,119,122,117,115,113,116,119,112,116,116,116,116,116,116,110,104,101,99,102,107,108,115,120,115,127,125,127,125,124,124,125,123,124,121,123,119,120,116,122,118,122,120,120,117,119,116,115,108,101,102,99,104,107,111,116,119,123,127,127,127,124,123,123,121,122,118,120,122,117,115,116,112,118,116,115,116,115,113,114,114,105,94,93,89,94,94,102,106,111,117,122,125,128,126,126,122,123,122,119,115,120,115,99,94,91,85,92,97,101,106,112,117,118,120,127,127,126,122,125,124,122,124,121,122,119,116,96,91,86,81,89,92,103,107,110,117,121,125,128,126,126,122,115,103,91,82,84,88,92,99,110,113,115,127,123,127,127,122,125,125,120,120,107,88,81,76,79,85,92,98,106,115,119,120,125,122,117,101,87,82,77,82,88,95,103,110,117,123,127,124,126,121,122,116,94,81,74,70,75,81,90,98,111,113,122,128,117,99,85,72,70,76,82,88,103,111,121,120,127,125,121,112,96,80,65,63,69,77,82,97,103,112,123,121,95,76,70,66,72,77,88,100,109,117,124,124,123,115,85,71,57,59,64,78,82,95,109,116,117,91,72,60,59,68,72,89,98,108,123,125,126,106,77,61,55,53,59,74,82,99,107,122,93,69,55,52,61,72,80,96,107,117,125,114,82,58,51,43,51,62,80,96,109,121,82,56,51,48,57,71,83,98,110,119,116,76,58,42,41,51,58,72,91,116,100,65,48,47,44,61,71,87,109,113,119,75,53,38,33,42,58,70,97,125,83,56,40,39,46,64,78,99,108,126,74,52,31,32,36,55,70,97,111,72,47,38,36,53,67,83,95,121,90,49,30,20,29,49,61,94,112,69,45,37,35,53,66,85,101,119,66,40,24,21,34,50,82,125,76,46,33,36,43,61,79,100,116,60,35,19,22,38,52,93,106,61,40,29,34,48,64,84,123,72,42,17,17,32,44,88,113,65,40,24,34,47,59,86,127,66,34,14,16,31,53,108,91,53,35,24,37,54,67,108,83,45,21,13,21,44,89,105,54,35,24,32,47,68,109,83,40,15,14,24,48,105,86,51,31,24,40,52,78,116,61,29,7,17,28,78,109,60,34,25,33,40,70,126,70,28,12,11,25,75,110,62,36,24,33,40,76,119,62,24,9,12,37,93,94,52,32,23,39,48,97,85,43,14,9,21,63,120,66,36,22,31,43,76,100,50,17,5,14,56,127,66,38,22,27,40,82,104,47,19,4,13,63,119,65,35,19,28,41,96,86,37,13,1,27,88,94,48,24,24,30,65,120,59,21,1,8,63,122,61,30,24,26,48,114,69,25,2,9,49,126,71,33,20,24,49,108,71,26,2,4,54,125,68,33,18,22,53,125,59,20,2,7,72,106,53,23,23,27,77,99,43,10,0,32,109,75,43,23,17,47,122,66,24,2,12,77,103,51,22,17,35,94,80,35,5,4,61,116,58,27,17,27,83,85,35,0,5,59,118,56,31,15,26,90,79,35,0,6,70,108,50,23,14,34,111,67,22,0,19,96,89,43,15,16,59,115,52,8,0,50,126,66,29,10,32,92,73,33,0,16,91,92,42,20,18,62,103,46,5,2,65,106,51,21,11,51,125,51,12,0,52,122,58,28,7,42,121,60,12,0,45,126,63,26,12,37,120,58,15,0,44,127,59,31,10,49,120,51,8,0,64,109,49,24,12,61,96,39,0,10,93,90,41,12,26,90,71,23,0,36,125,63,31,11,43,114,52,6,5,79,93,44,11,22,92,73,18,0,44,123,59,26,4,64,100,39,0,20,101,74,37,4,38,121,52,3,7,88,91,41,5,28,114,57,13,1,71,96,47,12,22,102,66,10,0,71,101,49,13,23,100,66,10,0,69,99,48,8,28,111,66,7,5,83,94,41,7,35,125,49,0,16,98,78,32,6,56,101,38,0,31,126,63,20,12,84,78,22,0,61,99,48,11,35,123,53,2,15,107,74,29,4,69,82,24,0,55,103,52,5,35,127,52,0,23,116,69,27,6,85,71,15,0,78,89,39,5,53,100,36,0,42,116,59,13,23,112,61,5,9,92,79,35,5,57,95,38,0,38,115,57,19,17,99,71,13,0,77,93,41,7,41,117,49,0,17,110,74,28,9,61,95,31,0,36,127,59,21,9,82,75,24,0,53,110,55,17,18,93,69,14,0,64,102,49,15,20,99,66,12,0,63,102,50,15,20,99,66,19,0,59,112,53,17,12,87,79,23,0,45,124,59,24,7,70,91,40,0,20,114,73,32,6,43,122,52,7,4,73,94,45,16,16,91,77,23,0,36,125,62,27,10,49,111,48,3,6,79,97,45,18,13,84,82,32,0,24,110,74,34,14,28,111,66,19,0,42,119,62,28,13,48,127,59,9,1,55,118,57,26,10,52,124,54,11,0,56,114,56,25,12,46,125,55,18,0,46,124,62,25,14,38,113,63,26,0,35,112,75,34,15,26,85,84,34,1,15,83,96,45,28,20,55,112,49,16,0,41,125,68,32,19,27,88,79,36,2,9,73,105,53,25,20,43,113,61,26,1,19,96,89,44,24,20,50,128,62,19,0,30,101,81,45,22,18,54,126,59,21,0,24,96,87,44,21,24,44,110,67,31,4,15,73,104,53,26,22,34,82,91,40,15,4,48,120,73,38,21,27,53,124,67,25,6,15,72,106,59,27,25,27,73,110,51,19,8,22,89,97,49,31,22,37,77,101,49,18,7,28,87,95,49,29,27,34,74,112,54,24,7,18,76,106,62,33,26,36,57,118,68,35,15,11,51,112,78,45,28,33,40,84,108,52,21,10,22,67,112,70,39,25,40,48,96,94,46,23,13,27,74,112,66,37,25,35,52,87,93,48,20,14,23,67,125,73,41,26,40,47,73,121,62,30,16,18,42,94,94,57,33,29,44,53,90,101,55,28,17,22,52,109,87,53,36,30,46,57,97,101,53,30,18,27,48,99,95,55,35,30,41,59,80,118,59,38,21,26,38,74,118,70,45,32,40,54,67,100,97,54,31,25,28,43,89,109,67,45,35,40,56,74,97,105,58,31,26,30,45,75,124,76,46,39,39,53,66,86,126,77,47,24,29,42,56,94,106,67,44,42,45,55,75,89,126,72,48,27,29,42,59,89,113,74,47,39,43,53,72,83,109,101,59,38,32,33,52,65,101,97,69,46,40,45,58,72,93,107,103,63,44,31,35,50,67,89,120,77,53,43,42,57,67,87,100,121,98,55,43,38,40,55,74,94,126,82,52,44,44,55,69,88,98,112,119,75,55,39,37,51,66,79,107,119,80,58,45,50,58,73,86,103,118,120,87,60,45,41,48,61,79,88,111,109,73,57,46,56,69,77,95,104,119,127,106,65,60,44,50,61,74,90,101,120,96,70,56,53,58,72,84,97,107,117,123,116,87,66,53,47,62,71,82,96,111,125,102,71,62,56,59,71,85,94,107,119,128,124,115,86,65,56,59,61,78,86,100,109,120,119,87,73,62,57,71,79,91,100,114,120,126,122,121,101,83,66,65,63,74,82,94,105,111,125,124,104,79,70,66,70,77,88,102,106,121,121,127,122,120,118,97,82,71,67,73,80,87,99,108,112,121,125,120,102,84,75,73,79,82,95,104,108,121,124,128,122,125,115,120,111,99,80,76,70,81,90,95,102,114,116,122,125,124,119,107,93,81,76,80,88,99,105,109,119,122,128,126,121,120,121,120,119,119,107,91,84,80,81,87,95,101,110,115,119,127,127,124,124,119,113,105,96,86,86,85,94,100,106,113,121,121,125,128,126,121,124,119,123,119,121,118,119,117,104,94,89,87,88,93,99,103,110,117,117,124,128,123,124,125,120,123,120,117,117,105,98,97,90,97,102,104,107,116,120,126,122,128,126,122,126,124,122,123,122,119,121,119,119,115,121,117,115,118,114,118,116,101,95,98,95,100,107,111,114,118,125,124,126,125,127,124,124,125,123,124,118,123,118,116,122,117,121,120,114,118,116,111,109,107,101,105,107,113,115,117,121,124,125,128,128,124,125,123,124,122,123,119,118,116,123,119,114,117,115,119,114,118,116,116,116,116,116,116,120,113,108,101,94,97,96,100,107,112,115,119,123,127,125,122,124,119,126,121,118,115,114,118,115,109,100,91,90,93,94,99,103,111,115,117,120,128,127,126,126,123,124,120,121,122,122,120,117,120,114,106,94,84,86,87,87,100,103,109,114,119,123,126,125,127,127,122,121,108,96,87,85,89,92,101,103,111,113,119,125,126,126,121,124,124,124,119,120,110,97,85,78,79,83,91,96,104,112,115,119,125,127,124,115,97,89,78,79,84,91,97,107,112,117,123,127,126,124,120,121,120,105,85,81,70,72,83,91,96,106,109,120,126,123,113,93,83,75,70,76,83,98,105,113,121,123,125,123,121,119,100,79,74,64,72,75,83,96,104,113,121,126,107,82,76,63,69,77,83,97,103,114,125,125,125,116,106,82,68,59,61,69,84,90,98,108,121,116,88,71,65,61,70,78,87,98,109,118,126,125,108,88,63,56,55,60,69,82,97,107,122,104,76,61,55,53,68,81,90,106,113,121,126,97,71,57,45,51,57,73,86,96,118,106,72,61,49,53,58,76,90,101,115,125,112,80,56,39,38,52,62,78,94,116,96,67,51,47,48,57,75,88,106,118,118,83,58,37,36,41,58,72,89,124,89,62,44,39,47,62,77,91,104,122,91,53,41,32,35,47,64,89,122,84,55,39,40,49,61,74,93,108,112,66,46,28,30,38,55,74,116,90,54,42,35,44,55,71,92,112,101,54,35,22,32,42,60,92,113,67,43,32,37,47,67,81,103,103,55,29,22,24,41,59,98,100,57,39,30,33,50,67,88,128,75,44,17,21,28,44,82,115,65,40,27,32,44,62,83,125,73,36,16,19,26,50,97,102,58,31,26,29,55,64,98,100,52,24,12,20,37,73,121,67,38,27,31,40,59,92,100,50,20,6,17,34,76,114,64,38,28,30,45,63,109,82,37,18,9,23,47,110,81,49,30,25,37,54,89,102,49,22,9,15,41,103,88,49,27,23,37,50,94,100,47,19,6,18,49,116,78,44,25,25,38,55,118,75,35,9,11,25,79,107,60,28,20,34,44,91,98,46,15,4,18,63,117,66,35,19,29,42,85,105,44,16,5,13,68,118,60,29,20,29,42,99,86,37,13,1,25,89,95,46,26,21,34,60,125,57,22,6,8,59,125,68,30,17,25,47,110,71,34,4,3,41,117,73,39,15,25,38,107,81,34,3,1,40,122,74,33,21,22,43,115,67,32,2,6,54,123,62,32,16,25,56,119,51,20,1,15,88,96,47,22,17,34,98,80,32,5,4,56,123,66,29,22,24,68,102,42,10,2,35,111,75,36,17,21,52,125,51,17,0,24,106,78,41,21,21,51,123,51,17,0,30,110,77,34,16,20,63,111,44,6,0,45,125,68,31,13,24,88,90,32,2,5,70,104,50,18,18,42,125,54,19,0,35,117,70,31,13,23,93,82,28,0,11,85,90,43,16,17,63,103,39,6,1,68,105,52,20,11,51,113,45,7,0,61,111,53,21,11,47,118,47,9,0,62,110,52,21,10,58,112,43,2,4,77,100,51,13,18,73,95,36,0,19,98,84,38,10,27,101,70,22,0,42,126,60,21,11,49,116,41,3,7,84,88,44,15,18,105,74,22,0,43,120,61,21,11,60,106,41,0,11,103,75,33,8,37,124,50,8,5,78,91,44,15,21,107,61,15,0,65,101,49,14,16,103,71,21,0,60,105,53,15,16,99,74,16,0,59,113,51,14,20,102,69,17,0,69,98,46,13,24,121,56,12,1,86,86,37,7,45,118,43,3,16,110,74,23,4,73,95,30,0,48,116,53,11,18,111,58,16,0,93,84,37,4,55,108,37,0,39,119,58,20,16,101,63,13,2,89,80,33,2,62,96,29,0,55,106,51,7,30,127,46,4,21,121,67,25,8,90,76,20,0,74,93,44,5,41,117,43,0,28,123,67,22,7,88,77,21,0,67,104,46,9,30,122,47,6,9,98,75,31,4,56,109,33,0,29,118,62,22,9,76,87,27,0,51,118,54,18,15,97,74,24,0,63,109,50,16,18,100,70,20,0,59,107,48,17,18,97,76,24,0,53,114,54,18,13,84,80,24,0,46,124,65,23,11,66,98,37,0,21,110,73,30,8,44,125,48,7,5,79,98,49,14,12,93,78,21,0,41,127,62,27,13,48,116,43,2,11,76,94,47,17,13,85,81,31,0,30,109,71,33,13,30,117,60,17,0,50,120,59,27,14,45,123,47,12,0,63,111,52,21,11,58,112,43,10,4,70,111,52,24,15,56,119,46,9,0,62,112,53,26,16,44,125,50,17,0,49,127,65,31,15,31,109,72,28,0,24,101,80,41,19,23,71,100,43,5,5,65,115,54,28,18,34,114,66,26,0,25,97,83,45,25,18,59,117,52,16,0,39,121,77,36,17,24,73,106,41,15,3,49,127,67,35,22,27,73,104,41,14,3,45,121,67,32,23,29,62,114,48,16,5,32,109,84,41,21,20,45,124,66,26,4,19,77,105,53,26,26,34,77,99,41,17,4,37,109,78,42,23,23,43,108,73,30,4,5,50,127,74,37,25,30,50,121,69,28,8,12,59,125,67,37,27,32,51,118,73,33,12,11,48,124,77,43,25,30,44,96,95,40,15,11,30,97,94,50,30,27,39,64,124,59,28,12,17,55,124,77,38,26,31,45,82,107,50,28,11,21,62,125,68,39,27,34,49,78,111,51,29,13,21,58,118,75,47,28,33,47,65,128,73,32,17,21,34,93,97,58,32,29,44,54,84,100,52,25,17,23,52,109,87,49,35,32,42,60,94,94,49,27,18,28,52,108,88,54,32,35,44,57,90,113,58,33,22,24,39,84,111,64,45,33,38,52,74,108,87,48,28,17,32,55,99,99,60,42,33,41,57,75,111,88,47,31,25,33,51,90,114,65,45,38,41,57,70,93,113,67,39,24,30,43,65,109,94,59,38,40,44,63,77,96,109,63,42,26,31,44,68,109,100,61,47,36,47,60,75,96,125,84,50,30,32,40,57,77,125,88,52,42,42,53,63,84,96,127,83,51,34,31,41,62,73,112,100,60,48,39,48,62,81,93,112,109,73,44,35,38,48,65,85,116,91,61,49,46,49,66,80,93,112,124,82,57,40,37,51,60,79,95,126,82,60,49,46,57,71,86,99,110,127,92,60,49,41,50,62,76,89,113,107,71,60,48,53,66,75,93,105,114,123,97,67,54,43,52,64,74,95,103,128,90,68,54,51,63,70,86,102,110,116,126,104,75,60,49,56,62,76,88,104,113,117,86,66,57,59,65,80,88,101,114,121,127,121,93,71,61,53,60,72,85,92,111,118,122,91,75,63,57,66,76,90,100,113,118,123,123,117,101,81,66,60,62,64,81,91,102,112,120,123,100,78,66,65,74,76,92,103,111,118,126,128,120,119,112,89,73,69,65,73,84,93,103,112,117,127,123,106,86,74,72,75,84,88,96,110,120,118,127,123,120,118,124,110,92,81,77,75,77,90,98,102,115,117,123,124,123,115,97,85,77,77,83,90,101,106,110,120,127,127,125,124,119,117,120,118,112,92,83,79,81,85,94,99,111,113,123,126,127,122,124,119,111,98,89,84,81,89,96,105,109,117,121,122,128,125,125,119,122,122,119,122,118,119,117,100,89,83,83,90,95,99,112,115,121,121,126,128,124,124,123,123,121,118,112,103,93,92,92,96,103,108,106,116,121,126,125,126,127,122,125,118,121,121,122,124,119,120,119,117,120,116,115,112,103,98,95,91,98,101,108,108,119,118,125,128,126,124,128,123,123,126,121,123,120,118,119,120,114,121,116,114,112,102,102,103,106,104,111,116,122,121,127,123,128,125,124,121,123,123,125,122,125,118,121,117,118,118,120,115,121,116,115,118,118,113,120,116,118,115,118,115,118,118,110,103,101,97,103,102,107,115,121,123,124,127,122,125,121,122,123,121,117,119,113,117,117,116,109,104,96,96,92,93,94,103,108,112,116,120,127,128,123,123,125,125,120,123,122,119,120,122,117,115,118,115,99,91,86,84,90,95,98,101,111,117,119,124,125,126,126,125,121,120,115,101,93,86,90,92,98,99,107,115,118,122,125,127,125,125,125,120,121,124,118,114,99,87,79,79,87,91,97,103,110,117,117,125,127,124,123,106,96,84,80,82,88,95,99,106,116,119,125,127,127,124,122,120,117,105,88,79,70,72,78,87,98,105,111,123,121,126,118,100,83,74,75,77,87,93,102,109,118,126,127,123,121,120,109,93,77,66,66,71,83,90,99,109,118,123,121,102,77,73,66,70,79,88,98,105,115,124,127,125,123,105,82,68,60,65,70,80,92,99,110,118,116,92,71,63,62,71,74,87,98,108,117,125,127,116,93,72,55,54,61,69,81,92,104,113,116,85,64,57,58,61,78,86,101,107,117,127,120,87,68,52,49,50,67,78,89,105,124,93,65,56,50,57,64,82,92,105,118,125,107,68,54,42,46,53,65,82,95,121,97,65,50,45,48,64,77,91,109,113,121,82,58,37,36,41,54,74,90,118,95,63,45,40,46,57,77,91,104,118,99,60,42,32,33,46,66,79,113,102,63,45,39,43,57,74,90,104,127,83,49,32,29,37,53,65,98,117,72,45,34,39,53,64,79,99,128,77,45,30,21,35,51,70,111,93,56,39,35,42,54,75,89,118,87,45,27,23,30,40,68,115,91,50,34,32,39,57,73,94,118,68,35,17,21,33,52,90,105,61,39,24,36,47,67,88,122,71,34,13,17,32,50,100,93,55,33,26,35,54,68,98,98,50,28,11,19,36,74,121,68,36,27,27,45,58,91,103,53,25,13,21,30,74,115,66,35,27,29,44,62,101,88,42,18,12,20,48,102,89,47,29,24,38,48,82,111,56,22,11,15,35,88,99,51,32,25,35,48,78,106,58,24,10,15,36,104,91,46,29,25,37,54,95,90,39,19,5,22,58,117,68,37,21,31,39,76,113,56,23,7,14,46,116,78,43,23,23,34,66,120,61,19,4,11,44,119,74,37,23,33,35,79,107,47,15,0,17,64,120,62,36,22,29,47,102,81,34,4,2,32,104,87,41,21,24,35,76,101,45,17,0,19,85,101,49,25,23,26,68,107,52,15,1,19,80,97,48,24,23,29,71,102,45,17,0,26,96,86,44,26,19,35,92,85,33,4,4,46,127,71,30,20,24,56,121,55,22,0,24,89,94,45,23,19,35,104,75,29,0,5,69,109,57,26,16,29,90,85,34,1,4,63,116,58,26,17,32,83,84,35,1,4,64,115,56,25,15,30,101,75,28,0,10,84,99,46,23,13,46,127,62,18,0,28,112,79,32,14,24,70,92,34,3,3,70,109,50,22,13,47,127,53,17,0,44,121,65,32,16,33,104,72,26,0,26,109,79,35,17,26,88,82,30,0,18,96,86,40,14,21,83,84,29,0,19,96,81,40,13,22,84,80,29,0,20,104,74,39,8,27,100,68,22,0,40,121,63,32,8,43,123,57,9,0,68,104,45,20,15,70,87,33,0,24,109,73,38,8,37,126,62,3,0,73,106,49,16,18,84,80,21,0,37,128,61,23,9,58,100,39,0,16,107,74,33,7,44,119,50,1,11,92,87,38,8,32,124,56,5,4,86,86,42,9,33,125,56,4,6,89,90,42,7,35,122,54,6,8,98,80,38,7,46,107,44,0,20,114,69,29,8,64,96,29,0,37,114,57,19,17,95,74,10,2,77,94,41,7,39,123,47,0,23,116,72,22,9,76,87,20,0,56,100,45,10,31,124,48,4,23,122,66,24,7,91,76,12,0,66,104,54,27,66,89,23,0,40,111,47,2,10,107,72,20,25,119,66,13,1,54,98,31,7,57,99,47,7,21,109,69,9,13,96,79,35,7,56,99,34,0,33,126,69,29,19,97,73,9,0,55,111,55,15,29,112,64,11,3,84,98,49,14,55,110,39,0,0,80,99,50,27,61,98,34,0,1,84,93,44,23,56,103,41,0,0,92,85,39,13,42,120,56,7,4,90,85,34,8,26,103,74,21,10,73,96,40,2,4,68,95,40,8,53,113,50,14,1,38,125,62,19,27,107,76,22,1,14,83,83,33,15,57,108,49,16,1,41,119,59,18,15,95,91,38,10,14,72,90,39,3,26,115,78,36,12,35,102,66,13,0,16,102,84,45,24,43,123,67,22,2,47,122,63,28,8,28,111,68,21,4,46,125,71,35,14,38,104,63,24,0,28,102,85,45,32,34,94,73,28,0,4,70,115,62,40,32,69,98,37,0,0,34,121,74,37,28,36,101,70,20,0,0,62,121,70,50,43,70,109,42,2,0,7,83,106,56,45,38,77,97,45,3,0,30,105,81,39,32,32,71,103,57,13,4,41,116,70,29,14,15,53,120,64,32,12,47,119,68,27,8,11,31,104,89,41,26,35,94,87,35,10,8,16,63,108,63,40,22,57,122,61,25,8,7,34,96,85,44,30,25,76,107,56,21,12,18,50,117,76,34,21,28,74,107,57,30,28,38,68,118,54,15,4,11,61,122,68,32,19,23,42,104,83,44,22,26,65,127,76,42,22,33,39,82,105,55,20,15,32,77,113,67,44,36,44,58,113,71,33,9,7,30,80,109,69,52,47,54,73,123,67,32,11,16,31,84,109,65,47,45,59,70,116,69,30,2,0,9,46,111,94,67,56,62,69,98,108,53,16,2,6,25,79,114,66,45,43,47,63,90,105,57,26,19,26,44,101,94,52,33,27,34,53,74,123,73,45,31,40,50,95,104,55,22,21,21,42,52,95,106,66,43,36,48,68,114,75,48,26,20,30,44,62,104,98,60,43,36,50,68,106,90,55,32,26,36,50,65,96,111,63,42,30,41,52,77,122,88,65,56,57,62,77,86,116,90,61,36,34,49,64,86,121,76,49,35,34,47,66,76,100,110,63,43,32,35,53,70,102,102,75,50,47,54,71,86,97,124,85,48,28,22,29,44,54,89,123,83,59,55,59,67,82,96,108,106,66,40,20,26,32,45,63,93,116,83,68,64,75,86,100,112,127,103,64,36,28,26,32,51,65,90,127,88,60,54,53,65,77,91,106,114,117,81,59,46,49,57,70,87,103,121,81,53,39,36,49,55,72,86,97,107,127,93,74,61,62,74,82,99,110,123,86,61,41,37,43,52,65,80,93,103,111,123,95,75,64,64,72,84,100,110,117,111,76,58,48,51,56,71,81,98,106,117,125,112,80,58,45,46,52,66,79,94,110,127,110,75,63,54,54,63,72,84,95,108,111,123,123,120,89,75,66,63,67,80,90,96,111,117,126,106,86,76,73,78,88,99,107,121,123,122,113,112,108,96,71,61,52,58,68,80,90,101,108,111,121,127,111,92,90,89,101,101,113,122,125,116,111,106,109,104,101,99,79,65,60,61,63,76,82,94,100,111,113,127,127,111,89,83,75,78,82,91,101,106,110,118,121,126,121,127,125,127,127,117,101,96,92,94,100,103,114,122,127,120,114,111,108,107,105,90,78,69,70,71,84,87,91,103,106,112,118,120,117,124,126,125,125,127,126,123,110,101,93,95,94,98,101,113,115,121,124,124,122,123,119,122,121,115,114,104,91,90,88,94,99,109,110,116,121,126,125,124,125,119,119,119,117,117,115,112,113,117,112,113,109,107,96,87,85,87,92,95,98,106,110,112,115,122,123,123,123,127,127,126,127,128,126,127,128,124,117,113,105,106,102,110,113,114,121,126,126,127,124,122,121,122,119,120,122,115,117,119,117,115,116,114,113,117,116,116,115,115,115,113,118,119,115,116,116,120,121,117,117,105,104,101,103,108,112,116,116,123,122,128,124,122,125,121,123,118,121,118,116,119,116,114,121,112,115,115,106,99,96,95,95,94,102,106,115,114,117,123,122,127,127,125,125,122,124,120,126,118,120,122,117,120,118,120,116,115,105,97,93,88,94,95,101,106,111,121,121,125,128,126,125,121,122,121,118,114,105,89,88,86,89,96,100,105,113,115,117,123,126,128,127,124,124,124,125,121,123,119,107,95,85,84,85,92,97,104,108,115,121,127,124,125,124,121,107,97,83,82,83,85,99,105,104,117,121,121,127,126,127,121,124,121,111,102,87,79,77,78,87,95,101,107,116,120,126,128,119,101,88,77,76,81,88,98,100,111,120,125,128,123,120,119,120,98,87,75,70,71,79,88,94,105,110,118,123,119,96,83,72,76,76,82,94,103,112,119,127,128,122,120,108,87,69,63,64,68,77,88,101,107,114,126,108,79,71,66,66,76,89,95,109,114,124,128,123,109,84,71,59,57,64,78,82,95,109,116,117,85,70,60,63,71,74,90,103,114,125,126,117,91,72,52,48,55,63,82,90,100,120,104,77,60,53,57,65,82,92,104,117,128,119,87,62,48,44,52,66,79,93,106,113,81,58,49,49,60,72,82,103,110,120,106,76,55,38,42,53,64,79,97,128,82,60,44,45,52,65,76,94,107,123,95,62,45,37,40,52,67,84,116,99,59,47,37,44,56,72,90,102,125,91,54,40,30,38,54,67,92,119,74,49,39,37,47,65,79,96,116,95,52,34,28,35,48,66,97,107,67,44,30,40,54,65,81,103,107,63,42,24,24,42,56,92,111,68,44,31,36,46,66,81,111,97,54,28,19,30,42,64,116,86,48,36,34,42,56,74,100,111,53,34,16,24,36,65,113,86,46,36,28,41,59,72,114,90,45,23,14,24,41,88,117,61,36,28,33,51,63,97,102,55,24,18,24,35,75,115,69,42,26,33,44,62,102,96,50,20,10,23,39,93,97,56,32,29,35,51,73,125,64,33,14,13,27,75,118,65,39,24,33,48,66,121,68,35,11,15,23,75,112,65,37,24,34,45,78,116,55,24,10,15,40,97,89,46,29,29,38,55,109,77,38,10,11,25,79,103,62,29,27,34,48,99,92,37,13,7,20,78,107,60,34,25,30,49,105,82,38,9,9,25,92,96,55,26,26,34,59,128,59,26,5,10,52,125,70,35,26,25,42,102,85,40,10,8,27,101,83,44,27,23,35,83,96,44,11,4,25,95,90,45,26,24,31,87,95,40,11,4,35,104,88,41,21,25,33,103,76,35,7,6,52,127,65,33,20,25,57,121,55,18,1,18,93,92,42,26,23,34,105,75,30,4,10,66,112,62,33,24,29,87,89,38,5,3,55,125,65,35,19,24,83,94,40,4,0,58,120,63,30,17,28,92,85,35,5,5,69,110,50,26,15,37,107,62,27,0,21,97,85,43,19,20,60,110,46,10,1,49,121,61,30,14,30,101,67,29,0,25,102,81,40,18,18,75,94,41,3,5,82,100,51,20,15,57,116,45,7,2,63,109,51,24,10,55,120,50,10,0,67,112,51,24,10,58,115,48,8,2,70,105,50,22,13,67,102,44,2,9,86,87,40,16,18,92,78,30,0,32,118,72,31,14,37,124,59,15,0,67,110,51,24,13,76,90,36,0,25,116,76,32,11,42,127,50,9,5,74,93,49,16,16,98,67,24,0,48,117,59,19,13,77,92,34,0,33,122,69,24,10,66,100,37,0,30,112,72,30,9,61,104,45,2,25,108,74,31,5,55,108,44,0,28,112,68,29,10,64,97,38,0,39,128,65,26,6,83,82,24,0,54,105,54,15,26,106,58,14,4,83,85,40,7,48,117,47,0,28,115,67,26,8,85,73,24,0,71,94,51,6,41,121,45,3,25,115,63,23,12,89,72,18,0,77,88,45,4,54,105,40,0,48,115,55,14,25,118,59,4,15,100,75,32,8,71,89,33,0,56,107,57,9,28,118,51,8,10,100,76,33,3,64,96,35,0,42,121,62,16,16,95,71,20,0,70,98,52,11,28,120,53,8,10,91,80,37,10,48,119,42,4,21,103,75,35,10,54,110,44,0,21,112,75,28,9,56,109,44,0,21,109,74,31,5,55,115,42,1,17,101,80,35,8,40,125,50,4,11,79,91,45,15,22,102,66,21,0,52,121,61,25,16,76,94,37,0,23,108,75,31,15,39,126,54,12,0,67,105,50,21,15,80,90,35,0,24,105,78,39,14,26,112,65,23,0,48,125,62,26,15,46,123,53,14,2,61,108,50,26,13,58,112,43,6,7,75,100,51,22,15,66,110,44,10,7,71,105,50,21,16,55,116,45,13,2,58,114,57,26,17,40,121,60,21,1,40,118,73,38,17,24,93,81,38,1,17,88,95,47,20,19,61,117,49,14,3,50,126,65,31,21,25,92,85,35,5,10,78,103,53,26,25,40,112,68,27,2,21,90,93,48,25,22,47,122,63,26,0,23,95,89,47,25,24,49,116,62,27,0,19,87,101,51,25,25,35,103,76,37,7,10,62,116,66,33,25,30,73,110,48,16,5,31,102,87,43,26,30,43,103,77,36,9,11,50,127,71,37,22,31,46,121,63,34,10,16,60,121,72,33,25,33,50,117,68,32,11,15,56,126,71,42,24,29,47,107,81,40,11,15,36,107,88,47,27,33,39,75,112,49,23,13,22,74,114,68,36,28,36,51,105,88,42,18,17,29,88,99,56,34,31,36,56,115,78,43,12,18,35,93,100,60,35,28,36,57,108,88,43,20,19,27,77,117,65,42,30,36,49,79,111,61,31,14,24,48,102,87,54,32,31,46,57,101,99,51,24,18,31,56,116,83,48,37,32,46,64,93,102,51,29,20,32,47,105,100,53,39,34,46,59,78,125,70,41,19,25,37,69,128,76,46,39,38,48,62,89,114,64,35,23,29,42,72,124,80,45,39,38,52,66,86,125,74,47,22,32,41,60,108,97,58,41,39,45,63,76,100,102,58,39,24,32,43,69,112,96,56,41,42,47,65,80,99,113,66,39,29,35,46,63,97,110,68,48,43,44,53,78,87,113,95,60,36,30,39,57,71,106,108,67,50,38,51,59,73,91,105,112,67,47,34,38,52,65,85,123,89,58,44,42,49,67,82,96,113,111,70,47,35,41,52,65,85,112,101,66,52,47,49,64,78,89,108,117,100,64,51,40,44,62,70,87,110,109,74,57,49,50,63,77,93,105,114,125,84,64,49,47,55,61,79,94,113,111,75,61,55,53,68,77,95,104,118,127,115,81,64,51,50,61,75,84,95,112,113,83,67,56,55,70,79,89,106,114,127,125,105,85,63,54,57,62,81,86,100,113,127,97,71,62,63,65,75,90,99,108,119,124,126,114,90,72,61,59,65,76,89,96,109,118,124,103,76,73,60,72,73,88,99,108,118,125,128,121,115,101,82,70,63,70,79,85,97,108,113,123,127,106,82,76,73,74,79,92,99,108,117,127,126,125,122,121,110,101,79,71,73,76,83,94,104,110,119,124,127,119,105,90,81,73,81,87,97,105,114,118,126,126,126,121,119,120,120,107,93,84,74,80,87,91,100,111,114,119,126,128,123,121,106,99,85,81,84,87,96,102,112,118,121,125,125,124,124,120,121,118,120,121,113,96,87,86,83,88,93,103,107,117,121,127,124,125,122,122,119,118,108,97,89,91,88,94,101,108,112,115,125,126,127,125,122,128,121,119,119,125,119,120,118,118,117,106,97,93,88,94,96,103,106,111,117,123,125,128,126,126,126,122,122,123,121,118,119,115,109,101,96,94,98,105,106,114,115,118,125,126,127,123,119,124,120,121,125,120,121,118,121,119,117,120,117,116,115,118,114,120,116,114,117,117,115,108,102,103,100,106,109,114,119,120,120,127,128,125,124,125,122,123,121,123,120,123,121,122,120,119,118,117,120,120,118,119,111,110,104,100,100,105,105,111,116,119,123,127,128,126,126,121,120,121,122,120,121,123,114,116,121,113,116,114,113,117,115,114,114,112,100,92,91,92,96,98,107,111,112,123,124,123,126,127,124,123,120,120,122,118,113,102,95,94,95,89,99,101,108,113,117,119,126,123,127,127,122,125,124,125,120,121,122,119,109,99,88,82,86,90,98,100,108,112,117,122,125,123,124,124,123,110,98,90,87,86,87,98,100,112,115,119,125,125,126,126,121,121,123,123,116,102,85,83,80,83,90,94,101,110,112,118,127,128,122,106,99,83,77,80,83,96,98,108,113,122,122,126,124,123,122,117,103,90,75,75,74,80,88,96,108,109,120,125,122,107,87,77,75,75,79,91,102,104,115,122,126,123,120,118,103,88,71,66,71,71,86,93,103,113,121,126,104,85,71,64,73,76,88,98,109,114,124,124,123,116,91,75,64,62,61,72,85,97,105,117,122,100,77,61,63,64,76,86,98,111,116,127,125,112,81,67,54,53,62,76,83,97,107,124,96,74,61,54,60,67,84,98,109,119,122,117,83,62,51,49,55,68,76,94,107,116,83,59,55,50,58,70,88,97,113,123,117,81,58,45,45,52,58,77,92,117,101,67,51,46,48,60,75,93,101,115,116,73,56,41,38,44,62,76,98,123,84,53,45,41,51,69,80,98,111,119,78,52,36,35,43,58,76,100,105,76,50,41,49,56,71,92,96,126,81,50,37,28,40,53,66,102,103,67,48,38,44,55,68,89,105,109,67,34,29,31,40,59,89,117,71,46,37,37,49,67,83,105,101,62,33,23,29,42,61,106,92,59,41,34,39,54,75,89,121,69,40,20,23,33,54,102,101,59,38,32,35,54,66,94,107,60,32,17,24,37,65,120,79,50,32,30,43,59,76,126,79,37,17,19,30,54,107,89,54,32,26,42,54,75,128,72,37,16,20,28,58,124,76,45,31,31,40,58,94,99,52,25,13,22,42,97,96,55,33,27,41,53,82,112,57,25,15,17,38,100,100,56,29,29,38,52,92,99,51,23,11,18,50,121,79,45,27,33,41,63,118,72,32,11,12,33,91,99,56,34,27,37,54,104,84,38,14,12,24,83,104,60,32,26,33,51,103,90,41,12,7,27,94,101,57,28,27,33,58,127,70,28,9,11,45,118,75,45,25,25,45,84,96,41,18,5,26,86,96,52,29,30,33,66,112,50,24,2,18,75,107,55,29,24,33,64,114,54,19,6,22,82,103,54,29,24,31,79,98,45,14,4,32,104,87,42,24,24,45,109,76,32,7,11,64,116,58,33,21,33,73,101,43,13,1,41,119,75,34,23,26,57,116,54,22,0,29,104,83,45,22,23,53,122,62,23,1,25,104,83,45,19,21,59,119,57,19,0,40,113,77,37,23,22,70,101,45,12,2,57,124,60,31,14,32,102,78,27,1,19,90,92,44,22,22,56,108,49,13,6,55,123,63,29,20,35,110,64,25,0,31,113,74,40,15,28,92,83,32,1,21,101,84,41,18,25,84,87,32,1,13,95,89,47,18,26,85,88,30,0,21,100,81,42,18,30,98,74,26,0,36,118,69,36,15,38,125,62,16,2,57,116,55,25,15,64,105,41,3,14,95,87,43,13,28,106,73,24,0,53,119,59,30,13,62,107,41,6,16,101,81,39,11,34,121,63,16,2,71,101,49,14,24,97,79,22,0,54,117,57,23,13,80,90,29,0,42,124,63,26,14,66,93,39,0,33,126,68,27,13,70,92,33,1,38,126,63,26,14,82,90,24,1,49,115,56,21,19,99,76,19,2,70,99,52,13,35,128,58,11,14,102,83,35,11,58,100,36,3,36,125,62,20,19,101,74,16,1,81,90,44,11,51,111,45,3,33,127,69,20,18,102,73,13,4,89,87,38,9,57,98,29,0,49,110,53,18,29,126,52,9,19,116,73,34,9,79,89,22,2,64,100,50,12,34,122,53,5,21,112,73,34,9,75,91,24,1,55,115,54,16,23,117,65,18,5,89,94,45,11,45,116,48,3,25,112,77,34,10,62,96,35,2,35,127,63,26,15,83,92,29,2,45,124,60,24,15,83,85,24,0,48,122,57,23,19,81,82,27,1,43,123,60,29,12,71,94,31,4,30,118,66,32,11,55,107,45,2,17,101,81,43,11,32,120,60,15,5,67,106,54,21,20,81,89,31,0,36,116,71,34,13,40,122,58,13,7,74,109,52,21,18,78,91,36,2,27,105,78,43,18,31,106,75,22,2,41,124,66,34,12,42,128,64,17,2,57,122,61,32,16,46,123,54,18,6,57,116,62,33,17,46,128,61,18,2,56,126,65,33,17,36,116,71,26,0,34,116,74,39,19,33,88,81,34,2,13,83,98,49,27,22,57,117,52,21,0,47,127,71,37,22,33,93,82,35,7,14,79,102,55,29,20,48,118,67,27,1,25,97,87,42,22,26,56,122,57,26,0,34,110,82,43,28,25,57,122,57,28,3,34,101,88,46,23,27,49,121,65,28,7,22,85,100,55,29,24,39,98,89,39,14,13,55,124,68,38,31,29,61,120,60,24,7,31,88,96,56,29,27,39,82,98,45,21,9,39,103,86,49,29,31,44,91,89,46,15,10,44,107,85,48,30,31,44,91,96,47,21,9,38,97,97,56,34,33,41,71,116,61,30,14,20,70,121,72,42,28,38,53,102,84,40,22,14,36,96,99,58,37,32,42,60,121,77,39,15,22,42,104,97,52,34,36,41,67,120,77,42,17,19,39,91,102,58,40,33,42,55,92,95,50,27,22,29,62,128,77,46,32,39,49,73,117,78,43,21,21,34,81,116,67,43,32,43,56,77,120,73,38,23,23,37,76,121,73,50,32,39,55,70,107,89,50,26,23,35,56,108,92,51,42,36,46,67,79,124,71,44,23,29,37,68,123,82,52,41,38,53,63,91,127,77,42,32,30,41,59,112,97,56,43,38,48,66,80,111,98,56,38,28,36,54,80,127,83,53,40,45,49,71,85,110,90,55,39,32,41,53,80,122,89,55,47,40,51,67,82,100,115,67,47,35,36,46,66,94,118,72,54,46,44,59,68,90,105,118,70,52,35,35,49,65,82,126,86,62,43,45,56,64,83,100,116,102,66,47,38,42,56,69,90,124,87,58,51,46,55,69,84,98,109,118,79,58,44,41,51,66,81,99,118,87,64,53,54,62,76,86,104,114,127,95,64,46,47,50,60,78,89,118,104,76,64,49,59,68,77,95,107,116,128,105,71,54,49,55,62,76,91,103,126,98,72,53,54,63,72,84,98,112,122,125,113,85,67,51,53,62,75,89,97,112,126,94,69,61,59,64,74,86,98,112,121,125,122,103,78,66,59,62,66,80,92,105,113,127,110,80,68,63,63,71,86,96,109,113,123,128,120,113,91,74,66,59,69,78,88,102,109,122,126,115,87,78,67,70,77,84,97,103,113,125,127,126,118,122,105,90,74,69,71,79,85,100,103,113,117,126,121,104,84,81,73,75,84,94,102,111,117,124,128,124,118,119,121,113,95,85,74,76,81,88,97,102,115,119,125,125,122,115,102,87,83,78,83,96,97,107,111,121,126,126,123,126,120,119,118,118,118,98,86,86,78,87,89,99,106,114,119,122,128,127,122,121,114,110,94,89,85,83,97,97,108,110,120,123,125,123,127,121,124,119,123,116,120,120,119,111,104,93,87,88,91,92,105,106,112,119,123,126,125,126,127,122,118,125,118,118,106,96,94,94,93,101,106,108,116,115,124,127,126,126,127,123,124,120,123,122,119,121,117,120,123,115,121,115,115,118,105,102,99,94,99,100,106,108,116,120,125,125,126,126,126,123,125,125,121,123,120,118,121,118,119,117,121,119,117,110,106,103,105,103,106,112,116,115,120,123,124,128,126,125,126,122,124,126,122,120,122,121,118,119,119,118,117,116,119,115,118,118,118,118,118,115,118,115,117,118,110,105,98,97,99,103,110,110,116,121,124,127,128,125,124,124,122,117,118,119,116,117,118,115,113,103,96,93,92,96,102,103,110,115,115,122,126,127,126,125,122,123,122,123,121,122,119,117,118,117,112,104,92,87,89,87,96,98,107,112,117,121,121,125,127,125,126,121,116,114,95,95,86,91,98,98,105,109,115,120,121,128,124,127,122,123,123,118,122,118,103,90,83,82,84,89,94,101,110,113,119,125,126,125,123,110,97,86,79,84,87,93,102,105,114,123,122,125,126,126,122,117,118,103,87,77,77,75,85,91,101,102,118,119,127,126,115,96,81,75,74,78,90,97,105,110,121,125,127,123,121,119,107,88,71,70,70,76,86,93,104,110,118,128,112,92,79,68,67,79,83,95,101,112,122,126,125,123,113,89,75,66,65,67,77,85,95,111,114,125,100,78,70,61,65,75,87,97,106,119,122,125,119,102,77,66,54,57,67,80,86,104,113,122,91,74,61,60,59,77,85,96,109,118,125,121,95,69,55,52,53,66,74,86,105,126,102,69,61,49,59,64,80,95,104,120,126,110,73,59,43,44,52,69,84,94,118,96,65,52,46,54,66,80,93,105,116,120,80,56,42,38,48,59,72,88,125,93,62,50,39,52,62,79,93,110,120,96,60,41,35,36,55,68,86,118,94,60,48,40,49,64,71,99,103,123,75,50,36,31,45,57,71,108,101,68,46,39,48,55,68,89,105,110,68,46,29,34,43,59,84,128,82,52,41,39,47,63,81,95,120,72,46,24,29,37,55,86,119,75,47,38,37,50,65,80,115,98,52,29,23,32,49,69,123,85,50,37,32,45,65,74,110,94,53,30,22,32,43,76,124,74,48,34,39,47,61,84,127,69,42,18,22,33,55,108,94,56,35,33,43,61,76,126,75,43,18,19,30,56,117,87,48,36,35,44,62,86,115,58,33,17,22,43,82,111,64,45,29,39,51,71,121,75,40,20,18,32,72,119,71,42,32,34,48,68,123,74,39,16,18,31,86,113,61,40,31,36,49,80,112,58,24,16,23,50,114,85,47,37,30,43,63,114,72,39,11,18,42,91,96,56,35,27,40,55,109,75,40,16,16,37,99,97,51,31,32,33,66,124,64,34,15,13,48,119,79,49,24,31,43,85,99,47,23,6,28,87,103,55,33,29,34,67,122,60,26,10,21,67,113,66,35,26,34,61,126,62,26,10,19,67,113,66,35,26,34,67,124,58,24,7,28,85,105,54,34,28,36,85,99,48,18,4,43,112,85,47,28,29,51,117,64,30,7,19,82,108,59,31,28,36,85,90,42,12,12,59,127,70,37,25,32,79,102,51,16,7,54,121,76,38,25,30,76,101,51,11,12,53,126,67,39,23,32,85,88,44,7,14,70,115,61,30,25,36,110,72,31,1,27,99,91,47,26,22,69,110,47,16,7,63,123,63,35,21,38,109,70,26,4,34,108,85,41,23,27,85,86,39,2,22,94,94,48,30,19,75,95,47,6,21,83,102,51,27,19,75,100,48,6,21,89,100,52,23,23,79,90,41,7,22,100,90,43,22,27,95,75,30,6,41,117,76,36,19,43,124,63,15,13,67,114,56,31,18,74,96,45,4,28,106,88,43,16,40,113,61,21,11,68,112,58,28,19,80,88,35,9,38,119,71,36,16,58,111,52,7,27,101,87,46,16,44,122,60,13,20,82,96,51,17,35,113,61,14,12,72,109,54,23,33,106,66,21,13,77,103,53,16,37,116,58,15,20,85,93,49,18,43,122,54,9,28,104,83,41,15,61,102,43,8,44,126,68,31,16,88,75,27,12,71,103,55,16,40,123,57,10,28,107,82,38,13,74,92,35,11,61,115,60,18,34,122,56,15,28,109,77,35,12,86,83,28,13,74,101,53,14,52,112,51,8,43,126,60,26,23,102,61,22,19,90,85,45,16,61,101,46,8,49,126,59,26,26,101,67,18,19,88,95,50,11,51,116,47,10,35,114,74,39,17,78,91,36,12,55,121,61,30,27,100,74,21,16,73,109,52,21,34,112,65,18,18,80,101,51,20,40,120,64,16,21,81,97,49,24,35,118,58,17,21,81,101,54,21,33,108,64,19,18,73,115,54,28,24,94,75,29,12,52,125,67,34,17,71,104,45,10,33,105,85,46,18,44,122,60,18,18,73,117,56,29,19,81,88,41,9,36,105,81,42,19,45,118,65,21,14,62,121,62,37,17,64,111,47,8,24,85,105,50,31,23,80,89,45,7,31,100,94,49,26,29,91,83,36,10,43,98,94,44,27,27,91,83,39,6,36,97,90,53,27,25,83,92,45,12,31,86,105,57,32,25,64,112,54,16,24,67,123,67,39,29,42,111,69,29,14,43,109,91,50,30,28,76,104,50,15,21,71,123,68,40,25,36,103,78,38,9,32,92,107,52,39,32,50,118,68,32,12,43,95,103,55,33,28,50,123,69,26,13,41,95,99,55,33,32,44,113,72,36,12,34,81,113,58,38,32,36,90,90,48,12,21,68,120,78,47,30,31,64,122,62,28,17,36,88,114,61,43,34,39,88,92,51,16,20,54,106,91,52,34,36,46,106,84,41,15,24,59,113,87,53,35,35,45,100,80,47,19,21,60,106,92,59,34,36,43,92,102,51,26,18,48,94,110,65,45,35,40,62,123,69,41,16,29,67,118,88,57,40,40,44,80,113,59,31,20,39,79,126,83,51,39,41,50,84,109,59,32,23,37,76,121,89,53,41,41,47,75,126,70,35,26,25,66,105,101,65,48,40,47,61,99,93,53,30,21,44,76,125,87,61,43,38,54,64,112,83,50,25,25,46,84,125,87,58,46,42,55,64,102,89,51,33,28,41,73,110,104,66,54,38,50,61,82,122,74,43,27,34,48,83,126,95,57,49,47,53,69,85,120,69,43,26,32,49,93,121,98,63,52,45,56,67,83,119,85,56,32,32,41,68,109,119,81,59,50,46,58,72,90,122,79,51,33,38,43,72,108,119,85,61,52,49,58,73,86,116,96,53,41,37,41,60,88,128,100,73,57,50,57,67,79,93,125,91,54,40,35,44,61,92,125,106,77,60,53,56,68,78,95,109,110,70,53,37,42,54,70,106,123,99,73,60,58,57,68,83,95,110,116,76,55,44,42,54,66,91,123,110,86,69,61,59,66,73,91,103,115,118,78,57,47,45,57,70,90,120,115,97,80,62,62,66,73,89,100,110,119,116,80,63,51,50,62,74,84,116,118,101,83,77,65,66,75,81,95,107,119,125,111,81,61,56,55,65,74,88,109,121,106,90,84,71,69,71,82,91,102,112,118,125,118,90,68,58,59,66,74,86,98,121,115,98,90,89,74,75,78,83,94,102,113,118,126,119,111,85,69,62,59,70,77,90,102,113,122,105,97,94,90,85,81,87,89,98,108,116,122,128,128,123,107,89,72,67,68,78,88,95,104,115,126,114,100,93,98,93,87,88,89,98,103,108,116,122,122,123,126,122,114,98,83,75,76,77,89,95,104,112,119,125,117,106,96,101,97,104,93,94,96,101,107,116,115,123,123,126,127,119,124,119,111,96,85,80,82,84,93,98,109,115,120,123,123,117,107,103,100,100,101,110,102,101,105,104,109,114,120,123,122,125,124,122,123,126,114,122,116,110,98,87,86,86,94,94,101,113,116,118,126,127,127,122,117,110,111,101,106,109,108,114,113,116,108,113,109,114,118,117,125,121,125,125,126,123,123,120,123,123,116,119,116,119,119,111,101,95,95,91,100,101,105,113,119,119,122,127,125,126,126,122,123,120,121,118,113,109,109,106,112,112,113,118,119,120,121,121,121,117,120,118,118,120,128,123,128,126,125,123,122,125,120,121,119,121,117,116,117,120,117,121,116,122,120,115,119,120,117,120,121,116,120,112,106,102,104,107,106,112,116,119,121,127,127,124,123,125,121,124,120,122,124,119,120,114,112,109,107,104,109,109,112,114,116,121,118,119,113,114,117,118,119,124,125,126,125,126,122,124,121,121,119,121,114,119,117,113,116,110,101,95,90,89,91,98,100,109,109,116,122,124,127,126,121,118,116,110,104,107,108,111,113,114,112,108,113,109,113,114,113,120,126,122,124,128,125,122,123,120,121,110,100,88,81,86,91,95,101,110,112,117,125,126,119,108,107,100,105,107,110,109,106,103,103,105,112,111,113,124,121,127,127,127,123,119,105,87,83,75,79,86,94,99,107,115,125,124,109,103,101,104,101,102,99,97,101,104,110,110,114,120,126,125,128,119,106,93,78,75,74,77,87,96,106,115,127,111,102,97,101,97,99,92,96,93,101,106,110,119,120,128,127,113,88,80,69,68,72,84,90,100,118,118,104,97,95,99,94,89,87,87,95,104,107,119,121,126,117,88,73,63,62,69,76,88,101,125,107,101,95,94,89,80,81,88,93,101,110,114,122,123,95,68,63,55,61,68,84,102,127,105,101,90,89,83,78,77,84,94,102,112,118,117,87,68,51,51,59,69,90,109,118,102,94,86,77,71,73,82,85,100,110,119,105,73,56,50,48,55,70,104,125,108,98,87,77,67,67,73,84,96,105,122,95,59,52,41,43,59,88,114,114,96,92,75,63,65,66,80,90,104,126,89,57,38,40,46,61,100,127,107,97,76,64,60,63,72,86,96,124,85,54,38,32,45,69,100,123,102,91,72,57,55,64,75,87,107,100,56,44,27,33,59,97,127,107,88,73,53,53,57,73,85,121,86,50,30,30,44,76,112,120,95,76,60,50,51,68,80,109,92,53,33,23,38,73,113,123,97,72,54,48,49,63,85,127,75,45,24,24,56,96,120,109,81,57,47,46,58,71,117,87,50,20,26,48,93,117,110,82,61,46,45,55,74,125,71,44,21,28,61,102,125,101,70,56,42,48,61,98,93,48,26,20,54,87,119,108,75,53,43,48,55,95,98,53,29,20,50,88,120,107,73,51,40,45,59,111,82,45,22,28,62,101,123,92,65,44,36,51,79,107,56,31,19,48,91,119,103,65,47,39,41,69,116,62,29,9,40,85,118,107,66,46,41,40,79,108,58,25,16,53,94,127,95,64,41,36,46,101,87,43,12,34,71,109,115,75,48,40,37,68,112,54,28,19,56,103,126,86,49,41,33,58,124,60,33,17,58,92,126,85,54,40,33,58,122,57,28,19,61,101,127,79,53,37,33,76,107,51,23,30,72,106,112,71,44,34,40,108,84,38,14,53,88,120,89,53,40,33,71,108,47,21,39,75,111,104,63,40,30,56,118,56,26,29,68,105,113,65,42,28,51,125,58,24,34,67,102,109,64,41,32,58,119,54,26,33,77,111,99,63,39,28,78,100,45,18,47,86,121,79,52,31,41,112,72,27,29,65,101,109,67,35,30,70,105,43,20,48,91,122,78,48,29,47,127,56,25,37,75,112,89,57,32,36,110,73,26,32,69,106,97,64,31,32,102,78,33,34,68,104,100,66,30,33,103,78,29,34,71,104,94,60,29,39,115,64,24,43,76,111,81,53,26,53,118,53,26,51,86,123,72,40,31,82,91,38,33,66,100,99,58,29,43,126,57,29,49,88,127,75,38,31,92,84,34,39,73,109,90,50,27,61,108,45,32,64,95,107,63,30,41,127,50,35,52,89,119,69,30,36,114,59,33,53,85,124,70,37,33,112,68,35,48,87,124,68,35,33,114,61,33,52,87,118,65,28,40,124,54,38,54,94,109,60,31,53,116,46,40,64,102,96,48,30,74,88,35,51,76,117,79,39,32,106,63,37,52,88,113,62,26,55,110,44,45,66,112,88,40,35,97,71,38,54,89,115,64,27,61,106,43,45,73,118,75,40,34,123,55,45,60,103,99,51,34,85,84,31,49,81,125,68,35,47,123,49,41,60,105,96,49,31,85,85,36,46,82,121,70,35,41,123,55,38,59,98,110,56,28,62,105,43,45,69,109,90,50,29,82,84,39,48,78,121,80,46,37,94,72,35,56,86,126,78,36,35,109,68,39,53,88,127,73,41,33,111,69,39,53,88,126,78,41,32,100,78,36,46,84,121,84,48,34,81,89,38,45,78,112,95,55,35,59,107,46,39,66,101,109,68,33,44,119,64,33,55,87,121,80,43,34,80,90,41,43,73,101,102,64,33,48,122,63,34,53,88,120,85,49,32,69,103,48,34,65,96,121,74,43,34,87,86,41,38,71,99,115,69,37,38,98,80,38,40,78,103,111,70,39,36,97,81,36,40,74,104,112,72,42,38,91,88,40,34,74,99,121,75,50,37,67,105,50,34,58,92,123,87,59,37,47,125,67,32,47,82,109,107,74,44,38,84,96,45,34,64,96,123,89,59,37,45,117,69,39,40,78,108,123,82,50,34,57,123,57,33,46,89,107,113,77,48,36,64,117,56,31,39,74,95,119,90,66,46,70,119,65,36,54,94,116,108,72,45,27,32,104,82,49,49,87,113,119,93,55,35,32,78,107,49,34,60,96,117,114,83,57,42,52,117,73,31,29,63,95,118,113,76,61,49,69,121,62,37,42,77,108,125,107,74,59,56,76,108,53,17,22,57,88,111,122,91,68,62,76,121,68,26,19,54,84,111,120,90,66,53,55,95,98,49,30,48,83,113,120,98,64,50,42,50,105,93,52,40,70,103,126,102,85,55,39,36,47,106,91,56,48,79,107,121,104,87,52,40,36,50,97,99,58,41,62,95,122,108,101,70,53,45,47,70,121,74,43,40,73,104,126,107,97,70,53,55,56,91,100,58,37,39,76,103,126,112,103,78,62,61,64,93,102,56,35,31,61,97,119,122,111,91,74,67,73,93,113,58,22,10,26,65,96,122,116,98,80,66,58,58,78,126,80,48,37,56,86,114,116,107,98,87,67,66,62,77,122,85,53,31,36,70,94,125,121,111,106,86,76,73,81,97,113,66,37,25,33,69,102,124,113,103,93,79,74,69,81,94,128,73,42,22,23,51,83,107,123,119,114,102,90,81,89,92,105,115,70,46,28,35,66,97,123,113,103,97,95,73,71,70,75,86,107,101,69,54,48,69,100,125,106,89,87,85,77,65,58,61,68,74,98,117,86,69,59,70,99,127,105,92,81,82,78,72,65,63,63,72,84,103,113,83,64,59,69,91,125,112,98,91,87,90,89,79,76,79,81,92,98,116,96,70,58,50,62,87,115,124,105,101,98,102,103,101,93,91,91,101,107,113,118,85,61,49,52,56,79,103,117,126,122,122,124,121,122,112,106,102,101,104,107,113,124,94,69,59,61,64,83,107,125,111,104,101,101,106,111,111,109,104,100,107,105,115,123,126,100,75,55,49,54,62,78,98,117,124,112,112,114,116,122,126,120,119,107,100,105,109,115,123,123,107,85,59,52,45,55,58,80,100,118,128,118,116,119,120,125,128,123,127,121,118,114,116,118,120,123,128,128,108,94,76,71,74,79,90,103,115,115,102,95,93,91,92,95,103,102,105,111,110,99,93,91,97,95,98,102,107,114,110,125,110,100,93,94,97,104,119,122,124,108,101,93,89,89,93,96,103,106,112,111,115,116,115,110,107,101,101,105,112,114,120,121,127,127,124,115,100,88,86,86,89,100,102,110,119,122,121,114,106,108,105,111,111,118,123,128,125,127,127,124,118,116,112,114,117,122,127,127,125,126,125,125,126,125,126,123,126,121,125,113,101,96,94,94,96,102,112,114,119,121,125,128,127,120,116,114,113,118,120,122,120,125,127,123,125,123,118,120,125,119,122,117,119,121,119,124,127,126,124,123,126,127,125,128,115,117,112,112,109,106,103,103,105,102,105,106,102,109,105,105,104,108,108,100,94,96,93,102,107,108,110,119,124,127,124,127,121,116,123,111,116,110,99,101,95,102,101,102,103,106,104,107,106,107,105,113,107,113,110,111,108,110,111,112,113,114,110,111,106,106,105,112,111,111,116,114,119,121,127,122,125,127,127,127,117,108,103,97,99,104,108,115,118,125,124,127,119,107,109,107,107,109,108,115,117,120,122,127,125,125,127,126,127,127,127,122,119,118,113,121,125,125,128,121,121,119,116,107,95,79,81,77,82,87,96,102,104,122,123,119,113,113,118,117,127,126,128,126,125,121,124,121,128,124,119,113,118,122,126,126,124,123,120,99,84,75,74,72,80,90,94,113,127,119,110,113,110,114,120,122,122,124,127,127,125,121,113,112,108,116,115,120,125,124,103,87,74,71,77,80,95,110,127,115,108,107,99,110,113,113,117,118,120,121,109,108,104,106,105,116,114,128,96,81,73,73,80,85,105,124,118,103,101,106,102,107,110,115,115,112,106,101,100,102,104,107,122,111,83,74,72,71,82,104,125,114,105,101,103,105,111,112,115,113,105,99,99,95,107,107,127,95,84,65,59,74,93,119,118,108,107,100,108,102,109,113,106,95,94,95,99,105,125,96,75,60,55,70,98,119,117,108,107,100,108,107,114,101,96,93,93,95,108,122,88,67,57,53,76,104,124,113,109,102,103,107,111,105,92,89,90,93,109,116,79,63,49,57,83,111,125,118,108,105,105,107,105,93,90,86,90,109,115,76,53,44,63,89,114,126,115,107,107,108,108,96,82,84,89,100,114,77,52,43,63,89,111,127,113,109,107,108,103,89,77,86,87,119,87,60,42,52,85,102,121,118,108,108,105,103,83,79,78,90,125,79,52,41,60,88,109,125,112,110,107,104,87,80,77,79,115,92,58,43,55,82,107,128,119,108,107,103,79,78,73,83,128,81,51,45,66,91,116,125,116,109,104,87,75,71,71,105,92,58,41,59,90,109,125,117,110,103,87,74,64,68,114,84,56,43,63,93,118,124,115,107,99,77,66,66,88,112,68,42,59,86,110,127,117,115,101,80,72,56,80,116,69,44,56,83,109,128,119,109,101,78,65,57,88,104,59,45,66,90,115,128,115,109,88,69,56,70,124,76,47,55,81,108,128,118,114,99,69,58,61,108,82,50,52,80,100,126,118,115,95,74,54,61,115,81,48,56,83,105,125,119,107,90,66,52,74,115,64,47,67,93,118,125,117,98,75,57,59,109,80,53,60,85,106,127,123,105,83,63,52,95,89,56,54,78,104,125,123,106,86,61,53,93,88,57,58,79,106,127,123,105,83,57,56,109,77,57,63,87,114,126,118,98,71,51,72,110,66,54,74,101,121,128,106,85,61,59,108,75,52,66,85,108,124,119,89,66,51,89,88,59,63,80,107,125,123,95,71,46,87,94,57,62,81,104,125,123,92,62,51,93,89,57,67,81,114,126,117,90,55,56,109,74,56,73,95,117,127,111,77,52,67,110,67,58,79,106,123,123,94,61,55,100,77,58,73,92,117,127,105,71,54,82,95,63,69,87,112,121,110,89,47,70,116,67,64,81,106,123,116,91,52,65,121,73,62,78,106,121,120,90,53,65,119,72,66,79,106,120,116,88,48,71,103,67,71,84,110,125,114,76,52,84,86,63,79,91,114,126,103,63,56,114,75,64,80,105,114,113,88,48,78,97,66,77,88,114,126,103,62,56,121,74,66,82,105,121,115,77,48,90,84,66,80,95,115,124,89,49,79,97,70,77,91,115,125,99,54,66,107,71,75,89,110,127,101,54,63,113,75,75,87,112,127,102,54,67,112,76,77,86,112,128,98,52,68,103,73,75,92,116,123,95,46,81,87,75,81,96,120,118,81,50,98,80,73,82,103,124,107,60,64,123,73,77,91,112,122,97,46,85,89,75,82,102,120,114,70,58,125,79,77,91,110,127,93,46,93,87,76,87,101,120,108,60,64,111,75,81,97,111,118,82,54,109,83,78,86,108,125,98,52,74,94,75,82,98,121,117,71,56,119,81,79,87,108,127,101,52,74,100,77,83,98,115,118,84,54,96,80,78,87,101,122,109,66,61,127,81,78,88,110,125,104,58,68,111,79,77,94,114,127,98,56,72,102,78,81,94,118,125,101,50,77,98,77,83,95,117,122,104,51,72,103,77,79,94,118,127,104,59,67,115,81,77,92,105,123,113,69,62,118,80,72,86,105,122,118,87,52,91,84,72,86,98,119,124,100,60,67,112,76,75,91,111,124,109,79,55,98,86,71,83,100,118,124,100,60,67,126,77,71,92,107,120,117,93,52,76,102,79,77,93,113,124,116,87,54,81,98,74,80,91,112,128,112,86,53,86,93,74,78,93,116,127,112,88,55,81,101,75,75,95,113,124,117,97,55,71,116,79,69,91,107,120,123,101,72,60,111,81,73,82,100,120,125,112,88,54,81,98,75,77,87,116,127,126,101,73,58,109,82,69,79,96,119,127,121,95,61,68,127,75,68,88,105,119,127,114,95,59,76,122,78,66,87,105,122,124,115,96,59,74,121,76,66,84,106,122,124,119,98,66,66,116,77,66,82,97,119,127,121,107,79,58,93,93,69,74,88,110,127,122,116,96,65,66,114,74,66,84,96,119,127,121,108,92,61,81,121,73,66,83,105,119,126,121,108,88,64,80,119,75,67,83,105,118,126,121,111,89,65,74,123,70,65,85,98,119,127,122,114,99,72,65,106,85,69,74,91,110,125,123,117,110,87,67,76,126,74,64,78,101,114,126,122,118,106,83,66,83,114,72,63,84,101,118,125,121,117,112,85,66,78,127,71,65,78,98,119,125,122,114,114,92,76,69,104,88,68,70,84,111,124,121,121,116,107,88,70,78,120,81,63,72,93,113,128,121,116,110,111,90,71,78,121,79,62,72,93,112,128,125,116,116,112,97,80,73,98,98,70,61,85,106,124,126,121,114,114,110,89,78,75,113,85,64,66,90,109,123,126,118,114,114,110,95,83,72,107,98,67,65,84,102,119,128,121,117,116,119,109,88,83,82,120,83,62,63,88,114,119,123,119,114,111,120,105,92,86,79,118,88,63,65,85,106,120,128,119,111,111,115,116,101,88,78,94,123,76,63,69,88,110,126,123,118,111,115,115,115,102,91,88,88,122,89,62,66,82,106,121,124,120,113,111,115,116,116,104,93,91,91,125,89,66,65,84,102,120,122,118,113,112,116,117,122,111,101,91,87,102,120,75,61,66,92,107,124,125,114,115,108,116,120,122,116,107,97,96,93,118,97,75,58,76,96,115,128,117,116,110,114,117,118,116,120,119,102,100,95,100,115,86,71,64,81,103,117,122,120,112,110,116,114,119,121,123,121,117,101,99,98,112,114,81,71,65,83,105,125,121,113,111,111,117,116,118,120,122,128,124,112,109,100,103,109,117,85,71,63,78,103,121,124,116,112,111,114,118,114,120,122,125,127,127,119,111,107,104,101,111,117,87,76,68,75,98,117,128,116,111,114,111,115,116,123,123,126,124,127,126,125,118,111,108,104,110,111,122,92,84,73,73,88,110,126,117,117,110,113,115,115,124,119,122,127,123,125,125,124,125,124,116,113,106,110,109,115,120,101,86,77,78,85,100,120,126,116,113,111,112,118,119,115,124,125,128,127,126,126,128,127,126,127,128,123,117,110,111,109,116,120,127,109,96,83,82,82,92,103,122,121,116,113,111,112,113,118,121,123,125,122,125,127,128,126,125,127,128,127,128,128,124,124,128,121,115,116,114,117,120,123,126,126,116,103,92,87,87,90,98,110,117,124,119,114,110,112,113,115,119,122,125,124,128,127,125,127,126,126,126,127,128,127,127,127,126,127,121,127,127,127,128,128,128,128,128,128,122,121,120,123,124,121,124,126,125,124,122,120,119,107,103,98,98,102,110,106,117,119,123,126,125,117,111,115,114,117,122,115,121,122,125,128,121,126,127,127,124,128,127,124,125,127,126,128,125,128,127,127,127,128,126,125,125,126,127,128,128,128,128,128,123,124,127,124,127,128,127,121,120,119,122,128,128,125,125,123,116,100,96,94,94,99,103,109,118,127,115,115,114,114,116,116,117,122,126,125,123,126,127,125,127,125,126,127,125,128,127,127,125,125,125,128,127,127,124,121,117,116,114,117,120,124,122,106,96,89,85,89,96,114,127,124,114,115,113,116,119,119,119,125,126,127,126,128,126,125,128,126,127,127,126,125,125,121,114,107,111,114,117,127,107,95,87,81,89,100,116,127,122,117,113,117,117,120,122,124,122,126,127,125,125,127,126,127,128,126,118,112,105,110,111,123,110,95,77,79,90,111,119,124,120,114,116,114,122,119,122,127,126,124,127,123,126,126,126,118,106,105,108,112,117,96,83,78,89,104,119,127,123,116,115,113,122,123,121,125,127,125,126,126,126,120,110,105,102,115,116,92,78,83,95,111,122,126,120,113,120,116,122,119,122,126,127,126,127,120,107,106,100,115,116,92,76,83,99,116,128,125,119,119,115,121,120,121,125,127,125,126,115,107,102,99,122,92,84,80,98,113,121,127,118,117,120,120,118,127,123,124,127,118,109,97,100,127,93,82,81,94,109,121,126,122,116,116,120,118,124,125,124,121,106,101,96,125,97,79,83,98,109,123,127,121,121,119,119,118,127,123,121,108,98,92,125,101,79,77,95,110,122,128,125,119,119,116,125,121,125,114,99,95,110,106,83,80,95,109,120,127,121,121,119,119,122,123,120,109,92,96,128,87,84,86,103,117,122,120,121,122,118,122,121,119,110,92,93,122,89,84,91,105,117,127,125,124,117,122,121,124,109,100,84,114,97,83,87,100,116,118,121,124,122,117,122,121,110,94,86,123,91,88,90,104,112,126,127,122,123,117,120,120,99,86,108,106,86,90,101,113,120,126,126,122,121,122,117,103,80,108,103,89,89,101,113,121,127,123,123,121,122,114,90,85,127,88,91,93,107,120,124,127,124,123,118,116,94,82,122,89,96,93,108,117,124,127,124,125,120,115,91,83,126,88,91,100,107,121,125,124,122,120,126,106,83,99,109,90,90,103,114,125,127,124,124,120,115,89,89,120,90,94,99,114,125,127,124,125,120,116,89,89,120,94,90,100,112,122,126,123,124,119,111,84,101,107,94,98,103,119,122,128,123,121,125,97,77,127,93,94,103,112,121,125,125,123,120,104,79,118,96,96,99,109,122,125,125,123,120,107,78,118,99,100,100,110,118,126,125,126,121,102,79,125,97,99,102,113,121,124,126,125,119,86,91,117,99,99,103,120,122,127,122,123,106,82,119,101,100,103,109,124,124,125,124,114,83,103,107,98,99,112,122,125,125,125,117,85,95,108,102,105,104,121,126,126,124,117,84,101,107,103,104,109,118,123,124,128,106,84,115,101,105,102,115,121,124,121,127,99,79,121,103,102,106,118,120,126,126,118,83,108,107,105,104,113,122,125,125,124,98,87,116,103,105,108,118,126,126,128,108,81,128,102,110,103,120,117,126,126,112,84,123,106,104,106,118,120,126,126,114,84,122,102,110,102,118,120,126,125,106,84,123,102,109,106,118,122,126,126,100,89,117,102,110,109,118,127,126,118,89,107,104,108,107,115,122,127,126,110,83,126,106,110,109,118,127,126,123,92,103,112,103,111,116,123,126,125,103,90,118,105,112,110,119,127,127,111,86,127,106,114,107,117,126,124,118,84,120,107,110,108,117,127,127,118,89,114,107,111,109,112,127,124,119,90,115,111,107,112,113,128,124,118,89,120,106,110,109,118,127,127,118,84,123,108,117,107,120,126,126,105,90,115,103,116,108,124,126,125,96,105,110,107,112,113,128,124,118,89,123,106,115,107,120,124,127,102,98,115,107,119,111,124,122,116,89,128,109,119,108,121,123,128,97,107,111,109,112,113,128,127,115,88,120,109,117,106,126,127,123,92,116,105,113,112,117,127,126,110,89,116,103,117,108,124,126,125,91,110,110,107,112,117,124,124,118,89,127,108,114,111,121,126,126,105,93,116,108,116,113,124,122,125,99,104,111,107,112,113,123,126,124,96,109,111,114,112,112,127,122,125,92,117,112,111,112,117,127,123,127,91,110,106,110,112,113,123,126,125,99,102,111,107,112,117,124,127,124,105,95,115,108,116,114,124,127,127,118,88,123,109,115,112,121,127,127,122,96,108,107,111,109,121,123,128,125,109,90,121,109,110,114,120,128,127,124,97,108,107,111,109,121,123,127,127,118,91,123,106,115,107,124,123,128,125,116,87,125,109,114,107,124,123,128,128,109,90,121,109,114,107,124,122,128,123,112,90,121,109,114,112,120,123,128,128,117,90,127,107,110,102,121,120,126,126,127,98,104,110,107,112,112,123,126,125,125,112,89,122,109,110,110,124,123,127,124,125,96,107,108,110,111,114,124,123,128,123,117,90,127,114,115,108,120,123,127,124,126,112,92,127,103,118,108,121,124,124,124,127,116,93,126,107,115,109,120,123,127,123,127,117,90,121,108,112,110,119,123,127,126,127,124,100,104,112,111,114,114,123,127,127,124,125,115,93,126,105,110,114,120,123,127,127,124,125,105,96,112,109,114,110,124,123,128,128,125,125,102,100,113,105,116,111,120,123,127,127,123,125,105,96,117,110,110,107,123,123,124,125,125,127,116,95,124,106,110,114,113,122,126,125,127,123,127,104,99,118,108,109,109,123,126,126,127,124,125,124,97,107,108,112,109,110,124,126,127,127,124,125,124,101,106,114,112,110,110,124,123,127,127,124,125,128,113,93,126,108,108,111,119,124,123,125,128,125,125,127,102,100,117,110,110,110,124,123,127,127,128,126,125,124,104,101,114,110,110,110,124,123,127,127,124,125,128,124,114,95,126,104,111,111,120,124,123,125,127,126,125,127,124,107,99,113,109,111,110,120,124,127,127,128,122,128,128,127,108,99,119,109,110,114,117,124,123,125,127,126,125,124,128,122,98,117,105,111,109,113,123,126,124,125,124,125,128,128,127,118,98,117,109,107,109,116,124,123,127,127,123,125,128,128,122,127,112,99,119,106,111,110,118,123,126,126,127,124,125,128,128,122,127,112,106,122,110,110,114,113,122,126,125,125,123,125,128,128,127,126,126,107,103,118,107,111,110,116,123,126,125,125,123,125,128,128,127,127,126,120,104,117,108,107,108,112,118,125,125,126,128,128,124,125,127,128,127,127,126,112,105,116,109,105,112,119,121,128,126,126,127,123,126,127,127,128,128,128,126,116,104,127,107,107,110,114,122,127,127,126,124,125,128,128,127,126,127,126,125,126,124,109,110,116,106,106,116,118,121,127,127,124,121,126,127,127,127,126,125,126,126,124,125,119,109,115,112,107,109,113,119,126,126,125,127,126,125,127,128,127,127,126,125,126,125,126,125,126,112,110,127,110,106,109,114,121,126,127,126,127,126,125,127,128,127,127,127,124,125,127,127,124,127,126,122,106,115,117,105,109,109,118,121,124,127,125,125,122,127,127,127,127,127,127,124,127,124,125,126,124,126,124,125,123,113,113,120,111,102,110,114,121,124,127,123,125,127,126,125,127,128,127,127,127,124,125,127,124,125,125,125,126,126,127,127,127,125,118,114,116,119,104,110,107,117,124,122,127,127,128,122,125,127,127,127,127,128,127,126,126,126,125,125,125,125,126,126,127,127,127,127,128,128,128,128,128,121,117,118,128,114,109,106,110,119,124,127,127,124,127,126,125,127,128,127,127,128,126,125,126,126,125,126,124,125,126,125,125,125,126,127,127,128,128,128,128,128,128,128,127,127,126,126,126,126,127,125,120,123,117,128,118,111,110,106,115,119,123,128,124,125,124,122,128,125,126,127,126,128,127,127,127,127,127,126,127,127,127,126,126,125,126,125,126,124,125,125,127,128,128,128,128,128,128,128,128,127,127,126,126,126,126,127,127,127,127,127,127,128,128,128,128,128,128,128,128,127,126,120,119,123,118,114,107,112,116,119,123,123,127,127,127,126,125,127,127,127,126,127,124,127,126,125,126,125,126,124,125,126,125,126,124,125,125,126,127,127,128,128,128,128,128,128,128,127,127,126,127,118,114,126,116,110,113,116,121,127,125,125,125,126,124,125,127,127,127,127,126,126,127,124,125,126,124,125,125,125,127,127,127,127,127,127,128,128,128,124,121,116,125,115,114,114,123,122,127,127,125,123,126,125,127,128,128,127,127,126,125,125,125,125,126,126,127,127,127,127,127,127,125,114,120,120,115,116,117,121,127,127,128,126,123,127,128,128,128,128,127,126,125,125,125,125,126,127,127,127,127,127,118,117,120,114,119,117,123,127,127,125,124,125,127,128,127,128,128,127,126,125,125,125,126,125,125,125,123,113,126,119,118,116,122,126,127,126,127,127,128,128,128,128,128,128,127,126,125,125,125,125,127,113,124,115,120,119,123,124,127,126,127,126,128,128,128,128,128,128,127,126,125,125,125,123,117,126,119,118,119,123,124,127,126,128,127,128,128,128,128,128,128,127,126,125,125,117,124,118,121,120,120,125,124,127,126,127,127,128,128,128,128,128,128,127,126,125,117,116,121,120,119,125,124,127,127,127,128,128,128,128,128,128,127,126,127,118,122,123,118,124,124,122,126,127,127,128,128,128,128,128,128,128,127,118,125,118,118,123,122,127,126,124,128,128,128,128,128,128,128,127,127,119,124,121,121,119,126,125,126,127,128,128,128,128,128,128,128,127,118,122,123,122,121,124,124,128,127,127,128,128,128,128,128,128,126,120,118,125,122,123,125,123,127,128,128,128,128,128,128,128,126,120,118,124,125,120,126,128,128,128,128,128,128,128,128,128,126,122,125,124,123,123,124,126,123,127,128,128,128,128,128,120,121,125,123,123,128,122,125,123,127,128,128,128,128,122,121,118,125,125,124,124,124,127,128,128,128,128,128,122,125,119,126,125,124,124,124,127,128,128,128,128,128,122,125,119,125,125,124,124,124,127,128,128,128,128,128,122,127,122,125,125,124,127,128,128,128,125,128,128,124,120,118,124,125,124,125,127,128,128,128,128,128,127,126,122,125,125,124,127,124,127,128,128,128,128,127,126,122,124,124,124,127,128,128,128,128,128,128,124,122,125,125,124,127,124,127,128,128,128,128,124,125,125,124,124,127,124,127,128,128,128,128,127,127,124,124,128,123,127,123,127,128,128,128,127,127,124,119,128,128,128,128,128,128,128,128,125,118,127,125,123,125,123,127,128,128,128,128,124,122,124,128,123,124,127,128,128,128,127,127,121,127,125,124,127,123,124,127,128,128,122,122,125,125,120,125,128,124,127,128,128,127,121,127,123,124,127,128,128,128,128,128,125,122,125,125,124,127,128,128,128,125,128,127,124,124,127,123,127,128,128,128,128,124,122,125,125,124,127,128,128,128,128,128,127,124,124,127,128,128,123,128,128,128,122,122,124,128,125,128,123,127,128,128,127,124,125,125,125,127,127,127,127,127,125,123,128,128,123,127,128,128,128,128,126,122,125,125,125,127,127,127,127,127,125,124,125,125,127,127,127,127,127,128,128,128,128,128,128,128,126,126,126,127,121,127,128,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,126,122,125,125,125,127,127,127,127,125,124,125,125,127,127,127,127,127,128,128,128,128,120,128,128,124,127,128,128,128,123,124,124,127,128,124,127,128,128,128,123,124,127,128,128,128,128,128,128,128,128,125,125,125,125,127,127,127,127,127,127,128,128,128,128,128,128,128,127,126,126,126,126,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,127,124,125,125,125,127,127,127,127,127,128,128,128,128,128,128,128,127,124,125,125,125,127,127,127,127,127,128,128,128,128,128,128,128,127,126,126,126,126,127,127,127,126,124,125,125,126,127,127,127,127,127,128,128,128,128,128,128,128,127,126,126,126,126,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,123,128,128,128,128,128,128,128,128,128,128,128,126,126,126,127,127,127,127,127,127,128,128,128,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,0}; +int spaceShipSound_numberOfSamples = 20805; //used to be 25805 also removed all negatives from [] +int spaceShipSound_sampleRate = 8; diff --git a/ecen427/tank.c b/ecen427/tank.c new file mode 100644 index 0000000..a6c74d6 --- /dev/null +++ b/ecen427/tank.c @@ -0,0 +1,111 @@ +#include "tank.h" + +void renderTank(unsigned int* framePointer) { + short tankx, tanky; + tankx = getTankPositionX(); + tanky = getTankPositionY(); + int row, col; + + for(row=0; row < 16; row++) { + for(col=0; col < 32; col++) { + if ((tank[row%16] & (1<<(32-1-col)))) { + framePointer[tanky*640 + tankx] = 0x0000FF00; + + } else { + framePointer[tanky*640 + tankx] = 0x00000000; + } + tankx++; + } + tankx=getTankPositionX(); + tanky++; + } +} +void renderDying1(unsigned int* framePointer) { + short tankx, tanky; + tankx = getTankPositionX(); + tanky = getTankPositionY(); + int row, col; + + for(row=0; row < 16; row++) { + for(col=0; col < 32; col++) { + if ((tank_dying1[row%16] & (1<<(32-1-col)))) { + framePointer[tanky*640 + tankx] = 0x0000FF00; + + } else { + framePointer[tanky*640 + tankx] = 0x00000000; + } + tankx++; + } + tankx=getTankPositionX(); + tanky++; + } +} +void renderDying2(unsigned int* framePointer) { + short tankx, tanky; + tankx = getTankPositionX(); + tanky = getTankPositionY(); + int row, col; + + for(row=0; row < 16; row++) { + for(col=0; col < 32; col++) { + if ((tank_dying2[row%16] & (1<<(32-1-col)))) { + framePointer[tanky*640 + tankx] = 0x0000FF00; + + } else { + framePointer[tanky*640 + tankx] = 0x00000000; + } + tankx++; + } + tankx=getTankPositionX(); + tanky++; + } +} + +void blankTank(unsigned int* framePointer) { + short tankx, tanky; + tankx = getTankPositionX(); + tanky = getTankPositionY(); + int row, col; + for(row=0; row < 16; row++) { + for(col=0; col < 32; col++) { + framePointer[tanky*640 + tankx] = 0x00000000; + tankx++; + } + tankx=getTankPositionX(); + tanky++; + } + +} +void moveTankL(unsigned int* framePointer) { + short dir = getDirection(); + short tankx, tanky; + tankx = getTankPositionX(); + tanky = getTankPositionY(); + if(tankx+32 == 638) { + tankx -= 2; + setTankPosition(tankx, tanky); + } + if(tankx == 4 || tankx+32 == 638) { + } + else { + tankx -= 2; + setTankPosition(tankx, tanky); + } +} + +void moveTankR(unsigned int* framePointer) { + short dir = getDirection(); + short tankx, tanky; + tankx = getTankPositionX(); + tanky = getTankPositionY(); + if(tankx == 0) { + tankx += 2; + setTankPosition(tankx, tanky); + } + if(tankx == 0 || tankx+32 == 638) { + } + else { + tankx += 2; + setTankPosition(tankx, tanky); + } +} diff --git a/ecen427/tank.h b/ecen427/tank.h new file mode 100644 index 0000000..702f876 --- /dev/null +++ b/ecen427/tank.h @@ -0,0 +1,77 @@ +#ifndef TANK_H_ +#define TANK_H_ +#define TANK_HEIGHT 16 +#define TANK_WIDTH 32 +#define packWord32(b31,b30,b29,b28,b27,b26,b25,b24,b23,b22,b21,b20,b19,b18,b17,b16,b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0) \ + ((b31 << 31) | (b30 << 30) | (b29 << 29) | (b28 << 28) | (b27 << 27) | (b26 << 26) | (b25 << 25) | (b24 << 24) | \ + (b23 << 23) | (b22 << 22) | (b21 << 21) | (b20 << 20) | (b19 << 19) | (b18 << 18) | (b17 << 17) | (b16 << 16) | \ + (b15 << 15) | (b14 << 14) | (b13 << 13) | (b12 << 12) | (b11 << 11) | (b10 << 10) | (b9 << 9 ) | (b8 << 8 ) | \ + (b7 << 7 ) | (b6 << 6 ) | (b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 ) ) + +int tank[TANK_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + +}; +int tank_dying1[TANK_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0), + packWord32(0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + +}; +int tank_dying2[TANK_HEIGHT] = +{ + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0), + packWord32(0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0), + packWord32(0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0), + packWord32(0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0), + packWord32(0,0,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + packWord32(0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0), + +}; + +void renderTank(unsigned int*); +void blankTank(unsigned int*); +void moveTankL(unsigned int*); +void moveTankR(unsigned int*); + +#endif /* TANK_H_ */ diff --git a/ecen427/tankDeath.c b/ecen427/tankDeath.c new file mode 100644 index 0000000..693a088 --- /dev/null +++ b/ecen427/tankDeath.c @@ -0,0 +1,383 @@ +int tankDeath_soundData[] = { +120, 119, 119, 119, 120, 120, 129, 130, +133, 129, 125, 119, 119, 119, 125, 128, +135, 137, 133, 123, 109, 99, 91, 92, +101, 116, 135, 140, 143, 130, 123, 105, + 96, 89, 92, 105, 115, 116, 120, 119, +130, 133, 139, 149, 163, 171, 174, 173, +161, 143, 133, 115, 99, 79, 72, 75, + 79, 82, 87, 103, 125, 143, 139, 137, +137, 149, 163, 173, 168, 153, 133, 111, +105, 106, 109, 119, 137, 149, 140, 133, +133, 143, 154, 168, 183, 187, 188, 184, +173, 163, 143, 113, 75, 39, 5, 0, + 0, 3, 9, 19, 46, 82, 105, 120, +135, 139, 144, 173, 195, 208, 211, 202, +191, 181, 181, 202, 236, 255, 255, 255, +255, 255, 240, 212, 192, 171, 130, 85, + 47, 36, 41, 37, 33, 43, 57, 51, + 33, 3, 0, 0, 0, 0, 5, 9, + 24, 67, 120, 157, 177, 201, 222, 239, +250, 246, 236, 216, 192, 159, 101, 41, + 0, 0, 0, 0, 0, 0, 58, 103, +129, 161, 192, 218, 239, 242, 221, 184, +163, 157, 157, 159, 163, 161, 129, 81, + 37, 17, 7, 19, 41, 61, 89, 139, +178, 195, 205, 202, 184, 161, 153, 157, +161, 181, 187, 177, 164, 149, 161, 197, +246, 255, 255, 255, 255, 255, 252, 226, +173, 105, 39, 0, 0, 0, 19, 71, +101, 133, 168, 183, 174, 163, 139, 113, + 99, 77, 47, 31, 36, 41, 39, 43, + 77, 125, 154, 149, 128, 95, 65, 57, + 79, 99, 130, 161, 173, 192, 221, 246, +255, 235, 181, 115, 48, 0, 0, 0, + 19, 58, 115, 171, 216, 216, 177, 119, + 67, 43, 39, 31, 24, 17, 12, 15, + 27, 79, 149, 226, 255, 255, 255, 255, +255, 255, 255, 240, 207, 157, 77, 3, + 0, 0, 0, 0, 0, 0, 41, 72, + 79, 67, 67, 95, 115, 125, 128, 120, +125, 147, 188, 222, 255, 255, 255, 255, +255, 255, 249, 255, 255, 255, 255, 255, +202, 140, 85, 29, 0, 0, 0, 0, + 0, 46, 113, 129, 113, 79, 41, 17, + 27, 61, 79, 92, 103, 103, 106, 115, +125, 154, 212, 255, 255, 255, 255, 255, +255, 222, 163, 115, 85, 96, 128, 163, +192, 207, 195, 143, 72, 0, 0, 0, + 0, 0, 0, 0, 0, 53, 135, 201, +255, 255, 255, 255, 255, 222, 183, 144, +106, 63, 0, 0, 0, 0, 0, 0, + 0, 29, 133, 192, 212, 207, 216, 245, +255, 255, 255, 249, 211, 205, 221, 250, +255, 255, 255, 255, 212, 140, 106, 105, +135, 167, 195, 218, 216, 192, 164, 135, +115, 105, 96, 92, 95, 103, 109, 119, +115, 85, 47, 15, 15, 47, 87, 115, +135, 149, 159, 188, 232, 255, 255, 255, +255, 255, 255, 255, 255, 255, 183, 106, + 55, 17, 27, 58, 87, 129, 174, 218, +239, 215, 161, 95, 31, 0, 0, 0, + 2, 17, 39, 87, 129, 147, 157, 168, +183, 188, 168, 115, 65, 31, 29, 33, + 29, 36, 53, 61, 65, 70, 85, 92, + 82, 82, 75, 58, 41, 48, 58, 72, +103, 149, 192, 229, 239, 226, 201, 164, +144, 143, 147, 137, 119, 103, 87, 85, +115, 161, 221, 255, 255, 246, 236, 218, +208, 183, 150, 128, 111, 101, 92, 99, +116, 135, 144, 149, 157, 163, 164, 164, +167, 159, 154, 154, 163, 173, 183, 187, +187, 191, 187, 177, 167, 161, 150, 137, +119, 106, 101, 99, 99, 96, 103, 105, + 99, 92, 79, 70, 70, 71, 75, 77, + 77, 82, 101, 123, 137, 144, 154, 163, +174, 177, 173, 173, 161, 153, 137, 111, + 82, 53, 29, 22, 29, 37, 58, 87, +106, 119, 133, 149, 163, 173, 174, 164, +147, 137, 135, 133, 135, 139, 135, 120, + 95, 72, 65, 58, 65, 75, 85, 99, +119, 130, 140, 147, 143, 135, 137, 153, +168, 168, 171, 161, 139, 123, 106, 113, +135, 171, 207, 235, 255, 255, 255, 255, +255, 221, 154, 77, 17, 0, 3, 46, + 79, 91, 103, 120, 128, 119, 113, 92, + 70, 51, 31, 17, 7, 12, 27, 48, + 81, 130, 187, 212, 202, 171, 139, 113, +106, 116, 119, 129, 140, 140, 153, 171, +191, 195, 173, 130, 92, 57, 23, 13, + 22, 36, 58, 99, 143, 177, 183, 157, +119, 85, 71, 77, 89, 91, 79, 71, + 71, 79, 119, 171, 216, 255, 255, 249, +236, 225, 211, 202, 191, 173, 143, 82, + 19, 0, 0, 0, 0, 0, 0, 46, + 72, 79, 67, 70, 95, 113, 123, 123, +120, 123, 144, 178, 205, 240, 255, 255, +255, 255, 246, 236, 246, 255, 255, 255, +252, 205, 150, 101, 43, 0, 0, 0, + 0, 0, 48, 109, 123, 105, 71, 36, + 15, 24, 58, 77, 95, 103, 101, 106, +113, 128, 154, 212, 255, 255, 255, 255, +255, 255, 222, 163, 115, 85, 96, 128, +163, 192, 207, 195, 143, 72, 0, 0, + 0, 0, 0, 0, 0, 0, 53, 135, +201, 255, 255, 255, 255, 255, 222, 183, +144, 106, 63, 0, 0, 0, 0, 0, + 0, 0, 29, 133, 192, 212, 207, 216, +245, 255, 255, 255, 249, 211, 205, 221, +250, 255, 255, 255, 255, 212, 140, 106, +105, 135, 167, 195, 218, 216, 192, 164, +135, 115, 105, 96, 92, 95, 103, 109, +119, 115, 85, 43, 13, 12, 46, 85, +115, 133, 149, 161, 188, 236, 255, 255, +255, 255, 255, 255, 255, 255, 255, 191, +106, 51, 13, 22, 51, 82, 125, 177, +226, 250, 225, 164, 96, 22, 0, 0, + 0, 0, 0, 24, 77, 125, 144, 157, +167, 183, 192, 168, 113, 53, 19, 17, + 24, 19, 24, 47, 57, 57, 57, 72, + 81, 72, 70, 58, 33, 12, 19, 37, + 57, 99, 159, 216, 255, 255, 249, 216, +171, 149, 147, 147, 133, 103, 77, 55, + 53, 92, 157, 240, 255, 255, 255, 255, +255, 255, 250, 208, 173, 149, 123, 101, +101, 115, 135, 147, 150, 153, 149, 147, +144, 149, 140, 143, 143, 144, 140, 140, +144, 140, 143, 143, 143, 143, 139, 140, +140, 140, 140, 137, 135, 137, 137, 137, +133, 130, 129, 130, 129, 129, 128, 128, +125, 125, 125, 128, 128, 128, 120, 120, +119, 123, 119, 116, 120, 116, 119, 119, +119, 115, 119, 116, 113, 115, 115, 115, +115, 113, 109, 106, 109, 113, 109, 109, +109, 109, 109, 109, 109, 109, 109, 109, +113, 113, 111, 115, 116, 116, 115, 115, +113, 96, 77, 75, 75, 67, 71, 105, +153, 183, 181, 154, 120, 87, 61, 48, + 46, 48, 63, 87, 143, 212, 255, 255, +255, 255, 255, 235, 143, 77, 58, 67, + 92, 92, 75, 57, 37, 24, 17, 15, + 9, 0, 0, 0, 0, 0, 0, 3, + 71, 159, 250, 255, 255, 255, 255, 240, +232, 229, 211, 171, 128, 95, 70, 55, + 46, 43, 33, 3, 0, 33, 81, 113, +111, 96, 77, 61, 53, 53, 57, 75, + 96, 120, 149, 177, 212, 255, 255, 255, +255, 255, 255, 255, 255, 183, 106, 43, + 0, 0, 0, 0, 0, 0, 5, 67, + 99, 105, 103, 96, 89, 82, 77, 79, + 77, 79, 82, 89, 92, 99, 103, 109, +111, 115, 115, 116, 101, 55, 24, 7, + 7, 24, 48, 75, 113, 147, 171, 202, +218, 236, 242, 255, 255, 255, 255, 255, +255, 255, 255, 250, 109, 9, 0, 0, + 0, 0, 0, 23, 96, 130, 120, 89, + 53, 19, 3, 0, 0, 0, 0, 3, + 15, 24, 24, 0, 0, 9, 61, 109, +125, 120, 105, 101, 130, 178, 226, 245, +229, 198, 164, 139, 116, 103, 99, 92, + 95, 99, 96, 89, 61, 36, 22, 31, + 87, 159, 207, 215, 202, 174, 168, 177, +171, 154, 133, 129, 150, 154, 154, 157, +183, 218, 229, 225, 221, 225, 215, 178, +133, 89, 57, 29, 15, 9, 12, 17, + 24, 31, 41, 43, 29, 37, 51, 63, + 92, 133, 154, 149, 147, 135, 125, 123, +115, 113, 111, 109, 105, 106, 105, 89, + 87, 115, 137, 149, 149, 144, 143, 137, +133, 129, 128, 125, 125, 123, 128, 125, +128, 128, 128, 128, 130, 128, 128, 125, +125, 129, 129, 130, 133, 129, 128, 128, +125, 125, 113, 113, 109, 115, 133, 143, +149, 144, 137, 135, 129, 120, 123, 113, +106, 113, 119, 119, 123, 120, 120, 119, +115, 119, 116, 113, 103, 75, 58, 72, +113, 149, 164, 183, 188, 181, 163, 143, +128, 116, 111, 103, 103, 103, 99, 103, +105, 105, 106, 106, 109, 109, 113, 111, +115, 116, 116, 116, 119, 116, 120, 119, +119, 119, 119, 119, 119, 113, 85, 55, + 29, 33, 70, 103, 125, 135, 140, 137, +135, 135, 140, 171, 208, 236, 255, 255, +255, 255, 242, 202, 171, 129, 87, 71, + 67, 55, 41, 48, 77, 113, 120, 125, +139, 144, 135, 103, 71, 43, 24, 15, + 5, 0, 0, 0, 0, 19, 37, 67, +113, 174, 226, 245, 229, 211, 177, 149, +129, 111, 106, 95, 96, 99, 103, 109, +115, 119, 120, 99, 71, 77, 89, 95, +101, 105, 137, 187, 240, 255, 245, 211, +184, 178, 174, 163, 153, 163, 197, 218, +216, 216, 225, 225, 202, 159, 120, 95, + 63, 48, 43, 39, 43, 48, 53, 61, + 67, 71, 79, 85, 89, 91, 92, 87, + 61, 36, 19, 12, 19, 33, 71, 129, +168, 192, 198, 205, 232, 255, 255, 255, +255, 255, 255, 222, 192, 171, 140, 92, + 47, 17, 0, 0, 0, 0, 0, 0, + 23, 63, 99, 111, 109, 92, 75, 75, +103, 154, 192, 202, 188, 178, 171, 154, +163, 178, 198, 211, 184, 139, 81, 27, + 15, 12, 19, 53, 96, 143, 159, 154, +133, 115, 92, 67, 51, 46, 33, 23, + 12, 13, 23, 39, 91, 163, 226, 255, +255, 255, 255, 255, 255, 242, 205, 154, +125, 103, 95, 96, 123, 150, 161, 147, +125, 109, 91, 85, 79, 79, 79, 85, + 85, 91, 96, 101, 105, 109, 113, 115, +123, 120, 123, 128, 130, 119, 96, 58, + 36, 19, 23, 39, 63, 89, 119, 150, +174, 198, 222, 255, 255, 255, 255, 255, +255, 255, 249, 168, 128, 111, 95, 101, +123, 150, 168, 154, 128, 95, 48, 2, + 0, 0, 0, 0, 0, 13, 57, 92, +130, 150, 149, 137, 130, 135, 120, 92, + 72, 53, 41, 33, 36, 33, 22, 17, + 48, 91, 129, 144, 144, 149, 147, 147, +143, 140, 140, 139, 140, 143, 149, 149, +150, 153, 154, 157, 157, 159, 161, 161, +161, 161, 161, 161, 157, 161, 157, 153, +153, 150, 149, 147, 144, 147, 140, 135, +115, 79, 53, 31, 27, 37, 55, 77, +105, 133, 177, 232, 255, 255, 255, 255, +255, 255, 255, 212, 154, 101, 65, 57, + 81, 128, 174, 215, 235, 231, 197, 129, + 58, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 51, 135, 198, 249, 252, 229, +205, 188, 163, 128, 96, 70, 53, 46, + 43, 46, 53, 61, 57, 51, 57, 53, + 51, 53, 57, 79, 125, 181, 221, 229, +225, 211, 211, 226, 255, 255, 255, 255, +246, 208, 164, 130, 116, 125, 133, 133, +137, 150, 168, 168, 153, 135, 115, 105, + 92, 87, 89, 89, 95, 101, 103, 109, +113, 116, 115, 116, 125, 133, 133, 128, +115, 103, 111, 128, 139, 149, 150, 150, +144, 144, 139, 143, 153, 163, 174, 184, +201, 202, 195, 178, 163, 150, 139, 120, +116, 113, 109, 101, 103, 113, 129, 133, +133, 137, 139, 130, 119, 106, 92, 82, + 65, 41, 39, 43, 57, 70, 65, 65, + 82, 111, 140, 168, 173, 163, 161, 159, +181, 188, 188, 191, 192, 187, 164, 137, +106, 91, 87, 87, 81, 82, 103, 111, +101, 96, 95, 103, 123, 139, 140, 130, +115, 101, 106, 116, 128, 154, 195, 240, +255, 255, 249, 242, 235, 211, 164, 119, + 92, 65, 43, 17, 9, 5, 9, 9, + 22, 41, 70, 96, 116, 115, 105, 95, + 81, 71, 71, 65, 63, 72, 85, 105, +144, 164, 187, 198, 208, 231, 252, 252, +239, 235, 236, 222, 195, 181, 168, 153, +116, 82, 57, 41, 27, 13, 0, 9, + 29, 55, 82, 111, 119, 119, 106, 95, + 95, 116, 153, 183, 191, 178, 171, 168, +154, 159, 174, 188, 195, 177, 143, 92, + 51, 41, 37, 41, 63, 96, 130, 149, +144, 135, 128, 113, 91, 79, 70, 57, + 46, 33, 31, 43, 58, 105, 164, 215, +245, 255, 255, 245, 235, 236, 221, 188, +144, 119, 103, 91, 96, 123, 147, 154, +143, 123, 111, 92, 87, 81, 81, 81, + 85, 87, 92, 99, 103, 106, 111, 113, +116, 120, 120, 123, 128, 128, 119, 99, + 61, 39, 23, 27, 41, 63, 91, 119, +149, 174, 197, 222, 255, 255, 255, 255, +255, 255, 255, 249, 168, 128, 111, 95, +101, 123, 150, 168, 154, 128, 95, 48, + 2, 0, 0, 0, 0, 0, 13, 57, + 92, 130, 150, 149, 137, 130, 135, 120, + 92, 72, 53, 41, 33, 36, 33, 22, + 17, 48, 91, 129, 144, 144, 149, 147, +147, 143, 140, 140, 139, 140, 143, 149, +149, 150, 153, 154, 157, 157, 159, 161, +161, 161, 161, 161, 161, 157, 161, 157, +153, 153, 150, 149, 147, 144, 147, 140, +135, 115, 79, 53, 31, 27, 33, 53, + 75, 103, 135, 177, 232, 255, 255, 255, +255, 255, 255, 255, 215, 157, 99, 61, + 55, 79, 129, 178, 218, 240, 239, 201, +125, 53, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 39, 137, 211, 255, 255, +240, 212, 192, 164, 125, 95, 58, 41, + 31, 29, 33, 41, 51, 43, 39, 46, + 37, 37, 39, 43, 70, 125, 195, 250, +255, 255, 235, 226, 240, 255, 255, 255, +255, 255, 232, 177, 135, 120, 130, 140, +140, 149, 164, 188, 191, 167, 143, 116, + 99, 82, 79, 79, 77, 85, 91, 96, +103, 111, 113, 113, 115, 128, 139, 143, +144, 140, 133, 144, 150, 157, 159, 159, +154, 149, 147, 140, 143, 140, 139, 140, +137, 139, 139, 140, 140, 137, 139, 140, +139, 140, 140, 139, 135, 139, 135, 137, +137, 137, 133, 130, 129, 128, 129, 128, +125, 99, 70, 79, 103, 119, 119, 99, + 87, 91, 109, 116, 119, 113, 106, 113, +144, 202, 240, 255, 255, 255, 255, 225, +168, 105, 65, 57, 53, 58, 92, 125, +133, 106, 85, 79, 67, 48, 23, 7, + 0, 0, 7, 22, 43, 82, 154, 225, +255, 255, 255, 255, 255, 246, 221, 168, +119, 95, 67, 29, 0, 0, 0, 0, + 0, 0, 0, 61, 125, 163, 154, 128, + 91, 72, 89, 125, 144, 157, 173, 168, +171, 173, 159, 168, 191, 216, 229, 215, +168, 135, 125, 137, 137, 133, 144, 164, +171, 168, 159, 150, 140, 130, 128, 128, +129, 130, 130, 135, 140, 139, 144, 143, +144, 149, 150, 153, 154, 149, 153, 149, +149, 149, 149, 147, 147, 144, 143, 143, +140, 139, 133, 128, 123, 105, 82, 82, + 96, 106, 135, 173, 197, 201, 201, 184, +168, 159, 139, 130, 140, 164, 178, 174, +153, 129, 109, 91, 79, 70, 65, 67, + 63, 67, 65, 65, 75, 95, 99, 105, +105, 105, 105, 103, 103, 105, 106, 101, +105, 106, 106, 109, 111, 109, 109, 113, +115, 113, 116, 119, 116, 120, 116, 119, +120, 120, 120, 120, 120, 120, 123, 129, +128, 109, 101, 113, 128, 128, 105, 79, + 51, 41, 55, 103, 154, 183, 184, 184, +195, 216, 218, 197, 163, 120, 87, 63, + 51, 51, 58, 85, 140, 208, 255, 255, +255, 255, 255, 226, 164, 95, 47, 24, + 5, 0, 0, 24, 67, 92, 106, 129, +149, 143, 128, 113, 87, 75, 81, 103, +120, 125, 111, 91, 72, 58, 51, 48, + 47, 39, 37, 27, 13, 7, 9, 19, + 43, 65, 116, 173, 222, 250, 255, 255, +250, 255, 255, 255, 255, 255, 255, 255, +255, 255, 255, 192, 135, 75, 13, 0, + 0, 9, 63, 115, 161, 184, 178, 147, +111, 82, 57, 31, 13, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 61, 79, + 95, 105, 125, 161, 195, 231, 255, 255, +250, 225, 192, 164, 143, 129, 135, 171, +226, 255, 255, 255, 255, 249, 192, 123, + 63, 9, 0, 0, 0, 0, 39, 113, +183, 236, 255, 255, 235, 177, 130, 96, + 77, 47, 3, 0, 0, 0, 0, 0, + 0, 0, 61, 153, 205, 212, 192, 183, +195, 215, 236, 252, 235, 201, 173, 157, +135, 91, 53, 39, 37, 31, 27, 24, + 29, 55, 111, 183, 255, 255, 255, 255, +255, 246, 246, 232, 197, 150, 111, 87, + 58, 55, 70, 109, 174, 249, 255, 255, +255, 255, 255, 252, 208, 147, 85, 23, + 0, 0, 0, 24, 72, 128, 171, 181, +168, 164, 163, 164, 167, 157, 120, 65, + 13, 2, 13, 24, 29, 53, 85, 123, +140, 128, 92, 70, 77, 99, 109, 92, + 71, 61, 77, 125, 183, 240, 255, 255, +255, 232, 197, 159, 150, 157, 144, 116, + 91, 95, 123, 157, 197, 226, 235, 218, +178, 149, 130, 113, 103, 91, 87, 81, + 81, 82, 85, 92, 99, 101, 106, 87, + 55, 47, 72, 99, 109, 106, 115, 147, +191, 229, 240, 212, 178, 159, 171, 173, +159, 128, 101, 65, 51, 48, 72, 116, +144, 163, 191, 232, 255, 255, 255, 255, +212, 147, 89, 57, 57, 67, 87, 125, +167, 205, 207, 188, 168, 154, 129, 82, + 27, 0, 0, 0, 13, 70, 120, 159, +171, 154, 119, 87, 43, 19, 24, 37, + 31, 12, 0, 0, 0, 24, 61, 116, +173, 201, 216, 222, 208, 201, 211, 225, +245, 255, 255, 252, 229, 192, 144, 111, + 71, 15, 0, 0, 0, 0, 5, 23, + 72, 143, 215, 255, 255, 255, 246, 235, +236, 255, 255, 231, 181, 128, 79, 47, + 27, 29, 51, 103, 174, 245, 255, 255, +255, 232, 202, 171, 129, 92, 67, 53, + 65, 115, 171, 221, 255, 255, 255, 218, +147, 85, 53, 46, 58, 79, 96, 105, +103, 85, 37, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 51, 77, 105, 157, +}; + +int tankDeath_numberOfSamples = 3006; + +int tankDeath_sampleRate = 8; + diff --git a/ecen427/ufo.c b/ecen427/ufo.c new file mode 100644 index 0000000..0b76500 --- /dev/null +++ b/ecen427/ufo.c @@ -0,0 +1,255 @@ +#include "ufo.h" + +void renderUfo(unsigned int* framePointer) { // draw for the first time + + if(getUfoState()){ + short x=0, y=0; + + for(x = 0; x < UFO_HEIGHT; x++) { + for(y = 0; y < UFO_WIDTH; y++){ + if ((ufo[x%UFO_HEIGHT] & (1<<(UFO_WIDTH-1-y)))) { + framePointer[(getUfoPositionY()+x)*640 + getUfoPositionX()+y] = 0x00FF0000; + } else { + framePointer[(getUfoPositionY()+x)*640 + getUfoPositionX()+y] = 0x00000000; + } + } + } + } + +} + +void moveUfo(unsigned int* framePointer, int ufo_left) { + short ufox, ufoy; + ufox = getUfoPositionX(); + ufoy = getUfoPositionY(); + + if((ufox+UFO_WIDTH) == 639 && !ufo_left) { + setUfoPositionX(ufox); + blankUfo(framePointer, getUfoPositionX(), getUfoPositionY()); + setUfoState(0); + } + if(ufox == 0 && ufo_left) { + setUfoPositionX(ufox); + blankUfo(framePointer, getUfoPositionX(), getUfoPositionY()); + setUfoState(0); + } + if(ufo_left) { + ufox -= 1; + setUfoPositionX(ufox); + } + else { + ufox += 1; + setUfoPositionX(ufox); + } +} + +void blankUfo(unsigned int* framePointer, int ufox, int ufoy){ + setHaveSpaceShipSound(0); + short row=0, col=0; + for(row = 0; row < UFO_HEIGHT; row++){ + for(col = 0; col < UFO_WIDTH; col++){ + framePointer[(ufoy+row)*640+(ufox+col)] = 0x00000000; + } + } +} + +int selectingUfoscore(unsigned int* framePointer, int ufoscore){ + int x_position = getUfoPositionX(); + int y_position = getUfoPositionY(); + int updatingscore = 0; + int counter = 0; + + switch(ufoscore){ + case 0: // 50 + renderUfoscore(framePointer, 5, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + updatingscore = 50; + break; + case 1: // 100 + renderUfoscore(framePointer, 1, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + + updatingscore = 100; + break; + case 2: // 150 + renderUfoscore(framePointer, 1, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 5, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + updatingscore = 150; + break; + case 3: // 200 + renderUfoscore(framePointer, 2, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + updatingscore = 200; + break; + case 4: // 250 + renderUfoscore(framePointer, 2, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 5, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + updatingscore = 250; + break; + case 5: // 300 + renderUfoscore(framePointer, 3, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + updatingscore = 300; + + break; + case 6: // 350 + renderUfoscore(framePointer, 3, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 5, x_position, y_position); + x_position = x_position + 8; + renderUfoscore(framePointer, 0, x_position, y_position); + updatingscore = 350; + + break; + default: + break; + + } + + while(counter < 500000){ + counter++; + } + + blankUfo(framePointer, x_position-16, y_position); + + return updatingscore; +} + +void renderUfoscore(unsigned int* framePointer, int number, int x_position, int y_position){ + + short x=0, y=0; + + switch(number){ + case 0: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_zero_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 1: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_one_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + + break; + case 2: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_two_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 3: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_three_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 4: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_four_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 5: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_five_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 6: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_six_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 7: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_seven_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 8: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_eight_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + case 9: + for(x = 0; x < UFOSCORE_HEIGHT; x++) { + for(y = 0; y < UFOSCORE_WIDTH; y++){ + if ((ufo_nine_block[x%UFOSCORE_HEIGHT] & (1<<(UFOSCORE_WIDTH-1-y)))) { + framePointer[(y_position+x)*640 + x_position+y] = 0x00FF00FF; + } else { + framePointer[(y_position+x)*640 + x_position+y] = 0x00000000; + } + } + } + break; + default: + break; + + } + +} diff --git a/ecen427/ufo.h b/ecen427/ufo.h new file mode 100644 index 0000000..b10e0f1 --- /dev/null +++ b/ecen427/ufo.h @@ -0,0 +1,134 @@ +#ifndef UFO_H_ +#define UFO_H_ + +#define UFO_HEIGHT 16 +#define UFO_WIDTH 30 +#define UFOSCORE_HEIGHT 6 +#define UFOSCORE_WIDTH 6 + +#define packWord6(b5,b4,b3,b2,b1,b0) \ + ((b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 )) + + +#define packWord30(b29,b28,b27,b26,b25,b24,b23,b22,b21,b20,b19,b18,b17,b16,b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0) \ + ((b29 << 29) | (b28 << 28) | (b27 << 27) | (b26 << 26) | (b25 << 25) | (b24 << 24) | \ + (b23 << 23) | (b22 << 22) | (b21 << 21) | (b20 << 20) | (b19 << 19) | (b18 << 18) | (b17 << 17) | (b16 << 16) | \ + (b15 << 15) | (b14 << 14) | (b13 << 13) | (b12 << 12) | (b11 << 11) | (b10 << 10) | (b9 << 9 ) | (b8 << 8 ) | \ + (b7 << 7 ) | (b6 << 6 ) | (b5 << 5 ) | (b4 << 4 ) | (b3 << 3 ) | (b2 << 2 ) | (b1 << 1 ) | (b0 << 0 ) ) + +int ufo[UFO_HEIGHT] = +{ + packWord30(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord30(0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0), + packWord30(0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,1,0,0,0), + packWord30(0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,1,0,0,0), + packWord30(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0), + packWord30(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0), + packWord30(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0), + packWord30(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0), + packWord30(0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0), + packWord30(0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0), + +}; + +int ufo_zero_block[UFOSCORE_HEIGHT] = // 0 block +{ + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), + packWord6(1,1,0,0,1,1), + packWord6(1,1,0,0,1,1), + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), +}; + +int ufo_one_block[UFOSCORE_HEIGHT] = // 1 block +{ + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), + packWord6(0,0,1,1,0,0), +}; +int ufo_two_block[UFOSCORE_HEIGHT] = // 2 block +{ + packWord6(1,1,1,1,1,1), + packWord6(0,0,0,0,0,1), + packWord6(0,0,0,0,0,1), + packWord6(1,1,1,1,1,1), + packWord6(1,0,0,0,0,0), + packWord6(1,1,1,1,1,1), +}; + +int ufo_three_block[UFOSCORE_HEIGHT] = // 3 block +{ + packWord6(1,1,1,1,1,1), + packWord6(0,0,0,0,1,0), + packWord6(0,0,1,1,0,0), + packWord6(0,0,0,0,1,0), + packWord6(0,0,0,0,0,1), + packWord6(1,1,1,1,1,0), +}; +int ufo_four_block[UFOSCORE_HEIGHT] = // 4 block +{ + packWord6(1,0,0,0,0,1), + packWord6(1,0,0,0,0,1), + packWord6(1,0,0,0,0,1), + packWord6(1,1,1,1,1,1), + packWord6(0,0,0,0,0,1), + packWord6(0,0,0,0,0,1), +}; +int ufo_five_block[UFOSCORE_HEIGHT] = // 5 block +{ + packWord6(1,1,1,1,1,1), + packWord6(1,0,0,0,0,0), + packWord6(1,1,1,1,1,1), + packWord6(0,0,0,0,0,1), + packWord6(0,0,0,0,0,1), + packWord6(1,1,1,1,1,1), +}; +int ufo_six_block[UFOSCORE_HEIGHT] = // 6 block +{ + packWord6(1,1,1,1,1,1), + packWord6(1,0,0,0,0,0), + packWord6(1,0,0,0,0,0), + packWord6(1,1,1,1,1,1), + packWord6(1,0,0,0,0,1), + packWord6(1,1,1,1,1,1), +}; +int ufo_seven_block[UFOSCORE_HEIGHT] = // 7 block +{ + packWord6(1,1,1,1,1,1), + packWord6(1,1,1,1,1,1), + packWord6(0,0,0,0,1,1), + packWord6(0,0,0,0,1,1), + packWord6(0,0,0,0,1,1), + packWord6(0,0,0,0,1,1), +}; +int ufo_eight_block[UFOSCORE_HEIGHT] = // 8 block +{ + packWord6(0,0,1,1,0,0), + packWord6(1,1,0,0,1,1), + packWord6(0,0,1,1,0,0), + packWord6(1,1,0,0,1,1), + packWord6(1,1,0,0,1,1), + packWord6(0,0,1,1,0,0), +}; +int ufo_nine_block[UFOSCORE_HEIGHT] = // 9 block +{ + packWord6(0,0,1,1,0,0), + packWord6(1,1,0,0,1,1), + packWord6(1,1,0,0,1,1), + packWord6(0,0,1,1,1,1), + packWord6(0,0,0,0,1,1), + packWord6(1,1,1,1,1,1), +}; + + +#endif /* UFO_H_ */ diff --git a/ecen427/vdma.c b/ecen427/vdma.c new file mode 100644 index 0000000..83ec661 --- /dev/null +++ b/ecen427/vdma.c @@ -0,0 +1,872 @@ +#include +#include "platform.h" +#include "xparameters.h" +#include "xaxivdma.h" +#include "xio.h" +#include "time.h" +#include "unistd.h" +#include "xgpio.h" // Provides access to PB GPIO driver. +#include "mb_interface.h" // provides the microblaze interrupt enables, etc. +#include "xintc_l.h" // Provides handy macros for the interrupt controller. +#include "xac97_l.h" +#include "nes.h" +#include "global.h" +#include + +XGpio gpLED; // This is a handle for the LED GPIO block. +XGpio gpPB; // This is a handle for the push-button GPIO block. + + +#define DEBUG +#define FRAME_BUFFER_0_ADDR 0xC5000000 // Starting location in DDR where we will store the images that we display. +#define VOL_ATTN_MIN 0x0 +#define VOL_ATTN_MAX 0x1f + +Xuint32 vol_attn = 0x10; + +int mytimer = 0; +int mycounter = 0; + +int onesec; +int fifteenms; +int fivems; +int tenms; +int buttonValid; +int currentButtonState; +int speed = 30; + +int holding; + +int gameState = 1; + + +void increaseVolume() { + if((int)vol_attn > VOL_ATTN_MIN) { + vol_attn = vol_attn - 0x1; + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_MasterVol, vol_attn | (vol_attn << 8)); + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_AuxOutVol, vol_attn | (vol_attn << 8)); + } +} +void decreaseVolume() { + if((int)vol_attn < VOL_ATTN_MAX) { + vol_attn = vol_attn + 0x1; + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_MasterVol, vol_attn | (vol_attn << 8)); + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_AuxOutVol, vol_attn | (vol_attn << 8)); + } +} +void delayDying() { + int counter = 0; + while(counter < 500000){ + counter++; + } +} + +void setGameState(int mystate){ + gameState = mystate; +} + +unsigned int * framePointer = (unsigned int *) FRAME_BUFFER_0_ADDR; + +void pb_interrupt_handler(); + +int isBottom(int value) { + short* aliens = getAliens(); + + if(value > 43) { + return 1; + } + if(value < 44 && value > 32) { + if(aliens[value+11] == 0) { + return 1; + } + else { + return 0; + } + } + if(value < 33 && value > 21) { + if(aliens[value+11] == 0 && aliens[value+22] == 0) { + return 1; + } + else { + return 0; + } + } + if(value < 22 && value > 10) { + if(aliens[value+11] == 0 && aliens[value+22] == 0 && aliens[value+33] == 0) { + return 1; + } + else { + return 0; + } + } + if(value < 11) { + if(aliens[value+11] == 0 && aliens[value+22] == 0 && aliens[value+33] == 0 && aliens[value+44] == 0) { + return 1; + } + else { + return 0; + } + } +} + +int whatRow(int position) { + if(position > 43) { + return 120; + } + if(position < 44 && position > 32) { + return 94; + } + if(position < 33 && position > 21) { + return 68; + } + if(position < 22 && position > 10) { + return 42; + } + if(position < 11) { + return 16; + } + +} + +void collisionCleanUp(int x, int y) { + setHaveAlienDeathSound(1); + blankTankBullet(framePointer); + setTankBulletPositionY(0); + setTankBulletState(0); + delayDying(); + dyingAlienHelper(framePointer, x, y); + int guise = getGuise(); + if(guise == 0) { + renderAlien2(framePointer); + } + else { + renderAlien1(framePointer); + } + alienSpeed(); +} + +void alienCollision() { + int curTankY = ((getTankBulletPositionY()-2)*640); + int curTankX = getTankBulletPositionX()+3; + int curAlienX = getAlienBlockPositionX(); + int curAlienY = getAlienBlockPositionY(); + int ufoscore = 0; + int updatescore = 0; + + if(framePointer[((getTankBulletPositionY()-2)*640) + getTankBulletPositionX()+3] == 0x00FF0000) { + setHaveSpaceShipDeathSound(1); + blankUfo(framePointer, getUfoPositionX(), getUfoPositionY()); + setUfoState(0); + blankTankBullet(framePointer); + setTankBulletPositionY(0); + setTankBulletState(0); + // ufo score operation + ufoscore = rand()%7; + updatescore = selectingUfoscore(framePointer, ufoscore); + updateMyscore(updatescore); + updateNumber(framePointer); + } + if(framePointer[((getTankBulletPositionY()-2)*640) + getTankBulletPositionX()+3] == 0x00FFFFFF || \ + framePointer[((getTankBulletPositionY()-2)*640) + getTankBulletPositionX()+5] == 0x00FFFFFF ||\ + framePointer[((getTankBulletPositionY()-2)*640) + getTankBulletPositionX()] == 0x00FFFFFF){ + curTankY = curTankY/640; + if(curAlienX > 1000) { + curAlienX -= 65535; + } + xil_printf("curX: %d\r\n", curAlienX); + if(curAlienY < curTankY && curTankY < curAlienY + 16 ) { + if(curAlienX < curTankX && curTankX < (curAlienX + 32)) { + dyingAlien(framePointer, (getAlienBlockPositionX()), (getAlienBlockPositionY())); + setAliens(0, 0); + collisionCleanUp((getAlienBlockPositionX()), (getAlienBlockPositionY())); + } + if(curAlienX + 32 < curTankX && curTankX < curAlienX + 64) { + dyingAlien(framePointer, (getAlienBlockPositionX()+32), (getAlienBlockPositionY())); + setAliens(0, 1); + collisionCleanUp((getAlienBlockPositionX()+32), (getAlienBlockPositionY())); + } + if(curAlienX + 64 < curTankX && curTankX < curAlienX + 96) { + dyingAlien(framePointer, (getAlienBlockPositionX()+64), (getAlienBlockPositionY())); + setAliens(0, 2); + collisionCleanUp((getAlienBlockPositionX()+64), (getAlienBlockPositionY())); + } + if(curAlienX + 96 < curTankX && curTankX < curAlienX + 128) { + dyingAlien(framePointer, (getAlienBlockPositionX()+96), (getAlienBlockPositionY())); + setAliens(0, 3); + collisionCleanUp((getAlienBlockPositionX()+96), (getAlienBlockPositionY())); + } + if(curAlienX + 128 < curTankX && curTankX < curAlienX + 160) { + dyingAlien(framePointer, (getAlienBlockPositionX()+128), (getAlienBlockPositionY())); + setAliens(0, 4); + collisionCleanUp((getAlienBlockPositionX()+128), (getAlienBlockPositionY())); + } + if(curAlienX + 160 < curTankX && curTankX < curAlienX + 192) { + dyingAlien(framePointer, (getAlienBlockPositionX()+160), (getAlienBlockPositionY())); + setAliens(0, 5); + collisionCleanUp((getAlienBlockPositionX()+160), (getAlienBlockPositionY())); + } + if(curAlienX + 192 < curTankX && curTankX < curAlienX + 224) { + dyingAlien(framePointer, (getAlienBlockPositionX()+192), (getAlienBlockPositionY())); + setAliens(0, 6); + collisionCleanUp((getAlienBlockPositionX()+192), (getAlienBlockPositionY())); + } + if(curAlienX + 224 < curTankX && curTankX < curAlienX + 256) { + dyingAlien(framePointer, (getAlienBlockPositionX()+ 224), (getAlienBlockPositionY())); + setAliens(0, 7); + collisionCleanUp((getAlienBlockPositionX()+ 224), (getAlienBlockPositionY())); + } + if(curAlienX + 256 < curTankX && curTankX < curAlienX + 288) { + dyingAlien(framePointer, (getAlienBlockPositionX()+ 256), (getAlienBlockPositionY())); + setAliens(0, 8); + collisionCleanUp((getAlienBlockPositionX()+256), (getAlienBlockPositionY())); + } + if(curAlienX + 288 < curTankX && curTankX < curAlienX + 320) { + dyingAlien(framePointer, (getAlienBlockPositionX()+288), (getAlienBlockPositionY())); + setAliens(0, 9); + collisionCleanUp((getAlienBlockPositionX()+288), (getAlienBlockPositionY())); + } + if(curAlienX + 320 < curTankX && curTankX < curAlienX + 352) { + dyingAlien(framePointer, (getAlienBlockPositionX()+320), (getAlienBlockPositionY())); + setAliens(0, 10); + collisionCleanUp((getAlienBlockPositionX()+320), (getAlienBlockPositionY())); + } + updateMyscore(40); + updateNumber(framePointer); + + } + if(curAlienY + 26 < curTankY && curTankY < curAlienY + 42) { + if(curAlienX < curTankX && curTankX < (curAlienX + 32)) { + dyingAlien(framePointer, (getAlienBlockPositionX()), (getAlienBlockPositionY()+26)); + setAliens(0, 11); + collisionCleanUp((getAlienBlockPositionX()), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 32 < curTankX && curTankX < curAlienX + 64) { + dyingAlien(framePointer, (getAlienBlockPositionX()+32), (getAlienBlockPositionY()+26)); + setAliens(0, 12); + collisionCleanUp((getAlienBlockPositionX()+32), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 64 < curTankX && curTankX < curAlienX + 96) { + dyingAlien(framePointer, (getAlienBlockPositionX()+64), (getAlienBlockPositionY()+26)); + setAliens(0, 13); + collisionCleanUp((getAlienBlockPositionX()+64), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 96 < curTankX && curTankX < curAlienX + 128) { + dyingAlien(framePointer, (getAlienBlockPositionX()+96), (getAlienBlockPositionY()+26)); + setAliens(0, 14); + collisionCleanUp((getAlienBlockPositionX()+96), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 128 < curTankX && curTankX < curAlienX + 160) { + dyingAlien(framePointer, (getAlienBlockPositionX()+128), (getAlienBlockPositionY()+26)); + setAliens(0, 15); + collisionCleanUp((getAlienBlockPositionX()+128), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 160 < curTankX && curTankX < curAlienX + 192) { + dyingAlien(framePointer, (getAlienBlockPositionX()+160), (getAlienBlockPositionY()+26)); + setAliens(0, 16); + collisionCleanUp((getAlienBlockPositionX()+160), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 192 < curTankX && curTankX < curAlienX + 224) { + dyingAlien(framePointer, (getAlienBlockPositionX()+192), (getAlienBlockPositionY()+26)); + setAliens(0, 17); + collisionCleanUp((getAlienBlockPositionX()+192), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 224 < curTankX && curTankX < curAlienX + 256) { + dyingAlien(framePointer, (getAlienBlockPositionX()+224), (getAlienBlockPositionY()+26)); + setAliens(0, 18); + collisionCleanUp((getAlienBlockPositionX()+224), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 256 < curTankX && curTankX < curAlienX + 288) { + dyingAlien(framePointer, (getAlienBlockPositionX()+256), (getAlienBlockPositionY()+26)); + setAliens(0, 19); + collisionCleanUp((getAlienBlockPositionX()+256), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 288 < curTankX && curTankX < curAlienX + 320) { + dyingAlien(framePointer, (getAlienBlockPositionX()+288), (getAlienBlockPositionY()+26)); + setAliens(0, 20); + collisionCleanUp((getAlienBlockPositionX()+288), (getAlienBlockPositionY()+26)); + } + if(curAlienX + 320 < curTankX && curTankX < curAlienX + 352) { + dyingAlien(framePointer, (getAlienBlockPositionX()+320), (getAlienBlockPositionY()+26)); + setAliens(0, 21); + collisionCleanUp((getAlienBlockPositionX()+320), (getAlienBlockPositionY()+26)); + } + updateMyscore(20); + updateNumber(framePointer); + } + if(curAlienY + 52 < curTankY && curTankY < curAlienY + 68) { + if(curAlienX < curTankX && curTankX < (curAlienX + 32)) { + dyingAlien(framePointer, (getAlienBlockPositionX()), (getAlienBlockPositionY()+52)); + setAliens(0, 22); + collisionCleanUp((getAlienBlockPositionX()), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 32 < curTankX && curTankX < curAlienX + 64) { + dyingAlien(framePointer, (getAlienBlockPositionX()+32), (getAlienBlockPositionY()+52)); + setAliens(0, 23); + collisionCleanUp((getAlienBlockPositionX()+32), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 64 < curTankX && curTankX < curAlienX + 96) { + dyingAlien(framePointer, (getAlienBlockPositionX()+64), (getAlienBlockPositionY()+52)); + setAliens(0, 24); + collisionCleanUp((getAlienBlockPositionX()+64), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 96 < curTankX && curTankX < curAlienX + 128) { + dyingAlien(framePointer, (getAlienBlockPositionX()+96), (getAlienBlockPositionY()+52)); + setAliens(0, 25); + collisionCleanUp((getAlienBlockPositionX()+96), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 128 < curTankX && curTankX < curAlienX + 160) { + dyingAlien(framePointer, (getAlienBlockPositionX()+128), (getAlienBlockPositionY()+52)); + setAliens(0, 26); + collisionCleanUp((getAlienBlockPositionX()+128), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 160 < curTankX && curTankX < curAlienX + 192) { + dyingAlien(framePointer, (getAlienBlockPositionX()+160), (getAlienBlockPositionY()+52)); + setAliens(0, 27); + collisionCleanUp((getAlienBlockPositionX()+160), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 192 < curTankX && curTankX < curAlienX + 224) { + dyingAlien(framePointer, (getAlienBlockPositionX()+192), (getAlienBlockPositionY()+52)); + setAliens(0, 28); + collisionCleanUp((getAlienBlockPositionX()+192), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 224 < curTankX && curTankX < curAlienX + 256) { + dyingAlien(framePointer, (getAlienBlockPositionX()+224), (getAlienBlockPositionY()+52)); + setAliens(0, 29); + collisionCleanUp((getAlienBlockPositionX()+224), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 256 < curTankX && curTankX < curAlienX + 288) { + dyingAlien(framePointer, (getAlienBlockPositionX()+256), (getAlienBlockPositionY()+52)); + setAliens(0, 30); + collisionCleanUp((getAlienBlockPositionX()+256), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 288 < curTankX && curTankX < curAlienX + 320) { + dyingAlien(framePointer, (getAlienBlockPositionX()+288), (getAlienBlockPositionY()+52)); + setAliens(0, 31); + collisionCleanUp((getAlienBlockPositionX()+288), (getAlienBlockPositionY()+52)); + } + if(curAlienX + 320 < curTankX && curTankX < curAlienX + 352) { + dyingAlien(framePointer, (getAlienBlockPositionX()+320), (getAlienBlockPositionY()+52)); + setAliens(0, 32); + collisionCleanUp((getAlienBlockPositionX()+320), (getAlienBlockPositionY()+52)); + } + updateMyscore(20); + updateNumber(framePointer); + } + if(curAlienY + 78 < curTankY && curTankY < curAlienY + 94) { + if(curAlienX < curTankX && curTankX < (curAlienX + 32)) { + dyingAlien(framePointer, (getAlienBlockPositionX()), (getAlienBlockPositionY()+78)); + setAliens(0, 33); + collisionCleanUp((getAlienBlockPositionX()), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 32 < curTankX && curTankX < curAlienX + 64) { + dyingAlien(framePointer, (getAlienBlockPositionX()+32), (getAlienBlockPositionY()+78)); + setAliens(0, 34); + collisionCleanUp((getAlienBlockPositionX()+32), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 64 < curTankX && curTankX < curAlienX + 96) { + dyingAlien(framePointer, (getAlienBlockPositionX()+64), (getAlienBlockPositionY()+78)); + setAliens(0, 35); + collisionCleanUp((getAlienBlockPositionX()+64), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 96 < curTankX && curTankX < curAlienX + 128) { + dyingAlien(framePointer, (getAlienBlockPositionX()+96), (getAlienBlockPositionY()+78)); + setAliens(0, 36); + collisionCleanUp((getAlienBlockPositionX()+96), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 128 < curTankX && curTankX < curAlienX + 160) { + dyingAlien(framePointer, (getAlienBlockPositionX()+128), (getAlienBlockPositionY()+78)); + setAliens(0, 37); + collisionCleanUp((getAlienBlockPositionX()+128), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 160 < curTankX && curTankX < curAlienX + 192) { + dyingAlien(framePointer, (getAlienBlockPositionX()+160), (getAlienBlockPositionY()+78)); + setAliens(0, 38); + collisionCleanUp((getAlienBlockPositionX()+160), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 192 < curTankX && curTankX < curAlienX + 224) { + dyingAlien(framePointer, (getAlienBlockPositionX()+192), (getAlienBlockPositionY()+78)); + setAliens(0, 39); + collisionCleanUp((getAlienBlockPositionX()+192), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 224 < curTankX && curTankX < curAlienX + 256) { + dyingAlien(framePointer, (getAlienBlockPositionX()+224), (getAlienBlockPositionY()+78)); + setAliens(0, 40); + collisionCleanUp((getAlienBlockPositionX()+224), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 256 < curTankX && curTankX < curAlienX + 288) { + dyingAlien(framePointer, (getAlienBlockPositionX()+256), (getAlienBlockPositionY()+78)); + setAliens(0, 41); + collisionCleanUp((getAlienBlockPositionX()+256), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 288 < curTankX && curTankX < curAlienX + 320) { + dyingAlien(framePointer, (getAlienBlockPositionX()+288), (getAlienBlockPositionY()+78)); + setAliens(0, 42); + collisionCleanUp((getAlienBlockPositionX()+288), (getAlienBlockPositionY()+78)); + } + if(curAlienX + 320 < curTankX && curTankX < curAlienX + 352) { + dyingAlien(framePointer, (getAlienBlockPositionX()+320), (getAlienBlockPositionY()+78)); + setAliens(0, 43); + collisionCleanUp((getAlienBlockPositionX()+320), (getAlienBlockPositionY()+78)); + } + updateMyscore(10); + updateNumber(framePointer); + } + if(curAlienY + 104 < curTankY && curTankY < curAlienY +120){ + if(curAlienX < curTankX && curTankX < (curAlienX + 32)) { + dyingAlien(framePointer, (getAlienBlockPositionX()), (getAlienBlockPositionY()+104)); + setAliens(0, 44); + collisionCleanUp((getAlienBlockPositionX()), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 32 < curTankX && curTankX < curAlienX + 64) { + dyingAlien(framePointer, (getAlienBlockPositionX()+32), (getAlienBlockPositionY()+104)); + setAliens(0,45); + collisionCleanUp((getAlienBlockPositionX()+32), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 64 < curTankX && curTankX < curAlienX + 96) { + dyingAlien(framePointer, (getAlienBlockPositionX()+64), (getAlienBlockPositionY()+104)); + setAliens(0, 46); + collisionCleanUp((getAlienBlockPositionX()+64), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 96 < curTankX && curTankX < curAlienX + 128) { + dyingAlien(framePointer, (getAlienBlockPositionX()+96), (getAlienBlockPositionY()+104)); + setAliens(0, 47); + collisionCleanUp((getAlienBlockPositionX()+96), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 128 < curTankX && curTankX < curAlienX + 160) { + dyingAlien(framePointer, (getAlienBlockPositionX()+128), (getAlienBlockPositionY()+104)); + setAliens(0, 48); + collisionCleanUp((getAlienBlockPositionX()+128), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 160 < curTankX && curTankX < curAlienX + 192) { + dyingAlien(framePointer, (getAlienBlockPositionX()+160), (getAlienBlockPositionY()+104)); + setAliens(0, 49); + collisionCleanUp((getAlienBlockPositionX()+160), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 192 < curTankX && curTankX < curAlienX + 224) { + dyingAlien(framePointer, (getAlienBlockPositionX()+192), (getAlienBlockPositionY()+104)); + setAliens(0, 50); + collisionCleanUp((getAlienBlockPositionX()+192), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 224 < curTankX && curTankX < curAlienX + 256) { + dyingAlien(framePointer, (getAlienBlockPositionX()+224), (getAlienBlockPositionY()+104)); + setAliens(0, 51); + collisionCleanUp((getAlienBlockPositionX()+224), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 256 < curTankX && curTankX < curAlienX + 288) { + dyingAlien(framePointer, (getAlienBlockPositionX()+256), (getAlienBlockPositionY()+104)); + setAliens(0, 52); + collisionCleanUp((getAlienBlockPositionX()+256), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 288 < curTankX && curTankX < curAlienX + 320) { + dyingAlien(framePointer, (getAlienBlockPositionX()+288), (getAlienBlockPositionY()+104)); + setAliens(0, 53); + collisionCleanUp((getAlienBlockPositionX()+288), (getAlienBlockPositionY()+104)); + } + if(curAlienX + 320 < curTankX && curTankX < curAlienX + 352) { + dyingAlien(framePointer, (getAlienBlockPositionX()+320), (getAlienBlockPositionY()+104)); + setAliens(0, 54); + collisionCleanUp((getAlienBlockPositionX()+320), (getAlienBlockPositionY()+104)); + } + updateMyscore(10); + updateNumber(framePointer); + } + } +} + +void alienSpeed() { + short* aliens = getAliens(); + int i; + int total = 0; + for(i = 0; i < 55; i++) { + if(aliens[i] == 1) { + total++; + } + } + if(total < 55) { + speed = 30; + } + if(total < 44) { + speed = 28; + } + if(total < 33) { + speed = 26; + } + if(total < 22) { + speed = 24; + } + if(total < 11) { + speed = 20; + } + if(total == 0) { + gameOver(framePointer); + } +} + +void timer_interrupt_handler() { + onesec++; + fifteenms++; + fivems++; + tenms++; + mytimer++; + + if(mytimer == 5000){ + mytimer = 0; + xil_printf("my counter value: %d\r\n", mycounter); + } + + if(onesec == 100) { + onesec = 0; + } + if(fifteenms == speed) { + fifteenms = 0; + incrementAlienSoundCadence(); + moveAlien(framePointer); + renderAlien(framePointer); + if(getAlienBlockPositionY() > 240){ + int col; + for(col=0; col<640; col++) { + if(framePointer[360*640 + col] == 0x00FFFFFF) { + gameOver(framePointer); + } + + } + } + + } + if(tenms == 2){ + tenms = 0; + if(getUfoState() == 1){ + moveUfo(framePointer, getUfoDirection()); + renderUfo(framePointer); + + } + + } + if(fivems == 1) { + fivems = 0; + if(getTankBulletState() == 1 || getAlien1BulletState() == 1 || getAlien2BulletState() == 1 || \ + getAlien3BulletState() == 1 || getAlien4BulletState() == 1) { + int i; + for(i = 0; i < 3; i++) { + moveBullets(framePointer); + renderBullet(framePointer); + } + if(getAlien1BulletState()){ + selectBlock(framePointer, 1); + } + if(getAlien2BulletState()){ + selectBlock(framePointer, 2); + } + if(getAlien3BulletState()){ + selectBlock(framePointer, 3); + } + if(getAlien4BulletState()){ + selectBlock(framePointer, 4); + } + if(getTankBulletState()){ + selectBlock(framePointer, 5); + } + } + } +} + +// This is invoked each time there is a change in the button state (result of a push or a bounce). +void pb_interrupt_handler() { + // Clear the GPIO interrupt. + XGpio_InterruptGlobalDisable(&gpPB); // Turn off all PB interrupts for now. + currentButtonState = XGpio_DiscreteRead(&gpPB, 1); // Get the current state of the buttons. + if(currentButtonState == 16) { + increaseVolume(); + } + if(currentButtonState == 4) { + decreaseVolume(); + } + XGpio_InterruptClear(&gpPB, 0xFFFFFFFF); // Ack the PB interrupt. + XGpio_InterruptGlobalEnable(&gpPB); // Re-enable PB interrupts. +} + +// Main interrupt handler +void interrupt_handler_dispatcher(void* ptr) { + int intc_status = XIntc_GetIntrStatus(XPAR_INTC_0_BASEADDR); + + // Check the AC97. Just one method - no need for a separate handler + if (intc_status & XPAR_AXI_AC97_0_INTERRUPT_MASK) { + XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_AXI_AC97_0_INTERRUPT_MASK); + fillSound(); + } + // Check the FIT interrupt first. + if (intc_status & XPAR_FIT_TIMER_0_INTERRUPT_MASK){ + XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_FIT_TIMER_0_INTERRUPT_MASK); + timer_interrupt_handler(); + } + // Check the push buttons. + if (intc_status & XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK){ + XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK); + pb_interrupt_handler(); + } +} + +int main() { + init_platform(); // Necessary for all programs. + // Initialize the GPIO peripherals. + XAC97_HardReset(XPAR_AXI_AC97_0_BASEADDR); //Reset XAC97 + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_MasterVol, AC97_VOL_ATTN_23_5_DB); // Set default volume + + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR, AC97_ExtendedAudioStat, 1); + XAC97_WriteReg(XPAR_AXI_AC97_0_BASEADDR,AC97_PCM_DAC_Rate,AC97_PCM_RATE_11025_HZ); + + XAC97_mSetControl(XPAR_AXI_AC97_0_BASEADDR, AC97_ENABLE_IN_FIFO_INTERRUPT); //Enable AC97 Interrupts + + //interrupt code from clock lab + int success; + success = XGpio_Initialize(&gpPB, XPAR_PUSH_BUTTONS_5BITS_DEVICE_ID); + // Set the push button peripheral to be inputs. + XGpio_SetDataDirection(&gpPB, 1, 0x0000001F); + // Enable the global GPIO interrupt for push buttons. + XGpio_InterruptGlobalEnable(&gpPB); + // Enable all interrupts in the push button peripheral. + XGpio_InterruptEnable(&gpPB, 0xFFFFFFFF); + + microblaze_register_handler(interrupt_handler_dispatcher, NULL); + XIntc_EnableIntr(XPAR_INTC_0_BASEADDR, + (XPAR_FIT_TIMER_0_INTERRUPT_MASK | XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK |XPAR_AXI_AC97_0_INTERRUPT_MASK )); + XIntc_MasterEnable(XPAR_INTC_0_BASEADDR); + microblaze_enable_interrupts(); + //end of interrupt code from clock lab + + + int Status; // Keep track of success/failure of system function calls. + XAxiVdma videoDMAController; + // There are 3 steps to initializing the vdma driver and IP. + // Step 1: lookup the memory structure that is used to access the vdma driver. + XAxiVdma_Config * VideoDMAConfig = XAxiVdma_LookupConfig(XPAR_AXI_VDMA_0_DEVICE_ID); + // Step 2: Initialize the memory structure and the hardware. + if(XST_FAILURE == XAxiVdma_CfgInitialize(&videoDMAController, VideoDMAConfig, XPAR_AXI_VDMA_0_BASEADDR)) { + xil_printf("VideoDMA Did not initialize.\r\n"); + } + // Step 3: (optional) set the frame store number. + if(XST_FAILURE == XAxiVdma_SetFrmStore(&videoDMAController, 2, XAXIVDMA_READ)) { + xil_printf("Set Frame Store Failed."); + } + // Initialization is complete at this point. + + // Setup the frame counter. We want two read frames. We don't need any write frames but the + // function generates an error if you set the write frame count to 0. We set it to 2 + // but ignore it because we don't need a write channel at all. + XAxiVdma_FrameCounter myFrameConfig; + myFrameConfig.ReadFrameCount = 2; + myFrameConfig.ReadDelayTimerCount = 10; + myFrameConfig.WriteFrameCount =2; + myFrameConfig.WriteDelayTimerCount = 10; + Status = XAxiVdma_SetFrameCounter(&videoDMAController, &myFrameConfig); + if (Status != XST_SUCCESS) { + xil_printf("Set frame counter failed %d\r\n", Status); + if(Status == XST_VDMA_MISMATCH_ERROR) + xil_printf("DMA Mismatch Error\r\n"); + } + // Now we tell the driver about the geometry of our frame buffer and a few other things. + // Our image is 480 x 640. + XAxiVdma_DmaSetup myFrameBuffer; + myFrameBuffer.VertSizeInput = 480; // 480 vertical pixels. + myFrameBuffer.HoriSizeInput = 640*4; // 640 horizontal (32-bit pixels). + myFrameBuffer.Stride = 640*4; // Dont' worry about the rest of the values. + myFrameBuffer.FrameDelay = 0; + myFrameBuffer.EnableCircularBuf=1; + myFrameBuffer.EnableSync = 0; + myFrameBuffer.PointNum = 0; + myFrameBuffer.EnableFrameCounter = 0; + myFrameBuffer.FixedFrameStoreAddr = 0; + if(XST_FAILURE == XAxiVdma_DmaConfig(&videoDMAController, XAXIVDMA_READ, &myFrameBuffer)) { + xil_printf("DMA Config Failed\r\n"); + } + // We need to give the frame buffer pointers to the memory that it will use. This memory + // is where you will write your video data. The vdma IP/driver then streams it to the HDMI + // IP. + myFrameBuffer.FrameStoreStartAddr[0] = FRAME_BUFFER_0_ADDR; + + if(XST_FAILURE == XAxiVdma_DmaSetBufferAddr(&videoDMAController, XAXIVDMA_READ, + myFrameBuffer.FrameStoreStartAddr)) { + xil_printf("DMA Set Address Failed Failed\r\n"); + } + // Print a sanity message if you get this far. + xil_printf("Woohoo! I made it through initialization.\n\r"); + // Now, let's get ready to start displaying some stuff on the screen. + // The variables framePointer and framePointer1 are just pointers to the base address + // of frame 0 and frame 1. + //unsigned int * framePointer = (unsigned int *) FRAME_BUFFER_0_ADDR; + int row = 0; + int col = 0; + for(row=0; row<480; row++) { + for(col=0; col<640; col++) { + if(row > 460 && row < 464) { + framePointer[row*640 + col] = 0x0000FF00; + } + else { + framePointer[row*640 + col] = 0x00000000; + } + } + } + + // This tells the HDMI controller the resolution of your display (there must be a better way to do this). + XIo_Out32(XPAR_AXI_HDMI_0_BASEADDR, 640*480); + + // Start the DMA for the read channel only. + if(XST_FAILURE == XAxiVdma_DmaStart(&videoDMAController, XAXIVDMA_READ)){ + xil_printf("DMA START FAILED\r\n"); + } + int frameIndex = 0; + // We have two frames, let's park on frame 0. Use frameIndex to index them. + // Note that you have to start the DMA process before parking on a frame. + if (XST_FAILURE == XAxiVdma_StartParking(&videoDMAController, frameIndex, XAXIVDMA_READ)) { + xil_printf("vdma parking failed\n\r"); + } + + setAlienBlockPosition(0, 120); + setTankPosition(300, 420); + renderTank(framePointer); + renderAlien(framePointer); + renderBunker(framePointer); + renderScore(framePointer); + renderNumber(framePointer); + renderTanks(framePointer); + alienSpeed(); + + while (gameState) { + + mycounter++; + + alienCollision(); + int nesButtonState = NES_mReadReg(XPAR_NES_0_BASEADDR, 0); + if(nesButtonState == 2) { + xil_printf("we are in left\r\n"); + moveTankL(framePointer); + renderTank(framePointer); + } + if(nesButtonState == 1) { + xil_printf("we are in right\r\n"); + moveTankR(framePointer); + renderTank(framePointer); + } + if(nesButtonState == 4) { + xil_printf("we are in mid\r\n"); + if(getTankBulletState() == 1) { + continue; + } + else { + setHaveTankBulletSound(1); + setTankBulletState(1); + initialTankBulletPosition(); + renderBullet(framePointer); + } + } + if(nesButtonState == 6) { + xil_printf("we are in mid\r\n"); + moveTankL(framePointer); + renderTank(framePointer); + if(getTankBulletState() == 1) { + continue; + } + else { + setHaveTankBulletSound(1); + setTankBulletState(1); + initialTankBulletPosition(); + renderBullet(framePointer); + } + } + if(nesButtonState == 5) { + xil_printf("we are in mid\r\n"); + moveTankR(framePointer); + renderTank(framePointer); + if(getTankBulletState() == 1) { + continue; + } + else { + setHaveTankBulletSound(1); + setTankBulletState(1); + initialTankBulletPosition(); + renderBullet(framePointer); + } + } + + int ufo_show = rand() % 3000; + if(ufo_show == 100){ + if(getUfoState() == 0){ + setHaveSpaceShipSound(1); + setUfoState(1); + setUfoDirection(); + if(getUfoDirection()){ // getUfoDirection = 1 means ufo going left + setUfoPositionX(610); + setUfoPositionY(45); + renderUfo(framePointer); + } + else{ // getUfoDirection = 0 means ufo going right + setUfoPositionX(0); + setUfoPositionY(45); + renderUfo(framePointer); + } + } + } + + int alienShot = rand() % 100000; // this controls how frequent bullets are fired by aliens + if(alienShot == 50) { //key 3 + int i = 0; + int j = rand() % 4; + int k[4] = {getAlien1BulletState(), getAlien2BulletState(), getAlien3BulletState(), getAlien4BulletState()}; + for(i = 0; i < 16; i ++) { + if(k[j] == 0) { + break; + } + else { + j = rand()%4; + } + } + int bottomAlien = 0; + short* aliens = getAliens(); + int a; + while(bottomAlien == 0) { + a = rand () % 54; + if(aliens[a] == 1 && isBottom(a)) { + bottomAlien = 1; + } + } + int position = whatRow(a); + int x = a % 11; + + switch(j){ + case 0: + if(getAlien1BulletState() == 0) { + setAlien1BulletState(1); + setAlien1BulletPosition(((getAlienBlockPositionX()+10) + 32 * x), getAlienBlockPositionY()+position); + renderBullet(framePointer); + } + break; + case 1: + if(getAlien2BulletState() == 0) { + setAlien2BulletState(1); + setAlien2BulletPosition(((getAlienBlockPositionX()+10) + 32 * x), getAlienBlockPositionY()+position); + renderBullet(framePointer); + } + break; + case 2: + if(getAlien3BulletState() == 0) { + setAlien3BulletState(1); + setAlien3BulletPosition(((getAlienBlockPositionX()+10) + 32 * x), getAlienBlockPositionY()+position); + renderBullet(framePointer); + } + break; + case 3: + if(getAlien4BulletState() == 0) { + setAlien4BulletState(1); + setAlien4BulletPosition(((getAlienBlockPositionX()+10) + 32 * x), getAlienBlockPositionY()+position); + renderBullet(framePointer); + } + break; + default : + break; + } + } + } + cleanup_platform(); + + return 0; +} diff --git a/ecen427/xac97_l.c b/ecen427/xac97_l.c new file mode 100644 index 0000000..34a7f85 --- /dev/null +++ b/ecen427/xac97_l.c @@ -0,0 +1,180 @@ +/*********************************************************************** + * Records a buffer of sound from either the Line-In or Mic-In ports + * to the AC97 controller and plays it back through the Line-Out port + * using the AC97. + ***********************************************************************/ +#include +#include +#include "xac97_l.h" + +void XAC97_WriteReg(Xuint32 baseaddr, Xuint32 reg_addr, Xuint32 value) { + XAC97_mSetAC97RegisterData(baseaddr, value); + XAC97_mSetAC97RegisterAccessCommand(baseaddr, reg_addr); + while (!XAC97_isRegisterAccessFinished(baseaddr)); +} + +Xuint32 XAC97_ReadReg(Xuint32 baseaddr, Xuint32 reg_addr) { + XAC97_mSetAC97RegisterAccessCommand(baseaddr, reg_addr | 0x80); + while (!XAC97_isRegisterAccessFinished(baseaddr)); + return XAC97_mGetAC97RegisterData(baseaddr); +} + +void XAC97_AwaitCodecReady(Xuint32 baseaddr) { + while(!XAC97_isCodecReady(baseaddr)); +} + + +void XAC97_Delay(Xuint32 value) { + volatile int i = value; + while(i-- > 0); +} + + +void XAC97_SoftReset(Xuint32 BaseAddress) { + XAC97_WriteReg(BaseAddress, AC97_Reset, 0x0000); + + /** Set default output volumes **/ + XAC97_WriteReg(BaseAddress, AC97_MasterVol, AC97_VOL_MID); + XAC97_WriteReg(BaseAddress, AC97_AuxOutVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_MasterVolMono, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_PCMOutVol, AC97_VOL_MAX); + + /** Clear the fifos **/ + XAC97_ClearFifos(BaseAddress); +} + + +void XAC97_HardReset(Xuint32 BaseAddress) { + XAC97_mSetControl(BaseAddress, AC97_ENABLE_RESET_AC97); + XAC97_Delay(100000); + XAC97_mSetControl(BaseAddress, AC97_DISABLE_RESET_AC97); + XAC97_Delay(100000); + XAC97_SoftReset(BaseAddress); +} + + +void XAC97_InitAudio(Xuint32 BaseAddress, Xuint8 Loopback) { + Xuint8 i; + + /** Reset audio codec **/ + XAC97_SoftReset(BaseAddress); + + /** Wait until we receive the ready signal **/ + XAC97_AwaitCodecReady(BaseAddress); + + if( Loopback == AC97_ANALOG_LOOPBACK ) { + XAC97_WriteReg(BaseAddress, AC97_MicVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_LineInVol, AC97_VOL_MAX); + } + else if( Loopback == AC97_DIGITAL_LOOPBACK ) + XAC97_WriteReg(BaseAddress, AC97_GeneralPurpose, AC97_GP_ADC_DAC_LOOPBACK); + +} // end XAC97_InitAudio() + + +void XAC97_EnableInput(Xuint32 BaseAddress, Xuint8 InputType) { + XAC97_WriteReg(BaseAddress, AC97_RecordGain, AC97_VOL_MAX); + + if( InputType == AC97_MIC_INPUT ) + XAC97_WriteReg(BaseAddress, AC97_RecordSelect, AC97_RECORD_MIC_IN); + else if( InputType == AC97_LINE_INPUT ) + XAC97_WriteReg(BaseAddress, AC97_RecordSelect, AC97_RECORD_LINE_IN); +} + + +void XAC97_DisableInput(Xuint32 BaseAddress, Xuint8 InputType) { + XAC97_WriteReg(BaseAddress, AC97_RecordGain, AC97_VOL_MUTE); + + if( InputType == AC97_MIC_INPUT ) + XAC97_WriteReg(BaseAddress, AC97_MicVol, AC97_VOL_MUTE); + else if( InputType == AC97_LINE_INPUT ) + XAC97_WriteReg(BaseAddress, AC97_LineInVol, AC97_VOL_MUTE); +} + + +void XAC97_RecAudio(Xuint32 BaseAddress, Xuint32 StartAddress, + Xuint32 EndAddress) { + Xuint32 i; + Xuint32 sample; + volatile Xuint32 *sound_ptr = (Xuint32*)StartAddress; + + /** Enable VRA Mode **/ + XAC97_WriteReg(BaseAddress, AC97_ExtendedAudioStat, 1); + + /** Clear out the FIFOs **/ + XAC97_ClearFifos(BaseAddress); + + /** Wait until we receive the ready signal **/ + XAC97_AwaitCodecReady(BaseAddress); + + /** Volume settings **/ + XAC97_WriteReg(BaseAddress, AC97_MasterVol, AC97_VOL_MUTE); + XAC97_WriteReg(BaseAddress, AC97_AuxOutVol, AC97_VOL_MUTE); + XAC97_WriteReg(BaseAddress, AC97_MasterVolMono, AC97_VOL_MUTE); + XAC97_WriteReg(BaseAddress, AC97_PCBeepVol, AC97_VOL_MUTE); + XAC97_WriteReg(BaseAddress, AC97_PCMOutVol, AC97_VOL_MUTE); + + XAC97_WriteReg(BaseAddress, AC97_GeneralPurpose, AC97_GP_PCM_BYPASS_3D); + + /** Record the incoming audio **/ + while( sound_ptr < (Xuint32*)EndAddress ) { + sample = XAC97_ReadFifo(BaseAddress); + *sound_ptr = sample; + sound_ptr++; + } + +} // end XAC97_RecAudio() + + + +void XAC97_PlayAudio(Xuint32 BaseAddress, Xuint32 StartAddress, + Xuint32 EndAddress){ + Xuint32 i; + Xuint32 sample; + volatile Xuint32 *sound_ptr = (Xuint32*)StartAddress; + + /** Wait for the ready signal **/ + XAC97_AwaitCodecReady(BaseAddress); + + /** Disable VRA Mode **/ + XAC97_WriteReg(BaseAddress, AC97_ExtendedAudioStat, 0); + + /** Play Volume Settings **/ + XAC97_WriteReg(BaseAddress, AC97_MasterVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_AuxOutVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_MasterVolMono, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_PCBeepVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_PCMOutVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_LineInVol, AC97_VOL_MAX); + XAC97_WriteReg(BaseAddress, AC97_MicVol, AC97_VOL_MAX); + + /** Clear FIFOs **/ + XAC97_ClearFifos(BaseAddress); + + while( sound_ptr < (Xuint32*)EndAddress ) { + sample = *sound_ptr; + sound_ptr = sound_ptr + 1; + XAC97_WriteFifo(BaseAddress, sample); + } + + XAC97_ClearFifos(BaseAddress); + +} // end XAC97_PlayAudio() + + +Xuint32 XAC97_ReadFifo(Xuint32 BaseAddress) { + while(XAC97_isOutFIFOEmpty(BaseAddress)); + return XAC97_mGetOutFifoData(BaseAddress); +} + +void XAC97_WriteFifo(Xuint32 BaseAddress, Xuint32 sample) { + while(XAC97_isInFIFOFull(BaseAddress)); + XAC97_mSetInFifoData(BaseAddress, sample); +} + +void XAC97_ClearFifos(Xuint32 BaseAddress) { + Xuint32 i; + XAC97_mSetControl(BaseAddress, AC97_CLEAR_FIFOS); + for( i = 0; i < 512; i++ ) + XAC97_mSetInFifoData(BaseAddress, 0); +} diff --git a/ecen427/xac97_l.h b/ecen427/xac97_l.h new file mode 100644 index 0000000..3704766 --- /dev/null +++ b/ecen427/xac97_l.h @@ -0,0 +1,291 @@ + + +#ifndef XAC97_L_H_ +#define XAC97_L_H_ + +#ifndef XAC97_H +#define XAC97_H + +#include +#include + +// AC97 core register offsets +#define AC97_IN_FIFO_OFFSET 0x0 +#define AC97_OUT_FIFO_OFFSET 0x0 +#define AC97_STATUS_OFFSET 0x4 +#define AC97_CONTROL_OFFSET 0x4 +#define AC97_REG_READ_OFFSET 0x8 +#define AC97_REG_WRITE_OFFSET 0x8 +#define AC97_REG_CONTROL_OFFSET 0xc + +// Status register bitmask constants +#define AC97_IN_FIFO_FULL 0x01 +#define AC97_IN_FIFO_EMPTY 0x02 +#define AC97_OUT_FIFO_EMPTY 0x04 +#define AC97_OUT_FIFO_DATA 0x08 +//#define AC97_REG_ACCESS_FINISHED 0x10 +#define AC97_REG_ACCESS_BUSY 0x10 +#define AC97_CODEC_RDY 0x20 +#define AC97_IN_FIFO_UNDERRUN 0x40 +#define AC97_OUT_FIFO_OVERRUN 0x80 +#define AC97_REG_ACCESS_ERROR 0x100 +#define AC97_IN_FIFO_LEVEL 0x003ff000 // 21 downto 12 +#define AC97_IN_FIFO_LEVEL_RSHFT 12 +#define AC97_OUT_FIFO_LEVEL 0xffc00000 // 31 downto 22 +#define AC97_OUT_FIFO_LEVEL_RSHFT 22 + +// FIFO Control Offsets +#define AC97_CLEAR_IN_FIFO 0x1 +#define AC97_CLEAR_OUT_FIFO 0x2 +#define AC97_ENABLE_IN_FIFO_INTERRUPT 0x4 +#define AC97_ENABLE_OUT_FIFO_INTERRUPT 0x8 +#define AC97_ENABLE_RESET_AC97 0x10 +#define AC97_DISABLE_RESET_AC97 0x0 +#define AC97_CLEAR_FIFOS AC97_CLEAR_IN_FIFO | AC97_CLEAR_OUT_FIFO + +/** AC97 CODEC Registers **/ +#define AC97_Reset 0x00 +#define AC97_MasterVol 0x02 +#define AC97_AuxOutVol 0x04 +#define AC97_MasterVolMono 0x06 +#define AC97_Reserved0x08 0x08 +#define AC97_PCBeepVol 0x0A +#define AC97_PhoneInVol 0x0C +#define AC97_MicVol 0x0E +#define AC97_LineInVol 0x10 +#define AC97_CDVol 0x12 +#define AC97_VideoVol 0x14 +#define AC97_AuxInVol 0x16 +#define AC97_PCMOutVol 0x18 +#define AC97_RecordSelect 0x1A +#define AC97_RecordGain 0x1C +#define AC97_Reserved0x1E 0x1E +#define AC97_GeneralPurpose 0x20 +#define AC97_3DControl 0x22 +#define AC97_PowerDown 0x26 +#define AC97_ExtendedAudioID 0x28 +#define AC97_ExtendedAudioStat 0x2A +#define AC97_PCM_DAC_Rate 0x2C +#define AC97_PCM_ADC_Rate 0x32 +#define AC97_PCM_DAC_Rate0 0x78 +#define AC97_PCM_DAC_Rate1 0x7A +#define AC97_Reserved0x34 0x34 +#define AC97_JackSense 0x72 +#define AC97_SerialConfig 0x74 +#define AC97_MiscControlBits 0x76 +#define AC97_VendorID1 0x7C +#define AC97_VendorID2 0x7E + +// Volume Constants for registers: +// AC97_MasterVol +// AC97_HeadphoneVol +// AC97_MasterVolMono +#define AC97_RIGHT_VOL_ATTN_0_DB 0x0 +#define AC97_RIGHT_VOL_ATTN_1_5_DB 0x1 +#define AC97_RIGHT_VOL_ATTN_3_0_DB 0x2 +#define AC97_RIGHT_VOL_ATTN_4_5_DB 0x3 +#define AC97_RIGHT_VOL_ATTN_6_0_DB 0x4 +#define AC97_RIGHT_VOL_ATTN_7_5_DB 0x5 +#define AC97_RIGHT_VOL_ATTN_9_0_DB 0x6 +#define AC97_RIGHT_VOL_ATTN_10_0_DB 0x7 +#define AC97_RIGHT_VOL_ATTN_11_5_DB 0x8 +#define AC97_RIGHT_VOL_ATTN_13_0_DB 0x9 +#define AC97_RIGHT_VOL_ATTN_14_5_DB 0xa +#define AC97_RIGHT_VOL_ATTN_16_0_DB 0xb +#define AC97_RIGHT_VOL_ATTN_17_5_DB 0xc +#define AC97_RIGHT_VOL_ATTN_19_0_DB 0xd +#define AC97_RIGHT_VOL_ATTN_20_5_DB 0xe +#define AC97_RIGHT_VOL_ATTN_22_0_DB 0xf +#define AC97_RIGHT_VOL_ATTN_23_5_DB 0x10 +#define AC97_RIGHT_VOL_ATTN_25_0_DB 0x11 +#define AC97_RIGHT_VOL_ATTN_26_5_DB 0x12 +#define AC97_RIGHT_VOL_ATTN_28_0_DB 0x13 +#define AC97_RIGHT_VOL_ATTN_29_5_DB 0x14 +#define AC97_RIGHT_VOL_ATTN_31_0_DB 0x15 +#define AC97_RIGHT_VOL_ATTN_32_5_DB 0x16 +#define AC97_RIGHT_VOL_ATTN_34_0_DB 0x17 +#define AC97_RIGHT_VOL_ATTN_35_5_DB 0x18 +#define AC97_RIGHT_VOL_ATTN_37_0_DB 0x19 +#define AC97_RIGHT_VOL_ATTN_38_5_DB 0x1a +#define AC97_RIGHT_VOL_ATTN_40_0_DB 0x1b +#define AC97_RIGHT_VOL_ATTN_41_5_DB 0x1c +#define AC97_RIGHT_VOL_ATTN_43_0_DB 0x1d +#define AC97_RIGHT_VOL_ATTN_44_5_DB 0x1e +#define AC97_RIGHT_VOL_ATTN_46_0_DB 0x1f + +#define AC97_LEFT_VOL_ATTN_0_DB 0x0 +#define AC97_LEFT_VOL_ATTN_1_5_DB 0x100 +#define AC97_LEFT_VOL_ATTN_3_0_DB 0x200 +#define AC97_LEFT_VOL_ATTN_4_5_DB 0x300 +#define AC97_LEFT_VOL_ATTN_6_0_DB 0x400 +#define AC97_LEFT_VOL_ATTN_7_5_DB 0x500 +#define AC97_LEFT_VOL_ATTN_9_0_DB 0x600 +#define AC97_LEFT_VOL_ATTN_10_0_DB 0x700 +#define AC97_LEFT_VOL_ATTN_11_5_DB 0x800 +#define AC97_LEFT_VOL_ATTN_13_0_DB 0x900 +#define AC97_LEFT_VOL_ATTN_14_5_DB 0xa00 +#define AC97_LEFT_VOL_ATTN_16_0_DB 0xb00 +#define AC97_LEFT_VOL_ATTN_17_5_DB 0xc00 +#define AC97_LEFT_VOL_ATTN_19_0_DB 0xd00 +#define AC97_LEFT_VOL_ATTN_20_5_DB 0xe00 +#define AC97_LEFT_VOL_ATTN_22_0_DB 0xf00 +#define AC97_LEFT_VOL_ATTN_23_5_DB 0x1000 +#define AC97_LEFT_VOL_ATTN_25_0_DB 0x1100 +#define AC97_LEFT_VOL_ATTN_26_5_DB 0x1200 +#define AC97_LEFT_VOL_ATTN_28_0_DB 0x1300 +#define AC97_LEFT_VOL_ATTN_29_5_DB 0x1400 +#define AC97_LEFT_VOL_ATTN_31_0_DB 0x1500 +#define AC97_LEFT_VOL_ATTN_32_5_DB 0x1600 +#define AC97_LEFT_VOL_ATTN_34_0_DB 0x1700 +#define AC97_LEFT_VOL_ATTN_35_5_DB 0x1800 +#define AC97_LEFT_VOL_ATTN_37_0_DB 0x1900 +#define AC97_LEFT_VOL_ATTN_38_5_DB 0x1a00 +#define AC97_LEFT_VOL_ATTN_40_0_DB 0x1b00 +#define AC97_LEFT_VOL_ATTN_41_5_DB 0x1c00 +#define AC97_LEFT_VOL_ATTN_43_0_DB 0x1d00 +#define AC97_LEFT_VOL_ATTN_44_5_DB 0x1e00 +#define AC97_LEFT_VOL_ATTN_46_0_DB 0x1f00 + +#define AC97_VOL_ATTN_0_DB AC97_LEFT_VOL_ATTN_0_DB | AC97_RIGHT_VOL_ATTN_0_DB +#define AC97_VOL_ATTN_1_5_DB AC97_LEFT_VOL_ATTN_1_5_DB | AC97_RIGHT_VOL_ATTN_1_5_DB +#define AC97_VOL_ATTN_3_0_DB AC97_LEFT_VOL_ATTN_3_0_DB | AC97_RIGHT_VOL_ATTN_3_0_DB +#define AC97_VOL_ATTN_4_5_DB AC97_LEFT_VOL_ATTN_4_5_DB | AC97_RIGHT_VOL_ATTN_4_5_DB +#define AC97_VOL_ATTN_6_0_DB AC97_LEFT_VOL_ATTN_6_0_DB | AC97_RIGHT_VOL_ATTN_6_0_DB +#define AC97_VOL_ATTN_7_5_DB AC97_LEFT_VOL_ATTN_7_5_DB | AC97_RIGHT_VOL_ATTN_7_5_DB +#define AC97_VOL_ATTN_9_0_DB AC97_LEFT_VOL_ATTN_9_0_DB | AC97_RIGHT_VOL_ATTN_9_0_DB +#define AC97_VOL_ATTN_10_0_DB AC97_LEFT_VOL_ATTN_10_0_DB | AC97_RIGHT_VOL_ATTN_10_0_DB +#define AC97_VOL_ATTN_11_5_DB AC97_LEFT_VOL_ATTN_11_5_DB | AC97_RIGHT_VOL_ATTN_11_5_DB +#define AC97_VOL_ATTN_13_0_DB AC97_LEFT_VOL_ATTN_13_0_DB | AC97_RIGHT_VOL_ATTN_13_0_DB +#define AC97_VOL_ATTN_14_5_DB AC97_LEFT_VOL_ATTN_14_5_DB | AC97_RIGHT_VOL_ATTN_14_5_DB +#define AC97_VOL_ATTN_16_0_DB AC97_LEFT_VOL_ATTN_16_0_DB | AC97_RIGHT_VOL_ATTN_16_0_DB +#define AC97_VOL_ATTN_17_5_DB AC97_LEFT_VOL_ATTN_17_5_DB | AC97_RIGHT_VOL_ATTN_17_5_DB +#define AC97_VOL_ATTN_19_0_DB AC97_LEFT_VOL_ATTN_19_0_DB | AC97_RIGHT_VOL_ATTN_19_0_DB +#define AC97_VOL_ATTN_20_5_DB AC97_LEFT_VOL_ATTN_20_5_DB | AC97_RIGHT_VOL_ATTN_20_5_DB +#define AC97_VOL_ATTN_22_0_DB AC97_LEFT_VOL_ATTN_22_0_DB | AC97_RIGHT_VOL_ATTN_22_0_DB +#define AC97_VOL_ATTN_23_5_DB AC97_LEFT_VOL_ATTN_23_5_DB | AC97_RIGHT_VOL_ATTN_23_5_DB +#define AC97_VOL_ATTN_25_0_DB AC97_LEFT_VOL_ATTN_25_0_DB | AC97_RIGHT_VOL_ATTN_25_0_DB +#define AC97_VOL_ATTN_26_5_DB AC97_LEFT_VOL_ATTN_26_5_DB | AC97_RIGHT_VOL_ATTN_26_5_DB +#define AC97_VOL_ATTN_28_0_DB AC97_LEFT_VOL_ATTN_28_0_DB | AC97_RIGHT_VOL_ATTN_28_0_DB +#define AC97_VOL_ATTN_29_5_DB AC97_LEFT_VOL_ATTN_29_5_DB | AC97_RIGHT_VOL_ATTN_29_5_DB +#define AC97_VOL_ATTN_31_0_DB AC97_LEFT_VOL_ATTN_31_0_DB | AC97_RIGHT_VOL_ATTN_31_0_DB +#define AC97_VOL_ATTN_32_5_DB AC97_LEFT_VOL_ATTN_32_5_DB | AC97_RIGHT_VOL_ATTN_32_5_DB +#define AC97_VOL_ATTN_34_0_DB AC97_LEFT_VOL_ATTN_34_0_DB | AC97_RIGHT_VOL_ATTN_34_0_DB +#define AC97_VOL_ATTN_35_5_DB AC97_LEFT_VOL_ATTN_35_5_DB | AC97_RIGHT_VOL_ATTN_35_5_DB +#define AC97_VOL_ATTN_37_0_DB AC97_LEFT_VOL_ATTN_37_0_DB | AC97_RIGHT_VOL_ATTN_37_0_DB +#define AC97_VOL_ATTN_38_5_DB AC97_LEFT_VOL_ATTN_38_5_DB | AC97_RIGHT_VOL_ATTN_38_5_DB +#define AC97_VOL_ATTN_40_0_DB AC97_LEFT_VOL_ATTN_40_0_DB | AC97_RIGHT_VOL_ATTN_40_0_DB +#define AC97_VOL_ATTN_41_5_DB AC97_LEFT_VOL_ATTN_41_5_DB | AC97_RIGHT_VOL_ATTN_41_5_DB +#define AC97_VOL_ATTN_43_0_DB AC97_LEFT_VOL_ATTN_43_0_DB | AC97_RIGHT_VOL_ATTN_43_0_DB +#define AC97_VOL_ATTN_44_5_DB AC97_LEFT_VOL_ATTN_44_5_DB | AC97_RIGHT_VOL_ATTN_44_5_DB +#define AC97_VOL_ATTN_46_0_DB AC97_LEFT_VOL_ATTN_46_0_DB | AC97_RIGHT_VOL_ATTN_46_0_DB + +#define AC97_VOL_MUTE 0x8000 +#define AC97_VOL_MIN 0x1f1f +#define AC97_VOL_MID 0x0a0a +#define AC97_VOL_MAX 0x0000 + +#define AC97_RECORD_MIC_IN 0x0000 +#define AC97_RECORD_LINE_IN 0x0404 // both left and right + +// Extended Audio Control +#define AC97_EXTENDED_AUDIO_CONTROL_VRA 0x1 + + +// PCM Data rate constants +// AC97_PCM_DAC_Rate 0x2C +// AC97_PCM_ADC_Rate 0x32 +#define AC97_PCM_RATE_8000_HZ 0x1F40 +#define AC97_PCM_RATE_11025_HZ 0x2B11 +#define AC97_PCM_RATE_16000_HZ 0x3E80 +#define AC97_PCM_RATE_22050_HZ 0x5622 +#define AC97_PCM_RATE_44100_HZ 0xAC44 +#define AC97_PCM_RATE_48000_HZ 0xBB80 + + +// General Purpose register constants (LM4549A) +// bits are zero by default +#define AC97_GP_PCM_BYPASS_3D 0x8000 // POP bit (on) +#define AC97_GP_NATIONAL_3D_ON 0x2000 // 3D bit (on) +#define AC97_GP_MONO_OUTPUT_MIX 0x0 // MIX bit (off) +#define AC97_GP_MONO_OUTPUT_MIC 0x200 // MIX bit (on) +#define AC97_GP_MIC_SELECT_MIC1 0x0 // MS bit (off) +#define AC97_GP_MIC_SELECT_MIC2 0x100 // MS bit (on) +#define AC97_GP_ADC_DAC_LOOPBACK 0x80 // LPBK bit + +#define AC97_MIC_INPUT 1 +#define AC97_LINE_INPUT 2 + +#define AC97_ANALOG_LOOPBACK 1 +#define AC97_DIGITAL_LOOPBACK 2 + +#define XAC97_mGetRegister(BaseAddress, offset) \ + XIo_In32((BaseAddress + offset)) + +// Macros for reading/writing AC97 core registers +#define XAC97_mSetInFifoData(BaseAddress, value) \ + XIo_Out32((BaseAddress) + AC97_IN_FIFO_OFFSET,(value)) +#define XAC97_mGetOutFifoData(BaseAddress) \ + XIo_In32((BaseAddress + AC97_OUT_FIFO_OFFSET)) +#define XAC97_mGetStatus(BaseAddress) \ + XIo_In32((BaseAddress + AC97_STATUS_OFFSET)) +#define XAC97_mSetControl(BaseAddress, value) \ + XIo_Out32((BaseAddress) + AC97_CONTROL_OFFSET,(value)) +#define XAC97_mSetAC97RegisterAccessCommand(BaseAddress, value) \ + XIo_Out32((BaseAddress) + AC97_REG_CONTROL_OFFSET,(value)) +#define XAC97_mGetAC97RegisterData(BaseAddress) \ + XIo_In32((BaseAddress + AC97_REG_READ_OFFSET)) +#define XAC97_mSetAC97RegisterData(BaseAddress, value) \ + XIo_Out32((BaseAddress) + AC97_REG_WRITE_OFFSET,(value)) + +// Status register macros +#define XAC97_isInFIFOFull(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_IN_FIFO_FULL) +#define XAC97_isInFIFOEmpty(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_IN_FIFO_EMPTY) +#define XAC97_isOutFIFOEmpty(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_OUT_FIFO_EMPTY) +#define XAC97_isOutFIFOFull(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_OUT_FIFO_FULL) +#define XAC97_isRegisterAccessFinished(BaseAddress) \ + ((XAC97_mGetStatus(BaseAddress) & AC97_REG_ACCESS_BUSY) == 0) +// (XAC97_mGetStatus(BaseAddress) & AC97_REG_ACCESS_FINISHED)) +#define XAC97_isRegisterAccessError(BaseAddress) \ + ((XAC97_mGetStatus(BaseAddress) & AC97_REG_ACCESS_ERROR) > 0) + +#define XAC97_isCodecReady(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_CODEC_RDY) +#define XAC97_isInFIFOUnderrun(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_IN_FIFO_UNDERRUN) +#define XAC97_isOutFIFOOverrun(BaseAddress) \ + (XAC97_mGetStatus(BaseAddress) & AC97_OUT_FIFO_UNDERRUN) +#define XAC97_getInFIFOLevel(BaseAddress) \ + ((XAC97_mGetStatus(BaseAddress) & AC97_IN_FIFO_LEVEL) >> \ + AC97_IN_FIFO_LEVEL_RSHFT) +#define XAC97_getOutFIFOLevel(BaseAddress) \ + ((XAC97_mGetStatus(BaseAddress) & AC97_OUT_FIFO_LEVEL) >> \ + AC97_OUT_FIFO_LEVEL_RSHFT) + + +// AC97 driver functions +void XAC97_WriteReg(Xuint32 BaseAddress, Xuint32 RegAddress, Xuint32 Value); +Xuint32 XAC97_ReadReg(Xuint32 BaseAddress, Xuint32 RegAddress); +void XAC97_AwaitCodecReady(Xuint32 BaseAddress); + +void XAC97_Delay(Xuint32 Value); +void XAC97_SoftReset(Xuint32 BaseAddress); +void XAC97_HardReset(Xuint32 BaseAddress); + +void XAC97_InitAudio(Xuint32 BaseAddress, Xuint8 Loopback); +void XAC97_EnableInput(Xuint32 BaseAddress, Xuint8 InputType); +void XAC97_DisableInput(Xuint32 BaseAddress, Xuint8 InputType); +void XAC97_RecAudio(Xuint32 BaseAddress, Xuint32 StartAddress, + Xuint32 EndAddress); +void XAC97_PlayAudio(Xuint32 BaseAddress, Xuint32 StartAddress, + Xuint32 EndAddress); +void XAC97_WriteFifo(Xuint32 BaseAddress, Xuint32 Sample); +Xuint32 XAC97_ReadFifo(Xuint32 BaseAddress); +void XAC97_ClearFifos(Xuint32 BaseAddress); + +#endif + +#endif