adding in ecen427 space invaders final lab
This commit is contained in:
parent
e3fae2b680
commit
110f83b420
337
ecen427/alien.c
Normal file
337
ecen427/alien.c
Normal 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
ecen427/alien.h
Normal file
158
ecen427/alien.h
Normal 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
ecen427/alienDeathSound.c
Normal file
18
ecen427/alienDeathSound.c
Normal file
File diff suppressed because one or more lines are too long
226
ecen427/bullet.c
Normal file
226
ecen427/bullet.c
Normal 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
ecen427/bullet.h
Normal file
109
ecen427/bullet.h
Normal 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
ecen427/bunker.c
Normal file
638
ecen427/bunker.c
Normal 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
ecen427/bunker.h
Normal file
440
ecen427/bunker.h
Normal 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
ecen427/global.c
Normal file
284
ecen427/global.c
Normal 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
16
ecen427/global.h
Normal file
16
ecen427/global.h
Normal file
@ -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_ */
|
213
ecen427/lscript.ld
Normal file
213
ecen427/lscript.ld
Normal file
@ -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 = .;
|
||||
}
|
||||
|
14
ecen427/nes.c
Normal file
14
ecen427/nes.c
Normal file
@ -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 ***************************/
|
||||
|
123
ecen427/nes.h
Normal file
123
ecen427/nes.h
Normal file
@ -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 */
|
14
ecen427/pit.c
Normal file
14
ecen427/pit.c
Normal file
@ -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 ***************************/
|
||||
|
129
ecen427/pit.h
Normal file
129
ecen427/pit.h
Normal file
@ -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 */
|
81
ecen427/platform.c
Normal file
81
ecen427/platform.c
Normal file
@ -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();
|
||||
}
|
27
ecen427/platform.h
Normal file
27
ecen427/platform.h
Normal file
@ -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
|
8
ecen427/platform_config.h
Normal file
8
ecen427/platform_config.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __PLATFORM_CONFIG_H_
|
||||
#define __PLATFORM_CONFIG_H_
|
||||
|
||||
#ifdef __PPC__
|
||||
#define CACHEABLE_REGION_MASK 0x80000080
|
||||
#endif
|
||||
|
||||
#endif
|
618
ecen427/score.c
Normal file
618
ecen427/score.c
Normal file
@ -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;
|
||||
}
|
402
ecen427/score.h
Normal file
402
ecen427/score.h
Normal file
@ -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_ */
|
3
ecen427/shoot.c
Normal file
3
ecen427/shoot.c
Normal file
File diff suppressed because one or more lines are too long
215
ecen427/sounds.c
Normal file
215
ecen427/sounds.c
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
47
ecen427/sounds.h
Normal file
47
ecen427/sounds.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* sounds.h
|
||||
*
|
||||
* Created on: Oct 29, 2013
|
||||
* Author: superman
|
||||
*/
|
||||
|
||||
#ifndef SOUNDS_H_
|
||||
#define SOUNDS_H_
|
||||
|
||||
#include <xbasic_types.h>
|
||||
#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_ */
|
||||
|
3
ecen427/spaceShipDeathSound.c
Normal file
3
ecen427/spaceShipDeathSound.c
Normal file
File diff suppressed because one or more lines are too long
3
ecen427/spaceShipSound.c
Normal file
3
ecen427/spaceShipSound.c
Normal file
File diff suppressed because one or more lines are too long
111
ecen427/tank.c
Normal file
111
ecen427/tank.c
Normal file
@ -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);
|
||||
}
|
||||
}
|
77
ecen427/tank.h
Normal file
77
ecen427/tank.h
Normal file
@ -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_ */
|
383
ecen427/tankDeath.c
Normal file
383
ecen427/tankDeath.c
Normal file
@ -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;
|
||||
|
255
ecen427/ufo.c
Normal file
255
ecen427/ufo.c
Normal file
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
134
ecen427/ufo.h
Normal file
134
ecen427/ufo.h
Normal file
@ -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_ */
|
872
ecen427/vdma.c
Normal file
872
ecen427/vdma.c
Normal file
@ -0,0 +1,872 @@
|
||||
#include <stdio.h>
|
||||
#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 <xuartlite_l.h>
|
||||
|
||||
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;
|
||||
}
|
180
ecen427/xac97_l.c
Normal file
180
ecen427/xac97_l.c
Normal file
@ -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 <xbasic_types.h>
|
||||
#include <xio.h>
|
||||
#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);
|
||||
}
|
291
ecen427/xac97_l.h
Normal file
291
ecen427/xac97_l.h
Normal file
@ -0,0 +1,291 @@
|
||||
|
||||
|
||||
#ifndef XAC97_L_H_
|
||||
#define XAC97_L_H_
|
||||
|
||||
#ifndef XAC97_H
|
||||
#define XAC97_H
|
||||
|
||||
#include <xbasic_types.h>
|
||||
#include <xio.h>
|
||||
|
||||
// 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
|
Loading…
Reference in New Issue
Block a user