summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@lab.panaceas.james.local>2013-10-11 11:39:43 +0100
committerroot <root@lab.panaceas.james.local>2013-10-11 11:39:43 +0100
commit4eac4fac1d9cbe51176bb1071cc35eb9456a74f0 (patch)
treebfed3e1e64092279449e6949cd8e1e50db7907c2
parentf94ef0f1404b687bb9f15caa1b6ec56ea3ea5c33 (diff)
downloadpong-4eac4fac1d9cbe51176bb1071cc35eb9456a74f0.zip
pong-4eac4fac1d9cbe51176bb1071cc35eb9456a74f0.tar.gz
pong-4eac4fac1d9cbe51176bb1071cc35eb9456a74f0.tar.bz2
tidy
-rw-r--r--software/pong3/GPU.h2
-rw-r--r--software/pong3/pong3.c9
2 files changed, 8 insertions, 3 deletions
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)