diff options
author | Benjamin Cohen <bencoh@notk.org> | 2011-12-12 17:22:17 +0100 |
---|---|---|
committer | Benjamin Cohen <bencoh@notk.org> | 2011-12-12 17:22:17 +0100 |
commit | 7cb4fbff1fb6781a1b9bea11dd584cdee26f17e1 (patch) | |
tree | 62608d2cc77c54b72721a5337794efbd63eb2465 | |
parent | edfdf6bec9f6ca37b6357ecb7c52a0be47e80cab (diff) | |
parent | 248cdd13e7202e788a5fa501c5714bd4a91e483b (diff) |
Merge branch 'master' of gitolite@notk.org:pong51
-rw-r--r-- | init.c | 2 | ||||
-rw-r--r-- | pong.c | 67 | ||||
-rw-r--r-- | pong.h | 1 |
3 files changed, 66 insertions, 4 deletions
@@ -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); @@ -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); + } + +} @@ -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(); |