Trammell Hudson avatar Trammell Hudson committed 81272f0 Draft

Use the asteroids font; far fewer points

Comments (0)

Files changed (5)

 	usb_serial.c \
 	bits.c \
 	hershey.c \
+	asteroids-font.c \
 	sin_table.c \
 	vector.c \
 	clock.c \
+/** \file
+ * Super simple font from Asteroids.
+ *
+ * http://www.edge-online.com/wp-content/uploads/edgeonline/oldfiles/images/feature_article/2009/05/asteroids2.jpg
+ */
+
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include <stdint.h>
+#include "asteroids-font.h"
+
+#define P(x,y)	((((x) & 0xF) << 4) | (((y) & 0xF) << 0))
+#define UP 0xFE
+#define LAST 0xFF
+ 
+const PROGMEM asteroids_char_t asteroids_font[] = {
+	['0' - 0x20] = { P(0,0), P(8,0), P(8,12), P(0,12), P(0,0), P(8,12), LAST },
+	['1' - 0x20] = { P(4,0), P(4,12), LAST },
+	['2' - 0x20] = { P(0,12), P(8,12), P(8,7), P(0,5), P(0,0), P(8,0), LAST },
+	['3' - 0x20] = { P(0,12), P(8,12), P(8,0), P(0,0), UP, P(0,6), P(8,6), LAST },
+	['4' - 0x20] = { P(0,12), P(0,6), P(8,6), UP, P(8,12), P(8,0), LAST },
+	['5' - 0x20] = { P(0,0), P(8,0), P(8,5), P(0,6), P(0,12), P(8,12), LAST },
+	['6' - 0x20] = { P(0,12), P(0,0), P(8,0), P(8,5), P(0,7), LAST },
+	['7' - 0x20] = { P(0,12), P(8,12), P(8,6), P(4,0), LAST },
+	['8' - 0x20] = { P(0,0), P(8,0), P(8,12), P(0,12), P(0,0), UP, P(0,6), P(8,6), LAST },
+	['9' - 0x20] = { P(8,0), P(8,12), P(0,12), P(0,7), P(8,5), LAST },
+};
+
+/** \file
+ * Asteroids simple font.
+ */
+#ifndef _asteroids_font_h_
+#define _asteroids_font_h_
+
+#include <stdint.h>
+
+typedef struct
+{
+	uint8_t points[8]; // 4 bits x, 4 bits y
+} asteroids_char_t;
+
+
+extern const asteroids_char_t asteroids_font[];
+
+
+#endif
 	sei();
 
 	draw_char_big( 0+cx, cy, h / 10 + '0');
-	draw_char_big(16+cx, cy, h % 10 + '0');
+	draw_char_big(20+cx, cy, h % 10 + '0');
 	draw_char_big(40+cx, cy, m / 10 + '0');
-	draw_char_big(56+cx, cy, m % 10 + '0');
+	draw_char_big(60+cx, cy, m % 10 + '0');
 	draw_char_big(80+cx, cy, s / 10 + '0');
-	draw_char_big(96+cx, cy, s % 10 + '0');
+	draw_char_big(100+cx, cy, s % 10 + '0');
 }
 
 
 	const uint8_t cy = 64;
 
 	draw_char_big( 0+cx, cy, h / 10 + '0');
-	draw_char_big(25+cx, cy, h % 10 + '0');
-	draw_char_big(50+cx, cy, m / 10 + '0');
-	draw_char_big(75+cx, cy, m % 10 + '0');
-	draw_char_big(100+cx, cy, s / 10 + '0');
-	draw_char_big(125+cx, cy, s % 10 + '0');
+	draw_char_big(32+cx, cy, h % 10 + '0');
+	draw_char_big(64+cx, cy, m / 10 + '0');
+	draw_char_big(96+cx, cy, m % 10 + '0');
+	draw_char_big(128+cx, cy, s / 10 + '0');
+	draw_char_big(160+cx, cy, s % 10 + '0');
 
 	draw_str(85, 190, "Future");
 	draw_str(120, 160, "Crew!");
 #include "usb_serial.h"
 #include "bits.h"
 #include "hershey.h"
+#include "asteroids-font.h"
 #include "sin_table.h"
 
 
 	const uint8_t scale
 )
 {
-	const hershey_char_t * p = &hershey_simplex[c - 0x20];
-	const uint8_t count = pgm_read_byte(&p->count);
-
 	uint8_t ox = x;
 	uint8_t oy = y;
 	uint8_t pen_down = 0;
 
+#ifdef CONFIG_HERSHEY
+	const hershey_char_t * p = &hershey_simplex[c - 0x20];
+	const uint8_t count = pgm_read_byte(&p->count);
+
 	for (uint8_t i = 0 ; i < count ; i++)
 	{
 		const int8_t px = pgm_read_byte(&p->points[i*2+0]);
 
 	const uint8_t width = pgm_read_byte(&p->width);
 	return scaling(width, scale);
+#else
+	const asteroids_char_t * const p = &asteroids_font[c - 0x20];
+	for (uint8_t i = 0 ; i < 8 ; i++)
+	{
+		const uint8_t xy = pgm_read_byte(&p->points[i]);
+		if (xy == 0xFF)
+			break;
+		if (xy == 0xFE)
+		{
+			pen_down = 0;
+			continue;
+		}
+
+		const int8_t px = ((xy >> 4) & 0xF) * 2;
+		const int8_t py = ((xy >> 0) & 0xF) * 2;
+		const uint8_t nx = x + scaling(px, scale);
+		const uint8_t ny = y + scaling(py, scale);
+
+		if (pen_down)
+			line(ox, oy, nx, ny);
+
+		pen_down = 1;
+		ox = nx;
+		oy = ny;
+	}
+
+	return 16;
+#endif
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.