Browse Source

adding in ecen427 space invaders final lab

master
Derek McQuay 3 years ago
parent
commit
110f83b420
32 changed files with 6429 additions and 0 deletions
  1. +337
    -0
      ecen427/alien.c
  2. +158
    -0
      ecen427/alien.h
  3. +18
    -0
      ecen427/alienDeathSound.c
  4. +226
    -0
      ecen427/bullet.c
  5. +109
    -0
      ecen427/bullet.h
  6. +638
    -0
      ecen427/bunker.c
  7. +440
    -0
      ecen427/bunker.h
  8. +284
    -0
      ecen427/global.c
  9. +16
    -0
      ecen427/global.h
  10. +213
    -0
      ecen427/lscript.ld
  11. +14
    -0
      ecen427/nes.c
  12. +123
    -0
      ecen427/nes.h
  13. +14
    -0
      ecen427/pit.c
  14. +129
    -0
      ecen427/pit.h
  15. +81
    -0
      ecen427/platform.c
  16. +27
    -0
      ecen427/platform.h
  17. +8
    -0
      ecen427/platform_config.h
  18. +618
    -0
      ecen427/score.c
  19. +402
    -0
      ecen427/score.h
  20. +3
    -0
      ecen427/shoot.c
  21. +215
    -0
      ecen427/sounds.c
  22. +47
    -0
      ecen427/sounds.h
  23. +3
    -0
      ecen427/spaceShipDeathSound.c
  24. +3
    -0
      ecen427/spaceShipSound.c
  25. +111
    -0
      ecen427/tank.c
  26. +77
    -0
      ecen427/tank.h
  27. +383
    -0
      ecen427/tankDeath.c
  28. +255
    -0
      ecen427/ufo.c
  29. +134
    -0
      ecen427/ufo.h
  30. +872
    -0
      ecen427/vdma.c
  31. +180
    -0
      ecen427/xac97_l.c
  32. +291
    -0
      ecen427/xac97_l.h

+ 337
- 0
ecen427/alien.c View File

@@ -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);
}
}

+ 158
- 0
ecen427/alien.h View File

@@ -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_ */

+ 18
- 0
ecen427/alienDeathSound.c
File diff suppressed because it is too large
View File


+ 226
- 0
ecen427/bullet.c View File

@@ -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);
}
}
}

+ 109
- 0
ecen427/bullet.h View File

@@ -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_ */

+ 638
- 0
ecen427/bunker.c View File

