summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Cohen <bencoh@notk.org>2011-12-12 17:22:17 +0100
committerBenjamin Cohen <bencoh@notk.org>2011-12-12 17:22:17 +0100
commit7cb4fbff1fb6781a1b9bea11dd584cdee26f17e1 (patch)
tree62608d2cc77c54b72721a5337794efbd63eb2465
parentedfdf6bec9f6ca37b6357ecb7c52a0be47e80cab (diff)
parent248cdd13e7202e788a5fa501c5714bd4a91e483b (diff)
Merge branch 'master' of gitolite@notk.org:pong51
-rw-r--r--init.c2
-rw-r--r--pong.c67
-rw-r--r--pong.h1
3 files changed, 66 insertions, 4 deletions
diff --git a/init.c b/init.c
index 5be3728..8ab5f8f 100644
--- a/init.c
+++ b/init.c
@@ -40,7 +40,7 @@ void Timer0_Init(void) {
}
void wait500ns(){
- TL0 = 255-(SYSCLK/100000/2); // an edge every 5us;
+ TL0 = 255-(SYSCLK/100000); // an edge every 10us;
TF0=0;
TR0=1;
while (!TF0);
diff --git a/pong.c b/pong.c
index dad891e..c0e0b23 100644
--- a/pong.c
+++ b/pong.c
@@ -68,6 +68,8 @@ void main (void) {
LCD_Init();
LCD_Clear(1, 0);
+ InitGame();
+
while (1) { // spin forever
if (RI0) {
@@ -98,9 +100,8 @@ void main (void) {
}
- printf("woot %02u:%02u:%02u\r\n", HH, MM, SS);
- LCD_Set(1, 0, 2*SS, 0x15, 0x33);
-
+ printf("woot %02u:%02u:%02u -- %u\r\n", HH, MM, SS, X_MAX);
+ LCD_DrawScreen();
}
}
}
@@ -286,3 +287,63 @@ void LCD_Clear(__bit _CS1, __bit _CS2) {
}
}
}
+
+
+void LCD_DrawScreen() {
+ unsigned char x, y;
+ unsigned char xOverFlow;
+
+ x = (OldGame.player1 >> X_SHIFT);
+ LCD_Set(1, 0, x/8, 1, 0xFF);
+ LCD_Set(1, 0, x/8+1, 1, 0xFF);
+ if (x % 8 != 0) {
+ LCD_Set(1, 0, x/8, 2, 0xFF);
+ LCD_Set(1, 0, x/8+1, 2, 0xFF);
+ }
+
+ x = (OldGame.player2 >> X_SHIFT);
+ LCD_Set(1, 0, x/8, 62, 0xFF);
+ LCD_Set(1, 0, x/8+1, 62, 0xFF);
+ if (x % 8 != 0) {
+ LCD_Set(1, 0, x/8, 61, 0xFF);
+ LCD_Set(1, 0, x/8+1, 61, 0xFF);
+ }
+
+ x = (OldGame.ball.x >> X_SHIFT);
+ y = (OldGame.ball.y >> Y_SHIFT);
+ LCD_Set(1, 0, x/8, y, 0xFF);
+ LCD_Set(1, 0, x/8, y+1, 0xFF);
+ if (x % 8 == 7) {
+ LCD_Set(1, 0, x/8+1, y, 0xFF);
+ LCD_Set(1, 0, x/8+1, y+1, 0xFF);
+ }
+
+ x = (NextGame.player1 >> X_SHIFT);
+ xOverFlow = x % 8;
+ LCD_Set(1, 0, x/8, 1, (0xFF >> (8-xOverFlow)));
+ LCD_Set(1, 0, x/8, 2, (0xFF >> (8-xOverFlow)));
+ if (xOverFlow != 0) {
+ LCD_Set(1, 0, x/8+1, 1, (0xFF << xOverFlow));
+ LCD_Set(1, 0, x/8+1, 2, (0xFF << xOverFlow));
+ }
+
+ x = (NextGame.player2 >> X_SHIFT);
+ xOverFlow = x % 8;
+ LCD_Set(1, 0, x/8, 62, (0xFF >> (8-xOverFlow)));
+ LCD_Set(1, 0, x/8, 61, (0xFF >> (8-xOverFlow)));
+ if (xOverFlow != 0) {
+ LCD_Set(1, 0, x/8+1, 62, (0xFF << xOverFlow));
+ LCD_Set(1, 0, x/8+1, 61, (0xFF << xOverFlow));
+ }
+
+ x = (OldGame.ball.x >> X_SHIFT);
+ y = (OldGame.ball.y >> Y_SHIFT);
+ xOverFlow = x % 8;
+ LCD_Set(1, 0, x/8, y, ~(0x03 << xOverFlow));
+ LCD_Set(1, 0, x/8, y+1, ~(0x03 << xOverFlow));
+ if (x % 8 == 7) {
+ LCD_Set(1, 0, x/8+1, y, 0xFE);
+ LCD_Set(1, 0, x/8+1, y+1, 0xFE);
+ }
+
+}
diff --git a/pong.h b/pong.h
index ee1e17f..5dd657a 100644
--- a/pong.h
+++ b/pong.h
@@ -57,3 +57,4 @@ void hscanf(char* str, unsigned char* a, unsigned char* b, unsigned char* c);
void LCD_Set(__bit _CS1, __bit _CS2, unsigned char x, unsigned char y, unsigned char toSet);
void LCD_Clear(__bit _CS1, __bit _CS2);
+void LCD_DrawScreen();