From 4eac4fac1d9cbe51176bb1071cc35eb9456a74f0 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Oct 2013 11:39:43 +0100 Subject: tidy --- software/pong3/GPU.h | 2 ++ software/pong3/pong3.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'software') diff --git a/software/pong3/GPU.h b/software/pong3/GPU.h index 3883381..fef1499 100644 --- a/software/pong3/GPU.h +++ b/software/pong3/GPU.h @@ -24,6 +24,8 @@ #define GPU_REG_BAT1_Y 0x4 #define GPU_REG_SPRITE_COLOUR 0x5 #define GPU_REG_SPRITE_BASE 0x10 + +#define GPU_RGB(r,g,b) (((r) << 6) | ((g) << 3) | (b)) #endif /* GPU_H_ */ diff --git a/software/pong3/pong3.c b/software/pong3/pong3.c index 59530cb..aba6ae6 100644 --- a/software/pong3/pong3.c +++ b/software/pong3/pong3.c @@ -43,17 +43,22 @@ update_gpu (int x, int y, int bat0, int bat1) static void show_score (int score) { + // int to seven segment lookup: MSB dp g f e d c b a LSB const uint8_t lookup[10] = { 0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F }; + uint8_t ss = 0; + // show negative with DP if (score < 0) { ss |= 0x80; score = -score; } + if (score > 9) score = 9; + ss |= lookup[score]; pio_write (ss); @@ -69,9 +74,7 @@ load_sprite (void) const unsigned int n = sizeof (sprite) / sizeof (uint16_t); unsigned int i; - // RRR GGG BBB - // set the sprite color 111 010 000 - orange - gpu_write (GPU_REG_SPRITE_COLOUR, 0x01D0); + gpu_write (GPU_REG_SPRITE_COLOUR, GPU_RGB(7,2,0)); // squirt the bromium logo into the sprite for (i = 0; i < n; ++i) -- cgit v1.2.3