@@ -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<initial_y+32){
if(bullet_x >= 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<initial_y+48){
if(bullet_x >= BUNKER1_X-3 && bullet_x<BUNKER1_X+16 && bunker[8] != 4){
erodeBunker(framePointer, 0, 8);
hit = 1;
}
if(bullet_x >= BUNKER1_X+48 && bullet_x<BUNKER1_X+64+3 && bunker[9] != 4){
erodeBunker(framePointer, 0, 9);
hit = 1;
}
}
}
if(bullet_x > BUNKER2_X-3 && bullet_x < BUNKER2_X+64+3){
bunker = getBunker2();
if(bullet_y>initial_y && bullet_y<initial_y+16){
if(bullet_x >= BUNKER2_X-3 && bullet_x<BUNKER2_X+16 && bunker[0] != 4){
erodeBunker(framePointer, 1, 0);
hit = 1;
}
if(bullet_x >= BUNKER2_X+16 && bullet_x<BUNKER2_X+32 && bunker[1] != 4){
erodeBunker(framePointer, 1, 1);
hit = 1;
}
if(bullet_x >= BUNKER2_X+32 && bullet_x<BUNKER2_X+48 && bunker[2] != 4){
erodeBunker(framePointer, 1, 2);
hit = 1;
}
if(bullet_x >= BUNKER2_X+48 && bullet_x<BUNKER2_X+64+3 && bunker[3] != 4){
erodeBunker(framePointer, 1, 3);
hit = 1;
}
}
if(bullet_y>initial_y+16 && bullet_y<initial_y+32){
if(bullet_x >= BUNKER2_X-3 && bullet_x<BUNKER2_X+16 && bunker[4] != 4){
erodeBunker(framePointer, 1, 4);
hit = 1;
}
if(bullet_x >= BUNKER2_X+16 && bullet_x<BUNKER2_X+32 && bunker[5] != 4){
erodeBunker(framePointer, 1, 5);
hit = 1;
}
if(bullet_x >= BUNKER2_X+32 && bullet_x<BUNKER2_X+48 && bunker[6] != 4){
erodeBunker(framePointer, 1, 6);
hit = 1;
}
if(bullet_x >= BUNKER2_X+48 && bullet_x<BUNKER2_X+64+3 && bunker[7] != 4){
erodeBunker(framePointer, 1, 7);
hit = 1;
}
}
if(bullet_y>initial_y+32 && bullet_y<initial_y+48){
if(bullet_x >= BUNKER2_X-3 && bullet_x<BUNKER2_X+16 && bunker[8] != 4){
erodeBunker(framePointer, 1, 8);
hit = 1;
}
if(bullet_x >= BUNKER2_X+48 && bullet_x<BUNKER2_X+64+3 && bunker[9] != 4){
erodeBunker(framePointer, 1, 9);
hit = 1;
}
}
}
if(bullet_x > BUNKER3_X-3 && bullet_x < BUNKER3_X+64+3){
bunker = getBunker3();
if(bullet_y>initial_y && bullet_y<initial_y+16){
if(bullet_x >= BUNKER3_X-3 && bullet_x<BUNKER3_X+16 && bunker[0] != 4){
erodeBunker(framePointer, 2, 0);
hit = 1;
}
if(bullet_x >= BUNKER3_X+16 && bullet_x<BUNKER3_X+32 && bunker[1] != 4){
erodeBunker(framePointer, 2, 1);
hit = 1;
}
if(bullet_x >= BUNKER3_X+32 && bullet_x<BUNKER3_X+48 && bunker[2] != 4){
erodeBunker(framePointer, 2, 2);
hit = 1;
}
if(bullet_x >= BUNKER3_X+48 && bullet_x<BUNKER3_X+64+3 && bunker[3] != 4){
erodeBunker(framePointer, 2, 3);
hit = 1;
}
}
if(bullet_y>initial_y+16 && bullet_y<initial_y+32){
if(bullet_x >= BUNKER3_X-3 && bullet_x<BUNKER3_X+16 && bunker[4] != 4){
erodeBunker(framePointer, 2, 4);
hit = 1;
}
if(bullet_x >= BUNKER3_X+16 && bullet_x<BUNKER3_X+32 && bunker[5] != 4){
erodeBunker(framePointer, 2, 5);
hit = 1;
}
if(bullet_x >= BUNKER3_X+32 && bullet_x<BUNKER3_X+48 && bunker[6] != 4){
erodeBunker(framePointer, 2, 6);
hit = 1;
}
if(bullet_x >= BUNKER3_X+48 && bullet_x<BUNKER3_X+64+3 && bunker[7] != 4){
erodeBunker(framePointer, 2, 7);
hit = 1;
}
}
if(bullet_y>initial_y+32 && bullet_y<initial_y+48){
if(bullet_x >= BUNKER3_X-3 && bullet_x<BUNKER3_X+16 && bunker[8] != 4){
erodeBunker(framePointer, 2, 8);
hit = 1;
}
if(bullet_x >= BUNKER3_X+48 && bullet_x<BUNKER3_X+64+3 && bunker[9] != 4){
erodeBunker(framePointer, 2, 9);
hit = 1;
}
}
}
if(bullet_x > BUNKER4_X-3 && bullet_x < BUNKER4_X+64+3){
bunker = getBunker4();
if(bullet_y>initial_y && bullet_y<initial_y+16){
if(bullet_x >= BUNKER4_X-3 && bullet_x<BUNKER4_X+16 && bunker[0] != 4){
erodeBunker(framePointer, 3, 0);
hit = 1;
}
if(bullet_x >= BUNKER4_X+16 && bullet_x<BUNKER4_X+32 && bunker[1] != 4){
erodeBunker(framePointer, 3, 1);
hit = 1;
}
if(bullet_x >= BUNKER4_X+32 && bullet_x<BUNKER4_X+48 && bunker[2] != 4){
erodeBunker(framePointer, 3, 2);
hit = 1;
}
if(bullet_x >= BUNKER4_X+48 && bullet_x<BUNKER4_X+64+3 && bunker[3] != 4){
erodeBunker(framePointer, 3, 3);
hit = 1;
}
}
if(bullet_y>initial_y+16 && bullet_y<initial_y+32){
if(bullet_x >= BUNKER4_X-3 && bullet_x<BUNKER4_X+16 && bunker[4] != 4){
erodeBunker(framePointer, 3, 4);
hit = 1;
}
if(bullet_x >= BUNKER4_X+16 && bullet_x<BUNKER4_X+32 && bunker[5] != 4){
erodeBunker(framePointer, 3, 5);
hit = 1;
}
if(bullet_x >= BUNKER4_X+32 && bullet_x<BUNKER4_X+48 && bunker[6] != 4){
erodeBunker(framePointer, 3, 6);
hit = 1;
}
if(bullet_x >= BUNKER4_X+48 && bullet_x<BUNKER4_X+64+3 && bunker[7] != 4){
erodeBunker(framePointer, 3, 7);
hit = 1;
}
}
if(bullet_y>initial_y+32 && bullet_y<initial_y+48){
if(bullet_x >= BUNKER4_X-3 && bullet_x<BUNKER4_X+16 && bunker[8] != 4){
erodeBunker(framePointer, 3, 8);
hit = 1;
}
if(bullet_x >= BUNKER4_X+48 && bullet_x<BUNKER4_X+64+3 && bunker[9] != 4){
erodeBunker(framePointer, 3, 9);
hit = 1;
}
}
}
if(bullet_y > 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;
}
}
}

+ 440
- 0
ecen427/bunker.h View File

@@ -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_ */

+ 284
- 0
ecen427/global.c View File

@@ -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;
}